提交 bb400a0e 编写于 作者: yesgohome123's avatar yesgohome123

2023年6月15日22:32:55

上级 b1429189
<?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>
<artifactId>eweb-chrm</artifactId>
<groupId>cn.eweb.chrm</groupId>
<version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>design-pattern</artifactId>
<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.18</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<version>1.2.83</version>
<artifactId>fastjson</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package cn.eweb.chrm;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
\ No newline at end of file
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ReflectUtil;
import com.alibaba.fastjson.JSONArray;
import java.util.*;
public class Test {
public static void main(String[] args) {
List<User> sourceList = new ArrayList<>();
for(int i=0;i<10;i++){
User user = new User();
user.setId(i);
user.setName("a"+i);
user.setOrg("d"+i);
user.setParentName("p"+i);
sourceList.add(user);
}
List<User> targetList = new ArrayList<>();
for(int i=2;i<12;i++){
User user = new User();
user.setId(i);
user.setName("a"+i);
user.setOrg("d"+i);
user.setParentName("p"+i);
if(i==5 || i ==8){
user.setParentName(user.getParentName()+"aa");
}
targetList.add(user);
}
// 取到相同的数据,需要得到哪些字段变了
Collection<User> usersTarget = CollUtil.intersection(sourceList, targetList);
Collection<User> usersSource = CollUtil.intersection(targetList, sourceList);
// 变化字段
List<String> fiels =new ArrayList<>();
fiels.add("parentName");
fiels.add("name");
Map<Integer,List<String>> fieldsMap =new HashMap<>();
usersTarget.stream().forEach(t->{
usersSource.stream().forEach(s->{
if(t.equals(s)){
//对比字段
List<String> change =new ArrayList<>();
fiels.stream().forEach(field->{
Object targetValue = ReflectUtil.getFieldValue(t, field);
Object sourceValue = ReflectUtil.getFieldValue(s, field);
if(!targetValue.equals(sourceValue)){
change.add(field);
}
});
if(change.size()>0){
fieldsMap.put(t.getId(),change);
}
}
});
});
Collection<User> subtract = CollUtil.subtract(targetList, sourceList);
System.out.println(JSONArray.toJSONString(subtract));
}
}
class User{
private int id;
private String name;
private String org;
private String parentName;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getOrg() {
return org;
}
public void setOrg(String org) {
this.org = org;
}
public String getParentName() {
return parentName;
}
public void setParentName(String parentName) {
this.parentName = parentName;
}
@Override
public int hashCode() {
return this.getName().hashCode();
}
@Override
public boolean equals(Object obj) {
User target = (User) obj;
if(this.getName().equals(target.getName())&& this.getOrg().equals(target.getOrg())){
return true;
}
return false;
}
}
\ No newline at end of file
<?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>
<artifactId>eweb-chrm</artifactId>
<groupId>cn.eweb.chrm</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>eweb-cases</artifactId>
<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
\ No newline at end of file
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>cn.eweb.chrm</groupId> <groupId>cn.eweb.chrm</groupId>
<artifactId>chrm-auth-client</artifactId> <artifactId>chrm-auth-client</artifactId>
......
...@@ -25,16 +25,6 @@ ...@@ -25,16 +25,6 @@
<artifactId>chrm-auth-app</artifactId> <artifactId>chrm-auth-app</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>cn.eweb.chrm</groupId>
<artifactId>chrm-auth-client</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.eweb.chrm</groupId>
<artifactId>chrm-auth-infrastructure</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
......
package cn.eweb.chrm.auth.controller; package cn.eweb.chrm.auth.controller;
import cn.eweb.chrm.auth.domain.metrics.IMetricsService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
......
package cn.eweb.chrm.auth.domain.metrics;
public interface IMetricsService {
}
...@@ -28,11 +28,7 @@ ...@@ -28,11 +28,7 @@
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.83_noneautotype</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
......
package cn.eweb.chrm.auth.user.gateway.impl.database.dataobject; package cn.eweb.chrm.auth.user.gateway.database.dataobject;
import cn.eweb.frame.common.core.base.pojo.entity.BaseDO; import cn.eweb.frame.common.core.base.pojo.entity.BaseDO;
import lombok.Data; import lombok.Data;
......
package cn.eweb.chrm.auth.user.gateway.impl.database.mapper; package cn.eweb.chrm.auth.user.gateway.database.mapper;
import cn.eweb.chrm.auth.user.gateway.impl.database.dataobject.UserInfoDO; import cn.eweb.chrm.auth.user.gateway.database.dataobject.UserInfoDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/** /**
......
package cn.eweb.chrm.auth.user.gateway.impl.database.mapper; package cn.eweb.chrm.auth.user.gateway.database.mapper;
import cn.eweb.chrm.auth.user.gateway.impl.database.dataobject.UserDO; import cn.eweb.chrm.auth.user.gateway.database.dataobject.UserDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
......
package cn.eweb.chrm.auth.user.gateway.impl;
import cn.eweb.chrm.auth.domain.metrics.IMetricsService;
import org.springframework.stereotype.Service;
@Service
public class IMetricsServiceImpl implements IMetricsService {
}
...@@ -19,6 +19,11 @@ ...@@ -19,6 +19,11 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>cn.eweb.chrm</groupId>
<artifactId>chrm-auth-controller</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
...@@ -27,5 +32,29 @@ ...@@ -27,5 +32,29 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId> <artifactId>spring-boot-starter-log4j2</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<!-- 开发组件 -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
package cn.eweb.chrm; package cn.eweb.chrm.auth;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
......
server:
port: 7777
sra:
default:
# 服务端请求协议
agreement: http
# 服务器IP 或 域名
domain: 127.0.0.1
dev-enable:
# 作者
author: jwss
# 模块包名
module-package: com.jwss.sra.system
# 开启缓存
permission-cache: true
# 强密码
strong-password: srapwd
# 文件上传地址
file-upload:
local-url: F:/server/file/
browser-url: /upload/
spring:
sqltoy:
# 配置sql文件路径,多个用逗号分割
sqlResourcesDir: classpath:mapper
# 默认为false,debug模式将打印执行sql,并自动检测sql文件更新并重新加载
debug: true
datasource:
name: dataSource
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/chrm?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC
username: root
password: 123456
druid:
initial-size: 5
min-idle: 5
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
numTestsPerEvictionRun: 3
keepAlive: true
# 切记切记不要打开poolPreparedStatements 和设置maxOpenPreparedStatements,druid这里有bug,会报关闭的语句,让你找不到错误的原因
#poolPreparedStatements: false
#注意maxOpenPreparedStatements设置>0 就等同于设置poolPreparedStatements=true
#maxOpenPreparedStatements: 20
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 100000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 600000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: true
testOnReturn: false
removeAbandoned: true
removeAbandonedTimeout: 300
server:
port: 8080
sra:
default:
# 服务端请求协议
agreement: http
# 服务器IP 或 域名
domain: 106.52.139.93
dev-enable:
author: jwss
module-package: com.jwss.sra.system
permission-cache: true
strong-password: srapwd
# 文件上传地址
file-upload:
local-url: /home/lighthouse/server/spring-boot/upload/
browser-url: /upload/
spring:
sqltoy:
# 配置sql文件路径,多个用逗号分割
sqlResourcesDir: classpath:mapper
# 默认为false,debug模式将打印执行sql,并自动检测sql文件更新并重新加载
debug: false
datasource:
name: dataSource
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/DB_SRA_V1?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC
username: root
password: root
druid:
initial-size: 5
min-idle: 5
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
numTestsPerEvictionRun: 3
keepAlive: true
# 切记切记不要打开poolPreparedStatements 和设置maxOpenPreparedStatements,druid这里有bug,会报关闭的语句,让你找不到错误的原因
#poolPreparedStatements: false
#注意maxOpenPreparedStatements设置>0 就等同于设置poolPreparedStatements=true
#maxOpenPreparedStatements: 20
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 100000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 600000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: true
testOnReturn: false
removeAbandoned: true
removeAbandonedTimeout: 300
server:
servlet:
context-path: /
sra:
default:
password: sra123456
salt: sra-salt
db-name: DB_SRA_V1
sa-token:
# 路由放行
excludes:
- /test/index
- /favicon.ico
# swagger和knife
- /v2/api-docs
- /configuration/ui
- /swagger-resources/**
- /configuration/security
- /doc.html
- /webjars/**
# 登录
- /user/login
- /file/verificationCode
# 文件访问路径
- /upload/**
- /codeGenerator/**
package-scan:
# 多个包用冒号隔开
swagger-packages: com.jwss.sra.system.controller
# Sa-Token 配置
sa-token:
# token名称 (同时也是cookie名称)
token-name: sa-token
# token有效期,单位s 默认30天, -1代表永不过期
timeout: 86400
# token临时有效期 (指定时间内无操作就视为token过期) 单位: 秒
activity-timeout: -1
# 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
is-concurrent: true
# 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
is-share: true
# token风格
token-style: random-64
# 是否输出操作日志
is-log: false
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
# redis配置
redis:
# Redis数据库索引(默认为0)
# database: 1
# Redis服务器地址
host: 127.0.0.1
# Redis服务器连接端口
port: 6379
# Redis服务器连接密码(默认为空)
# password:
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池最大连接数
max-active: 200
# 连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
# 连接池中的最大空闲连接
max-idle: 10
# 连接池中的最小空闲连接
min-idle: 0
# sqltoy框架相关配置
sqltoy:
unify-fields-handler: com.jwss.sra.config.sqltoy.SqlToyUnifyFieldsHandler
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
servlet:
multipart:
max-file-size: 10MB
freemarker:
suffix: .ftl
settings:
classic_compatible: true
# 环境配置激活
profiles:
active: dev
\ No newline at end of file
...@@ -8,9 +8,16 @@ ...@@ -8,9 +8,16 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<artifactId>eweb-chrm-auth</artifactId> <artifactId>eweb-chrm-auth</artifactId>
<modules>
<module>chrm-auth-infrastructure</module>
<module>chrm-auth-domain</module>
<module>chrm-auth-client</module>
<module>chrm-auth-app</module>
<module>chrm-auth-controller</module>
<module>chrm-auth-start</module>
</modules>
<properties> <properties>
<maven.compiler.source>19</maven.compiler.source> <maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target> <maven.compiler.target>19</maven.compiler.target>
......
...@@ -8,12 +8,9 @@ ...@@ -8,12 +8,9 @@
<module>eweb-chrm-resources</module> <module>eweb-chrm-resources</module>
<module>eweb-chrm-office</module> <module>eweb-chrm-office</module>
<module>eweb-chrm-tool</module> <module>eweb-chrm-tool</module>
<module>eweb-chrm-auth/chrm-auth-infrastructure</module> <module>eweb-cases</module>
<module>eweb-chrm-auth/chrm-auth-domain</module> <module>eweb-cases/design-pattern</module>
<module>eweb-chrm-auth/chrm-auth-client</module>
<module>eweb-chrm-auth/chrm-auth-app</module>
<module>eweb-chrm-auth/chrm-auth-controller</module>
<module>eweb-chrm-auth/chrm-auth-start</module>
</modules> </modules>
<parent> <parent>
<groupId>cn.eweb.frame</groupId> <groupId>cn.eweb.frame</groupId>
......
...@@ -20,14 +20,24 @@ ...@@ -20,14 +20,24 @@
<spring-boot.version>2.7.10</spring-boot.version> <spring-boot.version>2.7.10</spring-boot.version>
<spring-cloud.version>2020.0.1</spring-cloud.version> <spring-cloud.version>2020.0.1</spring-cloud.version>
<spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version> <spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
<spring-data-redis.version>2.7.12</spring-data-redis.version>
<spring-data-mongo.version>3.4.12</spring-data-mongo.version>
<mybatis-plus.version>3.5.3.1</mybatis-plus.version> <mybatis-plus.version>3.5.3.1</mybatis-plus.version>
<taos-jdbcdriver.version>3.2.1</taos-jdbcdriver.version>
<ojdbc.version>21.9.0.0</ojdbc.version>
<elastic-rest-client.version>8.8.0</elastic-rest-client.version>
<transmittable-thread-local>2.14.2</transmittable-thread-local>
<mongo.version>3.12.13</mongo.version>
<ehcache.version>3.10.8</ehcache.version>
<caffeine.version>2.9.3</caffeine.version>
<fastjson.version>1.2.83_noneautotype</fastjson.version>
<mapstruct.version>1.5.3.Final</mapstruct.version> <mapstruct.version>1.5.3.Final</mapstruct.version>
<lombok.version>1.18.28</lombok.version> <lombok.version>1.18.28</lombok.version>
<lombok-mapstruct.version>0.2.0</lombok-mapstruct.version> <lombok-mapstruct.version>0.2.0</lombok-mapstruct.version>
<hutool.version>5.8.15</hutool.version> <hutool.version>5.8.15</hutool.version>
<junit-jupiter.version>5.9.3</junit-jupiter.version>
<junit-platform.version>1.9.3</junit-platform.version>
</properties> </properties>
<dependencyManagement> <dependencyManagement>
...@@ -69,6 +79,42 @@ ...@@ -69,6 +79,42 @@
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit-platform.version}</version>
<scope>test</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.16</version>
</dependency>
<!-- mp --> <!-- mp -->
<dependency> <dependency>
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
...@@ -104,6 +150,180 @@ ...@@ -104,6 +150,180 @@
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>31.1-jre</version> <version>31.1-jre</version>
</dependency> </dependency>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.6</version>
</dependency>
<!--
https://mvnrepository.com/artifact/com.taosdata.jdbc/taos-jdbcdriver -->
<dependency>
<groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId>
<version>${taos-jdbcdriver.version}</version>
<scope>test</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>${ojdbc.version}</version>
<scope>provided</scope>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>transmittable-thread-local</artifactId>
<version>${transmittable-thread-local}</version>
</dependency>
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>${ehcache.version}</version>
<scope>provided</scope>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>${caffeine.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring-framework.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring-framework.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring-framework.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring-framework.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring-framework.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>${spring-data-redis.version}</version>
<scope>provided</scope>
<optional>true</optional>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>${spring-data-mongo.version}</version>
<scope>provided</scope>
<optional>true</optional>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>${mongo.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
<scope>provided</scope>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>${httpclient-httpmime.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>${httpclient-core.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>${elastic-rest-client.version}</version>
<scope>provided</scope>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.eweb.frame</groupId> <groupId>cn.eweb.frame</groupId>
<artifactId>eweb-common-utils</artifactId> <artifactId>eweb-common-utils</artifactId>
......
...@@ -38,11 +38,6 @@ ...@@ -38,11 +38,6 @@
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId> <artifactId>spring-aop</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-asm</artifactId>
<version>3.0.7.RELEASE</version>
</dependency>
<dependency> <dependency>
<groupId>org.aspectj</groupId> <groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId> <artifactId>aspectjrt</artifactId>
...@@ -55,6 +50,10 @@ ...@@ -55,6 +50,10 @@
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId> <artifactId>hutool-all</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
...@@ -146,6 +145,18 @@ ...@@ -146,6 +145,18 @@
<artifactId>commons-math3</artifactId> <artifactId>commons-math3</artifactId>
<version>3.6.1</version> <version>3.6.1</version>
</dependency> </dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>transmittable-thread-local</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
package cn.eweb.frame.common.utils.xml;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentFactory;
import org.dom4j.Element;
import org.dom4j.io.DOMReader;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXParseException;
import java.io.InputStream;
import java.util.List;
/**
*
*
* @author <a href="mailto:zhaofang123@gmail.com">FANGFANG ZHAO</a>
* @since 0.1, Feb 4, 2009
* @version $Id: XmlHelper.java 8 2015-06-08 09:09:03Z zhaofang123@gmail.com $
*/
public class XmlHelper {
private static final Log LOG = LogFactory.getLog(XmlHelper.class);
public static final EntityResolver DEFAULT_DTD_RESOLVER = new DTDEntityResolver();
public static final XmlHelper INSTANCE = new XmlHelper();
private DOMReader domReader;
private SAXReader saxReader;
/**
* Create a dom4j SAXReader which will append all validation errors to
* errorList
*/
public SAXReader createSAXReader(String file, List<String> errorsList,
EntityResolver entityResolver) {
if (saxReader == null) {
saxReader = new SAXReader();
}
if (entityResolver != null) {
saxReader.setEntityResolver(entityResolver);
saxReader.setValidation(true);
}
saxReader.setErrorHandler(new ErrorLogger(file, errorsList));
saxReader.setMergeAdjacentText(true);
return saxReader;
}
/**
* Create a dom4j DOMReader
*/
public DOMReader createDOMReader() {
if (domReader == null) {
domReader = new DOMReader();
}
return domReader;
}
/**
* Create a dom4j Element
*/
public static Element createDom4jElement(String elName) {
return DocumentFactory.getInstance().createElement(elName);
}
/**
* Create a dom4j Document
* @return
*/
public static Document createDom4jDocument() {
return DocumentFactory.getInstance().createDocument("UTF-8");
}
/**
* @param in
* @return
* @throws DocumentException
*/
public static Document read(InputStream in) throws DocumentException {
return read(in, null);
}
public static Document read(InputStream in, EntityResolver resolver) throws DocumentException {
SAXReader reader = INSTANCE.createSAXReader("#INPUT_STREAM_FILE", null, resolver);
return reader.read(in);
}
public static void dump(Element element) {
try {
OutputFormat outformat = OutputFormat.createPrettyPrint();
XMLWriter writer = new XMLWriter(System.out, outformat);
writer.write(element);
writer.flush();
System.out.println();
} catch (Throwable t) {
System.err.println(element.asXML());
}
}
static public class ErrorLogger implements ErrorHandler {
private String file;
private List<String> errors;
ErrorLogger(String file, List<String> errors) {
this.file = file;
this.errors = errors;
}
@Override
public void error(SAXParseException error) {
String message = file + '(' + error.getLineNumber() + ") " + error.getMessage();
LOG.error("Error parsing XML[" + file + "]: " + message);
if (errors != null) {
errors.add(message);
}
}
@Override
public void fatalError(SAXParseException error) {
error(error);
}
@Override
public void warning(SAXParseException warn) {
LOG.warn("Warning parsing XML: " + file + '(' + warn.getLineNumber() + ") " + warn.getMessage());
}
}
static public class DTDEntityResolver implements EntityResolver {
public static final String PUBLIC_ID = "metadata.dtd";
public static final String SYSTEM_ID = "https://raw.githubusercontent.com/devezhao/persist4j/master/src/main/resources/metadata.dtd";
DTDEntityResolver() {
super();
}
@Override
public InputSource resolveEntity(String publicId, String systemId) {
InputStream stream = getClass().getClassLoader().getResourceAsStream(PUBLIC_ID);
InputSource source = new InputSource(stream);
source.setPublicId(PUBLIC_ID);
source.setSystemId(SYSTEM_ID);
source.setEncoding("UTF-8");
return source;
}
}
}
<?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>
<artifactId>eweb-dynamic-orm</artifactId>
<groupId>cn.eweb.frame</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dynamic-orm-core</artifactId>
<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>test</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>cn.eweb.frame</groupId>
<artifactId>eweb-common-utils</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
<includes>
<include>**/*.xsd</include>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/*.xml</exclude>
<exclude>**/*.properties</exclude>
</excludes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
<testResource>
<directory>src/test/resources</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
xmlns="http://www.sagframe.com/schema/sqltoy-translate"
xmlns:tns="http://www.sagframe.com/schema/sqltoy-translate"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.sagframe.com/schema/sqltoy-translate"
elementFormDefault="qualified">
<xsd:attributeGroup name="sqlToyTranslateAttrs">
<xsd:attribute name="cache" type="xsd:string"
use="required" />
<xsd:attribute name="keep-alive" type="xsd:integer"
default="3600">
<xsd:annotation>
<xsd:documentation>
<![CDATA[unit is second]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="heap" type="xsd:integer"
default="10000">
<xsd:annotation>
<xsd:documentation>
<![CDATA[unit is EntryUnit.ENTRIES]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="off-heap" type="xsd:integer"
default="0">
<xsd:annotation>
<xsd:documentation>
<![CDATA[unit is MemoryUnit.MB]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="disk-size" type="xsd:integer"
default="0">
<xsd:annotation>
<xsd:documentation>
<![CDATA[unit is MemoryUnit.MB]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="i18n" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
<![CDATA[example:zh_cn:1,en_us:2]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:attributeGroup>
<xsd:attributeGroup name="sqlToyTranslateUpdater">
<xsd:attribute name="cache" type="xsd:string"
use="required" />
<xsd:attribute name="has-inside-group"
type="xsd:boolean" default="false">
<xsd:annotation>
<xsd:documentation>
<![CDATA[缓存内部是否存在分组,比如数据字典缓存中有字典分类]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="check-frequency" type="xsd:string" />
</xsd:attributeGroup>
<!-- root -->
<xsd:element name="sagacity">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="cache-translates">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="sql-translate" minOccurs="0"
maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
<![CDATA[基于sql直接查询,将结果放入缓存,一般格式:key、name、segment1、segment2、status
第一列放编码,第二列放名称、后续作为扩展列自行定义,一般将状态放于最后一列
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:complexType mixed="true">
<xsd:sequence minOccurs="0">
<xsd:element name="sql" type="xsd:string" />
</xsd:sequence>
<xsd:attribute name="sql" type="xsd:string" />
<xsd:attribute name="datasource"
type="xsd:string" />
<xsd:attributeGroup
ref="sqlToyTranslateAttrs" />
</xsd:complexType>
</xsd:element>
<xsd:element name="service-translate" minOccurs="0"
maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
<![CDATA[通过spring service调用获取缓存,返回结果为List<List>或List<Object[]>类型]]>
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:attribute name="service" type="xsd:string"
use="required">
<xsd:annotation>
<xsd:documentation>
<![CDATA[对应serviceName或者对应java类型,如:com.xxx.TranslateService]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="method" type="xsd:string"
use="required">
<xsd:annotation>
<xsd:documentation>
<![CDATA[服务对应的method必须有一个字符型参数,例如:getDictCache(String cacheType)]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attributeGroup
ref="sqlToyTranslateAttrs" />
</xsd:complexType>
</xsd:element>
<xsd:element name="rest-translate" minOccurs="0"
maxOccurs="unbounded">
<xsd:complexType>
<xsd:attribute name="url" type="xsd:string"
use="required" />
<xsd:attribute name="username" type="xsd:string" />
<xsd:attribute name="password" type="xsd:string" />
<xsd:attributeGroup
ref="sqlToyTranslateAttrs" />
</xsd:complexType>
</xsd:element>
<xsd:element name="local-translate" minOccurs="0"
maxOccurs="unbounded">
<xsd:complexType mixed="true">
<xsd:attributeGroup
ref="sqlToyTranslateAttrs" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
<xsd:attribute name="disk-store-path"
default="./translateCaches" />
<xsd:attribute name="default-keep-alive"
type="xsd:integer" default="3600">
<xsd:annotation>
<xsd:documentation>
<![CDATA[unit is second]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="default-heap"
type="xsd:integer" default="10000">
<xsd:annotation>
<xsd:documentation>
<![CDATA[unit is EntryUnit.ENTRIES]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="default-off-heap"
type="xsd:integer" default="0">
<xsd:annotation>
<xsd:documentation>
<![CDATA[unit is MemoryUnit.MB]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="default-disk-size"
type="xsd:integer" default="0">
<xsd:annotation>
<xsd:documentation>
<![CDATA[unit is MemoryUnit.MB]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<!-- 缓存变更检测 -->
<xsd:element name="cache-update-checkers" minOccurs="0"
maxOccurs="1">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
1、返回结果必须是:cacheName,cacheType(可为null) 两列值,请求参数:lastUpdateTime;
2、check-frequency:可以是一个数字如5(每个5秒检测一次),也可以分段模式0..10:20?300,10:20..20?15,20..24?150
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="sql-checker" minOccurs="0"
maxOccurs="unbounded">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element name="sql" type="xsd:string" />
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string" />
<xsd:attribute name="sql" type="xsd:string" />
<xsd:attribute name="check-frequency"
type="xsd:string" />
<xsd:attribute name="datasource"
type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="service-checker" minOccurs="0"
maxOccurs="unbounded">
<xsd:complexType mixed="true">
<xsd:attribute name="id" type="xsd:string" />
<xsd:attribute name="service" type="xsd:string"
use="required" />
<xsd:attribute name="method" type="xsd:string"
use="required" />
<xsd:attribute name="check-frequency"
type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="rest-checker" minOccurs="0"
maxOccurs="unbounded">
<xsd:complexType mixed="true">
<xsd:attribute name="id" type="xsd:string" />
<xsd:attribute name="url" type="xsd:string"
use="required" />
<xsd:attribute name="check-frequency"
type="xsd:string" />
<xsd:attribute name="username" type="xsd:string" />
<xsd:attribute name="password" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="sql-increment-checker"
minOccurs="0" maxOccurs="unbounded">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element name="sql" type="xsd:string" />
</xsd:sequence>
<xsd:attribute name="sql" type="xsd:string" />
<xsd:attributeGroup
ref="sqlToyTranslateUpdater" />
<xsd:attribute name="datasource"
type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="service-increment-checker"
minOccurs="0" maxOccurs="unbounded">
<xsd:complexType mixed="true">
<xsd:attribute name="service" type="xsd:string"
use="required" />
<xsd:attribute name="method" type="xsd:string"
use="required" />
<xsd:attributeGroup
ref="sqlToyTranslateUpdater" />
</xsd:complexType>
</xsd:element>
<xsd:element name="rest-increment-checker"
minOccurs="0" maxOccurs="unbounded">
<xsd:complexType mixed="true">
<xsd:attribute name="url" type="xsd:string"
use="required" />
<xsd:attributeGroup
ref="sqlToyTranslateUpdater" />
<xsd:attribute name="username" type="xsd:string" />
<xsd:attribute name="password" type="xsd:string" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
<xsd:attribute name="cluster-time-deviation"
type="xsd:integer" default="1">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
集群各个节点时间差异(单位秒),缓存更新检测时将基准检测时间扣减差集群时差。
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
Metadata DTD 1.1
-->
<!--
主节点
-->
<!ELEMENT metadata-config (entity)+>
<!--
default-parent - 全局实体的默认继承
schema-name-optimize - 是否启用 schema 名称优化(实体 ReferencesMapping 优化为 references_mapping,字段 uniqueId 优化为 UNIQUE_ID)
-->
<!ATTLIST metadata-config
default-parent CDATA #IMPLIED
schema-name-optimize (true | false | 1 | 0) "false"
>
<!--
实体定义
-->
<!ELEMENT entity (field+, index*)>
<!--
实体定义的属性列表
name - 实体名称
physical-name - 物理名称
type-code - 实体代号,3位数字
name-field - 名称字段
parent - 父实体
description - 描述
schema-name-optimize - 是否启用schema优化
main - 所属主实体
extra-attrs - 扩展属性(JSON格式)
creatable - 可创建
updatable - 可更新
queryable - 可查询
deletable - 可删除
-->
<!ATTLIST entity
name CDATA #REQUIRED
physical-name CDATA #IMPLIED
type-code CDATA #REQUIRED
name-field CDATA #IMPLIED
parent CDATA #IMPLIED
description CDATA #IMPLIED
schema-name-optimize (true | false | 1 | 0) "false"
main CDATA #IMPLIED
extra-attrs CDATA #IMPLIED
creatable (true | false | 1 | 0) "true"
updatable (true | false | 1 | 0) "true"
queryable (true | false | 1 | 0) "true"
deletable (true | false | 1 | 0) "true"
>
<!--
字段定义
-->
<!ELEMENT field EMPTY>
<!--
字段定义的属性列表
name - 字段名称
type - 字段类型
physical-name - 物理名称
ref-entity - 引用实体列表
max-length - 最大长度,只支持某些字段
cascade - 级联模式,只支持删除级联
auto-value - 是否含有自动值(如在MySQL中可能存在如自动增长或当前时间),如为true,则系统会忽略填充此值
description - 描述
decimal-scale - 小数位精度
default-value - 默认值,由数据库完成
extra-attrs - 扩展属性(JSON格式)
creatable - 可创建
updatable - 可更新
queryable - 可查询
nullable - 可为空
repeatable - 可重复
-->
<!ATTLIST field
name CDATA #REQUIRED
type (primary | reference | any-reference | reference-list | char | string | text | ntext
| int | small-int | double | decimal | long | date | timestamp | time | bool | binary) #REQUIRED
physical-name CDATA #IMPLIED
ref-entity CDATA #IMPLIED
max-length CDATA #IMPLIED
cascade (delete | remove-links | ignore) "remove-links"
auto-value (true | false | 1 | 0) "false"
description CDATA #IMPLIED
decimal-scale (1 | 2 | 3 | 4 | 5 | 6 | 7 | 8) "4"
default-value CDATA #IMPLIED
extra-attrs CDATA #IMPLIED
creatable (true | false | 1 | 0) "true"
updatable (true | false | 1 | 0) "true"
queryable (true | false | 1 | 0) "true"
nullable (true | false | 1 | 0) "true"
repeatable (true | false | 1 | 0) "true"
>
<!--
索引定义(只为生成 SCHEMA 所用)
-->
<!ELEMENT index EMPTY>
<!--
字段定义的属性列表
type - 索引类型
field-list - 字段列表
-->
<!ATTLIST index
type (key | unique | fulltext) "key"
field-list CDATA #REQUIRED
>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<sqltoy xmlns="https://www.sagframe.com/schema/sqltoy"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.sagframe.com/schema/sqltoy https://www.sagframe.com/schema/sqltoy/sqltoy.xsd">
<sql id="show_case">
<!-- filters 用来对参与查询或执行的参数值进行转化处理 -->
<filters>
<!-- 参数等于某个值则将参数值设置为null -->
<eq params="organType" value="-1" />
<!-- 将参数条件值转换为日期格式,format可以是yyyy-MM-dd这种自定义格式也可以是: first_day:月的第一天;last_day:月的最后一天,first_year_day:年的第一天,last_year_day年的最后一天 -->
<to-date params="" format="yyyyMMdd" increment-days="1" />
<to-number params="" data-type="decimal" />
<!-- 通过缓存将名称用类似like模式匹配出对应的编码作为条件进行精准查询 -->
<cache-arg param="" cache-name="" cache-type="" alias-name="">
<!-- 对缓存进行过滤,比如个人授权的机构、状态为生效的缓存数据等 -->
<!-- compare-param: 可以是一个参数的属性名称也可以是具体的值,cache-index对应缓存数据的第几列 -->
<filter compare-param="1" cache-index="4"/>
</cache-arg>
<!-- 首要参数,比如页面上精准输入了订单编号,此时除特定条件外其他条件全部设置为null不参与查询 -->
<primary param="orderId" excludes="organIds" />
<!-- 将数组转化成in 的参数条件并增加单引号 -->
<to-in-arg params="" />
<!-- 空白转为null -->
<blank params="*" excludes="staffName" />
<!-- 参数值在某个区间则转为null -->
<between params="" start-value="0" end-value="9999" excludes="" />
<!-- 将前端传过来的字符串切割成数组 -->
<split params="staffAuthOrgs" data-type="string" split-sign="," />
<!-- 将参数转为字符串类型,add-quote:none\double\single,默认为none -->
<to-string params="" add-quote="none"/>
<!-- 参数小于等于某个值时转为null -->
<lte params="" value="" />
<!-- 参数小于某个值时转为null -->
<lt params="" value="" />
<!-- 参数大于等于某个值时转为null -->
<gte params="" value="" />
<!-- 参数大于某个值时转为null -->
<gt params="" value="" />
<!-- 字符替换,默认根据正则表达进行全部替换,is-first为true时只替换首个 -->
<replace params="" regex="" value="" is-first="false" />
<!-- 排他性参数,当某个参数是xxx值时,将其他参数设置为特定值 -->
<exclusive param="" compare-type="eq" compare-values="" set-params="" set-value="" />
<!--sysdate()-1d(d:天,h:小时,w:周;m:月,y:年);first_of_month-3d/first_of_year/first_of_week/last_of_month/last_of_week/last_of_year -->
<default params="beginDate" data-type="localDate" value="sysdate()-1d" />
</filters>
<!-- 缓存翻译,可以对例如:A,B 这种拼连的进行翻译(要指定分隔符号后最后拼装符号 split-regex="," link-sign=",")
uncached-template 是针对未能匹配时显示的补充,${value} 表示显示key值,可以key=[${value}未定义
这种写法 -->
<translate cache="dictCache" cache-type="POST_TYPE"
columns="POST_TYPE" cache-indexs="1" uncached-template="" />
<!-- 安全掩码:tel\姓名\地址\卡号 -->
<!--最简单用法: <secure-mask columns="" type="tel"/> -->
<secure-mask columns="" type="name" head-size="3"
tail-size="4" mask-code="*****" mask-rate="50" />
<!-- 分库策略 -->
<sharding-datasource strategy="multiDataBase" />
<!-- 分表策略 -->
<sharding-table tables="" strategy="hisRealTable"
params="" />
<!-- 分页优化,缓存相同查询条件的分页总记录数量, alive-max:表示相同的一个sql保留100个不同条件查询 alive-seconds:相同的查询条件分页总记录数保留时长(单位秒) -->
<page-optimize alive-max="100" alive-seconds="600" />
<!-- 日期格式化 -->
<date-format columns="" format="yyyy-MM-dd HH:mm:ss" />
<!-- 数字格式 -->
<number-format columns="" format="capital-rmb" />
<value>
<![CDATA[
select t1.*,t2.ORGAN_NAME from
@fast(select * from sys_staff_info t
where #[t.sexType=:sexType]
#[and t.JOIN_DATE>:beginDate]
#[and t.STAFF_NAME like :staffName]
-- 是否虚拟员工@if()做逻辑判断
#[@if(:isVirtual==true||:isVirtual==0) and t.IS_VIRTUAL=1]
) t1,sys_organ_info t2
where t1.ORGAN_ID=t2.ORGAN_ID
]]>
</value>
<!-- count-sql(只针对分页查询有效,sqltoy分页针对计算count的sql进行了智能处理, 一般不需要额外定义countsql,除极为苛刻的性能优化,sqltoy提供了极度优化的口子) -->
<count-sql><![CDATA[]]></count-sql>
<!-- 汇总和求平均 -->
<summary columns="" radix-size="2" reverse="false" sum-site="left">
<global sum-label="" label-column="" />
<group sum-label="" label-column="" group-column="" />
</summary>
<!-- 拼接某列,mysql中等同于group_concat\oracle 中的WMSYS.WM_CONCAT功能 -->
<link sign="," column="" />
<!-- 行转列 (跟unpivot互斥) -->
<pivot category-columns="" group-columns="" start-column="" end-column="" default-value="0" />
<!-- 列转行 -->
<unpivot columns-to-rows="1:xxx,2:xxxx" new-columns-labels="" />
</sql>
</sqltoy>
\ No newline at end of file
############# db config ####################
jdbc.connection.driver_class=oracle.jdbc.OracleDriver
jdbc.connection.url=jdbc:oracle:thin:@192.168.56.109:1521:sqltoy
jdbc.connection.username=sqltoy
jdbc.connection.password=sqltoy
jdbc.show_sql=false
jdbc.fetch_size=50
jdbc.batch_size=25
jdbc.maxIdle=3
jdbc.minIdle=1
jdbc.maxTotal=3
jdbc.defaultAutoCommit=false
jdbc.initialSize=2
jdbc.numTestsPerEvictionRun=2
## project phase,last formally datasource is simple as dbcp
jdbc.formally=false
############ sqltoy config ########################
sqltoy.debug=true
sqltoy.dialect=oracle
sqltoy.batchSize=200
sqltoy.autoCommit=false
sqltoy.showSql=true
package cn.eweb.frame.dynamic.orm;
import cn.eweb.frame.common.utils.xml.XmlHelper;
import cn.hutool.json.JSONArray;
import lombok.extern.slf4j.Slf4j;
import org.dom4j.Document;
import org.dom4j.Element;
import org.junit.Test;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Slf4j
public class XmlTest {
@Test
public void ReadXml(){
URL url = getClass().getClassLoader().getResource("metadata-test.xml");
List<String> errors = new ArrayList<>();
Document document;
XmlHelper XML_HELPER = new XmlHelper();
try {
document = XML_HELPER.createSAXReader("",
errors, XmlHelper.DEFAULT_DTD_RESOLVER).read(Objects.requireNonNull(url).openStream());
Element root = document.getRootElement();
log.info("rootElement name:{}",root.getName());
List<Element> elementList = root.elements();
log.info("elements 数量:{}",elementList.size());
for (Element item : elementList) {
System.out.println("实体标签的子标签的名字是"+ item.getName());
List<Element> fields = item.elements();
for(Element field : fields){
log.info("name:{}",field.getName());
log.info("type:{}",field.attribute("type"));
}
}
} catch (Exception e) {
}
}
@Test
public void getJSON(){
JSONArray jsonArray = new JSONArray();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE metadata-config SYSTEM "metadata.dtd">
<metadata-config schema-name-optimize="true" default-parent="SystemCommon">
<entity name="SystemCommon" type-code="000">
<field name="commonReference" type="reference" ref-entity="TestAllType" description="引用"/>
</entity>
<entity name="TestAllType" type-code="100">
<field name="tPrimary" type="primary" description="主键" />
<field name="tReference" type="reference" ref-entity="TestAllType" description="引用"/>
<field name="tInt" type="int"/>
<field name="tSmallInt" type="small-int"/>
<field name="tDouble" type="double" decimal-scale="6"/>
<field name="tDecimal" type="decimal" decimal-scale="7" />
<field name="tLong" type="long" auto-value="true"/>
<field name="tDate" type="date" description="日期"/>
<field name="tTimestamp" type="timestamp" description="日期时间" />
<field name="tTime" type="time" description="时间" />
<field name="tChar" type="char" description="字符"/>
<field name="tString" type="string" description="文版"/>
<field name="tText" type="text" description="长文本"/>
<field name="tBool" type="bool" description="布尔"/>
<field name="tNtext" type="ntext" description="超大文本"/>
<field name="tBinary" type="binary" description="二进制数据"/>
<field name="tAnyReference" type="any-reference" ref-entity="*" description="任意引用"/>
<field name="tAnyReference2" type="any-reference" ref-entity="Test2,Test3" description="任意引用"/>
<field name="tReferenceList" type="reference-list" ref-entity="TestAllType" description="多引用"/>
<index type="fulltext" field-list="tText,tNtext" />
<index field-list="tReference" />
<index field-list="tAnyReference" type="unique" />
</entity>
<entity name="Test2" type-code="102">
<field name="t2Primary" type="primary" description="主键" />
<field name="t2Reference" type="reference" ref-entity="TestAllType" description="引用"/>
<field name="t2Int" type="int"/>
</entity>
<entity name="Test3" type-code="103">
<field name="t3Primary" type="primary" description="主键" />
<field name="t1Reference" type="reference" ref-entity="TestAllType" description="引用"/>
<field name="t2Reference" type="reference" ref-entity="Test2" description="引用"/>
<field name="sum" type="double"/>
<field name="count" type="double"/>
</entity>
<entity name="Test4" type-code="104">
<field name="t4Primary" type="primary" />
<field name="year" type="string"/>
<field name="quarter" type="string" />
<field name="month" type="string"/>
<field name="week" type="string" />
<field name="count" type="string"/>
</entity>
</metadata-config>
\ No newline at end of file
<?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>
<artifactId>eweb-dynamic-orm</artifactId>
<groupId>cn.eweb.frame</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dynamic-orm-spring-boot-starter</artifactId>
<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
\ No newline at end of file
package cn.eweb.frame;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
\ No newline at end of file
<?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>
<artifactId>eweb-framework</artifactId>
<groupId>cn.eweb.frame</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>eweb-dynamic-orm</artifactId>
<packaging>pom</packaging>
<modules>
<module>dynamic-orm-core</module>
<module>dynamic-orm-spring-boot-starter</module>
</modules>
<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
\ No newline at end of file
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
<module>eweb-spring-framework</module> <module>eweb-spring-framework</module>
<module>eweb-spring-boot</module> <module>eweb-spring-boot</module>
<module>eweb-domain-event</module> <module>eweb-domain-event</module>
<module>eweb-dynamic-orm</module>
</modules> </modules>
<properties> <properties>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册