This commit is contained in:
JeeLowCode
2024-12-31 17:22:40 +08:00
parent 2b7d95c86c
commit 718a00da8b
1891 changed files with 154772 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,85 @@
/*
Navicat Premium Data Transfer
Source Server : 内网-root
Source Server Type : MySQL
Source Server Version : 80022
Source Host : 192.168.5.120:3306
Source Schema : db_jeelowcodelog
Target Server Type : MySQL
Target Server Version : 80022
File Encoding : 65001
Date: 31/12/2024 13:48:13
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for lowcode_log_api
-- ----------------------------
DROP TABLE IF EXISTS `lowcode_log_api`;
CREATE TABLE `lowcode_log_api` (
`id` bigint(0) NOT NULL COMMENT '编号',
`tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT '租户ID',
`create_user` bigint(0) NULL DEFAULT NULL COMMENT '创建者',
`create_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人名称',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`create_dept` bigint(0) NULL DEFAULT NULL COMMENT '创建部门',
`update_user` bigint(0) NULL DEFAULT NULL COMMENT '更新者',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`is_deleted` int(0) NULL DEFAULT 0 COMMENT '是否已删除',
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '请求标题',
`model_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '模块标题',
`request_uri` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '请求地址',
`request_method` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '请求方式',
`request_params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '请求参数',
`ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作IP地址',
`method_class` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '方法类',
`method_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '方法名',
`time` bigint(0) NULL DEFAULT NULL COMMENT '执行时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `ind_create_time`(`create_time`) USING BTREE,
INDEX `ind_time`(`time`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '请求日志表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of lowcode_log_api
-- ----------------------------
-- ----------------------------
-- Table structure for lowcode_log_api_error
-- ----------------------------
DROP TABLE IF EXISTS `lowcode_log_api_error`;
CREATE TABLE `lowcode_log_api_error` (
`id` bigint(0) NOT NULL COMMENT '编号',
`tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT '租户ID',
`create_user` bigint(0) NULL DEFAULT NULL COMMENT '创建者',
`create_user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人名称',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`create_dept` bigint(0) NULL DEFAULT NULL COMMENT '创建部门',
`update_user` bigint(0) NULL DEFAULT NULL COMMENT '更新者',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`is_deleted` int(0) NULL DEFAULT 0 COMMENT '是否已删除',
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '请求标题',
`model_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '模块标题',
`request_uri` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '请求地址',
`request_method` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '请求方式',
`request_params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '请求参数',
`ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作IP地址',
`method_class` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '方法类',
`method_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '方法名',
`time` bigint(0) NULL DEFAULT NULL COMMENT '执行时间',
`error` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '错误原因',
PRIMARY KEY (`id`) USING BTREE,
INDEX `ind_create_time`(`create_time`) USING BTREE,
INDEX `ind_time`(`time`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '请求错误日志表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of lowcode_log_api_error
-- ----------------------------
SET FOREIGN_KEY_CHECKS = 1;

2
doc/sql/mysql/说明.txt Normal file
View File

@@ -0,0 +1,2 @@
db_jeelowcode.sql ->主数据库
db_jeelowcodelog.sql -> 日志数据库

View File

@@ -0,0 +1,5 @@
基于 Vue3 + element-plus +Avue 实现的管理后台。仓库地址:
* Gitee<https://gitee.com/jeelowecode/jeelowcode-ui-admin-vue3>
* GitHub<https://github.com/jeelowcode/jeelowcode-ui-admin-vue3>
* GitCode<https://gitcode.com/jeelowcode/jeelowcode-ui-admin-vue3>

View File

@@ -0,0 +1,23 @@
## AdoptOpenJDK 停止发布 OpenJDK 二进制,而 Eclipse Temurin 是它的延伸,提供更好的稳定性
## 感谢复旦核博士的建议!灰子哥,牛皮!
FROM eclipse-temurin:8-jre
## 创建目录,并使用它作为工作目录
RUN mkdir -p /yudao-server
WORKDIR /yudao-server
## 将后端项目的 Jar 文件,复制到镜像中
COPY ./target/yudao-server.jar app.jar
## 设置 TZ 时区
ENV TZ=Asia/Shanghai
## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖
ENV JAVA_OPTS="-Xms512m -Xmx512m -Djava.security.egd=file:/dev/./urandom"
## 应用参数
ENV ARGS=""
## 暴露后端项目的 48080 端口
EXPOSE 48080
## 启动后端项目
CMD java ${JAVA_OPTS} -jar app.jar $ARGS

80
jeelowcode-admin/pom.xml Normal file
View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.jeelowcode</groupId>
<artifactId>jeelowcode</artifactId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jeelowcode-admin</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description> 低代码启动器 </description>
<dependencies>
<!-- 系统模块 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-system-biz</artifactId>
<version>${revision}</version>
</dependency>
<!-- 代码生成器、接口文档 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-infra-biz</artifactId>
<version>${revision}</version>
</dependency>
<!-- 工作流服务 暂时关闭 后面用到再打开 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-bpm-biz</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!-- 服务保障相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-protection</artifactId>
</dependency>
<!-- 低代码服务 -->
<dependency>
<groupId>com.jeelowcode</groupId>
<artifactId>jeelowcode-module-biz</artifactId>
</dependency>
</dependencies>
<build>
<!-- 设置构建的 jar 包名 -->
<finalName>${project.artifactId}</finalName>
<plugins>
<!-- 打包 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal> <!-- 将引入的 jar 打入其中 -->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,40 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.server;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* 项目的启动类
*/
@MapperScan("${jeelowcode.info.base-package}.**.mapper.**") //低代码平台
@SuppressWarnings("SpringComponentScan")
@SpringBootApplication(scanBasePackages = {
"${yudao.info.base-package}.server",
"${yudao.info.base-package}.module",
"${jeelowcode.info.base-package}.module",
"${jeelowcode.info.base-package}.core",//核心模块
"${jeelowcode.info.base-package}.**.spring"
})
public class JeeLowCodeApplication {
public static void main(String[] args) {
SpringApplication.run(JeeLowCodeApplication.class, args);
}
}

View File

@@ -0,0 +1,67 @@
server:
port: 48080
--- #################### 数据库相关配置 ####################
spring:
datasource:
dynamic: # 多数据源配置
primary: master
datasource:
master:
# MYSQL数据库
name: db_jeelowcode
url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
username: root
password: 123456
slave: # 日志库单独
name: db_jeelowcodelog
lazy: true # 开启懒加载,保证启动速度
url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
username: root
password: 123456
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
redis:
host: 127.0.0.1 # 地址
port: 6379 # 端口
database: 9 # 数据库索引
# password: 123456 # 密码,建议生产环境开启
--- #################### 芋道相关配置 ####################
# 芋道配置项,设置当前项目所有自定义的配置
yudao:
captcha:
enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试;
security:
mock-enable: true
permit-all-urls:
- /admin-api/jeelowcode/open/** # 低代码平台,不需要登
- /admin-api/jeelowcode/demo/**
xss:
enable: false
exclude-urls: # 如下两个 url仅仅是为了演示去掉配置也没关系
- ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求
- ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求
access-log: # 访问日志的配置项
enable: false
error-code: # 错误码相关配置项
enable: false
demo: false # 关闭演示模式
tencent-lbs-key: TVDBZ-TDILD-4ON4B-PFDZA-RNLKH-VVF6E # QQ 地图的密钥 https://lbs.qq.com/service/staticV2/staticGuide/staticDoc
--- #################### 地代码平台相关配置 ####################
jeelowcode:
excludeTableNames: #不允许该类型的表开头
- lowcode_
- qrtz_
- system_
- act_
- bpm_
- flw_
- infra_
debug: true #是否开启调试模式
#AES加解密 key 重新生成AesUtil.genAesKey()
aesKey: O2BEeIv399qHQNhD6aGW8R8DEj4bqHXm
#JAVA增强生成文件地址
enhancePath: jeelowcode-module\jeelowcode-module-biz\src\main\java\com\jeelowcode\module\biz\enhance

View File

@@ -0,0 +1,70 @@
server:
port: 48080
--- #################### 数据库相关配置 ####################
spring:
datasource:
dynamic: # 多数据源配置
primary: master
datasource:
master:
# MYSQL数据库
name: db_jeelowcode
url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例
username: root
password: 123456
slave: # 日志库单独
name: db_jeelowcodelog
lazy: true # 开启懒加载,保证启动速度
url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
username: root
password: 123456
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
redis:
host: 127.0.0.1 # 地址
port: 6379 # 端口
database: 9 # 数据库索引
# password: 123456 # 密码,建议生产环境开启
logging:
file:
name: /data/mjkj/webapp/mjkj_jeelowcode/webapp/logs/${spring.application.name}.log # 日志文件名,全路径
--- #################### 芋道相关配置 ####################
# 芋道配置项,设置当前项目所有自定义的配置
yudao:
captcha:
enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试;
security:
mock-enable: true
permit-all-urls:
- /admin-api/jeelowcode/open/** # 低代码平台,不需要登
- /admin-api/jeelowcode/demo/**
xss:
enable: false
exclude-urls: # 如下两个 url仅仅是为了演示去掉配置也没关系
- ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求
- ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求
access-log: # 访问日志的配置项
enable: false
error-code: # 错误码相关配置项
enable: false
demo: false # 关闭演示模式
tencent-lbs-key: TVDBZ-TDILD-4ON4B-PFDZA-RNLKH-VVF6E # QQ 地图的密钥 https://lbs.qq.com/service/staticV2/staticGuide/staticDoc
--- #################### 低代码平台相关配置 ####################
jeelowcode:
excludeTableNames: #不允许该类型的表开头
- lowcode_
- qrtz_
- system_
- act_
- bpm_
- flw_
- infra_
debug: true #是否开启调试模式
#AES加解密 key 重新生成AesUtil.genAesKey()
aesKey: O2BEeIv399qHQNhD6aGW8R8DEj4bqHXm
#JAVA增强生成文件地址(正式环境没有用到)
enhancePath: ''

View File

@@ -0,0 +1,453 @@
spring:
application:
name: jeelowcode-server
profiles:
active: local
main:
allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。
# Servlet 配置
servlet:
# 文件上传相关配置项
multipart:
max-file-size: 16MB # 单个文件大小
max-request-size: 32MB # 设置总上传的文件大小
mvc:
pathmatch:
matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类
# throw-exception-if-no-handler-found: true # 404 错误时抛出异常,方便统一处理
# static-path-pattern: /static/** # 静态资源路径; 注意:如果不配置,则 throw-exception-if-no-handler-found 不生效!!! TODO 芋艿:不能配置,会导致 swagger 不生效
# Jackson 配置项
jackson:
serialization:
write-dates-as-timestamps: true # 设置 Date 的格式,使用时间戳
write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401
write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳
fail-on-empty-beans: false # 允许序列化无属性的 Bean
# Cache 配置项
cache:
type: REDIS
redis:
time-to-live: 1h # 设置过期时间为 1 小时
--- #################### 接口文档配置 ####################
springdoc:
api-docs:
enabled: true
path: /v3/api-docs
swagger-ui:
enabled: true
path: /swagger-ui
default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档
knife4j:
enable: true
setting:
language: zh_cn
# 工作流 Flowable 配置
flowable:
# 1. false: 默认值Flowable 启动时,对比数据库表中保存的版本,如果不匹配。将抛出异常
# 2. true: 启动时会对数据库中所有表进行更新操作,如果表存在,不做处理,反之,自动创建表
# 3. create_drop: 启动时自动创建表,关闭时自动删除表
# 4. drop_create: 启动时,删除旧表,再创建新表
database-schema-update: true # 设置为 false可通过 https://github.com/flowable/flowable-sql 初始化
db-history-used: true # flowable6 默认 true 生成信息表,无需手动设置
check-process-definitions: false # 设置为 false禁用 /resources/processes 自动部署 BPMN XML 流程
history-level: full # full保存历史数据的最高级别可保存全部流程相关细节包括流程流转各节点参数
# MyBatis Plus 的配置项
mybatis-plus:
configuration:
map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。
jdbc-type-for-null: 'null'
global-config:
db-config:
id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。
# id-type: AUTO # 自增 ID适合 MySQL 等直接自增的数据库
# id-type: INPUT # 用户输入 ID适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库
# id-type: ASSIGN_ID # 分配 ID默认使用雪花算法。注意Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
banner: false # 关闭控制台的 Banner 打印
type-aliases-package: ${yudao.info.base-package}.module.*.dal.dataobject,${yudao.info.base-package}.module.**.mapper.*Mapper
encryptor:
password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成
mybatis-plus-join:
banner: false # 是否打印 mybatis plus join banner默认true
sub-table-logic: true # 全局启用副表逻辑删除默认true。关闭后关联查询不会加副表逻辑删除
ms-cache: true # 拦截器MappedStatement缓存默认 true
table-alias: t # 表别名(默认 t)
logic-del-type: on # 副表逻辑删除条件的位置,支持 WHERE、ON默认 ON
# Spring Data Redis 配置
spring:
data:
redis:
repositories:
enabled: false # 项目未使用到 Spring Data Redis 的 Repository所以直接禁用保证启动速度
--- #################### 数据库相关配置 ####################
spring:
mvc:
servlet:
load-on-startup: 10
# 数据源配置项
autoconfigure:
exclude:
# - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源
# - org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration # 默认 local 环境,不开启 Quartz 的自动配置
# - de.codecentric.boot.admin.server.config.AdminServerAutoConfiguration # 禁用 Spring Boot Admin 的 Server 的自动配置
# - de.codecentric.boot.admin.server.ui.config.AdminServerUiAutoConfiguration # 禁用 Spring Boot Admin 的 Server UI 的自动配置
# - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置
datasource:
druid: # Druid 【监控】相关的全局配置
web-stat-filter:
enabled: true
stat-view-servlet:
enabled: true
allow: # 设置白名单,不填则允许所有访问
url-pattern: /druid/*
login-username: # 控制台管理用户名和密码
login-password:
filter:
stat:
enabled: true
log-slow-sql: true # 慢 SQL 记录
slow-sql-millis: 100
merge-sql: true
wall:
config:
multi-statement-allow: true
dynamic: # 多数据源配置
druid: # Druid 【连接池】相关的全局配置
initial-size: 10 # 初始连接数
min-idle: 20 # 最小连接池数量
max-active: 100 # 最大连接池数量
max-wait: 60000 # 配置获取连接等待超时的时间,单位:毫秒
time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒
min-evictable-idle-time-millis: 7200000 # 配置一个连接在池中最小生存的时间,单位:毫秒
max-evictable-idle-time-millis: 25200000 # 配置一个连接在池中最大生存的时间,单位:毫秒
#validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效
test-while-idle: true
test-on-borrow: false
test-on-return: false
socket-timeout: 60000 # socket超时时间单位毫秒
connect-timeout: 60000 # 建立数据库连接超时时间,单位:毫秒
--- #################### 定时任务相关配置 ####################
# Quartz 配置项,对应 QuartzProperties 配置类
spring:
quartz:
auto-startup: true # 本地开发环境,尽量不要开启 Job
scheduler-name: schedulerName # Scheduler 名字。默认为 schedulerName
job-store-type: jdbc # Job 存储器类型。默认为 memory 表示内存,可选 jdbc 使用数据库。
wait-for-jobs-to-complete-on-shutdown: true # 应用关闭时,是否等待定时任务执行完成。默认为 false ,建议设置为 true
properties: # 添加 Quartz Scheduler 附加属性,更多可以看 http://www.quartz-scheduler.org/documentation/2.4.0-SNAPSHOT/configuration.html 文档
org:
quartz:
# Scheduler 相关配置
scheduler:
instanceName: schedulerName
instanceId: AUTO # 自动生成 instance ID
# JobStore 相关配置
jobStore:
# JobStore 实现类。可见博客https://blog.csdn.net/weixin_42458219/article/details/122247162
class: org.springframework.scheduling.quartz.LocalDataSourceJobStore
isClustered: true # 是集群模式
clusterCheckinInterval: 15000 # 集群检查频率,单位:毫秒。默认为 15000即 15 秒
misfireThreshold: 60000 # misfire 阀值,单位:毫秒。
# 线程池相关配置
threadPool:
threadCount: 25 # 线程池大小。默认为 10 。
threadPriority: 5 # 线程优先级
class: org.quartz.simpl.SimpleThreadPool # 线程池类型
jdbc: # 使用 JDBC 的 JobStore 的时候JDBC 的配置
initialize-schema: NEVER # 是否自动使用 SQL 初始化 Quartz 表结构。这里设置成 never ,我们手动创建表结构。
--- #################### 监控相关配置 ####################
# Lock4j 配置项
lock4j:
acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒
expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒
# Resilience4j 配置项
resilience4j:
ratelimiter:
instances:
backendA:
limit-for-period: 1 # 每个周期内,允许的请求数。默认为 50
limit-refresh-period: 60s # 每个周期的时长,单位:微秒。默认为 500
timeout-duration: 1s # 被限流时,阻塞等待的时长,单位:微秒。默认为 5s
register-health-indicator: true # 是否注册到健康监测
# Actuator 监控端点的配置项
management:
endpoints:
web:
base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator
exposure:
include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
# Spring Boot Admin 配置项
spring:
boot:
admin:
# Spring Boot Admin Client 客户端的相关配置
client:
url: http://127.0.0.1:${server.port}/${spring.boot.admin.context-path} # 设置 Spring Boot Admin Server 地址
instance:
service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME]
# Spring Boot Admin Server 服务端的相关配置
context-path: /admin # 配置 Spring
# 日志文件配置
logging:
file:
name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径
level:
# 配置自己写的 MyBatis Mapper 打印日志
cn.iocoder.yudao.module.bpm.dal.mysql: debug
cn.iocoder.yudao.module.infra.dal.mysql: debug
cn.iocoder.yudao.module.infra.dal.mysql.job.JobLogMapper: INFO # 配置 JobLogMapper 的日志级别为 info
cn.iocoder.yudao.module.infra.dal.mysql.file.FileConfigMapper: INFO # 配置 FileConfigMapper 的日志级别为 info
cn.iocoder.yudao.module.system.dal.mysql: debug
cn.iocoder.yudao.module.system.dal.mysql.sensitiveword.SensitiveWordMapper: INFO # 配置 SensitiveWordMapper 的日志级别为 info
cn.iocoder.yudao.module.system.dal.mysql.sms.SmsChannelMapper: INFO # 配置 SmsChannelMapper 的日志级别为 info
cn.iocoder.yudao.module.tool.dal.mysql: debug
cn.iocoder.yudao.module.member.dal.mysql: debug
cn.iocoder.yudao.module.trade.dal.mysql: debug
cn.iocoder.yudao.module.promotion.dal.mysql: debug
cn.iocoder.yudao.module.statistics.dal.mysql: debug
cn.iocoder.yudao.module.crm.dal.mysql: debug
cn.iocoder.yudao.module.erp.dal.mysql: debug
cn.iocoder.yudao.module.jeelowcode.mapper: debug #低代码平台
org.springframework.context.support.PostProcessorRegistrationDelegate: ERROR # TODO 芋艿先禁用Spring Boot 3.X 存在部分错误的 WARN 提示
com.jeelowcode.core: debug
com.jeelowcode.module: debug
com.jeelowcode.core.framework.mapper.LogApiMapper: ERROR #日志入库不需要打印
com.jeelowcode.core.framework.mapper.LogApiErrorMapper: ERROR #日志入库不需要打印
cn.iocoder.yudao.module.system.dal.mysql.logger.OperateLogMapper: ERROR #日志入库不需要打印
debug: false
--- #################### 验证码相关配置 ####################
aj:
captcha:
jigsaw: classpath:images/jigsaw # 滑动验证,底图路径,不配置将使用默认图片;以 classpath: 开头,取 resource 目录下路径
pic-click: classpath:images/pic-click # 滑动验证,底图路径,不配置将使用默认图片;以 classpath: 开头,取 resource 目录下路径
cache-type: redis # 缓存 local/redis...
cache-number: 1000 # local 缓存的阈值,达到这个值,清除缓存
timing-clear: 180 # local定时清除过期缓存(单位秒),设置为0代表不执行
type: blockPuzzle # 验证码类型 default两种都实例化。 blockPuzzle 滑块拼图 clickWord 文字点选
water-mark: JeeLowCode # 右下角水印文字(我的水印),可使用 https://tool.chinaz.com/tools/unicode.aspx 中文转 UnicodeLinux 可能需要转 unicode
interference-options: 0 # 滑动干扰项(0/1/2)
req-frequency-limit-enable: false # 接口请求次数一分钟限制是否开启 true|false
req-get-lock-limit: 5 # 验证失败 5 次get接口锁定
req-get-lock-seconds: 10 # 验证失败后,锁定时间间隔
req-get-minute-limit: 30 # get 接口一分钟内请求数限制
req-check-minute-limit: 60 # check 接口一分钟内请求数限制
req-verify-minute-limit: 60 # verify 接口一分钟内请求数限制
--- #################### 消息队列相关 ####################
# rocketmq 配置项,对应 RocketMQProperties 配置类
rocketmq:
name-server: 127.0.0.1:9876 # RocketMQ Namesrv
# Producer 配置项
producer:
group: ${spring.application.name}_PRODUCER # 生产者分组
spring:
rabbitmq:
host: 127.0.0.1 # RabbitMQ 服务的地址
port: 5672 # RabbitMQ 服务的端口
username: rabbit # RabbitMQ 服务的账号
password: rabbit # RabbitMQ 服务的密码
# Kafka 配置项,对应 KafkaProperties 配置类
kafka:
bootstrap-servers: 127.0.0.1:9092 # 指定 Kafka Broker 地址,可以设置多个,以逗号分隔
# Kafka Producer 配置项
producer:
acks: 1 # 0-不应答。1-leader 应答。all-所有 leader 和 follower 应答。
retries: 3 # 发送失败时,重试发送的次数
value-serializer: org.springframework.kafka.support.serializer.JsonSerializer # 消息的 value 的序列化
# Kafka Consumer 配置项
consumer:
auto-offset-reset: earliest # 设置消费者分组最初的消费进度为 earliest 。可参考博客 https://blog.csdn.net/lishuangzhe7047/article/details/74530417 理解
value-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer
properties:
spring.json.trusted.packages: '*'
# Kafka Consumer Listener 监听器配置
listener:
missing-topics-fatal: false # 消费监听接口监听的主题不存在时,默认会报错。所以通过设置为 false ,解决报错
--- #################### 第三方授权登录 ####################
justauth:
enabled: true
type:
DINGTALK: # 钉钉
client-id: dingvrnreaje3yqvzhxg
client-secret: i8E6iZyDvZj51JIb0tYsYfVQYOks9Cq1lgryEjFRqC79P3iJcrxEwT6Qk2QvLrLI
ignore-check-redirect-uri: true
WECHAT_ENTERPRISE: # 企业微信
client-id: wwd411c69a39ad2e54
client-secret: 1wTb7hYxnpT2TUbIeHGXGo7T0odav1ic10mLdyyATOw
agent-id: 1000004
ignore-check-redirect-uri: true
WECHAT_MINI_APP: # 微信小程序
client-id: ${wx.miniapp.appid}
client-secret: ${wx.miniapp.secret}
ignore-check-redirect-uri: true
ignore-check-state: true # 微信小程序,不会使用到 state所以不进行校验
WECHAT_MP: # 微信公众号
client-id: ${wx.mp.app-id}
client-secret: ${wx.mp.secret}
ignore-check-redirect-uri: true
cache:
type: REDIS
prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE::
timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟
--- #################### 微信公众号、小程序相关配置 ####################
wx:
mp: # 公众号配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档
app-id: wx5b23ba7a5589ecbb # 测试号(自己的)
secret: 2a7b3b20c537e52e74afd395eb85f61f
# 存储配置,解决 AccessToken 的跨节点的共享
config-storage:
type: RedisTemplate # 采用 RedisTemplate 操作 Redis会自动从 Spring 中获取
key-prefix: wx # Redis Key 的前缀
http-client-type: HttpClient # 采用 HttpClient 请求微信公众号平台
miniapp: # 小程序配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-miniapp-spring-boot-starter/README.md 文档
appid: wx63c280fe3248a3e7 # wenhualian的接口测试号
secret: 6f270509224a7ae1296bbf1c8cb97aed
config-storage:
type: RedisTemplate # 采用 RedisTemplate 操作 Redis会自动从 Spring 中获取
key-prefix: wa # Redis Key 的前缀
http-client-type: HttpClient # 采用 HttpClient 请求微信公众号平台
--- #################### 芋道相关配置 ####################
yudao:
info:
version: 1.0.0
base-package: cn.iocoder.yudao
web:
admin-ui:
url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址
security:
permit-all_urls:
- /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,不需要登录
websocket:
enable: true # websocket的开关
path: /infra/ws # 路径
sender-type: local # 消息发送的类型,可选值为 local、redis、rocketmq、kafka、rabbitmq
sender-rocketmq:
topic: ${spring.application.name}-websocket # 消息发送的 RocketMQ Topic
consumer-group: ${spring.application.name}-websocket-consumer # 消息发送的 RocketMQ Consumer Group
sender-rabbitmq:
exchange: ${spring.application.name}-websocket-exchange # 消息发送的 RabbitMQ Exchange
queue: ${spring.application.name}-websocket-queue # 消息发送的 RabbitMQ Queue
sender-kafka:
topic: ${spring.application.name}-websocket # 消息发送的 Kafka Topic
consumer-group: ${spring.application.name}-websocket-consumer # 消息发送的 Kafka Consumer Group
swagger:
title: JeeLowCode低代码开发平台
description: 提供管理后台、用户 App 的所有功能
version: ${yudao.info.version}
url: ${yudao.web.admin-ui.url}
captcha:
enable: true # 验证码的开关,默认为 true
codegen:
base-package: ${yudao.info.base-package}
db-schemas: ${spring.datasource.dynamic.datasource.master.name}
front-type: 10 # 前端模版的类型,参见 CodegenFrontTypeEnum 枚举类
error-code: # 错误码相关配置项
constants-class-list:
- cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants
- cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants
- cn.iocoder.yudao.module.member.enums.ErrorCodeConstants
- cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants
- cn.iocoder.yudao.module.system.enums.ErrorCodeConstants
- cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants
tenant: # 多租户相关配置项
enable: true
ignore-urls:
- /admin-api/system/tenant/get-id-by-name # 基于名字获取租户,不许带租户编号
- /admin-api/system/tenant/get-by-website # 基于域名获取租户,不许带租户编号
- /admin-api/system/captcha/get # 获取图片验证码,和租户无关
- /admin-api/system/captcha/check # 校验图片验证码,和租户无关
- /admin-api/infra/file/*/get/** # 获取图片,和租户无关
- /admin-api/system/sms/callback/* # 短信回调接口,无法带上租户编号
- /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,无法携带租户编号
- /admin-api/jeelowcode/** # 低代码平台的全部放开,有自己的一套租户 规则
ignore-tables:
- DUAL
- dual
- ALL_TABLES
- all_tables
- ALL_INDEXES
- all_indexes
- system_tenant
- system_tenant_package
- system_dict_data
- system_dict_type
- system_error_code
- system_menu
- system_sms_channel
- system_sms_template
- system_sms_log
- system_sensitive_word
- system_oauth2_client
- system_mail_account
- system_mail_template
- system_mail_log
- system_notify_template
- system_notify_message
- infra_codegen_column
- infra_codegen_table
- infra_test_demo
- infra_config
- infra_file_config
- infra_file
- infra_file_content
- infra_job
- infra_job_log
- infra_job_log
- infra_data_source_config
- rep_demo_dxtj
- rep_demo_employee
- rep_demo_gongsi
- rep_demo_jianpiao
- tmp_report_data_1
- tmp_report_data_income
- 'lowcode_config' #低代码开头的不要多租户
- 'lowcode_dbform*' #低代码开头的不要多租户
- 'lowcode_desform*' #低代码开头的不要多租户
- 'lowcode_report*' #低代码开头的不要多租户
- 'lowcode_log_*' #低代码开头的不要多租户
- '*_seq' #oracle自增主键等
- information_schema
sms-code: # 短信验证码相关的配置项
expire-times: 10m
send-frequency: 1m
send-maximum-quantity-per-day: 10
begin-code: 9999 # 这里配置 9999 的原因是,测试方便。
end-code: 9999 # 这里配置 9999 的原因是,测试方便。
debug: false
# -------------------jeeLowCode 低代码平台--------------------------
jeelowcode:
info:
version: 1.0.0
base-package: com.jeelowcode

View File

@@ -0,0 +1,76 @@
<configuration>
<!-- 引用 Spring Boot 的 logback 基础配置 -->
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<!-- 变量 yudao.info.base-package基础业务包 -->
<springProperty scope="context" name="yudao.info.base-package" source="yudao.info.base-package"/>
<!-- 格式化输出:%d 表示日期,%X{tid} SkWalking 链路追踪编号,%thread 表示线程名,%-5level级别从左显示 5 个字符宽度,%msg日志消息%n是换行符 -->
<property name="PATTERN_DEFAULT" value="%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} | %highlight(${LOG_LEVEL_PATTERN:-%5p} ${PID:- }) | %boldYellow(%thread [%tid]) %boldGreen(%-40.40logger{39}) | %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
<!-- 控制台 Appender -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">     
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
<pattern>${PATTERN_DEFAULT}</pattern>
</layout>
</encoder>
</appender>
<!-- 文件 Appender -->
<!-- 参考 Spring Boot 的 file-appender.xml 编写 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
<pattern>${PATTERN_DEFAULT}</pattern>
</layout>
</encoder>
<!-- 日志文件名 -->
<file>${LOG_FILE}</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- 滚动后的日志文件名 -->
<fileNamePattern>${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz}</fileNamePattern>
<!-- 启动服务时,是否清理历史日志,一般不建议清理 -->
<cleanHistoryOnStart>${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
<!-- 日志文件,到达多少容量,进行滚动 -->
<maxFileSize>${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB}</maxFileSize>
<!-- 日志文件的总大小0 表示不限制 -->
<totalSizeCap>${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0}</totalSizeCap>
<!-- 日志文件的保留天数 -->
<maxHistory>${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30}</maxHistory>
</rollingPolicy>
</appender>
<!-- 异步写入日志,提升性能 -->
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
<!-- 不丢失日志。默认的,如果队列的 80% 已满,则会丢弃 TRACT、DEBUG、INFO 级别的日志 -->
<discardingThreshold>0</discardingThreshold>
<!-- 更改默认的队列的深度,该值会影响性能。默认值为 256 -->
<queueSize>256</queueSize>
<appender-ref ref="FILE"/>
</appender>
<!-- SkyWalking GRPC 日志收集实现日志中心。注意SkyWalking 8.4.0 版本开始支持 -->
<appender name="GRPC" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
<pattern>${PATTERN_DEFAULT}</pattern>
</layout>
</encoder>
</appender>
<!-- 本地环境 -->
<springProfile name="local">
<root level="INFO">
<appender-ref ref="STDOUT"/>
<appender-ref ref="GRPC"/> <!-- 本地环境下,如果不想接入 SkyWalking 日志服务,可以注释掉本行 -->
<appender-ref ref="ASYNC"/> <!-- 本地环境下,如果不想打印日志,可以注释掉本行 -->
</root>
</springProfile>
<!-- 其它环境 -->
<springProfile name="dev,test,stage,prod,default">
<root level="INFO">
<appender-ref ref="STDOUT"/>
<appender-ref ref="ASYNC"/>
<appender-ref ref="GRPC"/>
</root>
</springProfile>
</configuration>

87
jeelowcode-core/pom.xml Normal file
View File

@@ -0,0 +1,87 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.jeelowcode</groupId>
<artifactId>jeelowcode</artifactId>
<version>${revision}</version>
</parent>
<groupId>com.jeelowcode</groupId>
<artifactId>jeelowcode-core</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<version>${jeelowcode.version}</version>
<description> JeeLowCode低代码核心代码 </description>
<dependencies>
<!-- Web 相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-web</artifactId>
</dependency>
<!-- 鉴权 相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-security</artifactId>
</dependency>
<!-- DB 相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-mybatis</artifactId>
</dependency>
<!-- redis 相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-redis</artifactId>
</dependency>
<!-- 租户 相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>
</dependency>
<!-- **************** jeelowcode低代码框架 **************** -->
<dependency>
<groupId>com.jeelowcode</groupId>
<artifactId>jeelowcode-excel</artifactId>
</dependency>
<dependency>
<groupId>com.jeelowcode</groupId>
<artifactId>jeelowcode-exception</artifactId>
</dependency>
<dependency>
<groupId>com.jeelowcode</groupId>
<artifactId>jeelowcode-plus</artifactId>
</dependency>
<dependency>
<groupId>com.jeelowcode</groupId>
<artifactId>jeelowcode-tenant</artifactId>
</dependency>
<dependency>
<groupId>com.jeelowcode</groupId>
<artifactId>jeelowcode-utils</artifactId>
</dependency>
<dependency>
<groupId>com.jeelowcode</groupId>
<artifactId>jeelowcode-global</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>QLExpress</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,491 @@
/* Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,允许商用使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与本软件竞争的软件。
最终解释权归http://www.jeelowcode.com*/
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,允许商用使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与本软件竞争的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.adapter;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.tenant.config.TenantProperties;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jeelowcode.core.framework.mapper.AdapterMapper;
import com.jeelowcode.core.framework.utils.Func;
import com.jeelowcode.core.framework.utils.FuncWeb;
import com.jeelowcode.framework.plus.SqlHelper;
import com.jeelowcode.framework.plus.build.buildmodel.wrapper.SqlInfoQueryWrapper;
import com.jeelowcode.framework.utils.adapter.IJeeLowCodeAdapter;
import com.jeelowcode.framework.utils.enums.DefaultDbFieldEnum;
import com.jeelowcode.framework.utils.model.*;
import com.jeelowcode.framework.utils.params.JeeLowCodeDeptParam;
import com.jeelowcode.framework.utils.params.JeeLowCodeDictParam;
import com.jeelowcode.framework.utils.params.JeeLowCodeUserParam;
import com.jeelowcode.framework.utils.utils.FuncBase;
import com.jeelowcode.framework.utils.utils.JeeLowCodeUtils;
import com.jeelowcode.core.framework.service.IFrameSqlService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;
/**
* 芋道源码适配器
*/
@Service
@Slf4j
public class YudaoAdapter implements IJeeLowCodeAdapter {
@Autowired
private IFrameSqlService sqlService;
@Autowired
private TenantProperties tenantProperties;
@Autowired
private AdapterMapper adapterMapper;
//获取当前在线人id
@Override
public String getOnlineUserId() {
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
return FuncBase.toStr(loginUserId);
}
//获取当前在线人账号
@Override
public String getOnlineUserName() {
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
String userName = adapterMapper.getUserName(loginUserId);
return userName;
}
@Override
public String getOnlineUserNickName() {
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
return adapterMapper.getNickname(loginUserId);
}
@Override
public String getOnlineUserDeptId() {
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
Long deptId = adapterMapper.getDeptId(loginUserId);
return Func.toStr(deptId);
}
//获取当前在线人id
@Override
public String getTenantId() {
//当前线程
Long tenantId = TenantContextHolder.getTenantId();
if (Func.isNotEmpty(tenantId) && tenantId > 0) {
return FuncBase.toStr(tenantId);
}
//当前线程没有租户信息,则从登录用户获取
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
if (FuncBase.isNotEmpty(loginUser)) {
tenantId = loginUser.getTenantId();
return FuncBase.toStr(tenantId);
}
return "-1";
}
//获取部门id
@Override
public Long getDeptId(Long userId){
Long deptId = adapterMapper.getDeptId(userId);
return deptId;
}
//判断请求是否排除多租户
@Override
public boolean getTenantIsIgnore() {
HttpServletRequest request = FuncWeb.getRequest();
if (!Func.isJeeLowCodeUrl(request)) {//低代码平台有自己一套租户逻辑
return false;
}
boolean ignore = TenantContextHolder.isIgnore();
return ignore;
}
//获取所有租户列表
@Override
public List<JeeLowTenant> getTenantList() {
List<String> selectList = new ArrayList<>();
selectList.add("id");
selectList.add("name");
SqlInfoQueryWrapper.Wrapper wrapper = SqlHelper.getQueryWrapper()
.setTableName("system_tenant")
.select(selectList, true)
.setWhere(where -> {
where.eq("deleted", 0);
where.eq("status", 0);
}).build();
List<Map<String, Object>> tenantList = sqlService.getDataListByPlus(wrapper);
return tenantList.stream()
.map(tenantMap -> {
String id = JeeLowCodeUtils.getMap2Str(tenantMap, "id");
String name = JeeLowCodeUtils.getMap2Str(tenantMap, "name");
JeeLowTenant jeeLowTenant = new JeeLowTenant();
jeeLowTenant.setTenantId(id);
jeeLowTenant.setTenantName(name);
return jeeLowTenant;
})
.collect(Collectors.toList());
}
//获取字典列表
@Override
public List<JeeLowCodeDict> getDictList(JeeLowCodeDictParam param) {
List<JeeLowCodeDict> resultList = new ArrayList<>();
List<String> dictCodeList = param.getDictCodeList();
Map<String, JeeLowCodeDictParam.DictCodeDataParam> paramMap = FuncBase.isEmpty(param.getParamMap()) ? new HashMap<>() : param.getParamMap();
SqlInfoQueryWrapper.Wrapper wrapper = SqlHelper.getQueryWrapper()
.setTableName("system_dict_type")
.setWhere(where -> {
where.eq("deleted", 0);
where.eq("status", 0);
where.in("type", dictCodeList);
}).build();
List<Map<String, Object>> typeList = sqlService.getDataListByPlus(wrapper);
typeList.stream()
.map(typeMap -> {
String code = JeeLowCodeUtils.getMap2Str(typeMap, "type");
JeeLowCodeDictParam.DictCodeDataParam dictCodeDataParam = paramMap.get(code);
List<String> dictDataLabelList = FuncBase.isNotEmpty(dictCodeDataParam) ? dictCodeDataParam.getDictDataLabelList() : Collections.emptyList();
List<String> dictDataValueList = FuncBase.isNotEmpty(dictCodeDataParam) ? dictCodeDataParam.getDictDataValueList() : Collections.emptyList();
SqlInfoQueryWrapper.Wrapper wrapperData = SqlHelper.getQueryWrapper()
.setTableName("system_dict_data")
.select("value", "label")
.setWhere(where -> {
where.eq("deleted", 0);
where.eq("status", 0);
where.eq("dict_type", code);
where.in("label", dictDataLabelList);
where.in("value", dictDataValueList);
})
.orderByAsc("sort")
.build();
List<Map<String, Object>> dataList = sqlService.getDataListByPlus(wrapperData);
List<JeeLowCodeDict.DictData> list = dataList.stream()
.map(tmpMap -> {
String value = JeeLowCodeUtils.getMap2Str(tmpMap, "value");
String label = JeeLowCodeUtils.getMap2Str(tmpMap, "label");
JeeLowCodeDict.DictData data = new JeeLowCodeDict.DictData();
data.setLabel(label);
data.setVal(value);
return data;
})
.collect(Collectors.toList());
JeeLowCodeDict dict = new JeeLowCodeDict();
dict.setDataList(list);
dict.setDictCode(code);
return dict;
})
.forEach(resultList::add);
return resultList;
}
//获取部门列表
@Override
public List<JeeLowCodeDept> getDeptList(JeeLowCodeDeptParam param) {
String deptName = param.getDeptName();//部门名称搜索
String type = Func.isEmpty(param.getType()) ? "all" : param.getType();
List<Long> deptIdList = new ArrayList<>();//部门id列表,为空则查所有
if (Func.equals(type, "now")) {//本级
String onlineUserDeptId = this.getOnlineUserDeptId();
deptIdList.add(Func.toLong(onlineUserDeptId));
} else if (Func.equals(type, "sub")) {//本级以及下级
String onlineUserDeptId = this.getOnlineUserDeptId();
deptIdList = this.getChildDeptIdList(Func.toLong(onlineUserDeptId));
}
List<Long> finalDeptIdList = deptIdList;
SqlInfoQueryWrapper.Wrapper wrapper = SqlHelper.getQueryWrapper()
.select("id", "parent_id", "name")
.setTableName("system_dept")
.setWhere(where -> {
where.in(Func.isNotEmpty(finalDeptIdList), "id", finalDeptIdList);
where.like(FuncBase.isNotEmpty(deptName), "name", deptName);
where.eq("deleted", 0);
})
.orderByAsc("sort")
.build();
List<Map<String, Object>> deptList = sqlService.getDataListByPlus(wrapper);
List<JeeLowCodeDept> resultList = deptList.stream()
.map(deptMap -> {
String id = JeeLowCodeUtils.getMap2Str(deptMap, "id");
String pid = JeeLowCodeUtils.getMap2Str(deptMap, "parent_id");
String name = JeeLowCodeUtils.getMap2Str(deptMap, "name");
JeeLowCodeDept dept = new JeeLowCodeDept();
dept.setDeptId(id);
dept.setDeptPid(pid);
dept.setDeptName(name);
return dept;
})
.collect(Collectors.toList());
return resultList;
}
//获取所有角色列表
@Override
public List<JeeLowCodeRole> getRoleList() {
Long tenantId = TenantContextHolder.getTenantId();
SqlInfoQueryWrapper.Wrapper wrapper = SqlHelper.getQueryWrapper()
.select("id", "name")
.setTableName("system_role")
.setWhere(where -> {
where.in("deleted", 0);
where.eq("tenant_id", tenantId);
})
.orderByAsc("sort")
.build();
List<Map<String, Object>> roleList = sqlService.getDataListByPlus(wrapper);
List<JeeLowCodeRole> resultList = roleList.stream()
.map(roleMap -> {
String id = JeeLowCodeUtils.getMap2Str(roleMap, "id");
String name = JeeLowCodeUtils.getMap2Str(roleMap, "name");
JeeLowCodeRole role = new JeeLowCodeRole();
role.setRoleId(id);
role.setRoleName(name);
return role;
})
.collect(Collectors.toList());
return resultList;
}
//回显用户
@Override
public List<Map<String, Object>> getUserViewList(List<Long> userIdList) {
SqlInfoQueryWrapper.Wrapper wrapper = SqlHelper.getQueryWrapper()
.select("id", "nickname")
.setTableName("system_users")
.setWhere(where -> {
where.in("id", userIdList);
})
.build();
List<Map<String, Object>> dataList = sqlService.getDataListByPlus(wrapper);
return dataList;
}
//回显部门
@Override
public List<Map<String, Object>> getDeptViewList(List<Long> deptIdList) {
SqlInfoQueryWrapper.Wrapper wrapper = SqlHelper.getQueryWrapper()
.select("id", "name")
.setTableName("system_dept")
.setWhere(where -> {
where.in("id", deptIdList);
})
.build();
List<Map<String, Object>> dataList = sqlService.getDataListByPlus(wrapper);
return dataList;
}
//获取用户分页列表
@Override
public Object getUserPage(Integer pageNo, Integer pageSize, JeeLowCodeUserParam param) {
Page page = FuncWeb.getPage(pageNo, pageSize);
Long deptId = param.getDeptId();
Long roleId = param.getRoleId();
String type = param.getType();//all now sub
String nickName = param.getNickName();
String mobile = param.getMobile();
List<String> fieldList = param.getFieldList();
List<Long> deptIdList = new ArrayList<>();//部门id列表
if (Func.isEmpty(deptId)) {//部门为空的时候type才生效
if (Func.equals(type, "now")) {//本级
String onlineUserDeptId = this.getOnlineUserDeptId();
deptIdList.add(Func.toLong(onlineUserDeptId));
} else if (Func.equals(type, "sub")) {//本级以及下级
String onlineUserDeptId = this.getOnlineUserDeptId();
deptIdList = this.getChildDeptIdList(Func.toLong(onlineUserDeptId));
}
} else {//指定部门
deptIdList.add(deptId);
}
Map<String, Object> params = new HashMap<>();
params.put("nickName", nickName);
params.put("mobile", mobile);
IPage<JeeLowCodeUser> pages = null;
if (Func.isNotEmpty(roleId)) {//说明有选择了角色
pages = adapterMapper.getUserPageByRoleId(getTenantId(),page, roleId, deptIdList, params);
} else {
pages = adapterMapper.getUserPageByDeptId(getTenantId(),page, deptIdList, params);
}
if (Func.isEmpty(fieldList)) {//查所有
return pages;
}
//存在自定义列
Map<String, Consumer<JeeLowCodeUser>> fieldSetters = new HashMap<>();
fieldSetters.put("userId", user -> user.setUserId(null));
fieldSetters.put("nickName", user -> user.setNickName(null));
fieldSetters.put("mobile", user -> user.setMobile(null));
fieldSetters.put("email", user -> user.setEmail(null));
fieldSetters.put("sex", user -> user.setSex(null));
fieldSetters.put("post", user -> user.setPost(null));
fieldSetters.put("avatar", user -> user.setAvatar(null));
fieldSetters.put("deptName", user -> user.setDeptName(null));
// 为其他字段添加更多的条目
List<JeeLowCodeUser> records = pages.getRecords();
records.stream().peek(user -> fieldSetters.forEach((fieldName, setter) -> {
if (!fieldList.contains(fieldName)) {
setter.accept(user);
}
}))
.collect(Collectors.toList());
return pages;
}
//初始化-新增数据默认项
@Override
public void initSaveDefaultData(Map<String, Object> map) {
//默认值由系统赋值,不做修改
map.remove(DefaultDbFieldEnum.CREATE_USER.getFieldCode());
map.remove(DefaultDbFieldEnum.CREATE_TIME.getFieldCode());
map.remove(DefaultDbFieldEnum.CREATE_DEPT.getFieldCode());
map.remove(DefaultDbFieldEnum.IS_DELETED.getFieldCode());
map.remove(DefaultDbFieldEnum.TENANT_ID.getFieldCode());
map.remove(DefaultDbFieldEnum.UPDATE_USER.getFieldCode());
map.remove(DefaultDbFieldEnum.UPDATE_TIME.getFieldCode());
DateTime now = DateUtil.date();
if (FuncBase.isEmpty(map.get(DefaultDbFieldEnum.ID.getFieldCode()))) {
map.put(DefaultDbFieldEnum.ID.getFieldCode(), IdWorker.getId());
}
map.put(DefaultDbFieldEnum.CREATE_USER.getFieldCode(), Func.toLong(this.getOnlineUserId()));
map.put(DefaultDbFieldEnum.CREATE_TIME.getFieldCode(), now);
map.put(DefaultDbFieldEnum.CREATE_DEPT.getFieldCode(), Func.toLong(this.getOnlineUserDeptId()));
map.put(DefaultDbFieldEnum.IS_DELETED.getFieldCode(), 0);
map.put(DefaultDbFieldEnum.TENANT_ID.getFieldCode(), Func.toLong(this.getTenantId()));
}
//初始化-修改数据默认项
@Override
public void initUpdateDefaultData(Map<String, Object> map) {
//默认值由系统赋值,不做修改
map.remove(DefaultDbFieldEnum.CREATE_USER.getFieldCode());
map.remove(DefaultDbFieldEnum.CREATE_TIME.getFieldCode());
map.remove(DefaultDbFieldEnum.CREATE_DEPT.getFieldCode());
map.remove(DefaultDbFieldEnum.IS_DELETED.getFieldCode());
map.remove(DefaultDbFieldEnum.TENANT_ID.getFieldCode());
map.remove(DefaultDbFieldEnum.UPDATE_USER.getFieldCode());
map.remove(DefaultDbFieldEnum.UPDATE_TIME.getFieldCode());
DateTime now = DateUtil.date();
map.put(DefaultDbFieldEnum.UPDATE_USER.getFieldCode(), Func.toLong(this.getOnlineUserId()));
map.put(DefaultDbFieldEnum.UPDATE_TIME.getFieldCode(), now);
}
//获取所有不用租户的表
@Override
public Set<String> getTenantIgnoreTable() {
return tenantProperties.getIgnoreTables();
}
@Override
public Set<String> getTenantIgnoreUrl() {
return tenantProperties.getIgnoreUrls().stream()
.filter(url -> !url.contains("jeelowcode"))
.collect(Collectors.toCollection(HashSet::new));
}
//判断多租户是否启用
@Override
public boolean getTenantEnable() {
return tenantProperties.getEnable();
}
//获取所有子部门
private List<Long> getChildDeptIdList(Long id) {
List<Long> children = new LinkedList<>();//子集
children.add(id);
// 遍历每一层
List<Long> parentIdList = new ArrayList<>();
parentIdList.add(id);
for (int i = 0; i < Short.MAX_VALUE; i++) { // 使用 Short.MAX_VALUE 避免 bug 场景下,存在死循环
List<Long> finalParentIdList = parentIdList;
SqlInfoQueryWrapper.Wrapper wrapper = SqlHelper.getQueryWrapper()
.select("id")
.setTableName("system_dept")
.setWhere(where -> {
where.eq("deleted", 0);
where.in("parent_id", finalParentIdList);
})
.build();
List<Map<String, Object>> deptList = sqlService.getDataListByPlus(wrapper);
// 1. 如果没有子部门,则结束遍历
if (Func.isEmpty(deptList)) {
break;
}
List<Long> tmpIdList = deptList.stream()
.map(deptMap -> Func.getMap2Long(deptMap, "id"))
.filter(Objects::nonNull)
.collect(Collectors.toCollection(ArrayList::new));
children.addAll(tmpIdList);//存入到总集合里面
parentIdList = tmpIdList;//进行下一轮
}
return children;
}
}

View File

@@ -0,0 +1,665 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance;
import cn.hutool.core.date.DateUtil;
import com.jeelowcode.core.framework.config.aspect.enhance.model.BuildSqlEnhanceContext;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceContext;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceResult;
import com.jeelowcode.core.framework.entity.EnhanceSqlEntity;
import com.jeelowcode.core.framework.mapper.JeeLowCodeMapper;
import com.jeelowcode.core.framework.mapper.JeeLowCodeSqlMapper;
import com.jeelowcode.core.framework.utils.Func;
import com.jeelowcode.core.framework.utils.FuncWeb;
import com.jeelowcode.framework.plus.SqlHelper;
import com.jeelowcode.framework.plus.build.buildmodel.wrapper.SqlInfoQueryWrapper;
import com.jeelowcode.framework.plus.core.model.SqlFormatModel;
import com.jeelowcode.framework.utils.adapter.IJeeLowCodeAdapter;
import com.jeelowcode.framework.utils.enums.JeeLowCodeFieldTypeEnum;
import com.jeelowcode.framework.utils.enums.ParamEnum;
import com.jeelowcode.framework.utils.enums.QueryModelEnum;
import com.jeelowcode.framework.utils.model.ExecuteEnhanceModel;
import com.jeelowcode.framework.utils.model.ResultDataModel;
import com.jeelowcode.framework.utils.utils.FuncBase;
import com.jeelowcode.framework.utils.utils.JeeLowCodeUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.collections4.CollectionUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
import static com.jeelowcode.core.framework.config.aspect.enhance.JeeLowCodeAnnotationAspectjJAVA.EXPRESSION;
import static com.jeelowcode.core.framework.config.aspect.enhance.JeeLowCodeAnnotationAspectjJAVA.aspectMethodNameMap;
import static com.jeelowcode.framework.utils.constant.EnhanceConstant.*;
/**
* @author JX
* @create 2024-08-19 13:46
* @dedescription:
*/
@Aspect
@Component
public class JeeLowCodeAnnoaionAspectjSQL {
@Autowired
private IJeeLowCodeAdapter jeeLowCodeAdapter;
@Autowired
private JeeLowCodeSqlMapper sqlMapper;
@Autowired
private JeeLowCodeMapper jeeLowCodeMapper;
private static Map<String, List<EnhanceSqlEntity>> sqlPlugins = new HashMap<>();
@AfterReturning(value = EXPRESSION, returning = "returnVal")
public Object afterReturingAdvice(JoinPoint joinPoint, Object returnVal){
BuildSqlEnhanceContext contextAndPlugins = getContextAndPlugins(joinPoint, returnVal);
if (FuncBase.isEmpty(contextAndPlugins)){
return returnVal;
}
EnhanceContext context = contextAndPlugins.getContext();
//判断结果类型
ExecuteEnhanceModel formModel =null; //表单类
ResultDataModel listModel =null; //查询类
Boolean resultFlag = false;
if(Func.isNotEmpty(returnVal) && returnVal instanceof ExecuteEnhanceModel){//表单类
formModel = (ExecuteEnhanceModel) returnVal;
resultFlag = true;
}
if(Func.isNotEmpty(returnVal) && returnVal instanceof ResultDataModel){//列表类
listModel = (ResultDataModel) returnVal;
}
//把结果放到上下文中再执行插件
if(resultFlag){
String id = formModel.getId();
context.getResult().setId(id);
context.getResult().setExitFlag(formModel.isExitFlag());
}else {
context.getResult().setRecords(listModel.getRecords());
context.getResult().setTotal(listModel.getTotal());
context.getResult().setExitFlag(listModel.isExitFlag());
}
//集合操作的插件
List<EnhanceSqlEntity> setOperations = contextAndPlugins.getSetOperations();
if(CollectionUtils.isNotEmpty(setOperations)){
//执行
executeEnhanceSetOperation(context,setOperations);
listModel.setTotal(context.getResult().getTotal());
listModel.setRecords(context.getResult().getRecords());
}
//所有sql增强
List<EnhanceSqlEntity> enhanceSqlEntityList = contextAndPlugins.getEntitys();
for (EnhanceSqlEntity enhanceSqlEntity : enhanceSqlEntityList) {
if (setOperations.contains(enhanceSqlEntity)){
continue;
}
this.executSQLPlugin(context,enhanceSqlEntity);
if (FuncBase.isNotEmpty(context.getResult()) && context.getResult().isExitFlag()){
listModel.setTotal(context.getResult().getTotal());
listModel.setRecords(context.getResult().getRecords());
return listModel;
}
}
return returnVal;
}
public BuildSqlEnhanceContext getContextAndPlugins(JoinPoint joinPoint,Object returnVal){
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
// 获取方法名称
String methodName = methodSignature.getName();
if (!aspectMethodNameMap.containsKey(methodName)) {//不在拦截范围内 add
return null;
}
Object[] args = joinPoint.getArgs();
LocalVariableTableParameterNameDiscoverer discoverer = new LocalVariableTableParameterNameDiscoverer();
String[] parameterNames = discoverer.getParameterNames(methodSignature.getMethod());
Map<String, Object> paramMap = new HashMap<>();
for (int i = 0; i < parameterNames.length; i++) {
paramMap.put(parameterNames[i], args[i]);
}
Long dbFormId = (Long) paramMap.getOrDefault("dbFormId", null);
Long dataId = (Long)paramMap.getOrDefault("dataId",null);
Page page = (Page)paramMap.getOrDefault("page", null);
List<Long> dataIdList =(List)paramMap.getOrDefault("dataIdList",null);
String buttonCode = aspectMethodNameMap.get(methodName);
String key = dbFormId + "_" + buttonCode;
List<EnhanceSqlEntity> allPlugins = sqlPlugins.getOrDefault(key, null);
if (Func.isEmpty(allPlugins)) {
return null;
}
List<EnhanceSqlEntity> setOperation = new ArrayList<>();
if (FuncBase.isNotEmpty(allPlugins)) {
setOperation = allPlugins.stream()
.filter(enhanceSqlEntity -> (FuncBase.equals(enhanceSqlEntity.getButtonCode(), ENHANCE_LIST) ||
FuncBase.equals(enhanceSqlEntity.getButtonCode(), ENHANCE_EXPORT)))
.collect(Collectors.toList());
if (setOperation.size() < 2) {
//如果只有一条,则直接执行,不用走集合操作
setOperation.clear();
}
}
List<Map<String,Object>> dataList = new ArrayList<>();
if(returnVal instanceof ResultDataModel){
dataList = ((ResultDataModel) returnVal).getRecords();
}
EnhanceContext context = new EnhanceContext();
Map<String, Object> params = JeeLowCodeUtils.getMap2Map(paramMap, "params");
context.setParam(dbFormId, params, dataList, dataId, page, dataIdList);
context.setResult(new EnhanceResult());
return new BuildSqlEnhanceContext(context, allPlugins,setOperation);
}
public static void initSqlPlugins(Map<String, List<EnhanceSqlEntity>> initSQLPlugins) {
sqlPlugins = initSQLPlugins;
}
public void executSQLPlugin(EnhanceContext context, EnhanceSqlEntity enhanceSqlEntity) {
switch (enhanceSqlEntity.getButtonCode()){
case ENHANCE_ADD:
//新增
this.executeEnhanceAfterAdd(context, enhanceSqlEntity);
break;
case ENHANCE_DELETE:
//删除
this.executeEnhanceAfterDelete(context, enhanceSqlEntity);
break;
case ENHANCE_EDIT:
//编辑
this.executeEnhanceAfterEdit(context, enhanceSqlEntity);
break;
case ENHANCE_DETAIL:
//详情
this.executeEnhanceAfterDetail(context, enhanceSqlEntity);
break;
case ENHANCE_IMPORT:
//导入
this.executeEnhanceAfterImport(context, enhanceSqlEntity);
break;
case ENHANCE_LIST:
//列表
this.executeEnhanceAfterList(context, enhanceSqlEntity);
break;
case ENHANCE_PAGE:
//分页
this.executeEnhanceAfterPage(context, enhanceSqlEntity);
break;
case ENHANCE_EXPORT:
//导出
this.executeEnhanceAfterExport(context, enhanceSqlEntity);
break;
}
}
//新增
public void executeEnhanceAfterAdd(EnhanceContext context,EnhanceSqlEntity sqlEntity) {
Long dbFormId = context.getParam().getDbFormId();
Map<String,Object> paramMap = context.getParam().getParams();
if(FuncBase.isNotEmpty(context.getParam().getDataId())){//把id放入到参数
paramMap.put("id",context.getParam().getDataId());
}
this.executeSql(sqlEntity.getExecuteSql(), paramMap);
}
//删除
public void executeEnhanceAfterDelete(EnhanceContext context,EnhanceSqlEntity sqlEntity){
List<Long> dataIdList = context.getParam().getDataIdList();
String executeSql = sqlEntity.getExecuteSql();
if(FuncBase.isEmpty(executeSql)){
return ;
}
//因为是批量删除的,需要拆分出来
for(Long dataId:dataIdList){
Map<String,Object> dataMap =new HashMap<>();
dataMap.put("id",dataId);
//执行sql
this.executeSql(executeSql,dataMap);
}
}
//编辑
public void executeEnhanceAfterEdit(EnhanceContext context,EnhanceSqlEntity sqlEntity){
Long dataId = context.getParam().getDataId();
Map<String,Object> paramMap = context.getParam().getParams();
paramMap.put("id", dataId);//把id放到json里面传递
this.executeSql(sqlEntity.getExecuteSql(),paramMap);
}
//详情
public void executeEnhanceAfterDetail(EnhanceContext context,EnhanceSqlEntity sqlEntity){
Long dbFormId = context.getParam().getDbFormId();
Long id = (Long) context.getParam().getDataId();
Map<String, Object> params = context.getParam().getParams();
params.put("id",id);//把id放入参数集
String autoWhereSql = this.getAutoWhereSql(dbFormId, params);
String executeSql = sqlEntity.getExecuteSql();
List<Map<String, Object>> dataMapList = this.executeSelectListSql(executeSql, params, autoWhereSql);
context.setResult( ResultDataModel.fomatList(dataMapList));
}
//导入
public void executeEnhanceAfterImport(EnhanceContext context,EnhanceSqlEntity sqlEntity){
Map<String,Object> paramMap = context.getParam().getParams();
this.executeSql(sqlEntity.getExecuteSql(),paramMap);
}
//列表
public void executeEnhanceAfterList(EnhanceContext context,EnhanceSqlEntity sqlEntity){
Long dbFormId = context.getParam().getDbFormId();
Map<String, Object> params = context.getParam().getParams();
String executeSql = sqlEntity.getExecuteSql();
String autoWhereSql = this.getAutoWhereSql(dbFormId, params);
List<Map<String, Object>> dataMapList = this.executeSelectListSql(executeSql, params, autoWhereSql);
context.getResult().setRecords(dataMapList);
context.getResult().setExitFlag(true);
}
// 分页
public void executeEnhanceAfterPage(EnhanceContext context,EnhanceSqlEntity sqlEntity){
Long dbFormId = context.getParam().getDbFormId();
Map<String, Object> params = context.getParam().getParams();
Integer pageNo = JeeLowCodeUtils.getMap2Integer(params, "pageNo");
Integer pageSize = JeeLowCodeUtils.getMap2Integer(params, "pageSize");
Page page = FuncWeb.getPage(pageNo, pageSize);
String executeSql = sqlEntity.getExecuteSql();
String autoWhereSql = this.getAutoWhereSql(dbFormId, params);
IPage<Map<String, Object>> pages = this.executeSelectPageSql(executeSql, params, autoWhereSql, page);
FuncWeb.setPageResult(context, pages);
}
//导出
public void executeEnhanceAfterExport(EnhanceContext context, EnhanceSqlEntity sqlEntity){
Long dbFormId = context.getParam().getDbFormId();
Map<String, Object> params = context.getParam().getParams();
String executeSql = sqlEntity.getExecuteSql();
String autoWhereSql = this.getAutoWhereSql(dbFormId, params);
List<Map<String, Object>> dataMapList = this.executeSelectListSql(executeSql, params, autoWhereSql);
context.getResult().setRecords(dataMapList);
context.getResult().setExitFlag(true);
}
//执行集合操作
public void executeEnhanceSetOperation(EnhanceContext context,List<EnhanceSqlEntity> sqlEntitys){
sqlEntitys.sort(Comparator.comparing(EnhanceSqlEntity::getSort,Comparator.nullsLast(Integer::compareTo)));
for (int i = 0; i < sqlEntitys.size()-1; i++) {
EnhanceSqlEntity leftEntity = null;
EnhanceSqlEntity rightEntity = null;
if (i == 0) {
leftEntity = sqlEntitys.get(i);
rightEntity = sqlEntitys.get(i + 1);
} else {
rightEntity = sqlEntitys.get(i + 1);
}
switch (rightEntity.getListResultHandleType()) {
case "1":
//执行合集操作
executSetOperationOr(leftEntity, rightEntity, context);
break;
case "2":
//执行差集操作
executSetOperationDiffer(leftEntity, rightEntity, context);
break;
case "3":
//执行并集操作
executSetOperationUnion(leftEntity, rightEntity, context);
break;
case "4":
//执行交集操作
executSetOperationInterSerction(leftEntity, rightEntity, context);
break;
default:
case "0":
//执行串行操作
executSetOperationAnd(leftEntity, rightEntity, context);
break;
}
}
}
//执行合集操作
private void executSetOperationOr(EnhanceSqlEntity leftEntity, EnhanceSqlEntity rightEntity, EnhanceContext context) {
List<Map<String, Object>> leftRecords ;
if(FuncBase.isNotEmpty(leftEntity)){
EnhanceContext leftContext = context.clone();
executSQLPlugin(leftContext, leftEntity);
leftRecords = leftContext.getResult().getRecords();
}else {
leftRecords = context.getResult().getRecords();
}
EnhanceContext rightContext = context.clone();
executSQLPlugin(rightContext, rightEntity);
List<Map<String, Object>> rightRecords = rightContext.getResult().getRecords();
CollectionUtils.addAll(leftRecords,rightRecords);
context.getResult().setRecords(leftRecords);
}
private void executSetOperationDiffer(EnhanceSqlEntity leftEntity, EnhanceSqlEntity rightEntity, EnhanceContext context){
List<Map<String,Object>> differ;
List<Map<String, Object>> leftRecords ;
if(FuncBase.isNotEmpty(leftEntity)){
EnhanceContext leftContext = context.clone();
executSQLPlugin(leftContext, leftEntity);
leftRecords = leftContext.getResult().getRecords();
}else {
leftRecords = context.getResult().getRecords();
}
EnhanceContext rightContext = context.clone();
executSQLPlugin(rightContext, rightEntity);
List<Map<String, Object>> rightRecords = rightContext.getResult().getRecords();
differ = (List<Map<String, Object>>) CollectionUtils.subtract(leftRecords, rightRecords);
context.getResult().setRecords(differ);
};
//并集
public void executSetOperationUnion(EnhanceSqlEntity leftEntity, EnhanceSqlEntity rightEntity, EnhanceContext context){
List<Map<String,Object>> union;
List<Map<String, Object>> leftRecords ;
if(FuncBase.isNotEmpty(leftEntity)){
EnhanceContext leftContext = context.clone();
executSQLPlugin(leftContext, leftEntity);
leftRecords = leftContext.getResult().getRecords();
}else {
leftRecords = context.getResult().getRecords();
}
EnhanceContext rightContext = context.clone();
executSQLPlugin(rightContext, rightEntity);
List<Map<String, Object>> rightRecords = rightContext.getResult().getRecords();
union = (List<Map<String, Object>>) CollectionUtils.union(leftRecords, rightRecords);
context.getResult().setRecords(union);
}
//交集
public void executSetOperationInterSerction(EnhanceSqlEntity leftEntity, EnhanceSqlEntity rightEntity, EnhanceContext context){
List<Map<String,Object>> intersection;
List<Map<String, Object>> leftRecords ;
if(FuncBase.isNotEmpty(leftEntity)){
EnhanceContext leftContext = context.clone();
executSQLPlugin(leftContext, leftEntity);
leftRecords = leftContext.getResult().getRecords();
}else {
leftRecords = context.getResult().getRecords();
}
EnhanceContext rightContext = context.clone();
executSQLPlugin(rightContext, rightEntity);
List<Map<String, Object>> rightRecords = rightContext.getResult().getRecords();
intersection = (List<Map<String, Object>>) CollectionUtils.intersection(leftRecords, rightRecords);
context.getResult().setRecords(intersection);
}
//串行
public void executSetOperationAnd(EnhanceSqlEntity leftEntity, EnhanceSqlEntity rightEntity, EnhanceContext context){
executSQLPlugin(context, leftEntity);
executSQLPlugin(context, rightEntity);
}
/**
* 获取自动构建where的语句
* @param dbFormId
* @return
*/
public String getAutoWhereSql(Long dbFormId, Map<String, Object> params){
SqlInfoQueryWrapper.Wrapper queryWrapper = SqlHelper.getQueryWrapper();
List<Map<String, String>> whereFieldMapList = jeeLowCodeMapper.getDbWhereFieldList(dbFormId);
//没有搜索条件
if (FuncBase.isEmpty(whereFieldMapList)) {
SqlFormatModel sqlFormatModel = queryWrapper.buildSql();
String whereSql = sqlFormatModel.getSql();
Map<String, Object> paramMap = sqlFormatModel.getDataMap();
if(Func.isNotEmpty(paramMap)){
params.putAll(paramMap);
}
whereSql=whereSql.substring(6);//因为是where开头要去掉
return whereSql;
}
//如果是多选的时候,要做特殊处理,因为多选的时候 ,数据库存储的是 11,22,33
String moreSelectFieldListStr = (String)params.get(ParamEnum.MORE_SELECT_FIELD.getCode());
List<String> moreSelectFieldList=null;
if(FuncBase.isNotEmpty(moreSelectFieldListStr)){
moreSelectFieldList = FuncBase.toStrList(moreSelectFieldListStr);
}
for (Map<String, String> whereFieldMap : whereFieldMapList) {
String field_code = whereFieldMap.get("field_code");//字段
String field_type = whereFieldMap.get("field_type");//类型
String query_mode = whereFieldMap.get("query_mode");//EQ LIKE
Object obj = params.get(field_code);
if (FuncBase.isEmpty(obj)) {
continue;
}
JeeLowCodeFieldTypeEnum fieldTypeEnum = JeeLowCodeFieldTypeEnum.getByFieldType(field_type);
switch (fieldTypeEnum) {
case DATE:
obj = DateUtil.parse(Func.toStr(obj), "yyyy-MM-dd");
break;
case DATETIME:
obj = DateUtil.parse(Func.toStr(obj), "yyyy-MM-dd HH:mm:ss");
break;
case TIME:
obj = DateUtil.parse(Func.toStr(obj), "HH:mm:ss");
break;
}
Object finalObj = obj;
//类型转换 111,22,33
if (FuncBase.equals(query_mode, QueryModelEnum.EQ.getCode())) {//精确
if(FuncBase.isNotEmpty(moreSelectFieldList) && moreSelectFieldList.contains(field_code)){//在多选里面
queryWrapper.setWhere(where->{
where.and(w->w.eq(field_code, finalObj)
.or().likeLeft(field_code,","+ finalObj)
.or().likeRight(field_code, finalObj +",")
.or().like(field_code,","+ finalObj +","));
});
}else{
queryWrapper.setWhere(where->{
where.eq(field_code, finalObj);
});
}
} else if (FuncBase.equals(query_mode, QueryModelEnum.RANGE.getCode())) {//范围
String listStr = FuncBase.toStr(obj);
List<String> paramList = FuncBase.toStrList(listStr);// 1<=x<2
Object leftVal = paramList.get(0);
Object rightVal = paramList.get(1);
if (FuncBase.equals(field_type, JeeLowCodeFieldTypeEnum.BIGINT)) {//防止大整型出现精度问题
leftVal = FuncBase.toLong(leftVal);
rightVal = FuncBase.toLong(rightVal);
}
if (FuncBase.isNotEmpty(leftVal) && FuncBase.isNotEmpty(rightVal)) {
Object finalLeftVal = leftVal;
Object finalRightVal = rightVal;
queryWrapper.setWhere(where->{
where.between(field_code, finalLeftVal, finalRightVal);//区间
});
} else if (FuncBase.isNotEmpty(leftVal)) {//>=
Object finalLeftVal1 = leftVal;
queryWrapper.setWhere(where->{
where.ge(field_code, finalLeftVal1);
});
} else if (FuncBase.isNotEmpty(rightVal)) {//<=
Object finalRightVal1 = rightVal;
queryWrapper.setWhere(where->{
where.le(field_code, finalRightVal1);
});
}
} else {
queryWrapper.setWhere(where->{
where.like(field_code, finalObj);
});
}
}
SqlFormatModel sqlFormatModel = queryWrapper.buildSql();
String whereSql = sqlFormatModel.getSql();
if (FuncBase.isEmpty(whereSql)) {
return whereSql;
}
Map<String, Object> paramMap = sqlFormatModel.getDataMap();
if(Func.isNotEmpty(paramMap)){
params.putAll(paramMap);
}
whereSql=whereSql.substring(6);//因为是where开头要去掉
return whereSql;
}
/**
* 运行增删改
* @param executeSql
* @param paramMap
* @throws Throwable
*/
public void executeSql(String executeSql, Map<String, Object> paramMap) {
String sql = this.getSql(executeSql, paramMap);
this.execute(sql,paramMap);
}
/**
* 执行查询
*
* @param executeSql
* @param paramMap
* @return
* @throws Throwable
*/
public List<Map<String, Object>> executeSelectListSql(String executeSql, Map<String, Object> paramMap, String autoWhereSql) {
String sql = this.getSql(executeSql, paramMap, autoWhereSql);
Object obj = this.execute(sql,paramMap);
return (List<Map<String, Object>>)obj;
}
//分页
public IPage<Map<String, Object>> executeSelectPageSql(String executeSql, Map<String, Object> paramMap, String autoWhereSql, Page page) {
String sql = this.getSql(executeSql, paramMap, autoWhereSql);
Object obj = this.execute(sql, paramMap,page);
return (IPage<Map<String, Object>>)obj;
}
/**
* 获取执行sql
* @param executeSql
* @param paramMap
* @return
*/
private String getSql(String executeSql, Map<String, Object> paramMap){
return this.getSql(executeSql,paramMap,null);
}
private String getSql(String executeSql, Map<String, Object> paramMap, String autoWhereSql){
//替换参数
executeSql = Func.replaceParam(executeSql,paramMap,autoWhereSql,jeeLowCodeAdapter);
return executeSql.trim();
}
/**
* 执行sql
* @param sql
* @return
*/
private Object execute(String sql,Map<String,Object> dataMap){
return execute(sql,dataMap,null);
}
private Object execute(String sql,Map<String,Object> dataMap, Page page){
sql=sql.trim();
//执行sql
if (sql.startsWith("insert") || sql.startsWith("INSERT")) {
sqlMapper.insertData(sql,dataMap);
} else if (sql.startsWith("update") || sql.startsWith("UPDATE")) {
sqlMapper.updateData(sql,dataMap);
} else if (sql.startsWith("delete") || sql.startsWith("DELETE")) {
sqlMapper.deleteData(sql,dataMap);
} else if (sql.startsWith("select") || sql.startsWith("SELECT")) {
if(FuncBase.isNotEmpty(page)){
return sqlMapper.selectPageData(page, sql,dataMap);
}
return sqlMapper.selectData(sql,dataMap);
}
return null;
}
// 新增增强
public static void addPlugin(EnhanceSqlEntity sqlEntity){
String key = sqlEntity.getDbformId()+"_"+sqlEntity.getButtonCode();
sqlPlugins.merge(key, new ArrayList<>(Collections.singletonList(sqlEntity)), (oldValue, newValue) -> {
oldValue.addAll(newValue);
return oldValue;
});
}
// 修改增强
public static void updatePlugin(EnhanceSqlEntity sqlEntity) {
String key = sqlEntity.getDbformId() + "_" + sqlEntity.getButtonCode();
sqlPlugins.merge(key, new ArrayList<>(Collections.singletonList(sqlEntity)), (oldValue, newValue) -> {
// 先删除再新增
oldValue.removeIf(enhanceSql -> FuncBase.equals(enhanceSql.getId(), sqlEntity.getId()));
oldValue.add(sqlEntity);
return oldValue;
});
}
// 删除增强
public static void removePlugin(EnhanceSqlEntity sqlEntity){
String key = sqlEntity.getDbformId() + "_" + sqlEntity.getButtonCode();
List<EnhanceSqlEntity> sqlEntityList = sqlPlugins.getOrDefault(key, new ArrayList<>());
// id相同则删除
sqlEntityList.removeIf(enhanceSqlEntity -> sqlEntity.getId().equals(enhanceSqlEntity.getId()));
if (FuncBase.isEmpty(sqlEntityList)) {
sqlPlugins.remove(key);
}
}
}

View File

@@ -0,0 +1,702 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance;
import com.jeelowcode.core.framework.config.aspect.enhance.criteria.*;
import com.jeelowcode.core.framework.config.aspect.enhance.model.*;
import com.jeelowcode.core.framework.config.aspect.enhance.plugin.*;
import com.jeelowcode.core.framework.config.listener.JeeLowCodeListener;
import com.jeelowcode.core.framework.entity.EnhanceJavaEntity;
import com.jeelowcode.core.framework.utils.Func;
import com.jeelowcode.framework.exception.JeeLowCodeException;
import com.jeelowcode.framework.utils.model.ExecuteEnhanceModel;
import com.jeelowcode.framework.utils.model.ResultDataModel;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import com.jeelowcode.framework.utils.utils.FuncBase;
import groovy.lang.GroovyObject;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import static com.jeelowcode.framework.utils.constant.EnhanceConstant.*;
/**
* @author JX
* @create 2024-08-12 10:26
* @dedescription:
*/
@Aspect
@Component
@Slf4j
public class JeeLowCodeAnnotationAspectjJAVA {
public final static String EXPRESSION = "execution(* com.jeelowcode.core.framework.service.impl.FrameServiceImpl.*(..))";
//需要处理的增强
private static Map<String, List<EnhanceJavaEntity>> pluginNames = new HashMap<>();
//需要处理的切面方法
public static Map<String, String> aspectMethodNameMap = new HashMap<>();
@Autowired
private JeeLowCodeListener jeeLowCodeListener;
@Before(value = EXPRESSION)
public void before(JoinPoint joinPoint) throws Throwable {
BuildEnhanceContext buildEnhanceContext = this.getContextAndPlugins(joinPoint);
if (FuncBase.isEmpty(buildEnhanceContext)) {
return;
}
List<EnhanceJavaEntity> enhanceJavaEntityList = buildEnhanceContext.getEntitys();
if (Func.isEmpty(enhanceJavaEntityList)) {
return;
}
EnhanceContext context = buildEnhanceContext.getContext();
//执行增强
for (EnhanceJavaEntity enhanceJavaEntity : enhanceJavaEntityList) {
this.executeEnhance(enhanceJavaEntity, context, JavaEnhanceEventState.START.getName(), joinPoint);
if (FuncBase.isNotEmpty(context.getResult()) && context.getResult().isExitFlag()) {
break;
}
}
}
@AfterReturning(value = EXPRESSION, returning = "returnVal")
public Object afterReturning(JoinPoint joinPoint, Object returnVal) throws Throwable {
//获取参数
BuildEnhanceContext buildEnhanceContext = this.getContextAndPlugins(joinPoint);
if (FuncBase.isEmpty(buildEnhanceContext)) {
return returnVal;
}
if (!(returnVal instanceof ResultDataModel) && !(returnVal instanceof ExecuteEnhanceModel)) {
return returnVal;
}
List<EnhanceJavaEntity> enhanceJavaEntityList = buildEnhanceContext.getEntitys();
if (Func.isEmpty(enhanceJavaEntityList)) {//无增强
return returnVal;
}
EnhanceContext context = buildEnhanceContext.getContext();
boolean resultFlag = false;
//封装返回值
if (returnVal instanceof ResultDataModel) {//列表相关
ResultDataModel resultDataModel = (ResultDataModel) returnVal;
EnhanceResult enhanceResult = new EnhanceResult();
enhanceResult.setRecords(resultDataModel.getRecords());
enhanceResult.setTotal(resultDataModel.getTotal());
context.getParam().setList(resultDataModel.getRecords());
context.setResult(enhanceResult);
resultFlag = true;
} else if (returnVal instanceof ExecuteEnhanceModel) {//新增,修改,删除
ExecuteEnhanceModel executeEnhanceModel = (ExecuteEnhanceModel) returnVal;
EnhanceResult enhanceResult = new EnhanceResult();
enhanceResult.setId(executeEnhanceModel.getId());
enhanceResult.setExitFlag(executeEnhanceModel.isExitFlag());
context.setResult(enhanceResult);
}
//集合操作
List<EnhanceJavaEntity> setOperations = buildEnhanceContext.getSetOperations();
executeSetOperation(context, setOperations);
//执行插件
for (EnhanceJavaEntity enhanceJavaEntity : enhanceJavaEntityList) {
//里面集合存在,不用执行
if (Func.isNotEmpty(setOperations) && setOperations.contains(enhanceJavaEntity)){
continue;
}
this.executeEnhance(enhanceJavaEntity, context, JavaEnhanceEventState.END.getName(), joinPoint);
if (FuncBase.isNotEmpty(context.getResult()) && context.getResult().isExitFlag()) {
break;
}
}
//返回结果
Object result = getResult(context);
if (resultFlag) {
ResultDataModel returnValData = (ResultDataModel) returnVal;
ResultDataModel resultDataModel = (ResultDataModel) result;
returnValData.setRecords(resultDataModel.getRecords());
returnValData.setTotal(resultDataModel.getTotal());
return returnValData;
} else {
ExecuteEnhanceModel returnValData = (ExecuteEnhanceModel) returnVal;
ExecuteEnhanceModel resultDataModel = (ExecuteEnhanceModel) result;
returnValData.setId(resultDataModel.getId());
return returnValData;
}
}
@Around(value = EXPRESSION)
public Object aroudAdvice(ProceedingJoinPoint joinPoint) throws Throwable {
BuildEnhanceContext buildEnhanceContext = this.getContextAndPlugins(joinPoint);
if (FuncBase.isEmpty(buildEnhanceContext)) {
return joinPoint.proceed();
}
List<EnhanceJavaEntity> enhanceJavaEntityList = buildEnhanceContext.getEntitys();
if (Func.isEmpty(enhanceJavaEntityList)) {
return joinPoint.proceed();
}
EnhanceContext context = buildEnhanceContext.getContext();
for (EnhanceJavaEntity enhanceJavaEntity : enhanceJavaEntityList) {
this.executeEnhance(enhanceJavaEntity, context, JavaEnhanceEventState.AROUND.getName(), joinPoint);
if (FuncBase.isNotEmpty(context.getResult()) && context.getResult().isExitFlag()) {
break;
}
}
if (Func.isEmpty(context.getResult())) {
return joinPoint.proceed();
}
return getResult(context);
}
@AfterThrowing(value = EXPRESSION, throwing = "ex")
public void afterThrowing(JoinPoint joinPoint, Exception ex) throws Throwable {
BuildEnhanceContext buildEnhanceContext = this.getContextAndPlugins(joinPoint);
if (FuncBase.isEmpty(buildEnhanceContext)) {
return;
}
List<EnhanceJavaEntity> enhanceJavaEntityList = buildEnhanceContext.getEntitys();
if (Func.isEmpty(enhanceJavaEntityList)) {
return;
}
EnhanceContext context = buildEnhanceContext.getContext();
for (EnhanceJavaEntity enhanceJavaEntity : enhanceJavaEntityList) {
this.executeEnhance(enhanceJavaEntity, context, JavaEnhanceEventState.THROWING.getName(), joinPoint);
if (FuncBase.isNotEmpty(context.getResult()) && context.getResult().isExitFlag()) {
break;
}
}
}
public static void initPluginNames(Map<String, List<EnhanceJavaEntity>> initPluginNames) {
pluginNames = initPluginNames;
}
public static void initAspectMethodNameMap(Map<String, String> initAspectMethodNameMap) {
aspectMethodNameMap = initAspectMethodNameMap;
}
public BuildEnhanceContext getContextAndPlugins(JoinPoint joinPoint) {
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
// 获取方法名称
String methodName = methodSignature.getName();
if (!aspectMethodNameMap.containsKey(methodName)) {//不在拦截范围内 add
return null;
}
//处理参数
Object[] args = joinPoint.getArgs();
LocalVariableTableParameterNameDiscoverer discoverer = new LocalVariableTableParameterNameDiscoverer();
String[] parameterNames = discoverer.getParameterNames(methodSignature.getMethod());
Map<String, Object> paramMap = new HashMap<>();
for (int i = 0; i < parameterNames.length; i++) {
paramMap.put(parameterNames[i], args[i]);
}
//判断该表单,当前的功能是否有增强
Long dbFormId = (Long) paramMap.get("dbFormId");
String buttonCode = aspectMethodNameMap.get(methodName);
String key = dbFormId + "_" + buttonCode;
List<EnhanceJavaEntity> enhanceJavaEntityList = pluginNames.getOrDefault(key, null);
if (Func.isEmpty(enhanceJavaEntityList)) {//不存在增强
return null;
}
//判断是否是列表,导出增强
List<EnhanceJavaEntity> setOperation = enhanceJavaEntityList.stream()
.filter(enhanceJavaEntity -> (FuncBase.equals(enhanceJavaEntity.getButtonCode(), ENHANCE_LIST) ||
FuncBase.equals(enhanceJavaEntity.getButtonCode(), ENHANCE_EXPORT)) && FuncBase.isNotEmpty(PluginManager.getPlugin(enhanceJavaEntity)))
.collect(Collectors.toList());
if (setOperation.size() < 2) {
//如果只有一条,则直接执行,不用走集合操作
setOperation.clear();
}
EnhanceParam param = new EnhanceParam();
param.setDbFormId(dbFormId);
param.setList((ArrayList) paramMap.getOrDefault("dataList", null));
param.setParams((Map<String, Object>) paramMap.getOrDefault("params", null));
//把参数放入到上下文
EnhanceContext context = new EnhanceContext();
context.setParam(param);
BuildEnhanceContext buildEnhanceContext = new BuildEnhanceContext(context, enhanceJavaEntityList, setOperation);
return buildEnhanceContext;
}
//执行增强
public void executeEnhance(EnhanceJavaEntity enhanceJavaEntity, EnhanceContext context, String type, JoinPoint joinPoint) throws Throwable {
String javaType = enhanceJavaEntity.getJavaType();
if (FuncBase.equals(javaType, JavaEnhanceEnum.SPRING.getType()) || (FuncBase.equals(javaType, JavaEnhanceEnum.CLASS.getType()))) {
//执行spring增强与class增强
this.executeSpringEnhance(enhanceJavaEntity, type, context, joinPoint);
} else if (FuncBase.equals(javaType, JavaEnhanceEnum.ONLINIE.getType())) {
//执行在线增强
this.executeOnLineScript(enhanceJavaEntity, type, context, joinPoint);
} else if (FuncBase.equals(javaType, JavaEnhanceEnum.HTTP.getType())) {
//执行http增强
this.executeHttpEnhance(enhanceJavaEntity, type, context, joinPoint);
}
}
/*
* 执行spring增强
*/
private void executeSpringEnhance(EnhanceJavaEntity enhanceJavaEntity, String type, EnhanceContext context, JoinPoint joinPoint) throws Throwable {
String javaClassUrl = enhanceJavaEntity.getJavaClassUrl();//
BaseAdvicePlugin plugin = PluginManager.getPlugin(javaClassUrl);
switch (type) {
case "start"://前置增强
if (!(plugin instanceof BeforeAdvicePlugin)) {
break;
}
//执行
PluginManager.executePlugin(javaClassUrl, context);
break;
case "end"://后置增强
if (!(plugin instanceof AfterAdvicePlugin)) {
break;
}
//执行
PluginManager.executePlugin(javaClassUrl, context);
break;
case "around":
if (!(plugin instanceof AroundAdvicePlugin)) {
break;
}
//环绕-前置
PluginManager.executeAroundBeforePlugin(plugin, context);
if (Func.isEmpty(context.getResult())) {
context.setResult(new EnhanceResult());
}
if (context.getResult().isExitFlag()) {//说明终止,不用往下走
break;
}
//执行原方法
ProceedingJoinPoint proceedingJoinPoint = (ProceedingJoinPoint) joinPoint;
Object proceed = proceedingJoinPoint.proceed();
if (proceed instanceof ResultDataModel) {
EnhanceResult enhanceResult = context.getResult();
enhanceResult.setRecords(((ResultDataModel) proceed).getRecords());
enhanceResult.setTotal(((ResultDataModel) proceed).getTotal());
} else if (proceed instanceof ExecuteEnhanceModel) {
EnhanceResult enhanceResult = context.getResult();
enhanceResult.setId(((ExecuteEnhanceModel) proceed).getId());
}
//环绕-后置
PluginManager.executeAroundAfterPlugin(plugin, context);
break;
case "throwing":
if (!(plugin instanceof ThrowAdvicePlugin)) {
break;
}
PluginManager.executePlugin(javaClassUrl, context);
break;
default:
break;
}
}
/*
* 执行Online增强---只有环绕增强
*/
private void executeOnLineScript(EnhanceJavaEntity enhanceJavaEntity, String type, EnhanceContext context, JoinPoint joinPoint) throws Throwable {
if (!FuncBase.equals(type, JavaEnhanceEventState.AROUND.getName())) {
return;
}
Class<?> onlineClass = jeeLowCodeListener.getGroovyClassLoader().parseClass(enhanceJavaEntity.getOnlineScript());
GroovyObject groovyObject = (GroovyObject) onlineClass.newInstance();
groovyObject.invokeMethod("beforeExecute", context);
//只有前置
if (context.getOnlyBefore()) {
return;
}
//执行原方法
ProceedingJoinPoint proceedingJointpoint = (ProceedingJoinPoint) joinPoint;
Object proceed = proceedingJointpoint.proceed();
if (proceed instanceof ResultDataModel) {
EnhanceResult enhanceResult = context.getResult();
enhanceResult.setRecords(((ResultDataModel) proceed).getRecords());
enhanceResult.setTotal(((ResultDataModel) proceed).getTotal());
} else if (proceed instanceof ExecuteEnhanceModel) {
EnhanceResult enhanceResult = context.getResult();
enhanceResult.setId(((ExecuteEnhanceModel) proceed).getId());
}
groovyObject.invokeMethod("afterExecute", context);
}
private void executeHttpEnhance(EnhanceJavaEntity enhanceJavaEntity, String type, EnhanceContext context, JoinPoint joinPoint) {
if (!FuncBase.equals(type, JavaEnhanceEventState.AROUND.getName())) {
return;
}
context.setBefore(true);
String accept = null;
for (int i = 0; i < 3; i++) {
try {
accept = Func.sendPost(enhanceJavaEntity.getJavaClassUrl(), context);
EnhanceRespModel respBody = Func.json2Bean(accept, EnhanceRespModel.class);
if (respBody.checkStatus()) {
context = respBody.getData();
context.setBefore(false);
break;
}
Map<String, Object> errorMap = new HashMap<>();
errorMap.put("body", Func.json2Str(context));
errorMap.put("url", enhanceJavaEntity.getJavaClassUrl());
errorMap.put("respBody", Func.json2Str(respBody));
log.error("发送HTTP增强失败" + Func.json2Str(errorMap));
Thread.sleep(2000);//休息2秒
} catch (Exception e) {
log.error("发送HTTP增强失败-e" + e.getMessage());
}
}
if (context.getOnlyBefore()) {
return;
}
try {
ProceedingJoinPoint proceedingJointpoint = (ProceedingJoinPoint) joinPoint;
Object proceed = proceedingJointpoint.proceed();
if (proceed instanceof ResultDataModel) {
EnhanceResult enhanceResult = context.getResult();
enhanceResult.setRecords(((ResultDataModel) proceed).getRecords());
enhanceResult.setTotal(((ResultDataModel) proceed).getTotal());
} else if (proceed instanceof ExecuteEnhanceModel) {
EnhanceResult enhanceResult = context.getResult();
enhanceResult.setId(((ExecuteEnhanceModel) proceed).getId());
}
} catch (Throwable e) {
throw new JeeLowCodeException("发送HTTP增强失败" + e.getMessage());
}
for (int i = 0; i < 3; i++) {
try {
accept = Func.sendPost(enhanceJavaEntity.getJavaClassUrl(), context);
EnhanceRespModel respBody = Func.json2Bean(accept, EnhanceRespModel.class);
if (respBody.checkStatus()) {
context = respBody.getData();
break;
}
Map<String, Object> errorMap = new HashMap<>();
errorMap.put("body", Func.json2Str(context));
errorMap.put("url", enhanceJavaEntity.getJavaClassUrl());
errorMap.put("respBody", Func.json2Str(respBody));
log.error("发送HTTP增强失败" + Func.json2Str(errorMap));
Thread.sleep(2000);//休息2秒
} catch (Exception e) {
log.error("发送HTTP增强失败-e" + e.getMessage());
}
}
}
private void executeSetOperation(EnhanceContext context, List<EnhanceJavaEntity> javaEntityList) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
if (Func.isEmpty(javaEntityList) || javaEntityList.size() < 2) {
return;
}
//只有后置增强才有集合操作
List<EnhanceJavaEntity> afterJavaList = javaEntityList.stream().filter(javaEntity -> {
Object o = null;
if (Func.equals(JavaEnhanceEnum.SPRING.getType(), javaEntity.getJavaType())) {
o = SpringUtils.getBean(javaEntity.getJavaClassUrl());
} else if (Func.equals(JavaEnhanceEnum.CLASS.getType(), javaEntity.getJavaType())) {
try {
o = Class.forName(javaEntity.getJavaClassUrl()).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException ignored) {}
}
return o instanceof AfterAdvicePlugin;
}).collect(Collectors.toList());
if (Func.isEmpty(afterJavaList) || afterJavaList.size() < 2) {
if (Func.isNotEmpty(afterJavaList)) {
javaEntityList.removeAll(afterJavaList);
}
return;
}
//根据序号排序
afterJavaList.sort(
Comparator.comparing(
EnhanceJavaEntity::getSort, Comparator.nullsLast(Integer::compareTo)));
for (int i = 0; i < afterJavaList.size() - 1; i++) {
EnhanceJavaEntity leftEntity = null;
EnhanceJavaEntity rightEntity = null;
if (i == 0) {
leftEntity = afterJavaList.get(i);
rightEntity = afterJavaList.get(i + 1);
} else {
rightEntity = afterJavaList.get(i + 1);
}
switch (rightEntity.getListResultHandleType()) {
case "1":
//执行合集操作
executSetOperationOr(leftEntity, rightEntity, context);
break;
case "2":
//执行差集操作
executSetOperationDiffer(leftEntity, rightEntity, context);
break;
case "3":
//执行并集操作
executSetOperationUnion(leftEntity, rightEntity, context);
break;
case "4":
//执行交集操作
executSetOperationInterSerction(leftEntity, rightEntity, context);
break;
default:
case "0":
//执行串行操作
executSetOperationAnd(leftEntity, rightEntity, context);
break;
}
}
}
//串行
private void executSetOperationAnd(EnhanceJavaEntity leftEntity, EnhanceJavaEntity rightEntity, EnhanceContext context) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
AfterAdvicePlugin leftPlugin = judgeLeftPlugin(leftEntity);
AfterAdvicePlugin rightPlugin = (AfterAdvicePlugin)PluginManager.getPlugin(rightEntity);
AndCriteriaFilterAdvicePlugin andAdvicePlugin = new AndCriteriaFilterAdvicePlugin(leftPlugin, rightPlugin);
andAdvicePlugin.execute(context);
}
//合集
private void executSetOperationOr(EnhanceJavaEntity leftEntity, EnhanceJavaEntity rightEntity, EnhanceContext context) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
AfterAdvicePlugin leftPlugin = judgeLeftPlugin(leftEntity);
AfterAdvicePlugin rightPlugin = (AfterAdvicePlugin)PluginManager.getPlugin(rightEntity);
OrCriteriaFilterAdvicePlugin orAdvicePlugin = new OrCriteriaFilterAdvicePlugin(leftPlugin, rightPlugin);
orAdvicePlugin.execute(context);
}
//差集
private void executSetOperationDiffer(EnhanceJavaEntity leftEntity, EnhanceJavaEntity rightEntity, EnhanceContext context) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
AfterAdvicePlugin leftPlugin = judgeLeftPlugin(leftEntity);
AfterAdvicePlugin rightPlugin = (AfterAdvicePlugin)PluginManager.getPlugin(rightEntity);
DifferenceCriteriaFilterAdvicePlugin differPlugin = new DifferenceCriteriaFilterAdvicePlugin(leftPlugin, rightPlugin);
differPlugin.execute(context);
}
//并集
private void executSetOperationUnion(EnhanceJavaEntity leftEntity, EnhanceJavaEntity rightEntity, EnhanceContext context) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
AfterAdvicePlugin leftPlugin = judgeLeftPlugin(leftEntity);
AfterAdvicePlugin rightPlugin = (AfterAdvicePlugin)PluginManager.getPlugin(rightEntity);
UnionCriteriaFilterAdvicePlugin unionPlugin = new UnionCriteriaFilterAdvicePlugin(leftPlugin, rightPlugin);
unionPlugin.execute(context);
}
//交集
private void executSetOperationInterSerction(EnhanceJavaEntity leftEntity, EnhanceJavaEntity rightEntity, EnhanceContext context) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
AfterAdvicePlugin leftPlugin = judgeLeftPlugin(leftEntity);
AfterAdvicePlugin rightPlugin = (AfterAdvicePlugin)PluginManager.getPlugin(rightEntity);
IntersectionCriteriaFilterAdvicePlugin intersectionPlugin = new IntersectionCriteriaFilterAdvicePlugin(leftPlugin, rightPlugin);
intersectionPlugin.execute(context);
}
public Object getResult(EnhanceContext context) {
if (Func.isEmpty(context.getResult().getRecords()) && FuncBase.isEmpty(context.getResult().getId())) {
return ResultDataModel.fomat(0L, new ArrayList<>());
}
if (FuncBase.isEmpty(context.getResult().getRecords())) {
ExecuteEnhanceModel enhanceModel = new ExecuteEnhanceModel();
enhanceModel.setId(context.getResult().getId());
enhanceModel.setExitFlag(context.getResult().isExitFlag());
return enhanceModel;
} else {
ResultDataModel resultDataModel = new ResultDataModel();
resultDataModel.setRecords(context.getResult().getRecords());
resultDataModel.setTotal(context.getResult().getTotal());
resultDataModel.setExitFlag(context.getResult().isExitFlag());
return resultDataModel;
}
}
//判断左边是否为空
public AfterAdvicePlugin judgeLeftPlugin(EnhanceJavaEntity leftEntity) {
AfterAdvicePlugin leftPlugin = null;
if (FuncBase.isNotEmpty(leftEntity)) {
leftPlugin = (AfterAdvicePlugin)PluginManager.getPlugin(leftEntity);
} else {
leftPlugin = enhanceContext -> {
};
}
return leftPlugin;
}
//新增增强
public static void addPlugin(EnhanceJavaEntity javaEntity){
try {
String key = javaEntity.getDbformId()+"_"+javaEntity.getButtonCode();
// 1.处理 pluginNames
pluginNames.merge(key, new ArrayList<>(Collections.singletonList(javaEntity)), (oldValue, newValue) -> {
oldValue.addAll(newValue);
return oldValue;
});
// 2.处理 plugins
if (Func.equals(javaEntity.getJavaType(), JavaEnhanceEnum.SPRING.getType())){
String javaClassUrl = javaEntity.getJavaClassUrl();
Object bean = SpringUtils.getBean(javaClassUrl);
if (Func.isNotEmpty(bean) && bean instanceof BaseAdvicePlugin) {
PluginManager.addPlugin(javaClassUrl, (BaseAdvicePlugin) bean);
}
}else if (Func.equals(javaEntity.getJavaType(), JavaEnhanceEnum.CLASS.getType())){
Class<?> enhanceClass = Class.forName(javaEntity.getJavaClassUrl());
BaseAdvicePlugin plugin = (BaseAdvicePlugin) enhanceClass.newInstance();
PluginManager.addPlugin(javaEntity.getJavaClassUrl(), plugin);
}
} catch (Exception e) {
throw new JeeLowCodeException("增强插件加载失败");
}
}
//修改增强
public static void updatePlugins(EnhanceJavaEntity javaEntity){
try {
String key = javaEntity.getDbformId()+"_"+javaEntity.getButtonCode();
AtomicReference<String> oldJavaClassUrlAtomicRe = new AtomicReference<>();
// 1.处理 pluginNames
pluginNames.merge(key, new ArrayList<>(Collections.singletonList(javaEntity)), (oldValue, newValue) -> {
// 先删除再新增
oldValue.removeIf(oldJavaEntity -> {
if (FuncBase.equals(oldJavaEntity.getId(), javaEntity.getId())) {
oldJavaClassUrlAtomicRe.set(oldJavaEntity.getJavaClassUrl());
return true;
}else {
return false;
}
});
oldValue.add(javaEntity);
return oldValue;
});
// 2.处理 plugins 先删除再新增
removePlugins(oldJavaClassUrlAtomicRe.get());
String javaType = javaEntity.getJavaType();
String javaClassUrl = javaEntity.getJavaClassUrl();
if (Func.equals(javaType, JavaEnhanceEnum.SPRING.getType())){
Object bean = SpringUtils.getBean(javaClassUrl);
if (Func.isNotEmpty(bean) && bean instanceof BaseAdvicePlugin) {
PluginManager.addPlugin(javaClassUrl, (BaseAdvicePlugin) bean);
}
}else if (Func.equals(javaType, JavaEnhanceEnum.CLASS.getType())){
Class<?> enhanceClass = Class.forName(javaClassUrl);
BaseAdvicePlugin plugin = (BaseAdvicePlugin) enhanceClass.newInstance();
PluginManager.addPlugin(javaClassUrl, plugin);
}
} catch (Exception e) {
throw new JeeLowCodeException("增强插件加载失败");
}
}
//删除增强
public static void deletePlugins(EnhanceJavaEntity javaEntity){
String key = javaEntity.getDbformId() + "_" + javaEntity.getButtonCode();
// 1.处理 pluginNames
List<EnhanceJavaEntity> javaEntityList = pluginNames.getOrDefault(key, new ArrayList<>());
AtomicReference<String> oldJavaClassUrlAtomicRe = new AtomicReference<>();
javaEntityList.removeIf(oldJavaEntity -> {
if (oldJavaEntity.getId().equals(javaEntity.getId())) {
oldJavaClassUrlAtomicRe.set(oldJavaEntity.getJavaClassUrl());
return true;
}else {
return false;
}
});
if (FuncBase.isEmpty(javaEntityList)) {
pluginNames.remove(key);
}
// 2.处理 plugins
removePlugins(oldJavaClassUrlAtomicRe.get());
}
/**
* 删除 plugins 中的增强
*/
private static void removePlugins(String oldJavaClassUrl){
if (Func.isEmpty(oldJavaClassUrl)) {
return;
}
Set<String> JavaClassUrlSet = pluginNames.values().stream().flatMap(Collection::stream)
.map(EnhanceJavaEntity::getJavaClassUrl).collect(Collectors.toSet());
if (!JavaClassUrlSet.contains(oldJavaClassUrl)) {
PluginManager.removePlugin(oldJavaClassUrl);
}
}
}

View File

@@ -0,0 +1,35 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.criteria;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceContext;
import com.jeelowcode.core.framework.config.aspect.enhance.plugin.AfterAdvicePlugin;
/**
* @author JX
* @create 2024-08-20 10:37
* @dedescription:
*/
public class AndCriteriaFilterAdvicePlugin extends BaseCriterFilterAdvicePlugin implements AfterAdvicePlugin {
public AndCriteriaFilterAdvicePlugin(AfterAdvicePlugin leftCriterFilter, AfterAdvicePlugin rightCriterFilter) {
super(leftCriterFilter,rightCriterFilter);
}
@Override
public void execute(EnhanceContext enhanceContext) {
leftCriterFilter.execute(enhanceContext);
rightCriterFilter.execute(enhanceContext);
}
}

View File

@@ -0,0 +1,35 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.criteria;
import com.jeelowcode.core.framework.config.aspect.enhance.plugin.AfterAdvicePlugin;
/**
* @author JX
* @create 2024-08-19 14:48
* @dedescription: 基础过滤条件
*/
public class BaseCriterFilterAdvicePlugin {
public AfterAdvicePlugin leftCriterFilter;
public AfterAdvicePlugin rightCriterFilter;
public BaseCriterFilterAdvicePlugin(AfterAdvicePlugin leftCriterFilter, AfterAdvicePlugin rightCriterFilter) {
this.leftCriterFilter = leftCriterFilter;
this.rightCriterFilter = rightCriterFilter;
}
}

View File

@@ -0,0 +1,54 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.criteria;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceContext;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceResult;
import com.jeelowcode.core.framework.config.aspect.enhance.plugin.AfterAdvicePlugin;
import org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author JX
* @create 2024-08-19 14:52
* @dedescription: 差集
*/
public class DifferenceCriteriaFilterAdvicePlugin extends BaseCriterFilterAdvicePlugin implements AfterAdvicePlugin {
public DifferenceCriteriaFilterAdvicePlugin(AfterAdvicePlugin leftCriterFilter, AfterAdvicePlugin rightCriterFilter) {
super(leftCriterFilter,rightCriterFilter);
}
@Override
public void execute(EnhanceContext enhanceContext) {
List<Map<String,Object>> differ = new ArrayList<>();
EnhanceContext leftEnhanceContext = enhanceContext.clone();
EnhanceContext rightEnhanceContext = enhanceContext.clone();
//执行增强
leftCriterFilter.execute(leftEnhanceContext);
rightCriterFilter.execute(rightEnhanceContext);
//合并结果
EnhanceResult leftResult = leftEnhanceContext.getResult();
EnhanceResult rightResult = rightEnhanceContext.getResult();
List<Map<String, Object>> leftRecords = leftResult.getRecords();
List<Map<String, Object>> rightRecords = rightResult.getRecords();
differ = (List<Map<String, Object>>) CollectionUtils.subtract(leftRecords, rightRecords);
enhanceContext.getResult().setRecords(differ);
}
}

View File

@@ -0,0 +1,53 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.criteria;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceContext;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceResult;
import com.jeelowcode.core.framework.config.aspect.enhance.plugin.AfterAdvicePlugin;
import org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author JX
* @create 2024-08-19 14:46
* @dedescription: 交集
*/
public class IntersectionCriteriaFilterAdvicePlugin extends BaseCriterFilterAdvicePlugin implements AfterAdvicePlugin {
public IntersectionCriteriaFilterAdvicePlugin(AfterAdvicePlugin leftCriterFilter, AfterAdvicePlugin rightCriterFilter) {
super(leftCriterFilter,rightCriterFilter);
}
@Override
public void execute(EnhanceContext enhanceContext) {
List<Map<String,Object>> intersection = new ArrayList<>();
EnhanceContext leftEnhanceContext = enhanceContext.clone();
EnhanceContext rightEnhanceContext = enhanceContext.clone();
//执行增强
leftCriterFilter.execute(leftEnhanceContext);
rightCriterFilter.execute(rightEnhanceContext);
//合并结果
EnhanceResult leftResult = leftEnhanceContext.getResult();
EnhanceResult rightResult = rightEnhanceContext.getResult();
List<Map<String, Object>> leftRecords = leftResult.getRecords();
List<Map<String, Object>> rightRecords = rightResult.getRecords();
intersection = (List<Map<String, Object>>) CollectionUtils.intersection(leftRecords, rightRecords);
enhanceContext.getResult().setRecords(intersection);
}
}

View File

@@ -0,0 +1,54 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.criteria;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceContext;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceResult;
import com.jeelowcode.core.framework.config.aspect.enhance.plugin.AfterAdvicePlugin;
import org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author JX
* @create 2024-08-19 14:56
* @dedescription: 合集
*/
public class OrCriteriaFilterAdvicePlugin extends BaseCriterFilterAdvicePlugin implements AfterAdvicePlugin {
public OrCriteriaFilterAdvicePlugin(AfterAdvicePlugin leftCriterFilter, AfterAdvicePlugin rightCriterFilter) {
super(leftCriterFilter,rightCriterFilter);
}
@Override
public void execute(EnhanceContext enhanceContext) {
List<Map<String,Object>> or = new ArrayList<>();
EnhanceContext leftEnhanceContext = enhanceContext.clone();
EnhanceContext rightEnhanceContext = enhanceContext.clone();
//执行增强
leftCriterFilter.execute(leftEnhanceContext);
rightCriterFilter.execute(rightEnhanceContext);
//合并结果
EnhanceResult leftResult = leftEnhanceContext.getResult();
EnhanceResult rightResult = rightEnhanceContext.getResult();
List<Map<String, Object>> leftRecords = leftResult.getRecords();
List<Map<String, Object>> rightRecords = rightResult.getRecords();
CollectionUtils.addAll(leftRecords,rightRecords);
or = leftRecords;
enhanceContext.getResult().setRecords(or);
}
}

View File

@@ -0,0 +1,53 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.criteria;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceContext;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceResult;
import com.jeelowcode.core.framework.config.aspect.enhance.plugin.AfterAdvicePlugin;
import org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author JX
* @create 2024-08-19 14:12
* @dedescription: 并集
*/
public class UnionCriteriaFilterAdvicePlugin extends BaseCriterFilterAdvicePlugin implements AfterAdvicePlugin {
public UnionCriteriaFilterAdvicePlugin(AfterAdvicePlugin leftCriterFilter, AfterAdvicePlugin rightCriterFilter) {
super(leftCriterFilter,rightCriterFilter);
}
@Override
public void execute(EnhanceContext enhanceContext) {
List<Map<String,Object>> union = new ArrayList<>();
EnhanceContext leftEnhanceContext = enhanceContext.clone();
EnhanceContext rightEnhanceContext = enhanceContext.clone();
//执行增强
leftCriterFilter.execute(leftEnhanceContext);
rightCriterFilter.execute(rightEnhanceContext);
//合并结果
EnhanceResult leftResult = leftEnhanceContext.getResult();
EnhanceResult rightResult = rightEnhanceContext.getResult();
List<Map<String, Object>> leftRecords = leftResult.getRecords();
List<Map<String, Object>> rightRecords = rightResult.getRecords();
union = (List<Map<String, Object>>) CollectionUtils.union(leftRecords, rightRecords);
enhanceContext.getResult().setRecords(union);
}
}

View File

@@ -0,0 +1,42 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.model;
/**
* @author JX
* @create 2024-08-19 12:00
* @dedescription:
*/
public class BaseEnhanceContext {
private Boolean before; //当前是前置增强
private Boolean onlyBefore = false; //只执行前置增强
public Boolean getBefore() {
return before;
}
public void setBefore(Boolean before) {
this.before = before;
}
public Boolean getOnlyBefore() {
return onlyBefore;
}
public void setOnlyBefore(Boolean onlyBefore) {
this.onlyBefore = onlyBefore;
}
}

View File

@@ -0,0 +1,62 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.model;
import com.jeelowcode.core.framework.entity.EnhanceJavaEntity;
import java.util.List;
/**
* @author JX
* @create 2024-08-15 15:46
* @dedescription:
*/
public class BuildEnhanceContext {
private EnhanceContext context;
private List<EnhanceJavaEntity> entitys;
private List<EnhanceJavaEntity> setOperations;
public BuildEnhanceContext(EnhanceContext context, List<EnhanceJavaEntity> entitys,List<EnhanceJavaEntity> setOperations) {
this.context = context;
this.entitys = entitys;
this.setOperations = setOperations;
}
public EnhanceContext getContext() {
return context;
}
public void setContext(EnhanceContext context) {
this.context = context;
}
public List<EnhanceJavaEntity> getEntitys() {
return entitys;
}
public void setEntitys(List<EnhanceJavaEntity> entitys) {
this.entitys = entitys;
}
public List<EnhanceJavaEntity> getSetOperations() {
return setOperations;
}
public void setSetOperations(List<EnhanceJavaEntity> setOperations) {
this.setOperations = setOperations;
}
}

View File

@@ -0,0 +1,63 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.model;
import com.jeelowcode.core.framework.entity.EnhanceSqlEntity;
import java.util.List;
/**
* @author JX
* @create 2024-08-21 15:52
* @dedescription:
*/
public class BuildSqlEnhanceContext {
private EnhanceContext context;
private List<EnhanceSqlEntity> entitys;
private List<EnhanceSqlEntity> setOperations;
public EnhanceContext getContext() {
return context;
}
public void setContext(EnhanceContext context) {
this.context = context;
}
public List<EnhanceSqlEntity> getEntitys() {
return entitys;
}
public void setEntitys(List<EnhanceSqlEntity> entitys) {
this.entitys = entitys;
}
public List<EnhanceSqlEntity> getSetOperations() {
return setOperations;
}
public void setSetOperations(List<EnhanceSqlEntity> setOperations) {
this.setOperations = setOperations;
}
public BuildSqlEnhanceContext(EnhanceContext context, List<EnhanceSqlEntity> entitys, List<EnhanceSqlEntity> setOperations) {
this.context = context;
this.entitys = entitys;
this.setOperations = setOperations;
}
}

View File

@@ -0,0 +1,85 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.model;
import com.jeelowcode.framework.utils.model.ResultDataModel;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.io.*;
import java.util.List;
import java.util.Map;
/**
* @author JX
* @create 2024-08-12 9:14
* @dedescription: 增强执行上下文
*/
public class EnhanceContext extends BaseEnhanceContext implements Serializable{
//参数
private EnhanceParam param;
//结果
private EnhanceResult result;
public EnhanceParam getParam() {
return param;
}
public void setParam(EnhanceParam param) {
this.param = param;
}
public EnhanceResult getResult() {
return result;
}
public void setResult(EnhanceResult result) {
this.result = result;
}
public void setResult(ResultDataModel resultDataModel){
this.result.setExitFlag(resultDataModel.isExitFlag());
this.result.setRecords(resultDataModel.getRecords());
this.result.setTotal(resultDataModel.getTotal());
}
//通过序列化和反序列化实现深拷贝
@Override
public EnhanceContext clone(){
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(this);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
return (EnhanceContext) ois.readObject();
} catch (IOException |ClassNotFoundException e ) {
e.printStackTrace();
return null;
}
}
public void setParam(Long dbFormId,Map<String,Object> params,List<Map<String,Object>> list){
this.param = new EnhanceParam(dbFormId,params,list);
}
public void setResult(boolean exitFlag,String id,Long total,List<Map<String,Object>> records){
this.result = new EnhanceResult(exitFlag,id,total,records);
}
public void setParam(Long dbFormId, Map<String, Object> params, List<Map<String, Object>> list, Long dataId, Page page, List<Long> dataIdList){
this.param = new EnhanceParam(dbFormId,params,list,dataId,page,dataIdList);
}
}

View File

@@ -0,0 +1,105 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.model;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* @author JX
* @create 2024-08-15 10:02
* @dedescription:
*/
public class EnhanceParam implements Serializable {
private Long dbFormId;
private Map<String, Object> params;
private List<Map<String, Object>> list;
private Long dataId;
private Page page;
private List<Long> dataIdList;
public Long getDbFormId() {
return dbFormId;
}
public void setDbFormId(Long dbFormId) {
this.dbFormId = dbFormId;
}
public Map<String, Object> getParams() {
return params;
}
public void setParams(Map<String, Object> params) {
this.params = params;
}
public List<Map<String, Object>> getList() {
return list;
}
public void setList(List<Map<String, Object>> list) {
this.list = list;
}
public EnhanceParam() {
}
public Long getDataId() {
return dataId;
}
public void setDataId(Long dataId) {
this.dataId = dataId;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public List<Long> getDataIdList() {
return dataIdList;
}
public void setDataIdList(List<Long> dataIdList) {
this.dataIdList = dataIdList;
}
public EnhanceParam(Long dbFormId, Map<String, Object> params, List<Map<String, Object>> list) {
this.dbFormId = dbFormId;
this.params = params;
this.list = list;
}
public EnhanceParam(Long dbFormId, Map<String, Object> params, List<Map<String, Object>> list, Long dataId, Page page, List<Long> dataIdList) {
this.dbFormId = dbFormId;
this.params = params;
this.list = list;
this.dataId = dataId;
this.page = page;
this.dataIdList = dataIdList;
}
}

View File

@@ -0,0 +1,56 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.model;
/**
* @author JX
* @create 2024-08-16 16:32
* @dedescription:
*/
public class EnhanceRespModel {
private int status;
private EnhanceContext data;
private String message;
public boolean checkStatus(){
return this.status == 200;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public EnhanceContext getData() {
return data;
}
public void setData(EnhanceContext data) {
this.data = data;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

View File

@@ -0,0 +1,76 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.model;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* @author JX
* @create 2024-08-15 10:02
* @dedescription:
*/
public class EnhanceResult implements Serializable {
private boolean exitFlag = false;//是否退出
//表单
private String id;
//列表
private Long total;
private List<Map<String, Object>> records;
public boolean isExitFlag() {
return exitFlag;
}
public void setExitFlag(boolean exitFlag) {
this.exitFlag = exitFlag;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Long getTotal() {
return total;
}
public void setTotal(Long total) {
this.total = total;
}
public List<Map<String, Object>> getRecords() {
return records;
}
public void setRecords(List<Map<String, Object>> records) {
this.records = records;
}
public EnhanceResult() {
}
public EnhanceResult(boolean exitFlag, String id, Long total, List<Map<String, Object>> records) {
this.exitFlag = exitFlag;
this.id = id;
this.total = total;
this.records = records;
}
}

View File

@@ -0,0 +1,37 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.model;
/**
* @author JX
* @create 2024-08-16 14:03
* @dedescription:
*/
public enum JavaEnhanceEnum {
SPRING("spring"),
CLASS("class"),
ONLINIE("online_edit"),
HTTP("http");
private String type;
JavaEnhanceEnum(String type) {
this.type = type;
}
public String getType() {
return this.type;
}
}

View File

@@ -0,0 +1,40 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.model;
/**
* @author JX
* @create 2024-08-15 16:05
* @dedescription:
*/
public enum JavaEnhanceEventState {
START("start"),
END("end"),
AROUND("around"),
THROWING("throwing");
private String name;
JavaEnhanceEventState(String NAME) {
this.name = NAME;
}
public String getName() {
return this.name;
}
}

View File

@@ -0,0 +1,26 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.plugin;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceContext;
/**
* @author JX
* @create 2024-08-12 9:27
* @dedescription: 后置增强插件
*/
public interface AfterAdvicePlugin extends BaseAdvicePlugin {
void execute(EnhanceContext enhanceContext);
}

View File

@@ -0,0 +1,29 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.plugin;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceContext;
/**
* @author JX
* @create 2024-08-12 9:25
* @dedescription: 环绕增强插件
*/
public interface AroundAdvicePlugin extends BaseAdvicePlugin {
void beforeExecute(EnhanceContext enhanceContext);
void afterExecute(EnhanceContext enhanceContext);
}

View File

@@ -0,0 +1,26 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.plugin;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceContext;
/**
* @author JX
* @create 2024-08-13 15:34
* @dedescription: 基础增强插件
*/
public interface BaseAdvicePlugin {
default void execute(EnhanceContext enhanceContext){}
}

View File

@@ -0,0 +1,27 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.plugin;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceContext;
/**
* @author JX
* @create 2024-08-12 9:20
* @dedescription: 前置增强插件
*/
public interface BeforeAdvicePlugin extends BaseAdvicePlugin {
void execute(EnhanceContext enhanceContext);
}

View File

@@ -0,0 +1,71 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.plugin;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceContext;
import com.jeelowcode.core.framework.entity.EnhanceJavaEntity;
import java.util.HashMap;
import java.util.Map;
/**
* @author JX
* @create 2024-08-12 9:38
* @dedescription:
*/
public class PluginManager{
public static Map<String, BaseAdvicePlugin> plugins = new HashMap<>();
public static BaseAdvicePlugin getPlugin(String key){
return plugins.get(key);
}
public static BaseAdvicePlugin getPlugin(EnhanceJavaEntity entity){
return plugins.get(entity.getJavaClassUrl());
}
public static void addPlugin(String key, BaseAdvicePlugin plugin){
plugins.put(key,plugin);
}
public static void addPlugin(BaseAdvicePlugin plugin){
plugins.put(plugin.getClass().getName(), plugin);
}
public static boolean removePlugin(String name){
plugins.remove(name);
return true;
}
public static void executePlugin(String name, EnhanceContext enhanceContext){
BaseAdvicePlugin plugin = plugins.get(name);
plugin.execute(enhanceContext);
}
public static void executePlugin(BaseAdvicePlugin plugin, EnhanceContext enhanceContext){
plugin.execute(enhanceContext);
}
public static void executeAroundBeforePlugin(BaseAdvicePlugin plugin, EnhanceContext enhanceContext){
AroundAdvicePlugin aroundPlugin = (AroundAdvicePlugin) plugin;
aroundPlugin.beforeExecute(enhanceContext);
}
public static void executeAroundAfterPlugin(BaseAdvicePlugin plugin, EnhanceContext enhanceContext){
AroundAdvicePlugin aroundPlugin = (AroundAdvicePlugin) plugin;
aroundPlugin.afterExecute(enhanceContext);
}
}

View File

@@ -0,0 +1,26 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhance.plugin;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceContext;
/**
* @author JX
* @create 2024-08-12 11:50
* @dedescription: 异常增强插件
*/
public interface ThrowAdvicePlugin extends BaseAdvicePlugin {
void execute(EnhanceContext model);
}

View File

@@ -0,0 +1,198 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhancereport;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceResult;
import com.jeelowcode.core.framework.config.aspect.enhance.model.JavaEnhanceEnum;
import com.jeelowcode.core.framework.config.aspect.enhance.plugin.AfterAdvicePlugin;
import com.jeelowcode.core.framework.config.aspect.enhancereport.model.BuildEnhanceReportContext;
import com.jeelowcode.core.framework.config.aspect.enhancereport.model.EnhanceReportContext;
import com.jeelowcode.core.framework.config.aspect.enhancereport.model.EnhanceReportParam;
import com.jeelowcode.core.framework.config.aspect.enhancereport.plugin.ReportAfterAdvicePlugin;
import com.jeelowcode.core.framework.config.aspect.enhancereport.plugin.ReportBaseAdvicePlugin;
import com.jeelowcode.core.framework.config.aspect.enhancereport.plugin.ReportPluginManager;
import com.jeelowcode.core.framework.utils.Func;
import com.jeelowcode.framework.exception.JeeLowCodeException;
import com.jeelowcode.framework.utils.model.ResultDataModel;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import com.jeelowcode.framework.utils.utils.FuncBase;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
import org.springframework.stereotype.Component;
import java.util.*;
/**
* 报表统计
*/
@Aspect
@Component
@Slf4j
public class JeeLowCodeAnnotationAspectjReport {
public final static String EXPRESSION = "execution(* com.jeelowcode.core.framework.service.impl.FrameServiceImpl.*(..))";
//拦截方法
public final static String ASPECT_METHODNAME ="getReportDataList";
//需要处理的增强 key=报表code value=增强
private static Map<String, String> pluginNames = new HashMap<>();
@AfterReturning(value = EXPRESSION, returning = "returnVal")
public Object afterReturning(JoinPoint joinPoint, Object returnVal) throws Throwable {
//获取参数
BuildEnhanceReportContext buildEnhanceContext = this.getContextAndPlugins(joinPoint);
if (FuncBase.isEmpty(buildEnhanceContext)) {//没有增强
return returnVal;
}
//不是列表类增强
if (!(returnVal instanceof ResultDataModel)) {
return returnVal;
}
//增强列表
String javaClass = buildEnhanceContext.getJavaClass();
if (Func.isEmpty(javaClass)) {//无增强
return returnVal;
}
EnhanceReportContext context = buildEnhanceContext.getContext();
//把原来返回值封装到上下文context
ResultDataModel resultDataModel = (ResultDataModel) returnVal;
List<Map<String, Object>> records = resultDataModel.getRecords();
if(Func.isEmpty(records)){
records=new ArrayList<>();
}
EnhanceResult enhanceResult = new EnhanceResult();
enhanceResult.setRecords(records);
enhanceResult.setTotal((long)records.size());
context.getParam().setList(records);
context.setResult(enhanceResult);
//执行增强
this.executeJavaEnhance(javaClass, context);
//返回结果
ResultDataModel returnValData = (ResultDataModel) returnVal;
resultDataModel = (ResultDataModel) getResult(context);
returnValData.setRecords(resultDataModel.getRecords());
returnValData.setTotal(resultDataModel.getTotal());
return returnValData;
}
public BuildEnhanceReportContext getContextAndPlugins(JoinPoint joinPoint) {
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
// 获取方法名称
String methodName = methodSignature.getName();
if (Func.notEquals(methodName,ASPECT_METHODNAME)) {//不在拦截范围内 add
return null;
}
//处理参数
Object[] args = joinPoint.getArgs();
LocalVariableTableParameterNameDiscoverer discoverer = new LocalVariableTableParameterNameDiscoverer();
String[] parameterNames = discoverer.getParameterNames(methodSignature.getMethod());
Map<String, Object> paramMap = new HashMap<>();
for (int i = 0; i < parameterNames.length; i++) {
paramMap.put(parameterNames[i], args[i]);
}
//判断该表单,当前的功能是否有增强
String reportCode = (String) paramMap.get("reportCode");
String javaClass = pluginNames.getOrDefault(reportCode, null);
if (Func.isEmpty(javaClass)) {//不存在增强
return null;
}
EnhanceReportParam param = new EnhanceReportParam();
param.setReportCode(reportCode);
param.setList((ArrayList) paramMap.getOrDefault("dataList", null));
param.setParams((Map<String, Object>) paramMap.getOrDefault("params", null));
//把参数放入到上下文
EnhanceReportContext context = new EnhanceReportContext();
context.setParam(param);
BuildEnhanceReportContext buildEnhanceContext = new BuildEnhanceReportContext(context, javaClass);
return buildEnhanceContext;
}
//执行JAVA增强
private void executeJavaEnhance(String javaClassUrl, EnhanceReportContext context) throws Throwable {
ReportBaseAdvicePlugin plugin = ReportPluginManager.getPlugin(javaClassUrl);
if (!(plugin instanceof ReportAfterAdvicePlugin)) {
return;
}
//执行
ReportPluginManager.executePlugin(javaClassUrl, context);
}
public Object getResult(EnhanceReportContext context) {
if (Func.isEmpty(context.getResult().getRecords()) && FuncBase.isEmpty(context.getResult().getId())) {
return ResultDataModel.fomat(0L, new ArrayList<>());
}
ResultDataModel resultDataModel = new ResultDataModel();
resultDataModel.setRecords(context.getResult().getRecords());
resultDataModel.setTotal(context.getResult().getTotal());
resultDataModel.setExitFlag(context.getResult().isExitFlag());
return resultDataModel;
}
//刷新插件
public static void refreshPlugin(String type,String reportCode,String javaClass){
try {
if(Func.isEmpty(javaClass)){
return;
}
if(Func.equals(type,"ADD") ||Func.equals(type,"UPDATE")){
JavaEnhanceEnum javaEnhanceEnum=javaClass.indexOf(".")>0?JavaEnhanceEnum.CLASS:JavaEnhanceEnum.SPRING;
if(Func.equals(javaEnhanceEnum,JavaEnhanceEnum.SPRING)){
Object bean = SpringUtils.getBean(javaClass);
if (Func.isNotEmpty(bean) && bean instanceof ReportBaseAdvicePlugin) {
ReportPluginManager.addPlugin(javaClass, (ReportBaseAdvicePlugin) bean);
pluginNames.put(reportCode,javaClass);
}
}else{
Class<?> enhanceClass = Class.forName(javaClass);
ReportBaseAdvicePlugin plugin = (ReportBaseAdvicePlugin) enhanceClass.newInstance();
ReportPluginManager.addPlugin(javaClass, plugin);
pluginNames.put(reportCode,javaClass);
}
}else if(Func.equals(type,"DEL")){
pluginNames.remove(reportCode,javaClass);
if (!new HashSet<>(pluginNames.values()).contains(javaClass)) {
ReportPluginManager.removePlugin(javaClass);
}
}
} catch (Exception e) {
//e.printStackTrace();
throw new JeeLowCodeException("增强["+javaClass+"]插件加载失败");
}
}
}

View File

@@ -0,0 +1,47 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhancereport.model;
/**
* @author JX
* @create 2024-08-15 15:46
* @dedescription:
*/
public class BuildEnhanceReportContext {
private EnhanceReportContext context;
private String javaClass;
public BuildEnhanceReportContext(EnhanceReportContext context, String javaClass) {
this.context = context;
this.javaClass = javaClass;
}
public EnhanceReportContext getContext() {
return context;
}
public void setContext(EnhanceReportContext context) {
this.context = context;
}
public String getJavaClass() {
return javaClass;
}
public void setJavaClass(String javaClass) {
this.javaClass = javaClass;
}
}

View File

@@ -0,0 +1,87 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhancereport.model;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeelowcode.core.framework.config.aspect.enhance.model.BaseEnhanceContext;
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceResult;
import com.jeelowcode.framework.utils.model.ResultDataModel;
import java.io.*;
import java.util.List;
import java.util.Map;
/**
* @author JX
* @create 2024-08-12 9:14
* @dedescription: 增强执行上下文
*/
public class EnhanceReportContext extends BaseEnhanceContext implements Serializable{
//参数
private EnhanceReportParam param;
//结果
private EnhanceResult result;
public EnhanceReportParam getParam() {
return param;
}
public void setParam(EnhanceReportParam param) {
this.param = param;
}
public EnhanceResult getResult() {
return result;
}
public void setResult(EnhanceResult result) {
this.result = result;
}
public void setResult(ResultDataModel resultDataModel){
this.result.setExitFlag(resultDataModel.isExitFlag());
this.result.setRecords(resultDataModel.getRecords());
this.result.setTotal(resultDataModel.getTotal());
}
//通过序列化和反序列化实现深拷贝
@Override
public EnhanceReportContext clone(){
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(this);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
return (EnhanceReportContext) ois.readObject();
} catch (IOException |ClassNotFoundException e ) {
e.printStackTrace();
return null;
}
}
public void setParam(String reportCode,Map<String,Object> params,List<Map<String,Object>> list){
this.param = new EnhanceReportParam(reportCode,params,list);
}
public void setResult(boolean exitFlag,String id,Long total,List<Map<String,Object>> records){
this.result = new EnhanceResult(exitFlag,id,total,records);
}
public void setParam(String reportCode, Map<String, Object> params, List<Map<String, Object>> list, Long dataId, Page page, List<Long> dataIdList){
this.param = new EnhanceReportParam(reportCode,params,list,dataId,page,dataIdList);
}
}

View File

@@ -0,0 +1,106 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhancereport.model;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* @author JX
* @create 2024-08-15 10:02
* @dedescription:
*/
public class EnhanceReportParam implements Serializable {
private String reportCode;
private Map<String, Object> params;
private List<Map<String, Object>> list;
private Long dataId;
private Page page;
private List<Long> dataIdList;
public String getReportCode() {
return reportCode;
}
public void setReportCode(String reportCode) {
this.reportCode = reportCode;
}
public Map<String, Object> getParams() {
return params;
}
public void setParams(Map<String, Object> params) {
this.params = params;
}
public List<Map<String, Object>> getList() {
return list;
}
public void setList(List<Map<String, Object>> list) {
this.list = list;
}
public EnhanceReportParam() {
}
public Long getDataId() {
return dataId;
}
public void setDataId(Long dataId) {
this.dataId = dataId;
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
public List<Long> getDataIdList() {
return dataIdList;
}
public void setDataIdList(List<Long> dataIdList) {
this.dataIdList = dataIdList;
}
public EnhanceReportParam(String reportCode, Map<String, Object> params, List<Map<String, Object>> list) {
this.reportCode = reportCode;
this.params = params;
this.list = list;
}
public EnhanceReportParam(String reportCode, Map<String, Object> params, List<Map<String, Object>> list, Long dataId, Page page, List<Long> dataIdList) {
this.reportCode = reportCode;
this.params = params;
this.list = list;
this.dataId = dataId;
this.page = page;
this.dataIdList = dataIdList;
}
}

View File

@@ -0,0 +1,24 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhancereport.plugin;
import com.jeelowcode.core.framework.config.aspect.enhancereport.model.EnhanceReportContext;
/**
* 报表统计 后置增强(报表统计专属)
*/
public interface ReportAfterAdvicePlugin extends ReportBaseAdvicePlugin {
void execute(EnhanceReportContext enhanceContext);
}

View File

@@ -0,0 +1,26 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhancereport.plugin;
import com.jeelowcode.core.framework.config.aspect.enhancereport.model.EnhanceReportContext;
/**
* @author JX
* @create 2024-08-13 15:34
* @dedescription: 基础增强插件
*/
public interface ReportBaseAdvicePlugin {
default void execute(EnhanceReportContext enhanceContext){}
}

View File

@@ -0,0 +1,54 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.enhancereport.plugin;
import com.jeelowcode.core.framework.config.aspect.enhancereport.model.EnhanceReportContext;
import java.util.HashMap;
import java.util.Map;
public class ReportPluginManager {
public static Map<String, ReportBaseAdvicePlugin> plugins = new HashMap<>();
public static ReportBaseAdvicePlugin getPlugin(String key){
return plugins.get(key);
}
public static void addPlugin(String key, ReportBaseAdvicePlugin plugin){
plugins.put(key,plugin);
}
public static void addPlugin(ReportBaseAdvicePlugin plugin){
plugins.put(plugin.getClass().getName(), plugin);
}
public static boolean removePlugin(String name){
plugins.remove(name);
return true;
}
public static void executePlugin(String name, EnhanceReportContext enhanceContext){
ReportBaseAdvicePlugin plugin = plugins.get(name);
plugin.execute(enhanceContext);
}
public static void executePlugin(ReportBaseAdvicePlugin plugin, EnhanceReportContext enhanceContext){
plugin.execute(enhanceContext);
}
}

View File

@@ -0,0 +1,61 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.aspect.nologin;
import com.jeelowcode.core.framework.service.IFormService;
import com.jeelowcode.core.framework.utils.Func;
import com.jeelowcode.framework.constants.FrameErrorCodeConstants;
import com.jeelowcode.framework.exception.JeeLowCodeException;
import com.jeelowcode.framework.utils.enums.AuthTypeEnum;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.stereotype.Component;
/**
* 不登录是否可以查看dbform配置
*/
@Aspect
@Component
public class JeeLowCodeNoLoginViewDbFormAspect {
private ExpressionParser parser = new SpelExpressionParser();
@Autowired
private IFormService formService;
@Around("@annotation(com.jeelowcode.framework.utils.annotation.JeeLowCodeNoLoginViewDbForm)")
public Object aroundMethod(ProceedingJoinPoint joinPoint) throws Throwable {
// 获取方法的参数
Object[] args = joinPoint.getArgs();
// 假设dbformId是第一个参数你可以根据实际情况调整索引
Long dbformId = (Long) args[0];
if (Func.isEmpty(dbformId)) {
throw new JeeLowCodeException(FrameErrorCodeConstants.FRAME_PARAM_NULL_ERROR.getMsg());
}
//判断该接口是否勾选 不登录可查看
AuthTypeEnum authType = formService.getAuthType(dbformId);
if (!Func.equals(authType, AuthTypeEnum.authOpen)) {//配置没有勾选,判断是否已经登录了
throw new JeeLowCodeException(FrameErrorCodeConstants.FRAME_LOGIN_VIEW_ERROR.getMsg());
}
return joinPoint.proceed();
}
}

View File

@@ -0,0 +1,37 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand;
import com.jeelowcode.core.framework.config.btncommand.button.IButtonCommand;
/**
* 命令发起者
*/
public class ButtonInvoker<T> {
private IButtonCommand<T> buttonCommand;
//发起命令
public T executeCommand(){
return (T)buttonCommand.execute();
}
public IButtonCommand getButtonCommand() {
return buttonCommand;
}
public void setButtonCommand(IButtonCommand buttonCommand) {
this.buttonCommand = buttonCommand;
}
}

View File

@@ -0,0 +1,53 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.button;
import com.jeelowcode.core.framework.config.btncommand.receiver.IButtonCommandReceiver;
import java.util.List;
/**
* 具体命令-新增按钮命令
*/
public class AddBatchButtonCommand implements IButtonCommand<List<String>> {
//命令执行者
private IButtonCommandReceiver<List<String>> recevier;
private String name = "批量新增";
/**
* 绑定执行者
* @param recevier 执行者
*/
public AddBatchButtonCommand(IButtonCommandReceiver recevier) {
this.recevier = recevier;
}
/**
* 执行命令
* @return
*/
@Override
public List<String> execute() {
return recevier.receiver();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@@ -0,0 +1,54 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.button;
import com.jeelowcode.core.framework.config.btncommand.receiver.IButtonCommandReceiver;
import com.jeelowcode.framework.utils.model.ExecuteEnhanceModel;
/**
* 具体命令-新增按钮命令
*/
public class AddButtonCommand implements IButtonCommand<ExecuteEnhanceModel> {
//命令执行者
private IButtonCommandReceiver<ExecuteEnhanceModel> recevier;
private String name = "新增";
/**
* 绑定执行者
* @param recevier 执行者
*/
public AddButtonCommand(IButtonCommandReceiver recevier) {
this.recevier = recevier;
}
/**
* 执行命令
* @return
*/
@Override
public ExecuteEnhanceModel execute() {
return recevier.receiver();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@@ -0,0 +1,47 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.button;
import com.jeelowcode.core.framework.config.btncommand.receiver.IButtonCommandReceiver;
/**
* 具体命令-分页按钮命令
*/
public class DefinableButtonCommand implements IButtonCommand<Object> {
//命令执行者
private IButtonCommandReceiver recevier;
private String name = "自定义";
/**
* 绑定执行者
*
* @param recevier 执行者
*/
public DefinableButtonCommand(IButtonCommandReceiver recevier) {
this.recevier = recevier;
}
/**
* 执行命令
*
* @return
*/
@Override
public Object execute() {
return recevier.receiver();
}
}

View File

@@ -0,0 +1,47 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.button;
import com.jeelowcode.core.framework.config.btncommand.receiver.IButtonCommandReceiver;
import com.jeelowcode.framework.utils.model.ExecuteEnhanceModel;
/**
* 具体命令-删除按钮命令
*/
public class DelButtonCommand implements IButtonCommand<ExecuteEnhanceModel> {
//命令执行者
private IButtonCommandReceiver<ExecuteEnhanceModel> recevier;
private String name = "删除";
/**
* 绑定执行者
*
* @param recevier 执行者
*/
public DelButtonCommand(IButtonCommandReceiver recevier) {
this.recevier = recevier;
}
/**
* 执行命令
*
* @return
*/
@Override
public ExecuteEnhanceModel execute() {
return recevier.receiver();
}
}

View File

@@ -0,0 +1,48 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.button;
import com.jeelowcode.core.framework.config.btncommand.receiver.IButtonCommandReceiver;
import com.jeelowcode.framework.utils.model.ResultDataModel;
/**
* 具体命令-详情按钮命令
*/
public class DetailsButtonCommand implements IButtonCommand<ResultDataModel> {
//命令执行者
private IButtonCommandReceiver<ResultDataModel> recevier;
private String name = "详情";
/**
* 绑定执行者
*
* @param recevier 执行者
*/
public DetailsButtonCommand(IButtonCommandReceiver recevier) {
this.recevier = recevier;
}
/**
* 执行命令
*
* @return
*/
@Override
public ResultDataModel execute() {
return recevier.receiver();
}
}

View File

@@ -0,0 +1,48 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.button;
import com.jeelowcode.core.framework.config.btncommand.receiver.IButtonCommandReceiver;
import com.jeelowcode.framework.utils.model.ExecuteEnhanceModel;
/**
* 具体命令-编辑按钮命令
*/
public class EditBatchButtonCommand implements IButtonCommand<ExecuteEnhanceModel> {
//命令执行者
private IButtonCommandReceiver<ExecuteEnhanceModel> recevier;
private String name = "批量编辑";
/**
* 绑定执行者
*
* @param recevier 执行者
*/
public EditBatchButtonCommand(IButtonCommandReceiver recevier) {
this.recevier = recevier;
}
/**
* 执行命令
*
* @return
*/
@Override
public ExecuteEnhanceModel execute() {
return recevier.receiver();
}
}

View File

@@ -0,0 +1,48 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.button;
import com.jeelowcode.core.framework.config.btncommand.receiver.IButtonCommandReceiver;
import com.jeelowcode.framework.utils.model.ExecuteEnhanceModel;
/**
* 具体命令-编辑按钮命令
*/
public class EditButtonCommand implements IButtonCommand<ExecuteEnhanceModel> {
//命令执行者
private IButtonCommandReceiver<ExecuteEnhanceModel> recevier;
private String name = "编辑";
/**
* 绑定执行者
*
* @param recevier 执行者
*/
public EditButtonCommand(IButtonCommandReceiver recevier) {
this.recevier = recevier;
}
/**
* 执行命令
*
* @return
*/
@Override
public ExecuteEnhanceModel execute() {
return recevier.receiver();
}
}

View File

@@ -0,0 +1,47 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.button;
import com.jeelowcode.core.framework.config.btncommand.receiver.IButtonCommandReceiver;
import com.jeelowcode.core.framework.params.model.ExcelModel;
/**
* 具体命令-新增按钮命令
*/
public class ExportButtonCommand implements IButtonCommand<ExcelModel> {
//命令执行者
private IButtonCommandReceiver<ExcelModel> recevier;
private String name = "导出数据";
/**
* 绑定执行者
* @param recevier 执行者
*/
public ExportButtonCommand(IButtonCommandReceiver recevier) {
this.recevier = recevier;
}
/**
* 执行命令
* @return
*/
@Override
public ExcelModel execute() {
ExcelModel receiver = recevier.receiver();
return receiver;
}
}

View File

@@ -0,0 +1,47 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.button;
import com.jeelowcode.core.framework.config.btncommand.receiver.IButtonCommandReceiver;
import com.jeelowcode.core.framework.params.model.ExcelTemplateModel;
/**
* 具体命令-新增按钮命令
*/
public class ExportTemplateButtonCommand implements IButtonCommand<ExcelTemplateModel> {
//命令执行者
private IButtonCommandReceiver<ExcelTemplateModel> recevier;
private String name = "导出数据模板";
/**
* 绑定执行者
* @param recevier 执行者
*/
public ExportTemplateButtonCommand(IButtonCommandReceiver recevier) {
this.recevier = recevier;
}
/**
* 执行命令
* @return
*/
@Override
public ExcelTemplateModel execute() {
ExcelTemplateModel receiver = recevier.receiver();
return receiver;
}
}

View File

@@ -0,0 +1,23 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.button;
/**
* 命令-所有具体命令都要实现该接口
* @param <T>
*/
public interface IButtonCommand<T> {
//统一执行方法
T execute();
}

View File

@@ -0,0 +1,47 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.button;
import com.jeelowcode.core.framework.config.btncommand.receiver.IButtonCommandReceiver;
import com.jeelowcode.core.framework.params.model.ExcelImportResultModel;
/**
* 具体命令-新增按钮命令
*/
public class ImportButtonCommand implements IButtonCommand<ExcelImportResultModel> {
//命令执行者
private IButtonCommandReceiver<ExcelImportResultModel> recevier;
private String name = "导入";
/**
* 绑定执行者
* @param recevier 执行者
*/
public ImportButtonCommand(IButtonCommandReceiver recevier) {
this.recevier = recevier;
}
/**
* 执行命令
* @return
*/
@Override
public ExcelImportResultModel execute() {
ExcelImportResultModel receiver = recevier.receiver();
return receiver;
}
}

View File

@@ -0,0 +1,48 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.button;
import com.jeelowcode.core.framework.config.btncommand.receiver.IButtonCommandReceiver;
import com.jeelowcode.framework.utils.model.ResultDataModel;
/**
* 具体命令-分页按钮命令
*/
public class ListButtonCommand implements IButtonCommand<ResultDataModel> {
//命令执行者
private IButtonCommandReceiver<ResultDataModel> recevier;
private String name = "分页";
/**
* 绑定执行者
*
* @param recevier 执行者
*/
public ListButtonCommand(IButtonCommandReceiver recevier) {
this.recevier = recevier;
}
/**
* 执行命令
*
* @return
*/
@Override
public ResultDataModel execute() {
return recevier.receiver();
}
}

View File

@@ -0,0 +1,49 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.button;
import com.jeelowcode.core.framework.config.btncommand.receiver.IButtonCommandReceiver;
import java.util.Map;
/**
* 具体命令-统计按钮命令
*/
public class SummaryButtonCommand implements IButtonCommand<Map> {
//命令执行者
private IButtonCommandReceiver<Map> recevier;
private String name = "统计";
/**
* 绑定执行者
*
* @param recevier 执行者
*/
public SummaryButtonCommand(IButtonCommandReceiver recevier) {
this.recevier = recevier;
}
/**
* 执行命令
*
* @return
*/
@Override
public Map execute() {
return recevier.receiver();
}
}

View File

@@ -0,0 +1,23 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.definable;
/**
* 自定义按钮
* @param <T> 返回值
* @param <S> 参数
*/
public interface DefinableButtonPlugin<T,S> {
T execute(S param);
}

View File

@@ -0,0 +1,85 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.definable;
import cn.hutool.cache.Cache;
import cn.hutool.cache.CacheUtil;
import com.jeelowcode.framework.exception.JeeLowCodeException;
import com.jeelowcode.core.framework.utils.Func;
import lombok.extern.slf4j.Slf4j;
import java.util.HashMap;
import java.util.Map;
@Slf4j
public class DefinablePluginManager<T> {
//从数据库读取放入到map
public static Map<String,String> allDefinableMap=new HashMap<>();
//只保留最近10个常用的
Cache<String, DefinableButtonPlugin> cache = CacheUtil.newLRUCache(10);
//初始化实例
public static DefinableButtonPlugin initClazz(String clazzStr) {
try {
Class<?> clazz = Class.forName(clazzStr);
DefinableButtonPlugin definableButtonPlugin = (DefinableButtonPlugin)clazz.newInstance();//实例化
return definableButtonPlugin;
} catch (Exception e) {
throw new JeeLowCodeException(e.getMessage());
}
}
//添加插件
public void addPlugin(String key, DefinableButtonPlugin plugin) {
cache.put(key, plugin);
}
//移除
public void remove(String key) {
if (cache.containsKey(key)) {
cache.remove(key);
}
}
public DefinableButtonPlugin getPlugin(String key) {
if (cache.containsKey(key)) {
return cache.get(key);
}
if(!allDefinableMap.containsKey(key)){
log.error("自定义按钮控件不存在==》"+key);
return null;
}
//没有在队列里面,则重新实例化
String clazzUrl = allDefinableMap.get(key);
addPlugin(key, initClazz(clazzUrl));
return cache.get(key);
}
//运行插件
public Object executePlugin(String key,T param) {
DefinableButtonPlugin plugin = this.getPlugin(key);
if(Func.isEmpty(plugin)){
return null;
}
return plugin.execute(param);
}
}

View File

@@ -0,0 +1,27 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.param;
import lombok.Data;
import java.util.Map;
/**
* 新增按钮参数
*/
@Data
public class ButtonParamAdd {
private Long dbFormId;//表单id
private Map<String, Object> params;//参数
}

View File

@@ -0,0 +1,28 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.param;
import cn.hutool.json.JSONObject;
import lombok.Data;
import java.util.List;
/**
* 新增按钮参数
*/
@Data
public class ButtonParamAddBatch {
private Long dbFormId;//表单id
private List<JSONObject> dataMapList;//批量参数
}

View File

@@ -0,0 +1,24 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.param;
import lombok.Data;
/**
* 自定义按钮参数
*/
@Data
public class ButtonParamDefinable {
}

View File

@@ -0,0 +1,27 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.param;
import lombok.Data;
import java.util.List;
/**
* 删除按钮参数
*/
@Data
public class ButtonParamDel {
private Long dbFormId;
private List<Long> dataIdList;
}

View File

@@ -0,0 +1,28 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.param;
import lombok.Data;
import java.util.Map;
/**
* 新增按钮参数
*/
@Data
public class ButtonParamDetail {
private Long dbFormId;//表单id
private Long dataId;
private Map<String,Object> params;
}

View File

@@ -0,0 +1,28 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.param;
import lombok.Data;
import java.util.Map;
/**
* 编辑按钮参数
*/
@Data
public class ButtonParamEdit {
private Long dbFormId;
private Long dataId;
private Map<String,Object> params;
}

View File

@@ -0,0 +1,28 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.param;
import cn.hutool.json.JSONObject;
import lombok.Data;
import java.util.List;
/**
* 编辑按钮参数
*/
@Data
public class ButtonParamEditBatch {
private Long dbFormId;
private List<JSONObject> jsonObjectList;
}

View File

@@ -0,0 +1,27 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.param;
import lombok.Data;
import java.util.Map;
/**
* 导入按钮参数
*/
@Data
public class ButtonParamExport {
private Long dbFormId;//表单id
private Map<String, Object> params ;//文参数
}

View File

@@ -0,0 +1,24 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.param;
import lombok.Data;
/**
* 导入按钮参数
*/
@Data
public class ButtonParamExportTemplate {
private Long dbFormId;//表单id
}

View File

@@ -0,0 +1,31 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.param;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* 导入按钮参数
*/
@Data
public class ButtonParamImport {
private String serviceType;//业务类型 IMPORT_TEMPLATE = 导入模版 HANBLE_TEMPLATE = 处理模版
private Long dbFormId;//表单id
private String fileName;
private List<Map<String, Object>> dataMapList;//数据列表
private Long batchCode;
}

View File

@@ -0,0 +1,29 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.param;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import java.util.Map;
/**
* 分页按钮参数
*/
@Data
public class ButtonParamList {
private Long dbFormId;//表单id
private Page page;
private Map<String,Object> params;
}

View File

@@ -0,0 +1,27 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.param;
import lombok.Data;
import java.util.Map;
/**
* 导入按钮参数
*/
@Data
public class ButtonParamReportExport {
private String reportCode;//报表编码
private Map<String, Object> params ;//文参数
}

View File

@@ -0,0 +1,29 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.param;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import java.util.Map;
/**
* 分页按钮参数
*/
@Data
public class ButtonParamReportList {
private String reportCode;//报表编号
private Page page;
private Map<String,Object> params;
}

View File

@@ -0,0 +1,27 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.param;
import lombok.Data;
import java.util.Map;
/**
* 统计按钮参数
*/
@Data
public class ButtonParamSummary {
private Long dbFormId;//表单id
private Map<String,Object> params;
}

View File

@@ -0,0 +1,58 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.receiver;
import com.jeelowcode.core.framework.utils.Func;
import com.jeelowcode.framework.utils.model.ExecuteEnhanceModel;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import com.jeelowcode.core.framework.config.btncommand.param.ButtonParamAdd;
import com.jeelowcode.core.framework.service.IFrameService;
import java.util.Map;
/**
* 新增按钮执行者
*/
public class ButtonReceiverAdd implements IButtonCommandReceiver<ExecuteEnhanceModel> {
private String pluginKey;
private ButtonParamAdd param;
public ButtonReceiverAdd(ButtonParamAdd param) {
this.param = param;
}
/**
* 执行命令
* @return
*/
@Override
public ExecuteEnhanceModel receiver() {
IFrameService frameService = SpringUtils.getBean(IFrameService.class);
Long dbFormId = param.getDbFormId();
Map<String, Object> paramMap = param.getParams();
if(Func.isNotEmpty(paramMap)){
paramMap.remove("id");
}
ExecuteEnhanceModel enhanceModel = frameService.saveData(dbFormId, paramMap);
return enhanceModel;
}
}

View File

@@ -0,0 +1,58 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.receiver;
import cn.hutool.json.JSONObject;
import com.jeelowcode.core.framework.config.btncommand.param.ButtonParamAddBatch;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import com.jeelowcode.core.framework.service.IFrameService;
import java.util.List;
/**
* 新增按钮执行者
*/
public class ButtonReceiverAddBatch implements IButtonCommandReceiver<List<String>> {
private String pluginKey;
private ButtonParamAddBatch param;
public ButtonReceiverAddBatch(ButtonParamAddBatch param) {
this.param = param;
}
/**
* 执行命令
* @return
*/
@Override
public List<String> receiver() {
IFrameService frameService = SpringUtils.getBean(IFrameService.class);
Long dbFormId = param.getDbFormId();
List<JSONObject> jsonList = param.getDataMapList();
for(JSONObject jsonObject:jsonList){
jsonObject.remove("id");
}
List<String> idList = frameService.saveBatchData(dbFormId, jsonList);
return idList;
}
}

View File

@@ -0,0 +1,198 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.receiver;
import com.jeelowcode.core.framework.entity.ReportEntity;
import com.jeelowcode.core.framework.params.vo.role.DbFormRoleFieldVo;
import com.jeelowcode.framework.excel.model.ExcelTitleModel;
import com.jeelowcode.framework.exception.JeeLowCodeException;
import com.jeelowcode.framework.utils.enums.YNEnum;
import com.jeelowcode.framework.utils.model.ResultDataModel;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import com.jeelowcode.core.framework.config.virtualization.VirtualizationFieldPluginManager;
import com.jeelowcode.core.framework.entity.FormFieldWebEntity;
import com.jeelowcode.core.framework.mapper.FormFieldWebMapper;
import com.jeelowcode.core.framework.params.model.WebFormatConfigModel;
import com.jeelowcode.core.framework.service.IFormService;
import com.jeelowcode.core.framework.utils.Func;
import org.apache.commons.collections4.map.LinkedMap;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
/**
* 公共
*/
public class ButtonReceiverBase {
//移除不是导入项目
public void removeNotExport(LinkedMap<String, ExcelTitleModel> headTitleMap, List<DbFormRoleFieldVo> roleFieldVoList) {
if(Func.isEmpty(roleFieldVoList)){
return;
}
Map<String, DbFormRoleFieldVo> roleDisableMap =roleFieldVoList.stream()
.collect(Collectors.toMap(DbFormRoleFieldVo::getFieldCode, entity -> entity));
Iterator<Map.Entry<String, ExcelTitleModel>> iterator = headTitleMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, ExcelTitleModel> entry = iterator.next();
String key = entry.getKey();
if(roleDisableMap.containsKey(key)){//存在权限问题
DbFormRoleFieldVo roleVo = roleDisableMap.get(key);
//如果全部为空话,看最大的那个,最大的那个为N说明是没有权限需要剔除
if(Func.isEmpty(roleVo.getFormIsEdit()) && Func.isEmpty(roleVo.getFormIsView()) && Func.isEmpty(roleVo.getListIsView())&&Func.equals(roleVo.getEnableState(), YNEnum.N.getCode())){
iterator.remove();
}
}
}
}
/**
*
* 移除不是界面显示的列表-列表数据
*
* @param records
*/
public void removeNotWebView(Long dbFormId, List<Map<String, Object>> records,List<DbFormRoleFieldVo> roleFieldVoList) {
if (Func.isEmpty(records)) {
return;
}
Map<String, DbFormRoleFieldVo> roleDisableMap =null;
if(Func.isNotEmpty(roleFieldVoList)){
//转为map
roleDisableMap = roleFieldVoList.stream()
.collect(Collectors.toMap(DbFormRoleFieldVo::getFieldCode, entity -> entity));
}
IFormService formService = SpringUtils.getBean(IFormService.class);
Set<String> webViewFieldSet = new HashSet<>(formService.getWebViewFieldList(dbFormId));
Map<String, DbFormRoleFieldVo> finalRoleDisableMap = roleDisableMap;
try {
Func.jeelowcodeForkJoinPool().submit(() -> records.parallelStream().forEach(recordMap -> recordMap.keySet().removeIf(key -> {
if(Func.equals(key,"jeelowcode_subtable_data") || Func.equals(key,"hasChildren") || Func.equals(key,"leaf")){
return false;
}
boolean noRoleFlag=false;
if(Func.isNotEmpty(finalRoleDisableMap) && finalRoleDisableMap.containsKey(key)){
DbFormRoleFieldVo roleVo = finalRoleDisableMap.get(key);
//如果全部为空话,看最大的那个,最大的那个为N说明是没有权限需要剔除
if(Func.isEmpty(roleVo.getFormIsEdit()) && Func.isEmpty(roleVo.getFormIsView()) && Func.isEmpty(roleVo.getListIsView())&&Func.equals(roleVo.getEnableState(),YNEnum.N.getCode())){
noRoleFlag=true;
}
}
return !webViewFieldSet.contains(key) || noRoleFlag;
}))).get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e.getMessage());
}
}
/**
* 处理字段凭接(虚拟化字段)
*
* @param dbFormId
* @param records
*/
public void webViewAppend(Long dbFormId, List<Map<String, Object>> records) {
FormFieldWebMapper fieldWebMapper = SpringUtils.getBean(FormFieldWebMapper.class);
// 获取表单的字段对应的字典
IFormService formService = SpringUtils.getBean(IFormService.class);
Map<String, Map<String, Object>> fieldDictMap = formService.getFieldDict(dbFormId);
List<FormFieldWebEntity> webEntityList = fieldWebMapper.webEntityListAndFormatConfigIsNotNull(dbFormId);
webEntityList.stream().forEach(web->{
String fieldCode = web.getFieldCode();
String formatConfig = web.getFormatConfig();
if(Func.isEmpty(formatConfig)){
return;
}
WebFormatConfigModel webFormatConfigModel = Func.json2Bean(formatConfig, WebFormatConfigModel.class);
if(Func.isEmpty(webFormatConfigModel)){
return;
}
String formatType = webFormatConfigModel.getFormatType();
if(Func.isEmpty(formatType) || !Func.equals(formatType,"java")){
return;
}
WebFormatConfigModel.Json formatJson= webFormatConfigModel.getFormatJson();
WebFormatConfigModel.JavaModel javaModel = formatJson.getJava();
String valueType = javaModel.getValueType();
List<WebFormatConfigModel.JavaGroup> groupList = javaModel.getGroup();
WebFormatConfigModel.JavaCustom custom = javaModel.getCustom();
switch (valueType){
case "group"://表达式
records.stream().forEach(record -> {
record.put(fieldCode, this.getGroupVal(fieldDictMap, groupList, new HashMap<>(record)));
});
break;
case "custom":
records.stream().forEach(record -> {
//运行插件
String result = VirtualizationFieldPluginManager.executePlugin(custom.getJavaPath(), new HashMap<>(record));
record.put(fieldCode, result);
});
break;
}
});
}
//获取分组
private String getGroupVal(Map<String, Map<String, Object>> fieldDictMap, List<WebFormatConfigModel.JavaGroup> groupList, Map<String, Object> dataMap) {
this.replaceDict(fieldDictMap, dataMap);// 替换字典值
String formatVal = ""; // 用于存储格式化后的值
for (WebFormatConfigModel.JavaGroup group : groupList) {
String value = group.getValue();
String type = group.getType();
if(Func.isEmpty(value)){
continue;
}
switch (type) {
case "CONCAT":
formatVal += value;
break;
case "CALCULATE":
formatVal += Func.executeJavaExpress(value, dataMap);
break;
}
}
return formatVal;
}
/**
* 替换字典值
*/
private void replaceDict(Map<String, Map<String, Object>> fieldDictMap, Map<String, Object> dataMap){
if (Func.isEmpty(fieldDictMap) || Func.isEmpty(dataMap)) {
return;
}
fieldDictMap.keySet().stream().forEach(field -> {
Object oldValue = dataMap.get(field);
if (Func.isEmpty(oldValue)) {
return;
}
Map<String, Object> dictMap = fieldDictMap.get(field);
if (Func.isEmpty(dictMap)) {
return;
}
Object newValue = dictMap.get(oldValue.toString());
if (Func.isEmpty(newValue)) {
return;
}
dataMap.put(field, newValue);
});
}
}

View File

@@ -0,0 +1,44 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.receiver;
import com.jeelowcode.core.framework.config.btncommand.definable.DefinablePluginManager;
/**
* 自定义按钮执行者
*/
public class ButtonReceiverDefinable implements IButtonCommandReceiver<Object> {
private String pluginKey;
private Object param;
public ButtonReceiverDefinable(String pluginKey, Object param) {
this.pluginKey = pluginKey;
this.param = param;
}
/**
* 执行命令
* @return
*/
@Override
public Object receiver() {
DefinablePluginManager definablePluginManager=new DefinablePluginManager();
return definablePluginManager.executePlugin(pluginKey, param);
}
}

View File

@@ -0,0 +1,57 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.receiver;
import com.jeelowcode.core.framework.config.btncommand.param.ButtonParamDel;
import com.jeelowcode.framework.utils.model.ExecuteEnhanceModel;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import com.jeelowcode.core.framework.service.IFrameService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 删除按钮执行者
*/
public class ButtonReceiverDel implements IButtonCommandReceiver<ExecuteEnhanceModel> {
private String pluginKey;
private ButtonParamDel param;
public ButtonReceiverDel(ButtonParamDel param) {
this.param = param;
}
/**
* 执行命令
* @return
*/
@Override
public ExecuteEnhanceModel receiver() {
IFrameService frameService = SpringUtils.getBean(IFrameService.class);
Long dbformId = param.getDbFormId();
List<Long> dataIdList = param.getDataIdList();
Map<String,Object> params=new HashMap<>();
params.put("dataIdList",dataIdList);
params.put("whereFieldCode","id");
//逻辑删除
ExecuteEnhanceModel enhanceModel = frameService.delData(dbformId, params);
return enhanceModel;
}
}

View File

@@ -0,0 +1,63 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.receiver;
import com.jeelowcode.core.framework.config.btncommand.param.ButtonParamDetail;
import com.jeelowcode.core.framework.params.vo.role.DbFormRoleFieldVo;
import com.jeelowcode.framework.utils.adapter.IJeeLowCodeAdapter;
import com.jeelowcode.framework.utils.model.ResultDataModel;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import com.jeelowcode.core.framework.service.IDbFormRoleService;
import com.jeelowcode.core.framework.service.IFrameService;
import java.util.List;
import java.util.Map;
/**
* 详情按钮执行者
*/
public class ButtonReceiverDetail extends ButtonReceiverBase implements IButtonCommandReceiver<ResultDataModel> {
private String pluginKey;
private ButtonParamDetail param;
public ButtonReceiverDetail(ButtonParamDetail param) {
this.param = param;
}
/**
* 执行命令
* @return
*/
@Override
public ResultDataModel receiver() {
IFrameService frameService = SpringUtils.getBean(IFrameService.class);
IDbFormRoleService dbFormRoleService = SpringUtils.getBean(IDbFormRoleService.class);
IJeeLowCodeAdapter jeeLowCodeAdapter = SpringUtils.getBean(IJeeLowCodeAdapter.class);
String tenantId = jeeLowCodeAdapter.getTenantId();
Long dbformId = param.getDbFormId();
Long dataId = param.getDataId();
Map<String, Object> params = param.getParams();
List<DbFormRoleFieldVo> roleFieldVoList = dbFormRoleService.listRoleField(tenantId, dbformId,false);
ResultDataModel resultDataModel = frameService.getDataDetail(dbformId, dataId, params);
super.webViewAppend(dbformId,resultDataModel.getRecords());
super.removeNotWebView(dbformId,resultDataModel.getRecords(),roleFieldVoList);
return resultDataModel;
}
}

View File

@@ -0,0 +1,52 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.receiver;
import com.jeelowcode.framework.utils.model.ExecuteEnhanceModel;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import com.jeelowcode.core.framework.config.btncommand.param.ButtonParamEdit;
import com.jeelowcode.core.framework.service.IFrameService;
import java.util.Map;
/**
* 编辑按钮执行者
*/
public class ButtonReceiverEdit implements IButtonCommandReceiver<ExecuteEnhanceModel> {
private String pluginKey;
private ButtonParamEdit param;
public ButtonReceiverEdit(ButtonParamEdit param) {
this.param = param;
}
/**
* 执行命令
* @return
*/
@Override
public ExecuteEnhanceModel receiver() {
IFrameService frameService = SpringUtils.getBean(IFrameService.class);
Long dbformId = param.getDbFormId();
Long dataId = param.getDataId();
Map<String, Object> params = param.getParams();
ExecuteEnhanceModel enhanceModel = frameService.editData(dbformId, dataId, params);
return enhanceModel;
}
}

View File

@@ -0,0 +1,50 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.receiver;
import cn.hutool.json.JSONObject;
import com.jeelowcode.framework.utils.model.ExecuteEnhanceModel;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import com.jeelowcode.core.framework.config.btncommand.param.ButtonParamEditBatch;
import com.jeelowcode.core.framework.service.IFrameService;
import java.util.List;
/**
* 编辑按钮执行者
*/
public class ButtonReceiverEditBatch implements IButtonCommandReceiver<ExecuteEnhanceModel> {
private String pluginKey;
private ButtonParamEditBatch param;
public ButtonReceiverEditBatch(ButtonParamEditBatch param) {
this.param = param;
}
/**
* 执行命令
* @return
*/
@Override
public ExecuteEnhanceModel receiver() {
IFrameService frameService = SpringUtils.getBean(IFrameService.class);
Long dbformId = param.getDbFormId();
List<JSONObject> jsonObjectList = param.getJsonObjectList();
frameService.editBatchData(dbformId, jsonObjectList);
return null;
}
}

View File

@@ -0,0 +1,83 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.receiver;
import com.jeelowcode.framework.utils.adapter.IJeeLowCodeAdapter;
import com.jeelowcode.framework.utils.model.ResultDataModel;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import com.jeelowcode.core.framework.config.btncommand.param.ButtonParamExport;
import com.jeelowcode.core.framework.params.model.ExcelModel;
import com.jeelowcode.core.framework.params.vo.role.DbFormRoleFieldVo;
import com.jeelowcode.core.framework.service.IDbFormRoleService;
import com.jeelowcode.core.framework.service.IExcelService;
import com.jeelowcode.core.framework.service.IFormService;
import com.jeelowcode.core.framework.service.IFrameService;
import java.util.List;
import java.util.Map;
/**
* 新增按钮执行者
*/
public class ButtonReceiverExport extends ButtonReceiverBase implements IButtonCommandReceiver<ExcelModel> {
private String pluginKey;
private ButtonParamExport param;
public ButtonReceiverExport(ButtonParamExport param) {
this.param = param;
}
/**
* 执行命令
* @return
*/
@Override
public ExcelModel receiver() {
IExcelService excelService = SpringUtils.getBean(IExcelService.class);
IFormService formService = SpringUtils.getBean(IFormService.class);
IFrameService frameService = SpringUtils.getBean(IFrameService.class);
IDbFormRoleService dbFormRoleService = SpringUtils.getBean(IDbFormRoleService.class);
IJeeLowCodeAdapter jeeLowCodeAdapter = SpringUtils.getBean(IJeeLowCodeAdapter.class);
String tenantId = jeeLowCodeAdapter.getTenantId();
Long dbFormId = param.getDbFormId();
Map<String, Object> params = param.getParams();
ResultDataModel model = frameService.getExportDataList(dbFormId, params);
//数据
List<Map<String, Object>> dataMapList = model.getRecords();
//格式化数据,转为字符串
formService.formatDataList(dbFormId,dataMapList);
//处理权限问题
List<DbFormRoleFieldVo> roleFieldVoList = dbFormRoleService.listRoleField(tenantId, dbFormId,false);
super.webViewAppend(dbFormId,dataMapList);//格式化
super.removeNotWebView(dbFormId,dataMapList,roleFieldVoList);
//获取基本信息
ExcelModel excelModel = excelService.getExcelModel(dbFormId);
excelModel.setDataMapList(dataMapList);
//剔除表头
super.removeNotExport(excelModel.getHeadTitleMap(),roleFieldVoList);
return excelModel;
}
}

View File

@@ -0,0 +1,63 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.receiver;
import com.jeelowcode.framework.excel.model.ExcelTitleModel;
import com.jeelowcode.framework.utils.adapter.IJeeLowCodeAdapter;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import com.jeelowcode.core.framework.config.btncommand.param.ButtonParamExportTemplate;
import com.jeelowcode.core.framework.params.model.ExcelTemplateModel;
import com.jeelowcode.core.framework.params.vo.role.DbFormRoleFieldVo;
import com.jeelowcode.core.framework.service.IDbFormRoleService;
import com.jeelowcode.core.framework.service.IExcelService;
import org.apache.commons.collections4.map.LinkedMap;
import java.util.List;
/**
* 导出模板按钮执行者
*/
public class ButtonReceiverExportTemplate extends ButtonReceiverBase implements IButtonCommandReceiver<ExcelTemplateModel> {
private String pluginKey;
private ButtonParamExportTemplate param;
public ButtonReceiverExportTemplate(ButtonParamExportTemplate param) {
this.param = param;
}
/**
* 执行命令
* @return
*/
@Override
public ExcelTemplateModel receiver() {
IExcelService excelService = SpringUtils.getBean(IExcelService.class);
IDbFormRoleService dbFormRoleService = SpringUtils.getBean(IDbFormRoleService.class);
IJeeLowCodeAdapter jeeLowCodeAdapter = SpringUtils.getBean(IJeeLowCodeAdapter.class);
String tenantId = jeeLowCodeAdapter.getTenantId();
Long dbFormId = param.getDbFormId();
ExcelTemplateModel excelTemplateModel = excelService.getExportExcelTemplate(dbFormId);
LinkedMap<String, ExcelTitleModel> headTitleMap = excelTemplateModel.getHeadTitleMap();
List<DbFormRoleFieldVo> roleFieldVoList = dbFormRoleService.listRoleField(tenantId, dbFormId,false);
super.removeNotExport(headTitleMap,roleFieldVoList);
return excelTemplateModel;
}
}

View File

@@ -0,0 +1,79 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.receiver;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.jeelowcode.core.framework.config.btncommand.param.ButtonParamImport;
import com.jeelowcode.core.framework.params.model.ExcelImportResultModel;
import com.jeelowcode.core.framework.service.IExcelFileService;
import com.jeelowcode.core.framework.service.IExcelService;
import com.jeelowcode.core.framework.utils.Func;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
/**
* 新增按钮执行者
*/
public class ButtonReceiverImport implements IButtonCommandReceiver<ExcelImportResultModel> {
private String pluginKey;
private ButtonParamImport param;
public ButtonReceiverImport(ButtonParamImport param) {
this.param = param;
}
/**
* 执行命令
* @return
*/
@Override
public ExcelImportResultModel receiver() {
IExcelService excelService = SpringUtils.getBean(IExcelService.class);
IExcelFileService excelFileService = SpringUtils.getBean(IExcelFileService.class);
// 将request设置为子线程共享
ServletRequestAttributes sra = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
ExcelImportResultModel resultModel=null;
//保存Excel数据
String serviceType = param.getServiceType();
switch (serviceType){
case "IMPORT_TEMPLATE"://导入excel到临时库
long fileId = IdWorker.getId();
excelFileService.saveExcelSync(fileId,param);
resultModel = new ExcelImportResultModel();
resultModel.setBatchCode(Func.toStr(fileId));
resultModel.setDbFormId(param.getDbFormId());
resultModel.setTotalCou(param.getDataMapList().size());
resultModel.setFileId(fileId);
break;
case "HANBLE_TEMPLATE"://处理临时库数据
excelService.handleTempTable(sra,param.getDbFormId(),param.getBatchCode());
break;
}
return resultModel;
}
}

View File

@@ -0,0 +1,64 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.receiver;
import com.jeelowcode.framework.utils.adapter.IJeeLowCodeAdapter;
import com.jeelowcode.framework.utils.model.ResultDataModel;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import com.jeelowcode.core.framework.config.btncommand.param.ButtonParamList;
import com.jeelowcode.core.framework.params.vo.role.DbFormRoleFieldVo;
import com.jeelowcode.core.framework.service.IDbFormRoleService;
import com.jeelowcode.core.framework.service.IFrameService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import java.util.Map;
/**
* 编辑按钮执行者
*/
public class ButtonReceiverList extends ButtonReceiverBase implements IButtonCommandReceiver<ResultDataModel> {
private String pluginKey;
private ButtonParamList param;
public ButtonReceiverList(ButtonParamList param) {
this.param = param;
}
/**
* 执行命令
* @return
*/
@Override
public ResultDataModel receiver() {
IFrameService frameService = SpringUtils.getBean(IFrameService.class);
IDbFormRoleService dbFormRoleService = SpringUtils.getBean(IDbFormRoleService.class);
IJeeLowCodeAdapter jeeLowCodeAdapter = SpringUtils.getBean(IJeeLowCodeAdapter.class);
String tenantId = jeeLowCodeAdapter.getTenantId();
Long dbformId = param.getDbFormId();
Map<String, Object> params = param.getParams();
Page page = param.getPage();
ResultDataModel resultDataModel = frameService.getDataList(dbformId, page, params);
List<DbFormRoleFieldVo> roleFieldVoList = dbFormRoleService.listRoleField(tenantId, dbformId,false);
super.webViewAppend(dbformId,resultDataModel.getRecords());//格式化
super.removeNotWebView(dbformId,resultDataModel.getRecords(),roleFieldVoList);
return resultDataModel;
}
}

View File

@@ -0,0 +1,64 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.receiver;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeelowcode.core.framework.config.btncommand.param.ButtonParamReportExport;
import com.jeelowcode.core.framework.params.model.ExcelModel;
import com.jeelowcode.core.framework.service.IExcelService;
import com.jeelowcode.core.framework.service.IFrameService;
import com.jeelowcode.framework.utils.model.ResultDataModel;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import java.util.Map;
/**
* 新增按钮执行者
*/
public class ButtonReceiverReportExport extends ButtonReceiverBase implements IButtonCommandReceiver<ExcelModel> {
private String pluginKey;
private ButtonParamReportExport param;
public ButtonReceiverReportExport(ButtonParamReportExport param) {
this.param = param;
}
/**
* 执行命令
* @return
*/
@Override
public ExcelModel receiver() {
IExcelService excelService = SpringUtils.getBean(IExcelService.class);
IFrameService frameService = SpringUtils.getBean(IFrameService.class);
String reportCode = param.getReportCode();
Map<String, Object> params = param.getParams();
//数据列表
Page page=new Page(1,-1);
ResultDataModel model = frameService.getReportDataList(reportCode, page,params);
//获取基本信息
ExcelModel excelModel = excelService.getExcelReportModel(reportCode);
excelModel.setDataMapList(model.getRecords());
return excelModel;
}
}

View File

@@ -0,0 +1,53 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.receiver;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeelowcode.core.framework.config.btncommand.param.ButtonParamReportList;
import com.jeelowcode.core.framework.service.IFrameService;
import com.jeelowcode.framework.utils.model.ResultDataModel;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import java.util.Map;
/**
* 数据报表分页执行者
*/
public class ButtonReceiverReportList extends ButtonReceiverBase implements IButtonCommandReceiver<ResultDataModel> {
private String pluginKey;
private ButtonParamReportList param;
public ButtonReceiverReportList(ButtonParamReportList param) {
this.param = param;
}
/**
* 执行命令
* @return
*/
@Override
public ResultDataModel receiver() {
String reportCode = param.getReportCode();
Page page = param.getPage();
Map<String, Object> params = param.getParams();
IFrameService frameService = SpringUtils.getBean(IFrameService.class);
ResultDataModel reportDataPage = frameService.getReportDataList(reportCode, page, params);
return reportDataPage;
}
}

View File

@@ -0,0 +1,65 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.receiver;
import com.jeelowcode.framework.utils.model.ResultDataModel;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import com.jeelowcode.core.framework.config.btncommand.param.ButtonParamSummary;
import com.jeelowcode.core.framework.service.IFrameService;
import com.jeelowcode.core.framework.utils.Func;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 统计按钮执行者
*/
public class ButtonReceiverSummary implements IButtonCommandReceiver<Map<String, Object>> {
private String pluginKey;
private ButtonParamSummary param;
public ButtonReceiverSummary(ButtonParamSummary param) {
this.param = param;
}
/**
* 执行命令
*
* @return
*/
@Override
public Map<String, Object> receiver() {
IFrameService frameService = SpringUtils.getBean(IFrameService.class);
Long dbformId = param.getDbFormId();
Map<String, Object> params = param.getParams();
ResultDataModel resultDataModel = frameService.getDataSummaryList(dbformId, params);
Map<String, Object> resultMap = new HashMap<>();
if(Func.isEmpty(resultDataModel)){
return resultMap;
}
List<Map<String, Object>> dataMapList = resultDataModel.getRecords();
if (Func.isEmpty(dataMapList)) {//数据为空
return resultMap;
}
return dataMapList.get(0);
}
}

View File

@@ -0,0 +1,28 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.btncommand.receiver;
/**
* 按钮执行者
* @param <T> 返回值
*/
public interface IButtonCommandReceiver<T> {
/**
* 执行
* @return
*/
T receiver();
}

View File

@@ -0,0 +1,58 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.job;
import cn.hutool.core.date.DateUtil;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import com.jeelowcode.core.framework.service.IJeeLowCodeConfigService;
import com.jeelowcode.core.framework.service.IJeeLowCodeService;
import com.jeelowcode.framework.tenant.annotation.JeeLowCodeTenantIgnore;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
/**
* 删除excel临时表数据
*/
@Component
@Slf4j
public class ClearExcelDataJob implements JobHandler {
@Autowired
private IJeeLowCodeService jeeLowCodeService;
@Autowired
private IJeeLowCodeConfigService jeeLowCodeConfigService;
@Override
@JeeLowCodeTenantIgnore
public String execute(String param) {
log.info("*********** 开始清理Excel Data日志 ************");
Date now = DateUtil.date();
Integer day = jeeLowCodeConfigService.getExcelFileDataDay();
//x天之前
Date clearDate = DateUtil.offsetDay(now, -day);
Integer clearCou = jeeLowCodeService.clearExcelData(clearDate);
String resultStr="*********** Excel Data日志清理完成共清理了"+clearCou+"条 ************";
log.info(resultStr);
return resultStr;
}
}

View File

@@ -0,0 +1,43 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.job;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import com.jeelowcode.core.framework.service.IJeeLowCodeService;
import com.jeelowcode.framework.tenant.annotation.JeeLowCodeTenantIgnore;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 保存模块使用记录
*/
@Slf4j
@Component("saveModelUsageRecordsJob")
public class SaveModelUsageRecordsJob implements JobHandler {
@Autowired
private IJeeLowCodeService jeeLowCodeService;
@Override
@JeeLowCodeTenantIgnore
public String execute(String param) {
log.info("*********** 开始保存模块使用记录 ************");
Integer cou = jeeLowCodeService.saveModelUsageRecords();
String resultStr = "*********** 保存模块使用记录完成,共保存了" + cou + "条 ************";
log.info(resultStr);
return resultStr;
}
}

View File

@@ -0,0 +1,68 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.listener;
import com.jeelowcode.core.framework.service.IFormService;
import com.jeelowcode.core.framework.service.IReportService;
import com.jeelowcode.framework.utils.component.redis.JeeLowCodeRedisUtils;
import groovy.lang.GroovyClassLoader;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@Slf4j
@Order(value = 999)
@Component
public class JeeLowCodeListener implements ApplicationListener<ContextRefreshedEvent> {
@Autowired
JeeLowCodeRedisUtils redisUtil;
@Autowired
private IFormService dbFormService;
@Autowired
private IReportService reportService;
public GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
public GroovyClassLoader getGroovyClassLoader() {
return groovyClassLoader;
}
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
//初始化自定义按钮
dbFormService.initConfigBtnCommand();
log.info("1.初始化自定义按钮--->完成");
// 容器启动完成后清除框架缓存
dbFormService.cleanCache();
log.info("2.清除框架缓存--->完成");
//初始化在线编辑脚本
dbFormService.initOnlineScript(groovyClassLoader);
log.info("3.初始化在线脚本--->完成");
//初始化增强插件
dbFormService.initEnhancePluginManager();
log.info("4.初始化增强--->完成");
reportService.initEnhancePluginManager();
log.info("5.初始化报表增强--->完成");
}
}

View File

@@ -0,0 +1,193 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.log;
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
import com.jeelowcode.core.framework.adapter.YudaoAdapter;
import com.jeelowcode.core.framework.utils.Func;
import com.jeelowcode.core.framework.utils.FuncWeb;
import com.jeelowcode.framework.exception.JeeLowCodeException;
import com.jeelowcode.framework.exception.JeeLowCodeMoreException;
import com.jeelowcode.framework.global.JeeLowCodeBaseConstant;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import com.jeelowcode.framework.utils.utils.FuncBase;
import com.jeelowcode.core.framework.params.model.LogRequestApiModel;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import io.swagger.v3.oas.annotations.Operation;
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.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import org.springframework.web.util.ContentCachingRequestWrapper;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.time.LocalDateTime;
import java.util.Map;
/**
* 请求日志切面
*/
@Slf4j
@Aspect
@Component
public class ApiLogAspect {
// JeeLowCode
@Pointcut("execution(* com.jeelowcode.core.framework.controller.*Controller.*(..)))")
private void pointcutJeeLowCode() {}
// 芋道
@Pointcut("@annotation(io.swagger.v3.oas.annotations.Operation)")
private void pointcutYudao() {}
/**
* 切入点是所有控制住
* @param point
* @return
* @throws Throwable
*/
@Around("pointcutJeeLowCode()||pointcutYudao()")
public Object around(ProceedingJoinPoint point) throws Throwable {
//获取类名
String className = point.getTarget().getClass().getName();
//获取方法
String methodName = point.getSignature().getName();
MethodSignature signature = (MethodSignature) point.getSignature();
Method method = signature.getMethod();
Operation operation = method.getAnnotation(Operation.class);
String modelName="其他模块";
if(Func.isNotEmpty(operation) && Func.isNotEmpty(operation.tags())){
modelName =operation.tags()[0];
}
String apiName="请求日志";
if(Func.isNotEmpty(operation) && Func.isNotEmpty(operation.summary())){
apiName =operation.summary();
}
if (Func.equals("刷新令牌", apiName)){
return point.proceed();
}
// 发送异步日志事件
long beginTime = System.currentTimeMillis();
LogRequestApiModel logApiModel = getRequestParam(methodName, className, apiName,modelName);
//执行方法
String error="";
try{
return point.proceed();
}catch (JeeLowCodeMoreException e){
String message = e.getMessage();
Map<String,String> map = Func.json2Bean(message, Map.class);
String title = map.get("title");
String e1 = map.get("e");
error=getErrorStr(e);
throw new JeeLowCodeMoreException(title,e1);
}catch (JeeLowCodeException e){
error=getErrorStr(e);
throw new JeeLowCodeException(e.getMessage());
}catch (Exception e){
error=getErrorStr(e);
throw e;
}finally {
//执行时长(毫秒)
long time = System.currentTimeMillis() - beginTime;
//记录日志
this.publishEvent(logApiModel, time,error);
}
}
//获取具体错误信息
private static String getErrorStr(Exception e){
StringBuffer sb=new StringBuffer();
sb.append(e).append("\r\n");
StackTraceElement[] trace = e.getStackTrace();
for (StackTraceElement traceElement : trace){
sb.append("\tat ").append(traceElement).append("\r\n");
}
return sb.toString();
}
private static LogRequestApiModel getRequestParam(String methodName, String methodClass, String title,String modelTitle) {
try{
HttpServletRequest request = FuncWeb.getRequest();
ContentCachingRequestWrapper requestWrapper = new ContentCachingRequestWrapper(request);
YudaoAdapter jeeLowCodeAdapter = SpringUtils.getBean(YudaoAdapter.class);
String tenantId ="";
try{
tenantId = jeeLowCodeAdapter.getTenantId();
}catch (Exception e){
}
String onlineUserId = jeeLowCodeAdapter.getOnlineUserId();
LogRequestApiModel logApiModel=new LogRequestApiModel();
logApiModel.setId(IdWorker.getId());
logApiModel.setTenantId(tenantId);
logApiModel.setCreateUser(FuncBase.toLong(onlineUserId));
logApiModel.setCreateUserName(jeeLowCodeAdapter.getOnlineUserName());
logApiModel.setCreateTime(LocalDateTime.now());
logApiModel.setIp(ServletUtils.getClientIP(request));//ip
logApiModel.setTitle(title);
logApiModel.setModelTitle(modelTitle);//模块名称
logApiModel.setMethodName(methodName);//方法名称
logApiModel.setMethodClass(methodClass);//类名称
logApiModel.setRequestUri(FuncWeb.getPath(requestWrapper.getRequestURI()));//请求url
logApiModel.setRequestParams(FuncWeb.getRequestParams(requestWrapper));//请求参数
logApiModel.setRequestMethod(requestWrapper.getMethod());//请求方式
return logApiModel;
}catch (Exception e){
e.printStackTrace();
}
return null;
}
private static void publishEvent(LogRequestApiModel logApiModel, long time, String error) {
try{
if(FuncBase.isEmpty(logApiModel)){
return;
}
String requestUri = logApiModel.getRequestUri();
if(Func.equals(requestUri, JeeLowCodeBaseConstant.REQUEST_URL_START+"/apilog/page") || Func.equals(requestUri,JeeLowCodeBaseConstant.REQUEST_URL_START+"/apilog/detail")){
return;//本身查看
}
logApiModel.setTime(time);//耗时
logApiModel.setError(error);
SpringUtils.getApplicationContext().publishEvent(new ApiLogEvent(logApiModel));
}catch (Exception e){
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,25 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.log;
import com.jeelowcode.core.framework.params.model.LogRequestApiModel;
import org.springframework.context.ApplicationEvent;
public class ApiLogEvent extends ApplicationEvent {
public ApiLogEvent(LogRequestApiModel model) {
super(model);
}
}

View File

@@ -0,0 +1,65 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.log;
import cn.hutool.core.bean.BeanUtil;
import com.jeelowcode.core.framework.entity.LogRequestApiEntity;
import com.jeelowcode.core.framework.entity.LogRequestErrorApiEntity;
import com.jeelowcode.core.framework.mapper.LogApiErrorMapper;
import com.jeelowcode.core.framework.mapper.LogApiMapper;
import com.jeelowcode.core.framework.utils.Func;
import com.jeelowcode.framework.utils.tool.spring.SpringUtils;
import com.jeelowcode.core.framework.params.model.LogRequestApiModel;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
/**
* 异步监听日志事件
*
* @author Chill
*/
@Component
@Slf4j
@AllArgsConstructor
public class ApiLogListener {
@Autowired
private LogApiMapper logApiMapper;
@Autowired
private LogApiErrorMapper logApiErrorMapper;
@Async("asyncPoolTaskExecutor")
@Order
@EventListener(ApiLogEvent.class)
public void saveApiLog(ApiLogEvent event) {
LogRequestApiModel apiModel =(LogRequestApiModel)event.getSource();
String error = apiModel.getError();
if(Func.isEmpty(error)){//正常日志
LogRequestApiEntity infoEntity = BeanUtil.copyProperties(apiModel, LogRequestApiEntity.class);
logApiMapper.insert(infoEntity);
}else{//错误日志
LogRequestErrorApiEntity errorEntity = BeanUtil.copyProperties(apiModel, LogRequestErrorApiEntity.class);
logApiErrorMapper.insert(errorEntity);
}
}
}

View File

@@ -0,0 +1,64 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.validate;
import com.jeelowcode.core.framework.service.IFrameService;
import com.jeelowcode.core.framework.utils.Func;
import com.jeelowcode.core.framework.utils.FuncWeb;
import com.jeelowcode.framework.exception.JeeLowCodeException;
import com.jeelowcode.framework.utils.adapter.IJeelowCodeValidate;
import com.jeelowcode.framework.utils.utils.FuncBase;
import com.jeelowcode.framework.utils.utils.JeeLowCodeUtils;
import com.jeelowcode.framework.utils.component.properties.JeeLowCodeProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import java.util.StringJoiner;
/**
* 校验表名是否合法
*/
@Component
public class DbFormCopyValidate implements IJeelowCodeValidate {
@Lazy
@Autowired
private IFrameService frameService;
@Override
public void validate(HttpServletRequest req) throws JeeLowCodeException {
Map<String, Object> parameterMap = FuncWeb.getParameterMap(req);
String tableName = JeeLowCodeUtils.getMap2Str(parameterMap, "tableName");
if (FuncBase.isEmpty(tableName)) {
throw new JeeLowCodeException("表名不允许为空");
}
if (!Func.checkTableName(tableName)) {
StringJoiner joiner = new StringJoiner(",");
JeeLowCodeProperties.getExcludeTableNames().forEach(joiner::add);
String errorMsg = joiner.toString();
throw new JeeLowCodeException(String.format("表名称不允许以【%s】开头", errorMsg));
}
//校验表名是否重复
if (frameService.checkTable(tableName)) {
String errorStr = String.format("数据库表【%s】已存在", tableName);
throw new JeeLowCodeException(errorStr);
}
}
}

View File

@@ -0,0 +1,61 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.validate;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jeelowcode.core.framework.entity.ReportEntity;
import com.jeelowcode.core.framework.service.IReportService;
import com.jeelowcode.core.framework.utils.FuncWeb;
import com.jeelowcode.framework.exception.JeeLowCodeException;
import com.jeelowcode.framework.utils.adapter.IJeelowCodeValidate;
import com.jeelowcode.framework.utils.utils.FuncBase;
import com.jeelowcode.framework.utils.utils.JeeLowCodeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
/**
* 校验表名是否合法
*/
@Component
public class ReportCopyValidate implements IJeelowCodeValidate {
@Lazy
@Autowired
private IReportService reportService;
@Override
public void validate(HttpServletRequest req) throws JeeLowCodeException {
Map<String, Object> parameterMap = FuncWeb.getParameterMap(req);
String reportCode = JeeLowCodeUtils.getMap2Str(parameterMap, "reportCode");
if (FuncBase.isEmpty(reportCode)) {
throw new JeeLowCodeException("报表编号不允许为空");
}
LambdaQueryWrapper<ReportEntity> wrapper=new LambdaQueryWrapper<>();
wrapper.eq(ReportEntity::getReportCode,reportCode);
long count = reportService.count(wrapper);
//校验表名是否重复
if (count>0) {
String errorStr = String.format("报表编号【%s】已存在", reportCode);
throw new JeeLowCodeException(errorStr);
}
}
}

View File

@@ -0,0 +1,60 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.validate;
import com.jeelowcode.core.framework.params.DbFormAddOrUpdateParam;
import com.jeelowcode.core.framework.service.IFrameService;
import com.jeelowcode.core.framework.utils.Func;
import com.jeelowcode.core.framework.utils.FuncWeb;
import com.jeelowcode.framework.exception.JeeLowCodeException;
import com.jeelowcode.framework.utils.adapter.IJeelowCodeValidate;
import com.jeelowcode.framework.utils.utils.FuncBase;
import com.jeelowcode.framework.utils.component.properties.JeeLowCodeProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.util.StringJoiner;
/**
* 校验表名是否合法
*/
@Component
public class TableNameValidate implements IJeelowCodeValidate {
@Autowired
private IFrameService frameService;
@Override
public void validate(HttpServletRequest req) throws JeeLowCodeException {
DbFormAddOrUpdateParam param = FuncWeb.getParameterBodyObj(req, DbFormAddOrUpdateParam.class);
String tableName = param.getDbForm().getTableName().trim();
if (FuncBase.isEmpty(tableName)) {
throw new JeeLowCodeException("表名不允许为空");
}
if (!Func.checkTableName(tableName)) {
StringJoiner joiner = new StringJoiner(",");
JeeLowCodeProperties.getExcludeTableNames().forEach(joiner::add);
String errorMsg = joiner.toString();
throw new JeeLowCodeException(String.format("表名称不允许以【%s】开头", errorMsg));
}
//校验表名是否重复
if (frameService.checkTable(tableName)) {
String errorStr = String.format("数据库表【%s】已存在", tableName);
throw new JeeLowCodeException(errorStr);
}
}
}

View File

@@ -0,0 +1,24 @@
/*
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
本软件受适用的国家软件著作权法(包括国际条约)和开源协议 双重保护许可。
开源协议中文释意如下:
1.JeeLowCode开源版本无任何限制在遵循本开源协议Apache2.0)条款下,【允许商用】使用,不会造成侵权行为。
2.允许基于本平台软件开展业务系统开发。
3.在任何情况下,您不得使用本软件开发可能被认为与【本软件竞争】的软件。
最终解释权归http://www.jeelowcode.com
*/
package com.jeelowcode.core.framework.config.virtualization;
import java.util.Map;
/**
* 虚拟化字段相关-JAVA函数处理
*/
public interface VirtualizationFieldPlugin {
String execute(Map<String, Object> dataMap);
}

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