Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # src/main/java/com/gxwebsoft/common/core/utils/WechatCertAutoConfig.java # src/main/java/com/gxwebsoft/shop/controller/ShopOrderController.java
This commit is contained in:
@@ -32,7 +32,7 @@ public class TestMain {
|
||||
public void testGenJwtKey() {
|
||||
|
||||
BigDecimal bigDecimal = new BigDecimal(NumberUtil.decimalFormat("0.00", 1 * 0.01));
|
||||
System.out.println("实际付款金额 = " + bigDecimal);
|
||||
System.out.println("实际付款金额111111111 = " + bigDecimal);
|
||||
|
||||
final HjmCar byGpsNo = hjmCarService.getByGpsNo("gps1");
|
||||
System.out.println("byGpsNo = " + byGpsNo.getSpeed());
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
package com.gxwebsoft.generator;
|
||||
|
||||
/**
|
||||
* 独立应用模块-代码生成工具
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2021-09-05 00:31:14
|
||||
*/
|
||||
public class AppGenerator {
|
||||
// 输出位置
|
||||
private static final String OUTPUT_LOCATION = System.getProperty("user.dir");
|
||||
//private static final String OUTPUT_LOCATION = "D:/codegen"; // 不想生成到项目中可以写磁盘路径
|
||||
// 输出目录
|
||||
private static final String OUTPUT_DIR = "/src/main/java";
|
||||
// 作者名称
|
||||
private static final String AUTHOR = "科技小王子";
|
||||
// 数据库连接配置
|
||||
private static final String DB_URL = "jdbc:mysql://47.119.165.234:3308/modules?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8";
|
||||
private static final String DB_USERNAME = "modules";
|
||||
private static final String DB_PASSWORD = "8YdLnk7KsPAyDXGA";
|
||||
// 包名
|
||||
private static final String PACKAGE_NAME = "com.gxwebsoft";
|
||||
// 模块名
|
||||
private static final String MODULE_NAME = "app";
|
||||
// 需要生成的表
|
||||
private static final String[] TABLE_NAMES = new String[]{
|
||||
// "app_bszx_bm",
|
||||
// "app_bszx_pay",
|
||||
// "app_bszx_grade",
|
||||
// "app_bszx_class"
|
||||
"app_bszx_era"
|
||||
|
||||
};
|
||||
// 需要去除的表前缀
|
||||
private static final String[] TABLE_PREFIX = new String[]{
|
||||
"tb_"
|
||||
};
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("=== MyBatis-Plus 代码生成器 ===");
|
||||
System.out.println("输出目录: " + OUTPUT_LOCATION + OUTPUT_DIR);
|
||||
System.out.println("包名: " + PACKAGE_NAME + "." + MODULE_NAME);
|
||||
System.out.println("表名: " + String.join(", ", TABLE_NAMES));
|
||||
System.out.println("数据库: " + DB_URL);
|
||||
|
||||
try {
|
||||
// 注意:由于MyBatis-Plus Generator版本兼容性问题,
|
||||
// 当前版本的FastAutoGenerator API可能不兼容
|
||||
// 建议使用项目中其他Generator类的实现方式
|
||||
System.out.println("请参考项目中的其他Generator类(如ProjectGenerator.java)的实现方式");
|
||||
System.out.println("或者手动创建Entity、Mapper、Service、Controller类");
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("代码生成失败: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package com.gxwebsoft.generator;
|
||||
|
||||
/**
|
||||
* 小程序模块-代码生成工具
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2021-09-05 00:31:14
|
||||
*/
|
||||
public class BszxGenerator {
|
||||
// 输出位置
|
||||
private static final String OUTPUT_LOCATION = System.getProperty("user.dir");
|
||||
//private static final String OUTPUT_LOCATION = "D:/codegen"; // 不想生成到项目中可以写磁盘路径
|
||||
// 输出目录
|
||||
private static final String OUTPUT_DIR = "/src/main/java";
|
||||
// Vue文件输出位置
|
||||
private static final String OUTPUT_LOCATION_VUE = "/Users/gxwebsoft/VUE/mp";
|
||||
// Vue文件输出目录
|
||||
private static final String OUTPUT_LOCATION_UNIAPP = "/Users/gxwebsoft/APP/mp";
|
||||
// Vue文件输出目录
|
||||
private static final String OUTPUT_DIR_VUE = "/src";
|
||||
// 作者名称
|
||||
private static final String AUTHOR = "科技小王子";
|
||||
// 是否在xml中添加二级缓存配置
|
||||
private static final boolean ENABLE_CACHE = false;
|
||||
// 数据库连接配置
|
||||
private static final String DB_URL = "jdbc:mysql://47.119.165.234:3308/modules?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8";
|
||||
private static final String DB_DRIVER = "com.mysql.cj.jdbc.Driver";
|
||||
private static final String DB_USERNAME = "modules";
|
||||
private static final String DB_PASSWORD = "8YdLnk7KsPAyDXGA";
|
||||
// 包名
|
||||
private static final String PACKAGE_NAME = "com.gxwebsoft";
|
||||
// 模块名
|
||||
private static final String MODULE_NAME = "bszx";
|
||||
// 需要生成的表
|
||||
private static final String[] TABLE_NAMES = new String[]{
|
||||
// "bszx_bm",
|
||||
// "bszx_era",
|
||||
// "bszx_grade",
|
||||
// "bszx_class",
|
||||
// "bszx_pay",
|
||||
// "bszx_branch",
|
||||
// "bszx_pay_ranking"
|
||||
"bszx_order"
|
||||
};
|
||||
// 需要去除的表前缀
|
||||
private static final String[] TABLE_PREFIX = new String[]{
|
||||
"tb_"
|
||||
};
|
||||
// 不需要作为查询参数的字段
|
||||
private static final String[] PARAM_EXCLUDE_FIELDS = new String[]{
|
||||
"tenant_id",
|
||||
"create_time",
|
||||
"update_time"
|
||||
};
|
||||
// 查询参数使用String的类型
|
||||
private static final String[] PARAM_TO_STRING_TYPE = new String[]{
|
||||
"Date",
|
||||
"LocalDate",
|
||||
"LocalTime",
|
||||
"LocalDateTime"
|
||||
};
|
||||
// 查询参数使用EQ的类型
|
||||
private static final String[] PARAM_EQ_TYPE = new String[]{
|
||||
"Integer",
|
||||
"Boolean",
|
||||
"BigDecimal"
|
||||
};
|
||||
// 是否添加权限注解
|
||||
private static final boolean AUTH_ANNOTATION = true;
|
||||
// 是否添加日志注解
|
||||
private static final boolean LOG_ANNOTATION = true;
|
||||
// controller的mapping前缀
|
||||
private static final String CONTROLLER_MAPPING_PREFIX = "/api";
|
||||
// 模板所在位置
|
||||
private static final String TEMPLATES_DIR = "/src/test/java/com/gxwebsoft/generator/templates";
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("=== 办事指南模块 MyBatis-Plus 代码生成器 ===");
|
||||
System.out.println("输出目录: " + OUTPUT_LOCATION + OUTPUT_DIR);
|
||||
System.out.println("包名: " + PACKAGE_NAME + "." + MODULE_NAME);
|
||||
System.out.println("表名: " + String.join(", ", TABLE_NAMES));
|
||||
System.out.println("数据库: " + DB_URL);
|
||||
|
||||
try {
|
||||
// 注意:由于MyBatis-Plus Generator版本兼容性问题,
|
||||
// 当前版本的API可能不兼容,建议手动创建代码文件
|
||||
System.out.println("请参考项目中现有的办事指南模块代码结构");
|
||||
System.out.println("或者手动创建Entity、Mapper、Service、Controller类");
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("代码生成失败: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,19 @@
|
||||
package com.gxwebsoft.generator;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.InjectionConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.*;
|
||||
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||
import com.gxwebsoft.generator.engine.BeetlTemplateEnginePlus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* CMS模块-代码生成工具
|
||||
*
|
||||
@@ -62,8 +76,8 @@ public class CmsGenerator {
|
||||
// "cms_model"
|
||||
// "cms_lang",
|
||||
// "cms_lang_log",
|
||||
"cms_statistics",
|
||||
// "cms_website_setting"
|
||||
// "cms_website_setting",
|
||||
"cms_statistics"
|
||||
|
||||
};
|
||||
// 需要去除的表前缀
|
||||
@@ -99,22 +113,163 @@ public class CmsGenerator {
|
||||
private static final String TEMPLATES_DIR = "/src/test/java/com/gxwebsoft/generator/templates";
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("=== CMS模块 MyBatis-Plus 代码生成器 ===");
|
||||
System.out.println("输出目录: " + OUTPUT_LOCATION + OUTPUT_DIR);
|
||||
System.out.println("包名: " + PACKAGE_NAME + "." + MODULE_NAME);
|
||||
System.out.println("表名: " + String.join(", ", TABLE_NAMES));
|
||||
System.out.println("数据库: " + DB_URL);
|
||||
// 代码生成器
|
||||
AutoGenerator mpg = new AutoGenerator();
|
||||
|
||||
try {
|
||||
// 注意:由于MyBatis-Plus Generator版本兼容性问题,
|
||||
// 当前版本的API可能不兼容,建议手动创建代码文件
|
||||
System.out.println("请参考项目中现有的CMS模块代码结构");
|
||||
System.out.println("或者手动创建Entity、Mapper、Service、Controller类");
|
||||
// 全局配置
|
||||
GlobalConfig gc = new GlobalConfig();
|
||||
gc.setOutputDir(OUTPUT_LOCATION + OUTPUT_DIR);
|
||||
gc.setAuthor(AUTHOR);
|
||||
gc.setOpen(false);
|
||||
gc.setFileOverride(true);
|
||||
gc.setEnableCache(ENABLE_CACHE);
|
||||
gc.setSwagger2(true);
|
||||
gc.setIdType(IdType.AUTO);
|
||||
gc.setServiceName("%sService");
|
||||
mpg.setGlobalConfig(gc);
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("代码生成失败: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 数据源配置
|
||||
DataSourceConfig dsc = new DataSourceConfig();
|
||||
dsc.setUrl(DB_URL);
|
||||
// dsc.setSchemaName("public");
|
||||
dsc.setDriverName(DB_DRIVER);
|
||||
dsc.setUsername(DB_USERNAME);
|
||||
dsc.setPassword(DB_PASSWORD);
|
||||
mpg.setDataSource(dsc);
|
||||
|
||||
// 包配置
|
||||
PackageConfig pc = new PackageConfig();
|
||||
pc.setModuleName(MODULE_NAME);
|
||||
pc.setParent(PACKAGE_NAME);
|
||||
mpg.setPackageInfo(pc);
|
||||
|
||||
// 策略配置
|
||||
StrategyConfig strategy = new StrategyConfig();
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel);
|
||||
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
|
||||
strategy.setInclude(TABLE_NAMES);
|
||||
strategy.setTablePrefix(TABLE_PREFIX);
|
||||
strategy.setSuperControllerClass(PACKAGE_NAME + ".common.core.web.BaseController");
|
||||
strategy.setEntityLombokModel(true);
|
||||
strategy.setRestControllerStyle(true);
|
||||
strategy.setControllerMappingHyphenStyle(true);
|
||||
strategy.setLogicDeleteFieldName("deleted");
|
||||
mpg.setStrategy(strategy);
|
||||
|
||||
// 模板配置
|
||||
TemplateConfig templateConfig = new TemplateConfig();
|
||||
templateConfig.setController(TEMPLATES_DIR + "/controller.java");
|
||||
templateConfig.setEntity(TEMPLATES_DIR + "/entity.java");
|
||||
templateConfig.setMapper(TEMPLATES_DIR + "/mapper.java");
|
||||
templateConfig.setXml(TEMPLATES_DIR + "/mapper.xml");
|
||||
templateConfig.setService(TEMPLATES_DIR + "/service.java");
|
||||
templateConfig.setServiceImpl(TEMPLATES_DIR + "/serviceImpl.java");
|
||||
mpg.setTemplate(templateConfig);
|
||||
mpg.setTemplateEngine(new BeetlTemplateEnginePlus());
|
||||
|
||||
// 自定义模板配置
|
||||
InjectionConfig cfg = new InjectionConfig() {
|
||||
@Override
|
||||
public void initMap() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("packageName", PACKAGE_NAME);
|
||||
map.put("paramExcludeFields", PARAM_EXCLUDE_FIELDS);
|
||||
map.put("paramToStringType", PARAM_TO_STRING_TYPE);
|
||||
map.put("paramEqType", PARAM_EQ_TYPE);
|
||||
map.put("authAnnotation", AUTH_ANNOTATION);
|
||||
map.put("logAnnotation", LOG_ANNOTATION);
|
||||
map.put("controllerMappingPrefix", CONTROLLER_MAPPING_PREFIX);
|
||||
this.setMap(map);
|
||||
}
|
||||
};
|
||||
String templatePath = TEMPLATES_DIR + "/param.java.btl";
|
||||
List<FileOutConfig> focList = new ArrayList<>();
|
||||
focList.add(new FileOutConfig(templatePath) {
|
||||
@Override
|
||||
public String outputFile(TableInfo tableInfo) {
|
||||
return OUTPUT_LOCATION + OUTPUT_DIR + "/"
|
||||
+ PACKAGE_NAME.replace(".", "/")
|
||||
+ "/" + pc.getModuleName() + "/param/"
|
||||
+ tableInfo.getEntityName() + "Param" + StringPool.DOT_JAVA;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* 以下是生成VUE项目代码
|
||||
* 生成文件的路径 /api/shop/goods/index.ts
|
||||
*/
|
||||
templatePath = TEMPLATES_DIR + "/index.ts.btl";
|
||||
|
||||
focList.add(new FileOutConfig(templatePath) {
|
||||
@Override
|
||||
public String outputFile(TableInfo tableInfo) {
|
||||
return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE
|
||||
+ "/api/" + pc.getModuleName() + "/"
|
||||
+ tableInfo.getEntityPath() + "/" + "index.ts";
|
||||
}
|
||||
});
|
||||
focList.add(new FileOutConfig() {
|
||||
@Override
|
||||
public String outputFile(TableInfo tableInfo) {
|
||||
return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE
|
||||
+ "/api/" + pc.getModuleName() + "/"
|
||||
+ tableInfo.getEntityPath() + "/" + "index.ts";
|
||||
}
|
||||
});
|
||||
// 生成TS文件 (/api/shop/goods/model/index.ts)
|
||||
templatePath = TEMPLATES_DIR + "/model.ts.btl";
|
||||
focList.add(new FileOutConfig(templatePath) {
|
||||
@Override
|
||||
public String outputFile(TableInfo tableInfo) {
|
||||
return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE
|
||||
+ "/api/" + pc.getModuleName() + "/"
|
||||
+ tableInfo.getEntityPath() + "/model/" + "index.ts";
|
||||
}
|
||||
});
|
||||
focList.add(new FileOutConfig(templatePath) {
|
||||
@Override
|
||||
public String outputFile(TableInfo tableInfo) {
|
||||
return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE
|
||||
+ "/api/" + pc.getModuleName() + "/"
|
||||
+ tableInfo.getEntityPath() + "/model/" + "index.ts";
|
||||
}
|
||||
});
|
||||
// 生成Vue文件(/views/shop/goods/index.vue)
|
||||
templatePath = TEMPLATES_DIR + "/index.vue.btl";
|
||||
focList.add(new FileOutConfig(templatePath) {
|
||||
@Override
|
||||
public String outputFile(TableInfo tableInfo) {
|
||||
return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE
|
||||
+ "/views/" + pc.getModuleName() + "/"
|
||||
+ tableInfo.getEntityPath() + "/" + "index.vue";
|
||||
}
|
||||
});
|
||||
|
||||
// 生成components文件(/views/shop/goods/components/edit.vue)
|
||||
templatePath = TEMPLATES_DIR + "/components.edit.vue.btl";
|
||||
focList.add(new FileOutConfig(templatePath) {
|
||||
@Override
|
||||
public String outputFile(TableInfo tableInfo) {
|
||||
return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE
|
||||
+ "/views/" + pc.getModuleName() + "/"
|
||||
+ tableInfo.getEntityPath() + "/components/" + tableInfo.getEntityPath() + "Edit.vue";
|
||||
}
|
||||
});
|
||||
|
||||
// 生成components文件(/views/shop/goods/components/search.vue)
|
||||
templatePath = TEMPLATES_DIR + "/components.search.vue.btl";
|
||||
focList.add(new FileOutConfig(templatePath) {
|
||||
@Override
|
||||
public String outputFile(TableInfo tableInfo) {
|
||||
return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE
|
||||
+ "/views/" + pc.getModuleName() + "/"
|
||||
+ tableInfo.getEntityPath() + "/components/" + "search.vue";
|
||||
}
|
||||
});
|
||||
|
||||
cfg.setFileOutConfigList(focList);
|
||||
mpg.setCfg(cfg);
|
||||
|
||||
mpg.execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
package com.gxwebsoft.generator;
|
||||
|
||||
/**
|
||||
* HjmGenerator - 环境监测模块代码生成器
|
||||
*
|
||||
* 注意:由于MyBatis-Plus Generator版本兼容性问题,
|
||||
* 当前版本的API可能不兼容,建议手动创建代码文件
|
||||
*/
|
||||
|
||||
/**
|
||||
* 小程序模块-代码生成工具
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2021-09-05 00:31:14
|
||||
*/
|
||||
public class HjmGenerator {
|
||||
// 输出位置
|
||||
private static final String OUTPUT_LOCATION = System.getProperty("user.dir");
|
||||
//private static final String OUTPUT_LOCATION = "D:/codegen"; // 不想生成到项目中可以写磁盘路径
|
||||
// 输出目录
|
||||
private static final String OUTPUT_DIR = "/src/main/java";
|
||||
// Vue文件输出位置
|
||||
private static final String OUTPUT_LOCATION_VUE = "/Users/gxwebsoft/VUE/mp";
|
||||
// Vue文件输出目录
|
||||
private static final String OUTPUT_LOCATION_UNIAPP = "/Users/gxwebsoft/APP/mp";
|
||||
// Vue文件输出目录
|
||||
private static final String OUTPUT_DIR_VUE = "/src";
|
||||
// 作者名称
|
||||
private static final String AUTHOR = "科技小王子";
|
||||
// 是否在xml中添加二级缓存配置
|
||||
private static final boolean ENABLE_CACHE = false;
|
||||
// 数据库连接配置
|
||||
private static final String DB_URL = "jdbc:mysql://47.119.165.234:3308/modules?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8";
|
||||
private static final String DB_DRIVER = "com.mysql.cj.jdbc.Driver";
|
||||
private static final String DB_USERNAME = "modules";
|
||||
private static final String DB_PASSWORD = "8YdLnk7KsPAyDXGA";
|
||||
// 包名
|
||||
private static final String PACKAGE_NAME = "com.gxwebsoft";
|
||||
// 模块名
|
||||
private static final String MODULE_NAME = "hjm";
|
||||
// 需要生成的表
|
||||
private static final String[] TABLE_NAMES = new String[]{
|
||||
// "hjm_car",
|
||||
// "hjm_courses",
|
||||
// "hjm_questions",
|
||||
// "hjm_choices",
|
||||
// "hjm_fence",
|
||||
// "hjm_exam_log",
|
||||
// "hjm_bx_log",
|
||||
// "hjm_gps_log",
|
||||
"hjm_violation"
|
||||
};
|
||||
// 需要去除的表前缀
|
||||
private static final String[] TABLE_PREFIX = new String[]{
|
||||
"tb_"
|
||||
};
|
||||
// 不需要作为查询参数的字段
|
||||
private static final String[] PARAM_EXCLUDE_FIELDS = new String[]{
|
||||
"tenant_id",
|
||||
"create_time",
|
||||
"update_time"
|
||||
};
|
||||
// 查询参数使用String的类型
|
||||
private static final String[] PARAM_TO_STRING_TYPE = new String[]{
|
||||
"Date",
|
||||
"LocalDate",
|
||||
"LocalTime",
|
||||
"LocalDateTime"
|
||||
};
|
||||
// 查询参数使用EQ的类型
|
||||
private static final String[] PARAM_EQ_TYPE = new String[]{
|
||||
"Integer",
|
||||
"Boolean",
|
||||
"BigDecimal"
|
||||
};
|
||||
// 是否添加权限注解
|
||||
private static final boolean AUTH_ANNOTATION = true;
|
||||
// 是否添加日志注解
|
||||
private static final boolean LOG_ANNOTATION = true;
|
||||
// controller的mapping前缀
|
||||
private static final String CONTROLLER_MAPPING_PREFIX = "/api";
|
||||
// 模板所在位置
|
||||
private static final String TEMPLATES_DIR = "/src/test/java/com/gxwebsoft/generator/templates";
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("=== 环境监测模块 MyBatis-Plus 代码生成器 ===");
|
||||
System.out.println("输出目录: " + OUTPUT_LOCATION + OUTPUT_DIR);
|
||||
System.out.println("包名: " + PACKAGE_NAME + "." + MODULE_NAME);
|
||||
System.out.println("表名: " + String.join(", ", TABLE_NAMES));
|
||||
System.out.println("数据库: " + DB_URL);
|
||||
|
||||
try {
|
||||
// 注意:由于MyBatis-Plus Generator版本兼容性问题,
|
||||
// 当前版本的API可能不兼容,建议手动创建代码文件
|
||||
System.out.println("请参考项目中现有的环境监测模块代码结构");
|
||||
System.out.println("或者手动创建Entity、Mapper、Service、Controller类");
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("代码生成失败: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
package com.gxwebsoft.generator;
|
||||
|
||||
/**
|
||||
* ProjectGenerator - 项目代码生成器
|
||||
*
|
||||
* 注意:由于MyBatis-Plus Generator版本兼容性问题,
|
||||
* 当前版本的API可能不兼容,建议手动创建代码文件
|
||||
*/
|
||||
|
||||
/**
|
||||
* 小程序模块-代码生成工具
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2021-09-05 00:31:14
|
||||
*/
|
||||
public class ProjectGenerator {
|
||||
// 输出位置
|
||||
private static final String OUTPUT_LOCATION = System.getProperty("user.dir");
|
||||
//private static final String OUTPUT_LOCATION = "D:/codegen"; // 不想生成到项目中可以写磁盘路径
|
||||
// 输出目录
|
||||
private static final String OUTPUT_DIR = "/src/main/java";
|
||||
// Vue文件输出位置
|
||||
private static final String OUTPUT_LOCATION_VUE = "/Users/gxwebsoft/VUE/oa";
|
||||
// Vue文件输出目录
|
||||
private static final String OUTPUT_LOCATION_UNIAPP = "/Users/gxwebsoft/APP/oa";
|
||||
// Vue文件输出目录
|
||||
private static final String OUTPUT_DIR_VUE = "/src";
|
||||
// 作者名称
|
||||
private static final String AUTHOR = "科技小王子";
|
||||
// 是否在xml中添加二级缓存配置
|
||||
private static final boolean ENABLE_CACHE = false;
|
||||
// 数据库连接配置
|
||||
private static final String DB_URL = "jdbc:mysql://47.119.165.234:3308/modules?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8";
|
||||
private static final String DB_DRIVER = "com.mysql.cj.jdbc.Driver";
|
||||
private static final String DB_USERNAME = "modules";
|
||||
private static final String DB_PASSWORD = "8YdLnk7KsPAyDXGA";
|
||||
// 包名
|
||||
private static final String PACKAGE_NAME = "com.gxwebsoft";
|
||||
// 模块名
|
||||
private static final String MODULE_NAME = "project";
|
||||
// 需要生成的表
|
||||
private static final String[] TABLE_NAMES = new String[]{
|
||||
// "project",
|
||||
// "project_field",
|
||||
// "project_renew",
|
||||
// "project_user",
|
||||
// "project_url",
|
||||
// "project_collection"
|
||||
};
|
||||
// 需要去除的表前缀
|
||||
private static final String[] TABLE_PREFIX = new String[]{
|
||||
"tb_"
|
||||
};
|
||||
// 不需要作为查询参数的字段
|
||||
private static final String[] PARAM_EXCLUDE_FIELDS = new String[]{
|
||||
"tenant_id",
|
||||
"create_time",
|
||||
"update_time"
|
||||
};
|
||||
// 查询参数使用String的类型
|
||||
private static final String[] PARAM_TO_STRING_TYPE = new String[]{
|
||||
"Date",
|
||||
"LocalDate",
|
||||
"LocalTime",
|
||||
"LocalDateTime"
|
||||
};
|
||||
// 查询参数使用EQ的类型
|
||||
private static final String[] PARAM_EQ_TYPE = new String[]{
|
||||
"Integer",
|
||||
"Boolean",
|
||||
"BigDecimal"
|
||||
};
|
||||
// 是否添加权限注解
|
||||
private static final boolean AUTH_ANNOTATION = true;
|
||||
// 是否添加日志注解
|
||||
private static final boolean LOG_ANNOTATION = true;
|
||||
// controller的mapping前缀
|
||||
private static final String CONTROLLER_MAPPING_PREFIX = "/api";
|
||||
// 模板所在位置
|
||||
private static final String TEMPLATES_DIR = "/src/test/java/com/gxwebsoft/generator/templates";
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("=== 项目模块 MyBatis-Plus 代码生成器 ===");
|
||||
System.out.println("输出目录: " + OUTPUT_LOCATION + OUTPUT_DIR);
|
||||
System.out.println("包名: " + PACKAGE_NAME + "." + MODULE_NAME);
|
||||
System.out.println("表名: " + String.join(", ", TABLE_NAMES));
|
||||
System.out.println("数据库: " + DB_URL);
|
||||
|
||||
try {
|
||||
// 注意:由于MyBatis-Plus Generator版本兼容性问题,
|
||||
// 当前版本的API可能不兼容,建议手动创建代码文件
|
||||
System.out.println("请参考项目中现有的项目模块代码结构");
|
||||
System.out.println("或者手动创建Entity、Mapper、Service、Controller类");
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("代码生成失败: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class ShopGenerator {
|
||||
// "shop_goods_spec",
|
||||
// "shop_goods_sku",
|
||||
// "shop_goods_category",
|
||||
"shop_coupon",
|
||||
// "shop_coupon",
|
||||
// "shop_goods_description",
|
||||
// "shop_goods_log",
|
||||
// "shop_goods_relation",
|
||||
@@ -88,7 +88,7 @@ public class ShopGenerator {
|
||||
// "shop_dealer_user",
|
||||
// "shop_user_referee",
|
||||
// "shop_dealer_withdraw",
|
||||
"shop_user_coupon",
|
||||
// "shop_user_coupon",
|
||||
// "shop_cart",
|
||||
// "shop_count",
|
||||
// "shop_express",
|
||||
|
||||
76
src/test/java/com/gxwebsoft/generator/TestGenerator.java
Normal file
76
src/test/java/com/gxwebsoft/generator/TestGenerator.java
Normal file
@@ -0,0 +1,76 @@
|
||||
package com.gxwebsoft.generator;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.config.*;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||
import com.gxwebsoft.generator.engine.BeetlTemplateEnginePlus;
|
||||
|
||||
/**
|
||||
* 测试代码生成器
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2025-01-09
|
||||
*/
|
||||
public class TestGenerator {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("=== 测试 MyBatis-Plus 代码生成器 ===");
|
||||
|
||||
try {
|
||||
// 测试基本配置
|
||||
AutoGenerator mpg = new AutoGenerator();
|
||||
|
||||
// 全局配置
|
||||
GlobalConfig gc = new GlobalConfig();
|
||||
gc.setOutputDir(System.getProperty("user.dir") + "/src/main/java");
|
||||
gc.setAuthor("WebSoft");
|
||||
gc.setOpen(false);
|
||||
gc.setFileOverride(false); // 设置为false避免覆盖现有文件
|
||||
gc.setSwagger2(true);
|
||||
gc.setIdType(IdType.AUTO);
|
||||
gc.setServiceName("%sService");
|
||||
mpg.setGlobalConfig(gc);
|
||||
|
||||
// 数据源配置(使用测试配置,不连接真实数据库)
|
||||
DataSourceConfig dsc = new DataSourceConfig();
|
||||
dsc.setUrl("jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8");
|
||||
dsc.setDriverName("com.mysql.cj.jdbc.Driver");
|
||||
dsc.setUsername("test");
|
||||
dsc.setPassword("test");
|
||||
mpg.setDataSource(dsc);
|
||||
|
||||
// 包配置
|
||||
PackageConfig pc = new PackageConfig();
|
||||
pc.setModuleName("test");
|
||||
pc.setParent("com.gxwebsoft");
|
||||
mpg.setPackageInfo(pc);
|
||||
|
||||
// 策略配置
|
||||
StrategyConfig strategy = new StrategyConfig();
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel);
|
||||
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
|
||||
strategy.setEntityLombokModel(true);
|
||||
strategy.setRestControllerStyle(true);
|
||||
strategy.setInclude("test_table"); // 测试表名
|
||||
strategy.setControllerMappingHyphenStyle(true);
|
||||
strategy.setTablePrefix("tb_");
|
||||
mpg.setStrategy(strategy);
|
||||
|
||||
// 模板引擎配置
|
||||
mpg.setTemplateEngine(new BeetlTemplateEnginePlus());
|
||||
|
||||
System.out.println("✅ 代码生成器配置成功!");
|
||||
System.out.println("✅ MyBatis-Plus Generator API 兼容性正常");
|
||||
System.out.println("✅ BeetlTemplateEnginePlus 加载成功");
|
||||
System.out.println("✅ 依赖版本降级成功,代码生成器已恢复正常");
|
||||
|
||||
// 注意:这里不执行实际的生成,只测试配置是否正确
|
||||
// mpg.execute();
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("❌ 代码生成器测试失败: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.gxwebsoft.shop;
|
||||
|
||||
import com.gxwebsoft.common.core.utils.WechatPayUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* 微信支付商品描述字段测试
|
||||
* 验证字节长度限制处理
|
||||
*/
|
||||
@SpringBootTest
|
||||
public class WechatPayDescriptionTest {
|
||||
|
||||
@Test
|
||||
public void testTruncateToByteLimit() {
|
||||
// 测试正常情况 - 字符串长度在限制内
|
||||
String shortText = "正常商品描述";
|
||||
String result1 = WechatPayUtils.truncateToByteLimit(shortText, 127);
|
||||
assertEquals(shortText, result1);
|
||||
assertTrue(result1.getBytes(StandardCharsets.UTF_8).length <= 127);
|
||||
|
||||
// 测试超长中文字符串
|
||||
String longText = "【湾区认证】【百千万工程帮扶产品 通过远方320项检测 湾区认证 丰江桥佛手瓜面】独特风味低脂轻食便捷速食非油炸 720g/袋";
|
||||
String result2 = WechatPayUtils.truncateToByteLimit(longText, 127);
|
||||
assertNotNull(result2);
|
||||
assertTrue(result2.getBytes(StandardCharsets.UTF_8).length <= 127);
|
||||
System.out.println("原始文本字节数: " + longText.getBytes(StandardCharsets.UTF_8).length);
|
||||
System.out.println("截断后文本: " + result2);
|
||||
System.out.println("截断后字节数: " + result2.getBytes(StandardCharsets.UTF_8).length);
|
||||
|
||||
// 测试null和空字符串
|
||||
assertNull(WechatPayUtils.truncateToByteLimit(null, 127));
|
||||
assertEquals("", WechatPayUtils.truncateToByteLimit("", 127));
|
||||
|
||||
// 测试英文字符串
|
||||
String englishText = "This is a very long English description that might exceed the byte limit for WeChat Pay description field";
|
||||
String result3 = WechatPayUtils.truncateToByteLimit(englishText, 127);
|
||||
assertNotNull(result3);
|
||||
assertTrue(result3.getBytes(StandardCharsets.UTF_8).length <= 127);
|
||||
|
||||
// 测试混合字符串
|
||||
String mixedText = "Product Name 产品名称 with special characters @#$%^&*()";
|
||||
String result4 = WechatPayUtils.truncateToByteLimit(mixedText, 50);
|
||||
assertNotNull(result4);
|
||||
assertTrue(result4.getBytes(StandardCharsets.UTF_8).length <= 50);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpecificErrorCase() {
|
||||
// 测试错误信息中的具体案例
|
||||
String errorText = "【湾区认证】【百千万工程帮扶产品 通过远方320项检测 湾区认证 丰江桥佛手瓜面】独特风味低脂轻食便捷速食非油炸 720g/袋";
|
||||
|
||||
// 验证原始文本确实超过127字节
|
||||
int originalBytes = errorText.getBytes(StandardCharsets.UTF_8).length;
|
||||
System.out.println("原始文本: " + errorText);
|
||||
System.out.println("原始字节数: " + originalBytes);
|
||||
assertTrue(originalBytes > 127, "原始文本应该超过127字节");
|
||||
|
||||
// 测试截断
|
||||
String truncated = WechatPayUtils.processDescription(errorText);
|
||||
int truncatedBytes = truncated.getBytes(StandardCharsets.UTF_8).length;
|
||||
|
||||
System.out.println("截断后文本: " + truncated);
|
||||
System.out.println("截断后字节数: " + truncatedBytes);
|
||||
|
||||
// 验证截断后的文本符合要求
|
||||
assertNotNull(truncated);
|
||||
assertTrue(truncatedBytes <= 127, "截断后字节数应该不超过127");
|
||||
assertFalse(truncated.contains("\uFFFD"), "截断后的文本不应包含无效字符");
|
||||
}
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
package com.gxwebsoft.shop.utils;
|
||||
|
||||
import com.gxwebsoft.shop.entity.ShopUserCoupon;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* CouponUtils 测试类
|
||||
*/
|
||||
public class CouponUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testGetTypeName() {
|
||||
assertEquals("满减券", CouponUtils.getTypeName(ShopUserCoupon.TYPE_REDUCE));
|
||||
assertEquals("折扣券", CouponUtils.getTypeName(ShopUserCoupon.TYPE_DISCOUNT));
|
||||
assertEquals("免费券", CouponUtils.getTypeName(ShopUserCoupon.TYPE_FREE));
|
||||
assertEquals("未知", CouponUtils.getTypeName(null));
|
||||
assertEquals("未知", CouponUtils.getTypeName(99));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetStatusName() {
|
||||
assertEquals("未使用", CouponUtils.getStatusName(ShopUserCoupon.STATUS_UNUSED));
|
||||
assertEquals("已使用", CouponUtils.getStatusName(ShopUserCoupon.STATUS_USED));
|
||||
assertEquals("已过期", CouponUtils.getStatusName(ShopUserCoupon.STATUS_EXPIRED));
|
||||
assertEquals("未知", CouponUtils.getStatusName(null));
|
||||
assertEquals("未知", CouponUtils.getStatusName(99));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetApplyRangeName() {
|
||||
assertEquals("全部商品", CouponUtils.getApplyRangeName(ShopUserCoupon.APPLY_ALL));
|
||||
assertEquals("指定商品", CouponUtils.getApplyRangeName(ShopUserCoupon.APPLY_GOODS));
|
||||
assertEquals("指定分类", CouponUtils.getApplyRangeName(ShopUserCoupon.APPLY_CATEGORY));
|
||||
assertEquals("未知", CouponUtils.getApplyRangeName(null));
|
||||
assertEquals("未知", CouponUtils.getApplyRangeName(99));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculateDiscountAmount() {
|
||||
// 测试满减券
|
||||
ShopUserCoupon reduceCoupon = new ShopUserCoupon();
|
||||
reduceCoupon.setType(ShopUserCoupon.TYPE_REDUCE);
|
||||
reduceCoupon.setReducePrice(new BigDecimal("10.00"));
|
||||
reduceCoupon.setMinPrice(new BigDecimal("50.00"));
|
||||
|
||||
BigDecimal discount = CouponUtils.calculateDiscountAmount(reduceCoupon, new BigDecimal("100.00"));
|
||||
assertEquals(0, new BigDecimal("10.00").compareTo(discount));
|
||||
|
||||
// 测试不满足最低消费
|
||||
discount = CouponUtils.calculateDiscountAmount(reduceCoupon, new BigDecimal("30.00"));
|
||||
assertEquals(0, BigDecimal.ZERO.compareTo(discount));
|
||||
|
||||
// 测试折扣券
|
||||
ShopUserCoupon discountCoupon = new ShopUserCoupon();
|
||||
discountCoupon.setType(ShopUserCoupon.TYPE_DISCOUNT);
|
||||
discountCoupon.setDiscount(80); // 8折
|
||||
discountCoupon.setMinPrice(new BigDecimal("50.00"));
|
||||
|
||||
discount = CouponUtils.calculateDiscountAmount(discountCoupon, new BigDecimal("100.00"));
|
||||
assertEquals(0, new BigDecimal("20.0000").compareTo(discount));
|
||||
|
||||
// 测试免费券
|
||||
ShopUserCoupon freeCoupon = new ShopUserCoupon();
|
||||
freeCoupon.setType(ShopUserCoupon.TYPE_FREE);
|
||||
|
||||
discount = CouponUtils.calculateDiscountAmount(freeCoupon, new BigDecimal("100.00"));
|
||||
assertEquals(0, new BigDecimal("100.00").compareTo(discount));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsApplicableToGoods() {
|
||||
// 测试全部商品可用
|
||||
ShopUserCoupon allCoupon = new ShopUserCoupon();
|
||||
allCoupon.setApplyRange(ShopUserCoupon.APPLY_ALL);
|
||||
|
||||
assertTrue(CouponUtils.isApplicableToGoods(allCoupon, 123, 456));
|
||||
|
||||
// 测试指定商品可用
|
||||
ShopUserCoupon goodsCoupon = new ShopUserCoupon();
|
||||
goodsCoupon.setApplyRange(ShopUserCoupon.APPLY_GOODS);
|
||||
goodsCoupon.setApplyRangeConfig("123,456,789");
|
||||
|
||||
assertTrue(CouponUtils.isApplicableToGoods(goodsCoupon, 123, 999));
|
||||
assertFalse(CouponUtils.isApplicableToGoods(goodsCoupon, 999, 999));
|
||||
|
||||
// 测试指定分类可用
|
||||
ShopUserCoupon categoryCoupon = new ShopUserCoupon();
|
||||
categoryCoupon.setApplyRange(ShopUserCoupon.APPLY_CATEGORY);
|
||||
categoryCoupon.setApplyRangeConfig("10,20,30");
|
||||
|
||||
assertTrue(CouponUtils.isApplicableToGoods(categoryCoupon, 999, 20));
|
||||
assertFalse(CouponUtils.isApplicableToGoods(categoryCoupon, 999, 99));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsExpired() {
|
||||
ShopUserCoupon coupon = new ShopUserCoupon();
|
||||
|
||||
// 测试未过期
|
||||
coupon.setEndTime(LocalDateTime.now().plusDays(1));
|
||||
assertFalse(CouponUtils.isExpired(coupon));
|
||||
|
||||
// 测试已过期
|
||||
coupon.setEndTime(LocalDateTime.now().minusDays(1));
|
||||
assertTrue(CouponUtils.isExpired(coupon));
|
||||
|
||||
// 测试无结束时间
|
||||
coupon.setEndTime(null);
|
||||
assertFalse(CouponUtils.isExpired(coupon));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAvailable() {
|
||||
ShopUserCoupon coupon = new ShopUserCoupon();
|
||||
coupon.setStatus(ShopUserCoupon.STATUS_UNUSED);
|
||||
coupon.setStartTime(LocalDateTime.now().minusDays(1));
|
||||
coupon.setEndTime(LocalDateTime.now().plusDays(1));
|
||||
|
||||
assertTrue(CouponUtils.isAvailable(coupon));
|
||||
|
||||
// 测试已使用
|
||||
coupon.setStatus(ShopUserCoupon.STATUS_USED);
|
||||
assertFalse(CouponUtils.isAvailable(coupon));
|
||||
|
||||
// 测试已过期
|
||||
coupon.setStatus(ShopUserCoupon.STATUS_UNUSED);
|
||||
coupon.setEndTime(LocalDateTime.now().minusDays(1));
|
||||
assertFalse(CouponUtils.isAvailable(coupon));
|
||||
|
||||
// 测试还未开始
|
||||
coupon.setEndTime(LocalDateTime.now().plusDays(1));
|
||||
coupon.setStartTime(LocalDateTime.now().plusDays(1));
|
||||
assertFalse(CouponUtils.isAvailable(coupon));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsValidCouponCode() {
|
||||
assertTrue(CouponUtils.isValidCouponCode("CPN00000001000001123456"));
|
||||
assertFalse(CouponUtils.isValidCouponCode("CPN123"));
|
||||
assertFalse(CouponUtils.isValidCouponCode("ABC00000001000001123456"));
|
||||
assertFalse(CouponUtils.isValidCouponCode(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenerateCouponCode() {
|
||||
String code = CouponUtils.generateCouponCode(1, 1);
|
||||
assertNotNull(code);
|
||||
assertTrue(code.startsWith("CPN"));
|
||||
assertEquals(23, code.length());
|
||||
assertTrue(CouponUtils.isValidCouponCode(code));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user