Compare commits

...

27 Commits

Author SHA1 Message Date
王熙朝 eb686da73e fase()尝试elk 2024-05-20 22:23:37 +08:00
王熙朝 596dd3544f fase()链路追踪 2024-05-19 18:24:48 +08:00
王熙朝 f49fd448e5 fase()修改或增加用mq通知初始化 2024-05-17 20:00:47 +08:00
王熙朝 29e6463f58 fase()修改或增加用mq通知初始化 2024-05-17 20:00:04 +08:00
王熙朝 f0e416ccf1 fase()规则测试 2024-05-17 09:51:08 +08:00
王熙朝 881752d134 fase()规则引擎初始化 2024-05-15 22:36:32 +08:00
王熙朝 34bf35a398 fase()随机显示和队列显示 2024-05-14 22:40:46 +08:00
王熙朝 28b252bb66 fase()线程池查找随机字段值 2024-05-13 22:41:37 +08:00
王熙朝 6044eaa915 fase()远程调用测试 2024-05-12 21:43:07 +08:00
王熙朝 bf01b893c7 fase()远程调用启动 2024-05-11 17:30:19 +08:00
王熙朝 20c771be2c fase()远程调用 2024-05-10 22:11:04 +08:00
王熙朝 91ceda487b fase()规范化 2024-05-10 14:43:05 +08:00
王熙朝 a9aa680abe fase()分层 2024-05-09 22:33:45 +08:00
王熙朝 9861b856e9 fase()分 2024-05-09 21:05:47 +08:00
王熙朝 f6c40ea666 fase()引擎规则调整 2024-05-08 21:49:44 +08:00
王熙朝 8ea31f9805 fase()引擎规则调整 2024-05-08 17:01:38 +08:00
王熙朝 f0ef7133ea feat()规则引擎 2024-05-06 08:37:15 +08:00
王熙朝 7d880faa7f 引擎 2024-05-04 19:28:54 +08:00
王熙朝 3bb6b71a99 feat(AccreditServiceImpl)资产授权 2024-05-01 09:13:38 +08:00
王熙朝 43feb93e6a feat(DataAccessServiceImpl)重写同步 2024-04-29 22:24:34 +08:00
王熙朝 c647dbf7fe feat(DataAccessServiceImpl)重写同步 2024-04-28 22:33:31 +08:00
王熙朝 50b273c1fc feat(dictServiceImpl)字典映射 2024-04-27 20:33:32 +08:00
王熙朝 43fec1afd3 feat(dictServiceImpl)资产模型字典表的关联,编辑 2024-04-26 22:44:43 +08:00
王熙朝 596a557ca1 feat(dataAccessServiceImpl,AccessServiceImpl)增加了同步和测试,完善了数据结构,重写字典 2024-04-24 21:29:05 +08:00
王熙朝 8e2250f874 type(AccreditServiceImpl,DataAccessServiceImpl)根据表单查询相应的表结构和表框架,新增接入同时会加入相应数据库的表结构和表框架 2024-04-23 22:28:19 +08:00
王熙朝 0324d7c70d fix:修复了删除异常的bug 2024-04-23 14:13:05 +08:00
王熙朝 72caf426a7 feat:增加了测试,部门查询+中间件,用户部门查询 2024-04-23 08:51:24 +08:00
338 changed files with 14873 additions and 3926 deletions

View File

@ -136,6 +136,12 @@
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>7.3</version>
</dependency>
</dependencies>
</project>

View File

@ -20,4 +20,7 @@ public class ServiceNameConstants {
* serviceid
*/
public static final String FILE_SERVICE = "muyu-file";
public static final String EDITION_MUYU = "muyu-rule";
public static final String System_MUYU = "muyu-system";
}

View File

@ -0,0 +1,20 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-goods</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-goods-test</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@ -0,0 +1,32 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>muyu-common</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-common-goods</artifactId>
<packaging>pom</packaging>
<modules>
<module>muyu-goods-test</module>
</modules>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- MuYu Common Core-->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-core</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -1,5 +1,6 @@
package com.muyu.common.redis.service;
import com.alibaba.fastjson2.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundSetOperations;
import org.springframework.data.redis.core.HashOperations;
@ -143,7 +144,7 @@ public class RedisService {
* @return
*/
public <T> List<T> getCacheList (final String key) {
return redisTemplate.opsForList().range(key, 0, -1);
return (List<T>) redisTemplate.opsForList().range(key, 0, -1);
}
/**
@ -190,10 +191,9 @@ public class RedisService {
* Map
*
* @param key
*
* @return
*/
public <T> Map<String, T> getCacheMap (final String key) {
public <T> Map<Object, Object> getCacheMap (final String key) {
return redisTemplate.opsForHash().entries(key);
}

View File

@ -60,9 +60,9 @@ public class TokenService {
Map<String, Object> rspMap = new HashMap<String, Object>();
rspMap.put("access_token", JwtUtils.createToken(claimsMap));
rspMap.put("expires_in", expireTime);
System.out.println(token);
return rspMap;
}
/**
*
*

View File

@ -18,6 +18,7 @@
<module>muyu-common-datascope</module>
<module>muyu-common-datasource</module>
<module>muyu-common-system</module>
<module>muyu-common-goods</module>
</modules>
<artifactId>muyu-common</artifactId>

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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.muyu</groupId>
<artifactId>muyu</artifactId>
<version>3.6.3</version>
<relativePath>../../../pom.xml</relativePath>
</parent>
<artifactId>muyu-data-test-client</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-goods-edition-common</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-system</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-goods-edition-remote</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-data-test-common</artifactId>
<version>3.6.3</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,11 @@
package muyu.data.test.clinet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DataClientApplication {
public static void main(String[] args) {
SpringApplication.run(DataClientApplication.class);
}
}

View File

@ -0,0 +1,136 @@
package muyu.data.test.clinet.config;
import lombok.extern.log4j.Log4j2;
import muyu.data.test.clinet.config.runner.AccessConfigRunner;
import muyu.data.test.common.dataSoutce.DataSourceConfig;
import muyu.data.test.common.model.DataModel;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import java.sql.*;
import java.util.*;
/**
*
*/
@Log4j2
@ComponentScan
@Import(value = AccessConfigRunner.class)
public class AccessConfig {
public List<DataModel> getRabdomData(Long id, String tableName, Integer ruleLevel) {
List<List<DataModel>> listList = new ArrayList<>();
Connection connection = DataSourceConfig.getConnection(id);
String sql = "select * from " + tableName;
try {
//获取原数据
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(sql);
PreparedStatement pst = connection.prepareStatement("select * from " + tableName);
log.info("元数据1:{}", resultSet);
// ResultSet resultSet1 = pst.executeQuery();
//元数据信息
ResultSetMetaData metaData = pst.getMetaData();
//元数据数量
int columnCount = metaData.getColumnCount();
while (resultSet.next()) {
List<DataModel> list = new ArrayList<>();
for (int i = 1; i <= columnCount; i++) {
String columnName = metaData.getColumnName(i);
log.info("字段名:{}", columnName);
String tableName1 = metaData.getTableName(i);
log.info("表名:{}", tableName1);
String columnClassName = metaData.getColumnClassName(i);
log.info("java类型:{}", columnClassName);
String columnTypeName = metaData.getColumnTypeName(i);
log.info("原类型:{}", columnTypeName);
String catalogName = metaData.getCatalogName(i);
log.info("数据库名:{}", catalogName);
Object object = resultSet.getObject(i);
log.info("字段值:{}", object);
DataModel build = DataModel.builder()
.key(columnName)
.val(object)
.sourceType(columnTypeName)
.processType(columnClassName)
.processClass(Class.forName(columnClassName))
.build();
log.info("测试内容:{}", build);
list.add(build);
}
listList.add(list);
}
} catch (SQLException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
log.info("长度:{}", listList.size());
log.info("列表:{}", listList);
if (listList.size() == 0) {
return null;
}
for (List<DataModel> list : listList) {
System.out.println(list);
}
Random random = new Random();
int i = random.nextInt(listList.size());
return listList.get(i);
}
public List<List<DataModel>> getColumn(Long id, String tableName, Integer ruleLevel) {
List<List<DataModel>> listList = new ArrayList<>();
Connection connection = DataSourceConfig.getConnection(id);
String sql = "select * from " + tableName;
try {
//获取原数据
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(sql);
PreparedStatement pst = connection.prepareStatement("select * from " + tableName);
log.info("元数据1:{}", resultSet);
//元数据信息
ResultSetMetaData metaData = pst.getMetaData();
//元数据数量
int columnCount = metaData.getColumnCount();
while (resultSet.next()) {
List<DataModel> list = new ArrayList<>();
for (int i = 1; i <= columnCount; i++) {
String columnName = metaData.getColumnName(i);
String columnClassName = metaData.getColumnClassName(i);
String columnTypeName = metaData.getColumnTypeName(i);
Object object = resultSet.getObject(i);
DataModel build = DataModel.builder()
.key(columnName)
.val(object)
.sourceType(columnTypeName)
.processType(columnClassName)
.processClass(Class.forName(columnClassName))
.build();
// log.info("测试内容:{}",build);
list.add(build);
}
listList.add(list);
}
} catch (SQLException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
return listList;
}
private Map<String, String> getColumnComments(DatabaseMetaData metaData, String typeName) {
Map<String, String> columnComents = new HashMap<>();
try (ResultSet colums = metaData.getColumns(null, null, typeName, null)) {
while (colums.next()) {
String columsName = colums.getString("COLUMN_NAME");
String columsComment = colums.getString("REMARKS");
columnComents.put(columsName, columsComment);
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
return columnComents;
}
}

View File

@ -0,0 +1,101 @@
package muyu.data.test.clinet.config;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.exception.ServiceException;
import com.muyu.edition.domain.Edition;
import com.muyu.goods.edition.remote.EditionDataRemoteService;
import lombok.extern.log4j.Log4j2;
import muyu.data.test.clinet.config.runner.DataEditionConfigRunner;
import muyu.data.test.common.context.DataModelContextHolder;
import muyu.data.test.common.context.DataSetContextHolder;
import muyu.data.test.common.dataSoutce.EditionSoutceConfig;
import muyu.data.test.common.dymamicLoad.DynamicLoader;
import muyu.data.test.common.model.DataModel;
import muyu.data.test.common.model.DataSetModel;
import muyu.data.test.common.model.RecordModel;
import muyu.data.test.common.model.process.DataModelProcessModel;
import muyu.data.test.common.model.process.DataSetProcessModel;
import muyu.data.test.common.model.process.RecordProcessModel;
import muyu.data.test.common.req.TestDataModelReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Log4j2
@ComponentScan
@Import(value = DataEditionConfigRunner.class)
public class DataEditionConfig {
@Autowired
private EditionDataRemoteService editionDataRemoteService;
public Object setColumn(TestDataModelReq testDataModelReq) {
switch (testDataModelReq.getRuleLevel()) {
case 2:
//先获取一个记录列
List<RecordModel> dataModels = new ArrayList<>();
// 获取数据集的数据
List<List<DataModel>> dataModelLists = testDataModelReq.getDataModelLists();
//给记录列赋值
dataModelLists.stream().forEach(res -> {
//获取记录模型
RecordModel recordModel = RecordModel.builder().dataModels(res).build();
dataModels.add(recordModel);
});
//调取数据集的处理模型
DataSetModel dataSetModel = DataSetModel.builder().recordModels(dataModels).build();
//调取数据集的上下文
DataSetProcessModel dataSetProcessModel = new DataSetProcessModel();
dataSetProcessModel.setDataSetModel(dataSetModel);
DataSetContextHolder.set(dataSetProcessModel);
case 3:
//调取记录的处理模型
RecordModel recordModel = RecordModel.builder()
.dataModels(testDataModelReq.getDataModelList())
.build();
//调取记录的上下文
RecordProcessModel recordProcessModel = new RecordProcessModel();
recordProcessModel.setKeys(testDataModelReq.getKeys());
recordProcessModel.setRecordModel(recordModel);
case 4:
//调取数据处理模型
DataModelProcessModel dataModelProcessModel = new DataModelProcessModel();
dataModelProcessModel.setDataModel(testDataModelReq.getDataModel());
//调取数据明显上下文
DataModelContextHolder.set(dataModelProcessModel);
}
// 获取规则
List<Edition> listEdition = editionDataRemoteService.lists().getData();
List<Edition> editions = listEdition.stream().filter(e -> e.getId().equals(testDataModelReq.getEditionId())).collect(Collectors.toList());
Edition edition = editions.get(0);
Map<String, byte[]> aByte = EditionSoutceConfig.getByte(edition.getId());
try {
// 加载class文件到虚拟机中然后通过反射执行
@SuppressWarnings("resource")
DynamicLoader.MemoryClassLoader classLoader = new DynamicLoader.MemoryClassLoader(aByte);
Class<?> clazz = classLoader.loadClass(edition.getVersionClass());
// 调用ruleTest方法
Method mainMethod = clazz.getDeclaredMethod("execution");
Object o = clazz.newInstance();
mainMethod.invoke(o);
} catch (Exception e) {
e.printStackTrace();
throw new ServiceException("异常" + e.getMessage());
}
return "正常,无需返回";
}
public void editionInitialize() {
//获取规则
Result<List<Edition>> tableDataInfoResult = editionDataRemoteService.lists();
List<Edition> editions = tableDataInfoResult.getData();
EditionSoutceConfig.indexByte(editions);
}
}

View File

@ -0,0 +1,57 @@
package muyu.data.test.clinet.config.runner;
import com.muyu.common.core.domain.Result;
import com.muyu.system.domain.DataAccess;
import com.muyu.system.remote.RemoteSystemManageService;
import lombok.extern.log4j.Log4j2;
import muyu.data.test.common.dataSoutce.DataSourceConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
/**
*
*/
@Log4j2
@Component
@Configuration
public class AccessConfigRunner implements ApplicationRunner {
@Autowired
private RemoteSystemManageService remoteSystemManageService;
@Override
public void run(ApplicationArguments args) throws Exception {
//远程调用
Result<List<DataAccess>> lists = remoteSystemManageService.lists();
// log.info("数据源调用状态:{}",lists);
//判断非空
if (lists.getData() == null || lists.getData().isEmpty()) {
log.error("数据为空");
return;
}
//获取数据源集合
List<DataAccess> listResultData = lists.getData();
// log.info("远程调用:{}",listResultData);
//存入map
//创建map
HashMap<Long, DataAccess> frimaryVoHashMap = new HashMap<>();
//遍历循环存入map
listResultData.forEach(res -> {
frimaryVoHashMap.put(res.getId(), res);
});
//遍历添加到hashMap
for (DataAccess listResultDatum : listResultData) {
if (listResultDatum.getType().equals("MySql")) {
//记录线程池
DataSourceConfig.index(listResultDatum);
}
}
}
}

View File

@ -0,0 +1,80 @@
package muyu.data.test.clinet.config.runner;
import com.muyu.common.core.domain.Result;
import com.muyu.edition.domain.Edition;
import com.muyu.edition.domain.RuleEngine;
import com.muyu.goods.edition.remote.EditionDataRemoteService;
import com.muyu.goods.edition.remote.RemoteDataManagerService;
import lombok.extern.log4j.Log4j2;
import muyu.data.test.common.dataSoutce.EditionSoutceConfig;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Log4j2
@Component
@Configuration
public class DataEditionConfigRunner implements ApplicationRunner, ApplicationContextAware {
@Autowired
private RemoteDataManagerService remoteDataManagerService;
@Autowired
private EditionDataRemoteService editionDataRemoteService;
/**
*
*
* @param applicationContext the ApplicationContext object to be used by this object
* @throws BeansException
*/
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
System.out.println("1");
}
@Override
public void run(ApplicationArguments args) throws Exception {
//获取引擎
Result<List<RuleEngine>> listResult = remoteDataManagerService.list();
// log.info("获取引擎:{}",listResult);
List<RuleEngine> listResultData = listResult.getData();
//获取规则
Result<List<Edition>> tableDataInfoResult = editionDataRemoteService.lists();
// log.info("获取规则:{}",tableDataInfoResult);
List<Edition> editionList = tableDataInfoResult.getData();
// log.info("获取规则:{}",editionList);
//处理获取的引擎和规则
for (RuleEngine listResultDatum : listResultData) {
List<Edition> editions = editionList.stream().filter(e -> e.getRuleId().equals(listResultDatum.getRuleId())).collect(Collectors.toList());
EditionSoutceConfig.indexByte(editions);
for (Edition edition : editionList.stream().filter(e -> e.getRuleId().equals(listResultDatum.getRuleId())).collect(Collectors.toList())) {
EditionSoutceConfig.index(listResultDatum.getRuleId(), edition);
}
}
Long ruleId = listResultData.get(0).getRuleId();
Long id = editionList.get(0).getId();
// HashMap<Long, Edition> editionHashMap = EditionSoutceConfig.get(ruleId);
// log.info("查看第一批:{}",editionHashMap);
HashMap<Long, Map<String, byte[]>> even = EditionSoutceConfig.even();
Map<String, byte[]> aByte = EditionSoutceConfig.getByte(id);
log.info("总表:{}", even);
log.info("第一个:{}", aByte);
String versionClass = editionList.get(0).getVersionClass();
byte[] bytes = aByte.get(versionClass);
String s = new String(bytes);
log.info(s);
}
}

View File

@ -0,0 +1,2 @@
muyu.data.test.clinet.config.AccessConfig
muyu.data.test.clinet.config.DataEditionConfig

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/muyu-visual-monitor"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.muyu" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<root level="info">
<appender-ref ref="console"/>
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
</configuration>

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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.muyu</groupId>
<artifactId>muyu-data-test</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-data-test-common</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-core</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-system</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-modules-system</artifactId>
<version>3.6.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-goods-edition-common</artifactId>
<version>3.6.3</version>
<scope>compile</scope>
</dependency>
<!-- rabbitMQ 依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,39 @@
package muyu.data.test.common.context;
import lombok.Data;
import lombok.experimental.SuperBuilder;
import muyu.data.test.common.model.process.DataModelProcessModel;
/**
*
*
* @ClassName DataModelContextHolder
* @Author
*/
@Data
@SuperBuilder
public class DataModelContextHolder {
private static final ThreadLocal<DataModelProcessModel> THREAD_LOCAL = new ThreadLocal<>();
private RecordContextHolder recordContextHolder;
public static DataModelContextHolder build(RecordContextHolder recordContextHolder) {
return DataModelContextHolder.builder()
.recordContextHolder(recordContextHolder)
.build();
}
public static DataModelProcessModel get() {
return THREAD_LOCAL.get();
}
public static void set(DataModelProcessModel dataModelProcessModel) {
THREAD_LOCAL.set(dataModelProcessModel);
}
public static void remove() {
THREAD_LOCAL.remove();
}
}

View File

@ -0,0 +1,38 @@
package muyu.data.test.common.context;
import lombok.Data;
import lombok.experimental.SuperBuilder;
import muyu.data.test.common.model.process.DataSetProcessModel;
/**
*
*
* @ClassName DataSetContextHolder
* @Author
*/
@Data
@SuperBuilder
public class DataSetContextHolder {
private static final ThreadLocal<DataSetProcessModel> THREAD_LOCAL = new ThreadLocal<>();
private TaskContextHolder taskContextHolder;
public static DataSetContextHolder build(TaskContextHolder taskContextHolder) {
return DataSetContextHolder.builder()
.taskContextHolder(taskContextHolder)
.build();
}
public static DataSetProcessModel get() {
return THREAD_LOCAL.get();
}
public static void set(DataSetProcessModel dataSetProcessModel) {
THREAD_LOCAL.set(dataSetProcessModel);
}
public static void remove() {
THREAD_LOCAL.remove();
}
}

View File

@ -0,0 +1,38 @@
package muyu.data.test.common.context;
import lombok.Data;
import lombok.experimental.SuperBuilder;
import muyu.data.test.common.model.process.RecordProcessModel;
/**
*
*
* @ClassName RecordContextHolder
* @Author
*/
@Data
@SuperBuilder
public class RecordContextHolder {
private static final ThreadLocal<RecordProcessModel> THREAD_LOCAL = new ThreadLocal<>();
private DataSetContextHolder dataSetContextHolder;
public static RecordContextHolder build(DataSetContextHolder dataSetContextHolder) {
return RecordContextHolder.builder()
.dataSetContextHolder(dataSetContextHolder)
.build();
}
public static RecordProcessModel get() {
return THREAD_LOCAL.get();
}
public static void set(RecordProcessModel recordProcessModel) {
THREAD_LOCAL.set(recordProcessModel);
}
public static void remove() {
THREAD_LOCAL.remove();
}
}

View File

@ -0,0 +1,14 @@
package muyu.data.test.common.context;
/**
*
*
* @ClassName TaskContextHolder
* @Author
*/
public class TaskContextHolder {
public static TaskContextHolder build() {
return new TaskContextHolder();
}
}

View File

@ -0,0 +1,93 @@
package muyu.data.test.common.dataSoutce;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidPooledConnection;
import com.muyu.system.domain.DataAccess;
import lombok.Data;
import lombok.extern.log4j.Log4j2;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
/**
* 线
*/
@Data
@Component
@Configuration
@Log4j2
public class DataSourceConfig {
private static HashMap<Long, DruidDataSource> hashMap = new HashMap<>();
/**
* 线
* 线
*/
public static void index(DataAccess dataAccess) throws SQLException {
//主机地址
String host = dataAccess.getHost();
//端口号
String port = dataAccess.getPort();
//数据库名
String databaseName = dataAccess.getDatabaseName();
// url
String url = String.format("jdbc:mysql://" + host + ":" + port + "/" + databaseName);
DruidDataSource dataSource = new DruidDataSource();
//初始化链接池数量
dataSource.setInitialSize(dataAccess.getInitNum().intValue());
//最大线程池
dataSource.setMaxActive(dataAccess.getMaxNum().intValue());
//最大等待时间
dataSource.setMaxWait(dataAccess.getMaxWaitTime());
//配置数据库的基本信息
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
//数据库连接池
dataSource.setUrl(url);
//数据库用户名
dataSource.setUsername(dataAccess.getUsername());
//数据库密码
dataSource.setPassword(dataAccess.getPassword());
dataSource.init();// 初始化
hashMap.put(dataAccess.getId(), dataSource);
// log.info("储存线程池:{}",hashMap);
}
/**
* 线
*/
public static Connection getConnection(Long key) {
DruidDataSource dataSource = hashMap.get(key);
try {
DruidPooledConnection connection = dataSource.getConnection();
return connection;
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
/**
* 线
*/
public static void returnConnection(Connection connection) {
try {
connection.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
/**
* 线
* 线
*/
public static DruidDataSource verify(Long key) throws SQLException {
DruidDataSource dataSource = hashMap.get(key);
// 获取连接
// log.info("查看连接上的线程池:{}",dataSource);
return dataSource;
}
}

View File

@ -0,0 +1,50 @@
package muyu.data.test.common.dataSoutce;
import com.muyu.edition.constant.RuleOperationConstants;
import com.muyu.edition.domain.Edition;
import lombok.Data;
import lombok.extern.log4j.Log4j2;
import muyu.data.test.common.dymamicLoad.DynamicLoader;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Data
@Component
@Configuration
@Log4j2
public class EditionSoutceConfig {
private static HashMap<Long, HashMap<Long, Edition>> hashMap = new HashMap<>();
private static HashMap<Long, Map<String, byte[]>> longHashMapHashMap = new HashMap<>();
public static void index(Long ruleId, Edition edition) {
HashMap<Long, Edition> editionHashMap = new HashMap<>();
editionHashMap.put(edition.getId(), edition);
hashMap.put(ruleId, editionHashMap);
}
public static void indexByte(List<Edition> list) {
list.stream().forEach(engine -> {
//获取版本内容
String content = engine.getRuleContent().replaceAll("\r\n", "");
//编译生成class文件存放到Map中
Map<String, byte[]> compile = DynamicLoader.compile(engine.getVersionClass() + RuleOperationConstants.FILE_SUFFIX, content);
longHashMapHashMap.put(engine.getId(), compile);
});
}
public static HashMap<Long, Edition> get(Long ruleId) {
return hashMap.get(ruleId);
}
public static Map<String, byte[]> getByte(Long id) {
return longHashMapHashMap.get(id);
}
public static HashMap<Long, Map<String, byte[]>> even() {
return longHashMapHashMap;
}
}

View File

@ -0,0 +1,29 @@
package muyu.data.test.common.domain;
import lombok.Data;
import lombok.experimental.SuperBuilder;
@Data
@SuperBuilder
public class Column {
/**
*
*/
private String key;
/**
*
*/
private Object val;
/**
*
*/
private String sourceType;
/**
*
*/
private String processType;
/**
*
*/
private Class<?> processClass;
}

View File

@ -0,0 +1,11 @@
package muyu.data.test.common.domain;
import lombok.Data;
import lombok.experimental.SuperBuilder;
@Data
@SuperBuilder
public class Table {
public String key;
public Object val;
}

View File

@ -0,0 +1,36 @@
package muyu.data.test.common.domain.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
*
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class DataModel {
/**
*
*/
private String key;
/**
*
*/
private Object val;
/**
*
*/
private String sourceType;
/**
*
*/
private String processType;
/**
*
*/
private Class<?> processClass;
}

View File

@ -0,0 +1,16 @@
package muyu.data.test.common.domain.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.List;
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class DataSetModel {
private List<RecordModel> list;
}

View File

@ -0,0 +1,16 @@
package muyu.data.test.common.domain.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.List;
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class RecordModel {
private List<DataModel> modelList;
}

View File

@ -0,0 +1,76 @@
package muyu.data.test.common.dymamicLoad;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* @ClassName DynamicLoader
* @Author
* @Date 2024/5/1 20:37
*/
public class DynamicLoader {
/**
* JavaMap
* Map便
*
* @param javaName
* @return map
*/
public static Map<String, byte[]> compile(String javaName, String javaSrc) {
// 调用java编译器接口
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
StandardJavaFileManager stdManager = compiler
.getStandardFileManager(null, null, null);
try (MemoryJavaFileManager manager = new MemoryJavaFileManager(
stdManager)) {
@SuppressWarnings("static-access")
JavaFileObject javaFileObject = manager.makeStringSource(javaName,
javaSrc);
JavaCompiler.CompilationTask task = compiler.getTask(null, manager,
null, null, null, Arrays.asList(javaFileObject));
if (task.call()) {
return manager.getClassBytes();
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
/**
* URLClassLoader defineClass
* URLClassLoaderclassjvm
*
* @author Administrator
*/
public static class MemoryClassLoader extends URLClassLoader {
Map<String, byte[]> classBytes = new HashMap<String, byte[]>();
public MemoryClassLoader(Map<String, byte[]> classBytes) {
super(new URL[0], MemoryClassLoader.class.getClassLoader());
this.classBytes.putAll(classBytes);
}
@Override
protected Class<?> findClass(String name)
throws ClassNotFoundException {
byte[] buf = classBytes.get(name);
if (buf == null) {
return super.findClass(name);
}
classBytes.remove(name);
return defineClass(name, buf, 0, buf.length);
}
}
}

View File

@ -0,0 +1,135 @@
package muyu.data.test.common.dymamicLoad;
import javax.tools.*;
import java.io.*;
import java.net.URI;
import java.nio.CharBuffer;
import java.util.HashMap;
import java.util.Map;
/**
* .classmap
*
* @ClassName MemoryJavaFileManager
* @Author
* @Date 2024/5/1 20:38
*/
@SuppressWarnings("rawtypes")
public final class MemoryJavaFileManager extends ForwardingJavaFileManager {
private final static String EXT = ".java";// Java源文件的扩展名
private Map<String, byte[]> classBytes;// 用于存放.class文件的内存
@SuppressWarnings("unchecked")
public MemoryJavaFileManager(JavaFileManager fileManager) {
super(fileManager);
classBytes = new HashMap<String, byte[]>();
}
static JavaFileObject makeStringSource(String name, String code) {
return new StringInputBuffer(name, code);
}
static URI toURI(String name) {
File file = new File(name);
if (file.exists()) {// 如果文件存在返回他的URI
return file.toURI();
} else {
try {
final StringBuilder newUri = new StringBuilder();
newUri.append("mfm:///");
newUri.append(name.replace('.', '/'));
if (name.endsWith(EXT)) {
newUri.replace(newUri.length() - EXT.length(),
newUri.length(), EXT);
}
return URI.create(newUri.toString());
} catch (Exception exp) {
return URI.create("mfm:///com/sun/script/java/java_source");
}
}
}
public Map<String, byte[]> getClassBytes() {
return classBytes;
}
@Override
public void close() throws IOException {
classBytes = new HashMap<String, byte[]>();
}
@Override
public void flush() throws IOException {
}
@Override
public JavaFileObject getJavaFileForOutput(
Location location, String className,
JavaFileObject.Kind kind, FileObject sibling) throws IOException {
if (kind == JavaFileObject.Kind.CLASS) {
return new ClassOutputBuffer(className);
} else {
return super.getJavaFileForOutput(location, className, kind,
sibling);
}
}
/**
* stringsourcejkd
*/
private static class StringInputBuffer extends SimpleJavaFileObject {
// The source code of this "file".
final String code;
/**
* Constructs a new JavaSourceFromString.
*
* @param name name
* @param code sourcecode
*/
StringInputBuffer(String name, String code) {
super(toURI(name), Kind.SOURCE);
this.code = code;
}
@Override
public CharBuffer getCharContent(boolean ignoreEncodingErrors) {
return CharBuffer.wrap(code);
}
@SuppressWarnings("unused")
public Reader openReader() {
return new StringReader(code);
}
}
/**
* JavaclassBytes
*/
private class ClassOutputBuffer extends SimpleJavaFileObject {
private String name;
/**
* @param name className
*/
ClassOutputBuffer(String name) {
super(toURI(name), Kind.CLASS);
this.name = name;
}
@Override
public OutputStream openOutputStream() {
return new FilterOutputStream(new ByteArrayOutputStream()) {
@Override
public void close() throws IOException {
out.close();
ByteArrayOutputStream bos = (ByteArrayOutputStream) out;
// 这里需要修改
classBytes.put(name, bos.toByteArray());
}
};
}
}
}

View File

@ -0,0 +1,15 @@
package muyu.data.test.common.engine;
/**
*
*
* @ClassName Engine
* @Author:
* @Date: 2024/5/6 13:48
*/
public interface Engine<V> {
public void execution();
public V get();
}

View File

@ -0,0 +1,35 @@
package muyu.data.test.common.engine.action;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.log4j.Log4j2;
/**
*
*
* @ClassName ActionRecords
* @Author
* @Date 2024/5/13 22:31
*/
@Getter
@Setter
@Log4j2
public class ActionRecords extends RuntimeException {
/**
*
*/
private String name = "记录";
/**
*
*/
private Object object;
public ActionRecords(Object object) {
this.object = object;
}
public void records() {
log.info("记录的数据是:{}", this.object);
}
}

View File

@ -0,0 +1,34 @@
package muyu.data.test.common.engine.action;
import com.muyu.edition.model.DataModel;
import lombok.Getter;
import lombok.Setter;
/**
*
*
* @ClassName ActionRemove
* @Author:
* @Date: 2024/5/6 13:48
*/
@Setter
@Getter
public class ActionRemove extends RuntimeException {
/**
*
*/
private String name = "移除";
/**
*
*/
private DataModel dataModel;
public ActionRemove(DataModel dataModel) {
this.dataModel = dataModel;
}
public void remove() {
this.dataModel.setValue(null);
}
}

View File

@ -0,0 +1,43 @@
package muyu.data.test.common.engine.action;
import com.muyu.edition.model.DataModel;
import lombok.Getter;
import lombok.Setter;
/**
*
*
* @ClassName ActionReplace
* @Author:
* @Date: 2024/5/6 13:48
*/
@Getter
@Setter
public class ActionReplace extends RuntimeException {
/**
*
*/
private String name = "替换";
/**
*
*/
private String newValue;
/**
*
*/
private DataModel dataModel;
public ActionReplace(String newValue, DataModel dataModel) {
super();
this.newValue = newValue;
this.dataModel = dataModel;
}
public ActionReplace() {
super();
}
public void replace() {
this.dataModel.setValue(this.newValue);
}
}

View File

@ -0,0 +1,48 @@
package muyu.data.test.common.engine.scope;
import muyu.data.test.common.context.DataModelContextHolder;
import muyu.data.test.common.engine.Engine;
import muyu.data.test.common.model.DataModel;
import muyu.data.test.common.model.process.DataModelProcessModel;
/**
*
*
* @ClassName DataModelEngine
* @Author:
* @Date: 2024/5/6 13:48
*/
public abstract class DataModelEngine implements Engine<DataModelProcessModel> {
@Override
public DataModelProcessModel get() {
return DataModelContextHolder.get();
}
public DataModel getModel() {
return get().getDataModel();
}
public String getKey() {
return getModel().getKey();
}
public Object getValue() {
return getModel().getVal();
}
public String getSourceType() {
return getModel().getSourceType();
}
public String getProcessType() {
return getModel().getProcessType();
}
public Class<?> getProcessClass() {
return getModel().getProcessClass();
}
}

View File

@ -0,0 +1,33 @@
package muyu.data.test.common.engine.scope;
import muyu.data.test.common.context.DataSetContextHolder;
import muyu.data.test.common.engine.Engine;
import muyu.data.test.common.model.DataSetModel;
import muyu.data.test.common.model.RecordModel;
import muyu.data.test.common.model.process.DataSetProcessModel;
import java.util.List;
/**
*
*
* @ClassName DataSetEngine
* @Author:
* @Date: 2024/5/6 13:48
*/
public abstract class DataSetEngine implements Engine<DataSetProcessModel> {
@Override
public DataSetProcessModel get() {
return DataSetContextHolder.get();
}
public DataSetModel getModel() {
return get().getDataSetModel();
}
public List<RecordModel> getRecordModels() {
return getModel().getRecordModels();
}
}

View File

@ -0,0 +1,37 @@
package muyu.data.test.common.engine.scope;
import muyu.data.test.common.context.RecordContextHolder;
import muyu.data.test.common.engine.Engine;
import muyu.data.test.common.model.DataModel;
import muyu.data.test.common.model.RecordModel;
import muyu.data.test.common.model.process.RecordProcessModel;
import java.util.List;
/**
*
*
* @ClassName RecordEngine
* @Author:
* @Date: 2024/5/6 13:48
*/
public abstract class RecordEngine implements Engine<RecordProcessModel> {
@Override
public RecordProcessModel get() {
return RecordContextHolder.get();
}
public List<String> getKeys() {
return get().getKeys();
}
public RecordModel getModel() {
return get().getRecordModel();
}
public List<DataModel> getDataModels() {
return getModel().getDataModels();
}
}

View File

@ -0,0 +1,44 @@
package muyu.data.test.common.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
*
*
* @ClassName DataModel
* @Author
* @Date 2024/5/5 18:48
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class DataModel {
/**
*
*/
private String key;
/**
*
*/
private Object val;
/**
*
*/
private String sourceType;
/**
*
*/
private String processType;
/**
*
*/
private Class<?> processClass;
}

View File

@ -0,0 +1,24 @@
package muyu.data.test.common.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.List;
/**
*
*
* @ClassName DataSetModel
* @Author
* @Date 2024/5/5 18:48
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class DataSetModel {
private List<RecordModel> recordModels;
}

View File

@ -0,0 +1,25 @@
package muyu.data.test.common.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.List;
/**
*
*
* @ClassName RecordModel
* @Author
* @Date 2024/5/5 18:48
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class RecordModel {
private List<DataModel> dataModels;
}

View File

@ -0,0 +1,20 @@
package muyu.data.test.common.model.process;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import muyu.data.test.common.model.DataModel;
/**
*
*
* @ClassName DataModelProcessModel
* @Author
* @Date 2024/5/5 18:37
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DataModelProcessModel {
private DataModel dataModel;
}

View File

@ -0,0 +1,20 @@
package muyu.data.test.common.model.process;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import muyu.data.test.common.model.DataSetModel;
/**
*
*
* @ClassName DataSetProcessModel
* @Author
* @Date 2024/5/5 18:37
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DataSetProcessModel {
private DataSetModel dataSetModel;
}

View File

@ -0,0 +1,23 @@
package muyu.data.test.common.model.process;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import muyu.data.test.common.model.RecordModel;
import java.util.List;
/**
*
*
* @ClassName RecordProcessModel
* @Author
* @Date 2024/5/5 18:37
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RecordProcessModel {
private List<String> keys;
private RecordModel recordModel;
}

View File

@ -0,0 +1,28 @@
package muyu.data.test.common.req;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import muyu.data.test.common.model.DataModel;
import java.util.List;
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class TestDataModelReq {
//作用域登记
private Integer ruleLevel;
//主键
private Long editionId;
//队列值
private List<String> keys;
//单个字段详情
private DataModel dataModel;
// 多个字段详情
private List<DataModel> dataModelList;
// 双重
private List<List<DataModel>> dataModelLists;
}

View File

@ -0,0 +1,20 @@
package muyu.data.test.common.scope;
import lombok.Data;
/**
*
*
* @ClassName DataModelContextHolder
* @Author
* @Version: 1.0
*/
@Data
public class DataModelContextHolder {
private final RecordContextHolder recordContextHolder;
public static DataModelContextHolder build(RecordContextHolder recordContextHolder) {
return new DataModelContextHolder(recordContextHolder);
}
}

View File

@ -0,0 +1,20 @@
package muyu.data.test.common.scope;
import lombok.Data;
/**
*
*
* @ClassName DataSetContextHolder
* @Author
* @Version: 1.0
*/
@Data
public class DataSetContextHolder {
private final TaskContextHolder taskContextHolder;
public static DataSetContextHolder build(TaskContextHolder taskContextHolder) {
return new DataSetContextHolder(taskContextHolder);
}
}

View File

@ -0,0 +1,20 @@
package muyu.data.test.common.scope;
import lombok.Data;
/**
*
*
* @ClassName RecordContextHolder
* @Author
* @Version: 1.0
*/
@Data
public class RecordContextHolder {
private final DataSetContextHolder dataSetContextHolder;
public static RecordContextHolder build(DataSetContextHolder dataSetContextHolder) {
return new RecordContextHolder(dataSetContextHolder);
}
}

View File

@ -0,0 +1,15 @@
package muyu.data.test.common.scope;
/**
*
*
* @ClassName TaskContextHolder
* @Author
* @Version: 1.0
*/
public class TaskContextHolder {
public static TaskContextHolder build() {
return new TaskContextHolder();
}
}

View File

@ -0,0 +1,7 @@
import java.util.List;
public class TestClass {
public static String ruleTest(List<String> list) {
return "1";
}
}

View File

@ -0,0 +1,13 @@
import com.muyu.edition.engine.action.ActionRecords;
import com.muyu.edition.engine.scope.parentClass;
/**
* @Description: this.form.name-this.form.versionCode
*/
public class this.form.versionCode extends parentClass {
@Override
public void execution () {
}
}`;

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/muyu-visual-monitor"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.muyu" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<root level="info">
<appender-ref ref="console"/>
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
</configuration>

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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.muyu</groupId>
<artifactId>muyu-data-test</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-data-test-server</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-data-test-common</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-data-test-client</artifactId>
<version>3.6.3</version>
</dependency>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- SpringBoot Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Swagger UI -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.fox.version}</version>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<!-- MuYu Common DataSource -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-datasource</artifactId>
</dependency>
<!-- MuYu Common DataScope -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-datascope</artifactId>
</dependency>
<!-- MuYu Common Log -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-log</artifactId>
</dependency>
<!-- MuYu Common Swagger -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-common-swagger</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 加入maven deploy插件当在deploy时忽略些model-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,19 @@
package com.data.test;
import com.muyu.common.security.annotation.EnableCustomConfig;
import com.muyu.common.security.annotation.EnableMyFeignClients;
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
@SpringBootApplication
@EnableCustomConfig
@EnableCustomSwagger2
@EnableMyFeignClients
@EnableAsync
public class DataTestApplication {
public static void main(String[] args) {
SpringApplication.run(DataTestApplication.class, args);
}
}

View File

@ -0,0 +1,56 @@
package com.data.test.common;
import com.data.test.server.TestService;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.controller.BaseController;
import lombok.extern.log4j.Log4j2;
import muyu.data.test.common.model.DataModel;
import muyu.data.test.common.req.TestDataModelReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.sql.SQLException;
import java.util.List;
@Log4j2
@RestController
@RequestMapping("/extract")
public class TestController extends BaseController {
@Autowired
private TestService service;
/**
*
*
* @param id
* @return
*/
@GetMapping("getRabdomData")
public Result<List<DataModel>> getRabdomData(Long id, String tableName, Integer ruleLevel) throws SQLException {
return success(service.getRabdomData(id, tableName, ruleLevel));
}
/**
*
*
* @param id
* @param tableName
* @param ruleLevel
* @return
* @throws Exception
*/
@GetMapping("getColumn")
public Result<List<List<DataModel>>> getColumn(Long id, String tableName, Integer ruleLevel) throws Exception {
return success(service.getColumn(id, tableName, ruleLevel));
}
@PostMapping("setColumn")
public Result setColumn(@RequestBody TestDataModelReq testDataModelReq) {
return success(service.setColumn(testDataModelReq));
}
@PostMapping("editionInitialize")
public void editionInitialize() {
service.editionInitialize();
}
}

View File

@ -0,0 +1,7 @@
package com.data.test.mapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface TestMapper {
}

View File

@ -0,0 +1,30 @@
package com.data.test.mq;
import com.data.test.common.TestController;
import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
@Log4j2
public class Consumer {
//队列名称
public static final String QueueName = "edition";
@Autowired
private TestController testController;
/**
*
*/
@RabbitListener(queuesToDeclare = {@Queue("edition")})
public void testEdition(Integer id) {
if (id > 0) {
testController.editionInitialize();
log.info("初始化");
} else {
log.info("等待");
}
}
}

View File

@ -0,0 +1,17 @@
package com.data.test.server;
import muyu.data.test.common.model.DataModel;
import muyu.data.test.common.req.TestDataModelReq;
import java.sql.SQLException;
import java.util.List;
public interface TestService {
List<DataModel> getRabdomData(Long id, String tableName, Integer ruleLevel) throws SQLException;
List<List<DataModel>> getColumn(Long id, String tableName, Integer ruleLevel);
Object setColumn(TestDataModelReq testDataModelReq);
void editionInitialize();
}

View File

@ -0,0 +1,40 @@
package com.data.test.server.impl;
import com.data.test.server.TestService;
import muyu.data.test.clinet.config.AccessConfig;
import muyu.data.test.clinet.config.DataEditionConfig;
import muyu.data.test.common.model.DataModel;
import muyu.data.test.common.req.TestDataModelReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.sql.SQLException;
import java.util.List;
@Service
public class TestServiceImpl implements TestService {
@Autowired
private AccessConfig accessConfig;
@Autowired
private DataEditionConfig dataEditionConfig;
@Override
public List<DataModel> getRabdomData(Long id, String tableName, Integer ruleLevel) throws SQLException {
return accessConfig.getRabdomData(id, tableName, ruleLevel);
}
@Override
public List<List<DataModel>> getColumn(Long id, String tableName, Integer ruleLevel) {
return accessConfig.getColumn(id, tableName, ruleLevel);
}
@Override
public Object setColumn(TestDataModelReq testDataModelReq) {
return dataEditionConfig.setColumn(testDataModelReq);
}
@Override
public void editionInitialize() {
dataEditionConfig.editionInitialize();
}
}

View File

@ -0,0 +1,33 @@
# Tomcat
server:
port: 9509
# Spring
spring:
rabbitmq:
host: 129.211.23.219
port: 5672
username: guest
password: guest
application:
# 应用名称
name: muyu-test
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 129.211.23.219:8848
config:
# 配置中心地址
server-addr: 129.211.23.219:8848
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
logging:
level:
com.muyu.edition.mapper: DEBUG

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/muyu-visual-monitor"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.muyu" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<root level="info">
<appender-ref ref="console"/>
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
</configuration>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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.muyu</groupId>
<artifactId>muyu</artifactId>
<version>3.6.3</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>muyu-data-test</artifactId>
<packaging>pom</packaging>
<modules>
<module>muyu-data-test-common</module>
<module>muyu-data-test-client</module>
<module>muyu-data-test-server</module>
</modules>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@ -13,7 +13,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@EnableCustomSwagger2
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class MuYuFileApplication {
public static void main (String[] args) {
public static void main(String[] args) {
SpringApplication.run(MuYuFileApplication.class, args);
}
}

View File

@ -33,40 +33,40 @@ public class MinioConfig {
*/
private String bucketName;
public String getUrl () {
public String getUrl() {
return url;
}
public void setUrl (String url) {
public void setUrl(String url) {
this.url = url;
}
public String getAccessKey () {
public String getAccessKey() {
return accessKey;
}
public void setAccessKey (String accessKey) {
public void setAccessKey(String accessKey) {
this.accessKey = accessKey;
}
public String getSecretKey () {
public String getSecretKey() {
return secretKey;
}
public void setSecretKey (String secretKey) {
public void setSecretKey(String secretKey) {
this.secretKey = secretKey;
}
public String getBucketName () {
public String getBucketName() {
return bucketName;
}
public void setBucketName (String bucketName) {
public void setBucketName(String bucketName) {
this.bucketName = bucketName;
}
@Bean
public MinioClient getMinioClient () {
public MinioClient getMinioClient() {
return MinioClient.builder().endpoint(url).credentials(accessKey, secretKey).build();
}
}

View File

@ -27,7 +27,7 @@ public class ResourcesConfig implements WebMvcConfigurer {
private String localFilePath;
@Override
public void addResourceHandlers (ResourceHandlerRegistry registry) {
public void addResourceHandlers(ResourceHandlerRegistry registry) {
/** 本地文件上传路径 */
registry.addResourceHandler(localFilePrefix + "/**")
.addResourceLocations("file:" + localFilePath + File.separator);
@ -37,7 +37,7 @@ public class ResourcesConfig implements WebMvcConfigurer {
*
*/
@Override
public void addCorsMappings (CorsRegistry registry) {
public void addCorsMappings(CorsRegistry registry) {
// 设置允许跨域的路由
registry.addMapping(localFilePrefix + "/**")
// 设置允许跨域请求的域名

View File

@ -2,8 +2,8 @@ package com.muyu.file.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.file.FileUtils;
import com.muyu.file.service.ISysFileService;
import com.muyu.common.system.domain.SysFile;
import com.muyu.file.service.ISysFileService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -27,7 +27,7 @@ public class SysFileController {
*
*/
@PostMapping("upload")
public Result<SysFile> upload (MultipartFile file) {
public Result<SysFile> upload(MultipartFile file) {
try {
// 上传并返回访问地址
String url = sysFileService.uploadFile(file);

View File

@ -31,13 +31,11 @@ public class FastDfsSysFileServiceImpl implements ISysFileService {
* FastDfs
*
* @param file
*
* @return 访
*
* @throws Exception
*/
@Override
public String uploadFile (MultipartFile file) throws Exception {
public String uploadFile(MultipartFile file) throws Exception {
InputStream inputStream = file.getInputStream();
StorePath storePath = storageClient.uploadFile(inputStream, file.getSize(),
FileTypeUtils.getExtension(file), null);

View File

@ -12,10 +12,8 @@ public interface ISysFileService {
*
*
* @param file
*
* @return 访
*
* @throws Exception
*/
public String uploadFile (MultipartFile file) throws Exception;
public String uploadFile(MultipartFile file) throws Exception;
}

View File

@ -36,13 +36,11 @@ public class LocalSysFileServiceImpl implements ISysFileService {
*
*
* @param file
*
* @return 访
*
* @throws Exception
*/
@Override
public String uploadFile (MultipartFile file) throws Exception {
public String uploadFile(MultipartFile file) throws Exception {
String name = FileUploadUtils.upload(localFilePath, file);
String url = domain + localFilePrefix + name;
return url;

View File

@ -28,13 +28,11 @@ public class MinioSysFileServiceImpl implements ISysFileService {
* Minio
*
* @param file
*
* @return 访
*
* @throws Exception
*/
@Override
public String uploadFile (MultipartFile file) throws Exception {
public String uploadFile(MultipartFile file) throws Exception {
String fileName = FileUploadUtils.extractFilename(file);
InputStream inputStream = file.getInputStream();
PutObjectArgs args = PutObjectArgs.builder()

View File

@ -38,12 +38,10 @@ public class FileUploadUtils {
*
* @param baseDir
* @param file
*
* @return
*
* @throws IOException
*/
public static final String upload (String baseDir, MultipartFile file) throws IOException {
public static final String upload(String baseDir, MultipartFile file) throws IOException {
try {
return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
} catch (FileException fe) {
@ -59,15 +57,13 @@ public class FileUploadUtils {
* @param baseDir
* @param file
* @param allowedExtension
*
* @return
*
* @throws FileSizeLimitExceededException
* @throws FileNameLengthLimitExceededException
* @throws IOException
* @throws InvalidExtensionException
*/
public static final String upload (String baseDir, MultipartFile file, String[] allowedExtension)
public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension)
throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
InvalidExtensionException {
int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length();
@ -87,12 +83,12 @@ public class FileUploadUtils {
/**
*
*/
public static final String extractFilename (MultipartFile file) {
public static final String extractFilename(MultipartFile file) {
return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), FileTypeUtils.getExtension(file));
}
private static final File getAbsoluteFile (String uploadDir, String fileName) throws IOException {
private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException {
File desc = new File(uploadDir + File.separator + fileName);
if (!desc.exists()) {
@ -103,7 +99,7 @@ public class FileUploadUtils {
return desc.isAbsolute() ? desc : desc.getAbsoluteFile();
}
private static final String getPathFileName (String fileName) throws IOException {
private static final String getPathFileName(String fileName) throws IOException {
String pathFileName = "/" + fileName;
return pathFileName;
}
@ -112,11 +108,10 @@ public class FileUploadUtils {
*
*
* @param file
*
* @throws FileSizeLimitExceededException
* @throws InvalidExtensionException
*/
public static final void assertAllowed (MultipartFile file, String[] allowedExtension)
public static final void assertAllowed(MultipartFile file, String[] allowedExtension)
throws FileSizeLimitExceededException, InvalidExtensionException {
long size = file.getSize();
if (size > DEFAULT_MAX_SIZE) {
@ -149,10 +144,9 @@ public class FileUploadUtils {
*
* @param extension
* @param allowedExtension
*
* @return true/false
*/
public static final boolean isAllowedExtension (String extension, String[] allowedExtension) {
public static final boolean isAllowedExtension(String extension, String[] allowedExtension) {
for (String str : allowedExtension) {
if (str.equalsIgnoreCase(extension)) {
return true;

View File

@ -17,7 +17,7 @@
<dependencies>
<!-- SpringCloud Alibaba Nacos -->
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>

View File

@ -16,7 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableMyFeignClients
@SpringBootApplication
public class MuYuGenApplication {
public static void main (String[] args) {
public static void main(String[] args) {
SpringApplication.run(MuYuGenApplication.class, args);
}
}

View File

@ -31,35 +31,35 @@ public class GenConfig {
*/
public static String tablePrefix;
public static String getAuthor () {
public static String getAuthor() {
return author;
}
public void setAuthor (String author) {
public void setAuthor(String author) {
GenConfig.author = author;
}
public static String getPackageName () {
public static String getPackageName() {
return packageName;
}
public void setPackageName (String packageName) {
public void setPackageName(String packageName) {
GenConfig.packageName = packageName;
}
public static boolean getAutoRemovePre () {
public static boolean getAutoRemovePre() {
return autoRemovePre;
}
public void setAutoRemovePre (boolean autoRemovePre) {
public void setAutoRemovePre(boolean autoRemovePre) {
GenConfig.autoRemovePre = autoRemovePre;
}
public static String getTablePrefix () {
public static String getTablePrefix() {
return tablePrefix;
}
public void setTablePrefix (String tablePrefix) {
public void setTablePrefix(String tablePrefix) {
GenConfig.tablePrefix = tablePrefix;
}
}

View File

@ -1,8 +1,8 @@
package com.muyu.gen.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.text.Convert;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
@ -41,7 +41,7 @@ public class GenController extends BaseController {
*/
@RequiresPermissions("tool:gen:list")
@GetMapping("/list")
public Result<TableDataInfo<GenTable>> genList (GenTable genTable) {
public Result<TableDataInfo<GenTable>> genList(GenTable genTable) {
startPage();
List<GenTable> list = genTableService.selectGenTableList(genTable);
return getDataTable(list);
@ -52,7 +52,7 @@ public class GenController extends BaseController {
*/
@RequiresPermissions("tool:gen:query")
@GetMapping(value = "/{tableId}")
public Result getInfo (@PathVariable Long tableId) {
public Result getInfo(@PathVariable Long tableId) {
GenTable table = genTableService.selectGenTableById(tableId);
List<GenTable> tables = genTableService.selectGenTableAll();
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
@ -68,7 +68,7 @@ public class GenController extends BaseController {
*/
@RequiresPermissions("tool:gen:list")
@GetMapping("/db/list")
public Result<TableDataInfo<GenTable>> dataList (GenTable genTable) {
public Result<TableDataInfo<GenTable>> dataList(GenTable genTable) {
startPage();
List<GenTable> list = genTableService.selectDbTableList(genTable);
return getDataTable(list);
@ -78,7 +78,7 @@ public class GenController extends BaseController {
*
*/
@GetMapping(value = "/column/{tableId}")
public Result<TableDataInfo<GenTableColumn>> columnList (Long tableId) {
public Result<TableDataInfo<GenTableColumn>> columnList(Long tableId) {
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
return Result.success(
TableDataInfo.<GenTableColumn>builder()
@ -94,7 +94,7 @@ public class GenController extends BaseController {
@RequiresPermissions("tool:gen:import")
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
@PostMapping("/importTable")
public Result importTableSave (String tables) {
public Result importTableSave(String tables) {
String[] tableNames = Convert.toStrArray(tables);
// 查询表信息
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
@ -108,7 +108,7 @@ public class GenController extends BaseController {
@RequiresPermissions("tool:gen:edit")
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
@PutMapping
public Result editSave (@Validated @RequestBody GenTable genTable) {
public Result editSave(@Validated @RequestBody GenTable genTable) {
genTableService.validateEdit(genTable);
genTableService.updateGenTable(genTable);
return success();
@ -120,7 +120,7 @@ public class GenController extends BaseController {
@RequiresPermissions("tool:gen:remove")
@Log(title = "代码生成", businessType = BusinessType.DELETE)
@DeleteMapping("/{tableIds}")
public Result remove (@PathVariable Long[] tableIds) {
public Result remove(@PathVariable Long[] tableIds) {
genTableService.deleteGenTableByIds(tableIds);
return success();
}
@ -130,7 +130,7 @@ public class GenController extends BaseController {
*/
@RequiresPermissions("tool:gen:preview")
@GetMapping("/preview/{tableId}")
public Result preview (@PathVariable("tableId") Long tableId) throws IOException {
public Result preview(@PathVariable("tableId") Long tableId) throws IOException {
Map<String, String> dataMap = genTableService.previewCode(tableId);
return success(dataMap);
}
@ -141,7 +141,7 @@ public class GenController extends BaseController {
@RequiresPermissions("tool:gen:code")
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
@GetMapping("/download/{tableName}")
public void download (HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException {
public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException {
byte[] data = genTableService.downloadCode(tableName);
genCode(response, data);
}
@ -152,7 +152,7 @@ public class GenController extends BaseController {
@RequiresPermissions("tool:gen:code")
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
@GetMapping("/genCode/{tableName}")
public Result genCode (@PathVariable("tableName") String tableName) {
public Result genCode(@PathVariable("tableName") String tableName) {
genTableService.generatorCode(tableName);
return success();
}
@ -163,7 +163,7 @@ public class GenController extends BaseController {
@RequiresPermissions("tool:gen:edit")
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
@GetMapping("/synchDb/{tableName}")
public Result synchDb (@PathVariable("tableName") String tableName) {
public Result synchDb(@PathVariable("tableName") String tableName) {
genTableService.synchDb(tableName);
return success();
}
@ -174,7 +174,7 @@ public class GenController extends BaseController {
@RequiresPermissions("tool:gen:code")
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
@GetMapping("/batchGenCode")
public void batchGenCode (HttpServletResponse response, String tables) throws IOException {
public void batchGenCode(HttpServletResponse response, String tables) throws IOException {
String[] tableNames = Convert.toStrArray(tables);
byte[] data = genTableService.downloadCode(tableNames);
genCode(response, data);
@ -183,7 +183,7 @@ public class GenController extends BaseController {
/**
* zip
*/
private void genCode (HttpServletResponse response, byte[] data) throws IOException {
private void genCode(HttpServletResponse response, byte[] data) throws IOException {
response.reset();
response.setHeader("Content-Disposition", "attachment; filename=\"muyu.zip\"");
response.addHeader("Content-Length", String.valueOf(data.length));

View File

@ -15,8 +15,6 @@ import javax.validation.constraints.NotBlank;
import java.util.List;
/**
* gen_table
*
@ -154,19 +152,19 @@ public class GenTable extends BaseEntity {
*/
private String parentMenuName;
public static boolean isSub (String tplCategory) {
public static boolean isSub(String tplCategory) {
return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory);
}
public static boolean isTree (String tplCategory) {
public static boolean isTree(String tplCategory) {
return tplCategory != null && StringUtils.equals(GenConstants.TPL_TREE, tplCategory);
}
public static boolean isCrud (String tplCategory) {
public static boolean isCrud(String tplCategory) {
return tplCategory != null && StringUtils.equals(GenConstants.TPL_CRUD, tplCategory);
}
public static boolean isSuperColumn (String tplCategory, String javaField) {
public static boolean isSuperColumn(String tplCategory, String javaField) {
if (isTree(tplCategory)) {
return StringUtils.equalsAnyIgnoreCase(javaField,
ArrayUtils.addAll(GenConstants.TREE_ENTITY, GenConstants.BASE_ENTITY));
@ -174,203 +172,203 @@ public class GenTable extends BaseEntity {
return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY);
}
public Long getTableId () {
public Long getTableId() {
return tableId;
}
public void setTableId (Long tableId) {
public void setTableId(Long tableId) {
this.tableId = tableId;
}
public String getTableName () {
public String getTableName() {
return tableName;
}
public void setTableName (String tableName) {
public void setTableName(String tableName) {
this.tableName = tableName;
}
public String getTableComment () {
public String getTableComment() {
return tableComment;
}
public void setTableComment (String tableComment) {
public void setTableComment(String tableComment) {
this.tableComment = tableComment;
}
public String getSubTableName () {
public String getSubTableName() {
return subTableName;
}
public void setSubTableName (String subTableName) {
public void setSubTableName(String subTableName) {
this.subTableName = subTableName;
}
public String getSubTableFkName () {
public String getSubTableFkName() {
return subTableFkName;
}
public void setSubTableFkName (String subTableFkName) {
public void setSubTableFkName(String subTableFkName) {
this.subTableFkName = subTableFkName;
}
public String getClassName () {
public String getClassName() {
return className;
}
public void setClassName (String className) {
public void setClassName(String className) {
this.className = className;
}
public String getTplCategory () {
public String getTplCategory() {
return tplCategory;
}
public void setTplCategory (String tplCategory) {
public void setTplCategory(String tplCategory) {
this.tplCategory = tplCategory;
}
public String getPackageName () {
public String getPackageName() {
return packageName;
}
public void setPackageName (String packageName) {
public void setPackageName(String packageName) {
this.packageName = packageName;
}
public String getModuleName () {
public String getModuleName() {
return moduleName;
}
public void setModuleName (String moduleName) {
public void setModuleName(String moduleName) {
this.moduleName = moduleName;
}
public String getBusinessName () {
public String getBusinessName() {
return businessName;
}
public void setBusinessName (String businessName) {
public void setBusinessName(String businessName) {
this.businessName = businessName;
}
public String getFunctionName () {
public String getFunctionName() {
return functionName;
}
public void setFunctionName (String functionName) {
public void setFunctionName(String functionName) {
this.functionName = functionName;
}
public String getFunctionAuthor () {
public String getFunctionAuthor() {
return functionAuthor;
}
public void setFunctionAuthor (String functionAuthor) {
public void setFunctionAuthor(String functionAuthor) {
this.functionAuthor = functionAuthor;
}
public String getGenType () {
public String getGenType() {
return genType;
}
public void setGenType (String genType) {
public void setGenType(String genType) {
this.genType = genType;
}
public String getGenPath () {
public String getGenPath() {
return genPath;
}
public void setGenPath (String genPath) {
public void setGenPath(String genPath) {
this.genPath = genPath;
}
public GenTableColumn getPkColumn () {
public GenTableColumn getPkColumn() {
return pkColumn;
}
public void setPkColumn (GenTableColumn pkColumn) {
public void setPkColumn(GenTableColumn pkColumn) {
this.pkColumn = pkColumn;
}
public GenTable getSubTable () {
public GenTable getSubTable() {
return subTable;
}
public void setSubTable (GenTable subTable) {
public void setSubTable(GenTable subTable) {
this.subTable = subTable;
}
public List<GenTableColumn> getColumns () {
public List<GenTableColumn> getColumns() {
return columns;
}
public void setColumns (List<GenTableColumn> columns) {
public void setColumns(List<GenTableColumn> columns) {
this.columns = columns;
}
public String getOptions () {
public String getOptions() {
return options;
}
public void setOptions (String options) {
public void setOptions(String options) {
this.options = options;
}
public String getTreeCode () {
public String getTreeCode() {
return treeCode;
}
public void setTreeCode (String treeCode) {
public void setTreeCode(String treeCode) {
this.treeCode = treeCode;
}
public String getTreeParentCode () {
public String getTreeParentCode() {
return treeParentCode;
}
public void setTreeParentCode (String treeParentCode) {
public void setTreeParentCode(String treeParentCode) {
this.treeParentCode = treeParentCode;
}
public String getTreeName () {
public String getTreeName() {
return treeName;
}
public void setTreeName (String treeName) {
public void setTreeName(String treeName) {
this.treeName = treeName;
}
public String getParentMenuId () {
public String getParentMenuId() {
return parentMenuId;
}
public void setParentMenuId (String parentMenuId) {
public void setParentMenuId(String parentMenuId) {
this.parentMenuId = parentMenuId;
}
public String getParentMenuName () {
public String getParentMenuName() {
return parentMenuName;
}
public void setParentMenuName (String parentMenuName) {
public void setParentMenuName(String parentMenuName) {
this.parentMenuName = parentMenuName;
}
public boolean isSub () {
public boolean isSub() {
return isSub(this.tplCategory);
}
public boolean isTree () {
public boolean isTree() {
return isTree(this.tplCategory);
}
public boolean isCrud () {
public boolean isCrud() {
return isCrud(this.tplCategory);
}
public boolean isSuperColumn (String javaField) {
public boolean isSuperColumn(String javaField) {
return isSuperColumn(this.tplCategory, javaField);
}
}

View File

@ -114,7 +114,7 @@ public class GenTableColumn extends BaseEntity {
*/
private Integer sort;
public static boolean isSuperColumn (String javaField) {
public static boolean isSuperColumn(String javaField) {
return StringUtils.equalsAnyIgnoreCase(javaField,
// BaseEntity
"createBy", "createTime", "updateBy", "updateTime", "remark",
@ -122,224 +122,224 @@ public class GenTableColumn extends BaseEntity {
"parentName", "parentId", "orderNum", "ancestors");
}
public static boolean isUsableColumn (String javaField) {
public static boolean isUsableColumn(String javaField) {
// isSuperColumn()中的名单用于避免生成多余Domain属性若某些属性在生成页面时需要用到不能忽略则放在此处白名单
return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark");
}
public Long getColumnId () {
public Long getColumnId() {
return columnId;
}
public void setColumnId (Long columnId) {
public void setColumnId(Long columnId) {
this.columnId = columnId;
}
public Long getTableId () {
public Long getTableId() {
return tableId;
}
public void setTableId (Long tableId) {
public void setTableId(Long tableId) {
this.tableId = tableId;
}
public String getColumnName () {
public String getColumnName() {
return columnName;
}
public void setColumnName (String columnName) {
public void setColumnName(String columnName) {
this.columnName = columnName;
}
public String getColumnComment () {
public String getColumnComment() {
return columnComment;
}
public void setColumnComment (String columnComment) {
public void setColumnComment(String columnComment) {
this.columnComment = columnComment;
}
public String getColumnType () {
public String getColumnType() {
return columnType;
}
public void setColumnType (String columnType) {
public void setColumnType(String columnType) {
this.columnType = columnType;
}
public String getJavaType () {
public String getJavaType() {
return javaType;
}
public void setJavaType (String javaType) {
public void setJavaType(String javaType) {
this.javaType = javaType;
}
public String getJavaField () {
public String getJavaField() {
return javaField;
}
public void setJavaField (String javaField) {
public void setJavaField(String javaField) {
this.javaField = javaField;
}
public String getCapJavaField () {
public String getCapJavaField() {
return StringUtils.capitalize(javaField);
}
public String getIsPk () {
public String getIsPk() {
return isPk;
}
public void setIsPk (String isPk) {
public void setIsPk(String isPk) {
this.isPk = isPk;
}
public boolean isPk () {
public boolean isPk() {
return isPk(this.isPk);
}
public boolean isPk (String isPk) {
public boolean isPk(String isPk) {
return isPk != null && StringUtils.equals("1", isPk);
}
public String getIsIncrement () {
public String getIsIncrement() {
return isIncrement;
}
public void setIsIncrement (String isIncrement) {
public void setIsIncrement(String isIncrement) {
this.isIncrement = isIncrement;
}
public boolean isIncrement () {
public boolean isIncrement() {
return isIncrement(this.isIncrement);
}
public boolean isIncrement (String isIncrement) {
public boolean isIncrement(String isIncrement) {
return isIncrement != null && StringUtils.equals("1", isIncrement);
}
public String getIsRequired () {
public String getIsRequired() {
return isRequired;
}
public void setIsRequired (String isRequired) {
public void setIsRequired(String isRequired) {
this.isRequired = isRequired;
}
public boolean isRequired () {
public boolean isRequired() {
return isRequired(this.isRequired);
}
public boolean isRequired (String isRequired) {
public boolean isRequired(String isRequired) {
return isRequired != null && StringUtils.equals("1", isRequired);
}
public String getIsInsert () {
public String getIsInsert() {
return isInsert;
}
public void setIsInsert (String isInsert) {
public void setIsInsert(String isInsert) {
this.isInsert = isInsert;
}
public boolean isInsert () {
public boolean isInsert() {
return isInsert(this.isInsert);
}
public boolean isInsert (String isInsert) {
public boolean isInsert(String isInsert) {
return isInsert != null && StringUtils.equals("1", isInsert);
}
public String getIsEdit () {
public String getIsEdit() {
return isEdit;
}
public void setIsEdit (String isEdit) {
public void setIsEdit(String isEdit) {
this.isEdit = isEdit;
}
public boolean isEdit () {
public boolean isEdit() {
return isInsert(this.isEdit);
}
public boolean isEdit (String isEdit) {
public boolean isEdit(String isEdit) {
return isEdit != null && StringUtils.equals("1", isEdit);
}
public String getIsList () {
public String getIsList() {
return isList;
}
public void setIsList (String isList) {
public void setIsList(String isList) {
this.isList = isList;
}
public boolean isList () {
public boolean isList() {
return isList(this.isList);
}
public boolean isList (String isList) {
public boolean isList(String isList) {
return isList != null && StringUtils.equals("1", isList);
}
public String getIsQuery () {
public String getIsQuery() {
return isQuery;
}
public void setIsQuery (String isQuery) {
public void setIsQuery(String isQuery) {
this.isQuery = isQuery;
}
public boolean isQuery () {
public boolean isQuery() {
return isQuery(this.isQuery);
}
public boolean isQuery (String isQuery) {
public boolean isQuery(String isQuery) {
return isQuery != null && StringUtils.equals("1", isQuery);
}
public String getQueryType () {
public String getQueryType() {
return queryType;
}
public void setQueryType (String queryType) {
public void setQueryType(String queryType) {
this.queryType = queryType;
}
public String getHtmlType () {
public String getHtmlType() {
return htmlType;
}
public void setHtmlType (String htmlType) {
public void setHtmlType(String htmlType) {
this.htmlType = htmlType;
}
public String getDictType () {
public String getDictType() {
return dictType;
}
public void setDictType (String dictType) {
public void setDictType(String dictType) {
this.dictType = dictType;
}
public Integer getSort () {
public Integer getSort() {
return sort;
}
public void setSort (Integer sort) {
public void setSort(Integer sort) {
this.sort = sort;
}
public boolean isSuperColumn () {
public boolean isSuperColumn() {
return isSuperColumn(this.javaField);
}
public boolean isUsableColumn () {
public boolean isUsableColumn() {
return isUsableColumn(javaField);
}
public String readConverterExp () {
public String readConverterExp() {
String remarks = StringUtils.substringBetween(this.columnComment, "", "");
StringBuffer sb = new StringBuffer();
if (StringUtils.isNotEmpty(remarks)) {

View File

@ -15,53 +15,47 @@ public interface GenTableColumnMapper extends BaseMapper<GenTableColumn> {
*
*
* @param tableName
*
* @return
*/
List<GenTableColumn> selectDbTableColumnsByName (String tableName);
List<GenTableColumn> selectDbTableColumnsByName(String tableName);
/**
*
*
* @param tableId
*
* @return
*/
List<GenTableColumn> selectGenTableColumnListByTableId (Long tableId);
List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
/**
*
*
* @param genTableColumn
*
* @return
*/
int insertGenTableColumn (GenTableColumn genTableColumn);
int insertGenTableColumn(GenTableColumn genTableColumn);
/**
*
*
* @param genTableColumn
*
* @return
*/
int updateGenTableColumn (GenTableColumn genTableColumn);
int updateGenTableColumn(GenTableColumn genTableColumn);
/**
*
*
* @param genTableColumns
*
* @return
*/
int deleteGenTableColumns (List<GenTableColumn> genTableColumns);
int deleteGenTableColumns(List<GenTableColumn> genTableColumns);
/**
*
*
* @param ids ID
*
* @return
*/
int deleteGenTableColumnByIds (Long[] ids);
int deleteGenTableColumnByIds(Long[] ids);
}

View File

@ -15,78 +15,70 @@ public interface GenTableMapper extends BaseMapper<GenTable> {
*
*
* @param genTable
*
* @return
*/
List<GenTable> selectGenTableList (GenTable genTable);
List<GenTable> selectGenTableList(GenTable genTable);
/**
*
*
* @param genTable
*
* @return
*/
List<GenTable> selectDbTableList (GenTable genTable);
List<GenTable> selectDbTableList(GenTable genTable);
/**
*
*
* @param tableNames
*
* @return
*/
List<GenTable> selectDbTableListByNames (String[] tableNames);
List<GenTable> selectDbTableListByNames(String[] tableNames);
/**
*
*
* @return
*/
List<GenTable> selectGenTableAll ();
List<GenTable> selectGenTableAll();
/**
* ID
*
* @param id ID
*
* @return
*/
GenTable selectGenTableById (Long id);
GenTable selectGenTableById(Long id);
/**
*
*
* @param tableName
*
* @return
*/
GenTable selectGenTableByName (String tableName);
GenTable selectGenTableByName(String tableName);
/**
*
*
* @param genTable
*
* @return
*/
int insertGenTable (GenTable genTable);
int insertGenTable(GenTable genTable);
/**
*
*
* @param genTable
*
* @return
*/
int updateGenTable (GenTable genTable);
int updateGenTable(GenTable genTable);
/**
*
*
* @param ids ID
*
* @return
*/
int deleteGenTableByIds (Long[] ids);
int deleteGenTableByIds(Long[] ids);
}

View File

@ -22,11 +22,10 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService {
*
*
* @param tableId
*
* @return
*/
@Override
public List<GenTableColumn> selectGenTableColumnListByTableId (Long tableId) {
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId) {
return genTableColumnMapper.selectGenTableColumnListByTableId(tableId);
}
@ -34,11 +33,10 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService {
*
*
* @param genTableColumn
*
* @return
*/
@Override
public int insertGenTableColumn (GenTableColumn genTableColumn) {
public int insertGenTableColumn(GenTableColumn genTableColumn) {
return genTableColumnMapper.insertGenTableColumn(genTableColumn);
}
@ -46,11 +44,10 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService {
*
*
* @param genTableColumn
*
* @return
*/
@Override
public int updateGenTableColumn (GenTableColumn genTableColumn) {
public int updateGenTableColumn(GenTableColumn genTableColumn) {
return genTableColumnMapper.updateGenTableColumn(genTableColumn);
}
@ -58,11 +55,10 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService {
*
*
* @param ids ID
*
* @return
*/
@Override
public int deleteGenTableColumnByIds (String ids) {
public int deleteGenTableColumnByIds(String ids) {
return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids));
}
}

View File

@ -58,10 +58,9 @@ public class GenTableServiceImpl implements IGenTableService {
*
* @param table
* @param template
*
* @return
*/
public static String getGenPath (GenTable table, String template) {
public static String getGenPath(GenTable table, String template) {
String genPath = table.getGenPath();
if (StringUtils.equals(genPath, "/")) {
return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table);
@ -73,11 +72,10 @@ public class GenTableServiceImpl implements IGenTableService {
*
*
* @param id ID
*
* @return
*/
@Override
public GenTable selectGenTableById (Long id) {
public GenTable selectGenTableById(Long id) {
GenTable genTable = genTableMapper.selectGenTableById(id);
setTableFromOptions(genTable);
return genTable;
@ -87,11 +85,10 @@ public class GenTableServiceImpl implements IGenTableService {
*
*
* @param genTable
*
* @return
*/
@Override
public List<GenTable> selectGenTableList (GenTable genTable) {
public List<GenTable> selectGenTableList(GenTable genTable) {
return genTableMapper.selectGenTableList(genTable);
}
@ -99,11 +96,10 @@ public class GenTableServiceImpl implements IGenTableService {
*
*
* @param genTable
*
* @return
*/
@Override
public List<GenTable> selectDbTableList (GenTable genTable) {
public List<GenTable> selectDbTableList(GenTable genTable) {
return genTableMapper.selectDbTableList(genTable);
}
@ -111,11 +107,10 @@ public class GenTableServiceImpl implements IGenTableService {
*
*
* @param tableNames
*
* @return
*/
@Override
public List<GenTable> selectDbTableListByNames (String[] tableNames) {
public List<GenTable> selectDbTableListByNames(String[] tableNames) {
return genTableMapper.selectDbTableListByNames(tableNames);
}
@ -125,7 +120,7 @@ public class GenTableServiceImpl implements IGenTableService {
* @return
*/
@Override
public List<GenTable> selectGenTableAll () {
public List<GenTable> selectGenTableAll() {
return genTableMapper.selectGenTableAll();
}
@ -133,12 +128,11 @@ public class GenTableServiceImpl implements IGenTableService {
*
*
* @param genTable
*
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void updateGenTable (GenTable genTable) {
public void updateGenTable(GenTable genTable) {
String options = JSON.toJSONString(genTable.getParams());
genTable.setOptions(options);
int row = genTableMapper.updateGenTable(genTable);
@ -153,12 +147,11 @@ public class GenTableServiceImpl implements IGenTableService {
*
*
* @param tableIds ID
*
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteGenTableByIds (Long[] tableIds) {
public void deleteGenTableByIds(Long[] tableIds) {
genTableMapper.deleteGenTableByIds(tableIds);
genTableColumnMapper.deleteGenTableColumnByIds(tableIds);
}
@ -170,7 +163,7 @@ public class GenTableServiceImpl implements IGenTableService {
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void importGenTable (List<GenTable> tableList) {
public void importGenTable(List<GenTable> tableList) {
String operName = SecurityUtils.getUsername();
try {
for (GenTable table : tableList) {
@ -195,11 +188,10 @@ public class GenTableServiceImpl implements IGenTableService {
*
*
* @param tableId
*
* @return
*/
@Override
public Map<String, String> previewCode (Long tableId) {
public Map<String, String> previewCode(Long tableId) {
Map<String, String> dataMap = new LinkedHashMap<>();
// 查询表信息
GenTable table = genTableMapper.selectGenTableById(tableId);
@ -227,11 +219,10 @@ public class GenTableServiceImpl implements IGenTableService {
*
*
* @param tableName
*
* @return
*/
@Override
public byte[] downloadCode (String tableName) {
public byte[] downloadCode(String tableName) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream);
generatorCode(tableName, zip);
@ -245,7 +236,7 @@ public class GenTableServiceImpl implements IGenTableService {
* @param tableName
*/
@Override
public void generatorCode (String tableName) {
public void generatorCode(String tableName) {
// 查询表信息
GenTable table = genTableMapper.selectGenTableByName(tableName);
// 设置主子表信息
@ -282,7 +273,7 @@ public class GenTableServiceImpl implements IGenTableService {
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void synchDb (String tableName) {
public void synchDb(String tableName) {
GenTable table = genTableMapper.selectGenTableByName(tableName);
List<GenTableColumn> tableColumns = table.getColumns();
Map<String, GenTableColumn> tableColumnMap = tableColumns.stream().collect(Collectors.toMap(GenTableColumn::getColumnName, Function.identity()));
@ -326,11 +317,10 @@ public class GenTableServiceImpl implements IGenTableService {
*
*
* @param tableNames
*
* @return
*/
@Override
public byte[] downloadCode (String[] tableNames) {
public byte[] downloadCode(String[] tableNames) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream);
for (String tableName : tableNames) {
@ -343,7 +333,7 @@ public class GenTableServiceImpl implements IGenTableService {
/**
*
*/
private void generatorCode (String tableName, ZipOutputStream zip) {
private void generatorCode(String tableName, ZipOutputStream zip) {
// 查询表信息
GenTable table = genTableMapper.selectGenTableByName(tableName);
// 设置主子表信息
@ -381,7 +371,7 @@ public class GenTableServiceImpl implements IGenTableService {
* @param genTable
*/
@Override
public void validateEdit (GenTable genTable) {
public void validateEdit(GenTable genTable) {
if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) {
String options = JSON.toJSONString(genTable.getParams());
JSONObject paramsObj = JSON.parseObject(options);
@ -406,7 +396,7 @@ public class GenTableServiceImpl implements IGenTableService {
*
* @param table
*/
public void setPkColumn (GenTable table) {
public void setPkColumn(GenTable table) {
for (GenTableColumn column : table.getColumns()) {
if (column.isPk()) {
table.setPkColumn(column);
@ -434,7 +424,7 @@ public class GenTableServiceImpl implements IGenTableService {
*
* @param table
*/
public void setSubTable (GenTable table) {
public void setSubTable(GenTable table) {
String subTableName = table.getSubTableName();
if (StringUtils.isNotEmpty(subTableName)) {
table.setSubTable(genTableMapper.selectGenTableByName(subTableName));
@ -446,7 +436,7 @@ public class GenTableServiceImpl implements IGenTableService {
*
* @param genTable
*/
public void setTableFromOptions (GenTable genTable) {
public void setTableFromOptions(GenTable genTable) {
JSONObject paramsObj = JSON.parseObject(genTable.getOptions());
if (StringUtils.isNotNull(paramsObj)) {
String treeCode = paramsObj.getString(GenConstants.TREE_CODE);

View File

@ -14,35 +14,31 @@ public interface IGenTableColumnService {
*
*
* @param tableId
*
* @return
*/
List<GenTableColumn> selectGenTableColumnListByTableId (Long tableId);
List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
/**
*
*
* @param genTableColumn
*
* @return
*/
int insertGenTableColumn (GenTableColumn genTableColumn);
int insertGenTableColumn(GenTableColumn genTableColumn);
/**
*
*
* @param genTableColumn
*
* @return
*/
int updateGenTableColumn (GenTableColumn genTableColumn);
int updateGenTableColumn(GenTableColumn genTableColumn);
/**
*
*
* @param ids ID
*
* @return
*/
int deleteGenTableColumnByIds (String ids);
int deleteGenTableColumnByIds(String ids);
}

View File

@ -15,117 +15,107 @@ public interface IGenTableService {
*
*
* @param genTable
*
* @return
*/
List<GenTable> selectGenTableList (GenTable genTable);
List<GenTable> selectGenTableList(GenTable genTable);
/**
*
*
* @param genTable
*
* @return
*/
List<GenTable> selectDbTableList (GenTable genTable);
List<GenTable> selectDbTableList(GenTable genTable);
/**
*
*
* @param tableNames
*
* @return
*/
List<GenTable> selectDbTableListByNames (String[] tableNames);
List<GenTable> selectDbTableListByNames(String[] tableNames);
/**
*
*
* @return
*/
List<GenTable> selectGenTableAll ();
List<GenTable> selectGenTableAll();
/**
*
*
* @param id ID
*
* @return
*/
GenTable selectGenTableById (Long id);
GenTable selectGenTableById(Long id);
/**
*
*
* @param genTable
*
* @return
*/
void updateGenTable (GenTable genTable);
void updateGenTable(GenTable genTable);
/**
*
*
* @param tableIds ID
*
* @return
*/
void deleteGenTableByIds (Long[] tableIds);
void deleteGenTableByIds(Long[] tableIds);
/**
*
*
* @param tableList
*/
void importGenTable (List<GenTable> tableList);
void importGenTable(List<GenTable> tableList);
/**
*
*
* @param tableId
*
* @return
*/
Map<String, String> previewCode (Long tableId);
Map<String, String> previewCode(Long tableId);
/**
*
*
* @param tableName
*
* @return
*/
byte[] downloadCode (String tableName);
byte[] downloadCode(String tableName);
/**
*
*
* @param tableName
*
* @return
*/
void generatorCode (String tableName);
void generatorCode(String tableName);
/**
*
*
* @param tableName
*/
void synchDb (String tableName);
void synchDb(String tableName);
/**
*
*
* @param tableNames
*
* @return
*/
byte[] downloadCode (String[] tableNames);
byte[] downloadCode(String[] tableNames);
/**
*
*
* @param genTable
*/
void validateEdit (GenTable genTable);
void validateEdit(GenTable genTable);
}

View File

@ -18,7 +18,7 @@ public class GenUtils {
/**
*
*/
public static void initTable (GenTable genTable, String operName) {
public static void initTable(GenTable genTable, String operName) {
genTable.setClassName(convertClassName(genTable.getTableName()));
genTable.setPackageName(GenConfig.getPackageName());
genTable.setModuleName(getModuleName(GenConfig.getPackageName()));
@ -31,7 +31,7 @@ public class GenUtils {
/**
*
*/
public static void initColumnField (GenTableColumn column, GenTable table) {
public static void initColumnField(GenTableColumn column, GenTable table) {
String dataType = getDbType(column.getColumnType());
String columnName = column.getColumnName();
column.setTableId(table.getTableId());
@ -116,10 +116,9 @@ public class GenUtils {
*
* @param arr
* @param targetValue
*
* @return
*/
public static boolean arraysContains (String[] arr, String targetValue) {
public static boolean arraysContains(String[] arr, String targetValue) {
return Arrays.asList(arr).contains(targetValue);
}
@ -127,10 +126,9 @@ public class GenUtils {
*
*
* @param packageName
*
* @return
*/
public static String getModuleName (String packageName) {
public static String getModuleName(String packageName) {
int lastIndex = packageName.lastIndexOf(".");
int nameLength = packageName.length();
return StringUtils.substring(packageName, lastIndex + 1, nameLength);
@ -140,10 +138,9 @@ public class GenUtils {
*
*
* @param tableName
*
* @return
*/
public static String getBusinessName (String tableName) {
public static String getBusinessName(String tableName) {
int lastIndex = tableName.lastIndexOf("_");
int nameLength = tableName.length();
return StringUtils.substring(tableName, lastIndex + 1, nameLength);
@ -153,10 +150,9 @@ public class GenUtils {
* Java
*
* @param tableName
*
* @return
*/
public static String convertClassName (String tableName) {
public static String convertClassName(String tableName) {
boolean autoRemovePre = GenConfig.getAutoRemovePre();
String tablePrefix = GenConfig.getTablePrefix();
if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) {
@ -171,10 +167,9 @@ public class GenUtils {
*
* @param replacementm
* @param searchList
*
* @return
*/
public static String replaceFirst (String replacementm, String[] searchList) {
public static String replaceFirst(String replacementm, String[] searchList) {
String text = replacementm;
for (String searchString : searchList) {
if (replacementm.startsWith(searchString)) {
@ -189,10 +184,9 @@ public class GenUtils {
*
*
* @param text
*
* @return
*/
public static String replaceText (String text) {
public static String replaceText(String text) {
return RegExUtils.replaceAll(text, "(?:表|若依)", "");
}
@ -200,10 +194,9 @@ public class GenUtils {
*
*
* @param columnType
*
* @return
*/
public static String getDbType (String columnType) {
public static String getDbType(String columnType) {
if (StringUtils.indexOf(columnType, "(") > 0) {
return StringUtils.substringBefore(columnType, "(");
} else {
@ -215,10 +208,9 @@ public class GenUtils {
*
*
* @param columnType
*
* @return
*/
public static Integer getColumnLength (String columnType) {
public static Integer getColumnLength(String columnType) {
if (StringUtils.indexOf(columnType, "(") > 0) {
String length = StringUtils.substringBetween(columnType, "(", ")");
return Integer.valueOf(length);

View File

@ -14,7 +14,7 @@ public class VelocityInitializer {
/**
* vm
*/
public static void initVelocity () {
public static void initVelocity() {
Properties p = new Properties();
try {
// 加载classpath目录下的vm文件

View File

@ -40,7 +40,7 @@ public class VelocityUtils {
*
* @return
*/
public static VelocityContext prepareContext (GenTable genTable) {
public static VelocityContext prepareContext(GenTable genTable) {
String moduleName = genTable.getModuleName();
String businessName = genTable.getBusinessName();
String packageName = genTable.getPackageName();
@ -76,14 +76,14 @@ public class VelocityUtils {
return velocityContext;
}
public static void setMenuVelocityContext (VelocityContext context, GenTable genTable) {
public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) {
String options = genTable.getOptions();
JSONObject paramsObj = JSON.parseObject(options);
String parentMenuId = getParentMenuId(paramsObj);
context.put("parentMenuId", parentMenuId);
}
public static void setTreeVelocityContext (VelocityContext context, GenTable genTable) {
public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) {
String options = genTable.getOptions();
JSONObject paramsObj = JSON.parseObject(options);
String treeCode = getTreecode(paramsObj);
@ -102,7 +102,7 @@ public class VelocityUtils {
}
}
public static void setSubVelocityContext (VelocityContext context, GenTable genTable) {
public static void setSubVelocityContext(VelocityContext context, GenTable genTable) {
GenTable subTable = genTable.getSubTable();
String subTableName = genTable.getSubTableName();
String subTableFkName = genTable.getSubTableFkName();
@ -124,7 +124,7 @@ public class VelocityUtils {
*
* @return
*/
public static List<String> getTemplateList (String tplCategory) {
public static List<String> getTemplateList(String tplCategory) {
List<String> templates = new ArrayList<String>();
templates.add("vm/java/domain.java.vm");
templates.add("vm/java/mapper.java.vm");
@ -148,7 +148,7 @@ public class VelocityUtils {
/**
*
*/
public static String getFileName (String template, GenTable genTable) {
public static String getFileName(String template, GenTable genTable) {
// 文件名称
String fileName = "";
// 包路径
@ -195,10 +195,9 @@ public class VelocityUtils {
*
*
* @param packageName
*
* @return
*/
public static String getPackagePrefix (String packageName) {
public static String getPackagePrefix(String packageName) {
int lastIndex = packageName.lastIndexOf(".");
return StringUtils.substring(packageName, 0, lastIndex);
}
@ -207,10 +206,9 @@ public class VelocityUtils {
*
*
* @param genTable
*
* @return
*/
public static HashSet<String> getImportList (GenTable genTable) {
public static HashSet<String> getImportList(GenTable genTable) {
List<GenTableColumn> columns = genTable.getColumns();
GenTable subGenTable = genTable.getSubTable();
HashSet<String> importList = new HashSet<String>();
@ -232,10 +230,9 @@ public class VelocityUtils {
*
*
* @param genTable
*
* @return
*/
public static String getDicts (GenTable genTable) {
public static String getDicts(GenTable genTable) {
List<GenTableColumn> columns = genTable.getColumns();
Set<String> dicts = new HashSet<String>();
addDicts(dicts, columns);
@ -252,7 +249,7 @@ public class VelocityUtils {
* @param dicts
* @param columns
*/
public static void addDicts (Set<String> dicts, List<GenTableColumn> columns) {
public static void addDicts(Set<String> dicts, List<GenTableColumn> columns) {
for (GenTableColumn column : columns) {
if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny(
column.getHtmlType(),
@ -267,10 +264,9 @@ public class VelocityUtils {
*
* @param moduleName
* @param businessName
*
* @return
*/
public static String getPermissionPrefix (String moduleName, String businessName) {
public static String getPermissionPrefix(String moduleName, String businessName) {
return StringUtils.format("{}:{}", moduleName, businessName);
}
@ -278,10 +274,9 @@ public class VelocityUtils {
* ID
*
* @param paramsObj
*
* @return ID
*/
public static String getParentMenuId (JSONObject paramsObj) {
public static String getParentMenuId(JSONObject paramsObj) {
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)
&& StringUtils.isNotEmpty(paramsObj.getString(GenConstants.PARENT_MENU_ID))) {
return paramsObj.getString(GenConstants.PARENT_MENU_ID);
@ -293,10 +288,9 @@ public class VelocityUtils {
*
*
* @param paramsObj
*
* @return
*/
public static String getTreecode (JSONObject paramsObj) {
public static String getTreecode(JSONObject paramsObj) {
if (paramsObj.containsKey(GenConstants.TREE_CODE)) {
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE));
}
@ -307,10 +301,9 @@ public class VelocityUtils {
*
*
* @param paramsObj
*
* @return
*/
public static String getTreeParentCode (JSONObject paramsObj) {
public static String getTreeParentCode(JSONObject paramsObj) {
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
}
@ -321,10 +314,9 @@ public class VelocityUtils {
*
*
* @param paramsObj
*
* @return
*/
public static String getTreeName (JSONObject paramsObj) {
public static String getTreeName(JSONObject paramsObj) {
if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
}
@ -335,10 +327,9 @@ public class VelocityUtils {
*
*
* @param genTable
*
* @return
*/
public static int getExpandColumn (GenTable genTable) {
public static int getExpandColumn(GenTable genTable) {
String options = genTable.getOptions();
JSONObject paramsObj = JSON.parseObject(options);
String treeName = paramsObj.getString(GenConstants.TREE_NAME);

View File

@ -1,31 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/muyu-gen" />
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<property name="log.path" value="logs/muyu-gen"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
@ -33,16 +33,16 @@
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
@ -50,25 +50,25 @@
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.muyu" level="info" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<logger name="com.muyu" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
<appender-ref ref="console"/>
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
</configuration>

View File

@ -55,7 +55,8 @@
from gen_table_column
</sql>
<select id="selectGenTableColumnListByTableId" parameterType="com.muyu.gen.domain.GenTableColumn" resultMap="GenTableColumnResult">
<select id="selectGenTableColumnListByTableId" parameterType="com.muyu.gen.domain.GenTableColumn"
resultMap="GenTableColumnResult">
<include refid="selectGenTableColumnVo"/>
where table_id = #{tableId}
order by sort
@ -63,11 +64,11 @@
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
select column_name,
(case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required,
(case when column_key = 'PRI' then '1' else '0' end) as is_pk,
ordinal_position as sort,
(case when (is_nullable = 'stream' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required,
(case when column_key = 'PRI' then '1' else '0' end) as is_pk,
ordinal_position as sort,
column_comment,
(case when extra = 'auto_increment' then '1' else '0' end) as is_increment,
(case when extra = 'auto_increment' then '1' else '0' end) as is_increment,
column_type
from information_schema.columns
where table_schema = (select database())
@ -75,7 +76,8 @@
order by ordinal_position
</select>
<insert id="insertGenTableColumn" parameterType="com.muyu.gen.domain.GenTableColumn" useGeneratedKeys="true" keyProperty="columnId">
<insert id="insertGenTableColumn" parameterType="com.muyu.gen.domain.GenTableColumn" useGeneratedKeys="true"
keyProperty="columnId">
insert into gen_table_column (
<if test="tableId != null and tableId != ''">table_id,</if>
<if test="columnName != null and columnName != ''">column_name,</if>

View File

@ -249,7 +249,8 @@
order by c.sort
</select>
<insert id="insertGenTable" parameterType="com.muyu.gen.domain.GenTable" useGeneratedKeys="true" keyProperty="tableId">
<insert id="insertGenTable" parameterType="com.muyu.gen.domain.GenTable" useGeneratedKeys="true"
keyProperty="tableId">
insert into gen_table (
<if test="tableName != null">table_name,</if>
<if test="tableComment != null and tableComment != ''">table_comment,</if>

View File

@ -3,6 +3,7 @@ package ${packageName}.controller;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -33,30 +34,27 @@ import com.muyu.common.core.web.page.TableDataInfo;
*/
@RestController
@RequestMapping("/${businessName}")
public class ${ClassName}Controller extends BaseController
{
public class ${ClassName}Controller extends BaseController {
@Autowired
private I${ClassName}Service ${className}Service;
/**
* 查询${functionName}列表
*/
@RequiresPermissions("${permissionPrefix}:list")
@GetMapping("/list")
#if($table.crud || $table.sub)
public Result<TableDataInfo> list(${ClassName} ${className})
{
/**
* 查询${functionName}列表
*/
@RequiresPermissions("${permissionPrefix}:list")
@GetMapping("/list")
#if($table.crud || $table.sub)
public Result<TableDataInfo> list(${ClassName} ${className}) {
startPage();
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
return getDataTable(list);
}
#elseif($table.tree)
public Result list(${ClassName} ${className})
{
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
return success(list);
}
#end
#elseif($table.tree)
public Result list(${ClassName} ${className}) {
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
return success(list);
}
#end
/**
* 导出${functionName}列表
@ -64,10 +62,9 @@ public class ${ClassName}Controller extends BaseController
@RequiresPermissions("${permissionPrefix}:export")
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ${ClassName} ${className})
{
public void export(HttpServletResponse response, ${ClassName} ${className}) {
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}. class);
util.exportExcel(response, list, "${functionName}数据");
}
@ -76,8 +73,7 @@ public class ${ClassName}Controller extends BaseController
*/
@RequiresPermissions("${permissionPrefix}:query")
@GetMapping(value = "/{${pkColumn.javaField}}")
public Result getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
{
public Result getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) {
return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
}
@ -87,8 +83,7 @@ public class ${ClassName}Controller extends BaseController
@RequiresPermissions("${permissionPrefix}:add")
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
@PostMapping
public Result add(@RequestBody ${ClassName} ${className})
{
public Result add(@RequestBody ${ClassName} ${className}) {
return toAjax(${className}Service.insert${ClassName}(${className}));
}
@ -98,8 +93,7 @@ public class ${ClassName}Controller extends BaseController
@RequiresPermissions("${permissionPrefix}:edit")
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit(@RequestBody ${ClassName} ${className})
{
public Result edit(@RequestBody ${ClassName} ${className}) {
return toAjax(${className}Service.update${ClassName}(${className}));
}
@ -108,9 +102,8 @@ public class ${ClassName}Controller extends BaseController
*/
@RequiresPermissions("${permissionPrefix}:remove")
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
@DeleteMapping("/{${pkColumn.javaField}s}")
public Result remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
{
@DeleteMapping("/{${pkColumn.javaField}s}")
public Result remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) {
return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s));
}
}

View File

@ -19,87 +19,87 @@ import com.muyu.common.core.web.domain.TreeEntity;
* @date ${datetime}
*/
#if($table.crud || $table.sub)
#set($Entity="BaseEntity")
#set($Entity="BaseEntity")
#elseif($table.tree)
#set($Entity="TreeEntity")
#set($Entity="TreeEntity")
#end
public class ${ClassName} extends ${Entity}
{
private static final long serialVersionUID = 1L;
{
private static final long serialVersionUID=1L;
#foreach ($column in $columns)
#if(!$table.isSuperColumn($column.javaField))
#if(!$table.isSuperColumn($column.javaField))
/** $column.columnComment */
#if($column.list)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($parentheseIndex != -1)
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
#elseif($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
#else
@Excel(name = "${comment}")
#end
#end
#if($column.list)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($parentheseIndex != -1)
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
#elseif($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
#else
@Excel(name = "${comment}")
#end
#end
private $column.javaType $column.javaField;
#end
#end
#end
#if($table.sub)
/** $table.subTable.functionName信息 */
private List<${subClassName}> ${subclassName}List;
/** $table.subTable.functionName信息 */
private List<${subClassName}> ${subclassName}List;
#end
#foreach ($column in $columns)
#if(!$table.isSuperColumn($column.javaField))
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField)
#else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end
#if(!$table.isSuperColumn($column.javaField))
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField)
#else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end
public void set${AttrName}($column.javaType $column.javaField)
{
this.$column.javaField = $column.javaField;
}
{
this.$column.javaField = $column.javaField;
}
public $column.javaType get${AttrName}()
{
return $column.javaField;
}
#end
{
return $column.javaField;
}
#end
#end
#if($table.sub)
public List<${subClassName}> get${subClassName}List()
{
public List<${subClassName}> get${subClassName}List()
{
return ${subclassName}List;
}
}
public void set${subClassName}List(List<${subClassName}> ${subclassName}List)
{
this.${subclassName}List = ${subclassName}List;
}
public void set${subClassName}List(List<${subClassName}> ${subclassName}List)
{
this.${subclassName}List= ${subclassName}List;
}
#end
@Override
public String toString() {
@Override
public String toString(){
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
#foreach ($column in $columns)
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField)
#else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end
.append("${column.javaField}", get${AttrName}())
#end
#if($table.sub)
.append("${subclassName}List", get${subClassName}List())
#end
.toString();
}
}
#foreach ($column in $columns)
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField)
#else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end
.append("${column.javaField}",get${AttrName}())
#end
#if($table.sub)
.append("${subclassName}List",get${subClassName}List())
#end
.toString();
}
}

View File

@ -1,6 +1,7 @@
package ${packageName}.mapper;
import java.util.List;
import ${packageName}.domain.${ClassName};
#if($table.sub)
import ${packageName}.domain.${subClassName};
@ -8,15 +9,14 @@ import ${packageName}.domain.${subClassName};
/**
* ${functionName}Mapper接口
*
*
* @author ${author}
* @date ${datetime}
*/
public interface ${ClassName}Mapper
{
public interface ${ClassName}Mapper {
/**
* 查询${functionName}
*
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return ${functionName}
*/
@ -24,7 +24,7 @@ public interface ${ClassName}Mapper
/**
* 查询${functionName}列表
*
*
* @param ${className} ${functionName}
* @return ${functionName}集合
*/
@ -32,7 +32,7 @@ public interface ${ClassName}Mapper
/**
* 新增${functionName}
*
*
* @param ${className} ${functionName}
* @return 结果
*/
@ -40,7 +40,7 @@ public interface ${ClassName}Mapper
/**
* 修改${functionName}
*
*
* @param ${className} ${functionName}
* @return 结果
*/
@ -48,7 +48,7 @@ public interface ${ClassName}Mapper
/**
* 删除${functionName}
*
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return 结果
*/
@ -56,36 +56,36 @@ public interface ${ClassName}Mapper
/**
* 批量删除${functionName}
*
*
* @param ${pkColumn.javaField}s 需要删除的数据主键集合
* @return 结果
*/
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
#if($table.sub)
#if($table.sub)
/**
* 批量删除${subTable.functionName}
*
* @param ${pkColumn.javaField}s 需要删除的数据主键集合
* @return 结果
*/
public int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
/**
* 批量新增${subTable.functionName}
*
* @param ${subclassName}List ${subTable.functionName}列表
* @return 结果
*/
public int batch${subClassName}(List<${subClassName}> ${subclassName}List);
/**
* 批量删除${subTable.functionName}
*
* @param ${pkColumn.javaField}s 需要删除的数据主键集合
* @return 结果
*/
public int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
/**
* 通过${functionName}主键删除${subTable.functionName}信息
*
* @param ${pkColumn.javaField} ${functionName}ID
* @return 结果
*/
public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
#end
/**
* 批量新增${subTable.functionName}
*
* @param ${subclassName}List ${subTable.functionName}列表
* @return 结果
*/
public int batch${subClassName}(List<${subClassName}> ${subclassName}List);
/**
* 通过${functionName}主键删除${subTable.functionName}信息
*
* @param ${pkColumn.javaField} ${functionName}ID
* @return 结果
*/
public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
#end
}

View File

@ -1,19 +1,19 @@
package ${packageName}.service;
import java.util.List;
import ${packageName}.domain.${ClassName};
/**
* ${functionName}Service接口
*
*
* @author ${author}
* @date ${datetime}
*/
public interface I${ClassName}Service
{
public interface I${ClassName}Service {
/**
* 查询${functionName}
*
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return ${functionName}
*/
@ -21,7 +21,7 @@ public interface I${ClassName}Service
/**
* 查询${functionName}列表
*
*
* @param ${className} ${functionName}
* @return ${functionName}集合
*/
@ -29,7 +29,7 @@ public interface I${ClassName}Service
/**
* 新增${functionName}
*
*
* @param ${className} ${functionName}
* @return 结果
*/
@ -37,7 +37,7 @@ public interface I${ClassName}Service
/**
* 修改${functionName}
*
*
* @param ${className} ${functionName}
* @return 结果
*/
@ -45,7 +45,7 @@ public interface I${ClassName}Service
/**
* 批量删除${functionName}
*
*
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合
* @return 结果
*/
@ -53,7 +53,7 @@ public interface I${ClassName}Service
/**
* 删除${functionName}信息
*
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return 结果
*/

View File

@ -1,20 +1,21 @@
package ${packageName}.service.impl;
import java.util.List;
#foreach ($column in $columns)
#if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
import com.muyu.common.core.utils.DateUtils;
#break
#end
#end
#foreach ($column in $columns)
#if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
import com.muyu.common.core.utils.DateUtils;
#break
#end
#end
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
#if($table.sub)
import java.util.ArrayList;
import com.muyu.common.core.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import ${packageName}.domain.${subClassName};
#end
#if($table.sub)
import java.util.ArrayList;
import com.muyu.common.core.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import ${packageName}.domain.${subClassName};
#end
import ${packageName}.mapper.${ClassName}Mapper;
import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service;
@ -26,8 +27,7 @@ import ${packageName}.service.I${ClassName}Service;
* @date ${datetime}
*/
@Service
public class ${ClassName}ServiceImpl implements I${ClassName}Service
{
public class ${ClassName}ServiceImpl implements I${ClassName}Service {
@Autowired
private ${ClassName}Mapper ${className}Mapper;
@ -38,8 +38,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
* @return ${functionName}
*/
@Override
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
{
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) {
return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
}
@ -50,8 +49,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
* @return ${functionName}
*/
@Override
public List<${ClassName}> select${ClassName}List(${ClassName} ${className})
{
public List<${ClassName}> select${ClassName}List(${ClassName} ${className}) {
return ${className}Mapper.select${ClassName}List(${className});
}
@ -61,24 +59,23 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
* @param ${className} ${functionName}
* @return 结果
*/
#if($table.sub)
@Transactional
#end
#if($table.sub)
@Transactional
#end
@Override
public int insert${ClassName}(${ClassName} ${className})
{
#foreach ($column in $columns)
#if($column.javaField == 'createTime')
${className}.setCreateTime(DateUtils.getNowDate());
#end
#end
#if($table.sub)
int rows = ${className}Mapper.insert${ClassName}(${className});
insert${subClassName}(${className});
return rows;
#else
return ${className}Mapper.insert${ClassName}(${className});
#end
public int insert${ClassName}(${ClassName} ${className}) {
#foreach ($column in $columns)
#if($column.javaField == 'createTime')
${className}.setCreateTime(DateUtils.getNowDate());
#end
#end
#if($table.sub)
int rows = ${className}Mapper.insert${ClassName}(${className});
insert${subClassName}(${className});
return rows;
#else
return ${className}Mapper.insert${ClassName}(${className});
#end
}
/**
@ -87,21 +84,21 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
* @param ${className} ${functionName}
* @return 结果
*/
#if($table.sub)
@Transactional
#end
#if($table.sub)
@Transactional
#end
@Override
public int update${ClassName}(${ClassName} ${className})
{
#foreach ($column in $columns)
#if($column.javaField == 'updateTime')
${className}.setUpdateTime(DateUtils.getNowDate());
#end
#end
#if($table.sub)
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}());
insert${subClassName}(${className});
#end
public int update${ClassName}(${ClassName} ${className}) {
#foreach ($column in $columns)
#if($column.javaField == 'updateTime')
${className}.setUpdateTime(DateUtils.getNowDate());
#end
#end
#if($table.sub)
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}())
;
insert${subClassName}(${className});
#end
return ${className}Mapper.update${ClassName}(${className});
}
@ -111,15 +108,14 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键
* @return 结果
*/
#if($table.sub)
@Transactional
#end
#if($table.sub)
@Transactional
#end
@Override
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s)
{
#if($table.sub)
${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s);
#end
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s) {
#if($table.sub)
${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s);
#end
return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s);
}
@ -129,41 +125,37 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
* @param ${pkColumn.javaField} ${functionName}主键
* @return 结果
*/
#if($table.sub)
@Transactional
#end
#if($table.sub)
@Transactional
#end
@Override
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
{
#if($table.sub)
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
#end
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) {
#if($table.sub)
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
#end
return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
}
#if($table.sub)
#if($table.sub)
/**
* 新增${subTable.functionName}信息
*
* @param ${className} ${functionName}对象
*/
public void insert${subClassName}(${ClassName} ${className})
{
List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List();
${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}();
if (StringUtils.isNotNull(${subclassName}List))
{
List<${subClassName}> list = new ArrayList<${subClassName}>();
for (${subClassName} ${subclassName} : ${subclassName}List)
{
${subclassName}.set${subTableFkClassName}(${pkColumn.javaField});
list.add(${subclassName});
}
if (list.size() > 0)
{
${className}Mapper.batch${subClassName}(list);
/**
* 新增${subTable.functionName}信息
*
* @param ${className} ${functionName}对象
*/
public void insert${subClassName}(${ClassName} ${className}) {
List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List();
${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}();
if (StringUtils.isNotNull(${subclassName}List)) {
List<${subClassName}> list = new ArrayList<${subClassName}>();
for (${subClassName} ${subclassName} :${subclassName}List)
{
${subclassName}.set${subTableFkClassName}(${pkColumn.javaField});
list.add(${subclassName});
}
if (list.size() > 0) {
${className}Mapper.batch${subClassName}(list);
}
}
}
}
#end
#end
}

View File

@ -1,8 +1,8 @@
package ${packageName}.domain;
#foreach ($import in $subImportList)
import ${import};
#end
#foreach ($import in $subImportList)
import ${import};
#end
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.muyu.common.core.annotation.Excel;
@ -20,62 +20,62 @@ import com.muyu.common.core.web.domain.BaseEntity;
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class ${subClassName} extends BaseEntity
{
private static final long serialVersionUID = 1L;
{
private static final long serialVersionUID=1L;
#foreach ($column in $subTable.columns)
#if(!$table.isSuperColumn($column.javaField))
#if(!$table.isSuperColumn($column.javaField))
/** $column.columnComment */
#if($column.list)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($parentheseIndex != -1)
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
#elseif($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
#else
@Excel(name = "${comment}")
#end
#end
#if($column.list)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($parentheseIndex != -1)
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
#elseif($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
#else
@Excel(name = "${comment}")
#end
#end
private $column.javaType $column.javaField;
#end
#end
#end
#foreach ($column in $subTable.columns)
#if(!$table.isSuperColumn($column.javaField))
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField)
#else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end
#if(!$table.isSuperColumn($column.javaField))
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField)
#else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end
public void set${AttrName}($column.javaType $column.javaField)
{
this.$column.javaField = $column.javaField;
}
{
this.$column.javaField = $column.javaField;
}
public $column.javaType get${AttrName}()
{
return $column.javaField;
}
#end
{
return $column.javaField;
}
#end
#end
@Override
public String toString() {
@Override
public String toString(){
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
#foreach ($column in $subTable.columns)
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField)
#else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end
.append("${column.javaField}", get${AttrName}())
#end
.toString();
}
}
#foreach ($column in $subTable.columns)
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField)
#else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end
.append("${column.javaField}",get${AttrName}())
#end
.toString();
}
}

View File

@ -2,43 +2,43 @@ import request from '@/utils/request'
// 查询${functionName}列表
export function list${BusinessName}(query) {
return request({
url: '/${moduleName}/${businessName}/list',
method: 'get',
params: query
})
return request({
url: '/${moduleName}/${businessName}/list',
method: 'get',
params: query
})
}
// 查询${functionName}详细
export function get${BusinessName}(${pkColumn.javaField}) {
return request({
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
method: 'get'
})
return request({
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
method: 'get'
})
}
// 新增${functionName}
export function add${BusinessName}(data) {
return request({
url: '/${moduleName}/${businessName}',
method: 'post',
data: data
})
return request({
url: '/${moduleName}/${businessName}',
method: 'post',
data: data
})
}
// 修改${functionName}
export function update${BusinessName}(data) {
return request({
url: '/${moduleName}/${businessName}',
method: 'put',
data: data
})
return request({
url: '/${moduleName}/${businessName}',
method: 'put',
data: data
})
}
// 删除${functionName}
export function del${BusinessName}(${pkColumn.javaField}) {
return request({
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
method: 'delete'
})
return request({
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
method: 'delete'
})
}

File diff suppressed because it is too large Load Diff

View File

@ -1,65 +1,65 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
#foreach($column in $columns)
#if($column.query)
#set($dictType=$column.dictType)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($column.htmlType == "input")
<el-form-item label="${comment}" prop="${column.javaField}">
<el-input
v-model="queryParams.${column.javaField}"
placeholder="请输入${comment}"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
<el-form-item label="${comment}" prop="${column.javaField}">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
<el-option
v-for="dict in ${dictType}"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
<el-form-item label="${comment}" prop="${column.javaField}">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
<el-form-item label="${comment}" prop="${column.javaField}">
<el-date-picker clearable
v-model="queryParams.${column.javaField}"
type="date"
value-format="YYYY-MM-DD"
placeholder="选择${comment}">
</el-date-picker>
</el-form-item>
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
<el-form-item label="${comment}" style="width: 308px">
<el-date-picker
v-model="daterange${AttrName}"
value-format="YYYY-MM-DD"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</el-form-item>
#end
#end
#end
#foreach($column in $columns)
#if($column.query)
#set($dictType=$column.dictType)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($column.htmlType == "input")
<el-form-item label="${comment}" prop="${column.javaField}">
<el-input
v-model="queryParams.${column.javaField}"
placeholder="请输入${comment}"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
<el-form-item label="${comment}" prop="${column.javaField}">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
<el-option
v-for="dict in ${dictType}"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
<el-form-item label="${comment}" prop="${column.javaField}">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
<el-option label="请选择字典生成" value=""/>
</el-select>
</el-form-item>
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
<el-form-item label="${comment}" prop="${column.javaField}">
<el-date-picker clearable
v-model="queryParams.${column.javaField}"
type="date"
value-format="YYYY-MM-DD"
placeholder="选择${comment}">
</el-date-picker>
</el-form-item>
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
<el-form-item label="${comment}" style="width: 308px">
<el-date-picker
v-model="daterange${AttrName}"
value-format="YYYY-MM-DD"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</el-form-item>
#end
#end
#end
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
@ -69,76 +69,85 @@
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="Plus"
@click="handleAdd"
v-hasPermi="['${moduleName}:${businessName}:add']"
>新增</el-button>
type="primary"
plain
icon="Plus"
@click="handleAdd"
v-hasPermi="['${moduleName}:${businessName}:add']"
>新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="Sort"
@click="toggleExpandAll"
>展开/折叠</el-button>
type="info"
plain
icon="Sort"
@click="toggleExpandAll"
>展开/折叠
</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table
v-if="refreshTable"
v-loading="loading"
:data="${businessName}List"
row-key="${treeCode}"
:default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
v-if="refreshTable"
v-loading="loading"
:data="${businessName}List"
row-key="${treeCode}"
:default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
#foreach($column in $columns)
#set($javaField=$column.javaField)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($column.pk)
#elseif($column.list && $column.htmlType == "datetime")
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
<template #default="scope">
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
#elseif($column.list && $column.htmlType == "imageUpload")
<el-table-column label="${comment}" align="center" prop="${javaField}" width="100">
<template #default="scope">
<image-preview :src="scope.row.${javaField}" :width="50" :height="50"/>
</template>
</el-table-column>
#elseif($column.list && "" != $column.dictType)
<el-table-column label="${comment}" align="center" prop="${javaField}">
<template #default="scope">
#if($column.htmlType == "checkbox")
<dict-tag :options="${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
#else
<dict-tag :options="${column.dictType}" :value="scope.row.${javaField}"/>
#end
</template>
</el-table-column>
#elseif($column.list && "" != $javaField)
#if(${foreach.index} == 1)
<el-table-column label="${comment}" prop="${javaField}" />
#else
<el-table-column label="${comment}" align="center" prop="${javaField}" />
#end
#end
#end
#foreach($column in $columns)
#set($javaField=$column.javaField)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($column.pk)
#elseif($column.list && $column.htmlType == "datetime")
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
<template #default="scope">
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
#elseif($column.list && $column.htmlType == "imageUpload")
<el-table-column label="${comment}" align="center" prop="${javaField}" width="100">
<template #default="scope">
<image-preview :src="scope.row.${javaField}" :width="50" :height="50"/>
</template>
</el-table-column>
#elseif($column.list && "" != $column.dictType)
<el-table-column label="${comment}" align="center" prop="${javaField}">
<template #default="scope">
#if($column.htmlType == "checkbox")
<dict-tag :options="${column.dictType}"
:value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
#else
<dict-tag :options="${column.dictType}" :value="scope.row.${javaField}"/>
#end
</template>
</el-table-column>
#elseif($column.list && "" != $javaField)
#if(${foreach.index} == 1)
<el-table-column label="${comment}" prop="${javaField}"/>
#else
<el-table-column label="${comment}" align="center" prop="${javaField}"/>
#end
#end
#end
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']">修改</el-button>
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['${moduleName}:${businessName}:add']">新增</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']">删除</el-button>
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
v-hasPermi="['${moduleName}:${businessName}:edit']">修改
</el-button>
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)"
v-hasPermi="['${moduleName}:${businessName}:add']">新增
</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
v-hasPermi="['${moduleName}:${businessName}:remove']">删除
</el-button>
</template>
</el-table-column>
</el-table>
@ -146,119 +155,120 @@
<!-- 添加或修改${functionName}对话框 -->
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
<el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px">
#foreach($column in $columns)
#set($field=$column.javaField)
#if($column.insert && !$column.pk)
#if(($column.usableColumn) || (!$column.superColumn))
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#set($dictType=$column.dictType)
#if("" != $treeParentCode && $column.javaField == $treeParentCode)
<el-form-item label="${comment}" prop="${treeParentCode}">
<el-tree-select
v-model="form.${treeParentCode}"
:data="${businessName}Options"
:props="{ value: '${treeCode}', label: '${treeName}', children: 'children' }"
value-key="${treeCode}"
placeholder="请选择${comment}"
check-strictly
/>
</el-form-item>
#elseif($column.htmlType == "input")
<el-form-item label="${comment}" prop="${field}">
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
</el-form-item>
#elseif($column.htmlType == "imageUpload")
<el-form-item label="${comment}" prop="${field}">
<image-upload v-model="form.${field}"/>
</el-form-item>
#elseif($column.htmlType == "fileUpload")
<el-form-item label="${comment}" prop="${field}">
<file-upload v-model="form.${field}"/>
</el-form-item>
#elseif($column.htmlType == "editor")
<el-form-item label="${comment}">
<editor v-model="form.${field}" :min-height="192"/>
</el-form-item>
#elseif($column.htmlType == "select" && "" != $dictType)
<el-form-item label="${comment}" prop="${field}">
<el-select v-model="form.${field}" placeholder="请选择${comment}">
<el-option
v-for="dict in ${dictType}"
:key="dict.value"
:label="dict.label"
#if($column.javaType == "Integer" || $column.javaType == "Long")
:value="parseInt(dict.value)"
#else
:value="dict.value"
#end
></el-option>
</el-select>
</el-form-item>
#elseif($column.htmlType == "select" && $dictType)
<el-form-item label="${comment}" prop="${field}">
<el-select v-model="form.${field}" placeholder="请选择${comment}">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
#elseif($column.htmlType == "checkbox" && "" != $dictType)
<el-form-item label="${comment}" prop="${field}">
<el-checkbox-group v-model="form.${field}">
<el-checkbox
v-for="dict in ${dictType}"
:key="dict.value"
:label="dict.value">
{{dict.label}}
</el-checkbox>
</el-checkbox-group>
</el-form-item>
#elseif($column.htmlType == "checkbox" && $dictType)
<el-form-item label="${comment}" prop="${field}">
<el-checkbox-group v-model="form.${field}">
<el-checkbox>请选择字典生成</el-checkbox>
</el-checkbox-group>
</el-form-item>
#elseif($column.htmlType == "radio" && "" != $dictType)
<el-form-item label="${comment}" prop="${field}">
<el-radio-group v-model="form.${field}">
<el-radio
v-for="dict in ${dictType}"
:key="dict.value"
#if($column.javaType == "Integer" || $column.javaType == "Long")
:label="parseInt(dict.value)"
#else
:label="dict.value"
#end
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
#elseif($column.htmlType == "radio" && $dictType)
<el-form-item label="${comment}" prop="${field}">
<el-radio-group v-model="form.${field}">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
#elseif($column.htmlType == "datetime")
<el-form-item label="${comment}" prop="${field}">
<el-date-picker clearable
v-model="form.${field}"
type="date"
value-format="YYYY-MM-DD"
placeholder="选择${comment}">
</el-date-picker>
</el-form-item>
#elseif($column.htmlType == "textarea")
<el-form-item label="${comment}" prop="${field}">
<el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" />
</el-form-item>
#end
#end
#end
#end
#foreach($column in $columns)
#set($field=$column.javaField)
#if($column.insert && !$column.pk)
#if(($column.usableColumn) || (!$column.superColumn))
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#set($dictType=$column.dictType)
#if("" != $treeParentCode && $column.javaField == $treeParentCode)
<el-form-item label="${comment}" prop="${treeParentCode}">
<el-tree-select
v-model="form.${treeParentCode}"
:data="${businessName}Options"
:props="{ value: '${treeCode}', label: '${treeName}', children: 'children' }"
value-key="${treeCode}"
placeholder="请选择${comment}"
check-strictly
/>
</el-form-item>
#elseif($column.htmlType == "input")
<el-form-item label="${comment}" prop="${field}">
<el-input v-model="form.${field}" placeholder="请输入${comment}"/>
</el-form-item>
#elseif($column.htmlType == "imageUpload")
<el-form-item label="${comment}" prop="${field}">
<image-upload v-model="form.${field}"/>
</el-form-item>
#elseif($column.htmlType == "fileUpload")
<el-form-item label="${comment}" prop="${field}">
<file-upload v-model="form.${field}"/>
</el-form-item>
#elseif($column.htmlType == "editor")
<el-form-item label="${comment}">
<editor v-model="form.${field}" :min-height="192"/>
</el-form-item>
#elseif($column.htmlType == "select" && "" != $dictType)
<el-form-item label="${comment}" prop="${field}">
<el-select v-model="form.${field}" placeholder="请选择${comment}">
<el-option
v-for="dict in ${dictType}"
:key="dict.value"
:label="dict.label"
#if($column.javaType == "Integer" || $column.javaType == "Long")
:value="parseInt(dict.value)"
#else
:value="dict.value"
#end
></el-option>
</el-select>
</el-form-item>
#elseif($column.htmlType == "select" && $dictType)
<el-form-item label="${comment}" prop="${field}">
<el-select v-model="form.${field}" placeholder="请选择${comment}">
<el-option label="请选择字典生成" value=""/>
</el-select>
</el-form-item>
#elseif($column.htmlType == "checkbox" && "" != $dictType)
<el-form-item label="${comment}" prop="${field}">
<el-checkbox-group v-model="form.${field}">
<el-checkbox
v-for="dict in ${dictType}"
:key="dict.value"
:label="dict.value">
{{dict.label}}
</el-checkbox>
</el-checkbox-group>
</el-form-item>
#elseif($column.htmlType == "checkbox" && $dictType)
<el-form-item label="${comment}" prop="${field}">
<el-checkbox-group v-model="form.${field}">
<el-checkbox>请选择字典生成</el-checkbox>
</el-checkbox-group>
</el-form-item>
#elseif($column.htmlType == "radio" && "" != $dictType)
<el-form-item label="${comment}" prop="${field}">
<el-radio-group v-model="form.${field}">
<el-radio
v-for="dict in ${dictType}"
:key="dict.value"
#if($column.javaType == "Integer" || $column.javaType == "Long")
:label="parseInt(dict.value)"
#else
:label="dict.value"
#end
>{{dict.label}}
</el-radio>
</el-radio-group>
</el-form-item>
#elseif($column.htmlType == "radio" && $dictType)
<el-form-item label="${comment}" prop="${field}">
<el-radio-group v-model="form.${field}">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
#elseif($column.htmlType == "datetime")
<el-form-item label="${comment}" prop="${field}">
<el-date-picker clearable
v-model="form.${field}"
type="date"
value-format="YYYY-MM-DD"
placeholder="选择${comment}">
</el-date-picker>
</el-form-item>
#elseif($column.htmlType == "textarea")
<el-form-item label="${comment}" prop="${field}">
<el-input v-model="form.${field}" type="textarea" placeholder="请输入内容"/>
</el-form-item>
#end
#end
#end
#end
</el-form>
<template #footer>
<div class="dialog-footer">
@ -271,204 +281,262 @@
</template>
<script setup name="${BusinessName}">
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
import {get${BusinessName}, list${BusinessName}} from "@/api/";
const { proxy } = getCurrentInstance();
#if(${dicts} != '')
#set($dictsNoSymbol=$dicts.replace("'", ""))
const { ${dictsNoSymbol} } = proxy.useDict(${dicts});
#end
const {proxy} = getCurrentInstance();
#if(${dicts} != '')
#set($dictsNoSymbol=$dicts.replace("'", ""))
const { ${dictsNoSymbol} } = proxy.useDict(${dicts});
#end
const ${businessName}List = ref([]);
const ${businessName}Options = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const title = ref("");
const isExpandAll = ref(true);
const refreshTable = ref(true);
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
const daterange${AttrName} = ref([]);
#end
#end
const ${businessName}List = ref([]);
const ${businessName}Options = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const title = ref("");
const isExpandAll = ref(true);
const refreshTable = ref(true);
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
const daterange${AttrName} = ref([]);
#end
#end
const data = reactive({
form: {},
queryParams: {
#foreach ($column in $columns)
#if($column.query)
$column.javaField: null#if($foreach.count != $columns.size()),#end
#end
#end
},
rules: {
#foreach ($column in $columns)
#if($column.required)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
$column.javaField: [
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end }
]#if($foreach.count != $columns.size()),#end
#end
#end
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询${functionName}列表 */
function getList() {
loading.value = true;
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
queryParams.value.params = {};
#break
#end
#end
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
if (null != daterange${AttrName} && '' != daterange${AttrName}) {
queryParams.value.params["begin${AttrName}"] = daterange${AttrName}.value[0];
queryParams.value.params["end${AttrName}"] = daterange${AttrName}.value[1];
}
#end
#end
list${BusinessName}(queryParams.value).then(response => {
${businessName}List.value = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}");
loading.value = false;
});
}
/** 查询${functionName}下拉树结构 */
function getTreeselect() {
list${BusinessName}().then(response => {
${businessName}Options.value = [];
const data = { ${treeCode}: 0, ${treeName}: '顶级节点', children: [] };
data.children = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}");
${businessName}Options.value.push(data);
});
}
// 取消按钮
function cancel() {
open.value = false;
reset();
}
// 表单重置
function reset() {
form.value = {
#foreach ($column in $columns)
#if($column.htmlType == "checkbox")
$column.javaField: []#if($foreach.count != $columns.size()),#end
#else
$column.javaField: null#if($foreach.count != $columns.size()),#end
#end
#end
};
proxy.resetForm("${businessName}Ref");
}
/** 搜索按钮操作 */
function handleQuery() {
getList();
}
/** 重置按钮操作 */
function resetQuery() {
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
daterange${AttrName}.value = [];
#end
#end
proxy.resetForm("queryRef");
handleQuery();
}
/** 新增按钮操作 */
function handleAdd(row) {
reset();
getTreeselect();
if (row != null && row.${treeCode}) {
form.value.${treeParentCode} = row.${treeCode};
} else {
form.value.${treeParentCode} = 0;
}
open.value = true;
title.value = "添加${functionName}";
}
/** 展开/折叠操作 */
function toggleExpandAll() {
refreshTable.value = false;
isExpandAll.value = !isExpandAll.value;
nextTick(() => {
refreshTable.value = true;
});
}
/** 修改按钮操作 */
async function handleUpdate(row) {
reset();
await getTreeselect();
if (row != null) {
form.value.${treeParentCode} = row.${treeCode};
}
get${BusinessName}(row.${pkColumn.javaField}).then(response => {
form.value = response.data;
#foreach ($column in $columns)
#if($column.htmlType == "checkbox")
form.value.$column.javaField = form.value.${column.javaField}.split(",");
#end
#end
open.value = true;
title.value = "修改${functionName}";
});
}
/** 提交按钮 */
function submitForm() {
proxy.#[[$]]#refs["${businessName}Ref"].validate(valid => {
if (valid) {
#foreach ($column in $columns)
#if($column.htmlType == "checkbox")
form.value.$column.javaField = form.value.${column.javaField}.join(",");
#end
#end
if (form.value.${pkColumn.javaField} != null) {
update${BusinessName}(form.value).then(response => {
proxy.#[[$modal]]#.msgSuccess("修改成功");
open.value = false;
getList();
});
} else {
add${BusinessName}(form.value).then(response => {
proxy.#[[$modal]]#.msgSuccess("新增成功");
open.value = false;
getList();
});
}
const data = reactive({
form: {},
queryParams: {
#foreach ($column in $columns)
#if($column.query)
$column.javaField: null#if($foreach.count != $columns.size()),#end
#end
#end
},
rules: {
#foreach ($column in $columns)
#if($column.required)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
$column.javaField: [
{
required: true, message: "$comment不能为空", trigger: #if($column.htmlType ==
"select" || $column.htmlType == "radio")"change"#else"blur"#end }
]#if($foreach.count != $columns.size()),#end
#end
#end
}
});
}
/** 删除按钮操作 */
function handleDelete(row) {
proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + row.${pkColumn.javaField} + '"的数据项?').then(function() {
return del${BusinessName}(row.${pkColumn.javaField});
}).then(() => {
const {queryParams, form, rules} = toRefs(data);
/** 查询${functionName}列表 */
function getList() {
loading.value = true;
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
queryParams.value.params = {};
#break
#end
#end
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
if (null != daterange${AttrName} && '' != daterange${AttrName}) {
queryParams.value.params["begin${AttrName}"] = daterange${AttrName}.value[0];
queryParams.value.params["end${AttrName}"] = daterange${AttrName}.value[1];
}
#end
#end
list${BusinessName}(queryParams.value).then(response => {
${businessName}List.value = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}");
loading.value = false;
});
}
/** 查询${functionName}下拉树结构 */
function getTreeselect() {
list${BusinessName}().then(response => {
${businessName}Options.value = [];
const data = {${treeCode}: 0, ${treeName}: '顶级节点', children: []};
data.children = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}");
${businessName}Options.value.push(data);
});
}
// 取消按钮
function cancel() {
open.value = false;
reset();
}
// 表单重置
function reset() {
form.value = {
#foreach ($column in $columns)
#if($column.htmlType == "checkbox")
$column.javaField: []#if($foreach.count != $columns.size()),#end
#else
$column.javaField: null#if($foreach.count != $columns.size()),#end
#end
#end
};
proxy.resetForm("${businessName}Ref");
}
/** 搜索按钮操作 */
function handleQuery() {
getList();
proxy.#[[$modal]]#.msgSuccess("删除成功");
}).catch(() => {});
}
}
getList();
/** 重置按钮操作 */
function resetQuery() {
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
daterange${AttrName}.value = [];
#end
#end
proxy.resetForm("queryRef");
handleQuery();
}
/** 新增按钮操作 */
function handleAdd(row) {
reset();
getTreeselect();
if (row != null && row.${treeCode}) {
form.value.${treeParentCode} = row.${treeCode};
} else {
form.value.${treeParentCode} = 0;
}
open.value = true;
title.value = "添加${functionName}";
}
/** 展开/折叠操作 */
function toggleExpandAll() {
refreshTable.value = false;
isExpandAll.value = !isExpandAll.value;
nextTick(() => {
refreshTable.value = true;
});
}
/** 修改按钮操作 */
async function handleUpdate(row) {
reset();
await getTreeselect();
if (row != null) {
form.value.${treeParentCode} = row.${treeCode};
}
get${BusinessName}(row.${pkColumn.javaField}).then(response => {
form.value = response.data;
#foreach ($column in $columns)
#if($column.htmlType == "checkbox")
form.value.$column.javaField = form.value.${column.javaField}.split(",");
#end
#end
open.value = true;
title.value = "修改${functionName}";
});
}
/** 提交按钮 */
function submitForm() {
proxy.
#
[[$]]
#refs["${businessName}Ref"].validate(valid => {
if (valid) {
#foreach($column in $columns)
#if($column.htmlType == "checkbox")
form.value.$column.javaField = form.value.$
{
column.javaField
}
.
join(",");
#end
#end
if (form.value.${
pkColumn.javaField
}
!=
null
)
{
update$
{
BusinessName
}
(form.value).then(response => {
proxy.
#
[[$modal]]
#.
msgSuccess("修改成功");
open.value = false;
getList();
});
}
else
{
add$
{
BusinessName
}
(form.value).then(response => {
proxy.
#
[[$modal]]
#.
msgSuccess("新增成功");
open.value = false;
getList();
});
}
}
});
}
/** 删除按钮操作 */
function handleDelete(row) {
proxy.
#
[[$modal]]
#.
confirm('是否确认删除${functionName}编号为"' + row.$
{
pkColumn.javaField
}
+'"的数据项?'
).
then(function () {
return del$
{
BusinessName
}
(row.$
{
pkColumn.javaField
}
)
;
}).then(() => {
getList();
proxy.
#
[[$modal]]
#.
msgSuccess("删除成功");
}).catch(() => {
});
}
getList();
</script>

File diff suppressed because it is too large Load Diff

View File

@ -1,135 +1,168 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${packageName}.mapper.${ClassName}Mapper">
<resultMap type="${ClassName}" id="${ClassName}Result">
#foreach ($column in $columns)
<result property="${column.javaField}" column="${column.columnName}" />
#end
#foreach ($column in $columns)
<result property="${column.javaField}" column="${column.columnName}"/>
#end
</resultMap>
#if($table.sub)
#if($table.sub)
<resultMap id="${ClassName}${subClassName}Result" type="${ClassName}" extends="${ClassName}Result">
<collection property="${subclassName}List" notNullColumn="sub_${subTable.pkColumn.columnName}" javaType="java.util.List" resultMap="${subClassName}Result" />
</resultMap>
<resultMap id="${ClassName}${subClassName}Result" type="${ClassName}" extends="${ClassName}Result">
<collection property="${subclassName}List" notNullColumn="sub_${subTable.pkColumn.columnName}"
javaType="java.util.List" resultMap="${subClassName}Result"/>
</resultMap>
<resultMap type="${subClassName}" id="${subClassName}Result">
#foreach ($column in $subTable.columns)
<result property="${column.javaField}" column="sub_${column.columnName}" />
#end
</resultMap>
#end
<resultMap type="${subClassName}" id="${subClassName}Result">
#foreach ($column in $subTable.columns)
<result property="${column.javaField}" column="sub_${column.columnName}"/>
#end
</resultMap>
#end
<sql id="select${ClassName}Vo">
select#foreach($column in $columns) $column.columnName#if($foreach.count != $columns.size()),#end#end from ${tableName}
select#foreach($column in $columns) $column.columnName#if($foreach.count != $columns.size()),#end#end
from ${tableName}
</sql>
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result">
<include refid="select${ClassName}Vo"/>
<where>
#foreach($column in $columns)
#set($queryType=$column.queryType)
#set($javaField=$column.javaField)
#set($javaType=$column.javaType)
#set($columnName=$column.columnName)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#if($column.query)
#if($column.queryType == "EQ")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName = #{$javaField}</if>
#elseif($queryType == "NE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName != #{$javaField}</if>
#elseif($queryType == "GT")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &gt; #{$javaField}</if>
#elseif($queryType == "GTE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &gt;= #{$javaField}</if>
#elseif($queryType == "LT")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &lt; #{$javaField}</if>
#elseif($queryType == "LTE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &lt;= #{$javaField}</if>
#elseif($queryType == "LIKE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName like concat('%', #{$javaField}, '%')</if>
#elseif($queryType == "BETWEEN")
<if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''"> and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}</if>
#end
#end
#end
<where>
#foreach($column in $columns)
#set($queryType=$column.queryType)
#set($javaField=$column.javaField)
#set($javaType=$column.javaType)
#set($columnName=$column.columnName)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#if($column.query)
#if($column.queryType == "EQ")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end">
and $columnName = #{$javaField}
</if>
#elseif($queryType == "NE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end">
and $columnName != #{$javaField}
</if>
#elseif($queryType == "GT")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end">
and $columnName &gt; #{$javaField}
</if>
#elseif($queryType == "GTE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end">
and $columnName &gt;= #{$javaField}
</if>
#elseif($queryType == "LT")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end">
and $columnName &lt; #{$javaField}
</if>
#elseif($queryType == "LTE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end">
and $columnName &lt;= #{$javaField}
</if>
#elseif($queryType == "LIKE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end">
and $columnName like concat('%', #{$javaField}, '%')
</if>
#elseif($queryType == "BETWEEN")
<if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''">
and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}
</if>
#end
#end
#end
</where>
</select>
<select id="select${ClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
#if($table.crud || $table.tree)
<include refid="select${ClassName}Vo"/>
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
#elseif($table.sub)
select#foreach($column in $columns) a.$column.columnName#if($foreach.count != $columns.size()),#end#end,
#foreach($column in $subTable.columns) b.$column.columnName as sub_$column.columnName#if($foreach.count != $subTable.columns.size()),#end#end
from ${tableName} a
left join ${subTableName} b on b.${subTableFkName} = a.${pkColumn.columnName}
where a.${pkColumn.columnName} = #{${pkColumn.javaField}}
#end
<select id="select${ClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}"
resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
#if($table.crud || $table.tree)
<include refid="select${ClassName}Vo"/>
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
#elseif($table.sub)
select#foreach($column in $columns) a.$column.columnName#if($foreach.count != $columns.size()),#end#end,
#foreach($column in $subTable.columns) b.$column.columnName as
sub_$column.columnName#if($foreach.count != $subTable.columns.size()),#end#end
from ${tableName} a
left join ${subTableName} b on b.${subTableFkName} = a.${pkColumn.columnName}
where a.${pkColumn.columnName} = #{${pkColumn.javaField}}
#end
</select>
<insert id="insert${ClassName}" parameterType="${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true" keyProperty="$pkColumn.javaField"#end>
<insert id="insert${ClassName}" parameterType="${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true"
keyProperty="$pkColumn.javaField"#end>
insert into ${tableName}
<trim prefix="(" suffix=")" suffixOverrides=",">
#foreach($column in $columns)
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName,</if>
#end
#end
</trim>
#foreach($column in $columns)
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
<if test="$column.javaField != null#if($column.javaType ==
'String' && $column.required) and $column.javaField != ''#end">$column.columnName,
</if>
#end
#end
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#foreach($column in $columns)
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">#{$column.javaField},</if>
#end
#end
</trim>
#foreach($column in $columns)
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
<if test="$column.javaField != null#if($column.javaType ==
'String' && $column.required) and $column.javaField != ''#end">#{$column.javaField},
</if>
#end
#end
</trim>
</insert>
<update id="update${ClassName}" parameterType="${ClassName}">
update ${tableName}
<trim prefix="SET" suffixOverrides=",">
#foreach($column in $columns)
#if($column.columnName != $pkColumn.columnName)
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName = #{$column.javaField},</if>
#end
#end
#foreach($column in $columns)
#if($column.columnName != $pkColumn.columnName)
<if test="$column.javaField != null#if($column.javaType ==
'String' && $column.required) and $column.javaField != ''#end">$column.columnName =
#{$column.javaField},
</if>
#end
#end
</trim>
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
</update>
<delete id="delete${ClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}">
delete from ${tableName} where ${pkColumn.columnName} = #{${pkColumn.javaField}}
delete
from ${tableName} where ${pkColumn.columnName} = #{${pkColumn.javaField}}
</delete>
<delete id="delete${ClassName}By${pkColumn.capJavaField}s" parameterType="String">
delete from ${tableName} where ${pkColumn.columnName} in
delete from ${tableName} where ${pkColumn.columnName} in
<foreach item="${pkColumn.javaField}" collection="array" open="(" separator="," close=")">
#{${pkColumn.javaField}}
</foreach>
</delete>
#if($table.sub)
<delete id="delete${subClassName}By${subTableFkClassName}s" parameterType="String">
delete from ${subTableName} where ${subTableFkName} in
<foreach item="${subTableFkclassName}" collection="array" open="(" separator="," close=")">
#{${subTableFkclassName}}
</foreach>
</delete>
#if($table.sub)
<delete id="delete${subClassName}By${subTableFkClassName}" parameterType="${pkColumn.javaType}">
delete from ${subTableName} where ${subTableFkName} = #{${subTableFkclassName}}
</delete>
<delete id="delete${subClassName}By${subTableFkClassName}s" parameterType="String">
delete from ${subTableName} where ${subTableFkName} in
<foreach item="${subTableFkclassName}" collection="array" open="(" separator="," close=")">
#{${subTableFkclassName}}
</foreach>
</delete>
<insert id="batch${subClassName}">
insert into ${subTableName}(#foreach($column in $subTable.columns) $column.columnName#if($foreach.count != $subTable.columns.size()),#end#end) values
<foreach item="item" index="index" collection="list" separator=",">
(#foreach($column in $subTable.columns) #{item.$column.javaField}#if($foreach.count != $subTable.columns.size()),#end#end)
</foreach>
</insert>
#end
</mapper>
<delete id="delete${subClassName}By${subTableFkClassName}" parameterType="${pkColumn.javaType}">
delete
from ${subTableName} where ${subTableFkName} = #{${subTableFkclassName}}
</delete>
<insert id="batch${subClassName}">
insert into ${subTableName}
(#foreach($column in $subTable.columns) $column.columnName#if($foreach.count != $subTable.columns.size())
,#end#end) values
<foreach item="item" index="index" collection="list" separator=",">
(#foreach($column in $subTable.columns) #{item.$column.javaField
}#if($foreach.count != $subTable.columns.size()),#end#end)
</foreach>
</insert>
#end
</mapper>

View File

@ -0,0 +1,34 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>muyu-goods-edition</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>muyu-goods-edition-client</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-goods-edition-common</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>muyu-goods-edition-remote</artifactId>
<version>3.6.3</version>
</dependency>
</dependencies>
</project>

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