mirror of https://gitee.com/xiaonuobase/snowy
【优化】代码生成器异常码枚举分类优化,gen模块去除引用system,cache分包优化
parent
47ed1f60b0
commit
2c4a182f94
1
pom.xml
1
pom.xml
|
@ -216,6 +216,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<delimiters>
|
||||
<delimiter>@</delimiter>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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;
|
|
@ -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;
|
|
@ -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>
|
||||
|
|
|
@ -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 {
|
||||
|
||||
/**
|
||||
* 路径分离(不通的机器,取不同的路径)
|
|
@ -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.
|
||||
|
||||
Snowy采用APACHE 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;
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* 业务名
|
||||
|
|
|
@ -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 2020年12月16日21: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 {
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 {
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* 登录用户的缓存,存储了当前登录的用户
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
<dependencies>
|
||||
|
||||
<!-- 系统模块 -->
|
||||
<dependency>
|
||||
<groupId>vip.xiaonuo</groupId>
|
||||
<artifactId>snowy-system</artifactId>
|
||||
|
|
Loading…
Reference in New Issue