【优化】代码生成器异常码枚举分类优化,gen模块去除引用system,cache分包优化

pull/24/head
徐玉祥 2021-06-30 16:21:53 +08:00
parent 47ed1f60b0
commit 2c4a182f94
16 changed files with 105 additions and 50 deletions

View File

@ -216,6 +216,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<delimiters>
<delimiter>@</delimiter>

View File

@ -65,6 +65,22 @@
<artifactId>postgresql</artifactId>
</dependency>-->
<!-- redis,使用jedis客户端排除lettuce -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<exclusions>
<exclusion>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<!-- druid连接池 -->
<dependency>
<groupId>com.alibaba</groupId>

View File

@ -22,7 +22,7 @@ Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意
5. https://gitee.com/xiaonuobase/snowy
6.Snowy https://www.xiaonuo.vip
*/
package vip.xiaonuo.sys.core.cache.base;
package vip.xiaonuo.core.cache.base;
import cn.hutool.cache.impl.CacheObj;
import cn.hutool.cache.impl.TimedCache;

View File

@ -22,7 +22,7 @@ Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意
5. https://gitee.com/xiaonuobase/snowy
6.Snowy https://www.xiaonuo.vip
*/
package vip.xiaonuo.sys.core.cache.base;
package vip.xiaonuo.core.cache.base;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;

View File

@ -16,6 +16,7 @@
<packaging>jar</packaging>
<dependencies>
<!-- core模块 -->
<dependency>
<groupId>vip.xiaonuo</groupId>
@ -23,13 +24,6 @@
<version>1.6.0</version>
</dependency>
<!-- system模块 -->
<dependency>
<groupId>vip.xiaonuo</groupId>
<artifactId>snowy-system</artifactId>
<version>1.6.0</version>
</dependency>
<!-- 代码生成引擎 -->
<dependency>
<groupId>org.apache.velocity</groupId>

View File

@ -22,7 +22,7 @@ Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意
5. https://gitee.com/xiaonuobase/snowy
6.Snowy https://www.xiaonuo.vip
*/
package vip.xiaonuo.generate.core.config;
package vip.xiaonuo.generate.core.consts;
import java.io.File;
@ -33,7 +33,7 @@ import java.io.File;
* @author yubaoshan
* @date 2020-12-19 02:30:56
*/
public class Config {
public class GenConstant {
/**
*

View File

@ -0,0 +1,59 @@
/*
Copyright [2020] [https://www.xiaonuo.vip]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
SnowyAPACHE LICENSE 2.0使
1.LICENSE
2.Snowy
3.
4. https://gitee.com/xiaonuobase/snowy
5. https://gitee.com/xiaonuobase/snowy
6.Snowy https://www.xiaonuo.vip
*/
package vip.xiaonuo.generate.core.consts;
/**
*
* <p>
* 3
* <p>
* 2 + 4 + 1
* <p>
* ExpEnumCodeConstant
*
* @author xuyuxiang
* @date 2020/6/19 20:46
*/
public interface GenExpEnumConstant {
/**
* 2
* <p>
* snowy-gen
*/
int SNOWY_GEN_MODULE_EXP_CODE = 60;
/* 分类编码4位 */
/**
*
*/
int GEN_CODE_EXCEPTION_ENUM = 1100;
/**
*
*/
int GEN_CONFIG_EXCEPTION_ENUM = 1200;
}

View File

@ -25,7 +25,7 @@ Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意
package vip.xiaonuo.generate.core.param;
import lombok.Data;
import vip.xiaonuo.generate.core.config.Config;
import vip.xiaonuo.generate.core.consts.GenConstant;
import vip.xiaonuo.generate.modular.entity.SysCodeGenerateConfig;
import java.util.List;
@ -86,7 +86,7 @@ public class XnCodeGenParam {
/**
*
*/
private String modularNane = Config.MODULAR_NAME;
private String modularNane = GenConstant.MODULAR_NAME;
/**
*

View File

@ -27,7 +27,7 @@ package vip.xiaonuo.generate.modular.enums;
import vip.xiaonuo.core.annotion.ExpEnumType;
import vip.xiaonuo.core.exception.enums.abs.AbstractBaseExceptionEnum;
import vip.xiaonuo.core.factory.ExpEnumCodeFactory;
import vip.xiaonuo.sys.core.consts.SysExpEnumConstant;
import vip.xiaonuo.generate.core.consts.GenExpEnumConstant;
/**
*
@ -35,7 +35,7 @@ import vip.xiaonuo.sys.core.consts.SysExpEnumConstant;
* @author yubaoshan
* @date 2020121621:21:14
*/
@ExpEnumType(module = SysExpEnumConstant.SNOWY_SYS_MODULE_EXP_CODE, kind = SysExpEnumConstant.SYS_APP_EXCEPTION_ENUM)
@ExpEnumType(module = GenExpEnumConstant.GEN_CODE_EXCEPTION_ENUM, kind = GenExpEnumConstant.GEN_CONFIG_EXCEPTION_ENUM)
public enum CodeGenerateExceptionEnum implements AbstractBaseExceptionEnum {
/**

View File

@ -27,7 +27,7 @@ package vip.xiaonuo.generate.modular.enums;
import vip.xiaonuo.core.annotion.ExpEnumType;
import vip.xiaonuo.core.exception.enums.abs.AbstractBaseExceptionEnum;
import vip.xiaonuo.core.factory.ExpEnumCodeFactory;
import vip.xiaonuo.sys.core.consts.SysExpEnumConstant;
import vip.xiaonuo.generate.core.consts.GenExpEnumConstant;
/**
*
@ -35,7 +35,7 @@ import vip.xiaonuo.sys.core.consts.SysExpEnumConstant;
* @author yubaoshan
* @date 2021-02-06 20:19:49
*/
@ExpEnumType(module = SysExpEnumConstant.SNOWY_SYS_MODULE_EXP_CODE, kind = SysExpEnumConstant.SYS_POS_EXCEPTION_ENUM)
@ExpEnumType(module = GenExpEnumConstant.SNOWY_GEN_MODULE_EXP_CODE, kind = GenExpEnumConstant.GEN_CONFIG_EXCEPTION_ENUM)
public enum SysCodeGenerateConfigExceptionEnum implements AbstractBaseExceptionEnum {
/**

View File

@ -37,7 +37,7 @@ import org.springframework.stereotype.Service;
import vip.xiaonuo.core.exception.ServiceException;
import vip.xiaonuo.core.factory.PageFactory;
import vip.xiaonuo.core.pojo.page.PageResult;
import vip.xiaonuo.generate.core.config.Config;
import vip.xiaonuo.generate.core.consts.GenConstant;
import vip.xiaonuo.generate.core.context.XnVelocityContext;
import vip.xiaonuo.generate.core.param.XnCodeGenParam;
import vip.xiaonuo.generate.core.tool.StringDateTool;
@ -186,7 +186,7 @@ public class CodeGenerateServiceImpl extends ServiceImpl<CodeGenerateMapper, Cod
List<InforMationColumnsResult> inforMationColumnsResultList = this.baseMapper.selectInformationColumns(Util.getDataBasename(), tableName);
for (int a = 0; a < inforMationColumnsResultList.size(); a++) {
if (ObjectUtil.isNotNull(inforMationColumnsResultList.get(a).columnKey)
&& inforMationColumnsResultList.get(a).columnKey.equals(Config.DB_TABLE_COM_KRY)) {
&& inforMationColumnsResultList.get(a).columnKey.equals(GenConstant.DB_TABLE_COM_KRY)) {
return true;
}
}
@ -251,24 +251,24 @@ public class CodeGenerateServiceImpl extends ServiceImpl<CodeGenerateMapper, Cod
//实例化一个VelocityEngine对象
VelocityEngine velocityEngine=new VelocityEngine(properties);
String[] filePath = Config.xnCodeGenFilePath(xnCodeGenParam.getBusName(), xnCodeGenParam.getPackageName());
String[] filePath = GenConstant.xnCodeGenFilePath(xnCodeGenParam.getBusName(), xnCodeGenParam.getPackageName());
for (int i = 0; i < filePath.length; i++) {
String templateName = Config.xnCodeGenTempFile[i];
String templateName = GenConstant.xnCodeGenTempFile[i];
String fileBaseName = ResetFileBaseName(xnCodeGenParam.getClassName(),
templateName.substring(templateName.indexOf(Config.FILE_SEP) + 1, templateName.lastIndexOf(TEMP_SUFFIX)));
String path = Config.getLocalPath ();
templateName.substring(templateName.indexOf(GenConstant.FILE_SEP) + 1, templateName.lastIndexOf(TEMP_SUFFIX)));
String path = GenConstant.getLocalPath ();
// 前端VUE位置有所变化, sql同样根目录
if (fileBaseName.contains(INDEX_PAGE_NAME) || fileBaseName.contains(ADD_FORM_PAGE_NAME) ||
fileBaseName.contains(EDIT_FORM_PAGE_NAME) ||fileBaseName.contains(MANAGE_JS_NAME) ||
fileBaseName.contains(SQL_NAME)) {
path = Config.getLocalFrontPath();
path = GenConstant.getLocalFrontPath();
}
File file = new File(path + filePath[i] + fileBaseName);
//判断是否覆盖存在的文件
if(file.exists() && !Config.FLAG){
if(file.exists() && !GenConstant.FLAG){
continue;
}
@ -279,7 +279,7 @@ public class CodeGenerateServiceImpl extends ServiceImpl<CodeGenerateMapper, Cod
}
try {
Writer writer = new FileWriter(file);
velocityEngine.mergeTemplate(Config.templatePath + templateName,ENCODED,context.createVelContext(xnCodeGenParam),writer);
velocityEngine.mergeTemplate(GenConstant.templatePath + templateName,ENCODED,context.createVelContext(xnCodeGenParam),writer);
writer.close();
} catch (Exception e) {
throw new ServiceException(CodeGenerateExceptionEnum.CODE_GEN_NOT_PATH);
@ -294,14 +294,14 @@ public class CodeGenerateServiceImpl extends ServiceImpl<CodeGenerateMapper, Cod
Util.initVelocity();
XnVelocityContext context = new XnVelocityContext();
String[] filePath = Config.xnCodeGenFilePath(xnCodeGenParam.getBusName(), xnCodeGenParam.getPackageName());
String[] filePath = GenConstant.xnCodeGenFilePath(xnCodeGenParam.getBusName(), xnCodeGenParam.getPackageName());
for (int a = 0; a < filePath.length; a++) {
String templateName = Config.xnCodeGenTempFile[a];
String templateName = GenConstant.xnCodeGenTempFile[a];
String fileBaseName = ResetFileBaseName(xnCodeGenParam.getClassName(),
templateName.substring(templateName.indexOf(Config.FILE_SEP) + 1, templateName.lastIndexOf(TEMP_SUFFIX)));
templateName.substring(templateName.indexOf(GenConstant.FILE_SEP) + 1, templateName.lastIndexOf(TEMP_SUFFIX)));
XnZipOutputStream(context.createVelContext(xnCodeGenParam),
Config.templatePath + templateName,
GenConstant.templatePath + templateName,
filePath[a] + fileBaseName,
zipOutputStream);
}

View File

@ -32,7 +32,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vip.xiaonuo.core.enums.YesOrNotEnum;
import vip.xiaonuo.core.exception.ServiceException;
import vip.xiaonuo.generate.core.config.Config;
import vip.xiaonuo.generate.core.consts.GenConstant;
import vip.xiaonuo.generate.core.enums.QueryTypeEnum;
import vip.xiaonuo.generate.core.enums.TableFilteredFieldsEnum;
import vip.xiaonuo.generate.core.tool.JavaEffTool;
@ -84,7 +84,7 @@ public class SysCodeGenerateConfigServiceImpl extends ServiceImpl<SysCodeGenerat
String YesOrNo = YesOrNotEnum.Y.getCode();
if (ObjectUtil.isNotNull(inforMationColumnsResult.getColumnKey())
&& inforMationColumnsResult.getColumnKey().equals(Config.DB_TABLE_COM_KRY) ||
&& inforMationColumnsResult.getColumnKey().equals(GenConstant.DB_TABLE_COM_KRY) ||
TableFilteredFieldsEnum.contains(inforMationColumnsResult.getColumnName())) {
YesOrNo = YesOrNotEnum.N.getCode();
}

View File

@ -48,22 +48,6 @@
<optional>true</optional>
</dependency>
<!-- redis,使用jedis客户端排除lettuce -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<exclusions>
<exclusion>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<!-- jwt token -->
<dependency>
<groupId>io.jsonwebtoken</groupId>

View File

@ -25,7 +25,7 @@ Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意
package vip.xiaonuo.sys.core.cache;
import cn.hutool.cache.impl.TimedCache;
import vip.xiaonuo.sys.core.cache.base.AbstractMemoryCacheOperator;
import vip.xiaonuo.core.cache.base.AbstractMemoryCacheOperator;
import java.util.Map;

View File

@ -25,8 +25,8 @@ Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意
package vip.xiaonuo.sys.core.cache;
import org.springframework.data.redis.core.RedisTemplate;
import vip.xiaonuo.core.cache.base.AbstractRedisCacheOperator;
import vip.xiaonuo.core.pojo.login.SysLoginUser;
import vip.xiaonuo.sys.core.cache.base.AbstractRedisCacheOperator;
/**
*

View File

@ -17,6 +17,7 @@
<dependencies>
<!-- 系统模块 -->
<dependency>
<groupId>vip.xiaonuo</groupId>
<artifactId>snowy-system</artifactId>