From 5203f988a5c3fdcfdfe3df2c147dea7f60ba0494 Mon Sep 17 00:00:00 2001 From: kuanghua <35098590+jzfai@users.noreply.github.com> Date: Fri, 10 Sep 2021 22:36:03 +0800 Subject: [PATCH 01/36] Update pom.xml --- pom.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 81763e7..916bd07 100644 --- a/pom.xml +++ b/pom.xml @@ -96,8 +96,8 @@ 127.0.0.1 df87d91b-b1ab-4720-8e1c-5a147edc6ddc nacos-group-${activatedProperties} - jzfai - kuhu8866 + admin + 123456 @@ -113,9 +113,9 @@ 127.0.0.1 df87d91b-b1ab-4720-8e1c-5a147edc6ddc nacos-group-${activatedProperties} - jzfai - kuhu8866 + admin + 123456 - \ No newline at end of file + From eab6764f6d3f3bfbd0f8793b58a97e07061608d4 Mon Sep 17 00:00:00 2001 From: kuanghua <35098590+jzfai@users.noreply.github.com> Date: Fri, 10 Sep 2021 22:43:37 +0800 Subject: [PATCH 02/36] Update pom.xml --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 916bd07..ee3bcb9 100644 --- a/pom.xml +++ b/pom.xml @@ -96,7 +96,7 @@ 127.0.0.1 df87d91b-b1ab-4720-8e1c-5a147edc6ddc nacos-group-${activatedProperties} - admin + jzfai 123456 @@ -113,7 +113,7 @@ 127.0.0.1 df87d91b-b1ab-4720-8e1c-5a147edc6ddc nacos-group-${activatedProperties} - admin + jzfai 123456 From 70cb9ada7e8be45e89fb838eeeb0f6e3ce27d54c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=9D=E5=8D=8E?= Date: Wed, 15 Sep 2021 17:45:28 +0800 Subject: [PATCH 03/36] add env modal ty-upload --- README.md | 104 ++- controller.mv | 136 ++++ element-form.mv | 302 +++++++++ element-table.mv | 295 +++++++++ entity.mv | 46 ++ mapper.mv | 19 + nacos_config_export_20210915163624.zip | Bin 0 -> 9322 bytes oldElementDemo.mv | 512 +++++++++++++++ pom.xml | 18 + service.mv | 54 ++ .../tyauth/config/Swagger2Config.java | 4 +- .../kuanghua/tyauth/utils/JwtUtilsSelf.java | 8 +- ty-auth/src/main/resources/application.yml | 17 +- .../gatewaytwo/config/SwaggerDocConfig.java | 21 + .../gatewaytwo/config/SwaggerProvider.java | 23 +- .../src/main/resources/application.yml | 49 +- ty-upload/pom.xml | 50 ++ .../kuanghua/tyupload/UploadApplication.java | 18 + .../kuanghua/tyupload/config/BaseConfig.java | 21 + .../tyupload/config/Swagger2Config.java | 52 ++ .../tyupload/controller/NacosTestDemo.java | 44 ++ .../tyupload/controller/UploadController.java | 83 +++ .../tyupload/service/UploadService.java | 90 +++ ty-upload/src/main/javabrandE/BrandE.vue | 266 ++++++++ ty-upload/src/main/javabrandE/BrandEForm.vue | 227 +++++++ ty-upload/src/main/main11.iml | 13 + ty-upload/src/main/resources/application.yml | 0 ty-upload/src/main/resources/bootstrap.yml | 35 + .../controller/UploadControllerTest.java | 28 + ty-upload/src/test/test2.iml | 11 + ty-upload/ty-upload.iml | 230 +++++++ .../tyuser/controller/BrandController.java | 129 ++++ .../tyuser/controller/UserController.java | 31 +- .../top/kuanghua/tyuser/element/Access.vue | 536 --------------- .../java/top/kuanghua/tyuser/element/User.vue | 617 ------------------ .../top/kuanghua/tyuser/entity/Brand.java | 50 ++ .../java/top/kuanghua/tyuser/entity/Role.java | 1 - .../kuanghua/tyuser/mapper/BrandMapper.java | 8 + .../kuanghua/tyuser/service/BrandService.java | 51 ++ .../java/top/kuanghua/tyuserbrand/Brand.vue | 276 ++++++++ .../top/kuanghua/tyuserbrand/BrandForm.vue | 227 +++++++ .../java/top/kuanghua/tyuserbrandE/BrandE.vue | 266 ++++++++ .../top/kuanghua/tyuserbrandE/BrandEForm.vue | 227 +++++++ 43 files changed, 3976 insertions(+), 1219 deletions(-) create mode 100644 controller.mv create mode 100644 element-form.mv create mode 100644 element-table.mv create mode 100644 entity.mv create mode 100644 mapper.mv create mode 100644 nacos_config_export_20210915163624.zip create mode 100644 oldElementDemo.mv create mode 100644 service.mv create mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerDocConfig.java create mode 100644 ty-upload/pom.xml create mode 100644 ty-upload/src/main/java/top/kuanghua/tyupload/UploadApplication.java create mode 100644 ty-upload/src/main/java/top/kuanghua/tyupload/config/BaseConfig.java create mode 100644 ty-upload/src/main/java/top/kuanghua/tyupload/config/Swagger2Config.java create mode 100644 ty-upload/src/main/java/top/kuanghua/tyupload/controller/NacosTestDemo.java create mode 100644 ty-upload/src/main/java/top/kuanghua/tyupload/controller/UploadController.java create mode 100644 ty-upload/src/main/java/top/kuanghua/tyupload/service/UploadService.java create mode 100644 ty-upload/src/main/javabrandE/BrandE.vue create mode 100644 ty-upload/src/main/javabrandE/BrandEForm.vue create mode 100644 ty-upload/src/main/main11.iml create mode 100644 ty-upload/src/main/resources/application.yml create mode 100644 ty-upload/src/main/resources/bootstrap.yml create mode 100644 ty-upload/src/test/java/top/kuanghua/tyupload/controller/UploadControllerTest.java create mode 100644 ty-upload/src/test/test2.iml create mode 100644 ty-upload/ty-upload.iml create mode 100644 ty-user/src/main/java/top/kuanghua/tyuser/controller/BrandController.java delete mode 100644 ty-user/src/main/java/top/kuanghua/tyuser/element/Access.vue delete mode 100644 ty-user/src/main/java/top/kuanghua/tyuser/element/User.vue create mode 100644 ty-user/src/main/java/top/kuanghua/tyuser/entity/Brand.java create mode 100644 ty-user/src/main/java/top/kuanghua/tyuser/mapper/BrandMapper.java create mode 100644 ty-user/src/main/java/top/kuanghua/tyuser/service/BrandService.java create mode 100644 ty-user/src/main/java/top/kuanghua/tyuserbrand/Brand.vue create mode 100644 ty-user/src/main/java/top/kuanghua/tyuserbrand/BrandForm.vue create mode 100644 ty-user/src/main/java/top/kuanghua/tyuserbrandE/BrandE.vue create mode 100644 ty-user/src/main/java/top/kuanghua/tyuserbrandE/BrandEForm.vue diff --git a/README.md b/README.md index 1b4dfb3..7bb514f 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,108 @@ -### 简介: - +#### 更新日志 ``` -vue3-admin-template 的数据来源 -涉及到的功能:jwt 权限校验,token过期,续约(有效期为3天,少于一天自动更新token),文件导入和上传, -用户相关操作等,多环境切换(dev,prod)等 +// 2021-09-15 +1.增加了文件上传下载,为vue3-element-plus提供例子数据 ``` -##### 使用的技术: - +### 前言 ``` +本架构使用的技术为: spring-boot:2.1.4.RELEASE spring-cloud:Greenwich.SR1 spring-cloud-starter-gateway:2.1.1.RELEASE nacos:2.1.3.RELEASE mybatis-plus: 3.3.2 -rabbitmq 等 +rabbitmq:3.7-management +redis: 3.2.9 +mysql:5.7 +``` + +#### swager文档地址: + +http://8.135.1.141/micro-service-doc/swagger-ui.html + +#### nacos地址(naocs配置请不要删除): + +http://8.135.1.141:8848/nacos/ + +用户名:jzfai +密码:123456 + +#### 微服务(后续还会新增新的微服务) + +``` +ty-common: 统一依赖,统一配置管理,feign接口整合等 +本架构的微服务有: +ty-gateway:网关微服务。使用的是spring-cloud-starter-gateway,先对于zull网关来说性能更好。主要实现了,权限控制和拦截,jwt token解析和校验,swagger文件整合,使用令牌技术请求限流等 +ty-auth:权限服务。jwt token生成,解析,校验等,默认配置3天有效期,少于一天自动续约(此处感兴趣的可以查看下源码) +ty-user:用户服务。用户的登录,注册,查看用户信息等一系列功能 +ty-upload:文件上传服务。使用的技术为fastDFS技术,此服务主要用于文件的上传和下载 +``` + +#### 亮点: + +``` +1.在网关中将jwt token和解析后的token信息已经设置在请求头中,在后续转发的微服务可以在请求头中轻松的拿到token和token解析后的数据,不用再通过feign去调用ty-auth获取token信息 +``` + +![1631692199271](http://8.135.1.141/file/images/1631692199271.png) + +``` +2.此时微服务已经可以在请求通中获取到token和信息,但是feign调用其他微服务的时候却出现了token丢失的情况,此时需要在feign调用服务时将请求头一起转发,那么微服务之前调用时也能获取都token和信息 +``` + +![1631692308212](http://8.135.1.141/file/images/1631692308212.png) + +``` +3.少于1天时间自动更新token,主要通过gateway的两个拦截器来完成 +AuthorizeFilterBefore:请求前拦截。解析token的有效性和是否过期,和配置了白名单的请求方法进行放行 +AuthorizeFilterAfter:请求后拦截。主要用于token更新校验,和生产新的token,通过isNeedUpdateToken字段告诉前端要更新token +如果想知道前端如何更新token可查看: +https://github.com/jzfai/vue3-admin-template +``` + +![1631693000767](http://8.135.1.141/file/images/1631693000767.png) + +``` +4.多环境和nacos: +开发人员可以快速的切换环境以达到开发的目的 +目前为止只添加了 +dev:开发时使用的分支 +prod:发布是切换的分支 +注:配置环境时请在nacos上添加相应的配置文件,不然会报错 +nacos: +注册中心: +通过discovery进行配置,具体可查看源码 +配置中心: +加载顺序:naocs默认加载的config配置文件-> shared-configs->extension-configs +优先级:naocs默认加载的config配置文件->extension-configs-> shared-configs +``` + +![1631693866876](http://8.135.1.141/file/images/1631693866876.png) + +![1631694125676](http://8.135.1.141/file/images/1631694125676.png) ``` -#### swagger文档 http://8.135.1.141:30156/swagger-ui.html -#### 感兴趣可以看下 +5.easycode模板配置: +本架构提供了基本的版本生成,可以快速生成,实现前后端的增删改查,前端的easycode生成的模板适配vue-element-template架构,可以把模板直接复制到easycode中生成相应的代码 +不会使用easycode可以查看这里 +https://www.jianshu.com/p/e4192d7c6844 +``` + +![1631695768271](http://8.135.1.141/file/images/1631695768271.png) + +### 如何运行 + +```javascript +克隆项目 +git clone https://github.com/jzfai/micro-service-plus.git +用idea打开项目,加载下载依赖即可运行 +``` + +>注:本项目加入了热更新:运行项目后,使用ctrl+F9快捷键或rebuild下就行直接更新服务 +#### 如果需要实时交流的可以加入wx群(有vue3+ts视频教程) + ![http://8.135.1.141/file/images/wx-groud.png](http://8.135.1.141/file/images/wx-groud.png) +大家的支持是我前进的动力 欢迎加入一起开发 diff --git a/controller.mv b/controller.mv new file mode 100644 index 0000000..8b019d4 --- /dev/null +++ b/controller.mv @@ -0,0 +1,136 @@ +##导入宏定义 +$!init +$!define + +##设置表后缀(宏定义) +#setTableSuffix("Controller") + +##保存文件(宏定义) +#save("/controller", "Controller.java") + +##包路径(宏定义) +#setPackageSuffix("controller") + +##定义服务名 +#set($serviceName = $!tool.append($!tool.firstLowerCase($!tableInfo.name), "Service")) + +##定义实体对象名 +#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.api.ApiController; +import com.baomidou.mybatisplus.extension.api.R; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +##import $!{tableInfo.savePackageName}api.entity.$!tableInfo.name; +import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.io.Serializable; +import java.util.*; + +##表注释(宏定义) +@Api(tags = "$!{tableInfo.comment}($!{tableInfo.name})") +@RestController +@RequestMapping("$!tool.firstLowerCase($!tableInfo.name)") +public class $!{tableInfo.name}Controller { + +@Resource +private $!{tableInfo.name}Service $!{serviceName}; + +/** +* 分页查询所有数据 +* @param $!entityName 查询实体 +* @return 所有数据 +*/ +@GetMapping("selectPage") +@ApiOperation(value = "分页查询所有数据") +public ResResult selectPage($!{tableInfo.name} $!entityName, KHCommonParams khCommonParams) { +QueryWrapper<$!{tableInfo.name}> queryWrapper = new QueryWrapper<>(); +#foreach($column in $tableInfo.fullColumn) + #if( $!column.comment ) + if(ObjectUtils.isNotEmpty($!{entityName}.get$!{tool.firstUpperCase($column.name)}())) { + queryWrapper.or().like("$!{column.name}",$!{entityName}.get$!{tool.firstUpperCase($column.name)}()); + } + #end +#end + +#set($StringBj="") +#foreach($column in $tableInfo.fullColumn) + #if( $!column.comment ) + #set($StringBj=$!{StringBj}+$!{tool.hump2Underline($column.name)}+",") + #end +#end + + +queryWrapper.or().orderByDesc("create_time"); +if(StringUtils.isNotEmpty(commonParams.getStartTime())) { + queryWrapper.or().between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); +} +queryWrapper.select("$StringBj.substring(0,$StringBj.lastIndexOf(','))"); +Page<$!{tableInfo.name}> $!{entityName}Page = this.$!{entityName}Service.selectPage(khCommonParams.getPageNum(), khCommonParams.getPageSize(), queryWrapper); +return new ResResult().success($!{entityName}Page); +} + +/** +* 通过主键查询单条数据 +* @param id 主键 +* @return 单条数据 +*/ +@GetMapping("selectById") +@ApiOperation(value = "通过id主键查询单条数据") +public ResResult selectById(@RequestParam("id") Integer id) { +return new ResResult().success(this.$!{serviceName}.selectById(id)); +} + +/** +* @Description: 根据id数组查询品牌列表 +* @Param: idList id数组 +* @return: ids列表数据 +*/ +@ApiOperation(value = "根据id数组查询品牌列表") +@PostMapping("selectBatchIds") +public ResResult selectBatchIds(@RequestParam("idList") List + idList) { + return new ResResult().success(this.$!{serviceName}.selectBatchIds(idList)); + } + /** + * 新增数据 + * @param $!entityName 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping("insert") + public ResResult insert(@RequestBody $!{tableInfo.name} $!entityName) { + return new ResResult().success(this.$!{serviceName}.insert($!entityName)); + } + + /** + * 修改数据 + * @param $!entityName 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "根据id修改数据") + @PutMapping("updateById") + public ResResult updateById(@RequestBody $!{tableInfo.name} $!entityName) { + return new ResResult().success(this.$!{serviceName}.updateById($!entityName)); + } + + /** + * 删除数据 + * @param idList 主键结合 + * @return 删除结果 + */ + @ApiOperation(value = "根据id数组删除数据") + @DeleteMapping("deleteBatchIds") + public ResResult deleteBatchIds(@RequestBody List + idList) { + return new ResResult().success(this.$!{serviceName}.deleteBatchIds(idList)); + } + + @DeleteMapping("deleteById") + @ApiOperation(value = "根据id数组删除数据") + public ResResult deleteById(@RequestParam("id") Integer id) { + return new ResResult().success(this.$!{serviceName}.deleteById(id)); + } + } \ No newline at end of file diff --git a/element-form.mv b/element-form.mv new file mode 100644 index 0000000..01d87bb --- /dev/null +++ b/element-form.mv @@ -0,0 +1,302 @@ +##导入宏定义 +$!init +$!define +##定义实体对象名 +#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) +#set($serviceName = 'ty-user') + +##保存文件(宏定义) +#save($!{entityName}, "Form.vue") + + + + + diff --git a/element-table.mv b/element-table.mv new file mode 100644 index 0000000..69f97a5 --- /dev/null +++ b/element-table.mv @@ -0,0 +1,295 @@ +##导入宏定义 +$!init +$!define +##定义实体对象名 +#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) +#set($serviceName = 'ty-user') + +##保存文件(宏定义) +#save($!{entityName}, ".vue") + + + + + diff --git a/entity.mv b/entity.mv new file mode 100644 index 0000000..50c90eb --- /dev/null +++ b/entity.mv @@ -0,0 +1,46 @@ +##导入宏定义 +$!init +$!define + +##保存文件(宏定义) +#save("/entity", ".java") + +##包路径(宏定义) +#setPackageSuffix("entity") + +##自动导入包(全局变量) +##$!autoImport +import com.baomidou.mybatisplus.extension.activerecord.Model; +import java.io.Serializable; + +##表注释(宏定义) +#tableComment("表实体类") +@Data +@ApiModel("$!tableInfo.comment") +@TableName(value = "tb_$!{tool.firstLowerCase($tableInfo.name)}") +public class $!{tableInfo.name} extends Model<$!{tableInfo.name}> { +#foreach($column in $tableInfo.fullColumn) + #if( $!column.comment ) + #set($listSize=$!{column.comment.split(';')}) + #if( $!listSize.size() > 0 ) + @ApiModelProperty(value="$!listSize[0]") + #end + #end +private $!{tool.getClsNameByFullName($column.type)} $!{column.name}; +#end +###foreach($column in $tableInfo.fullColumn) +###getSetMethod($column) +###end +#foreach($column in $tableInfo.pkColumn) + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.$!column.name; + } + #break +#end +} \ No newline at end of file diff --git a/mapper.mv b/mapper.mv new file mode 100644 index 0000000..ec158b1 --- /dev/null +++ b/mapper.mv @@ -0,0 +1,19 @@ +##导入宏定义 +$!init +$!define + +##设置表后缀(宏定义) +#setTableSuffix("Mapper") + +##保存文件(宏定义) +#save("/mapper", "Mapper.java") + +##包路径(宏定义) +#setPackageSuffix("mapper") + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +##表注释(宏定义) +public interface $!{tableName} extends BaseMapper<$!tableInfo.name> { + +} \ No newline at end of file diff --git a/nacos_config_export_20210915163624.zip b/nacos_config_export_20210915163624.zip new file mode 100644 index 0000000000000000000000000000000000000000..9c9820fd9dd360042a70a6fa890b9834d6db4696 GIT binary patch literal 9322 zcmeHMWmJ`0x29W>Zlu}L-7Q@L8w5nULt@h{UD6;Wn=WaPlrHH8=@bx98j-%>J!c4< z@96jaxntaW&)nl3W3PAY@$5C{TI-q5oJ&Cl8U_;r0RaKxl`kU@;)ao5eYe!rx3Z-- z23gr#(;FB%FzQ-cTbSzW+L>BeUXK}^Us$*Ud*r8uFlWhkQOSoi4dVbSE1EdDBmo}<}l)L?47oe6O)lHHLY+wzjrvw8sb^mQcRKXV&9qG@(G1n z(os?Wc`Rk9>;rnhSGasXHJUlwvD}c?Tw8kN(e|aeYpFdk>WMv~L>kzol$q$0eGoO2 z&(yz}33?ZbU5+?zFR^k#JY`!AZhn?P00J_?#OlFW@(0KMeah|!6o~f+BG!Z1RU!Krr zzBAZ1KN(9I%n`SNC){CJOKmIRSyqh`hV)o^TgJUQVMk+`sJFqxF**$w#pb}CQ{fYo zOcqRVPmVx1kOkO!se|A}HWAS!^?Aj5qidpbAE(u^ReqdGtv;?9zS%BWkz9;Dlm+UA zDjteGV}TQ3A&aZpxq=u>`2BdqD6jXcF9&B)w}<=Kz(Y{?EFQpZe{vF0J8$ zy$v6~#QRXxYG+qMWRzOrBg>c&JsbV0a|`@+OI`8{7e>X9n%G-7x|nn&Tr>*NWN9Qw z4_R9WPSrENhEw6U%8ZFgUmDij!TTQk+f&(Mp|9NbU_@wECyc_fB6hG)u#+iXXPQh@ zQbKQviX)9+tg27VI@&ZGVV$Rv!1CX#8bO(7^Pg7JkO!05{ZN=zE zGyBlUQbNywIv-Jn&=*+iX|gmSnBL>!BdQGzyN{Y#Y81^SK=Nv@6n8nY&zB-6K1;lE zuHmBdO%}#Px{dIIVH^2jlSFI$)YJat%_l9W6&d1%gSmyL@G@IIDprfs#b?TVGqx#p z=KaKk<1$<0{zpqgy60QE=M9%d2o8PU~M#nv76hkzx4vqX(byR@fsTJ5tm@5@yjYsnmlCB6)`r=OGv;?22g z_s$$3SBdXs%-_p+Bzx=>0b$EE0g3c+Qk}z(id5yza9}7KkMQ7n*hK#Ffpg$;J-)*1 z5M?y8T-iE1pbbaC3*dNkST6noh-vjb7Jsx^lP)k8XLrcraJ!`sfTfuGa2&@aI^b}A z2HyPQfN_B~xLDL3t~WUusl2ngh0rI1HMbbqJxr2E4)Z=ahh@^JLdEy$%}+tm)CX=z zwq`Qfs}s68b{2_D)%d`seiVXLj(A;+{el?`qHk~T5HB&fHIYfark9OQxPFuYks0Ij719Nu4hUz6v#F6{H;$p?XxX;0& z4o~eQfXh9IlEXLe{hWpHTw92w5Yvc9B>}n&$soa7>Xq;gd_N>xMk(evg&&@2Vi0_} zW=!R5jadx-UVhbCp}Lj5RBv&+w7mOg)IjkURq91f#g6U6{Jv2j4Rc?AxO3i3J?Fea zg2V0?5$`poz8yUbS=t!X(Qr(ep$ax%vKNl2()k2DHLHRHu)s3`}-!#QfUaq=Jp_Ig2&GDO!rl{_v@P{4uoM zI)8452hXCKUS56)QYPK~@t23Di=RL>3TE^mHIJ=n_V{HroCi^&p)X$%D4AU|nSZW)p zM>|+h^sTE-jl@V#%S6efEqSrB=Fdm#{I;Yi*yZz&#B>Vd zoGyu_YkKuY7yV4>K^9I7+y0azs9IG8wuYH7XrZ;rk|Fs_VXcGtO=q2Km*r#8$_TaR z0*4|M&E=1Wf%2SB6nn}oMu1c;5Z?Rn*FNP1E|a~ynsNKp^Y?5|`8%Hs4NPsXU7}?G zboa_sEv+ai0Ho!*=-|pRFDoGPothu3!ASS}f{mEChQ*W!)&82qfgnBNZemSTRWN6V}S*g71D> zu26rk#W*?5q)ZfKDNfsbbZdHhse&FdC@5Y9Xq$J{zEMWAZc-VAR^k@n}$R_ z@w6;i^pf26yiK8u(*{GeM0X*K_{^|kBx7uLY_^>)2|r=NfCxx_A&g+2$o;4jhQM2T zcr^7s`@QBjB$aYwf#HPHl%>{A@74yuFw^k5_MCu}ite0?xZ@qiuK5YGBF}|DRqdS( z;NpyFzT3={X2_nFzTuk$&b7P=Qjw{5_9zuAx`=r(sc%gTM2GEznEOGw^1fBskOBg7 z^)6hvWAhma2`G(_Gm6ZiYQvNBw20vIZRb`J z8tZZ+5z}E;l6A6hW!hbf@a>1tKWJJQlrdl*^4TS@$k-<2>i3XU`YMyX$0Ml{%a_qQ zmnf-O@I2W{_Jo6P3SPB%q*iGCxQL)V^;vgQA+^oLc=nEUZH;D)r5ghs$N>d$musLJMh|9d71E1H6nbq4tdmD4t_nkUOj5vyCT6k6uik zCVG6OKFCv_f`hLMQ3o&=$emVDD!fdoero~d=ICpe1IlWC@OK#zis~p@edowj%AH<4 zG&ntY(?H*^1(+Uuk^O zw*0VAVe2sAs~A4EEW0;a57VetCl9W!8n#38eZsjD-Zo{?V^^9K)v0Bwx%+1 zWyGw~j?N#9LxdfV^Ls6Jw?g^LxiI)gjQu0V{t;vUh_U~7VvPEZaQO>0{%=%ccNOMe zo%$b6%niEJo@ZkI|NT)`LrNEqIOSl$0+a#4o?-e zMoxJ$jT*cN@4TDseD79oH*6^c87GfOV5?tmW0%x3n2hXhdMn^F=EB_O!av$?F*p&Q=g2V)dI(4v`7q)F>O?`{zL`Ouj#)q}7y@{Y<#2iTs`9E~9v8fVFUem&P8J{Y@_scIgoh_csZ2thF0Qos zYE@vIus_+jJLd%V`s?5a|loJPI4$a`PwzbGwq@3Ocs^X$gM@7ETpsc+S<8<`3UR&ysRfDr)V4CDJG}v*73Q{zSfSL@nHBf>|&Ez2xyD0 z+?CZpOyW0-F#a8|taw|HQlVM>-wnz5Ah3N-v+W!Cg^;Hv0Q2y_XcXUFg3sD9Ii;95;v4^fwmD5 zMdjB;#(Aw_cuvnwog&rI+eq}~kydr~F(;P}X?6E0FohFXHVLH=EpX+6K{kpZJa1^t z9uPrAU{Tf(b)_%Y1T()&P~@{oUGO8(pz(%Nij+t=g=q1(-18 zSA=?lFYD|sHQn9O#DaL6PdD^peCu%aMp!sD=*~WS(Hid>0t#25MwUri$jTYTm{iVKF-;7c&pG47_V8#NXs=QLb zhU`-;a<}f$4lk9C^#TVhi`K=0DlYdBZ#iUa++9*FFOi2@cGa7RfkY3CHeVYzF+V1X z_~yV$w|-)@X2Q-jLqrthAYVF4h zvIA2AqWy&~=+q)<6K{B8eZKBuxN9=B;TK9l-Wxmm}aOUUcGkOMBDxEvY+ zf(Y?fb>Y8Mp8tvi=KtUTPqj>uXBi=1*!o(9Qx}4jHby%fz|x5M?}tpg*1y$O8LQ(8 zR-0~6OpGGh5C*_-E?~zhaQjhVJ78Y2)DV--NBC0jMrSQ$GQt$3+H zrah5=ummEt-|NEXqAjWeI5($)AYULujprCQRI_k1b1&9-bH4_0T5Kh4;E-N{W>P+< z3_4Nc7*LvCXxW^K@ZMD4`V_x{OoQimq9DTHmI6*ZSrloEjG#cYv|^(jvtFafy%;JW zOK6}-0zTBlX8A)l&|hQovV_)F&4ex zP-CBe*38tGvAnaL@+?UMml1Uow)2}Xj&%#|myCE&=}E6=8x&cA{rD6b76 z&SaTH;4`|_00A9Xd}^AYY<8$VZ&??VOi2P0`fSdk!1$O?+6V!`BGat=M_Q+M_4q2N*|++QZr4uYpCkV zD(=lKYP$2sc(omp+^5&cXJ`o*Z~~!eb9_KTfsQcXvu&M?D?Cr$8G~yc3e~UDnzfvJ zTLC_M=IM%kR`$eNXWZO4G+@OEyu{b5INB?gXT_kPdrvMaNnseqX(o(8FiNt>y=%rQ z?cD@NA?p1a01?Dow(L z8%Sa6pmD8(xdIzCYm;%fa@GNIAX=HG)7T1_F?B7F=|hP-1`mq85dLWeAZz-4UwPlo zfi;M%=#5^UGw~Q+PQ7a8YgjTvP^*mCi!uc4{Xro8Dwh_)BUCKobSc&zIZ4D766r@8 zS9CBJ_oz-=sB`lz=d#3J(t=6R0s~aREFu&kfI*^@ef7JdmNA1in5wI~g|&GxWpQqE zd`__W+%?o^-sk;vD2_yP^777*43_-4SP;8;uDV~FY7rB3k)kTKxy`dF{&2q!tr%qW zXM9eTagz3mW3GV#;T)Se#hYWUhn$U+WKQRT*KE*xstvBcVgu%1vcX+la`&dp-rB-S z_eX<9Mn;OZ@<)@X|08`@uUsD^eW?-?8#|M-!c(Wx!o$gf7eWW16YPknPiJ*?qo2@y zc~}F>&iBEG^kS;dqZAX9GLsUL;=yLH$_H)(-D|)&f#iBrikwshaDq}4Bnw1KpJbox z0KjWkCKx@s92jC}%Mv0Z(e0AnvyH}(fqJP2DVA3O=kM?TquurH!+`1Ol`>_8 z{1v(WR=fTa&;KZ%1b1qI>+N}!t90${On$U3<>_f;=*xcW%1%a_QYD2v`94}&zz}WM zfSf!XB1AAOX4W`9Eii|(kN(_Uyqm50Yij*zObEZm`&rc9#k|>Qzi#UPG?*)D z|J58pf7Xc@nao>(4Ams@hdM6Luo!w2KYufy2 gW5l +
+ +
+ +
+ 新增 + 批量删除 + +
+ + + #foreach($column in $tableInfo.otherColumn) + #if(${column.comment}) + + + + #end + #end + + 搜索 + +
+ + + + + + #foreach($column in $tableInfo.otherColumn) + #if(${column.comment}) + + #end + #end + + + + + + +
+ +
+ + + + #foreach($column in $tableInfo.otherColumn) + #if(${column.comment}) + #if( $column.comment.indexOf("time") != -1 || $column.name.indexOf("Time") != -1 ) + + + + + #elseif( $column.comment.indexOf("upload") != -1 || $column.name.indexOf("image") != -1) + + + + + +
将文件拖到此处,或点击上传
+
只能上传jpg/png文件,且不超过2M
+
+ 上传 +
+ #elseif( $column.comment.indexOf("option") != -1 ) + + + + + + + #elseif( $column.comment.indexOf("checkbox") != -1 ) + + + {{item.name}} + + + + #elseif( $column.comment.indexOf("radio") != -1 ) + + + 昨日 + 今日 + + + #else + + + + #end + #end + #end +
+ + 取 消 + 确 定 + +
+
+ + + + + + + + diff --git a/pom.xml b/pom.xml index ee3bcb9..b3cec92 100644 --- a/pom.xml +++ b/pom.xml @@ -13,6 +13,7 @@ ty-gateway ty-auth ty-user + ty-upload @@ -117,5 +118,22 @@ 123456 + + + + + + + + + + + + + + + + + diff --git a/service.mv b/service.mv new file mode 100644 index 0000000..4658d24 --- /dev/null +++ b/service.mv @@ -0,0 +1,54 @@ +##导入宏定义 +$!init +$!define + +##设置表后缀(宏定义) +#setTableSuffix("Service") + +##保存文件(宏定义) +#save("/service", "Service.java") +##定义服务名 +##定义实体对象名 +#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) +##包路径(宏定义) +#setPackageSuffix("service") +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +/** +* ($!{tableInfo.name}) +* @author kuanghua +* @since $time.currTime() +*/ +@Service +public class $!{tableInfo.name}Service{ + + @Resource + private $!{tableInfo.name}Mapper $!{entityName}Mapper; + + public Page<$!{tableInfo.name}> selectPage(Integer pageNum, Integer pageSize, QueryWrapper<$!{tableInfo.name}> queryWrapper) { + return this.$!{entityName}Mapper.selectPage(new Page<$!{tableInfo.name}>(pageNum, pageSize),queryWrapper); + } + + public $!{tableInfo.name} selectById(Integer id) { + return this.$!{entityName}Mapper.selectById(id); + } + + public List<$!{tableInfo.name}> selectBatchIds(List idList) { + return this.$!{entityName}Mapper.selectBatchIds(idList); + } + + public int insert($!{tableInfo.name} $!{entityName}) { + return this.$!{entityName}Mapper.insert($!{entityName}); + } + + public int updateById($!{tableInfo.name} $!{entityName}) { + return this.$!{entityName}Mapper.updateById($!{entityName}); + } + + public int deleteById(Integer id) { + return this.$!{entityName}Mapper.deleteById(id); + } + + public int deleteBatchIds(List idList) { + return this.$!{entityName}Mapper.deleteBatchIds(idList); + } +} \ No newline at end of file diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java b/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java index 24084cd..a7913b0 100644 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java +++ b/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java @@ -43,9 +43,9 @@ public Docket api() { private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("标题:kuanghua") - .description("描述:自定义的一个项目") + .description("描述:新一代的前端架构") .contact(new Contact("jzfai", null, "869653722@qq.com")) - .version("版本号:2.8") + .version("版本号:2.9") .build(); } /** diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/utils/JwtUtilsSelf.java b/ty-auth/src/main/java/top/kuanghua/tyauth/utils/JwtUtilsSelf.java index 09ed103..bd38ef3 100644 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/utils/JwtUtilsSelf.java +++ b/ty-auth/src/main/java/top/kuanghua/tyauth/utils/JwtUtilsSelf.java @@ -20,12 +20,12 @@ * @since 1.0 */ public class JwtUtilsSelf { - //有效期为 - public static final Long JWT_TTL = 3600000L;// 60 * 60 *1000 一个小时 + //https://www.cnblogs.com/passedbylove/p/11207827.html + //有效期为 + public static final Long JWT_TTL = 259200000L;//60 * 60 * 1000 * 24 * 3 三天 //Jwt令牌信息 - public static final String JWT_KEY = "@Kuanghua8866"; - + public static final String JWT_KEY = "kh@Login(Auth}*^31)&kuanghua%"; /** * 生成令牌 //* @param id diff --git a/ty-auth/src/main/resources/application.yml b/ty-auth/src/main/resources/application.yml index 665ff63..8290243 100644 --- a/ty-auth/src/main/resources/application.yml +++ b/ty-auth/src/main/resources/application.yml @@ -1,10 +1,9 @@ -server: - port: ${envpt.tomcatPortPre}0131 - -#jwt相关 -jwt-properties: - secret: ruixiude@Login(Auth}*^31)&kuanghua% # 登录校验的密钥(盐) - expire: 4320 # 过期时间,单位分钟 - cookieName: KH_TOKEN - cookieMaxAge: 1800 +#server: +# port: ${envpt.tomcatPortPre}0131 +# +##jwt相关 +#jwt-properties: +# secret: kh@Login(Auth}*^31)&kuanghua% # 登录校验的密钥(盐) +# # 60 * 60 * 1000 * 24 * 3 三天 +# expire: 259200000L; diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerDocConfig.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerDocConfig.java new file mode 100644 index 0000000..6a125b4 --- /dev/null +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerDocConfig.java @@ -0,0 +1,21 @@ +package top.kuanghua.gatewaytwo.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; + +import java.util.*; +/** + * @Title: SwaggerDocConfig + * @Description: + * @Auther: kuanghua + * @create 2021/9/14 13:36 + */ + +@Component +@ConfigurationProperties(prefix = "swagger-doc") +@Data +public class SwaggerDocConfig { + private Map serviceMap; +} diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerProvider.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerProvider.java index 81f200b..6cee91e 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerProvider.java +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerProvider.java @@ -21,9 +21,12 @@ @AllArgsConstructor public class SwaggerProvider implements SwaggerResourcesProvider { - public static final String API_URI = "/v2/api-docs"; + static final String API_URI = "/v2/api-docs"; private final RouteLocator routeLocator; private final GatewayProperties gatewayProperties; + + + private SwaggerDocConfig swaggerDocConfig; /** * @return */ @@ -31,16 +34,22 @@ public class SwaggerProvider implements SwaggerResourcesProvider { public List get() { List resources = new ArrayList<>(); //List routes = new ArrayList<>(); - routeLocator.getRoutes().subscribe(route -> { + swaggerDocConfig.getServiceMap().entrySet().stream().forEach(mapEntry -> { + /*设置swagger服务路径*/ + resources.add(createResource(mapEntry.getValue().toString(), mapEntry.getKey(), "2.9")); + }); + +// routeLocator.getRoutes().subscribe(route -> { // System.out.println("routeLocator"); // System.out.println(route); - }); - gatewayProperties.getRoutes().stream().forEach(item -> { +// route.getId(); +// }); +// gatewayProperties.getRoutes().stream().forEach(item -> { // System.out.println("gatewayProperties"); +// item.getId(); // System.out.println(item); - }); - /*设置swagger服务路径*/ - resources.add(createResource("用户模块", "ty-user", "2.9")); +// }); + return resources; } diff --git a/ty-gateway/ty-gateway-one/src/main/resources/application.yml b/ty-gateway/ty-gateway-one/src/main/resources/application.yml index 9492c9a..bb642e0 100644 --- a/ty-gateway/ty-gateway-one/src/main/resources/application.yml +++ b/ty-gateway/ty-gateway-one/src/main/resources/application.yml @@ -4,24 +4,24 @@ #spring: # cloud: # gateway: -## globalcors: -## corsConfigurations: -## '[/**]': -## # 允许携带认证信息 -## # 允许跨域的源(网站域名/ip),设置*为全部 -## # 允许跨域请求里的head字段,设置*为全部 -## # 允许跨域的method, 默认为GET和OPTIONS,设置*为全部 -## # 跨域允许的有效期 -## allow-credentials: true -## allowed-origins: "*" -## allowed-headers: "*" -## allowed-methods: -## - OPTIONS -## - GET -## - POST -## - PUT -## - DELETE -## #max-age: 3600 +# globalcors: +# corsConfigurations: +# '[/**]': +# # 允许携带认证信息 +# # 允许跨域的源(网站域名/ip),设置*为全部 +# # 允许跨域请求里的head字段,设置*为全部 +# # 允许跨域的method, 默认为GET和OPTIONS,设置*为全部 +# # 跨域允许的有效期 +# allow-credentials: true +# allowed-origins: "*" +# allowed-headers: "*" +# allowed-methods: +# - OPTIONS +# - GET +# - POST +# - PUT +# - DELETE +# #max-age: 3600 # routes: # - id: ty-auth # uri: lb://ty-auth @@ -51,6 +51,13 @@ # filters: # - StripPrefix=2 # +# - id: ty-upload +# uri: lb://ty-upload +# predicates: +# - Path=/api/ty-upload/** +# filters: +# - StripPrefix=2 +# ## - id: fai_search_route ## uri: lb://search ## predicates: @@ -81,3 +88,9 @@ # #token-properties: # renewTokenMinute: 1440 #默认1天时间告知前端刷新token +# +#swagger-doc: +# serviceMap: { +# ty-user: "用户模块", +# ty-upload: "文件上传" +# } \ No newline at end of file diff --git a/ty-upload/pom.xml b/ty-upload/pom.xml new file mode 100644 index 0000000..cf71082 --- /dev/null +++ b/ty-upload/pom.xml @@ -0,0 +1,50 @@ + + + + micro-service-plus + top.kuanghua + 1.0-SNAPSHOT + + 4.0.0 + + ty-upload + + + top.kuanghua + ty-common + 1.0-SNAPSHOT + + + com.github.tobato + fastdfs-client + 1.27.2 + + + + + ${project.artifactId} + + + src/main/resources + true + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.1 + + true + + + + + + \ No newline at end of file diff --git a/ty-upload/src/main/java/top/kuanghua/tyupload/UploadApplication.java b/ty-upload/src/main/java/top/kuanghua/tyupload/UploadApplication.java new file mode 100644 index 0000000..cb54be9 --- /dev/null +++ b/ty-upload/src/main/java/top/kuanghua/tyupload/UploadApplication.java @@ -0,0 +1,18 @@ +package top.kuanghua.tyupload; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; + +/** + * @Title: SmsApplication + * @Description: + * @Auther: + * @create 2020/8/20 10:46 + */ +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) +public class UploadApplication { + public static void main(String[] args) { + SpringApplication.run(UploadApplication.class, args); + } +} diff --git a/ty-upload/src/main/java/top/kuanghua/tyupload/config/BaseConfig.java b/ty-upload/src/main/java/top/kuanghua/tyupload/config/BaseConfig.java new file mode 100644 index 0000000..d8d6063 --- /dev/null +++ b/ty-upload/src/main/java/top/kuanghua/tyupload/config/BaseConfig.java @@ -0,0 +1,21 @@ +package top.kuanghua.tyupload.config; + +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +/** + * @Title: BaseConfig + * @Description: + * @Auther: kuanghua + * @create 2020/8/23 21:52 + */ +/* + * 总结:1.@Configuration 下的@ComponentScan回将包下带有@Component扫描变成配置类, + * 而@SpringBootApplication扫描的只会变成普通类 + * */ +@Configuration +//dao包扫描 +@ComponentScan(basePackages = {"top.kuanghua.khcomomon"}) +@EnableFeignClients(basePackages = {"top.kuanghua.feign"}) +public class BaseConfig {} diff --git a/ty-upload/src/main/java/top/kuanghua/tyupload/config/Swagger2Config.java b/ty-upload/src/main/java/top/kuanghua/tyupload/config/Swagger2Config.java new file mode 100644 index 0000000..106aedf --- /dev/null +++ b/ty-upload/src/main/java/top/kuanghua/tyupload/config/Swagger2Config.java @@ -0,0 +1,52 @@ +package top.kuanghua.tyupload.config; + +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@Component +@EnableSwagger2 //开启在线接口文档 +//配置包扫描 +public class Swagger2Config { + private boolean swagger_is_enable = true; + +// @Value("${.ipAddr}") +// private String ipAddr; + @Value("${server.port}") + private String port; + + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .enable(swagger_is_enable) + //.host(this.ipAddr + ":" + this.port) + .apiInfo(apiInfo()) + .select() + .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) + //.apis(basePackage("top.kuanghua.swagger.controller")) + .paths(PathSelectors.any()) + .build(); + } + + /** + * 构建 api文档的详细信息函数 + * @return + */ + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("标题:kuanghua") + .description("描述:新一代的前端架构") + .contact(new Contact("jzfai", null, "869653722@qq.com")) + .version("版本号:2.9") + .build(); + } +} diff --git a/ty-upload/src/main/java/top/kuanghua/tyupload/controller/NacosTestDemo.java b/ty-upload/src/main/java/top/kuanghua/tyupload/controller/NacosTestDemo.java new file mode 100644 index 0000000..61a872d --- /dev/null +++ b/ty-upload/src/main/java/top/kuanghua/tyupload/controller/NacosTestDemo.java @@ -0,0 +1,44 @@ +package top.kuanghua.tyupload.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import top.kuanghua.feign.tyauth.feign.TokenFeign; +import top.kuanghua.khcomomon.entity.ResResult; + +import java.util.HashMap; + +/** + * @Title: NacosTestDemo + * @Description: + * @Auther: kuanghua + * @create 2021/5/12 11:16 + */ + +@Api("nacos测试") +@RequestMapping("NacosTestDemo") +@RestController +public class NacosTestDemo { + @Autowired + private TokenFeign tokenFeign; + @ApiOperation("第一个") + @GetMapping("test") + public ResResult test(){ + HashMap hashMap = new HashMap(); + hashMap.put("username","邝华"); + ResResult resResult = tokenFeign.generateToken(hashMap); + System.out.println(resResult); + return resResult; + } + + @ApiOperation("第二个") + @GetMapping("test2") + public ResResult test2(String token){ + ResResult resResult = tokenFeign.parseToken(token); + System.out.println(resResult); + return resResult; + } +} diff --git a/ty-upload/src/main/java/top/kuanghua/tyupload/controller/UploadController.java b/ty-upload/src/main/java/top/kuanghua/tyupload/controller/UploadController.java new file mode 100644 index 0000000..86d6752 --- /dev/null +++ b/ty-upload/src/main/java/top/kuanghua/tyupload/controller/UploadController.java @@ -0,0 +1,83 @@ +package top.kuanghua.tyupload.controller; + +import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; +import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.tyupload.service.UploadService; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; + +/** + * @Title: UploadController @Description: @Auther:jzfai @Version: 1.0 + * @create 2020/3/4 21:58 + */ +@RestController +@RequestMapping("upload") +@Api(tags = "图片上传") +@DefaultProperties(defaultFallback = "fallBackMethod") // 指定一个类的全局熔断方法 + +@RefreshScope +public class UploadController { + + @Autowired + private UploadService uploadService; + + @ApiOperation(value = "上传图片", notes = "上传图片接口") + @PostMapping("image") + public ResResult uploadImage(@RequestParam("file") MultipartFile file) + throws IOException, InterruptedException { + String url = this.uploadService.upload(file); + // Thread.sleep(5000); + HashMap map = new HashMap<>(); + map.put("shortPath",url); + return new ResResult().success(map); + } +// +// @ApiOperation(value = "上传图片(多张)") +// @PostMapping("uploadGetMetaData") +// public ResResult uploadGetMetaData(@RequestParam("files") MultipartFile[] files) +// throws IOException, InterruptedException { +// ArrayList strings = new ArrayList<>(); +// for (MultipartFile file : files) { +// Map stringStringMap = this.uploadService.uploadGetMetaData(file); +// strings.add(stringStringMap); +// } +// //Thread.sleep(5000); +// return new ResResult().success(strings); +// } + @ApiOperation(value = "批量上传文件") + @PostMapping("files") + public ResResult uploadFileList(@RequestParam("files") MultipartFile[] files) throws IOException { + ArrayList strings = new ArrayList<>(); + for (MultipartFile file : files) { + String url = this.uploadService.upload(file); + strings.add(url); + } + return new ResResult().success(strings); + } + + public String fallBackMethod() { + return "请求繁忙,请稍后再试!"; + } + +// @Value(value = "${demo.a}") +// private String data12; +// @Value(value = "${demo.b}") +// private String datas; +// @ApiOperation(value = "test") +// @GetMapping("test") +// public String test() { +// System.out.println("data :" + data12 + ",datas="+datas); +// return "data :" + data12 + ",datas="+datas; +// } +} diff --git a/ty-upload/src/main/java/top/kuanghua/tyupload/service/UploadService.java b/ty-upload/src/main/java/top/kuanghua/tyupload/service/UploadService.java new file mode 100644 index 0000000..78d580d --- /dev/null +++ b/ty-upload/src/main/java/top/kuanghua/tyupload/service/UploadService.java @@ -0,0 +1,90 @@ +package top.kuanghua.tyupload.service; + + +import com.alibaba.fastjson.JSON; +import com.github.tobato.fastdfs.domain.fdfs.MetaData; +import com.github.tobato.fastdfs.domain.fdfs.StorePath; +import com.github.tobato.fastdfs.service.FastFileStorageClient; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.*; + +/** + * @Title: UploadService + * @Description: + * @Auther:jzfai + * @Version: 1.0 + * @create 2020/3/4 21:58 + */ +@Service +@Slf4j +public class UploadService { + + @Autowired + private FastFileStorageClient storageClient; + + private static final List CONTENT_TYPES = Arrays.asList("image/jpeg", "image/gif"); + + public String upload(MultipartFile file) throws IOException { + String originalFilename = file.getOriginalFilename(); + //检验文件类型 + String contentType = file.getContentType(); + if (!CONTENT_TYPES.contains(contentType)) { + //文件类型不合法 + log.info("文件类型不合法:{}", originalFilename); + } + //检验文件内容 + BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); + if (bufferedImage == null) { + log.info("文件内容不合法:{}", originalFilename); + } + //保存到服务器 + //file.transferTo(new File("D:\\java\\javaproject\\pinyou\\pinyou-upload\\src\\main\\resources\\static\\" + originalFilename)); + //上传到FastDfs + String ext = StringUtils.substringAfterLast(originalFilename, "."); + HashSet metaData = new HashSet<>(); + metaData.add(new MetaData("name", file.getOriginalFilename())); + metaData.add(new MetaData("createTime", JSON.toJSONString(new Date()))); + StorePath storePath = this.storageClient.uploadFile(file.getInputStream(), file.getSize(), ext, metaData); + return storePath.getFullPath(); + } + + public Map uploadGetMetaData(MultipartFile file) throws IOException { + String originalFilename = file.getOriginalFilename(); + //检验文件类型 + String contentType = file.getContentType(); + if (!CONTENT_TYPES.contains(contentType)) { + //文件类型不合法 + log.info("文件类型不合法:{}", originalFilename); + } + //检验文件内容 + BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); + if (bufferedImage == null) { + log.info("文件内容不合法:{}", originalFilename); + } + //保存到服务器 + //file.transferTo(new File("D:\\java\\javaproject\\pinyou\\pinyou-upload\\src\\main\\resources\\static\\" + originalFilename)); + //上传到FastDfs + String ext = StringUtils.substringAfterLast(originalFilename, "."); + HashSet metaData = new HashSet<>(); + metaData.add(new MetaData("name", file.getOriginalFilename())); + StorePath storePath = this.storageClient.uploadFile(file.getInputStream(), file.getSize(), ext, metaData); + //获取数据源信息 + Set metadata = this.storageClient.getMetadata(storePath.getGroup(), storePath.getPath()); + ArrayList metaDataArrayList = new ArrayList<>(metadata); + String name = metaDataArrayList.get(0).getValue(); + //拼接name和url返回 + Map hashMap = new HashMap<>(); + hashMap.put("name", name); + hashMap.put("url", storePath.getFullPath()); + System.out.println(hashMap); + return hashMap; + } +} diff --git a/ty-upload/src/main/javabrandE/BrandE.vue b/ty-upload/src/main/javabrandE/BrandE.vue new file mode 100644 index 0000000..070a2e6 --- /dev/null +++ b/ty-upload/src/main/javabrandE/BrandE.vue @@ -0,0 +1,266 @@ + + + + + + diff --git a/ty-upload/src/main/javabrandE/BrandEForm.vue b/ty-upload/src/main/javabrandE/BrandEForm.vue new file mode 100644 index 0000000..b212c74 --- /dev/null +++ b/ty-upload/src/main/javabrandE/BrandEForm.vue @@ -0,0 +1,227 @@ + + + + + + diff --git a/ty-upload/src/main/main11.iml b/ty-upload/src/main/main11.iml new file mode 100644 index 0000000..f608aea --- /dev/null +++ b/ty-upload/src/main/main11.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/ty-upload/src/main/resources/application.yml b/ty-upload/src/main/resources/application.yml new file mode 100644 index 0000000..e69de29 diff --git a/ty-upload/src/main/resources/bootstrap.yml b/ty-upload/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..19f67dc --- /dev/null +++ b/ty-upload/src/main/resources/bootstrap.yml @@ -0,0 +1,35 @@ +spring: + application: + name: @project.artifactId@ + profiles: + active: @activatedProperties@ + cloud: + nacos: + config: + enabled: true + namespace: @nacosNamespace@ + group: @nacosGroup@ + username: @nacosUsername@ + password: @nacosPassword@ + server-addr: @nacosIpPort@ + prefix: @project.artifactId@ + file-extension: yml + # 用于共享的配置文件 + shared-configs: + - data-id: application-@activatedProperties@.yml + group: @nacosGroup@ + refresh: true + extension-configs: + - data-id: @project.artifactId@.yml + group: @nacosGroup@ + refresh: true + - data-id: application-upload.yml + group: @nacosGroup@ + refresh: true + discovery: + namespace: @nacosNamespace@ + group: @nacosGroup@ + username: @nacosUsername@ + password: @nacosPassword@ + server-addr: @nacosIpPort@ + weight: @nacosWeight@ \ No newline at end of file diff --git a/ty-upload/src/test/java/top/kuanghua/tyupload/controller/UploadControllerTest.java b/ty-upload/src/test/java/top/kuanghua/tyupload/controller/UploadControllerTest.java new file mode 100644 index 0000000..9134a1d --- /dev/null +++ b/ty-upload/src/test/java/top/kuanghua/tyupload/controller/UploadControllerTest.java @@ -0,0 +1,28 @@ +package top.kuanghua.tyupload.controller; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Title: UploadControllerTest @Description: @Auther: kuanghua + * @create 2020/8/20 21:34 + */ +@SpringBootTest +@RunWith(SpringRunner.class) +class UploadControllerTest { + + @Autowired + private UploadControllerTest uploadControllerTest; + + @Test + void uploadImage() { + Map hashMap = new HashMap<>(); + hashMap.put("", ""); + } +} diff --git a/ty-upload/src/test/test2.iml b/ty-upload/src/test/test2.iml new file mode 100644 index 0000000..a0e49a3 --- /dev/null +++ b/ty-upload/src/test/test2.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ty-upload/ty-upload.iml b/ty-upload/ty-upload.iml new file mode 100644 index 0000000..44ed24d --- /dev/null +++ b/ty-upload/ty-upload.iml @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/controller/BrandController.java b/ty-user/src/main/java/top/kuanghua/tyuser/controller/BrandController.java new file mode 100644 index 0000000..ab88940 --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuser/controller/BrandController.java @@ -0,0 +1,129 @@ +package top.kuanghua.tyuser.controller; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.extension.api.ApiController; +import com.baomidou.mybatisplus.extension.api.R; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import top.kuanghua.khcomomon.entity.KHCommonParams; +import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.tyuser.entity.Brand; +import top.kuanghua.tyuser.service.BrandService; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.io.Serializable; +import java.util.*; + +@Api(tags = "品牌表(Brand)") +@RestController +@RequestMapping("brand") +public class BrandController { + + @Resource + private BrandService brandService; + + /** + * 分页查询所有数据 + * + * @param brand 查询实体 + * @return 所有数据 + */ + @GetMapping("selectPage") + @ApiOperation(value = "分页查询所有数据") + public ResResult selectPage(Brand brand, KHCommonParams commonParams) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (ObjectUtils.isNotEmpty(brand.getId())) { + queryWrapper.or().like("id", brand.getId()); + } + if (ObjectUtils.isNotEmpty(brand.getName())) { + queryWrapper.or().like("name", brand.getName()); + } + if (ObjectUtils.isNotEmpty(brand.getImage())) { + queryWrapper.or().like("image", brand.getImage()); + } + if (ObjectUtils.isNotEmpty(brand.getLetter())) { + queryWrapper.or().like("letter", brand.getLetter()); + } + if (ObjectUtils.isNotEmpty(brand.getSeq())) { + queryWrapper.or().like("seq", brand.getSeq()); + } + queryWrapper.or().orderByDesc("create_time"); + if(StringUtils.isNotEmpty(commonParams.getStartTime())) { + queryWrapper.or().between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); + } + queryWrapper.select("id,name,image,letter,seq,create_time,update_time"); + Page brandPage = this.brandService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); + return new ResResult().success(brandPage); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("selectById") + @ApiOperation(value = "通过id主键查询单条数据") + public ResResult selectById(@RequestParam("id") Integer id) { + return new ResResult().success(this.brandService.selectById(id)); + } + + /** + * @Description: 根据id数组查询品牌列表 + * @Param: idList id数组 + * @return: ids列表数据 + */ + @ApiOperation(value = "根据id数组查询品牌列表") + @PostMapping("selectBatchIds") + public ResResult selectBatchIds(@RequestParam("idList") List idList) { + return new ResResult().success(this.brandService.selectBatchIds(idList)); + } + + + /** + * 新增数据 + * + * @param brand 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping("insert") + public ResResult insert(@RequestBody Brand brand) { + return new ResResult().success(this.brandService.insert(brand)); + } + + /** + * 修改数据 + * + * @param brand 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "根据id修改数据") + @PutMapping("updateById") + public ResResult updateById(@RequestBody Brand brand) { + return new ResResult().success(this.brandService.updateById(brand)); + } + + /** + * 删除数据 + * + * @param idList 主键结合 + * @return 删除结果 + */ + @ApiOperation(value = "根据id数组删除数据") + @DeleteMapping("deleteBatchIds") + public ResResult deleteBatchIds(@RequestBody List idList) { + return new ResResult().success(this.brandService.deleteBatchIds(idList)); + } + + @DeleteMapping("deleteById") + @ApiOperation(value = "根据id数组删除数据") + public ResResult deleteById(@RequestParam("id") Integer id) { + return new ResResult().success(this.brandService.deleteById(id)); + } +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/controller/UserController.java b/ty-user/src/main/java/top/kuanghua/tyuser/controller/UserController.java index 23f7127..8194a24 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/controller/UserController.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/controller/UserController.java @@ -24,6 +24,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.HashMap; +import java.util.List; import java.util.Map; @Api(tags = "用户相关") @@ -71,11 +72,11 @@ public ResResult selectPage(User user, KHCommonParams commonParams) { * @param id 主键 * @return 单条数据 */ -// @GetMapping("selectById") -// @ApiOperation(value = "通过id主键查询单条数据") -// public ResResult selectById(@RequestParam("id") Integer id) { -// return new ResResult().success(this.userMapper.selectById(id)); -// } + @GetMapping("selectById") + @ApiOperation(value = "通过id主键查询单条数据") + public ResResult selectById(@RequestParam("id") Integer id) { + return new ResResult().success(this.userMapper.selectById(id)); + } // // /** // * @Description: 根据id数组查询品牌列表 @@ -120,16 +121,16 @@ public ResResult insert(@Valid @RequestBody User user) { // * @param idList 主键结合 // * @return 删除结果 // */ -// @ApiOperation(value = "根据id数组删除数据") -// @DeleteMapping("deleteBatchIds") -// public ResResult deleteBatchIds(@RequestBody List idList) { -// return new ResResult().success(this.userMapper.deleteBatchIds(idList)); -// } -// @DeleteMapping("deleteById") -// @ApiOperation(value = "根据id删除数据") -// public ResResult deleteById(@RequestParam("id") Integer id) { -// return new ResResult().success(this.userMapper.deleteById(id)); -// } + @ApiOperation(value = "根据id数组删除数据") + @DeleteMapping("deleteBatchIds") + public ResResult deleteBatchIds(@RequestBody List idList) { + return new ResResult().success(this.userMapper.deleteBatchIds(idList)); + } + @DeleteMapping("deleteById") + @ApiOperation(value = "根据id删除数据") + public ResResult deleteById(@RequestParam("id") Integer id) { + return new ResResult().success(this.userMapper.deleteById(id)); + } @PostMapping("registry") @ApiOperation(value = "用户注册") diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/element/Access.vue b/ty-user/src/main/java/top/kuanghua/tyuser/element/Access.vue deleted file mode 100644 index b384c8d..0000000 --- a/ty-user/src/main/java/top/kuanghua/tyuser/element/Access.vue +++ /dev/null @@ -1,536 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/element/User.vue b/ty-user/src/main/java/top/kuanghua/tyuser/element/User.vue deleted file mode 100644 index 0f5ecef..0000000 --- a/ty-user/src/main/java/top/kuanghua/tyuser/element/User.vue +++ /dev/null @@ -1,617 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/entity/Brand.java b/ty-user/src/main/java/top/kuanghua/tyuser/entity/Brand.java new file mode 100644 index 0000000..272face --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuser/entity/Brand.java @@ -0,0 +1,50 @@ +package top.kuanghua.tyuser.entity; + +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * 品牌表(Brand)表实体类 + * + * @author kuanghua + * @since 2021-09-15 11:54:49 + */ +@Data +@ApiModel("品牌表") +@TableName(value = "tb_brand") +public class Brand extends Model { + @ApiModelProperty(value = "品牌id") + private Integer id; + @ApiModelProperty(value = "品牌名称") + private String name; + @ApiModelProperty(value = "品牌图片地址") + private String image; + @ApiModelProperty(value = "品牌的首字母") + private String letter; + @ApiModelProperty(value = "排序") + private Integer seq; + @ApiModelProperty(value = "创建时间",hidden = true) + @TableField(fill = FieldFill.INSERT) + private Date createTime; + @ApiModelProperty(value = "更新时间",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private Date updateTime; + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/entity/Role.java b/ty-user/src/main/java/top/kuanghua/tyuser/entity/Role.java index aeaf470..6718ccc 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/entity/Role.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/entity/Role.java @@ -7,7 +7,6 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; - import java.io.Serializable; import java.util.Date; diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/BrandMapper.java b/ty-user/src/main/java/top/kuanghua/tyuser/mapper/BrandMapper.java new file mode 100644 index 0000000..71a79d2 --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuser/mapper/BrandMapper.java @@ -0,0 +1,8 @@ +package top.kuanghua.tyuser.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.tyuser.entity.Brand; + +public interface BrandMapper extends BaseMapper { + +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/service/BrandService.java b/ty-user/src/main/java/top/kuanghua/tyuser/service/BrandService.java new file mode 100644 index 0000000..8a0a519 --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuser/service/BrandService.java @@ -0,0 +1,51 @@ +package top.kuanghua.tyuser.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Service; +import top.kuanghua.tyuser.entity.Brand; +import top.kuanghua.tyuser.mapper.BrandMapper; + +import javax.annotation.Resource; +import java.util.List; + +/** + * (Brand) + * + * @author kuanghua + * @since 2021-09-15 11:54:48 + */ +@Service +public class BrandService { + + @Resource + private BrandMapper brandMapper; + + public Page selectPage(Integer pageNum, Integer pageSize, QueryWrapper queryWrapper) { + return this.brandMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); + } + + public Brand selectById(Integer id) { + return this.brandMapper.selectById(id); + } + + public List selectBatchIds(List idList) { + return this.brandMapper.selectBatchIds(idList); + } + + public int insert(Brand brand) { + return this.brandMapper.insert(brand); + } + + public int updateById(Brand brand) { + return this.brandMapper.updateById(brand); + } + + public int deleteById(Integer id) { + return this.brandMapper.deleteById(id); + } + + public int deleteBatchIds(List idList) { + return this.brandMapper.deleteBatchIds(idList); + } +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuserbrand/Brand.vue b/ty-user/src/main/java/top/kuanghua/tyuserbrand/Brand.vue new file mode 100644 index 0000000..cd9d35a --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuserbrand/Brand.vue @@ -0,0 +1,276 @@ + + + + + + diff --git a/ty-user/src/main/java/top/kuanghua/tyuserbrand/BrandForm.vue b/ty-user/src/main/java/top/kuanghua/tyuserbrand/BrandForm.vue new file mode 100644 index 0000000..f5c1f9b --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuserbrand/BrandForm.vue @@ -0,0 +1,227 @@ + + + + + + diff --git a/ty-user/src/main/java/top/kuanghua/tyuserbrandE/BrandE.vue b/ty-user/src/main/java/top/kuanghua/tyuserbrandE/BrandE.vue new file mode 100644 index 0000000..070a2e6 --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuserbrandE/BrandE.vue @@ -0,0 +1,266 @@ + + + + + + diff --git a/ty-user/src/main/java/top/kuanghua/tyuserbrandE/BrandEForm.vue b/ty-user/src/main/java/top/kuanghua/tyuserbrandE/BrandEForm.vue new file mode 100644 index 0000000..b212c74 --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuserbrandE/BrandEForm.vue @@ -0,0 +1,227 @@ + + + + + + From eadd0c03d93f4be75f9ae386603646d1777c066e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=9D=E5=8D=8E?= Date: Thu, 16 Sep 2021 18:37:23 +0800 Subject: [PATCH 04/36] fix update_time issue --- ty-auth/ty-auth.iml | 5 - .../config/MetaObjectHandlerConfig.java | 3 +- ty-common/ty-common.iml | 5 - ty-gateway/ty-gateway-one/ty-gateway-one.iml | 5 - .../java/top/kuanghua/tyuserbrand/Brand.vue | 276 ------------------ .../top/kuanghua/tyuserbrand/BrandForm.vue | 227 -------------- .../java/top/kuanghua/tyuserbrandE/BrandE.vue | 266 ----------------- .../top/kuanghua/tyuserbrandE/BrandEForm.vue | 227 -------------- ty-user/ty-user.iml | 5 - 9 files changed, 1 insertion(+), 1018 deletions(-) delete mode 100644 ty-user/src/main/java/top/kuanghua/tyuserbrand/Brand.vue delete mode 100644 ty-user/src/main/java/top/kuanghua/tyuserbrand/BrandForm.vue delete mode 100644 ty-user/src/main/java/top/kuanghua/tyuserbrandE/BrandE.vue delete mode 100644 ty-user/src/main/java/top/kuanghua/tyuserbrandE/BrandEForm.vue diff --git a/ty-auth/ty-auth.iml b/ty-auth/ty-auth.iml index 72ba5d9..88dd7e7 100644 --- a/ty-auth/ty-auth.iml +++ b/ty-auth/ty-auth.iml @@ -7,10 +7,6 @@ - - - - @@ -20,7 +16,6 @@ - diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/config/MetaObjectHandlerConfig.java b/ty-common/src/main/java/top/kuanghua/khcomomon/config/MetaObjectHandlerConfig.java index fe9a86a..407c23e 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/config/MetaObjectHandlerConfig.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/config/MetaObjectHandlerConfig.java @@ -20,7 +20,6 @@ public void insertFill(MetaObject metaObject) { @Override public void updateFill(MetaObject metaObject) { log.info("start update fill ...."); - this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now()); - this.strictUpdateFill(metaObject, "aaaa", LocalDateTime.class, LocalDateTime.now()); + this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date()); } } \ No newline at end of file diff --git a/ty-common/ty-common.iml b/ty-common/ty-common.iml index 039c62a..77de6d5 100644 --- a/ty-common/ty-common.iml +++ b/ty-common/ty-common.iml @@ -7,10 +7,6 @@ - - - - @@ -20,7 +16,6 @@ - diff --git a/ty-gateway/ty-gateway-one/ty-gateway-one.iml b/ty-gateway/ty-gateway-one/ty-gateway-one.iml index e71b88b..a0a458c 100644 --- a/ty-gateway/ty-gateway-one/ty-gateway-one.iml +++ b/ty-gateway/ty-gateway-one/ty-gateway-one.iml @@ -7,10 +7,6 @@ - - - - @@ -20,7 +16,6 @@ - diff --git a/ty-user/src/main/java/top/kuanghua/tyuserbrand/Brand.vue b/ty-user/src/main/java/top/kuanghua/tyuserbrand/Brand.vue deleted file mode 100644 index cd9d35a..0000000 --- a/ty-user/src/main/java/top/kuanghua/tyuserbrand/Brand.vue +++ /dev/null @@ -1,276 +0,0 @@ - - - - - - diff --git a/ty-user/src/main/java/top/kuanghua/tyuserbrand/BrandForm.vue b/ty-user/src/main/java/top/kuanghua/tyuserbrand/BrandForm.vue deleted file mode 100644 index f5c1f9b..0000000 --- a/ty-user/src/main/java/top/kuanghua/tyuserbrand/BrandForm.vue +++ /dev/null @@ -1,227 +0,0 @@ - - - - - - diff --git a/ty-user/src/main/java/top/kuanghua/tyuserbrandE/BrandE.vue b/ty-user/src/main/java/top/kuanghua/tyuserbrandE/BrandE.vue deleted file mode 100644 index 070a2e6..0000000 --- a/ty-user/src/main/java/top/kuanghua/tyuserbrandE/BrandE.vue +++ /dev/null @@ -1,266 +0,0 @@ - - - - - - diff --git a/ty-user/src/main/java/top/kuanghua/tyuserbrandE/BrandEForm.vue b/ty-user/src/main/java/top/kuanghua/tyuserbrandE/BrandEForm.vue deleted file mode 100644 index b212c74..0000000 --- a/ty-user/src/main/java/top/kuanghua/tyuserbrandE/BrandEForm.vue +++ /dev/null @@ -1,227 +0,0 @@ - - - - - - diff --git a/ty-user/ty-user.iml b/ty-user/ty-user.iml index 6d95e64..a0e988d 100644 --- a/ty-user/ty-user.iml +++ b/ty-user/ty-user.iml @@ -7,10 +7,6 @@ - - - - @@ -20,7 +16,6 @@ - From 0143789fb91ad3cd594d95837dfdb826ace4229c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=9D=E5=8D=8E?= Date: Fri, 8 Oct 2021 18:34:52 +0800 Subject: [PATCH 05/36] add error page func --- micro-service-plus.iml | 112 ++--- ty-auth/ty-auth.iml | 442 ++++++++--------- ty-common/ty-common.iml | 438 ++++++++-------- ty-gateway/ty-gateway-one/ty-gateway-one.iml | 468 +++++++++--------- ty-gateway/ty-gateway.iml | 444 ++++++++--------- .../tyupload/service/UploadService.java | 2 + ty-upload/ty-upload.iml | 458 ++++++++--------- .../controller/ErrorCollectionController.java | 124 +++++ .../tyuser/controller/UserController.java | 7 +- .../tyuser/entity/ErrorCollection.java | 34 ++ .../tyuser/mapper/ErrorCollectionMapper.java | 8 + .../service/ErrorCollectionService.java | 51 ++ ty-user/ty-user.iml | 440 ++++++++-------- 13 files changed, 1626 insertions(+), 1402 deletions(-) create mode 100644 ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java create mode 100644 ty-user/src/main/java/top/kuanghua/tyuser/entity/ErrorCollection.java create mode 100644 ty-user/src/main/java/top/kuanghua/tyuser/mapper/ErrorCollectionMapper.java create mode 100644 ty-user/src/main/java/top/kuanghua/tyuser/service/ErrorCollectionService.java diff --git a/micro-service-plus.iml b/micro-service-plus.iml index 021af43..7f10b3d 100644 --- a/micro-service-plus.iml +++ b/micro-service-plus.iml @@ -1,57 +1,57 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ty-auth/ty-auth.iml b/ty-auth/ty-auth.iml index 88dd7e7..9447a05 100644 --- a/ty-auth/ty-auth.iml +++ b/ty-auth/ty-auth.iml @@ -1,222 +1,222 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ty-common/ty-common.iml b/ty-common/ty-common.iml index 77de6d5..3ffe7b5 100644 --- a/ty-common/ty-common.iml +++ b/ty-common/ty-common.iml @@ -1,220 +1,220 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/ty-gateway-one.iml b/ty-gateway/ty-gateway-one/ty-gateway-one.iml index a0a458c..2e4a4dc 100644 --- a/ty-gateway/ty-gateway-one/ty-gateway-one.iml +++ b/ty-gateway/ty-gateway-one/ty-gateway-one.iml @@ -1,235 +1,235 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ty-gateway/ty-gateway.iml b/ty-gateway/ty-gateway.iml index 77d8bb2..e5e33c2 100644 --- a/ty-gateway/ty-gateway.iml +++ b/ty-gateway/ty-gateway.iml @@ -1,223 +1,223 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ty-upload/src/main/java/top/kuanghua/tyupload/service/UploadService.java b/ty-upload/src/main/java/top/kuanghua/tyupload/service/UploadService.java index 78d580d..d907045 100644 --- a/ty-upload/src/main/java/top/kuanghua/tyupload/service/UploadService.java +++ b/ty-upload/src/main/java/top/kuanghua/tyupload/service/UploadService.java @@ -39,11 +39,13 @@ public String upload(MultipartFile file) throws IOException { if (!CONTENT_TYPES.contains(contentType)) { //文件类型不合法 log.info("文件类型不合法:{}", originalFilename); + throw new RuntimeException("文件内容不合法"); } //检验文件内容 BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); if (bufferedImage == null) { log.info("文件内容不合法:{}", originalFilename); + throw new RuntimeException("文件内容不合法"); } //保存到服务器 //file.transferTo(new File("D:\\java\\javaproject\\pinyou\\pinyou-upload\\src\\main\\resources\\static\\" + originalFilename)); diff --git a/ty-upload/ty-upload.iml b/ty-upload/ty-upload.iml index 44ed24d..39cc125 100644 --- a/ty-upload/ty-upload.iml +++ b/ty-upload/ty-upload.iml @@ -1,230 +1,230 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java b/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java new file mode 100644 index 0000000..3da6048 --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java @@ -0,0 +1,124 @@ +package top.kuanghua.tyuser.controller; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.extension.api.ApiController; +import com.baomidou.mybatisplus.extension.api.R; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import top.kuanghua.khcomomon.entity.KHCommonParams; +import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.tyuser.entity.ErrorCollection; +import top.kuanghua.tyuser.service.ErrorCollectionService; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.io.Serializable; +import java.util.*; + +@Api(tags = "日志相关") +@RestController +@RequestMapping("errorCollection") +public class ErrorCollectionController { + + @Resource + private ErrorCollectionService errorCollectionService; + + /** + * 分页查询所有数据 + * + * @param errorCollection 查询实体 + * @return 所有数据 + */ + @GetMapping("selectPage") + @ApiOperation(value = "分页查询所有数据") + public ResResult selectPage(ErrorCollection errorCollection, KHCommonParams khCommonParams) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (ObjectUtils.isNotEmpty(errorCollection.getErrorLog())) { + queryWrapper.or().like("error_log", errorCollection.getErrorLog()); + } + if (ObjectUtils.isNotEmpty(errorCollection.getPageUrl())) { + queryWrapper.or().like("page_url", errorCollection.getPageUrl()); + } + if (ObjectUtils.isNotEmpty(errorCollection.getCreateTime())) { + queryWrapper.or().like("create_time", errorCollection.getCreateTime()); + } + + queryWrapper.select("error_log,page_url,create_time,id"); + queryWrapper.or().orderByDesc("create_time"); + if(StringUtils.isNotEmpty(khCommonParams.getStartTime())) { + queryWrapper.or().between("create_time",khCommonParams.getStartTime(),khCommonParams.getEndTime()); + } + Page errorCollectionPage = this.errorCollectionService.selectPage(khCommonParams.getPageNum(), khCommonParams.getPageSize(), queryWrapper); + return new ResResult().success(errorCollectionPage); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("selectById") + @ApiOperation(value = "通过id主键查询单条数据") + public ResResult selectById(@RequestParam("id") Integer id) { + return new ResResult().success(this.errorCollectionService.selectById(id)); + } + + /** + * @Description: 根据id数组查询品牌列表 + * @Param: idList id数组 + * @return: ids列表数据 + */ + @ApiOperation(value = "根据id数组查询品牌列表") + @PostMapping("selectBatchIds") + public ResResult selectBatchIds(@RequestParam("idList") List idList) { + return new ResResult().success(this.errorCollectionService.selectBatchIds(idList)); + } + + + /** + * 新增数据 + * + * @param errorCollection 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping("insert") + public ResResult insert(@RequestBody ErrorCollection errorCollection) { + return new ResResult().success(this.errorCollectionService.insert(errorCollection)); + } + + /** + * 修改数据 + * + * @param errorCollection 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "根据id修改数据") + @PutMapping("updateById") + public ResResult updateById(@RequestBody ErrorCollection errorCollection) { + return new ResResult().success(this.errorCollectionService.updateById(errorCollection)); + } + + /** + * 删除数据 + * + * @param idList 主键结合 + * @return 删除结果 + */ + @ApiOperation(value = "根据id数组删除数据") + @DeleteMapping("deleteBatchIds") + public ResResult deleteBatchIds(@RequestBody List idList) { + return new ResResult().success(this.errorCollectionService.deleteBatchIds(idList)); + } + + @DeleteMapping("deleteById") + @ApiOperation(value = "根据id数组删除数据") + public ResResult deleteById(@RequestParam("id") Integer id) { + return new ResResult().success(this.errorCollectionService.deleteById(id)); + } +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/controller/UserController.java b/ty-user/src/main/java/top/kuanghua/tyuser/controller/UserController.java index 8194a24..dfc01c4 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/controller/UserController.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/controller/UserController.java @@ -176,7 +176,12 @@ public ResResult changePassword( this.userService.changePassword(tokenInfo.get("username").toString(),oldPassword,newPassword); return new ResResult().success(); } - + @PostMapping("getUserInfo") + @ApiOperation(value = "获取用户信息") + public ResResult changePassword(@ApiIgnore @RequestHeader("TOKEN_INFO") String TOKEN_INFO) throws UnsupportedEncodingException { + Map tokenInfo = JSON.parseObject(URLDecoder.decode(TOKEN_INFO, "utf-8")); + return new ResResult().success(tokenInfo); + } @PostMapping("insertUser") diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/entity/ErrorCollection.java b/ty-user/src/main/java/top/kuanghua/tyuser/entity/ErrorCollection.java new file mode 100644 index 0000000..d205c1f --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuser/entity/ErrorCollection.java @@ -0,0 +1,34 @@ +package top.kuanghua.tyuser.entity; + +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * error_log_collection(ErrorCollection)表实体类 + * + * @author kuanghua + * @since 2021-10-08 11:37:25 + */ +@Data +@ApiModel("错误日志相关") +@TableName(value = "tb_error_collection") +public class ErrorCollection extends Model { + @ApiModelProperty(value = "错误日志") + private String errorLog; + @ApiModelProperty(value = "页面路径") + private String pageUrl; + @TableField(fill = FieldFill.INSERT) + @ApiModelProperty(value = "创建时间",hidden = true) + private Date createTime; + @ApiModelProperty(value = "id主键") + private Long id; +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/ErrorCollectionMapper.java b/ty-user/src/main/java/top/kuanghua/tyuser/mapper/ErrorCollectionMapper.java new file mode 100644 index 0000000..0038cef --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuser/mapper/ErrorCollectionMapper.java @@ -0,0 +1,8 @@ +package top.kuanghua.tyuser.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.tyuser.entity.ErrorCollection; + +public interface ErrorCollectionMapper extends BaseMapper { + +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/service/ErrorCollectionService.java b/ty-user/src/main/java/top/kuanghua/tyuser/service/ErrorCollectionService.java new file mode 100644 index 0000000..8e6ae57 --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuser/service/ErrorCollectionService.java @@ -0,0 +1,51 @@ +package top.kuanghua.tyuser.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Service; +import top.kuanghua.tyuser.entity.ErrorCollection; +import top.kuanghua.tyuser.mapper.ErrorCollectionMapper; + +import javax.annotation.Resource; +import java.util.List; + +/** + * (ErrorCollection) + * + * @author kuanghua + * @since 2021-10-08 11:37:24 + */ +@Service +public class ErrorCollectionService { + + @Resource + private ErrorCollectionMapper errorCollectionMapper; + + public Page selectPage(Integer pageNum, Integer pageSize, QueryWrapper queryWrapper) { + return this.errorCollectionMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); + } + + public ErrorCollection selectById(Integer id) { + return this.errorCollectionMapper.selectById(id); + } + + public List selectBatchIds(List idList) { + return this.errorCollectionMapper.selectBatchIds(idList); + } + + public int insert(ErrorCollection errorCollection) { + return this.errorCollectionMapper.insert(errorCollection); + } + + public int updateById(ErrorCollection errorCollection) { + return this.errorCollectionMapper.updateById(errorCollection); + } + + public int deleteById(Integer id) { + return this.errorCollectionMapper.deleteById(id); + } + + public int deleteBatchIds(List idList) { + return this.errorCollectionMapper.deleteBatchIds(idList); + } +} diff --git a/ty-user/ty-user.iml b/ty-user/ty-user.iml index a0e988d..94b3e31 100644 --- a/ty-user/ty-user.iml +++ b/ty-user/ty-user.iml @@ -1,221 +1,221 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 8315239197a743830867e4eb46cb796707643f14 Mon Sep 17 00:00:00 2001 From: kuanghua <869653722@qq.com> Date: Thu, 11 Nov 2021 18:55:43 +0800 Subject: [PATCH 06/36] func of element-svg icon for side menu --- pom.xml | 1 + .../khcomomon/entity/CommonParamsSelf.java | 20 ++ .../khcomomon/utils/ObjectUtilsSelf.java | 30 ++- ty-excel/pom.xml | 51 ++++ .../kuanghua/tyexcel/ExcelApplication.java | 13 + .../kuanghua/tyexcel/bo/ComplexHeadData.java | 16 ++ .../bo/CustomStringStringConverter.java | 15 ++ .../top/kuanghua/tyexcel/bo/DemoData.java | 24 ++ .../kuanghua/tyexcel/bo/DemoExtraData.java | 11 + .../top/kuanghua/tyexcel/bo/RuiDeKqBo.java | 28 +++ .../kuanghua/tyexcel/config/BaseConfig.java | 25 ++ .../tyexcel/config/Swagger2Config.java | 56 +++++ .../tyexcel/controller/ExcelController.java | 81 ++++++ .../kuanghua/tyexcel/service/DaoService.java | 36 +++ .../tyexcel/service/ExcelService.java | 160 ++++++++++++ .../kuanghua/tyexcel/vo/ExcelCheckResult.java | 29 +++ ty-excel/src/main/resources/application.yml | 9 + ty-excel/src/main/resources/bootstrap.yml | 32 +++ ty-excel/ty-excel.iml | 238 ++++++++++++++++++ .../filter/AuthorizeFilterAfter.java | 135 +++++----- .../tyupload/controller/NacosTestDemo.java | 1 + .../tyupload/controller/TestController.java | 14 ++ ty-user/pom.xml | 5 + .../controller/ErrorCollectionController.java | 2 - .../tyuser/controller/VciController.java | 171 +++++++++++++ .../top/kuanghua/tyuser/entity/Admin.java | 37 +-- .../tyuser/entity/ErrorCollection.java | 6 +- .../java/top/kuanghua/tyuser/entity/Vci.java | 51 ++++ .../tyuser/excel/cv/VciStatusImpCv.java | 35 +++ .../kuanghua/tyuser/excel/cv/VciTimeCv.java | 28 +++ .../tyuser/excel/imp/VciExcelImp.java | 41 +++ .../top/kuanghua/tyuser/mapper/VciMapper.java | 8 + .../kuanghua/tyuser/service/VciService.java | 133 ++++++++++ .../kuanghua/tyuser/vo/ExcelCheckResult.java | 29 +++ ty-user/ty-user.iml | 20 +- 35 files changed, 1504 insertions(+), 87 deletions(-) create mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/entity/CommonParamsSelf.java create mode 100644 ty-excel/pom.xml create mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/ExcelApplication.java create mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/bo/ComplexHeadData.java create mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/bo/CustomStringStringConverter.java create mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/bo/DemoData.java create mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/bo/DemoExtraData.java create mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/bo/RuiDeKqBo.java create mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/config/BaseConfig.java create mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/config/Swagger2Config.java create mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/controller/ExcelController.java create mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/service/DaoService.java create mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/service/ExcelService.java create mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/vo/ExcelCheckResult.java create mode 100644 ty-excel/src/main/resources/application.yml create mode 100644 ty-excel/src/main/resources/bootstrap.yml create mode 100644 ty-excel/ty-excel.iml create mode 100644 ty-upload/src/main/java/top/kuanghua/tyupload/controller/TestController.java create mode 100644 ty-user/src/main/java/top/kuanghua/tyuser/controller/VciController.java create mode 100644 ty-user/src/main/java/top/kuanghua/tyuser/entity/Vci.java create mode 100644 ty-user/src/main/java/top/kuanghua/tyuser/excel/cv/VciStatusImpCv.java create mode 100644 ty-user/src/main/java/top/kuanghua/tyuser/excel/cv/VciTimeCv.java create mode 100644 ty-user/src/main/java/top/kuanghua/tyuser/excel/imp/VciExcelImp.java create mode 100644 ty-user/src/main/java/top/kuanghua/tyuser/mapper/VciMapper.java create mode 100644 ty-user/src/main/java/top/kuanghua/tyuser/service/VciService.java create mode 100644 ty-user/src/main/java/top/kuanghua/tyuser/vo/ExcelCheckResult.java diff --git a/pom.xml b/pom.xml index b3cec92..3a221f6 100644 --- a/pom.xml +++ b/pom.xml @@ -14,6 +14,7 @@ ty-auth ty-user ty-upload + ty-excel diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CommonParamsSelf.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CommonParamsSelf.java new file mode 100644 index 0000000..2d63707 --- /dev/null +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CommonParamsSelf.java @@ -0,0 +1,20 @@ +package top.kuanghua.khcomomon.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Title: CommonParams + * @Description: + * @Auther: kuanghua + * @create 2020/12/15 12:01 + */ +@Data +@ApiModel +public class CommonParamsSelf extends KHCommonPageParams{ + @ApiModelProperty("开始时间") + private String startTime; + @ApiModelProperty("结束时间") + private String endTime; +} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ObjectUtilsSelf.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ObjectUtilsSelf.java index d9abe9f..a9fb5ce 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ObjectUtilsSelf.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ObjectUtilsSelf.java @@ -1,17 +1,15 @@ package top.kuanghua.khcomomon.utils; import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.extension.api.R; -import com.sun.javafx.collections.MappingChange; import org.apache.commons.lang3.StringUtils; import top.kuanghua.khcomomon.entity.ResResult; import java.lang.reflect.Array; +import java.text.SimpleDateFormat; import java.util.Collection; -import java.util.HashMap; +import java.util.Date; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; /** * 从jwt解析得到的数据是Object类型,转换为具体类型可能出现空指针, @@ -101,4 +99,28 @@ public static Map changeToMap(Object resResult){ return res; } + /** + * @return 时间年月日 + */ + public static String getCurrentDateTime(){ + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式 + return df.format(new Date()); + } + + /** + * @return 当前年月 + */ + public static String getCurrentDate(){ + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式 + return df.format(new Date()); + } + + /** + * @param date + * @return + */ + public static String formatDateTime(Date date){ + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式 + return df.format(date); + } } \ No newline at end of file diff --git a/ty-excel/pom.xml b/ty-excel/pom.xml new file mode 100644 index 0000000..83ad1ef --- /dev/null +++ b/ty-excel/pom.xml @@ -0,0 +1,51 @@ + + + + micro-service-plus + top.kuanghua + 1.0-SNAPSHOT + + 4.0.0 + ty-excel + + + + com.alibaba + easyexcel + 3.0.1 + + + top.kuanghua + ty-common + 1.0-SNAPSHOT + + + + + ${project.artifactId} + + + src/main/resources + + true + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.1 + + true + + + + + \ No newline at end of file diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/ExcelApplication.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/ExcelApplication.java new file mode 100644 index 0000000..900de90 --- /dev/null +++ b/ty-excel/src/main/java/top/kuanghua/tyexcel/ExcelApplication.java @@ -0,0 +1,13 @@ +package top.kuanghua.tyexcel; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; + +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) +public class ExcelApplication { + public static void main(String[] args) { + SpringApplication.run(ExcelApplication.class,args); + } +} + diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/ComplexHeadData.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/ComplexHeadData.java new file mode 100644 index 0000000..c216b31 --- /dev/null +++ b/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/ComplexHeadData.java @@ -0,0 +1,16 @@ +package top.kuanghua.tyexcel.bo; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +import java.util.Date; + +@Data +public class ComplexHeadData { + @ExcelProperty({"主标题", "字符串标题"}) + private String string; + @ExcelProperty({"主标题", "日期标题"}) + private Date date; + @ExcelProperty({"主标题", "数字标题"}) + private Double doubleData; +} \ No newline at end of file diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/CustomStringStringConverter.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/CustomStringStringConverter.java new file mode 100644 index 0000000..1b18c3c --- /dev/null +++ b/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/CustomStringStringConverter.java @@ -0,0 +1,15 @@ +package top.kuanghua.tyexcel.bo; + +import com.alibaba.excel.converters.Converter; +import com.alibaba.excel.enums.CellDataTypeEnum; +import com.alibaba.excel.metadata.GlobalConfiguration; +import com.alibaba.excel.metadata.data.ReadCellData; +import com.alibaba.excel.metadata.property.ExcelContentProperty; + + +public class CustomStringStringConverter implements Converter { + @Override + public String convertToJavaData(ReadCellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { + return "自定义:" + cellData.getStringValue(); + } +} \ No newline at end of file diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/DemoData.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/DemoData.java new file mode 100644 index 0000000..c047e4c --- /dev/null +++ b/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/DemoData.java @@ -0,0 +1,24 @@ +package top.kuanghua.tyexcel.bo; + +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.format.DateTimeFormat; +import lombok.Data; + +import java.util.Date; + +@Data +public class DemoData { + @ExcelProperty("字符串标题") + private String string; + @ExcelProperty("日期标题") + @DateTimeFormat("yyyy年MM月dd日HH时mm分ss秒") + private Date date; + @ExcelProperty(value="数字标题",index = 3) + private Double doubleData; + /** + * 忽略这个字段 + */ + @ExcelIgnore + private String ignore; +} \ No newline at end of file diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/DemoExtraData.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/DemoExtraData.java new file mode 100644 index 0000000..40726ca --- /dev/null +++ b/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/DemoExtraData.java @@ -0,0 +1,11 @@ +package top.kuanghua.tyexcel.bo; + +import lombok.Data; + +@Data +public class DemoExtraData { + + private String row1; + + private String row2; +} \ No newline at end of file diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/RuiDeKqBo.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/RuiDeKqBo.java new file mode 100644 index 0000000..f0e6ba9 --- /dev/null +++ b/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/RuiDeKqBo.java @@ -0,0 +1,28 @@ +package top.kuanghua.tyexcel.bo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.format.DateTimeFormat; +import lombok.Data; + +import java.util.Date; + +/** + * @Title: RuiDeKqBo + * @Description: + * @Auther: kuanghua + * @create 2021/7/9 10:27 + */ +@Data +public class RuiDeKqBo { + @ExcelProperty(value = "部门",converter = CustomStringStringConverter.class) + private String department; + @ExcelProperty("姓名") + private String username; + @ExcelProperty("日期") + @DateTimeFormat("yyyy年") + private Date dateTime; + @ExcelProperty("签到时间") + private String checkInTime; + private String row1; + private String row2; +} diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/config/BaseConfig.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/config/BaseConfig.java new file mode 100644 index 0000000..db4a35f --- /dev/null +++ b/ty-excel/src/main/java/top/kuanghua/tyexcel/config/BaseConfig.java @@ -0,0 +1,25 @@ +package top.kuanghua.tyexcel.config; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +/** + * @Title: BaseConfig + * @Description: + * @Auther: kuanghua + * @create 2020/8/23 21:52 + */ +/* + * 总结:1.@Configuration 下的@ComponentScan回将包下带有@Component扫描变成配置类, + * 而@SpringBootApplication扫描的只会变成普通类 + * */ +@Configuration +//扫描公用包的配置和自身的配置类 +@ComponentScan(basePackages = {"top.kuanghua.khcomomon","top.kuanghua.tyexcel"}) +//feign扫描 +//@EnableFeignClients(basePackages = {"top.kuanghua.feign.tyexecl","top.kuanghua.feign.tyauth"}) +//mapper包扫描 +//@MapperScan(basePackages = {"top.kuanghua.tyuser.mapper"}) +public class BaseConfig {} diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/config/Swagger2Config.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/config/Swagger2Config.java new file mode 100644 index 0000000..cbccfd4 --- /dev/null +++ b/ty-excel/src/main/java/top/kuanghua/tyexcel/config/Swagger2Config.java @@ -0,0 +1,56 @@ +package top.kuanghua.tyexcel.config; + +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@Component +@EnableSwagger2 //开启在线接口文档 +//配置包扫描 +public class Swagger2Config { + private boolean swagger_is_enable = true; +// @Value("${.ipAddr}") +// private String ipAddr; + @Value("${server.port}") + private String port; + + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .enable(swagger_is_enable) + //.host(this.ipAddr + ":" + this.port) + .apiInfo(apiInfo()) + .select() + .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) + //.apis(basePackage("top.kuanghua.swagger.controller")) + .paths(PathSelectors.any()) + .build(); + } + + /** + * 构建 api文档的详细信息函数 + * + * @return + */ + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("标题:swagger文档") + .description("描述:新一代的微服务架构") + .contact(new Contact("jzfai", null, "869653722@qq.com")) + .version("版本号:2.8") + .build(); + } + + /** + * http://localhost:8080/swagger-ui.html + */ +} diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/controller/ExcelController.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/controller/ExcelController.java new file mode 100644 index 0000000..99e9669 --- /dev/null +++ b/ty-excel/src/main/java/top/kuanghua/tyexcel/controller/ExcelController.java @@ -0,0 +1,81 @@ +package top.kuanghua.tyexcel.controller; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import springfox.documentation.annotations.ApiIgnore; +import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; +import top.kuanghua.tyexcel.bo.ComplexHeadData; +import top.kuanghua.tyexcel.bo.DemoData; +import top.kuanghua.tyexcel.bo.RuiDeKqBo; +import top.kuanghua.tyexcel.service.ExcelService; +import top.kuanghua.tyexcel.vo.ExcelCheckResult; + + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @Title: ExcelController + * @Description: + * @Auther: kuanghua + * @create 2021/7/9 11:37 + */ +@RestController +@RequestMapping("excel") +@Api(tags="文档导入相关") +@Slf4j +public class ExcelController { + + @Autowired + private ExcelService excelService; + + @ApiOperation("导入excel") + @PostMapping("importExcel") + public ResResult importExcel(@RequestParam("file") MultipartFile file) throws IOException { + ExcelCheckResult excelCheckResult = excelService.importExcel(file.getInputStream()); + return new ResResult().success(excelCheckResult); + } + + private List data() { + List list = new ArrayList(); + for (int i = 0; i < 10; i++) { + DemoData data = new DemoData(); + data.setString("字符串" + i); + data.setDate(new Date()); + data.setDoubleData(0.56); + list.add(data); + } + return list; + } + + @ApiOperation("导出excel") + @PostMapping("exportExcel") + public void exportExcel(HttpServletResponse response) throws IOException { + + // 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 + String fileName = URLEncoder.encode("测试", "UTF-8").replaceAll("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); + EasyExcel.write(response.getOutputStream(), ComplexHeadData.class).sheet("模板").doWrite(data()); + +// excelService.exportExcel(); +// return new ResResult().success(); + } +} diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/service/DaoService.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/service/DaoService.java new file mode 100644 index 0000000..90805f7 --- /dev/null +++ b/ty-excel/src/main/java/top/kuanghua/tyexcel/service/DaoService.java @@ -0,0 +1,36 @@ +package top.kuanghua.tyexcel.service; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.enums.CellExtraTypeEnum; +import com.alibaba.excel.exception.ExcelDataConvertException; +import com.alibaba.excel.metadata.CellExtra; +import com.alibaba.excel.metadata.data.ReadCellData; +import com.alibaba.excel.read.listener.ReadListener; +import com.alibaba.fastjson.JSON; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import top.kuanghua.tyexcel.bo.RuiDeKqBo; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +; + +/** + * @Title: ExeclService + * @Description: + * @Auther: kuanghua + * @create 2021/7/9 11:35 + */ +@Service +@Slf4j +public class DaoService { + public void test(){ + log.info("testInfo"); + } + +} + diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/service/ExcelService.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/service/ExcelService.java new file mode 100644 index 0000000..82ec61b --- /dev/null +++ b/ty-excel/src/main/java/top/kuanghua/tyexcel/service/ExcelService.java @@ -0,0 +1,160 @@ +package top.kuanghua.tyexcel.service; + +import com.alibaba.excel.context.AnalysisContext; + +import com.alibaba.excel.enums.CellExtraTypeEnum; +import com.alibaba.excel.exception.ExcelDataConvertException; +import com.alibaba.excel.metadata.CellExtra; +import com.alibaba.excel.metadata.data.ReadCellData; +import com.alibaba.excel.read.listener.ReadListener; +import com.alibaba.fastjson.JSON; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import top.kuanghua.tyexcel.bo.RuiDeKqBo; +import com.alibaba.excel.EasyExcel; +import org.springframework.stereotype.Service; +import top.kuanghua.tyexcel.vo.ExcelCheckResult; + + +import java.io.InputStream; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.*; + +; + +/** + * @Title: ExeclService + * @Description: + * @Auther: kuanghua + * @create 2021/7/9 11:35 + */ +@Service +@Slf4j +public class ExcelService { + + @Autowired + private DaoService daoService; + + public ExcelCheckResult importExcel(InputStream fileName) { + + List errLogList = new ArrayList<>(); + List successList = new ArrayList<>(); + + EasyExcel.read(fileName, RuiDeKqBo.class, new ReadListener() { + /** + * 单次缓存的数据量 + */ + public static final int BATCH_COUNT = 3000; + /** + *临时存储 + */ + private List cachedData = new ArrayList<>(BATCH_COUNT); + + @Override + public void onException(Exception exception, AnalysisContext context) throws Exception { + log.error("解析失败,但是继续解析下一行:{}", exception.getMessage()); + // 如果是某一个单元格的转换异常 能获取到具体行号 + // 如果要获取头的信息 配合invokeHeadMap使用 + if (exception instanceof ExcelDataConvertException) { + ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception; + + String formatString = MessageFormat.format("第{0}行,第{1}列解析异常", + excelDataConvertException.getRowIndex(), excelDataConvertException.getColumnIndex()); + + errLogList.add(formatString); + + } + } + + @Override + public void invokeHead(Map> headMap, AnalysisContext context) { +// System.out.println("头数据"); +// System.out.println(JSON.toJSONString(headMap)); + } + + @Override + public void invoke(RuiDeKqBo data, AnalysisContext context) { + successList.add(data); + cachedData.add(data); + if (cachedData.size() >= BATCH_COUNT) { + saveData(); + // 存储完成清理 list + cachedData = new ArrayList<>(BATCH_COUNT); + } + } + @Override + public void extra(CellExtra extra, AnalysisContext context) { + log.info("读取到了一条额外信息:{}", JSON.toJSONString(extra)); + switch (extra.getType()) { + case COMMENT: + log.info("额外信息是批注,在rowIndex:{},columnIndex;{},内容是:{}", extra.getRowIndex(), extra.getColumnIndex(), + extra.getText()); + break; + case HYPERLINK: + if ("Sheet1!A1".equals(extra.getText())) { + log.info("额外信息是超链接,在rowIndex:{},columnIndex;{},内容是:{}", extra.getRowIndex(), + extra.getColumnIndex(), extra.getText()); + } else if ("Sheet2!A1".equals(extra.getText())) { + log.info("额外信息是超链接,而且覆盖了一个区间,在firstRowIndex:{},firstColumnIndex;{},lastRowIndex:{},lastColumnIndex:{}," + + "内容是:{}", + extra.getFirstRowIndex(), extra.getFirstColumnIndex(), extra.getLastRowIndex(), + extra.getLastColumnIndex(), extra.getText()); + } else { + log.info("Unknown hyperlink!"); + } + break; + case MERGE: + log.info( + "额外信息是超链接,而且覆盖了一个区间,在firstRowIndex:{},firstColumnIndex;{},lastRowIndex:{},lastColumnIndex:{}", + extra.getFirstRowIndex(), extra.getFirstColumnIndex(), extra.getLastRowIndex(), + extra.getLastColumnIndex()); + break; + default: + } + + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { +// daoService.test(); +// saveData(); +// log.info(excelCheckResult.toString()); + } + + /** + * 加上存储数据库 + */ + private void saveData() { + log.info("{}条数据,开始存储数据库!", cachedData.size()); + log.info("存储数据库成功!"); + + + } + + + //注:headRowNumber(1)如果不写会自动匹配 + })// 需要读取批注 默认不读取 + .extraRead(CellExtraTypeEnum.COMMENT) + // 需要读取超链接 默认不读取 + .extraRead(CellExtraTypeEnum.HYPERLINK) + // 需要读取合并单元格信息 默认不读取 + .extraRead(CellExtraTypeEnum.MERGE).sheet().headRowNumber(1).doRead(); + + return new ExcelCheckResult(errLogList, successList); + } + + /* + * 导出Excel + * */ +// public void exportExcel() { +// String fileName = "D:\\construct\\micro-service-plus\\ty-excel\\src\\main\\java\\top\\kuanghua\\tyexcel\\" + System.currentTimeMillis() + ".xlsx"; +// +// Set excludeColumnFiledNames = new HashSet(); +// excludeColumnFiledNames.add("date"); +// // 这里 需要指定写用哪个class去写,然后写到第一个sheet,名字为模板 然后文件流会自动关闭 +// EasyExcel.write(fileName, ComplexHeadData.class).sheet("模板") +// .doWrite(data()); +// } +} + diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/vo/ExcelCheckResult.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/vo/ExcelCheckResult.java new file mode 100644 index 0000000..c1ae3e1 --- /dev/null +++ b/ty-excel/src/main/java/top/kuanghua/tyexcel/vo/ExcelCheckResult.java @@ -0,0 +1,29 @@ +package top.kuanghua.tyexcel.vo; + +import lombok.Data; + +import java.util.List; + +/** + * @Title: ExcelCheckResult + * @Description: + * @Auther: kuanghua + * @create 2021-11-02 11:33 + */ + +@Data +public class ExcelCheckResult { + private int errNum; + private int successNum; + private boolean checkResult; + private List errList; + private List successList; + + public ExcelCheckResult(List errList, List successList) { + this.errList = errList; + this.successList = successList; + this.errNum=errList.size(); + this.successNum=successList.size(); + this.checkResult=errList.size()==0; + } +} diff --git a/ty-excel/src/main/resources/application.yml b/ty-excel/src/main/resources/application.yml new file mode 100644 index 0000000..3cd6781 --- /dev/null +++ b/ty-excel/src/main/resources/application.yml @@ -0,0 +1,9 @@ +server: + port: ${envpt.tomcatPortPre}0135 + +#限制spring上传文件大小为20M +spring: + servlet: + multipart: + max-file-size: 20MB + max-request-size: 20MB \ No newline at end of file diff --git a/ty-excel/src/main/resources/bootstrap.yml b/ty-excel/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..97d7d53 --- /dev/null +++ b/ty-excel/src/main/resources/bootstrap.yml @@ -0,0 +1,32 @@ +spring: + application: + name: @project.artifactId@ + profiles: + active: @activatedProperties@ + cloud: + nacos: + config: + enabled: true + namespace: @nacosNamespace@ + group: @nacosGroup@ + username: @nacosUsername@ + password: @nacosPassword@ + server-addr: @nacosIpPort@ + prefix: @project.artifactId@ + file-extension: yml + # 用于共享的配置文件 + shared-configs: + - data-id: application-@activatedProperties@.yml + group: @nacosGroup@ + refresh: true + extension-configs: + - data-id: @project.artifactId@.yml + group: @nacosGroup@ + refresh: true + discovery: + namespace: @nacosNamespace@ + group: @nacosGroup@ + username: @nacosUsername@ + password: @nacosPassword@ + server-addr: @nacosIpPort@ + weight: @nacosWeight@ \ No newline at end of file diff --git a/ty-excel/ty-excel.iml b/ty-excel/ty-excel.iml new file mode 100644 index 0000000..ac0db2e --- /dev/null +++ b/ty-excel/ty-excel.iml @@ -0,0 +1,238 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java index 5e9c191..1fdc000 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java @@ -16,6 +16,7 @@ import org.springframework.core.io.buffer.DataBufferFactory; import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.io.buffer.DefaultDataBufferFactory; +import org.springframework.http.HttpHeaders; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.http.server.reactive.ServerHttpResponseDecorator; @@ -26,10 +27,12 @@ import top.kuanghua.feign.tyauth.feign.TokenFeign; import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; +import javax.annotation.Resource; import java.net.URLDecoder; import java.net.URLEncoder; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.List; import java.util.Map; /** @@ -45,9 +48,13 @@ public class AuthorizeFilterAfter implements GlobalFilter, Ordered { @Value("#{'${filter.allowPaths:}'.empty ? null : '${filter.allowPaths:}'.split(',')}") private List allowPaths; - @Autowired + + @Value("#{'${filter.notValidExpList:}'.empty ? null : '${filter.notValidExpList:}'.split(',')}") + private List notValidExpList; + + @Resource private TokenFeign tokenFeign; -// @Value("${jwt-properties.pubKeyPath}") + // @Value("${jwt-properties.pubKeyPath}") // private String pubKeyPath; @Value("${token-properties.renewTokenMinute}") private int renewTokenMinute; @@ -65,65 +72,79 @@ public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { return chain.filter(exchange); } } - ServerHttpResponseDecorator decoratedResponse = new ServerHttpResponseDecorator(response) { - @Override - public Mono writeWith(Publisher body) { - if (body instanceof Flux) { - Flux fluxBody = (Flux) body; - return super.writeWith(fluxBody.buffer().map(dataBuffers -> { - DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory(); - DataBuffer join = dataBufferFactory.join(dataBuffers); - byte[] content = new byte[join.readableByteCount()]; - join.read(content); - // 释放掉内存 - DataBufferUtils.release(join); - String str = new String(content, Charset.forName("UTF-8")); -// log.info("返回体:{}", str); - //todo 拦截到的返回体内容,可以随意去操作了 - //2.1.2 如果小于一个小时 刷新token - //String jwtToken = request.getHeaders().getFirst("AUTHORIZE_TOKEN"); - Long expValue = null; - Map dataMap=null; - try { -// Object reqData=tokenFeign.parseToken(jwtToken); -// Map map = JSON.parseObject(JSON.toJSONString(reqData), Map.class); - String tokenInfo = request.getHeaders().getFirst("TOKEN_INFO"); - //System.out.println("获取到新的token"+tokenInfo); - dataMap = JSON.parseObject(URLDecoder.decode(tokenInfo, "utf-8"), Map.class); - expValue = ObjectUtilsSelf.toLong(ObjectUtilsSelf.toString(dataMap.get("exp"))+"000"); - } catch (Exception e) { - e.printStackTrace(); - } - Long currentData= DateTime.now().plusMinutes(renewTokenMinute).getMillis(); - Map strMap=JSON.parseObject(str, Map.class); - if(ObjectUtils.isNotEmpty(expValue)&&expValue < currentData){ - String generateToken=null; + + //不校验exp时间 + for (String allowPath : notValidExpList) { + if(StringUtils.contains(path,allowPath)){ + return chain.filter(exchange); + } + } + + //获取token信息比较exp和当前时间进行比较 + ServerHttpResponseDecorator decoratedResponse = null; + try { + decoratedResponse = new ServerHttpResponseDecorator(response) { + @Override + public Mono writeWith(Publisher body) { + if (body instanceof Flux) { + Flux fluxBody = (Flux) body; + return super.writeWith(fluxBody.buffer().map(dataBuffers -> { + DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory(); + DataBuffer join = dataBufferFactory.join(dataBuffers); + byte[] content = new byte[join.readableByteCount()]; + join.read(content); + // 释放掉内存 + DataBufferUtils.release(join); + String str = new String(content, Charset.forName("UTF-8")); + // log.info("返回体:{}", str); + //todo 拦截到的返回体内容,可以随意去操作了 + //2.1.2 如果小于一个小时 刷新token + //String jwtToken = request.getHeaders().getFirst("AUTHORIZE_TOKEN"); + Long expValue = null; + Map dataMap=null; try { - //使用本地生成 - //generateToken = JwtUtilsKh.updateToken(dataMap, RsaUtils.getPrivateKey(priKeyPath), 62); - //调用ty-auth进行生成 - dataMap.remove("exp"); - dataMap.remove("iat"); - Object object = tokenFeign.updateToken(dataMap); - if(ObjectUtilsSelf.isEmpty(object)){ - return bufferFactory.wrap(str.getBytes()); - } - Map map = JSON.parseObject(JSON.toJSONString(object), Map.class); - generateToken = ObjectUtilsSelf.toString(map.get("data")); + // Object reqData=tokenFeign.parseToken(jwtToken); + // Map map = JSON.parseObject(JSON.toJSONString(reqData), Map.class); + String tokenInfo = request.getHeaders().getFirst("TOKEN_INFO"); + //System.out.println("获取到新的token"+tokenInfo); + dataMap = JSON.parseObject(URLDecoder.decode(tokenInfo, "utf-8"), Map.class); + expValue = ObjectUtilsSelf.toLong(ObjectUtilsSelf.toString(dataMap.get("exp"))+"000"); } catch (Exception e) { - //log.error(e.toString()); + e.printStackTrace(); + } + Long currentData= DateTime.now().plusMinutes(renewTokenMinute).getMillis(); + Map strMap=JSON.parseObject(str, Map.class); + if(ObjectUtils.isNotEmpty(expValue)&&expValue < currentData){ + String generateToken=null; + try { + //使用本地生成 + //generateToken = JwtUtilsKh.updateToken(dataMap, RsaUtils.getPrivateKey(priKeyPath), 62); + //调用ty-auth进行生成 + dataMap.remove("exp"); + dataMap.remove("iat"); + Object object = tokenFeign.updateToken(dataMap); + if(ObjectUtilsSelf.isEmpty(object)){ + return bufferFactory.wrap(str.getBytes()); + } + Map map = JSON.parseObject(JSON.toJSONString(object), Map.class); + generateToken = ObjectUtilsSelf.toString(map.get("data")); + } catch (Exception e) { + //log.error(e.toString()); + } + strMap.put("isNeedUpdateToken",true); + strMap.put("updateToken",generateToken); } - strMap.put("isNeedUpdateToken",true); - strMap.put("updateToken",generateToken); - } - response.getHeaders().setContentLength(JSON.toJSONString(strMap).getBytes().length); - return bufferFactory.wrap(JSON.toJSONString(strMap).getBytes()); - })); + response.getHeaders().setContentLength(JSON.toJSONString(strMap).getBytes().length); + return bufferFactory.wrap(JSON.toJSONString(strMap).getBytes()); + })); + } + // if body is not a flux. never got there. + return super.writeWith(body); } - // if body is not a flux. never got there. - return super.writeWith(body); - } - }; + }; + } catch (Exception e) { + return chain.filter(exchange); + } return chain.filter(exchange.mutate().response(decoratedResponse).build()); } diff --git a/ty-upload/src/main/java/top/kuanghua/tyupload/controller/NacosTestDemo.java b/ty-upload/src/main/java/top/kuanghua/tyupload/controller/NacosTestDemo.java index 61a872d..1abe74a 100644 --- a/ty-upload/src/main/java/top/kuanghua/tyupload/controller/NacosTestDemo.java +++ b/ty-upload/src/main/java/top/kuanghua/tyupload/controller/NacosTestDemo.java @@ -3,6 +3,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/ty-upload/src/main/java/top/kuanghua/tyupload/controller/TestController.java b/ty-upload/src/main/java/top/kuanghua/tyupload/controller/TestController.java new file mode 100644 index 0000000..89b5141 --- /dev/null +++ b/ty-upload/src/main/java/top/kuanghua/tyupload/controller/TestController.java @@ -0,0 +1,14 @@ +package top.kuanghua.tyupload.controller; + +import org.springframework.web.bind.annotation.CrossOrigin; + +/** + * @Title: TestController + * @Description: + * @Auther: kuanghua + * @create 2021-11-09 10:57 + */ +@CrossOrigin +public class TestController { + +} \ No newline at end of file diff --git a/ty-user/pom.xml b/ty-user/pom.xml index 21107c4..cb45de4 100644 --- a/ty-user/pom.xml +++ b/ty-user/pom.xml @@ -12,6 +12,11 @@ ty-user + + com.alibaba + easyexcel + 3.0.1 + top.kuanghua ty-common diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java b/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java index 3da6048..3d2fbb0 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java @@ -46,8 +46,6 @@ public ResResult selectPage(ErrorCollection errorCollection, KHCommonParams khCo if (ObjectUtils.isNotEmpty(errorCollection.getCreateTime())) { queryWrapper.or().like("create_time", errorCollection.getCreateTime()); } - - queryWrapper.select("error_log,page_url,create_time,id"); queryWrapper.or().orderByDesc("create_time"); if(StringUtils.isNotEmpty(khCommonParams.getStartTime())) { queryWrapper.or().between("create_time",khCommonParams.getStartTime(),khCommonParams.getEndTime()); diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/controller/VciController.java b/ty-user/src/main/java/top/kuanghua/tyuser/controller/VciController.java new file mode 100644 index 0000000..93a0285 --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuser/controller/VciController.java @@ -0,0 +1,171 @@ +package top.kuanghua.tyuser.controller; + + +import com.alibaba.excel.EasyExcel; +import com.alibaba.nacos.api.naming.CommonParams; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.springframework.web.multipart.MultipartFile; +import top.kuanghua.khcomomon.entity.CommonParamsSelf; +import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; +import top.kuanghua.tyuser.entity.Vci; +import top.kuanghua.tyuser.excel.imp.VciExcelImp; +import top.kuanghua.tyuser.service.VciService; +import org.springframework.web.bind.annotation.*; +import top.kuanghua.tyuser.vo.ExcelCheckResult; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.*; + + +@Api(tags = "VCI设备表(Vci)") +@RestController +@RequestMapping("vci") +public class VciController { + + @Resource + private VciService vciService; + + /** + * 分页查询所有数据 + * @param vci 查询实体 + * @return 所有数据 + */ + @GetMapping("selectPage") + @ApiOperation(value = "分页查询所有数据") + public ResResult selectPage(Vci vci, CommonParamsSelf commonParams) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (ObjectUtils.isNotEmpty(vci.getSn())) { + queryWrapper.like("sn", vci.getSn()); + } + if (ObjectUtils.isNotEmpty(vci.getHardVersion())) { + queryWrapper.like("hard_version", vci.getHardVersion()); + } + if (ObjectUtils.isNotEmpty(vci.getStatus())) { + queryWrapper.like("status", vci.getStatus()); + } + //根据创建时间查询 + queryWrapper.orderByDesc("create_time"); + if(StringUtils.isNotEmpty(commonParams.getStartTime())) { + queryWrapper.between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); + } + + queryWrapper.select("id,sn,hard_version,create_time,status,supplier,receipt_no,product_spec"); + Page vciPage = this.vciService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); + return new ResResult().success(vciPage); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("selectById") + @ApiOperation(value = "通过id主键查询单条数据") + public ResResult selectById(@RequestParam("id") Integer id) { + return new ResResult().success(this.vciService.selectById(id)); + } + /** + * @Description: 根据id数组查询品牌列表 + * @Param: idList id数组 + * @return: ids列表数据 + */ + @ApiOperation(value = "根据id数组查询品牌列表") + @PostMapping("selectBatchIds") + public ResResult selectBatchIds(@RequestParam("idList") List idList) { + return new ResResult().success(this.vciService.selectBatchIds(idList)); + } + /** + * 新增数据 + * @param vci 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping("insert") + public ResResult insert(@RequestBody Vci vci) { + return new ResResult().success(this.vciService.insert(vci)); + } + + /** + * 修改数据 + * @param vci 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "根据id修改数据") + @PutMapping("updateById") + public ResResult updateById(@RequestBody Vci vci) { + return new ResResult().success(this.vciService.updateById(vci)); + } + + /** + * 删除数据 + * @param idList 主键结合 + * @return 删除结果 + */ + @ApiOperation(value = "根据id数组删除数据") + @DeleteMapping("deleteBatchIds") + public ResResult deleteBatchIds(@RequestBody List idList) { + return new ResResult().success(this.vciService.deleteBatchIds(idList)); + } + + @DeleteMapping("deleteById") + @ApiOperation(value = "根据id数组删除数据") + public ResResult deleteById(@RequestParam("id") Integer id) { + return new ResResult().success(this.vciService.deleteById(id)); + } + + @ApiOperation("检查excel") + @PostMapping("validExcel") + public ResResult validExcel(@RequestParam("file") MultipartFile file) throws IOException { + ExcelCheckResult checkResult = vciService.validExcel(file.getInputStream()); + return new ResResult().success(checkResult); + } + + @ApiOperation("导入excel") + @PostMapping("importExcel") + public ResResult importExcel(@RequestBody List vciExcelBo) { + vciService.importExcel(vciExcelBo); + return new ResResult().success(); + } + + @ApiOperation("导出excel") + @GetMapping("exportExcel") + public void exportExcel(HttpServletResponse response,Vci vci, CommonParamsSelf commonParams) throws IOException { + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (ObjectUtils.isNotEmpty(vci.getSn())) { + queryWrapper.like("sn", vci.getSn()); + } + if (ObjectUtils.isNotEmpty(vci.getHardVersion())) { + queryWrapper.like("hard_version", vci.getHardVersion()); + } + if (ObjectUtils.isNotEmpty(vci.getStatus())) { + queryWrapper.like("status", vci.getStatus()); + } + //根据创建时间查询 + queryWrapper.orderByDesc("create_time"); + if(StringUtils.isNotEmpty(commonParams.getStartTime())) { + queryWrapper.between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); + } + + queryWrapper.select("sn,hard_version,create_time,status,supplier,receipt_no,product_spec"); + Page vciPage = this.vciService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); + // 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + + String fileName = URLEncoder.encode("Vci导出数据", "UTF-8")+"-"+ ObjectUtilsSelf.getCurrentDateTime(); + response.setHeader("Access-Control-Expose-Headers", "exportFileName"); + response.setHeader("exportFileName", fileName + ".xlsx" ); + EasyExcel.write(response.getOutputStream(), VciExcelImp.class).sheet("模板").doWrite(vciPage.getRecords()); + } + +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/entity/Admin.java b/ty-user/src/main/java/top/kuanghua/tyuser/entity/Admin.java index ead9133..3ec4619 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/entity/Admin.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/entity/Admin.java @@ -19,23 +19,24 @@ @ApiModel("用户列表") @TableName(value = "tb_admin") public class Admin extends Model { - private Integer id; - private String status; - private Date addTime; - @ApiModelProperty(value="超级管理员(0.不是,1.是)") - private String isSuper; - @ApiModelProperty(value="用户名") - private String username; - @ApiModelProperty(value="密码") - private String password; - @ApiModelProperty(value="是否删除") - private String isDelete; - @ApiModelProperty(value="手机号") - private String mobile; - @ApiModelProperty(value="邮箱") - private String email; - @ApiModelProperty(value="角色id") - private Integer roleId; + private Integer id; + private String status; + private Date addTime; + @ApiModelProperty(value = "超级管理员(0.不是,1.是)") + private String isSuper; + @ApiModelProperty(value = "用户名") + private String username; + @ApiModelProperty(value = "密码") + private String password; + @ApiModelProperty(value = "是否删除") + private String isDelete; + @ApiModelProperty(value = "手机号") + private String mobile; + @ApiModelProperty(value = "邮箱") + private String email; + @ApiModelProperty(value = "角色id") + private Integer roleId; + /** * 获取主键值 * @@ -45,4 +46,4 @@ public class Admin extends Model { protected Serializable pkVal() { return this.id; } - } +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/entity/ErrorCollection.java b/ty-user/src/main/java/top/kuanghua/tyuser/entity/ErrorCollection.java index d205c1f..85f0dc8 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/entity/ErrorCollection.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/entity/ErrorCollection.java @@ -22,6 +22,8 @@ @ApiModel("错误日志相关") @TableName(value = "tb_error_collection") public class ErrorCollection extends Model { + @ApiModelProperty(value = "id主键") + private Long id; @ApiModelProperty(value = "错误日志") private String errorLog; @ApiModelProperty(value = "页面路径") @@ -29,6 +31,6 @@ public class ErrorCollection extends Model { @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建时间",hidden = true) private Date createTime; - @ApiModelProperty(value = "id主键") - private Long id; + @ApiModelProperty(value = "浏览器类型",hidden = true) + private String browserType; } diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/entity/Vci.java b/ty-user/src/main/java/top/kuanghua/tyuser/entity/Vci.java new file mode 100644 index 0000000..b06117f --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuser/entity/Vci.java @@ -0,0 +1,51 @@ +package top.kuanghua.tyuser.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * VCI设备表(Vci)表实体类 + * + * @author kuanghua + * @since 2021-10-22 10:34:43 + */ +@Data +@ApiModel("VCI设备表") +@TableName(value = "tb_vci") +public class Vci extends Model { + @ApiModelProperty(value = "ID") + private Integer id; + @ApiModelProperty(value = "序列号,唯一") + private String sn; + @ApiModelProperty(value = "硬件版本") + private String hardVersion; + @ApiModelProperty(value = "状态:0:未出库、1:已入库") + private Integer status; + @ApiModelProperty(value = "供应商") + private String supplier; + @ApiModelProperty(value = "商品规格") + private String productSpec; + @ApiModelProperty(value = "入库单号") + private String receiptNo; + @ApiModelProperty(value = "入库时间") + @TableField(fill = FieldFill.INSERT) + private Date createTime; + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } +} + diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/excel/cv/VciStatusImpCv.java b/ty-user/src/main/java/top/kuanghua/tyuser/excel/cv/VciStatusImpCv.java new file mode 100644 index 0000000..309d6fb --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuser/excel/cv/VciStatusImpCv.java @@ -0,0 +1,35 @@ +package top.kuanghua.tyuser.excel.cv; + +import com.alibaba.excel.converters.Converter; +import com.alibaba.excel.metadata.GlobalConfiguration; +import com.alibaba.excel.metadata.data.ReadCellData; +import com.alibaba.excel.metadata.data.WriteCellData; +import com.alibaba.excel.metadata.property.ExcelContentProperty; + +public class VciStatusImpCv implements Converter { + @Override + public Integer convertToJavaData(ReadCellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { + String stringValue = cellData.getStringValue(); + int csId; + if("未入库".equals(stringValue)){ + csId=0; + }else if("已入库".equals(stringValue)){ + csId=1; + }else{ + csId=2; + } + return csId; + } + + //将java的数据类型转为excel数据类型 + @Override + public WriteCellData convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { + String cv=""; + if(0==value){ + cv="未入库"; + }else{ + cv="已入库"; + } + return new WriteCellData<>(cv); + } +} \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/excel/cv/VciTimeCv.java b/ty-user/src/main/java/top/kuanghua/tyuser/excel/cv/VciTimeCv.java new file mode 100644 index 0000000..e11f0ff --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuser/excel/cv/VciTimeCv.java @@ -0,0 +1,28 @@ +package top.kuanghua.tyuser.excel.cv; + +import com.alibaba.excel.converters.Converter; +import com.alibaba.excel.metadata.GlobalConfiguration; +import com.alibaba.excel.metadata.data.ReadCellData; +import com.alibaba.excel.metadata.data.WriteCellData; +import com.alibaba.excel.metadata.property.ExcelContentProperty; +import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; + +import java.text.SimpleDateFormat; +import java.util.Date; + +public class VciTimeCv implements Converter { + @Override + public Date convertToJavaData(ReadCellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { + String stringValue = cellData.getNumberValue().toString() ; + String DATE_FORMAT = "yyyyMMdd"; + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMAT); + Date parse = simpleDateFormat.parse(stringValue); + return parse; + } + + @Override + public WriteCellData convertToExcelData(Date value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { + return new WriteCellData<>(ObjectUtilsSelf.formatDateTime(value)); + } + +} \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/excel/imp/VciExcelImp.java b/ty-user/src/main/java/top/kuanghua/tyuser/excel/imp/VciExcelImp.java new file mode 100644 index 0000000..b9a641d --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuser/excel/imp/VciExcelImp.java @@ -0,0 +1,41 @@ +package top.kuanghua.tyuser.excel.imp; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; +import top.kuanghua.tyuser.excel.cv.VciStatusImpCv; +import top.kuanghua.tyuser.excel.cv.VciTimeCv; + +import java.util.Date; + +/** + * VCI设备表(Vci)表实体类 + * + * @author kuanghua + * @since 2021-10-22 10:34:43 + */ +@Data +public class VciExcelImp{ + //供应商 + @ExcelProperty(value = "供应商") + private String supplier; + // 商品名称 + // 设备号 + @ExcelProperty(value = "设备号") + private String sn; + // 硬件版本 + @ExcelProperty(value = "硬件版本") + private String hardVersion; + // 商品规格 + @ExcelProperty(value = "商品规格") + private String productSpec; + // 入库单号(批次号) + @ExcelProperty(value = "入库单号(批次号)") + private String receiptNo; + // 入库状态 + @ExcelProperty(value = "入库状态",converter = VciStatusImpCv.class) + private Integer status; + // 入库时间 + @ExcelProperty(value = "入库时间",converter = VciTimeCv.class) + private Date createTime; +} + diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/VciMapper.java b/ty-user/src/main/java/top/kuanghua/tyuser/mapper/VciMapper.java new file mode 100644 index 0000000..7f1e3c9 --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuser/mapper/VciMapper.java @@ -0,0 +1,8 @@ +package top.kuanghua.tyuser.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.tyuser.entity.Vci; + +public interface VciMapper extends BaseMapper { + +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/service/VciService.java b/ty-user/src/main/java/top/kuanghua/tyuser/service/VciService.java new file mode 100644 index 0000000..80ba931 --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuser/service/VciService.java @@ -0,0 +1,133 @@ +package top.kuanghua.tyuser.service; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.exception.ExcelDataConvertException; +import com.alibaba.excel.read.listener.ReadListener; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Service; +import top.kuanghua.tyuser.entity.Vci; +import top.kuanghua.tyuser.excel.imp.VciExcelImp; +import top.kuanghua.tyuser.mapper.VciMapper; +import top.kuanghua.tyuser.vo.ExcelCheckResult; + +import javax.annotation.Resource; +import java.io.InputStream; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; + +/** + * (Vci) + * + * @author kuanghua + * @since 2021-10-20 16:14:17 + */ +@Service +public class VciService { + + @Resource + private VciMapper vciMapper; + + public Page selectPage(Integer pageNum, Integer pageSize, QueryWrapper queryWrapper) { + return this.vciMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); + } + + public Vci selectById(Integer id) { + return this.vciMapper.selectById(id); + } + + public List selectBatchIds(List idList) { + return this.vciMapper.selectBatchIds(idList); + } + + public int insert(Vci vci) { + return this.vciMapper.insert(vci); + } + + public int updateById(Vci vci) { + return this.vciMapper.updateById(vci); + } + + public int deleteById(Integer id) { + return this.vciMapper.deleteById(id); + } + + public int deleteBatchIds(List idList) { + return this.vciMapper.deleteBatchIds(idList); + } + + /** + * 导入文件校验 + * @param fileName + * @return + */ + public ExcelCheckResult validExcel(InputStream fileName) { + List errLogList = new ArrayList<>(); + List successList = new ArrayList<>(); + EasyExcel.read(fileName, VciExcelImp.class, new ReadListener() { + /** + * 单次缓存的数据量 + */ + static final int BATCH_COUNT = 3000; + /** + * 临时存储 + */ + private List cachedData = new ArrayList<>(BATCH_COUNT); + + @Override + public void onException(Exception exception, AnalysisContext context) throws Exception { + // 如果是某一个单元格的转换异常 能获取到具体行号 + // 如果要获取头的信息 配合invokeHeadMap使用 + if (exception instanceof ExcelDataConvertException) { + ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception; + + String formatString = MessageFormat.format("第{0}行,第{1}列解析异常", + excelDataConvertException.getRowIndex(), excelDataConvertException.getColumnIndex()); + + errLogList.add(formatString); + + } + } + + @Override + public void invoke(VciExcelImp data, AnalysisContext context) { + successList.add(data); + cachedData.add(data); + if (cachedData.size() >= BATCH_COUNT) { + saveData(); + // 存储完成清理 list + cachedData = new ArrayList<>(BATCH_COUNT); + } + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + + } + + /** + * 加上存储数据库 + */ + private void saveData() { + + + } + }).sheet().headRowNumber(1).doRead(); + return new ExcelCheckResult<>(errLogList, successList); + } + + /** + * 导入 + * @param listData + */ + public void importExcel(List listData){ + listData.forEach((item) -> { + //售后维修表 + Vci vci = JSON.parseObject(JSON.toJSONString(item), Vci.class); + vciMapper.insert(vci); + }); + } +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/vo/ExcelCheckResult.java b/ty-user/src/main/java/top/kuanghua/tyuser/vo/ExcelCheckResult.java new file mode 100644 index 0000000..483ecb6 --- /dev/null +++ b/ty-user/src/main/java/top/kuanghua/tyuser/vo/ExcelCheckResult.java @@ -0,0 +1,29 @@ +package top.kuanghua.tyuser.vo; + +import lombok.Data; + +import java.util.List; + +/** + * @Title: ExcelCheckResult + * @Description: + * @Auther: kuanghua + * @create 2021-11-02 11:33 + */ + +@Data +public class ExcelCheckResult { + private int errNum; + private int successNum; + private boolean checkResult; + private List errList; + private List successList; + + public ExcelCheckResult(List errList, List successList) { + this.errList = errList; + this.successList = successList; + this.errNum=errList.size(); + this.successNum=successList.size(); + this.checkResult=errList.size()==0; + } +} diff --git a/ty-user/ty-user.iml b/ty-user/ty-user.iml index 94b3e31..0ccd583 100644 --- a/ty-user/ty-user.iml +++ b/ty-user/ty-user.iml @@ -20,6 +20,22 @@ + + + + + + + + + + + + + + + + @@ -127,7 +143,6 @@ - @@ -148,7 +163,6 @@ - @@ -157,7 +171,6 @@ - @@ -178,7 +191,6 @@ - From 2582ec168029155c201a3543bdb35917ce08a514 Mon Sep 17 00:00:00 2001 From: kuanghua <869653722@qq.com> Date: Thu, 11 Nov 2021 18:57:18 +0800 Subject: [PATCH 07/36] func of element-svg icon for side menu --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7bb514f..f532b1f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -#### 更新日志 +``#### 更新日志 ``` // 2021-09-15 1.增加了文件上传下载,为vue3-element-plus提供例子数据 @@ -45,13 +45,13 @@ ty-upload:文件上传服务。使用的技术为fastDFS技术,此服务主 1.在网关中将jwt token和解析后的token信息已经设置在请求头中,在后续转发的微服务可以在请求头中轻松的拿到token和token解析后的数据,不用再通过feign去调用ty-auth获取token信息 ``` -![1631692199271](http://8.135.1.141/file/images/1631692199271.png) +![1631692199271](http://8.135.1.141/file/images/java1.png) ``` 2.此时微服务已经可以在请求通中获取到token和信息,但是feign调用其他微服务的时候却出现了token丢失的情况,此时需要在feign调用服务时将请求头一起转发,那么微服务之前调用时也能获取都token和信息 ``` -![1631692308212](http://8.135.1.141/file/images/1631692308212.png) +![1631692308212](http://8.135.1.141/file/images/java2.png) ``` 3.少于1天时间自动更新token,主要通过gateway的两个拦截器来完成 @@ -61,7 +61,7 @@ AuthorizeFilterAfter:请求后拦截。主要用于token更新校验,和生 https://github.com/jzfai/vue3-admin-template ``` -![1631693000767](http://8.135.1.141/file/images/1631693000767.png) +![1631693000767](http://8.135.1.141/file/images/java3.png) ``` 4.多环境和nacos: @@ -78,9 +78,9 @@ nacos: 优先级:naocs默认加载的config配置文件->extension-configs-> shared-configs ``` -![1631693866876](http://8.135.1.141/file/images/1631693866876.png) +![1631693866876](http://8.135.1.141/file/images/java4.png) -![1631694125676](http://8.135.1.141/file/images/1631694125676.png) +![1631694125676](http://8.135.1.141/file/images/java5.png) ``` 5.easycode模板配置: @@ -89,7 +89,7 @@ nacos: https://www.jianshu.com/p/e4192d7c6844 ``` -![1631695768271](http://8.135.1.141/file/images/1631695768271.png) +![1631695768271](http://8.135.1.141/file/images/java6.png) ### 如何运行 From 480b6a62b73bab6f997c1b44a05863aee3029514 Mon Sep 17 00:00:00 2001 From: jzfai <869653722@qq.com> Date: Thu, 23 Dec 2021 18:31:44 +0800 Subject: [PATCH 08/36] update some func --- README-zh_CN.md | 79 +++ README.md | 187 +++---- controller.mv | 20 +- element-form.mv | 175 +++--- element-table.mv | 127 ++--- entity.mv | 34 +- nacos_config_export_20210915163624.zip | Bin 9322 -> 0 bytes nacos_config_export_20211223172459.zip | Bin 0 -> 14041 bytes oldElementDemo.mv | 512 ------------------ pom.xml | 35 +- .../kuanghua/khcomomon/entity/ResResult.java | 2 +- .../gatewaytwo/GatewayOneApplication.java | 2 +- .../filter/AuthorizeFilterAfter.java | 6 +- .../filter/AuthorizeFilterBefore.java | 14 - .../gatewaytwo/filter/StringTest.java | 24 - .../controller/ErrorCollectionController.java | 6 +- .../tyuser/entity/ErrorCollection.java | 7 +- 17 files changed, 378 insertions(+), 852 deletions(-) create mode 100644 README-zh_CN.md delete mode 100644 nacos_config_export_20210915163624.zip create mode 100644 nacos_config_export_20211223172459.zip delete mode 100644 oldElementDemo.mv delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/StringTest.java diff --git a/README-zh_CN.md b/README-zh_CN.md new file mode 100644 index 0000000..ff082aa --- /dev/null +++ b/README-zh_CN.md @@ -0,0 +1,79 @@ +### 前言 + +本架构为springCloud微服务架构,提供基本的jwt权限认证,token更新,以及各微服务之间调用等 +使用的技术如下: + +```json +spring-boot:2.1.4.RELEASE +spring-cloud:Greenwich.SR1 +spring-cloud-starter-gateway:2.1.1.RELEASE +nacos:2.1.3.RELEASE +mybatis-plus: 3.3.2 +rabbitmq:3.7-management +redis: 3.2.9 +mysql:5.7 +``` + +#### 更新日志: + +to look doc ---- +[真香定律!带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7036302298435289095) + +#### 线上文档: + +[真香定律!带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7036302298435289095) + +#### 开发接口和nacos地址 + +[swager文档地址](http://8.135.1.141/micro-service-doc/swagger-ui.html) + +[nacos地址](http://8.135.1.141:8848/nacos/) naocs: 用户名:jzfai; 密码:123456 + + +#### 线上体验地址: + +[github address](https://github.com/jzfai/micro-service-plus.git) + +[Access address](http://8.135.1.141/vue3-admin-plus) + +国内体验地址:http://8.135.1.141/vue3-admin-plus + +github 地址: https://github.com/jzfai/micro-service-plus.git + + + +#### 目前实现的微服务(后续还会新增新的微服务) + +``` +ty-common: 统一依赖,统一配置管理,feign接口整合等 +本架构的微服务有: +ty-gateway:网关微服务。使用的是spring-cloud-starter-gateway,先对于zull网关来说性能更好。主要实现了,权限控制和拦截,jwt token解析和校验,swagger文件整合,使用令牌技术请求限流等 +ty-auth:权限服务。jwt token生成,解析,校验等,默认配置3天有效期,少于一天自动续约(此处感兴趣的可以查看下源码) +ty-user:用户服务。用户的登录,注册,查看用户信息等一系列功能 +ty-excel:excel文件的读取和导出 +ty-upload:文件上传服务。使用的技术为fastDFS技术,此服务主要用于文件的上传和下载 +``` + + +#### 如何运行 + +```java +//git clone项目 +git clone https://github.com/jzfai/micro-service-plus.git + +//maven 下载依赖,即可运行 +``` + +>注:在Maven Projects->Profies 选择环境时,请不要选择prod环境。目前线上是prod环境下构建的包 + +#### 架构亮点 + +1.网关中将jwt token和解析后的token信息已经设置在请求头中,在后续转发的微服务可以在请求头中,轻松的拿到token和token解析后的数据。不用再通过feign去调用ty-auth,获取token信息。 + +2.各微服务在调用期间,会将请求头的token进行转发。所以在用feign调用微服务时token也不会丢失。 + +3.少于1天时间自动更新token,通过isNeedUpdateToken字段告诉前端需要更新token,实现了token续约的功能 + +4.多环境随意切换。在根目录下的pom.xml配置了profiles可以根据你的需要进行切换环境 + +5.提供了vue3+element-plus和mybits-plus相关的easycode模板。你可以一次性生成前后端模板,极大提高开发效率 \ No newline at end of file diff --git a/README.md b/README.md index f532b1f..ff082aa 100644 --- a/README.md +++ b/README.md @@ -1,108 +1,79 @@ -``#### 更新日志 -``` -// 2021-09-15 -1.增加了文件上传下载,为vue3-element-plus提供例子数据 -``` - -### 前言 -``` -本架构使用的技术为: -spring-boot:2.1.4.RELEASE -spring-cloud:Greenwich.SR1 -spring-cloud-starter-gateway:2.1.1.RELEASE -nacos:2.1.3.RELEASE -mybatis-plus: 3.3.2 -rabbitmq:3.7-management -redis: 3.2.9 -mysql:5.7 -``` - -#### swager文档地址: - -http://8.135.1.141/micro-service-doc/swagger-ui.html - -#### nacos地址(naocs配置请不要删除): - -http://8.135.1.141:8848/nacos/ - -用户名:jzfai -密码:123456 - -#### 微服务(后续还会新增新的微服务) - -``` -ty-common: 统一依赖,统一配置管理,feign接口整合等 -本架构的微服务有: -ty-gateway:网关微服务。使用的是spring-cloud-starter-gateway,先对于zull网关来说性能更好。主要实现了,权限控制和拦截,jwt token解析和校验,swagger文件整合,使用令牌技术请求限流等 -ty-auth:权限服务。jwt token生成,解析,校验等,默认配置3天有效期,少于一天自动续约(此处感兴趣的可以查看下源码) -ty-user:用户服务。用户的登录,注册,查看用户信息等一系列功能 -ty-upload:文件上传服务。使用的技术为fastDFS技术,此服务主要用于文件的上传和下载 -``` - -#### 亮点: - -``` -1.在网关中将jwt token和解析后的token信息已经设置在请求头中,在后续转发的微服务可以在请求头中轻松的拿到token和token解析后的数据,不用再通过feign去调用ty-auth获取token信息 -``` - -![1631692199271](http://8.135.1.141/file/images/java1.png) - -``` -2.此时微服务已经可以在请求通中获取到token和信息,但是feign调用其他微服务的时候却出现了token丢失的情况,此时需要在feign调用服务时将请求头一起转发,那么微服务之前调用时也能获取都token和信息 -``` - -![1631692308212](http://8.135.1.141/file/images/java2.png) - -``` -3.少于1天时间自动更新token,主要通过gateway的两个拦截器来完成 -AuthorizeFilterBefore:请求前拦截。解析token的有效性和是否过期,和配置了白名单的请求方法进行放行 -AuthorizeFilterAfter:请求后拦截。主要用于token更新校验,和生产新的token,通过isNeedUpdateToken字段告诉前端要更新token -如果想知道前端如何更新token可查看: -https://github.com/jzfai/vue3-admin-template -``` - -![1631693000767](http://8.135.1.141/file/images/java3.png) - -``` -4.多环境和nacos: -开发人员可以快速的切换环境以达到开发的目的 -目前为止只添加了 -dev:开发时使用的分支 -prod:发布是切换的分支 -注:配置环境时请在nacos上添加相应的配置文件,不然会报错 -nacos: -注册中心: -通过discovery进行配置,具体可查看源码 -配置中心: -加载顺序:naocs默认加载的config配置文件-> shared-configs->extension-configs -优先级:naocs默认加载的config配置文件->extension-configs-> shared-configs -``` - -![1631693866876](http://8.135.1.141/file/images/java4.png) - -![1631694125676](http://8.135.1.141/file/images/java5.png) - -``` -5.easycode模板配置: -本架构提供了基本的版本生成,可以快速生成,实现前后端的增删改查,前端的easycode生成的模板适配vue-element-template架构,可以把模板直接复制到easycode中生成相应的代码 -不会使用easycode可以查看这里 -https://www.jianshu.com/p/e4192d7c6844 -``` - -![1631695768271](http://8.135.1.141/file/images/java6.png) - -### 如何运行 - -```javascript -克隆项目 -git clone https://github.com/jzfai/micro-service-plus.git -用idea打开项目,加载下载依赖即可运行 -``` - ->注:本项目加入了热更新:运行项目后,使用ctrl+F9快捷键或rebuild下就行直接更新服务 - -#### 如果需要实时交流的可以加入wx群(有vue3+ts视频教程) - - ![http://8.135.1.141/file/images/wx-groud.png](http://8.135.1.141/file/images/wx-groud.png) - -大家的支持是我前进的动力 欢迎加入一起开发 +### 前言 + +本架构为springCloud微服务架构,提供基本的jwt权限认证,token更新,以及各微服务之间调用等 +使用的技术如下: + +```json +spring-boot:2.1.4.RELEASE +spring-cloud:Greenwich.SR1 +spring-cloud-starter-gateway:2.1.1.RELEASE +nacos:2.1.3.RELEASE +mybatis-plus: 3.3.2 +rabbitmq:3.7-management +redis: 3.2.9 +mysql:5.7 +``` + +#### 更新日志: + +to look doc ---- +[真香定律!带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7036302298435289095) + +#### 线上文档: + +[真香定律!带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7036302298435289095) + +#### 开发接口和nacos地址 + +[swager文档地址](http://8.135.1.141/micro-service-doc/swagger-ui.html) + +[nacos地址](http://8.135.1.141:8848/nacos/) naocs: 用户名:jzfai; 密码:123456 + + +#### 线上体验地址: + +[github address](https://github.com/jzfai/micro-service-plus.git) + +[Access address](http://8.135.1.141/vue3-admin-plus) + +国内体验地址:http://8.135.1.141/vue3-admin-plus + +github 地址: https://github.com/jzfai/micro-service-plus.git + + + +#### 目前实现的微服务(后续还会新增新的微服务) + +``` +ty-common: 统一依赖,统一配置管理,feign接口整合等 +本架构的微服务有: +ty-gateway:网关微服务。使用的是spring-cloud-starter-gateway,先对于zull网关来说性能更好。主要实现了,权限控制和拦截,jwt token解析和校验,swagger文件整合,使用令牌技术请求限流等 +ty-auth:权限服务。jwt token生成,解析,校验等,默认配置3天有效期,少于一天自动续约(此处感兴趣的可以查看下源码) +ty-user:用户服务。用户的登录,注册,查看用户信息等一系列功能 +ty-excel:excel文件的读取和导出 +ty-upload:文件上传服务。使用的技术为fastDFS技术,此服务主要用于文件的上传和下载 +``` + + +#### 如何运行 + +```java +//git clone项目 +git clone https://github.com/jzfai/micro-service-plus.git + +//maven 下载依赖,即可运行 +``` + +>注:在Maven Projects->Profies 选择环境时,请不要选择prod环境。目前线上是prod环境下构建的包 + +#### 架构亮点 + +1.网关中将jwt token和解析后的token信息已经设置在请求头中,在后续转发的微服务可以在请求头中,轻松的拿到token和token解析后的数据。不用再通过feign去调用ty-auth,获取token信息。 + +2.各微服务在调用期间,会将请求头的token进行转发。所以在用feign调用微服务时token也不会丢失。 + +3.少于1天时间自动更新token,通过isNeedUpdateToken字段告诉前端需要更新token,实现了token续约的功能 + +4.多环境随意切换。在根目录下的pom.xml配置了profiles可以根据你的需要进行切换环境 + +5.提供了vue3+element-plus和mybits-plus相关的easycode模板。你可以一次性生成前后端模板,极大提高开发效率 \ No newline at end of file diff --git a/controller.mv b/controller.mv index 8b019d4..48c3e1a 100644 --- a/controller.mv +++ b/controller.mv @@ -17,6 +17,9 @@ $!define ##定义实体对象名 #set($entityName = $!tool.firstLowerCase($!tableInfo.name)) + +import org.apache.commons.lang3.StringUtils; +import top.kuanghua.khcomomon.entity.CommonParams; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.api.ApiController; import com.baomidou.mybatisplus.extension.api.R; @@ -45,12 +48,12 @@ private $!{tableInfo.name}Service $!{serviceName}; */ @GetMapping("selectPage") @ApiOperation(value = "分页查询所有数据") -public ResResult selectPage($!{tableInfo.name} $!entityName, KHCommonParams khCommonParams) { +public ResResult selectPage($!{tableInfo.name} $!entityName, CommonParams commonParams) { QueryWrapper<$!{tableInfo.name}> queryWrapper = new QueryWrapper<>(); #foreach($column in $tableInfo.fullColumn) #if( $!column.comment ) if(ObjectUtils.isNotEmpty($!{entityName}.get$!{tool.firstUpperCase($column.name)}())) { - queryWrapper.or().like("$!{column.name}",$!{entityName}.get$!{tool.firstUpperCase($column.name)}()); + queryWrapper.like("$!{tool.hump2Underline($column.name)}",$!{entityName}.get$!{tool.firstUpperCase($column.name)}()); } #end #end @@ -63,12 +66,14 @@ QueryWrapper<$!{tableInfo.name}> queryWrapper = new QueryWrapper<>(); #end -queryWrapper.or().orderByDesc("create_time"); + if(StringUtils.isNotEmpty(commonParams.getStartTime())) { - queryWrapper.or().between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); +queryWrapper.between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); +queryWrapper.or().orderByDesc("create_time"); } + queryWrapper.select("$StringBj.substring(0,$StringBj.lastIndexOf(','))"); -Page<$!{tableInfo.name}> $!{entityName}Page = this.$!{entityName}Service.selectPage(khCommonParams.getPageNum(), khCommonParams.getPageSize(), queryWrapper); +Page<$!{tableInfo.name}> $!{entityName}Page = this.$!{entityName}Service.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); return new ResResult().success($!{entityName}Page); } @@ -127,10 +132,9 @@ public ResResult selectBatchIds(@RequestParam("idList") List idList) { return new ResResult().success(this.$!{serviceName}.deleteBatchIds(idList)); } - @DeleteMapping("deleteById") - @ApiOperation(value = "根据id数组删除数据") + @ApiOperation(value = "根据id删除数据") public ResResult deleteById(@RequestParam("id") Integer id) { return new ResResult().success(this.$!{serviceName}.deleteById(id)); } - } \ No newline at end of file + } \ No newline at end of file diff --git a/element-form.mv b/element-form.mv index 01d87bb..d76b914 100644 --- a/element-form.mv +++ b/element-form.mv @@ -3,36 +3,35 @@ $!init $!define ##定义实体对象名 #set($entityName = $!tool.firstLowerCase($!tableInfo.name)) -#set($serviceName = 'ty-user') +#set($serviceName = 'rbox-service') ##保存文件(宏定义) #save($!{entityName}, "Form.vue") - - - diff --git a/pom.xml b/pom.xml index 3a221f6..2206d2a 100644 --- a/pom.xml +++ b/pom.xml @@ -102,6 +102,24 @@ 123456 + + test + + true + + + test + 8.135.1.141 + ${baseLinuxIp}:8848 + 1000 + 127.0.0.1 + df87d91b-b1ab-4720-8e1c-5a147edc6ddc + nacos-group-${activatedProperties} + jzfai + 123456 + + + prod @@ -119,22 +137,5 @@ 123456 - - - - - - - - - - - - - - - - - diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/ResResult.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/ResResult.java index f8f8f84..f6686a7 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/ResResult.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/ResResult.java @@ -8,7 +8,7 @@ /** * 描述 * - * @author 三国的包子 + * @author kuanghua * @version 1.0 * @package entity * * @since 1.0 diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/GatewayOneApplication.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/GatewayOneApplication.java index b1a98e5..d767278 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/GatewayOneApplication.java +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/GatewayOneApplication.java @@ -29,7 +29,7 @@ public Mono resolve(ServerWebExchange exchange) { //1.获取请求request对象 ServerHttpRequest request = exchange.getRequest(); //2.从request中获取ip地址 - String hostString = request.getRemoteAddress().getHostString(); //Ip地址 + String hostString = request.getRemoteAddress().getHostString(); //3.返回 return Mono.just(hostString); } diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java index 1fdc000..f3ca5c0 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java @@ -96,15 +96,15 @@ public Mono writeWith(Publisher body) { // 释放掉内存 DataBufferUtils.release(join); String str = new String(content, Charset.forName("UTF-8")); - // log.info("返回体:{}", str); + // log.info("返回体:{}", str); //todo 拦截到的返回体内容,可以随意去操作了 //2.1.2 如果小于一个小时 刷新token //String jwtToken = request.getHeaders().getFirst("AUTHORIZE_TOKEN"); Long expValue = null; Map dataMap=null; try { - // Object reqData=tokenFeign.parseToken(jwtToken); - // Map map = JSON.parseObject(JSON.toJSONString(reqData), Map.class); + //Object reqData=tokenFeign.parseToken(jwtToken); + // Map map = JSON.parseObject(JSON.toJSONString(reqData), Map.class); String tokenInfo = request.getHeaders().getFirst("TOKEN_INFO"); //System.out.println("获取到新的token"+tokenInfo); dataMap = JSON.parseObject(URLDecoder.decode(tokenInfo, "utf-8"), Map.class); diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java index 8d49155..587a9a1 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java @@ -103,22 +103,8 @@ public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { httpHeaders.add("TOKEN_INFO", decode); }).build(); //将信息设置到线程中 - //TokenParseInfo tokenParseInfo = new TokenParseInfo(claims); - ServerWebExchange build = exchange.mutate().request(httpRequest).build(); return chain.filter(build); - //2.1.1.将解析出来的jwt token存入请求头中供其他服务读取(转发过去的服务不能接收) - //2.1.2 如果小于一个小时 刷新token -// long expValue = claims.getExpiration().getTime(); -// Long currentData= DateTime.now().plusMinutes(40).getMillis(); -// if(expValue < currentData){ -// String generateToken = JwtUtilsKh.updateToken(claims, RsaUtils.getPrivateKey(priKeyPath), 62); -// JSONObject message = new JSONObject(); -// message.put("code",10000); -// message.put("data",generateToken); -// message.put("msg","更新token"); -// return response.writeWith(Mono.just(getDataBuffer(response,message))); -// } } catch (Exception e) { JSONObject message = new JSONObject(); message.put("code",403); diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/StringTest.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/StringTest.java deleted file mode 100644 index 75787f0..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/StringTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package top.kuanghua.gatewaytwo.filter; - -import org.apache.commons.lang3.StringUtils; - -/** - * @Title: StringTest - * @Description: - * @Auther: kuanghua - * @create 2021/3/15 10:48 - */ -public class StringTest { - public static void main(String[] args) { - String a="/api/doc/swagger"; - String b="doc,swagger"; - - - String[] split = b.split(","); - for (String s : split) { -// System.out.println(StringUtils.contains(a, s)); - } - - - } -} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java b/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java index 3d2fbb0..c5a6512 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java @@ -43,13 +43,17 @@ public ResResult selectPage(ErrorCollection errorCollection, KHCommonParams khCo if (ObjectUtils.isNotEmpty(errorCollection.getPageUrl())) { queryWrapper.or().like("page_url", errorCollection.getPageUrl()); } + if (ObjectUtils.isNotEmpty(errorCollection.getVersion())) { + queryWrapper.or().like("version", errorCollection.getVersion()); + } if (ObjectUtils.isNotEmpty(errorCollection.getCreateTime())) { queryWrapper.or().like("create_time", errorCollection.getCreateTime()); } - queryWrapper.or().orderByDesc("create_time"); + if(StringUtils.isNotEmpty(khCommonParams.getStartTime())) { queryWrapper.or().between("create_time",khCommonParams.getStartTime(),khCommonParams.getEndTime()); } + queryWrapper.or().orderByDesc("create_time"); Page errorCollectionPage = this.errorCollectionService.selectPage(khCommonParams.getPageNum(), khCommonParams.getPageSize(), queryWrapper); return new ResResult().success(errorCollectionPage); } diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/entity/ErrorCollection.java b/ty-user/src/main/java/top/kuanghua/tyuser/entity/ErrorCollection.java index 85f0dc8..3372821 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/entity/ErrorCollection.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/entity/ErrorCollection.java @@ -14,7 +14,6 @@ /** * error_log_collection(ErrorCollection)表实体类 - * * @author kuanghua * @since 2021-10-08 11:37:25 */ @@ -28,9 +27,11 @@ public class ErrorCollection extends Model { private String errorLog; @ApiModelProperty(value = "页面路径") private String pageUrl; + @ApiModelProperty(value = "当前版本") + private String version; + @ApiModelProperty(value = "浏览器类型",hidden = true) + private String browserType; @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建时间",hidden = true) private Date createTime; - @ApiModelProperty(value = "浏览器类型",hidden = true) - private String browserType; } From ab5f66f4cefcaa9282d38a8f0936ef83459f6d07 Mon Sep 17 00:00:00 2001 From: jzfai <869653722@qq.com> Date: Thu, 23 Dec 2021 18:37:36 +0800 Subject: [PATCH 09/36] update some func --- README-zh_CN.md | 7 ++++--- README.md | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README-zh_CN.md b/README-zh_CN.md index ff082aa..19d331a 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -3,7 +3,7 @@ 本架构为springCloud微服务架构,提供基本的jwt权限认证,token更新,以及各微服务之间调用等 使用的技术如下: -```json +```java spring-boot:2.1.4.RELEASE spring-cloud:Greenwich.SR1 spring-cloud-starter-gateway:2.1.1.RELEASE @@ -17,11 +17,12 @@ mysql:5.7 #### 更新日志: to look doc ---- -[真香定律!带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7036302298435289095) + +[带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7044843310204059655) #### 线上文档: -[真香定律!带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7036302298435289095) +[带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7044843310204059655) #### 开发接口和nacos地址 diff --git a/README.md b/README.md index ff082aa..19d331a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ 本架构为springCloud微服务架构,提供基本的jwt权限认证,token更新,以及各微服务之间调用等 使用的技术如下: -```json +```java spring-boot:2.1.4.RELEASE spring-cloud:Greenwich.SR1 spring-cloud-starter-gateway:2.1.1.RELEASE @@ -17,11 +17,12 @@ mysql:5.7 #### 更新日志: to look doc ---- -[真香定律!带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7036302298435289095) + +[带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7044843310204059655) #### 线上文档: -[真香定律!带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7036302298435289095) +[带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7044843310204059655) #### 开发接口和nacos地址 From c7cd7e728f39ecb6b72ae1579727fcff03de4b41 Mon Sep 17 00:00:00 2001 From: jzfai <869653722@qq.com> Date: Thu, 6 Jan 2022 18:28:53 +0800 Subject: [PATCH 10/36] add send email msg and delay queue --- README.md | 6 +- micro-service-plus.iml | 77 ++--- pom.xml | 5 +- springboot-cloud-mapping.json | 113 ++++++++ .../tyauth/config/Swagger2Config.java | 2 +- .../tyauth/controller/TokenController.java | 10 +- ty-auth/ty-auth.iml | 246 ++++++++-------- .../feign/config/FeignConfiguration.java | 5 +- .../feign/tyauth/feign/TokenFeign.java | 9 +- .../kuanghua/khcomomon/entity/IdWorker.java | 2 +- .../khcomomon/utils/ChineseUtils.java | 6 +- .../kuanghua/khcomomon/utils/IdWorker.java | 2 +- .../khcomomon/utils/ObjectUtilsSelf.java | 25 ++ .../src/main/resources/config/banner.txt | 2 +- ty-common/ty-common.iml | 244 ++++++++-------- ty-example/pom.xml | 60 ++++ .../tyexample/ExampleApplication.java | 15 + .../kuanghua/tyexample/config/BaseConfig.java | 21 ++ .../tyexample/config/RabbitDelayConfig.java | 67 +++++ .../tyexample/config/SmsProperties.java | 25 ++ .../tyexample/config/Swagger2Config.java | 54 ++++ .../controller/RabbitDelayController.java | 36 +++ .../controller/SendEmailController.java | 50 ++++ .../tyexample/controller/SmsController.java | 32 +++ .../listener/RabbitDelayListener.java | 29 ++ .../tyexample/listener/SmsListener.java | 50 ++++ .../tyexample/service/RabbitDelayService.java | 33 +++ .../tyexample/service/SendEmailService.java | 102 +++++++ .../tyexample/service/SendMsgService.java | 42 +++ .../tyexample/utils/SendSmsUtils.java | 54 ++++ ty-example/src/main/main12.iml | 13 + ty-example/src/main/resources/application.yml | 24 ++ ty-example/src/main/resources/bootstrap.yml | 40 +++ ty-example/ty-auth.iml | 222 ++++++++++++++ ty-example/ty-example.iml | 243 ++++++++++++++++ ty-excel/ty-excel.iml | 253 ++++++++-------- .../filter/AuthorizeFilterBefore.java | 2 +- ty-gateway/ty-gateway-one/ty-gateway-one.iml | 271 +++++++++--------- ty-gateway/ty-gateway.iml | 271 +++++++++--------- .../tyupload/config/Swagger2Config.java | 2 +- .../tyupload/controller/NacosTestDemo.java | 3 +- .../tyupload/service/UploadService.java | 1 - ty-upload/ty-upload.iml | 247 ++++++++-------- .../tyuser/controller/BrandController.java | 16 +- .../controller/ErrorCollectionController.java | 12 +- .../tyuser/controller/UserController.java | 8 +- .../tyuser/controller/VciController.java | 1 - .../tyuser/excel/imp/VciExcelImp.java | 1 - .../kuanghua/tyuser/service/UserService.java | 2 - ty-user/ty-user.iml | 253 ++++++++-------- 50 files changed, 2366 insertions(+), 943 deletions(-) create mode 100644 springboot-cloud-mapping.json create mode 100644 ty-example/pom.xml create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/config/RabbitDelayConfig.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/config/SmsProperties.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/RabbitDelayController.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/SendEmailController.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/SmsController.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/listener/RabbitDelayListener.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/listener/SmsListener.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/service/RabbitDelayService.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/service/SendEmailService.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/service/SendMsgService.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/utils/SendSmsUtils.java create mode 100644 ty-example/src/main/main12.iml create mode 100644 ty-example/src/main/resources/application.yml create mode 100644 ty-example/src/main/resources/bootstrap.yml create mode 100644 ty-example/ty-auth.iml create mode 100644 ty-example/ty-example.iml diff --git a/README.md b/README.md index 19d331a..48b11e6 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ 使用的技术如下: ```java -spring-boot:2.1.4.RELEASE -spring-cloud:Greenwich.SR1 -spring-cloud-starter-gateway:2.1.1.RELEASE +spring-boot:2.2.4.RELEASE +spring-cloud:Hoxton.SR12 +spring-cloud-starter-gateway:2.2.9.RELEASE nacos:2.1.3.RELEASE mybatis-plus: 3.3.2 rabbitmq:3.7-management diff --git a/micro-service-plus.iml b/micro-service-plus.iml index 7f10b3d..aad4444 100644 --- a/micro-service-plus.iml +++ b/micro-service-plus.iml @@ -8,50 +8,61 @@ - - - - - - - - - + + + + + + + + + - - - - - - - + + + + + + + - + + + + + + + + + + + + - - - - + + + + + + - - - - - - + + + + - - - - - - + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 2206d2a..715f5ce 100644 --- a/pom.xml +++ b/pom.xml @@ -15,17 +15,18 @@ ty-user ty-upload ty-excel + ty-example org.springframework.boot spring-boot-starter-parent - 2.1.4.RELEASE + 2.2.4.RELEASE - Greenwich.SR1 + Hoxton.SR12 diff --git a/springboot-cloud-mapping.json b/springboot-cloud-mapping.json new file mode 100644 index 0000000..c970a57 --- /dev/null +++ b/springboot-cloud-mapping.json @@ -0,0 +1,113 @@ +{ + "git": { + "branch": "dc8e0454e3d0299e7002610a3f82af001013e959", + "commit": { + "id": "dc8e045", + "time": "2022-01-02T10:10:06Z" + } + }, + "build": { + "version": "0.0.1-SNAPSHOT", + "artifact": "start-site", + "versions": { + "spring-boot": "2.6.2", + "initializr": "0.12.0-SNAPSHOT" + }, + "name": "start.spring.io website", + "time": "2022-01-02T10:11:21.501Z", + "group": "io.spring.start" + }, + "bom-ranges": { + "azure": { + "3.2.0": "Spring Boot >=2.3.0.M1 and <2.4.0-M1", + "3.5.0": "Spring Boot >=2.4.0.M1 and <2.5.0-M1", + "3.10.0": "Spring Boot >=2.5.0.M1 and <2.6.0-M1" + }, + "codecentric-spring-boot-admin": { + "2.4.3": "Spring Boot >=2.3.0.M1 and <2.5.0-M1", + "2.5.5": "Spring Boot >=2.5.0.M1 and <2.6.0-M1" + }, + "solace-spring-boot": { + "1.1.0": "Spring Boot >=2.3.0.M1 and <2.6.0-M1" + }, + "solace-spring-cloud": { + "1.1.1": "Spring Boot >=2.3.0.M1 and <2.4.0-M1", + "2.1.0": "Spring Boot >=2.4.0.M1 and <2.6.0-M1" + }, + "spring-cloud": { + "Hoxton.SR12": "Spring Boot >=2.2.0.RELEASE and <2.4.0.M1", + "2020.0.5": "Spring Boot >=2.4.0.M1 and <2.6.0-M1", + "2021.0.0-M1": "Spring Boot >=2.6.0-M1 and <2.6.0-M3", + "2021.0.0-M3": "Spring Boot >=2.6.0-M3 and <2.6.0-RC1", + "2021.0.0-RC1": "Spring Boot >=2.6.0-RC1 and <2.6.1", + "2021.0.0": "Spring Boot >=2.6.1 and <2.6.3-SNAPSHOT", + "2021.0.1-SNAPSHOT": "Spring Boot >=2.6.3-SNAPSHOT and <2.7.0-M1" + }, + "spring-cloud-gcp": { + "2.0.7": "Spring Boot >=2.4.0-M1 and <2.6.0-M1" + }, + "spring-cloud-services": { + "2.3.0.RELEASE": "Spring Boot >=2.3.0.RELEASE and <2.4.0-M1", + "2.4.1": "Spring Boot >=2.4.0-M1 and <2.5.0-M1", + "3.3.0": "Spring Boot >=2.5.0-M1 and <2.6.0-M1" + }, + "spring-geode": { + "1.3.12.RELEASE": "Spring Boot >=2.3.0.M1 and <2.4.0-M1", + "1.4.13": "Spring Boot >=2.4.0-M1 and <2.5.0-M1", + "1.5.7": "Spring Boot >=2.5.0-M1 and <2.6.0-M1", + "1.6.1": "Spring Boot >=2.6.0-M1 and <2.7.0-M1" + }, + "vaadin": { + "14.8.1": "Spring Boot >=2.1.0.RELEASE and <2.8.0-M1" + }, + "wavefront": { + "2.0.2": "Spring Boot >=2.1.0.RELEASE and <2.4.0-M1", + "2.1.1": "Spring Boot >=2.4.0-M1 and <2.5.0-M1", + "2.2.2": "Spring Boot >=2.5.0-M1 and <2.7.0-M1" + } + }, + "dependency-ranges": { + "native": { + "0.9.0": "Spring Boot >=2.4.3 and <2.4.4", + "0.9.1": "Spring Boot >=2.4.4 and <2.4.5", + "0.9.2": "Spring Boot >=2.4.5 and <2.5.0-M1", + "0.10.0": "Spring Boot >=2.5.0-M1 and <2.5.2", + "0.10.1": "Spring Boot >=2.5.2 and <2.5.3", + "0.10.2": "Spring Boot >=2.5.3 and <2.5.4", + "0.10.3": "Spring Boot >=2.5.4 and <2.5.5", + "0.10.4": "Spring Boot >=2.5.5 and <2.5.6", + "0.10.5": "Spring Boot >=2.5.6 and <2.5.9-SNAPSHOT", + "0.10.6-SNAPSHOT": "Spring Boot >=2.5.9-SNAPSHOT and <2.6.0-M1", + "0.11.0-M1": "Spring Boot >=2.6.0-M1 and <2.6.0-RC1", + "0.11.0-M2": "Spring Boot >=2.6.0-RC1 and <2.6.0", + "0.11.0-RC1": "Spring Boot >=2.6.0 and <2.6.1", + "0.11.0": "Spring Boot >=2.6.1 and <2.6.2", + "0.11.1": "Spring Boot >=2.6.2 and <2.6.3-SNAPSHOT", + "0.11.2-SNAPSHOT": "Spring Boot >=2.6.3-SNAPSHOT and <2.7.0-M1" + }, + "okta": { + "1.4.0": "Spring Boot >=2.2.0.RELEASE and <2.4.0-M1", + "1.5.1": "Spring Boot >=2.4.0-M1 and <2.4.1", + "2.0.1": "Spring Boot >=2.4.1 and <2.5.0-M1", + "2.1.4": "Spring Boot >=2.5.0-M1 and <2.6.0-M1" + }, + "mybatis": { + "2.1.4": "Spring Boot >=2.1.0.RELEASE and <2.5.0-M1", + "2.2.1": "Spring Boot >=2.5.0-M1" + }, + "camel": { + "3.5.0": "Spring Boot >=2.3.0.M1 and <2.4.0-M1", + "3.10.0": "Spring Boot >=2.4.0.M1 and <2.5.0-M1", + "3.13.0": "Spring Boot >=2.5.0.M1 and <2.6.0-M1", + "3.14.0": "Spring Boot >=2.6.0.M1 and <2.7.0-M1" + }, + "picocli": { + "4.6.2": "Spring Boot >=2.4.0.RELEASE and <2.6.0-M1" + }, + "open-service-broker": { + "3.2.0": "Spring Boot >=2.3.0.M1 and <2.4.0-M1", + "3.3.1": "Spring Boot >=2.4.0-M1 and <2.5.0-M1", + "3.4.0-M2": "Spring Boot >=2.5.0-M1 and <2.6.0-M1" + } + } +} \ No newline at end of file diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java b/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java index a7913b0..fc50e49 100644 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java +++ b/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java @@ -43,7 +43,7 @@ public Docket api() { private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("标题:kuanghua") - .description("描述:新一代的前端架构") + .description("描述:新一代的微服务架构") .contact(new Contact("jzfai", null, "869653722@qq.com")) .version("版本号:2.9") .build(); diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TokenController.java b/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TokenController.java index 1339dbc..19130a1 100644 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TokenController.java +++ b/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TokenController.java @@ -32,9 +32,7 @@ public class TokenController { @ApiOperation("获取token信息") @PostMapping("parseToken") public ResResult parseToken(@RequestParam("jwtToken") String jwtToken){ - System.out.println("解析出来token了"); Claims claims = this.tokenService.parseToken(jwtToken); - System.out.println(claims); return new ResResult().success(claims); } @@ -45,8 +43,8 @@ public ResResult parseToken(@RequestParam("jwtToken") String jwtToken){ @PostMapping("generateToken") //@RequestHeader("authorize_token") String authorize_token public ResResult generateToken(@RequestBody Map tokenMap){ - System.out.println("生成的代码信息"); - System.out.println(tokenMap); +// System.out.println("生成的代码信息"); +// System.out.println(tokenMap); // System.out.println("generateToken获得请求头的信息"); @@ -64,8 +62,8 @@ public ResResult generateToken(@RequestBody Map tokenMap){ @PostMapping("updateToken") public ResResult updateToken(@RequestBody Map map){ String updateToken = this.tokenService.updateToken(map); - System.out.println("生成信息的token"+updateToken); - System.out.println("生成信息的token"+map.toString()); +// System.out.println("生成信息的token"+updateToken); +// System.out.println("生成信息的token"+map.toString()); return new ResResult().success(updateToken); } } diff --git a/ty-auth/ty-auth.iml b/ty-auth/ty-auth.iml index 9447a05..7d21540 100644 --- a/ty-auth/ty-auth.iml +++ b/ty-auth/ty-auth.iml @@ -21,38 +21,39 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - - - + + + - + @@ -71,16 +72,7 @@ - - - - - - - - - - + @@ -89,134 +81,150 @@ - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - + + + - - - + + + + + + + + + - - - + + + - + - + - + - + - + - - - + + + - - - - - - - + + + + + + + + + + + + + + + + + + - - - - + + + + + + - - - - - - + + + + - - - - - + + + + + \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/feign/config/FeignConfiguration.java b/ty-common/src/main/java/top/kuanghua/feign/config/FeignConfiguration.java index ca016ac..ba14433 100644 --- a/ty-common/src/main/java/top/kuanghua/feign/config/FeignConfiguration.java +++ b/ty-common/src/main/java/top/kuanghua/feign/config/FeignConfiguration.java @@ -2,6 +2,8 @@ import feign.RequestInterceptor; import feign.RequestTemplate; +import lombok.Data; +import lombok.extern.log4j.Log4j2; import org.springframework.context.annotation.Configuration; import org.springframework.util.ObjectUtils; import org.springframework.web.context.request.RequestContextHolder; @@ -13,6 +15,7 @@ /*feign转发时将请求的参数设转发到请求头上*/ @Configuration +@Log4j2 public class FeignConfiguration implements RequestInterceptor { @Override public void apply(RequestTemplate template) { @@ -25,7 +28,7 @@ public void apply(RequestTemplate template) { while (headerNames.hasMoreElements()) { String name = headerNames.nextElement(); String values = request.getHeader(name); - //System.out.println("等到的hearder头消息"+name+values); + template.header(name, values); } } diff --git a/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TokenFeign.java b/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TokenFeign.java index 104dea9..e58032b 100644 --- a/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TokenFeign.java +++ b/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TokenFeign.java @@ -17,23 +17,26 @@ * @create 2021/1/31 16:31 */ + +//FeignConfiguration.class -> forward req params of include the token @FeignClient(name="ty-auth",configuration = FeignConfiguration.class) @RequestMapping("token") public interface TokenFeign { + /* - * 解析token + * parse token * */ @PostMapping("parseToken") ResResult parseToken(@RequestParam("jwtToken") String jwtToken); /* - * 生成token + * create token * */ @PostMapping("generateToken") ResResult generateToken(@RequestBody Map map); /* - * 更新token + * update token * */ @PostMapping("updateToken") ResResult updateToken(@RequestBody Map map); diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/IdWorker.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/IdWorker.java index 3956250..f39e9ea 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/IdWorker.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/IdWorker.java @@ -154,7 +154,7 @@ protected static long getDatacenterId(long maxDatacenterId) { id = id % (maxDatacenterId + 1); } } catch (Exception e) { - System.out.println(" getDatacenterId: " + e.getMessage()); + // System.out.println(" getDatacenterId: " + e.getMessage()); } return id; } diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ChineseUtils.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ChineseUtils.java index ac135d7..48f83b7 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ChineseUtils.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ChineseUtils.java @@ -58,8 +58,8 @@ public static String getRandomLengthChiness(int start, int end) { } public static void main(String args[]) { - System.out.println(ChineseUtils.getChinese()); - System.out.println(ChineseUtils.getFixedLengthChinese(20)); - System.out.println(ChineseUtils.getRandomLengthChiness(2, 5)); +// System.out.println(ChineseUtils.getChinese()); +// System.out.println(ChineseUtils.getFixedLengthChinese(20)); +// System.out.println(ChineseUtils.getRandomLengthChiness(2, 5)); } } diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/IdWorker.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/IdWorker.java index b498e94..520a05f 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/IdWorker.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/IdWorker.java @@ -154,7 +154,7 @@ protected static long getDatacenterId(long maxDatacenterId) { id = id % (maxDatacenterId + 1); } } catch (Exception e) { - System.out.println(" getDatacenterId: " + e.getMessage()); + //System.out.println(" getDatacenterId: " + e.getMessage()); } return id; } diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ObjectUtilsSelf.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ObjectUtilsSelf.java index a9fb5ce..b8422c0 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ObjectUtilsSelf.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ObjectUtilsSelf.java @@ -2,8 +2,10 @@ import com.alibaba.fastjson.JSON; import org.apache.commons.lang3.StringUtils; +import org.springframework.web.multipart.MultipartFile; import top.kuanghua.khcomomon.entity.ResResult; +import java.io.File; import java.lang.reflect.Array; import java.text.SimpleDateFormat; import java.util.Collection; @@ -123,4 +125,27 @@ public static String formatDateTime(Date date){ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式 return df.format(date); } + + + /** + * MultipartFile change to file + * @param multiFile + * @return + */ + public static File MultipartFileToFile(MultipartFile multiFile) { + // 获取文件名 + String fileName = multiFile.getOriginalFilename(); + // 获取文件后缀 + String prefix = fileName.substring(fileName.lastIndexOf(".")); + // 若须要防止生成的临时文件重复,能够在文件名后添加随机码 + + try { + File file = File.createTempFile(fileName, prefix); + multiFile.transferTo(file); + return file; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } } \ No newline at end of file diff --git a/ty-common/src/main/resources/config/banner.txt b/ty-common/src/main/resources/config/banner.txt index 4b6d321..1a1dcb9 100644 --- a/ty-common/src/main/resources/config/banner.txt +++ b/ty-common/src/main/resources/config/banner.txt @@ -4,4 +4,4 @@ \\/ ___)| |_)| | | | | || (_| | ) ) ) )----☺ ☺ ☺ ☺ ☺ ☺ ☺ ☺ ☺ ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ - :: jzfai好嗨喔框架:: (v2.1.4RELEASE) \ No newline at end of file + :: new general micro service construct:: (v2.2.4RELEASE) \ No newline at end of file diff --git a/ty-common/ty-common.iml b/ty-common/ty-common.iml index 3ffe7b5..e823a48 100644 --- a/ty-common/ty-common.iml +++ b/ty-common/ty-common.iml @@ -20,48 +20,49 @@ - - - + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - + + + - + @@ -81,15 +82,13 @@ - - - - - - - - - + + + + + + + @@ -98,123 +97,132 @@ - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - + + + - - - + + + + + + + + + - - - + + + - + - + - + - + - - - - + + + + + + + + + - - - - + + + + + - - - - - - + + + + - - - - + + + + \ No newline at end of file diff --git a/ty-example/pom.xml b/ty-example/pom.xml new file mode 100644 index 0000000..f809565 --- /dev/null +++ b/ty-example/pom.xml @@ -0,0 +1,60 @@ + + + + micro-service-plus + top.kuanghua + 1.0-SNAPSHOT + + 4.0.0 + + ty-example + + + top.kuanghua + ty-common + 1.0-SNAPSHOT + + + top.kuanghua + user-api + 1.0-SNAPSHOT + + + + com.aliyun + aliyun-java-sdk-core + 4.5.3 + + + + org.springframework.boot + spring-boot-starter-mail + + + + + ${project.artifactId} + + + src/main/resources + true + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.1 + + true + + + + + \ No newline at end of file diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java b/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java new file mode 100644 index 0000000..003fdb0 --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java @@ -0,0 +1,15 @@ +package top.kuanghua.tyexample; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.annotation.EnableScheduling; + +@SpringBootApplication +@EnableScheduling +@EnableAsync +public class ExampleApplication { + public static void main(String[] args) { + SpringApplication.run(ExampleApplication.class,args); + } +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java b/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java new file mode 100644 index 0000000..9c668a7 --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java @@ -0,0 +1,21 @@ +package top.kuanghua.tyexample.config; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +/** + * @Title: BaseConfig + * @Description: + * @Auther: kuanghua + * @create 2020/8/23 21:52 + */ +/* + * 总结:1.@Configuration 下的@ComponentScan回将包下带有@Component扫描变成配置类, + * 而@SpringBootApplication扫描的只会变成普通类 + * */ +@Configuration +//扫描公用包的配置和自身的配置类 +@ComponentScan(basePackages = {"top.kuanghua.khcomomon"}) +public class BaseConfig { + +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/config/RabbitDelayConfig.java b/ty-example/src/main/java/top/kuanghua/tyexample/config/RabbitDelayConfig.java new file mode 100644 index 0000000..1959f7f --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/config/RabbitDelayConfig.java @@ -0,0 +1,67 @@ +package top.kuanghua.tyexample.config; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.amqp.core.*; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Title: Configuration + * @Description: + * @Auther: kuanghua + * @create 2022/1/05 10:04 + */ +@Configuration +@Slf4j +public class RabbitDelayConfig { + + /*死信部分*/ + public static final String ORDER_DELAY_QUEUE = "queue.delay.user.order"; + public static final String ORDER_DELAY_EXCHANGE = "exchange.delay.user.order"; + public static final String ORDER_DELAY_ROUTING_KEY = "delay_order"; + /*普通交换机*/ + public static final String ORDER_QUEUE_NAME = "queue.user.order"; + public static final String ORDER_EXCHANGE_NAME = "exchange.user.order"; + public static final String ORDER_ROUTING_KEY = "order"; + + /* + * DELAY_EXCHANGE + * 死信交换机原理:发送到死信交换机(在有效期时间内接收信息不进行转发,超时则进行转发到其他队列) + * */ + @Bean + public Queue delayOrderQueue() { + Map params = new HashMap<>(); + // 转发的队列交换机的名称 + params.put("x-dead-letter-exchange", ORDER_EXCHANGE_NAME); + // 转发的队列队列的路由名称 + params.put("x-dead-letter-routing-key", ORDER_ROUTING_KEY); + return new Queue(ORDER_DELAY_QUEUE, true, false, false, params); + } + @Bean + public DirectExchange orderDelayExchange() { + return new DirectExchange(ORDER_DELAY_EXCHANGE); + } + + + @Bean + public Binding dlxBinding() { + return BindingBuilder.bind(delayOrderQueue()).to(orderDelayExchange()).with(ORDER_DELAY_ROUTING_KEY); + } + + /*普通交换机*/ + @Bean + public Queue orderQueue() { + return new Queue(ORDER_QUEUE_NAME, true); + } + @Bean + public TopicExchange orderTopicExchange() { + return new TopicExchange(ORDER_EXCHANGE_NAME); + } + @Bean + public Binding orderBinding() { + return BindingBuilder.bind(orderQueue()).to(orderTopicExchange()).with(ORDER_ROUTING_KEY); + } +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/config/SmsProperties.java b/ty-example/src/main/java/top/kuanghua/tyexample/config/SmsProperties.java new file mode 100644 index 0000000..ab4ad5e --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/config/SmsProperties.java @@ -0,0 +1,25 @@ +package top.kuanghua.tyexample.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * @Title: SmsProperties + * @Description: + * @Auther:jzfai + * @Version: 1.0 + * @create 2020/3/13 18:19 + */ +@Component +@ConfigurationProperties(prefix = "kuanghua.sms") +@Data +public class SmsProperties { + String accessKeyId; + + String accessKeySecret; + + String signName; + + String verifyCodeTemplate; +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java b/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java new file mode 100644 index 0000000..4e14a84 --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java @@ -0,0 +1,54 @@ +package top.kuanghua.tyexample.config; + +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@Component +@EnableSwagger2 //开启在线接口文档 +//配置包扫描 +public class Swagger2Config { + private boolean swagger_is_enable = true; + + @Value("${server.port}") + private String port; + + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .enable(swagger_is_enable) + //.host(this.ipAddr + ":" + this.port) + .apiInfo(apiInfo()) + .select() + .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) + //.apis(basePackage("top.kuanghua.swagger.controller")) + .paths(PathSelectors.any()) + .build(); + } + + /** + * 构建 api文档的详细信息函数 + * @return + */ + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("标题:kuanghua") + .description("描述:新一代的微服务架构") + .contact(new Contact("jzfai", null, "869653722@qq.com")) + .version("版本号:2.9") + .build(); + } + + /** + * http://localhost:8080/swagger-ui.html + */ +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/RabbitDelayController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/RabbitDelayController.java new file mode 100644 index 0000000..8c4f6f0 --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/controller/RabbitDelayController.java @@ -0,0 +1,36 @@ +package top.kuanghua.tyexample.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.tyexample.service.RabbitDelayService; + +import javax.annotation.Resource; + +/** + * @Title: RabbitDelayController + * @Description: + * @Auther: kuanghua + * @create 2022-01-06 17:23 + */ +@Api(tags = "延时队列") +@RestController +@RequestMapping("delayQueue") +public class RabbitDelayController { + + @Resource + private RabbitDelayService rabbitDelayService; + + @ApiOperation(value = "测试延时队列") + @GetMapping("convertAndSend") + public ResResult convertAndSend(@ApiParam("延时时间(s)") @RequestParam("time") Integer time) { + rabbitDelayService.convertAndSend(time); + return new ResResult().success(); + } +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/SendEmailController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/SendEmailController.java new file mode 100644 index 0000000..7762880 --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/controller/SendEmailController.java @@ -0,0 +1,50 @@ +package top.kuanghua.tyexample.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.tyexample.service.SendEmailService; + +import javax.mail.MessagingException; +import java.io.IOException; + +/** + * @Title: SendEmailController + * @Description: + * @Auther: kuanghua + * @create 2020/8/20 22:41 + */ +@Api(tags = "发送邮件") +@RestController +@RequestMapping("email") +public class SendEmailController { + + @Autowired + private SendEmailService sendEmailService; + + @ApiOperation(value = "发送普通文本邮件") + @GetMapping("sendEmailText") + public ResResult sendEmailText(@RequestParam(name = "subject",defaultValue = "这是主题") String subject, + @RequestParam(name = "text",defaultValue = "发送的文本(这是测试文本)") String text, + @RequestParam(name = "sendTo",defaultValue = "1319404169@qq.com") String sendTo) { + sendEmailService.sendEmailText(subject, text, sendTo); + return new ResResult().success("发送邮件成功"); + } + + @ApiOperation(value = "发送文本邮件(可以带附件)", notes = "可以带附件 ") + @PostMapping("sendMimeMail") + public ResResult sendMimeMail(@RequestParam(name = "subject",defaultValue = "这是主题") String subject, + @RequestParam(name = "text",defaultValue = "发送的文本(这是测试文本)") String text, + @RequestParam(name = "sendTo",defaultValue = "1319404169@qq.com") String sendTo, + MultipartFile file) + throws IOException, MessagingException, InterruptedException { + if (file.getOriginalFilename().isEmpty()) { + return new ResResult().error("文件上传空"); + } + sendEmailService.sendMimeMail(subject, text, sendTo, file); + return new ResResult().success("发送邮件成功"); + } +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/SmsController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/SmsController.java new file mode 100644 index 0000000..d986fc0 --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/controller/SmsController.java @@ -0,0 +1,32 @@ +package top.kuanghua.tyexample.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.tyexample.service.SendMsgService; + +/** + * @Title: SmsController @Description: @Auther: + * + * @create 2020/8/20 11:33 + */ +@Api(tags = "短信") +@RestController +@RequestMapping("sms") +public class SmsController { + + @Autowired + private SendMsgService sendMsgService; + @ApiOperation(value = "发送短信") + @PostMapping("sendSms") + public ResResult sendSms(@ApiParam("手机号") @RequestParam("phone") String phone) { + sendMsgService.sendMsg(phone); + return new ResResult().success("短信发送成功"); + } +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/listener/RabbitDelayListener.java b/ty-example/src/main/java/top/kuanghua/tyexample/listener/RabbitDelayListener.java new file mode 100644 index 0000000..de4130d --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/listener/RabbitDelayListener.java @@ -0,0 +1,29 @@ +package top.kuanghua.tyexample.listener; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.stereotype.Component; +import top.kuanghua.tyexample.config.RabbitDelayConfig; + +/** + * @Title: orderDelayQueue + * @Description: + * @Auther: kuanghua + * @create 2021/1/18 10:27 + */ +@Component +@Slf4j +public class RabbitDelayListener { + @RabbitListener(queues = {RabbitDelayConfig.ORDER_QUEUE_NAME}) + public void ORDER_QUEUE_NAME( String outTradeno) { + /* + * 微信服务器查询订单,并更新订单状态 + * */ + log.info("receive the Delay info "+outTradeno); + } + // note: not dill the msg will re to redirect ORDER_QUEUE_NAME + // @RabbitListener(queues = {RabbitDelayConfig.ORDER_DELAY_QUEUE}) + // public void ORDER_DELAY_QUEUE( String outTradeno) { + // log.info("ORDER_DELAY_QUEUE"+outTradeno); + // } +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/listener/SmsListener.java b/ty-example/src/main/java/top/kuanghua/tyexample/listener/SmsListener.java new file mode 100644 index 0000000..317bb47 --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/listener/SmsListener.java @@ -0,0 +1,50 @@ +package top.kuanghua.tyexample.listener; + + +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.springframework.amqp.rabbit.annotation.Exchange; +import org.springframework.amqp.rabbit.annotation.Queue; +import org.springframework.amqp.rabbit.annotation.QueueBinding; +import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.stereotype.Component; +import top.kuanghua.tyexample.config.SmsProperties; +import top.kuanghua.tyexample.utils.SendSmsUtils; + + +import java.util.Map; + +@Component +@EnableConfigurationProperties(SmsProperties.class) +@Slf4j +public class SmsListener { + + @Autowired + private SendSmsUtils smsUtils; + + @Autowired + private SmsProperties smsProperties; + + @RabbitListener( + bindings = @QueueBinding(value = @Queue(value = "kuanghua.sms.queue", durable = "true"), + exchange = @Exchange(value = "kuanghua.sms.exchange", ignoreDeclarationExceptions = "true",durable = "true"), + key = {"sms.verify.code"}) + ) + public void listenSms(Map msg) throws Exception { + if (msg == null || msg.size() <= 0) { + // 放弃处理 + return; + } + String phone = msg.get("phone"); + String code = msg.get("code"); + if (StringUtils.isBlank(phone) || StringUtils.isBlank(code)) { + // 放弃处理 + log.error("发送短信mq phone或code字段为空"); + return; + } + // 发送短信 + this.smsUtils.sendMsg(phone,code,smsProperties.getSignName(),smsProperties.getVerifyCodeTemplate()); + } +} \ No newline at end of file diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/RabbitDelayService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/RabbitDelayService.java new file mode 100644 index 0000000..084da36 --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/service/RabbitDelayService.java @@ -0,0 +1,33 @@ +package top.kuanghua.tyexample.service; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import top.kuanghua.tyexample.config.RabbitDelayConfig; + +/** + * @Title: RabbitDelayService + * @Description: + * @Auther: kuanghua + * @create 2022-01-06 17:18 + */ +@Service +public class RabbitDelayService { + + @Autowired + private RabbitTemplate rabbitTemplate; + + /** + * @param time 延时的时间 + * 死信延时转发队列 + */ + public void convertAndSend(Integer time){ + rabbitTemplate.convertAndSend(RabbitDelayConfig.ORDER_DELAY_EXCHANGE, RabbitDelayConfig.ORDER_DELAY_ROUTING_KEY, "发送的数据", message -> { + // 如果配置了 params.put("x-message-ttl", 5 * 1000); 那么这一句也可以省略,具体根据业务需要是声明 Queue 的时候就指定好延迟时间还是在发送自己控制时间 + message.getMessageProperties().setExpiration(time * 1000 + ""); + return message; + }); + } +} + diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/SendEmailService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/SendEmailService.java new file mode 100644 index 0000000..afcfba6 --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/service/SendEmailService.java @@ -0,0 +1,102 @@ +package top.kuanghua.tyexample.service; + + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.mail.SimpleMailMessage; +import org.springframework.mail.javamail.JavaMailSenderImpl; +import org.springframework.mail.javamail.MimeMessageHelper; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; +import org.springframework.util.ResourceUtils; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; + +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; +import java.io.File; +import java.io.IOException; +import java.util.List; + +/** + * @Title: SendEmailService + * @Description: + * @Auther: kuanghua + * @create 2020/8/20 22:09 + */ +@Service +public class SendEmailService { + + @Autowired + private JavaMailSenderImpl javaMailSender; + + @Value("${spring.mail.username}") + private String sendForm; + + /** + * @Description: 发送文本邮件 + * @Param: subject 主题 + * @Param: text 发送的文本 + * @Param: sendForm 发送人 + * @Param: sendTo 发送给谁 + * @return: + * @Date: 2020-08-20 + */ + @Async + public void sendEmailText(String subject, String text, String sendTo) { + //封装简单的邮件内容 + SimpleMailMessage simpleMailMessage = new SimpleMailMessage(); + //邮件主题 + simpleMailMessage.setSubject(subject); + simpleMailMessage.setText(text); + //发件人和收件人 + simpleMailMessage.setFrom(sendForm); + simpleMailMessage.setTo(sendTo); + //发送 + javaMailSender.send(simpleMailMessage); + //demo + //sendEmailText("邮件主题测试setSubject","邮件主题测试setText","869653722@qq.com","1319404169@qq.com") + } + + /** + * @Description: 发送附件邮件 + * @Param: * @param null + * @return: + * @Date: 2020-08-20 + */ + @Async + public void sendMimeMail(String subject, String text, String sendTo,MultipartFile file) + throws MessagingException, IOException { + // String path = ResourceUtils.getURL("classpath:").getPath(); + // System.out.println(path + file.getOriginalFilename()); + //先将文件保存在本地 + //file.transferTo(filePath); + + File toFile = ObjectUtilsSelf.MultipartFileToFile(file); + //创建一个发送复杂消息对象 + MimeMessage mimeMessage = javaMailSender.createMimeMessage(); + //通过消息帮助对象,来设置发送的内容 + MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, "UTF-8"); + //邮件主题 + messageHelper.setSubject(subject); + //第2个参数为true表示是html + messageHelper.setText(text, true); + //上传文件 (文件名,File或IO对象) + String filename = file.getOriginalFilename(); + + messageHelper.addAttachment(filename, toFile); + //发件人和收件人 + messageHelper.setFrom(sendForm); + messageHelper.setTo(sendTo); + //发送 + javaMailSender.send(mimeMessage); + //发完后清空文件 + //filePath.delete(); + } + //@Scheduled(cron = "*/1 * * * * *") + //public void scheduled() { + //this.sendEmailText("邮件主题测试setSubject", "邮件主题测试setText", "869653722@qq.com", "1319404169@qq.com"); + //System.out.println("邮件发送了好烦啊"); + // } +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/SendMsgService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/SendMsgService.java new file mode 100644 index 0000000..2a00645 --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/service/SendMsgService.java @@ -0,0 +1,42 @@ +package top.kuanghua.tyexample.service; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.amqp.core.AmqpTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Service; +import top.kuanghua.khcomomon.utils.NumberUtilsSelf; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +/** + * @Title: SendMsgService + * @Description: + * @Auther: + * @create 2020/8/20 11:26 + */ +@Service +@Slf4j +public class SendMsgService { + + @Autowired + protected AmqpTemplate amqpTemplate; + + @Autowired + private StringRedisTemplate stringRedisTemplate; + + public void sendMsg(String phone) { + String code = NumberUtilsSelf.generateCode(6); + Map smsMap = new HashMap(); + smsMap.put("phone",phone); + smsMap.put("code",code); + amqpTemplate.convertAndSend("kuanghua.sms.exchange", "sms.verify.code",smsMap); + stringRedisTemplate.opsForValue().set("user:code:phone:"+phone,code,60, TimeUnit.SECONDS); + log.info("发送短信的code"+code); + } +} + + + diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/utils/SendSmsUtils.java b/ty-example/src/main/java/top/kuanghua/tyexample/utils/SendSmsUtils.java new file mode 100644 index 0000000..876ab4f --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/utils/SendSmsUtils.java @@ -0,0 +1,54 @@ +package top.kuanghua.tyexample.utils; + +import com.alibaba.fastjson.JSON; +import com.aliyuncs.CommonRequest; +import com.aliyuncs.CommonResponse; +import com.aliyuncs.DefaultAcsClient; +import com.aliyuncs.IAcsClient; +import com.aliyuncs.http.MethodType; +import com.aliyuncs.profile.DefaultProfile; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import top.kuanghua.tyexample.config.SmsProperties; + +import java.util.Map; + + +@Component +@Slf4j +public class SendSmsUtils { + + @Autowired + private SmsProperties smsProperties; + + public void sendMsg(String phone, String code, String signName, String codeTemplate){ + DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", smsProperties.getAccessKeyId(), smsProperties.getAccessKeySecret()); + IAcsClient client = new DefaultAcsClient(profile); + CommonRequest request = new CommonRequest(); + request.setSysMethod(MethodType.POST); + request.setSysDomain("dysmsapi.aliyuncs.com"); + request.setSysVersion("2017-05-25"); + request.setSysAction("SendSms"); + request.putQueryParameter("RegionId", "cn-hangzhou"); + request.putQueryParameter("PhoneNumbers", phone); + request.putQueryParameter("SignName", signName); + request.putQueryParameter("TemplateCode", codeTemplate); + request.putQueryParameter("TemplateParam", "{\"code\":\""+code+"\"}"); + try { + CommonResponse response = client.getCommonResponse(request); + String data = response.getData(); + Map map = JSON.parseObject(data, Map.class); + if (map.get("Code").equals("OK")){ + log.warn("发送短信成功 "+data); + }else{ + // 记录失败日志 + log.error("发送短信失败 "+data); + } + } catch (Exception e) { + // 记录失败日志 + log.error("发送短信失败 "+e.getMessage()); + throw new RuntimeException("发送短信失败 "+e.getMessage()); + } + } +} diff --git a/ty-example/src/main/main12.iml b/ty-example/src/main/main12.iml new file mode 100644 index 0000000..f608aea --- /dev/null +++ b/ty-example/src/main/main12.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/ty-example/src/main/resources/application.yml b/ty-example/src/main/resources/application.yml new file mode 100644 index 0000000..1b3189a --- /dev/null +++ b/ty-example/src/main/resources/application.yml @@ -0,0 +1,24 @@ +#msg config, place change to you sms config +kuanghua: + sms: + accessKeyId: LTAI4FrD2voTK2wTgRCPwT6d + accessKeySecret: Zj07thnb2jiBkl4wtqgvPeuSzkJRJ3 + signName: 品优商城 # 签名名称 + verifyCodeTemplate: SMS_189216068 # 模板名称 + + + + +#email config, place change to you email +spring: + mail: + username: 869653722@qq.com + password: xbthzedhnxatbcab + host: smtp.qq.com + properties: + mail.smtp.starttls.enable: true + + + +server: + port: ${envpt.tomcatPortPre}0121 \ No newline at end of file diff --git a/ty-example/src/main/resources/bootstrap.yml b/ty-example/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..c1b6427 --- /dev/null +++ b/ty-example/src/main/resources/bootstrap.yml @@ -0,0 +1,40 @@ +spring: + application: + name: @project.artifactId@ + profiles: + active: @activatedProperties@ + cloud: + nacos: + config: + enabled: true + namespace: @nacosNamespace@ + group: @nacosGroup@ + username: @nacosUsername@ + password: @nacosPassword@ + server-addr: @nacosIpPort@ + prefix: @project.artifactId@ + file-extension: yml + # 用于共享的配置文件 + shared-configs: + - data-id: application-@activatedProperties@.yml + group: @nacosGroup@ + refresh: true + # 额外的配置文件 + extension-configs: + - data-id: application-db.yml + group: @nacosGroup@ + refresh: true + - data-id: application-rabbit.yml + group: @nacosGroup@ + refresh: true + - data-id: application-redis.yml + group: @nacosGroup@ + refresh: true + discovery: + namespace: @nacosNamespace@ + group: @nacosGroup@ + username: @nacosUsername@ + password: @nacosPassword@ + server-addr: @nacosIpPort@ + weight: @nacosWeight@ + ip: @nacosDiscoveryIp@ \ No newline at end of file diff --git a/ty-example/ty-auth.iml b/ty-example/ty-auth.iml new file mode 100644 index 0000000..9447a05 --- /dev/null +++ b/ty-example/ty-auth.iml @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ty-example/ty-example.iml b/ty-example/ty-example.iml new file mode 100644 index 0000000..866c9e1 --- /dev/null +++ b/ty-example/ty-example.iml @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ty-excel/ty-excel.iml b/ty-excel/ty-excel.iml index ac0db2e..a9383d1 100644 --- a/ty-excel/ty-excel.iml +++ b/ty-excel/ty-excel.iml @@ -27,7 +27,7 @@ - + @@ -39,41 +39,47 @@ - - + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - - - + + + - + @@ -92,16 +98,7 @@ - - - - - - - - - - + @@ -110,129 +107,145 @@ - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + - - + + + + + + + + - - - + + + - + - + - + - + - - - - + + + + - - - - - - - + + + + + + + + + + + + + + + + + + - - - - + + + + + + - - - - - - + + + + - - - - - + + + + + \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java index 587a9a1..d99b2f2 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java @@ -82,7 +82,7 @@ public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { DataBuffer buffer = getDataBuffer(response,message); return response.writeWith(Mono.just(buffer)); } - //2.1 将解析到的jwt数据保存到线程中(转发过去的服务都能接收)(但是服务必须部署到同一台机器上) + //2.1 将解析到的jwt数据保存到线程中(转发过去的服务都能接收) try { //本地文件解析 //Claims claims = JwtUtilsKh.parserTokenGetBody(jwtToken, RsaUtils.getPublicKey(pubKeyPath)); diff --git a/ty-gateway/ty-gateway-one/ty-gateway-one.iml b/ty-gateway/ty-gateway-one/ty-gateway-one.iml index 2e4a4dc..a5b16e9 100644 --- a/ty-gateway/ty-gateway-one/ty-gateway-one.iml +++ b/ty-gateway/ty-gateway-one/ty-gateway-one.iml @@ -27,14 +27,14 @@ - + - - - + + + - + @@ -53,16 +53,7 @@ - - - - - - - - - - + @@ -71,165 +62,183 @@ - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - + + + - - - + + + + + + + + + - - - + + + - + - - + + - + - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + - - - - - - + + + + - - - - - + + + + + \ No newline at end of file diff --git a/ty-gateway/ty-gateway.iml b/ty-gateway/ty-gateway.iml index e5e33c2..b92bf04 100644 --- a/ty-gateway/ty-gateway.iml +++ b/ty-gateway/ty-gateway.iml @@ -15,14 +15,14 @@ - + - - - + + + - + @@ -41,16 +41,7 @@ - - - - - - - - - - + @@ -59,165 +50,183 @@ - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - + + + - - - + + + + + + + + + - - - + + + - + - - + + - + - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + - - - - - - + + + + - - - - - + + + + + \ No newline at end of file diff --git a/ty-upload/src/main/java/top/kuanghua/tyupload/config/Swagger2Config.java b/ty-upload/src/main/java/top/kuanghua/tyupload/config/Swagger2Config.java index 106aedf..731ecc1 100644 --- a/ty-upload/src/main/java/top/kuanghua/tyupload/config/Swagger2Config.java +++ b/ty-upload/src/main/java/top/kuanghua/tyupload/config/Swagger2Config.java @@ -44,7 +44,7 @@ public Docket api() { private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("标题:kuanghua") - .description("描述:新一代的前端架构") + .description("描述:新一代的微服务架构") .contact(new Contact("jzfai", null, "869653722@qq.com")) .version("版本号:2.9") .build(); diff --git a/ty-upload/src/main/java/top/kuanghua/tyupload/controller/NacosTestDemo.java b/ty-upload/src/main/java/top/kuanghua/tyupload/controller/NacosTestDemo.java index 1abe74a..17b6a68 100644 --- a/ty-upload/src/main/java/top/kuanghua/tyupload/controller/NacosTestDemo.java +++ b/ty-upload/src/main/java/top/kuanghua/tyupload/controller/NacosTestDemo.java @@ -31,7 +31,7 @@ public ResResult test(){ HashMap hashMap = new HashMap(); hashMap.put("username","邝华"); ResResult resResult = tokenFeign.generateToken(hashMap); - System.out.println(resResult); + //System.out.println(resResult); return resResult; } @@ -39,7 +39,6 @@ public ResResult test(){ @GetMapping("test2") public ResResult test2(String token){ ResResult resResult = tokenFeign.parseToken(token); - System.out.println(resResult); return resResult; } } diff --git a/ty-upload/src/main/java/top/kuanghua/tyupload/service/UploadService.java b/ty-upload/src/main/java/top/kuanghua/tyupload/service/UploadService.java index d907045..782685f 100644 --- a/ty-upload/src/main/java/top/kuanghua/tyupload/service/UploadService.java +++ b/ty-upload/src/main/java/top/kuanghua/tyupload/service/UploadService.java @@ -86,7 +86,6 @@ public Map uploadGetMetaData(MultipartFile file) throws IOExcept Map hashMap = new HashMap<>(); hashMap.put("name", name); hashMap.put("url", storePath.getFullPath()); - System.out.println(hashMap); return hashMap; } } diff --git a/ty-upload/ty-upload.iml b/ty-upload/ty-upload.iml index 39cc125..fa94c36 100644 --- a/ty-upload/ty-upload.iml +++ b/ty-upload/ty-upload.iml @@ -26,30 +26,32 @@ - - - - - - - - - - - + + + + + + + + + + + + + - + - - - + + + - + @@ -67,16 +69,7 @@ - - - - - - - - - - + @@ -85,146 +78,162 @@ - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - + + + - - + + + + + + + + - - - + + + - + - + - + - + - - + + - - - - + + + + - - - - - - + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + - - - - + + - - - - - + + + + + \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/controller/BrandController.java b/ty-user/src/main/java/top/kuanghua/tyuser/controller/BrandController.java index ab88940..ebddde9 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/controller/BrandController.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/controller/BrandController.java @@ -37,24 +37,18 @@ public class BrandController { @ApiOperation(value = "分页查询所有数据") public ResResult selectPage(Brand brand, KHCommonParams commonParams) { QueryWrapper queryWrapper = new QueryWrapper<>(); - if (ObjectUtils.isNotEmpty(brand.getId())) { - queryWrapper.or().like("id", brand.getId()); - } if (ObjectUtils.isNotEmpty(brand.getName())) { - queryWrapper.or().like("name", brand.getName()); + queryWrapper.like("name", brand.getName()); } if (ObjectUtils.isNotEmpty(brand.getImage())) { - queryWrapper.or().like("image", brand.getImage()); + queryWrapper.like("image", brand.getImage()); } if (ObjectUtils.isNotEmpty(brand.getLetter())) { - queryWrapper.or().like("letter", brand.getLetter()); - } - if (ObjectUtils.isNotEmpty(brand.getSeq())) { - queryWrapper.or().like("seq", brand.getSeq()); + queryWrapper.like("letter", brand.getLetter()); } - queryWrapper.or().orderByDesc("create_time"); + queryWrapper.orderByDesc("create_time"); if(StringUtils.isNotEmpty(commonParams.getStartTime())) { - queryWrapper.or().between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); + queryWrapper.between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); } queryWrapper.select("id,name,image,letter,seq,create_time,update_time"); Page brandPage = this.brandService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java b/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java index c5a6512..04c8696 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java @@ -38,22 +38,22 @@ public class ErrorCollectionController { public ResResult selectPage(ErrorCollection errorCollection, KHCommonParams khCommonParams) { QueryWrapper queryWrapper = new QueryWrapper<>(); if (ObjectUtils.isNotEmpty(errorCollection.getErrorLog())) { - queryWrapper.or().like("error_log", errorCollection.getErrorLog()); + queryWrapper.like("error_log", errorCollection.getErrorLog()); } if (ObjectUtils.isNotEmpty(errorCollection.getPageUrl())) { - queryWrapper.or().like("page_url", errorCollection.getPageUrl()); + queryWrapper.like("page_url", errorCollection.getPageUrl()); } if (ObjectUtils.isNotEmpty(errorCollection.getVersion())) { - queryWrapper.or().like("version", errorCollection.getVersion()); + queryWrapper.like("version", errorCollection.getVersion()); } if (ObjectUtils.isNotEmpty(errorCollection.getCreateTime())) { - queryWrapper.or().like("create_time", errorCollection.getCreateTime()); + queryWrapper.like("create_time", errorCollection.getCreateTime()); } if(StringUtils.isNotEmpty(khCommonParams.getStartTime())) { - queryWrapper.or().between("create_time",khCommonParams.getStartTime(),khCommonParams.getEndTime()); + queryWrapper.between("create_time",khCommonParams.getStartTime(),khCommonParams.getEndTime()); } - queryWrapper.or().orderByDesc("create_time"); + queryWrapper.orderByDesc("create_time"); Page errorCollectionPage = this.errorCollectionService.selectPage(khCommonParams.getPageNum(), khCommonParams.getPageSize(), queryWrapper); return new ResResult().success(errorCollectionPage); } diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/controller/UserController.java b/ty-user/src/main/java/top/kuanghua/tyuser/controller/UserController.java index dfc01c4..123f073 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/controller/UserController.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/controller/UserController.java @@ -53,13 +53,13 @@ public class UserController { public ResResult selectPage(User user, KHCommonParams commonParams) { QueryWrapper queryWrapper = new QueryWrapper<>(); if(StringUtils.isNotEmpty(user.getUsername())) { - queryWrapper.or().like("username",user.getUsername()); + queryWrapper.like("username",user.getUsername()); } if(StringUtils.isNotEmpty(user.getPhone())) { - queryWrapper.or().like("phone",user.getPhone()); + queryWrapper.like("phone",user.getPhone()); } if(StringUtils.isNotEmpty(commonParams.getStartTime())) { - queryWrapper.or().between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); + queryWrapper.between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); } queryWrapper.select("username","phone","create_time"); Page userPage = this.userMapper.selectPage(new Page<>(commonParams.getPageNum(), commonParams.getPageSize()), queryWrapper); @@ -100,7 +100,7 @@ public ResResult selectById(@RequestParam("id") Integer id) { public ResResult insert(@Valid @RequestBody User user) { //List userInfos = userInfoMapper.selectList(new EntityWrapper<>(userInfo).like("firstname", name) - // .or().like("lastname", name));52 + // .like("lastname", name));52 return new ResResult().success(this.userService.insert(user)); } /** diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/controller/VciController.java b/ty-user/src/main/java/top/kuanghua/tyuser/controller/VciController.java index 93a0285..c258672 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/controller/VciController.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/controller/VciController.java @@ -33,7 +33,6 @@ public class VciController { @Resource private VciService vciService; - /** * 分页查询所有数据 * @param vci 查询实体 diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/excel/imp/VciExcelImp.java b/ty-user/src/main/java/top/kuanghua/tyuser/excel/imp/VciExcelImp.java index b9a641d..9fd85f9 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/excel/imp/VciExcelImp.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/excel/imp/VciExcelImp.java @@ -9,7 +9,6 @@ /** * VCI设备表(Vci)表实体类 - * * @author kuanghua * @since 2021-10-22 10:34:43 */ diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/service/UserService.java b/ty-user/src/main/java/top/kuanghua/tyuser/service/UserService.java index a3060ce..3169080 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/service/UserService.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/service/UserService.java @@ -155,7 +155,6 @@ public HashMap loginValid(User user) { throw new RuntimeException("用户不存在"); } - System.out.println(CodecUtils.md5Hex(user.getPassword(), resUser.getSalt())); if(!resUser.getPassword().equals(CodecUtils.md5Hex(user.getPassword(),resUser.getSalt()))){ throw new RuntimeException("用户名或密码错误"); } @@ -178,7 +177,6 @@ public void changePassword(String username,String oldPassword,String newPassword if (ObjectUtilsSelf.isEmpty(resUser)) { throw new RuntimeException("用户不存在"); } - System.out.println(CodecUtils.md5Hex(resUser.getPassword(), resUser.getSalt())); if(!resUser.getPassword().equals(CodecUtils.md5Hex(oldPassword,resUser.getSalt()))){ throw new RuntimeException("密码错误"); } diff --git a/ty-user/ty-user.iml b/ty-user/ty-user.iml index 0ccd583..bb1bebe 100644 --- a/ty-user/ty-user.iml +++ b/ty-user/ty-user.iml @@ -22,7 +22,7 @@ - + @@ -34,41 +34,47 @@ - - + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - - - + + + - + @@ -87,16 +93,7 @@ - - - - - - - - - - + @@ -105,129 +102,145 @@ - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + - - + + + + + + + + - - - + + + - + - + - + - + - - - - + + + + - - - - - - - + + + + + + + + + + + + + + + + + + - - - - + + + + + + - - - - - - + + + + - - - - - + + + + + \ No newline at end of file From 9b85ba3f477973e775cc93a89a33a70b02e18f73 Mon Sep 17 00:00:00 2001 From: jzfai <869653722@qq.com> Date: Thu, 6 Jan 2022 18:52:06 +0800 Subject: [PATCH 11/36] add send email msg and delay queue --- ty-example/src/main/resources/application.yml | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/ty-example/src/main/resources/application.yml b/ty-example/src/main/resources/application.yml index 1b3189a..e69de29 100644 --- a/ty-example/src/main/resources/application.yml +++ b/ty-example/src/main/resources/application.yml @@ -1,24 +0,0 @@ -#msg config, place change to you sms config -kuanghua: - sms: - accessKeyId: LTAI4FrD2voTK2wTgRCPwT6d - accessKeySecret: Zj07thnb2jiBkl4wtqgvPeuSzkJRJ3 - signName: 品优商城 # 签名名称 - verifyCodeTemplate: SMS_189216068 # 模板名称 - - - - -#email config, place change to you email -spring: - mail: - username: 869653722@qq.com - password: xbthzedhnxatbcab - host: smtp.qq.com - properties: - mail.smtp.starttls.enable: true - - - -server: - port: ${envpt.tomcatPortPre}0121 \ No newline at end of file From 87fdfc0b59fdaa44584341cf9c36bc207e1c1178 Mon Sep 17 00:00:00 2001 From: jzfai <869653722@qq.com> Date: Sat, 8 Jan 2022 23:23:02 +0800 Subject: [PATCH 12/36] hystix and fix some demo --- .gitignore | 3 +- README.md | 9 +- micro-service-plus.iml | 77 +++-- pom.xml | 44 ++- ty-auth/src/main/resources/bootstrap.yml | 22 +- ty-common/ty-common.iml | 244 ++++++++-------- ty-example/pom.xml | 7 + .../controller/HystrixRibbonController.java | 31 ++ .../tyexample/controller/SmsController.java | 32 --- .../controller/UploadController.java | 84 ++++++ .../tyexample/service/UploadService.java | 92 ++++++ ty-example/src/main/resources/bootstrap.yml | 8 +- ty-example/ty-auth.iml | 222 -------------- ty-example/ty-example.iml | 262 +++++++++-------- ty-excel/src/main/resources/bootstrap.yml | 2 +- ty-excel/ty-excel.iml | 253 ++++++++-------- .../gatewaytwo/GatewayOneApplication.java | 8 +- .../gatewaytwo/config/BaseConfig.java | 4 +- .../gatewaytwo/config/JwtProperties.java | 4 +- .../SpecialHystrixGatewayFilterFactory.java | 241 ++++++++++++++++ .../controller/HstrixController.java | 26 ++ .../filter/AuthorizeFilterBefore.java | 34 ++- .../src/main/resources/application.yml | 205 ++++++------- .../src/main/resources/bootstrap.yml | 5 +- ty-gateway/ty-gateway-one/ty-gateway-one.iml | 271 +++++++++--------- ty-gateway/ty-gateway.iml | 271 +++++++++--------- ty-upload/src/main/resources/bootstrap.yml | 2 +- ty-upload/ty-upload.iml | 247 ++++++++-------- .../tyuser/controller/BrandController.java | 20 +- .../controller/ErrorCollectionController.java | 11 +- .../tyuser/controller/VciController.java | 1 + ty-user/src/main/resources/bootstrap.yml | 2 +- 32 files changed, 1465 insertions(+), 1279 deletions(-) create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/HystrixRibbonController.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/SmsController.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/UploadController.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java delete mode 100644 ty-example/ty-auth.iml create mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SpecialHystrixGatewayFilterFactory.java create mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/controller/HstrixController.java diff --git a/.gitignore b/.gitignore index 0ad508a..67f963d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ node_modules dist dist-ssr *.local -target \ No newline at end of file +target +*.iml \ No newline at end of file diff --git a/README.md b/README.md index 48b11e6..1a0d3ec 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ 使用的技术如下: ```java -spring-boot:2.2.4.RELEASE -spring-cloud:Hoxton.SR12 -spring-cloud-starter-gateway:2.2.9.RELEASE +spring-boot:2.1.4.RELEASE +spring-cloud:Greenwich.SR1 +spring-cloud-starter-gateway:2.1.1.RELEASE nacos:2.1.3.RELEASE mybatis-plus: 3.3.2 rabbitmq:3.7-management @@ -14,6 +14,9 @@ redis: 3.2.9 mysql:5.7 ``` + + + #### 更新日志: to look doc ---- diff --git a/micro-service-plus.iml b/micro-service-plus.iml index aad4444..7f10b3d 100644 --- a/micro-service-plus.iml +++ b/micro-service-plus.iml @@ -8,61 +8,50 @@ - - - - - - - - - + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - + - - - - - - + + + + + + - - - - + + + + - - - - - - + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 715f5ce..8872073 100644 --- a/pom.xml +++ b/pom.xml @@ -21,12 +21,12 @@ org.springframework.boot spring-boot-starter-parent - 2.2.4.RELEASE + 2.1.4.RELEASE - Hoxton.SR12 + Greenwich.SR1 @@ -88,9 +88,6 @@ dev - - true - dev 8.135.1.141 @@ -105,6 +102,7 @@ test + true @@ -120,23 +118,23 @@ 123456 - - - prod - - true - - - prod - 8.135.1.141 - ${baseLinuxIp}:8848 - 1000 - 127.0.0.1 - df87d91b-b1ab-4720-8e1c-5a147edc6ddc - nacos-group-${activatedProperties} - jzfai - 123456 - - + + + + + + + + + + + + + + + + + + diff --git a/ty-auth/src/main/resources/bootstrap.yml b/ty-auth/src/main/resources/bootstrap.yml index 40f8dfe..23a6628 100644 --- a/ty-auth/src/main/resources/bootstrap.yml +++ b/ty-auth/src/main/resources/bootstrap.yml @@ -16,20 +16,20 @@ spring: file-extension: yml # 用于共享的配置文件 shared-configs: - - data-id: application-@activatedProperties@.yml + - data-id: application-main.yml group: @nacosGroup@ refresh: true # 额外的配置文件 -# extension-configs: -# - data-id: application-db.yml -# group: @nacosGroup@ -# refresh: true -# - data-id: application-rabbit.yml -# group: @nacosGroup@ -# refresh: true -# - data-id: application-redis.yml -# group: @nacosGroup@ -# refresh: true + # extension-configs: + # - data-id: application-db.yml + # group: @nacosGroup@ + # refresh: true + # - data-id: application-rabbit.yml + # group: @nacosGroup@ + # refresh: true + # - data-id: application-redis.yml + # group: @nacosGroup@ + # refresh: true discovery: namespace: @nacosNamespace@ group: @nacosGroup@ diff --git a/ty-common/ty-common.iml b/ty-common/ty-common.iml index e823a48..3ffe7b5 100644 --- a/ty-common/ty-common.iml +++ b/ty-common/ty-common.iml @@ -20,49 +20,48 @@ - - - + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - + - + - - - + + + - + @@ -82,13 +81,15 @@ - - - - - - - + + + + + + + + + @@ -97,132 +98,123 @@ - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - + + + - - - + + + - + - + - + - + - - - - + + + + - - - - - - - - - - + + + + + + - - - - + + + + - - - - + + + + \ No newline at end of file diff --git a/ty-example/pom.xml b/ty-example/pom.xml index f809565..416031b 100644 --- a/ty-example/pom.xml +++ b/ty-example/pom.xml @@ -32,6 +32,13 @@ org.springframework.boot spring-boot-starter-mail + + + + com.github.tobato + fastdfs-client + 1.27.2 + diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/HystrixRibbonController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/HystrixRibbonController.java new file mode 100644 index 0000000..ced9bb3 --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/controller/HystrixRibbonController.java @@ -0,0 +1,31 @@ +package top.kuanghua.tyexample.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import top.kuanghua.khcomomon.entity.ResResult; + +/** + * @Title: HystrixRibbonController + * @Description: + * @Auther: kuanghua + * @create 2022-01-08 17:20 + */ +@Api(tags = "HystrixRibbon和限流测试") +@RestController +@RequestMapping("hystrixRibbon") +public class HystrixRibbonController { + @ApiOperation(value = "测试Hystrix熔断和Ribbon") + @GetMapping("timeoutTest") + public ResResult timeoutTest() { + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + return new ResResult<>().success(); + + } +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/SmsController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/SmsController.java deleted file mode 100644 index d986fc0..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/SmsController.java +++ /dev/null @@ -1,32 +0,0 @@ -package top.kuanghua.tyexample.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.tyexample.service.SendMsgService; - -/** - * @Title: SmsController @Description: @Auther: - * - * @create 2020/8/20 11:33 - */ -@Api(tags = "短信") -@RestController -@RequestMapping("sms") -public class SmsController { - - @Autowired - private SendMsgService sendMsgService; - @ApiOperation(value = "发送短信") - @PostMapping("sendSms") - public ResResult sendSms(@ApiParam("手机号") @RequestParam("phone") String phone) { - sendMsgService.sendMsg(phone); - return new ResResult().success("短信发送成功"); - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/UploadController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/UploadController.java new file mode 100644 index 0000000..cd46146 --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/controller/UploadController.java @@ -0,0 +1,84 @@ +package top.kuanghua.tyexample.controller; + +import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; +import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.tyexample.service.UploadService; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; + +/** + * @Title: UploadController @Description: @Auther:jzfai @Version: 1.0 + * @create 2020/3/4 21:58 + */ +@RestController +@RequestMapping("upload") +@Api(tags = "图片上传") +@DefaultProperties(defaultFallback = "fallBackMethod") // 指定一个类的全局熔断方法 +@RefreshScope +public class UploadController { + + + @Autowired + private UploadService uploadService; + + @ApiOperation(value = "上传图片或文件", notes = "上传图片接口") + @PostMapping("image") + public ResResult uploadImage(@RequestParam("file") MultipartFile file) + throws IOException, InterruptedException { + String url = this.uploadService.upload(file); + Thread.sleep(20000); + HashMap map = new HashMap<>(); + map.put("shortPath", url); + return new ResResult().success(map); + } + + // +// @ApiOperation(value = "上传图片(多张)") +// @PostMapping("uploadGetMetaData") +// public ResResult uploadGetMetaData(@RequestParam("files") MultipartFile[] files) +// throws IOException, InterruptedException { +// ArrayList strings = new ArrayList<>(); +// for (MultipartFile file : files) { +// Map stringStringMap = this.uploadService.uploadGetMetaData(file); +// strings.add(stringStringMap); +// } +// //Thread.sleep(5000); +// return new ResResult().success(strings); +// } + @ApiOperation(value = "批量上传图片或文件") + @PostMapping("files") + public ResResult uploadFileList(@RequestParam("files") MultipartFile[] files) throws IOException { + ArrayList strings = new ArrayList<>(); + for (MultipartFile file : files) { + String url = this.uploadService.upload(file); + strings.add(url); + } + return new ResResult().success(strings); + } + + public String fallBackMethod() { + return "请求繁忙,请稍后再试!"; + } + +// @Value(value = "${demo.a}") +// private String data12; +// @Value(value = "${demo.b}") +// private String datas; +// @ApiOperation(value = "test") +// @GetMapping("test") +// public String test() { +// System.out.println("data :" + data12 + ",datas="+datas); +// return "data :" + data12 + ",datas="+datas; +// } +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java new file mode 100644 index 0000000..eb5317b --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java @@ -0,0 +1,92 @@ +package top.kuanghua.tyexample.service; + + +import com.alibaba.fastjson.JSON; +import com.github.tobato.fastdfs.domain.fdfs.MetaData; +import com.github.tobato.fastdfs.domain.fdfs.StorePath; +import com.github.tobato.fastdfs.service.FastFileStorageClient; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.*; + +/** + * @Title: UploadService + * @Description: + * @Auther:jzfai + * @Version: 1.0 + * @create 2020/3/4 21:58 + */ +@Service +@Slf4j +public class UploadService { + + @Resource + private FastFileStorageClient storageClient; + + private static final List CONTENT_TYPES = Arrays.asList("image/jpeg", "image/gif"); + + public String upload(MultipartFile file) throws IOException { + String originalFilename = file.getOriginalFilename(); + //检验文件类型 + String contentType = file.getContentType(); + if (!CONTENT_TYPES.contains(contentType)) { + //文件类型不合法 + log.info("文件类型不合法:{}", originalFilename); + throw new RuntimeException("文件内容不合法"); + } + //检验文件内容 + BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); + if (bufferedImage == null) { + log.info("文件内容不合法:{}", originalFilename); + throw new RuntimeException("文件内容不合法"); + } + //保存到服务器 + //file.transferTo(new File("D:\\java\\javaproject\\pinyou\\pinyou-upload\\src\\main\\resources\\static\\" + originalFilename)); + //上传到FastDfs + String ext = StringUtils.substringAfterLast(originalFilename, "."); + HashSet metaData = new HashSet<>(); + metaData.add(new MetaData("name", file.getOriginalFilename())); + metaData.add(new MetaData("createTime", JSON.toJSONString(new Date()))); + StorePath storePath = this.storageClient.uploadFile(file.getInputStream(), file.getSize(), ext, metaData); + return storePath.getFullPath(); + } + + public Map uploadGetMetaData(MultipartFile file) throws IOException { + String originalFilename = file.getOriginalFilename(); + //检验文件类型 + String contentType = file.getContentType(); + if (!CONTENT_TYPES.contains(contentType)) { + //文件类型不合法 + log.info("文件类型不合法:{}", originalFilename); + } + //检验文件内容 + BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); + if (bufferedImage == null) { + log.info("文件内容不合法:{}", originalFilename); + } + //保存到服务器 + //file.transferTo(new File("D:\\java\\javaproject\\pinyou\\pinyou-upload\\src\\main\\resources\\static\\" + originalFilename)); + //上传到FastDfs + String ext = StringUtils.substringAfterLast(originalFilename, "."); + HashSet metaData = new HashSet<>(); + metaData.add(new MetaData("name", file.getOriginalFilename())); + StorePath storePath = this.storageClient.uploadFile(file.getInputStream(), file.getSize(), ext, metaData); + //获取数据源信息 + Set metadata = this.storageClient.getMetadata(storePath.getGroup(), storePath.getPath()); + ArrayList metaDataArrayList = new ArrayList<>(metadata); + String name = metaDataArrayList.get(0).getValue(); + //拼接name和url返回 + Map hashMap = new HashMap<>(); + hashMap.put("name", name); + hashMap.put("url", storePath.getFullPath()); + hashMap.put("group", storePath.getGroup()); + return hashMap; + } +} diff --git a/ty-example/src/main/resources/bootstrap.yml b/ty-example/src/main/resources/bootstrap.yml index c1b6427..76ddd5d 100644 --- a/ty-example/src/main/resources/bootstrap.yml +++ b/ty-example/src/main/resources/bootstrap.yml @@ -16,20 +16,26 @@ spring: file-extension: yml # 用于共享的配置文件 shared-configs: - - data-id: application-@activatedProperties@.yml + - data-id: application-main.yml group: @nacosGroup@ refresh: true # 额外的配置文件 extension-configs: + #get mysql config - data-id: application-db.yml group: @nacosGroup@ refresh: true - data-id: application-rabbit.yml group: @nacosGroup@ refresh: true + #get redis config - data-id: application-redis.yml group: @nacosGroup@ refresh: true + #get fdfs config + - data-id: application-upload.yml + group: @nacosGroup@ + refresh: true discovery: namespace: @nacosNamespace@ group: @nacosGroup@ diff --git a/ty-example/ty-auth.iml b/ty-example/ty-auth.iml deleted file mode 100644 index 9447a05..0000000 --- a/ty-example/ty-auth.iml +++ /dev/null @@ -1,222 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ty-example/ty-example.iml b/ty-example/ty-example.iml index 866c9e1..27a5064 100644 --- a/ty-example/ty-example.iml +++ b/ty-example/ty-example.iml @@ -21,37 +21,30 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + - - + - - - + + + - + @@ -60,7 +53,6 @@ - @@ -70,7 +62,16 @@ - + + + + + + + + + + @@ -79,165 +80,160 @@ - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + - - - - - - - - + + - - - + + + - + - + - - + - + - - + + - + - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + - - - - + + - - - - - + + + + + \ No newline at end of file diff --git a/ty-excel/src/main/resources/bootstrap.yml b/ty-excel/src/main/resources/bootstrap.yml index 97d7d53..5336782 100644 --- a/ty-excel/src/main/resources/bootstrap.yml +++ b/ty-excel/src/main/resources/bootstrap.yml @@ -16,7 +16,7 @@ spring: file-extension: yml # 用于共享的配置文件 shared-configs: - - data-id: application-@activatedProperties@.yml + - data-id: application-main.yml group: @nacosGroup@ refresh: true extension-configs: diff --git a/ty-excel/ty-excel.iml b/ty-excel/ty-excel.iml index a9383d1..ac0db2e 100644 --- a/ty-excel/ty-excel.iml +++ b/ty-excel/ty-excel.iml @@ -27,7 +27,7 @@ - + @@ -39,47 +39,41 @@ - - - - - - - + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - - - + + + - + @@ -98,7 +92,16 @@ - + + + + + + + + + + @@ -107,145 +110,129 @@ - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + - - - - - - - - + + - - - + + + - + - + - + - + - - - - + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + - - - - + + + + - - - - - + + + + + \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/GatewayOneApplication.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/GatewayOneApplication.java index d767278..4b46482 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/GatewayOneApplication.java +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/GatewayOneApplication.java @@ -18,11 +18,12 @@ @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) public class GatewayOneApplication { public static void main(String[] args) { - SpringApplication.run(GatewayOneApplication.class,args); + SpringApplication.run(GatewayOneApplication.class, args); } + //创建一个ipKeyResolver 指定用户的IP - @Bean(name="ipKeyResolver") - public KeyResolver keyResolver(){ + @Bean(name = "ipKeyResolver") + public KeyResolver keyResolver() { return new KeyResolver() { @Override public Mono resolve(ServerWebExchange exchange) { @@ -35,4 +36,5 @@ public Mono resolve(ServerWebExchange exchange) { } }; } + } diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/BaseConfig.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/BaseConfig.java index 198fee6..6effeec 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/BaseConfig.java +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/BaseConfig.java @@ -18,4 +18,6 @@ //dao包扫描 @ComponentScan(basePackages = {"top.kuanghua.khcomomon"}) @EnableFeignClients(basePackages = {"top.kuanghua.feign"}) -public class BaseConfig {} +public class BaseConfig { + +} diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/JwtProperties.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/JwtProperties.java index 15e5447..9bf7775 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/JwtProperties.java +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/JwtProperties.java @@ -34,7 +34,7 @@ public void init() throws Exception { File priKeyFile = new File(priKeyPath); if (!pubKeyFile.exists() || !priKeyFile.exists()) { File fileParent = pubKeyFile.getParentFile(); - if(!fileParent.exists()){ + if (!fileParent.exists()) { fileParent.mkdirs(); } throw new RuntimeException("秘钥文件不存在"); @@ -45,7 +45,7 @@ public void init() throws Exception { // } catch (Exception e) { // log.error("生成秘钥失败"); // //e.printStackTrace(); -// } +// }r } //读取公钥和私钥文件 this.publicKey = RsaUtils.getPublicKey(pubKeyPath); diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SpecialHystrixGatewayFilterFactory.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SpecialHystrixGatewayFilterFactory.java new file mode 100644 index 0000000..a206eeb --- /dev/null +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SpecialHystrixGatewayFilterFactory.java @@ -0,0 +1,241 @@ +package top.kuanghua.gatewaytwo.config; + +import com.netflix.hystrix.HystrixCommandGroupKey; +import com.netflix.hystrix.HystrixCommandKey; +import com.netflix.hystrix.HystrixCommandProperties; +import com.netflix.hystrix.HystrixObservableCommand; +import com.netflix.hystrix.exception.HystrixRuntimeException; +import org.springframework.beans.factory.ObjectProvider; +import org.springframework.cloud.gateway.filter.GatewayFilter; +import org.springframework.cloud.gateway.filter.GatewayFilterChain; +import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; +import org.springframework.core.annotation.AnnotatedElementUtils; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.reactive.DispatcherHandler; +import org.springframework.web.server.ResponseStatusException; +import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.util.UriComponentsBuilder; +import reactor.core.publisher.Mono; +import rx.Observable; +import rx.RxReactiveStreams; +import rx.Subscription; + +import java.math.BigDecimal; +import java.net.URI; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeoutException; +import java.util.function.Function; + +import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR; +import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.containsEncodedParts; + +@Component +public class SpecialHystrixGatewayFilterFactory extends AbstractGatewayFilterFactory { + + private static final String NAME = "SpecialHystrix"; + + private final ObjectProvider dispatcherHandler; + + public SpecialHystrixGatewayFilterFactory(ObjectProvider dispatcherHandler) { + super(Config.class); + this.dispatcherHandler = dispatcherHandler; + } + + @Override + public List shortcutFieldOrder() { + return Collections.singletonList(NAME_KEY); + } + + @Override + public GatewayFilter apply(Config config) { + return (exchange, chain) -> { + ServerHttpRequest request = exchange.getRequest(); + String path = request.getPath().pathWithinApplication().value(); + Map timeoutMap = config.getTimeout(); + Integer timeout = null; + if (timeoutMap != null) { + //对rest接口通配符url进行转换 暂只配置url 末尾为数字的的接口--- + path = config.wildCard(path); + timeout = timeoutMap.get(path); + } + + MyRouteHystrixCommand command; + if (timeout == null) { + //没有定义时间的接口将使用配置的default时间 + command = new MyRouteHystrixCommand(config.getFallbackUri(), exchange, chain, path); + } else { + //有配置时间的接口将使用配置的时间 + command = new MyRouteHystrixCommand(config.getFallbackUri(), exchange, chain, timeout, path); + } + + return Mono.create(s -> { + Subscription sub = command.toObservable().subscribe(s::success, s::error, s::success); + s.onCancel(sub::unsubscribe); + }).onErrorResume((Function>) throwable -> { + if (throwable instanceof HystrixRuntimeException) { + HystrixRuntimeException e = (HystrixRuntimeException) throwable; + HystrixRuntimeException.FailureType failureType = e.getFailureType(); + switch (failureType) { + case TIMEOUT: + return Mono.error(new TimeoutException()); + case COMMAND_EXCEPTION: { + Throwable cause = e.getCause(); + if (cause instanceof ResponseStatusException || AnnotatedElementUtils + .findMergedAnnotation(cause.getClass(), ResponseStatus.class) != null) { + return Mono.error(cause); + } + } + default: + break; + } + } + return Mono.error(throwable); + }).then(); + }; + } + + @Override + public String name() { + return NAME; + } + + private class MyRouteHystrixCommand extends HystrixObservableCommand { + + private final URI fallbackUri; + private final ServerWebExchange exchange; + private final GatewayFilterChain chain; + + public MyRouteHystrixCommand(URI fallbackUri, ServerWebExchange exchange, GatewayFilterChain chain, + String key) { + super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(key)) + .andCommandKey(HystrixCommandKey.Factory.asKey(key))); + this.fallbackUri = fallbackUri; + this.exchange = exchange; + this.chain = chain; + + } + + public MyRouteHystrixCommand(URI fallbackUri, ServerWebExchange exchange, GatewayFilterChain chain, + int timeout, + String key) { + //***出现通配符的情况**// + super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(key)) + .andCommandKey(HystrixCommandKey.Factory.asKey(key)) + .andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withExecutionTimeoutInMilliseconds(timeout))); + this.fallbackUri = fallbackUri; + this.exchange = exchange; + this.chain = chain; + + } + + @Override + protected Observable construct() { + return RxReactiveStreams.toObservable(this.chain.filter(exchange)); + } + + @Override + protected Observable resumeWithFallback() { + if (null == fallbackUri) { + return super.resumeWithFallback(); + } + URI uri = exchange.getRequest().getURI(); + boolean encoded = containsEncodedParts(uri); + URI requestUrl = UriComponentsBuilder.fromUri(uri) + .host(null) + .port(null) + .uri(this.fallbackUri) + .build(encoded) + .toUri(); + exchange.getAttributes().put(GATEWAY_REQUEST_URL_ATTR, requestUrl); + + ServerHttpRequest request = this.exchange.getRequest().mutate().uri(requestUrl).build(); + ServerWebExchange mutated = exchange.mutate().request(request).build(); + DispatcherHandler dispatcherHandler = SpecialHystrixGatewayFilterFactory.this.dispatcherHandler.getIfAvailable(); + return RxReactiveStreams.toObservable(dispatcherHandler.handle(mutated)); + } + } + + public static class Config { + + private String id; + private URI fallbackUri; + /** + * url -> timeout ms + */ + private Map timeout; + + public String getId() { + return id; + } + + public Config setId(String id) { + this.id = id; + return this; + } + + public URI getFallbackUri() { + return fallbackUri; + } + + public Config setFallbackUri(URI fallbackUri) { + if (fallbackUri != null && !"forward".equals(fallbackUri.getScheme())) { + throw new IllegalArgumentException("Hystrix Filter currently only supports 'forward' URIs, found " + fallbackUri); + } + this.fallbackUri = fallbackUri; + return this; + } + + public Map getTimeout() { + return timeout; + } + + public Config setTimeout(Map timeout) { + //YAML解析的时候MAP的KEY不支持'/',这里只能用'-'替代 + Map tempTimeout = new HashMap<>(timeout.size()); + for (String key : timeout.keySet()) { + Integer value = timeout.get(key); + + key = key.replace("-", "/"); + if (!key.startsWith("/")) { + key = "/" + key; + } + /** 末尾有动态传参 **/ + if (key.endsWith("/")) { + key = key + "**"; + } + tempTimeout.put(key, value); + } + this.timeout = tempTimeout; + return this; + } + + + public String wildCard(String path) { + String replace = path; + String[] split = path.split("/"); + if (split.length > 0) { + String wildcard = split[split.length - 1]; + boolean numeric = isNumeric(wildcard); + if (numeric) { + replace = path.replace(wildcard, "**"); + } + } + return replace; + } + + private boolean isNumeric(String str) { + String bigStr; + try { + bigStr = new BigDecimal(str).toString(); + } catch (Exception e) { + return false;//异常 说明包含非数字。 + } + return true; + } + } +} \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/controller/HstrixController.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/controller/HstrixController.java new file mode 100644 index 0000000..9138091 --- /dev/null +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/controller/HstrixController.java @@ -0,0 +1,26 @@ +package top.kuanghua.gatewaytwo.controller; + +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; +import top.kuanghua.khcomomon.entity.ResResult; + +/** + * @Title: hstrixController + * @Description: + * @Auther: kuanghua + * @create 2022-01-08 18:15 + */ +@RestController +public class HstrixController { + @ApiOperation(value = "") + @GetMapping("fallback") + public ResResult fallback() { + ResResult resResult = new ResResult(); + //设置20010为熔断状态吗 + resResult.setCode(20010); + resResult.setMsg("接口发生了熔断"); + resResult.setFlag(false); + return resResult; + } +} \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java index d99b2f2..75eecf8 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.cloud.gateway.filter.GatewayFilterChain; import org.springframework.cloud.gateway.filter.GlobalFilter; @@ -17,11 +16,10 @@ import org.springframework.web.server.ServerWebExchange; import reactor.core.publisher.Mono; import top.kuanghua.feign.tyauth.feign.TokenFeign; -import top.kuanghua.khcomomon.entity.ResResult; import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; +import javax.annotation.Resource; import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.List; @@ -46,7 +44,7 @@ * */ public class AuthorizeFilterBefore implements GlobalFilter, Ordered { - private static final String AUTHORIZE_TOKEN="AUTHORIZE_TOKEN"; + private static final String AUTHORIZE_TOKEN = "AUTHORIZE_TOKEN"; @Value("#{'${filter.allowPaths:}'.empty ? null : '${filter.allowPaths:}'.split(',')}") private List allowPaths; // @Value("${filter.allowPaths}") @@ -56,7 +54,7 @@ public class AuthorizeFilterBefore implements GlobalFilter, Ordered { // @Value("${jwt-properties.priKeyPath}") // private String priKeyPath; - @Autowired + @Resource private TokenFeign tokenFeign; @Override @@ -68,18 +66,18 @@ public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { //List stringList = Arrays.asList("/api/user/login","/api/search/searchData"); //1.白名单放行 for (String allowPath : allowPaths) { - if(StringUtils.contains(path,allowPath)){ - return chain.filter(exchange); + if (StringUtils.contains(path, allowPath)) { + return chain.filter(exchange); } } //2.解析jwt token放行 String jwtToken = request.getHeaders().getFirst(AUTHORIZE_TOKEN); - if(ObjectUtils.isEmpty(jwtToken)){ + if (ObjectUtils.isEmpty(jwtToken)) { JSONObject message = new JSONObject(); - message.put("code",403); + message.put("code", 403); message.put("msg", "token为空"); - DataBuffer buffer = getDataBuffer(response,message); + DataBuffer buffer = getDataBuffer(response, message); return response.writeWith(Mono.just(buffer)); } //2.1 将解析到的jwt数据保存到线程中(转发过去的服务都能接收) @@ -88,13 +86,13 @@ public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { //Claims claims = JwtUtilsKh.parserTokenGetBody(jwtToken, RsaUtils.getPublicKey(pubKeyPath)); //System.out.println("解析出来的body"+claims); //调用feign服务进行解析 - Object resResult= tokenFeign.parseToken(jwtToken); + Object resResult = tokenFeign.parseToken(jwtToken); Map tokenInfo = ObjectUtilsSelf.parseResToData(resResult); - log.info("解析的token数据",tokenInfo.toString()); + log.info("解析的token数据", tokenInfo.toString()); //将信息设置到头部 ServerHttpRequest httpRequest = exchange.getRequest().mutate().headers(httpHeaders -> { - String decode=""; + String decode = ""; try { decode = URLEncoder.encode(JSON.toJSONString(tokenInfo), "utf-8"); } catch (UnsupportedEncodingException e) { @@ -107,14 +105,14 @@ public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { return chain.filter(build); } catch (Exception e) { JSONObject message = new JSONObject(); - message.put("code",403); - message.put("msg","token解析失败"+e.getMessage()); - log.error("token解析失败"+e); - return response.writeWith(Mono.just(getDataBuffer(response,message))); + message.put("code", 403); + message.put("msg", "token解析失败" + e.getMessage()); + log.error("token解析失败" + e); + return response.writeWith(Mono.just(getDataBuffer(response, message))); } } - private DataBuffer getDataBuffer(ServerHttpResponse response, JSONObject message) { + private DataBuffer getDataBuffer(ServerHttpResponse response, JSONObject message) { byte[] bits = message.toJSONString().getBytes(StandardCharsets.UTF_8); DataBuffer buffer = response.bufferFactory().wrap(bits); //response.setStatusCode(HttpStatus.UNAUTHORIZED); diff --git a/ty-gateway/ty-gateway-one/src/main/resources/application.yml b/ty-gateway/ty-gateway-one/src/main/resources/application.yml index bb642e0..b77388d 100644 --- a/ty-gateway/ty-gateway-one/src/main/resources/application.yml +++ b/ty-gateway/ty-gateway-one/src/main/resources/application.yml @@ -1,96 +1,109 @@ -#server: -# port: ${envpt.tomcatPortPre}0156 -# -#spring: -# cloud: -# gateway: -# globalcors: -# corsConfigurations: -# '[/**]': -# # 允许携带认证信息 -# # 允许跨域的源(网站域名/ip),设置*为全部 -# # 允许跨域请求里的head字段,设置*为全部 -# # 允许跨域的method, 默认为GET和OPTIONS,设置*为全部 -# # 跨域允许的有效期 -# allow-credentials: true -# allowed-origins: "*" -# allowed-headers: "*" -# allowed-methods: -# - OPTIONS -# - GET -# - POST -# - PUT -# - DELETE -# #max-age: 3600 -# routes: -# - id: ty-auth -# uri: lb://ty-auth -# predicates: -# - Path=/api/ty-auth/** -# filters: -# - StripPrefix=2 -# -# - id: ty-email -# uri: lb://ty-email -# predicates: -# - Path=/api/ty-email/** -# filters: -# - StripPrefix=2 -# -# - id: ty-excel -# uri: lb://ty-excel -# predicates: -# - Path=/api/ty-excel/** -# filters: -# - StripPrefix=2 -# -# - id: ty-user -# uri: lb://ty-user -# predicates: -# - Path=/api/ty-user/** -# filters: -# - StripPrefix=2 -# -# - id: ty-upload -# uri: lb://ty-upload -# predicates: -# - Path=/api/ty-upload/** -# filters: -# - StripPrefix=2 -# -## - id: fai_search_route -## uri: lb://search -## predicates: -## - Path=/api/search/** -## filters: -## - StripPrefix=2 -## - name: RequestRateLimiter #请求数限流 名字不能随便写 ,使用默认的facatory -## args: -## key-resolver: "#{@ipKeyResolver}" -## redis-rate-limiter.replenishRate: 2 -## redis-rate-limiter.burstCapacity: 2 -# -# -#management: -# endpoint: -# gateway: -# enabled: true -# web: -# exposure: -# include: true -# -# -##白名单过滤 -#filter: -# allowPaths: swagger,docs,userRegister,userLogin,sendEmailCode,registry,login,loginOut,insertUser -# -# -# -#token-properties: -# renewTokenMinute: 1440 #默认1天时间告知前端刷新token -# -#swagger-doc: -# serviceMap: { -# ty-user: "用户模块", -# ty-upload: "文件上传" -# } \ No newline at end of file +server: + port: ${envpt.tomcatPortPre}0156 + +spring: + cloud: + gateway: + globalcors: + corsConfigurations: + '[/**]': + # 允许携带认证信息 + # 允许跨域的源(网站域名/ip),设置*为全部 + # 允许跨域请求里的head字段,设置*为全部 + # 允许跨域的method, 默认为GET和OPTIONS,设置*为全部 + # 跨域允许的有效期 + allow-credentials: true + allowed-origins: "*" + allowed-headers: "*" + allowed-methods: + - OPTIONS + - GET + - POST + - PUT + - DELETE + #max-age: 3600 + routes: + - id: ty-auth + uri: lb://ty-auth + predicates: + - Path=/api/ty-auth/** + filters: + - StripPrefix=2 + + - id: ty-email + uri: lb://ty-email + predicates: + - Path=/api/ty-email/** + filters: + - StripPrefix=2 + + - id: ty-example + uri: lb://ty-example + predicates: + - Path=/api/ty-example/** + filters: + - StripPrefix=2 + + #请求数限流 名字不能随便写 ,使用默认的facatory + - name: RequestRateLimiter + args: + key-resolver: "#{@ipKeyResolver}" + redis-rate-limiter.replenishRate: 2 + redis-rate-limiter.burstCapacity: 2 + + # hystrix 熔断配置 + - RemoveRequestHeader=Origin # 去除请求头的origin字段,此字段导致post请求 无法进入网关post熔断 + - name: SpecialHystrix #自定义熔断 + args: + id: SpecialHystrix + fallbackUri: forward:/fallback + timeout: + #指定接口超时处理 hystrixRibbon -> @RequestMapping("hystrixRibbon") + #timeoutTest-> @GetMapping("timeoutTest") , - > / + hystrixRibbon-timeoutTest: 11000 + #file-upload-: 20000 + #file-download-: 20000 + #course-file-upload-local-: 20000 + + - id: ty-user + uri: lb://ty-user + predicates: + - Path=/api/ty-user/** + filters: + - StripPrefix=2 + + - id: ty-upload + uri: lb://ty-upload + predicates: + - Path=/api/ty-upload/** + filters: + - StripPrefix=2 + +management: + endpoint: + gateway: + enabled: true + web: + exposure: + include: true + + +#白名单过滤 +filter: + allowPaths: / + notValidExpList: export,excel + + + +token-properties: + renewTokenMinute: 1440 #默认1天时间告知前端刷新token + + + +#config the visit service of gateway swagger +swagger-doc: + serviceMap: { + ty-user: "用户模块", + ty-upload: "文件上传", + ty-example: "使用例子" + } \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/src/main/resources/bootstrap.yml b/ty-gateway/ty-gateway-one/src/main/resources/bootstrap.yml index c3c775c..e6c3e43 100644 --- a/ty-gateway/ty-gateway-one/src/main/resources/bootstrap.yml +++ b/ty-gateway/ty-gateway-one/src/main/resources/bootstrap.yml @@ -16,13 +16,10 @@ spring: file-extension: yml # 用于共享的配置文件 shared-configs: - - data-id: application-@activatedProperties@.yml + - data-id: application-main.yml group: @nacosGroup@ refresh: true extension-configs: - - data-id: ty-gateway-one.yml - group: @nacosGroup@ - refresh: true - data-id: application-rabbit.yml group: @nacosGroup@ refresh: true diff --git a/ty-gateway/ty-gateway-one/ty-gateway-one.iml b/ty-gateway/ty-gateway-one/ty-gateway-one.iml index a5b16e9..2e4a4dc 100644 --- a/ty-gateway/ty-gateway-one/ty-gateway-one.iml +++ b/ty-gateway/ty-gateway-one/ty-gateway-one.iml @@ -27,14 +27,14 @@ - + - - - + + + - + @@ -53,7 +53,16 @@ - + + + + + + + + + + @@ -62,183 +71,165 @@ - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - + + + - - - + + + - + - - + + - + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + - - - - + + + + - - - - - + + + + + \ No newline at end of file diff --git a/ty-gateway/ty-gateway.iml b/ty-gateway/ty-gateway.iml index b92bf04..e5e33c2 100644 --- a/ty-gateway/ty-gateway.iml +++ b/ty-gateway/ty-gateway.iml @@ -15,14 +15,14 @@ - + - - - + + + - + @@ -41,7 +41,16 @@ - + + + + + + + + + + @@ -50,183 +59,165 @@ - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - + + + - - - + + + - + - - + + - + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + - - - - + + + + - - - - - + + + + + \ No newline at end of file diff --git a/ty-upload/src/main/resources/bootstrap.yml b/ty-upload/src/main/resources/bootstrap.yml index 19f67dc..3609f31 100644 --- a/ty-upload/src/main/resources/bootstrap.yml +++ b/ty-upload/src/main/resources/bootstrap.yml @@ -16,7 +16,7 @@ spring: file-extension: yml # 用于共享的配置文件 shared-configs: - - data-id: application-@activatedProperties@.yml + - data-id: application-main.yml group: @nacosGroup@ refresh: true extension-configs: diff --git a/ty-upload/ty-upload.iml b/ty-upload/ty-upload.iml index fa94c36..39cc125 100644 --- a/ty-upload/ty-upload.iml +++ b/ty-upload/ty-upload.iml @@ -26,32 +26,30 @@ - - - - - - - - - - - - - + + + + + + + + + + + - + - - - + + + - + @@ -69,7 +67,16 @@ - + + + + + + + + + + @@ -78,162 +85,146 @@ - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - + + + - - - - - - - - + + - - - + + + - + - + - + - + - - + + - - - - + + + + - - - - - - + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + - - + + - - - - - + + + + + \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/controller/BrandController.java b/ty-user/src/main/java/top/kuanghua/tyuser/controller/BrandController.java index ebddde9..c171fa4 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/controller/BrandController.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/controller/BrandController.java @@ -3,21 +3,18 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; -import com.baomidou.mybatisplus.extension.api.ApiController; -import com.baomidou.mybatisplus.extension.api.R; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; +import org.springframework.web.bind.annotation.*; import top.kuanghua.khcomomon.entity.KHCommonParams; import top.kuanghua.khcomomon.entity.ResResult; import top.kuanghua.tyuser.entity.Brand; import top.kuanghua.tyuser.service.BrandService; -import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import java.io.Serializable; -import java.util.*; +import java.util.List; @Api(tags = "品牌表(Brand)") @RestController @@ -30,25 +27,32 @@ public class BrandController { /** * 分页查询所有数据 * - * @param brand 查询实体 + * @param brand 查询实体 * @return 所有数据 */ @GetMapping("selectPage") @ApiOperation(value = "分页查询所有数据") public ResResult selectPage(Brand brand, KHCommonParams commonParams) { QueryWrapper queryWrapper = new QueryWrapper<>(); + if (ObjectUtils.isNotEmpty(brand.getId())) { + queryWrapper.like("id", brand.getId()); + } if (ObjectUtils.isNotEmpty(brand.getName())) { queryWrapper.like("name", brand.getName()); } if (ObjectUtils.isNotEmpty(brand.getImage())) { queryWrapper.like("image", brand.getImage()); } + if (ObjectUtils.isNotEmpty(brand.getLetter())) { queryWrapper.like("letter", brand.getLetter()); } + if (ObjectUtils.isNotEmpty(brand.getSeq())) { + queryWrapper.like("seq", brand.getSeq()); + } queryWrapper.orderByDesc("create_time"); - if(StringUtils.isNotEmpty(commonParams.getStartTime())) { - queryWrapper.between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); + if (StringUtils.isNotEmpty(commonParams.getStartTime())) { + queryWrapper.between("create_time", commonParams.getStartTime(), commonParams.getEndTime()); } queryWrapper.select("id,name,image,letter,seq,create_time,update_time"); Page brandPage = this.brandService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java b/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java index 04c8696..dcae33f 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java @@ -3,21 +3,18 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; -import com.baomidou.mybatisplus.extension.api.ApiController; -import com.baomidou.mybatisplus.extension.api.R; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; +import org.springframework.web.bind.annotation.*; import top.kuanghua.khcomomon.entity.KHCommonParams; import top.kuanghua.khcomomon.entity.ResResult; import top.kuanghua.tyuser.entity.ErrorCollection; import top.kuanghua.tyuser.service.ErrorCollectionService; -import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import java.io.Serializable; -import java.util.*; +import java.util.List; @Api(tags = "日志相关") @RestController @@ -50,8 +47,8 @@ public ResResult selectPage(ErrorCollection errorCollection, KHCommonParams khCo queryWrapper.like("create_time", errorCollection.getCreateTime()); } - if(StringUtils.isNotEmpty(khCommonParams.getStartTime())) { - queryWrapper.between("create_time",khCommonParams.getStartTime(),khCommonParams.getEndTime()); + if (StringUtils.isNotEmpty(khCommonParams.getStartTime())) { + queryWrapper.between("create_time", khCommonParams.getStartTime(), khCommonParams.getEndTime()); } queryWrapper.orderByDesc("create_time"); Page errorCollectionPage = this.errorCollectionService.selectPage(khCommonParams.getPageNum(), khCommonParams.getPageSize(), queryWrapper); diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/controller/VciController.java b/ty-user/src/main/java/top/kuanghua/tyuser/controller/VciController.java index c258672..93a0285 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/controller/VciController.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/controller/VciController.java @@ -33,6 +33,7 @@ public class VciController { @Resource private VciService vciService; + /** * 分页查询所有数据 * @param vci 查询实体 diff --git a/ty-user/src/main/resources/bootstrap.yml b/ty-user/src/main/resources/bootstrap.yml index 1d93e57..3a75337 100644 --- a/ty-user/src/main/resources/bootstrap.yml +++ b/ty-user/src/main/resources/bootstrap.yml @@ -16,7 +16,7 @@ spring: file-extension: yml # 用于共享的配置文件 shared-configs: - - data-id: application-@activatedProperties@.yml + - data-id: application-main.yml group: @nacosGroup@ refresh: true extension-configs: From dc1c2cd185ee58dd805c70b57f6560d978574cfa Mon Sep 17 00:00:00 2001 From: jzfai <869653722@qq.com> Date: Sun, 9 Jan 2022 20:18:57 +0800 Subject: [PATCH 13/36] add redis lock demo --- README.md | 3 +- ty-auth/src/main/resources/bootstrap.yml | 11 - ty-auth/ty-auth.iml | 246 ++++++++--------- ...RedisClient.java => RedisClientUtils.java} | 2 +- .../kuanghua/tyexample/config/BaseConfig.java | 6 + .../controller/RedisTestController.java | 133 +++++++++ .../tyexample/entity/ErrorCollection.java | 36 +++ .../mapper/ErrorCollectionMapper.java | 8 + .../tyexample/service/SendEmailService.java | 9 +- .../service/CacheAvalancheServiceTest.java | 32 +++ ty-example/ty-example.iml | 6 + .../kuanghua/tyuser/service/UserService.java | 92 +++---- ty-user/ty-user.iml | 253 +++++++++--------- 13 files changed, 511 insertions(+), 326 deletions(-) rename ty-common/src/main/java/top/kuanghua/khcomomon/utils/{RedisClient.java => RedisClientUtils.java} (99%) create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/entity/ErrorCollection.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/mapper/ErrorCollectionMapper.java create mode 100644 ty-example/src/test/java/top/kuanghua/tyexample/service/CacheAvalancheServiceTest.java diff --git a/README.md b/README.md index 1a0d3ec..2c5c8cc 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,6 @@ mysql:5.7 ``` - - #### 更新日志: to look doc ---- @@ -70,6 +68,7 @@ git clone https://github.com/jzfai/micro-service-plus.git >注:在Maven Projects->Profies 选择环境时,请不要选择prod环境。目前线上是prod环境下构建的包 + #### 架构亮点 1.网关中将jwt token和解析后的token信息已经设置在请求头中,在后续转发的微服务可以在请求头中,轻松的拿到token和token解析后的数据。不用再通过feign去调用ty-auth,获取token信息。 diff --git a/ty-auth/src/main/resources/bootstrap.yml b/ty-auth/src/main/resources/bootstrap.yml index 23a6628..bc12133 100644 --- a/ty-auth/src/main/resources/bootstrap.yml +++ b/ty-auth/src/main/resources/bootstrap.yml @@ -19,17 +19,6 @@ spring: - data-id: application-main.yml group: @nacosGroup@ refresh: true - # 额外的配置文件 - # extension-configs: - # - data-id: application-db.yml - # group: @nacosGroup@ - # refresh: true - # - data-id: application-rabbit.yml - # group: @nacosGroup@ - # refresh: true - # - data-id: application-redis.yml - # group: @nacosGroup@ - # refresh: true discovery: namespace: @nacosNamespace@ group: @nacosGroup@ diff --git a/ty-auth/ty-auth.iml b/ty-auth/ty-auth.iml index 7d21540..9447a05 100644 --- a/ty-auth/ty-auth.iml +++ b/ty-auth/ty-auth.iml @@ -21,39 +21,38 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - - - + + + - + @@ -72,7 +71,16 @@ - + + + + + + + + + + @@ -81,150 +89,134 @@ - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - + + + - - - + + + - + - + - + - + - + - - - + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + - - - - + + + + - - - - - + + + + + \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RedisClient.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RedisClientUtils.java similarity index 99% rename from ty-common/src/main/java/top/kuanghua/khcomomon/utils/RedisClient.java rename to ty-common/src/main/java/top/kuanghua/khcomomon/utils/RedisClientUtils.java index 19e3e86..841c22b 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RedisClient.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RedisClientUtils.java @@ -14,7 +14,7 @@ * Redis工具类 */ @Component -public class RedisClient { +public class RedisClientUtils { @Autowired private RedisTemplate redisTemplate; diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java b/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java index 9c668a7..5994fd9 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java @@ -1,5 +1,7 @@ package top.kuanghua.tyexample.config; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -16,6 +18,10 @@ @Configuration //扫描公用包的配置和自身的配置类 @ComponentScan(basePackages = {"top.kuanghua.khcomomon"}) +//mapper包扫描 +@MapperScan(basePackages = {"top.kuanghua.tyexample.mapper"}) +//feign扫描 +@EnableFeignClients(basePackages = {"top.kuanghua.feign.tyauth"}) public class BaseConfig { } diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java new file mode 100644 index 0000000..62d21d9 --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java @@ -0,0 +1,133 @@ +package top.kuanghua.tyexample.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.BoundHashOperations; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; +import top.kuanghua.khcomomon.utils.RedisClientUtils; +import top.kuanghua.tyexample.entity.ErrorCollection; +import top.kuanghua.tyexample.mapper.ErrorCollectionMapper; + +import javax.annotation.PostConstruct; +import javax.annotation.Resource; +import java.text.MessageFormat; +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * @Title: CacheAvalancheController + * @Description: + * @Auther: kuanghua + * @create 2022-01-09 16:48 + */ +@Api(tags = "缓存击穿和雪崩解决方案") +@RestController +@RequestMapping("redisCache") +public class RedisTestController { + + @Resource + private ErrorCollectionMapper errorCollectionMapper; + + @Autowired + private RedisTemplate redisTemplate; + + @Resource + private RedisClientUtils redisClient; + + + private Integer orderCount = 10; + private String redisCountKey = "orderCo"; + + + @PostConstruct + public void intParam() { + BoundHashOperations hashKey = redisTemplate.boundHashOps("hashKey"); + hashKey.increment(redisCountKey, orderCount); + } + + /* redis缓存击穿问题 + * 1. 当用户根据key 查询数据时,先查询缓存,如果缓存有命中,返回, + 2. 但是如果缓存没有命中直接穿过缓存层,访问数据层 如果有,则存储指缓存, + 3. 但是同样如果没有命中,(也就是数据库中也没有数据)直接返回用户,但是不缓存 + 这就是缓存的穿透。如果某一个key 请求量很大,但是存储层也没有数据,大量的请求都会达到存储层就会造成数据库压力巨大,有可能宕机的情况。 + + + 缓存雪崩 + 如果缓存集中在一段时间内失效,发生大量的缓存穿透,所有的查询都落在数据库上,造成了缓存雪崩。 + 这个没有完美解决办法,但可以分析用户行为,尽量让失效时间点均匀分布。 + + 限流 加锁排队 + + 在缓存失效后,通过对某一个key加锁或者是队列 来控制key的线程访问的数量。例如:某一个key 只允许一个线程进行 操作。 + + + 限流 + + 在缓存失效后,某一个key 做count统计限流,达到一定的阈值,直接丢弃,不再查询数据库。例如:令牌桶算法。等等。 + + + 数据预热 + + 在缓存失效应当尽量避免某一段时间,可以先进行数据预热,比如某些热门的商品。提前在上线之前,或者开放给用户使用之前,先进行loading 缓存中,这样用户使用的时候,直接从缓存中获取。要注意的是,要更加业务来进行过期时间的设置 ,尽量均匀。 + + + 做缓存降级(二级缓存策略) + + 当分布式缓存失效的时候,可以采用本地缓存,本地缓存没有再查询数据库。这种方式,可以避免很多数据分布式缓存没有,就直接打到数据库的情况。 + + * */ + + + @ApiOperation(value = "查询错误日志") + @GetMapping("queryErrorLogList") + public ResResult queryErrorLogList() { + + String key = "queryErrorLogList"; + /* + * 解决缓存穿透带来的问题 + * 1.查询值为空的时候也设置到redis的key上 + * 2.给空值的key设定过期时间(为了避免过多的KEY 存储在redis中) + * */ + if (redisTemplate.hasKey(key)) { + List redisList = redisTemplate.opsForList().range(key, 0, -1); + return new ResResult().success(redisList); + } else { + List ecList = errorCollectionMapper.selectList(null); + //无论ecList是否为空都设置到redis的key上,解决缓存穿透带来的雪崩问题 + //如果为空,一般情况下都需要设置一个过期时间,例如:5分钟失效。(为了避免过多的KEY 存储在redis中) + redisTemplate.opsForList().leftPushAll(key, ecList); + if (ObjectUtilsSelf.isEmpty(ecList)) { + //此处设置为20s,进行测试 + redisTemplate.expire(key, 20, TimeUnit.SECONDS); + } else { + //此处设置为20s,进行测试,不为空时可以不设置过期时间,根据业务需求进行设置 + redisTemplate.expire(key, 20, TimeUnit.SECONDS); + } + return new ResResult().success(ecList); + + } + } + + + @ApiOperation(value = "并发请求改接口测试redis锁") + @GetMapping("testRedisLock") + public void testRedisLock() throws InterruptedException { + //订单超卖问题 +// orderCount--; +// if (orderCount >= 0) { +// Thread.sleep(1000); +// System.out.println(MessageFormat.format("订单还剩{0}", orderCount)); +// } + + /*用redis锁*/ + BoundHashOperations hashKey = redisTemplate.boundHashOps("hashKey"); + Long decrement = hashKey.increment(redisCountKey, -1); + if (decrement >= 0) { + System.out.println(MessageFormat.format("redis订单还剩{0}", decrement)); + } + + } + +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/entity/ErrorCollection.java b/ty-example/src/main/java/top/kuanghua/tyexample/entity/ErrorCollection.java new file mode 100644 index 0000000..afe96e0 --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/entity/ErrorCollection.java @@ -0,0 +1,36 @@ +package top.kuanghua.tyexample.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * error_log_collection(ErrorCollection)表实体类 + * + * @author kuanghua + * @since 2021-10-08 11:37:25 + */ +@Data +@ApiModel("错误日志相关") +@TableName(value = "tb_error_collection") +public class ErrorCollection extends Model { + @ApiModelProperty(value = "id主键") + private Long id; + @ApiModelProperty(value = "错误日志") + private String errorLog; + @ApiModelProperty(value = "页面路径") + private String pageUrl; + @ApiModelProperty(value = "当前版本") + private String version; + @ApiModelProperty(value = "浏览器类型", hidden = true) + private String browserType; + @TableField(fill = FieldFill.INSERT) + @ApiModelProperty(value = "创建时间", hidden = true) + private Date createTime; +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/mapper/ErrorCollectionMapper.java b/ty-example/src/main/java/top/kuanghua/tyexample/mapper/ErrorCollectionMapper.java new file mode 100644 index 0000000..0e5413a --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/mapper/ErrorCollectionMapper.java @@ -0,0 +1,8 @@ +package top.kuanghua.tyexample.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.tyexample.entity.ErrorCollection; + +public interface ErrorCollectionMapper extends BaseMapper { + +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/SendEmailService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/SendEmailService.java index afcfba6..2dc1f96 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/service/SendEmailService.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/service/SendEmailService.java @@ -1,23 +1,20 @@ package top.kuanghua.tyexample.service; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.javamail.JavaMailSenderImpl; import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; -import org.springframework.util.ResourceUtils; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; +import javax.annotation.Resource; import javax.mail.MessagingException; import javax.mail.internet.MimeMessage; import java.io.File; import java.io.IOException; -import java.util.List; /** * @Title: SendEmailService @@ -28,7 +25,7 @@ @Service public class SendEmailService { - @Autowired + @Resource private JavaMailSenderImpl javaMailSender; @Value("${spring.mail.username}") @@ -66,7 +63,7 @@ public void sendEmailText(String subject, String text, String sendTo) { * @Date: 2020-08-20 */ @Async - public void sendMimeMail(String subject, String text, String sendTo,MultipartFile file) + public void sendMimeMail(String subject, String text, String sendTo, MultipartFile file) throws MessagingException, IOException { // String path = ResourceUtils.getURL("classpath:").getPath(); // System.out.println(path + file.getOriginalFilename()); diff --git a/ty-example/src/test/java/top/kuanghua/tyexample/service/CacheAvalancheServiceTest.java b/ty-example/src/test/java/top/kuanghua/tyexample/service/CacheAvalancheServiceTest.java new file mode 100644 index 0000000..4f3b9c6 --- /dev/null +++ b/ty-example/src/test/java/top/kuanghua/tyexample/service/CacheAvalancheServiceTest.java @@ -0,0 +1,32 @@ +package top.kuanghua.tyexample.service; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.test.context.junit4.SpringRunner; + +/** + * @Title: CacheAvalancheServiceTest + * @Description: + * @Auther: kuanghua + * @create 2022-01-09 16:35 + */ +@SpringBootTest +@RunWith(SpringRunner.class) +public class CacheAvalancheServiceTest { + + @Autowired + private RedisTemplate redisTemplate; + + @Test + public void test() throws InterruptedException { + redisTemplate.opsForValue().set("fai", "1"); + String fai = (String) redisTemplate.opsForValue().get("fai"); + System.out.println(fai); + //Thread.sleep(10000); + } + + +} \ No newline at end of file diff --git a/ty-example/ty-example.iml b/ty-example/ty-example.iml index 27a5064..24c4b6e 100644 --- a/ty-example/ty-example.iml +++ b/ty-example/ty-example.iml @@ -7,6 +7,10 @@ + + + + @@ -16,6 +20,8 @@ + + diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/service/UserService.java b/ty-user/src/main/java/top/kuanghua/tyuser/service/UserService.java index 3169080..df5a045 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/service/UserService.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/service/UserService.java @@ -2,18 +2,13 @@ import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import lombok.extern.java.Log; -import lombok.extern.log4j.Log4j; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.aspectj.weaver.ast.Var; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; -import org.springframework.web.bind.annotation.RequestHeader; -import springfox.documentation.annotations.ApiIgnore; import top.kuanghua.feign.tyauth.feign.TokenFeign; import top.kuanghua.feign.tyexecl.feign.ExcelFeign; import top.kuanghua.khcomomon.entity.ResResult; @@ -41,10 +36,10 @@ public class UserService { @Resource private UserMapper userMapper; - @Autowired + @Resource private ExcelFeign excelFeign; - @Autowired + @Resource private TokenFeign tokenFeign; @Autowired private StringRedisTemplate stringRedisTemplate; @@ -53,25 +48,25 @@ public void registry(User user, String code) throws Exception { QueryWrapper queryWrapper = new QueryWrapper() .select("phone") .eq("phone", user.getPhone()); - Boolean bl=this.userMapper.selectCount(queryWrapper)==1; - if(bl){ + Boolean bl = this.userMapper.selectCount(queryWrapper) == 1; + if (bl) { throw new Exception("手机号已存在"); } String codeStr = stringRedisTemplate.opsForValue().get("user:code:phone:" + user.getPhone()); - if(StringUtils.isEmpty(codeStr)){ + if (StringUtils.isEmpty(codeStr)) { throw new Exception("验证码失效,请重新获取"); } - if(!Objects.equals(codeStr,code)){ + if (!Objects.equals(codeStr, code)) { throw new Exception("验证码输入错误"); } String salt = CodecUtils.generateSalt(); user.setSalt(salt); - user.setPassword(CodecUtils.md5Hex(user.getPassword(),salt)); - boolean insertBl = this.userMapper.insert(user)==1; - if(insertBl){ + user.setPassword(CodecUtils.md5Hex(user.getPassword(), salt)); + boolean insertBl = this.userMapper.insert(user) == 1; + if (insertBl) { //删除redis中的code this.stringRedisTemplate.delete("user:code:phone:" + user.getPhone()); - }else{ + } else { throw new Exception("用户注册失败"); } } @@ -85,7 +80,7 @@ public Object insert(User user) { @Transactional(rollbackFor = Exception.class) public Object updateById(User user) { int updateById = this.userMapper.updateById(user); - int i=10/0; + int i = 10 / 0; return updateById; } @@ -98,34 +93,35 @@ public void loginOut() { /** * 用户注册 + * * @param code * @param username * @param password */ - public void userRegister(String email,String code,String username, String password){ + public void userRegister(String email, String code, String username, String password) { //user表中查询用户是否重复 QueryWrapper queryWrapper = new QueryWrapper() .eq("username", username); - if(this.userMapper.selectCount(queryWrapper)==1){ - throw new RuntimeException(MessageFormat.format("账号【{0}】已存在,请误重复注册", username)); + if (this.userMapper.selectCount(queryWrapper) == 1) { + throw new RuntimeException(MessageFormat.format("账号【{0}】已存在,请误重复注册", username)); } //去ty-execl中查询用户名是否存在 ResResult resResult = excelFeign.selectExcelByUser(username); List list = ObjectUtilsSelf.parseResToList(resResult); - if (list.size()==0) { - throw new RuntimeException(MessageFormat.format("考勤表中不存在用户名【{0}】", username)); + if (list.size() == 0) { + throw new RuntimeException(MessageFormat.format("考勤表中不存在用户名【{0}】", username)); } //校验验证码 String codeInfo = stringRedisTemplate.opsForValue().get("email.code.routing.name" + email); Map map = JSON.parseObject(codeInfo); - if(ObjectUtilsSelf.isEmpty(map)){ - throw new RuntimeException("验证码失效,请重新获取"); + if (ObjectUtilsSelf.isEmpty(map)) { + throw new RuntimeException("验证码失效,请重新获取"); } - if (!Objects.equals(map.get("code"),code)) { - throw new RuntimeException("验证码不正确"); + if (!Objects.equals(map.get("code"), code)) { + throw new RuntimeException("验证码不正确"); } //插入数据,用户添加成功 User userEt = new User(); @@ -135,58 +131,61 @@ public void userRegister(String email,String code,String username, String passwo //添加盐设置密码为md5 String salt = CodecUtils.generateSalt(); userEt.setSalt(salt); - userEt.setPassword(CodecUtils.md5Hex(userEt.getPassword(),salt)); + userEt.setPassword(CodecUtils.md5Hex(userEt.getPassword(), salt)); boolean inResult = userMapper.insert(userEt) == 1; - if(!inResult){ - throw new RuntimeException("插入失败"); + if (!inResult) { + throw new RuntimeException("插入失败"); } } + /** * 用户登录 + * * @param user * @return * @throws Exception */ public HashMap loginValid(User user) { QueryWrapper phoneQW = new QueryWrapper().like("email", user.getEmail()) - .or().eq("username",user.getUsername()); + .or().eq("username", user.getUsername()); User resUser = this.userMapper.selectOne(phoneQW); - if(ObjectUtils.isEmpty(resUser)){ + if (ObjectUtils.isEmpty(resUser)) { throw new RuntimeException("用户不存在"); } - if(!resUser.getPassword().equals(CodecUtils.md5Hex(user.getPassword(),resUser.getSalt()))){ + if (!resUser.getPassword().equals(CodecUtils.md5Hex(user.getPassword(), resUser.getSalt()))) { throw new RuntimeException("用户名或密码错误"); } //生成jwt token HashMap hm = new HashMap<>(); - hm.put("username",resUser.getUsername()); - hm.put("email",resUser.getEmail()); + hm.put("username", resUser.getUsername()); + hm.put("email", resUser.getEmail()); ResResult resResult = tokenFeign.generateToken(hm); - hm.put("jwtToken",resResult.getData()); - return hm; + hm.put("jwtToken", resResult.getData()); + return hm; } + /*修改用户密码*/ - public void changePassword(String username,String oldPassword,String newPassword) { + public void changePassword(String username, String oldPassword, String newPassword) { //校验oldPassword是否正确 QueryWrapper qw = new QueryWrapper() - .eq("username",username); + .eq("username", username); User resUser = this.userMapper.selectOne(qw); if (ObjectUtilsSelf.isEmpty(resUser)) { throw new RuntimeException("用户不存在"); } - if(!resUser.getPassword().equals(CodecUtils.md5Hex(oldPassword,resUser.getSalt()))){ + if (!resUser.getPassword().equals(CodecUtils.md5Hex(oldPassword, resUser.getSalt()))) { throw new RuntimeException("密码错误"); } //设置新的密码 String salt = CodecUtils.generateSalt(); resUser.setSalt(salt); - resUser.setPassword(CodecUtils.md5Hex(newPassword,salt)); - boolean insertBl = this.userMapper.updateById(resUser)==1; - if(!insertBl){ + resUser.setPassword(CodecUtils.md5Hex(newPassword, salt)); + boolean insertBl = this.userMapper.updateById(resUser) == 1; + if (!insertBl) { throw new RuntimeException("修改密码失败"); } } @@ -194,12 +193,13 @@ public void changePassword(String username,String oldPassword,String newPassword /** * 插入用户 + * * @param username 用户名 */ public void insertUser(String username) { //先查询当前用户是否存在不存在则导入 QueryWrapper qw = new QueryWrapper() - .eq("username",username); + .eq("username", username); User resUser = this.userMapper.selectOne(qw); if (ObjectUtilsSelf.isEmpty(resUser)) { @@ -209,7 +209,7 @@ public void insertUser(String username) { user.setUsername(username); String salt = CodecUtils.generateSalt(); user.setSalt(salt); - user.setPassword(CodecUtils.md5Hex(user.getPassword(),salt)); + user.setPassword(CodecUtils.md5Hex(user.getPassword(), salt)); userMapper.insert(user); } } @@ -218,13 +218,13 @@ public void insertUser(String username) { /** * 重置用用户名:如果用用户存在先删除原有用户在新增一个用户,没有则新建用户 */ - public void resetUser(String username){ + public void resetUser(String username) { QueryWrapper userWrap = new QueryWrapper().eq("username", username); List users = userMapper.selectList(userWrap); //用户存在,先删除用户 - if (users.size()==1) { + if (users.size() == 1) { userMapper.delete(userWrap); - }else{ + } else { //新增用户 this.insertUser(username); } diff --git a/ty-user/ty-user.iml b/ty-user/ty-user.iml index bb1bebe..0ccd583 100644 --- a/ty-user/ty-user.iml +++ b/ty-user/ty-user.iml @@ -22,7 +22,7 @@ - + @@ -34,47 +34,41 @@ - - - - - - - + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - - - + + + - + @@ -93,7 +87,16 @@ - + + + + + + + + + + @@ -102,145 +105,129 @@ - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + - - - - - - - - + + - - - + + + - + - + - + - + - - - - + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + - - - - + + + + - - - - - + + + + + \ No newline at end of file From b968ddfa19a011e1ef56d06736afabfa8aa37b83 Mon Sep 17 00:00:00 2001 From: jzfai <869653722@qq.com> Date: Mon, 10 Jan 2022 18:36:32 +0800 Subject: [PATCH 14/36] fix some isuue --- ty-example/pom.xml | 6 ++ .../tyexample/ExampleApplication.java | 3 +- .../kuanghua/tyexample/config/BaseConfig.java | 2 +- .../controller/RedisTestController.java | 2 - .../controller/SeataTestController.java | 34 +++++++++++ .../listener/CanalDataEventListener.java | 53 +++++++++++++++++ .../mapper/ErrorCollectionMapper.java | 1 + .../tyexample/service/SeataTestService.java | 26 ++++++++ ty-example/src/main/resources/application.yml | 59 +++++++++++++++++++ ty-example/ty-example.iml | 8 +++ .../top/kuanghua/tyuser/UserApplication.java | 5 +- ty-user/src/main/resources/application.yml | 25 +++++++- ty-user/src/main/resources/bootstrap.yml | 6 +- 13 files changed, 221 insertions(+), 9 deletions(-) create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/SeataTestController.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/listener/CanalDataEventListener.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java diff --git a/ty-example/pom.xml b/ty-example/pom.xml index 416031b..b040d7d 100644 --- a/ty-example/pom.xml +++ b/ty-example/pom.xml @@ -39,6 +39,12 @@ fastdfs-client 1.27.2 + + + com.xpand + starter-canal + 0.0.1-SNAPSHOT + diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java b/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java index 003fdb0..35ae229 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java @@ -8,8 +8,9 @@ @SpringBootApplication @EnableScheduling @EnableAsync +//@EnableAutoDataSourceProxy public class ExampleApplication { public static void main(String[] args) { - SpringApplication.run(ExampleApplication.class,args); + SpringApplication.run(ExampleApplication.class, args); } } diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java b/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java index 5994fd9..809d29d 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java @@ -21,7 +21,7 @@ //mapper包扫描 @MapperScan(basePackages = {"top.kuanghua.tyexample.mapper"}) //feign扫描 -@EnableFeignClients(basePackages = {"top.kuanghua.feign.tyauth"}) +@EnableFeignClients(basePackages = {"top.kuanghua.feign.tyuser"}) public class BaseConfig { } diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java index 62d21d9..69a2a70 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java @@ -79,11 +79,9 @@ public void intParam() { * */ - @ApiOperation(value = "查询错误日志") @GetMapping("queryErrorLogList") public ResResult queryErrorLogList() { - String key = "queryErrorLogList"; /* * 解决缓存穿透带来的问题 diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/SeataTestController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/SeataTestController.java new file mode 100644 index 0000000..f9444cd --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/controller/SeataTestController.java @@ -0,0 +1,34 @@ +package top.kuanghua.tyexample.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import top.kuanghua.tyexample.service.SeataTestService; + +/** + * @Title: SeataTestController + * @Description: + * @Auther: kuanghua + * @create 2022-01-10 15:05 + */ + +@Api(tags = "seata测试") +@RestController +@RequestMapping("seataTest") +public class SeataTestController { + @Autowired + private SeataTestService seataTestService; + + @ApiOperation(value = "测试seata回滚") + @GetMapping("test-seata-rollback") + public void testSeataRollback() { + try { + seataTestService.testSeataRollback(); + } catch (InterruptedException e) { + throw new RuntimeException("错误了"); + } + } +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/listener/CanalDataEventListener.java b/ty-example/src/main/java/top/kuanghua/tyexample/listener/CanalDataEventListener.java new file mode 100644 index 0000000..5e45cc6 --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/listener/CanalDataEventListener.java @@ -0,0 +1,53 @@ +package top.kuanghua.tyexample.listener; + +import com.alibaba.otter.canal.protocol.CanalEntry; +import com.xpand.starter.canal.annotation.*; + +/** + * @Title: CanalDataEventListener + * @Description: + * @Auther: kuanghua + * @create 2020/9/1 22:43 + */ +@CanalEventListener +public class CanalDataEventListener { + @InsertListenPoint + public void onEventInsert(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { + for (CanalEntry.Column column : rowData.getAfterColumnsList()) { + System.out.println("新增" + column.getName() + ":获取的数据" + column.getValue()); + } + } + + @UpdateListenPoint + public void onEventUpdate(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { + for (CanalEntry.Column column : rowData.getBeforeColumnsList()) { + System.out.println("修改前" + column.getName() + ":获取的数据" + column.getValue()); + } + for (CanalEntry.Column column : rowData.getAfterColumnsList()) { + System.out.println("修改后" + column.getName() + ":获取的数据" + column.getValue()); + } + } + + @DeleteListenPoint + public void onEventDelete(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { + for (CanalEntry.Column column : rowData.getBeforeColumnsList()) { + System.out.println("删除前" + column.getName() + ":获取的数据" + column.getValue()); + } + } + + //自定义监听 + @ListenPoint( + eventType = {CanalEntry.EventType.DELETE, CanalEntry.EventType.UPDATE}, //监听类型 + schema = {"changgou_content"}, + table = {"tb_content"}, //指定监控的表 + destination = "example" //指定实例的地址 + ) + public void onEventCustomUpdate(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { + for (CanalEntry.Column column : rowData.getBeforeColumnsList()) { + System.out.println("自定义前" + column.getName() + ":获取的数据" + column.getValue()); + } + for (CanalEntry.Column column : rowData.getAfterColumnsList()) { + System.out.println("自定义后" + column.getName() + ":获取的数据" + column.getValue()); + } + } +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/mapper/ErrorCollectionMapper.java b/ty-example/src/main/java/top/kuanghua/tyexample/mapper/ErrorCollectionMapper.java index 0e5413a..49b5aba 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/mapper/ErrorCollectionMapper.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/mapper/ErrorCollectionMapper.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import top.kuanghua.tyexample.entity.ErrorCollection; + public interface ErrorCollectionMapper extends BaseMapper { } diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java new file mode 100644 index 0000000..192ff88 --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java @@ -0,0 +1,26 @@ +package top.kuanghua.tyexample.service; + +import org.springframework.stereotype.Service; +import top.kuanghua.feign.tyuser.feign.UserFeign; + +import javax.annotation.Resource; + +/** + * @Title: SeataTestService + * @Description: + * @Auther: kuanghua + * @create 2022-01-10 15:09 + */ +@Service +public class SeataTestService { + + @Resource + private UserFeign userFeign; + + + public void testSeataRollback() throws InterruptedException { + userFeign.insertUser("jzfai"); + Thread.sleep(2000); + int fai = 1 / 0; + } +} diff --git a/ty-example/src/main/resources/application.yml b/ty-example/src/main/resources/application.yml index e69de29..bf57b5a 100644 --- a/ty-example/src/main/resources/application.yml +++ b/ty-example/src/main/resources/application.yml @@ -0,0 +1,59 @@ +#msg config, place change to you sms config +kuanghua: + sms: + accessKeyId: LTAI4FrD2voTK2wTgRCPwT6d + accessKeySecret: Zj07thnb2jiBkl4wtqgvPeuSzkJRJ3 + signName: 品优商城 # 签名名称 + verifyCodeTemplate: SMS_189216068 # 模板名称 + + + +#email config, place change to you email +spring: + mail: + username: 869653722@qq.com + password: xbthzedhnxatbcab + host: smtp.qq.com + properties: + mail.smtp.starttls.enable: true + + + +server: + port: ${envpt.tomcatPortPre}0121 + + +#seata +seata: + enabled: true + enable-auto-data-source-proxy: false + application-id: product-server + #需要和nacos中配置保持一致config.txt service.vgroupMapping.product-server-group=default + tx-service-group: product-server-group + config: + type: nacos + nacos: + #需要和server在同一个注册中心下 + serverAddr: 8.135.1.141:8848 + #需要server端(registry和config)、nacos配置client端(registry和config)保持一致 + group: SEATA_GROUP + userName: "jzfai" + password: "123456" + registry: + type: nacos + nacos: + #需要和server端保持一致,即server在nacos中的名称,默认为seata-server + application: seata-server + server-addr: 8.135.1.141:8848 + #需要server端(registry和config)、nacos配置client端(registry和config)保持一致 + group: SEATA_GROUP + userName: "jzfai" + + +#canal配置 +canal: + client: + instances: + example: + host: 8.135.1.141 + port: 11111 diff --git a/ty-example/ty-example.iml b/ty-example/ty-example.iml index 24c4b6e..aa31c78 100644 --- a/ty-example/ty-example.iml +++ b/ty-example/ty-example.iml @@ -216,6 +216,14 @@ + + + + + + + + diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/UserApplication.java b/ty-user/src/main/java/top/kuanghua/tyuser/UserApplication.java index afcf358..e61174e 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/UserApplication.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/UserApplication.java @@ -11,8 +11,9 @@ * @create 2020/11/7 20:07 */ @SpringBootApplication +@EnableAutoDataSourceProxy //开启seata事务管理 public class UserApplication { public static void main(String[] args) { - SpringApplication.run(UserApplication.class,args); + SpringApplication.run(UserApplication.class, args); } -} \ No newline at end of file +} diff --git a/ty-user/src/main/resources/application.yml b/ty-user/src/main/resources/application.yml index 3744044..340c3c1 100644 --- a/ty-user/src/main/resources/application.yml +++ b/ty-user/src/main/resources/application.yml @@ -1,2 +1,23 @@ -server: - port: ${envpt.tomcatPortPre}0106 +seata: + enabled: true + enable-auto-data-source-proxy: true + application-id: product-server + #需要和nacos中配置保持一致config.txt service.vgroupMapping.product-server-group=default + tx-service-group: product-server-group + config: + type: nacos + nacos: + #需要和server在同一个注册中心下 + serverAddr: 8.135.1.141:8848 + #需要server端(registry和config)、nacos配置client端(registry和config)保持一致 + group: SEATA_GROUP + userName: "jzfai" + password: "123456" + registry: + type: nacos + nacos: + #需要和server端保持一致,即server在nacos中的名称,默认为seata-server + application: seata-server + server-addr: 8.135.1.141:8848 + #需要server端(registry和config)、nacos配置client端(registry和config)保持一致 + group: SEATA_GROUP \ No newline at end of file diff --git a/ty-user/src/main/resources/bootstrap.yml b/ty-user/src/main/resources/bootstrap.yml index 3a75337..5968baf 100644 --- a/ty-user/src/main/resources/bootstrap.yml +++ b/ty-user/src/main/resources/bootstrap.yml @@ -38,4 +38,8 @@ spring: username: @nacosUsername@ password: @nacosPassword@ server-addr: @nacosIpPort@ - weight: @nacosWeight@ \ No newline at end of file + weight: @nacosWeight@ + + +server: + port: ${envpt.tomcatPortPre}0106 \ No newline at end of file From 7b0e5d2c907b2c6fb52282da650a3c5e824994a2 Mon Sep 17 00:00:00 2001 From: kuanghua <869653722@qq.com> Date: Mon, 10 Jan 2022 21:00:35 +0800 Subject: [PATCH 15/36] add seata use demo --- micro-service-plus.iml | 57 ---- pom.xml | 2 +- ty-auth/pom.xml | 5 - ty-auth/ty-auth.iml | 222 --------------- ty-common/pom.xml | 1 - ty-common/src/main/main3.iml | 11 - ty-common/ty-common.iml | 220 --------------- ty-example/pom.xml | 5 - .../tyexample/ExampleApplication.java | 5 +- .../controller/SeataTestController.java | 6 +- .../tyexample/service/SeataTestService.java | 8 +- ty-example/src/main/main12.iml | 13 - ty-example/src/main/resources/application.yml | 26 -- ty-example/src/main/resources/bootstrap.yml | 4 + ty-example/ty-example.iml | 253 ------------------ ty-excel/ty-excel.iml | 238 ---------------- ty-gateway/ty-gateway-one/ty-gateway-one.iml | 235 ---------------- ty-gateway/ty-gateway.iml | 223 --------------- ty-upload/ty-upload.iml | 230 ---------------- .../top/kuanghua/tyuser/UserApplication.java | 2 +- ty-user/src/main/main4.iml | 13 - ty-user/src/main/resources/application.yml | 23 -- ty-user/src/main/resources/bootstrap.yml | 5 + ty-user/ty-user.iml | 233 ---------------- 24 files changed, 20 insertions(+), 2020 deletions(-) delete mode 100644 micro-service-plus.iml delete mode 100644 ty-auth/ty-auth.iml delete mode 100644 ty-common/src/main/main3.iml delete mode 100644 ty-common/ty-common.iml delete mode 100644 ty-example/src/main/main12.iml delete mode 100644 ty-example/ty-example.iml delete mode 100644 ty-excel/ty-excel.iml delete mode 100644 ty-gateway/ty-gateway-one/ty-gateway-one.iml delete mode 100644 ty-gateway/ty-gateway.iml delete mode 100644 ty-upload/ty-upload.iml delete mode 100644 ty-user/src/main/main4.iml delete mode 100644 ty-user/ty-user.iml diff --git a/micro-service-plus.iml b/micro-service-plus.iml deleted file mode 100644 index 7f10b3d..0000000 --- a/micro-service-plus.iml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/pom.xml b/pom.xml index 8872073..5166516 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ com.alibaba fastjson - 1.2.51 + 1.2.79 diff --git a/ty-auth/pom.xml b/ty-auth/pom.xml index 21837ec..c04f8eb 100644 --- a/ty-auth/pom.xml +++ b/ty-auth/pom.xml @@ -17,11 +17,6 @@ ty-common 1.0-SNAPSHOT - - top.kuanghua - user-api - 1.0-SNAPSHOT - diff --git a/ty-auth/ty-auth.iml b/ty-auth/ty-auth.iml deleted file mode 100644 index 9447a05..0000000 --- a/ty-auth/ty-auth.iml +++ /dev/null @@ -1,222 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ty-common/pom.xml b/ty-common/pom.xml index 27b5bbe..1a35ee8 100644 --- a/ty-common/pom.xml +++ b/ty-common/pom.xml @@ -123,7 +123,6 @@ spring-boot-devtools - com.alibaba.cloud spring-cloud-starter-alibaba-seata diff --git a/ty-common/src/main/main3.iml b/ty-common/src/main/main3.iml deleted file mode 100644 index 908ad4f..0000000 --- a/ty-common/src/main/main3.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/ty-common/ty-common.iml b/ty-common/ty-common.iml deleted file mode 100644 index 3ffe7b5..0000000 --- a/ty-common/ty-common.iml +++ /dev/null @@ -1,220 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ty-example/pom.xml b/ty-example/pom.xml index b040d7d..bc88a27 100644 --- a/ty-example/pom.xml +++ b/ty-example/pom.xml @@ -16,11 +16,6 @@ ty-common 1.0-SNAPSHOT - - top.kuanghua - user-api - 1.0-SNAPSHOT - com.aliyun diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java b/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java index 35ae229..eb9767a 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java @@ -1,5 +1,7 @@ package top.kuanghua.tyexample; +import com.xpand.starter.canal.annotation.EnableCanalClient; +import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.scheduling.annotation.EnableAsync; @@ -8,7 +10,8 @@ @SpringBootApplication @EnableScheduling @EnableAsync -//@EnableAutoDataSourceProxy +//@EnableCanalClient +@EnableAutoDataSourceProxy public class ExampleApplication { public static void main(String[] args) { SpringApplication.run(ExampleApplication.class, args); diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/SeataTestController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/SeataTestController.java index f9444cd..006e993 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/SeataTestController.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/controller/SeataTestController.java @@ -25,10 +25,6 @@ public class SeataTestController { @ApiOperation(value = "测试seata回滚") @GetMapping("test-seata-rollback") public void testSeataRollback() { - try { - seataTestService.testSeataRollback(); - } catch (InterruptedException e) { - throw new RuntimeException("错误了"); - } + seataTestService.testSeataRollback(); } } diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java index 192ff88..3b733e7 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java @@ -1,6 +1,7 @@ package top.kuanghua.tyexample.service; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import top.kuanghua.feign.tyuser.feign.UserFeign; import javax.annotation.Resource; @@ -17,10 +18,9 @@ public class SeataTestService { @Resource private UserFeign userFeign; - - public void testSeataRollback() throws InterruptedException { + @Transactional(rollbackFor = Exception.class) + public void testSeataRollback(){ userFeign.insertUser("jzfai"); - Thread.sleep(2000); - int fai = 1 / 0; + int i=10/0; } } diff --git a/ty-example/src/main/main12.iml b/ty-example/src/main/main12.iml deleted file mode 100644 index f608aea..0000000 --- a/ty-example/src/main/main12.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/ty-example/src/main/resources/application.yml b/ty-example/src/main/resources/application.yml index bf57b5a..5d95712 100644 --- a/ty-example/src/main/resources/application.yml +++ b/ty-example/src/main/resources/application.yml @@ -23,32 +23,6 @@ server: port: ${envpt.tomcatPortPre}0121 -#seata -seata: - enabled: true - enable-auto-data-source-proxy: false - application-id: product-server - #需要和nacos中配置保持一致config.txt service.vgroupMapping.product-server-group=default - tx-service-group: product-server-group - config: - type: nacos - nacos: - #需要和server在同一个注册中心下 - serverAddr: 8.135.1.141:8848 - #需要server端(registry和config)、nacos配置client端(registry和config)保持一致 - group: SEATA_GROUP - userName: "jzfai" - password: "123456" - registry: - type: nacos - nacos: - #需要和server端保持一致,即server在nacos中的名称,默认为seata-server - application: seata-server - server-addr: 8.135.1.141:8848 - #需要server端(registry和config)、nacos配置client端(registry和config)保持一致 - group: SEATA_GROUP - userName: "jzfai" - #canal配置 canal: diff --git a/ty-example/src/main/resources/bootstrap.yml b/ty-example/src/main/resources/bootstrap.yml index 76ddd5d..883a2b2 100644 --- a/ty-example/src/main/resources/bootstrap.yml +++ b/ty-example/src/main/resources/bootstrap.yml @@ -36,6 +36,10 @@ spring: - data-id: application-upload.yml group: @nacosGroup@ refresh: true + #get seata config need after db config + - data-id: application-seata.yml + group: @nacosGroup@ + refresh: true discovery: namespace: @nacosNamespace@ group: @nacosGroup@ diff --git a/ty-example/ty-example.iml b/ty-example/ty-example.iml deleted file mode 100644 index aa31c78..0000000 --- a/ty-example/ty-example.iml +++ /dev/null @@ -1,253 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ty-excel/ty-excel.iml b/ty-excel/ty-excel.iml deleted file mode 100644 index ac0db2e..0000000 --- a/ty-excel/ty-excel.iml +++ /dev/null @@ -1,238 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/ty-gateway-one.iml b/ty-gateway/ty-gateway-one/ty-gateway-one.iml deleted file mode 100644 index 2e4a4dc..0000000 --- a/ty-gateway/ty-gateway-one/ty-gateway-one.iml +++ /dev/null @@ -1,235 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ty-gateway/ty-gateway.iml b/ty-gateway/ty-gateway.iml deleted file mode 100644 index e5e33c2..0000000 --- a/ty-gateway/ty-gateway.iml +++ /dev/null @@ -1,223 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ty-upload/ty-upload.iml b/ty-upload/ty-upload.iml deleted file mode 100644 index 39cc125..0000000 --- a/ty-upload/ty-upload.iml +++ /dev/null @@ -1,230 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/UserApplication.java b/ty-user/src/main/java/top/kuanghua/tyuser/UserApplication.java index e61174e..836265c 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/UserApplication.java +++ b/ty-user/src/main/java/top/kuanghua/tyuser/UserApplication.java @@ -11,7 +11,7 @@ * @create 2020/11/7 20:07 */ @SpringBootApplication -@EnableAutoDataSourceProxy //开启seata事务管理 +@EnableAutoDataSourceProxy public class UserApplication { public static void main(String[] args) { SpringApplication.run(UserApplication.class, args); diff --git a/ty-user/src/main/main4.iml b/ty-user/src/main/main4.iml deleted file mode 100644 index f608aea..0000000 --- a/ty-user/src/main/main4.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/ty-user/src/main/resources/application.yml b/ty-user/src/main/resources/application.yml index 340c3c1..e69de29 100644 --- a/ty-user/src/main/resources/application.yml +++ b/ty-user/src/main/resources/application.yml @@ -1,23 +0,0 @@ -seata: - enabled: true - enable-auto-data-source-proxy: true - application-id: product-server - #需要和nacos中配置保持一致config.txt service.vgroupMapping.product-server-group=default - tx-service-group: product-server-group - config: - type: nacos - nacos: - #需要和server在同一个注册中心下 - serverAddr: 8.135.1.141:8848 - #需要server端(registry和config)、nacos配置client端(registry和config)保持一致 - group: SEATA_GROUP - userName: "jzfai" - password: "123456" - registry: - type: nacos - nacos: - #需要和server端保持一致,即server在nacos中的名称,默认为seata-server - application: seata-server - server-addr: 8.135.1.141:8848 - #需要server端(registry和config)、nacos配置client端(registry和config)保持一致 - group: SEATA_GROUP \ No newline at end of file diff --git a/ty-user/src/main/resources/bootstrap.yml b/ty-user/src/main/resources/bootstrap.yml index 5968baf..98d883d 100644 --- a/ty-user/src/main/resources/bootstrap.yml +++ b/ty-user/src/main/resources/bootstrap.yml @@ -32,6 +32,10 @@ spring: - data-id: application-db.yml group: @nacosGroup@ refresh: true + #get seata config need after db config + - data-id: application-seata.yml + group: @nacosGroup@ + refresh: true discovery: namespace: @nacosNamespace@ group: @nacosGroup@ @@ -41,5 +45,6 @@ spring: weight: @nacosWeight@ + server: port: ${envpt.tomcatPortPre}0106 \ No newline at end of file diff --git a/ty-user/ty-user.iml b/ty-user/ty-user.iml deleted file mode 100644 index 0ccd583..0000000 --- a/ty-user/ty-user.iml +++ /dev/null @@ -1,233 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From ef05adc8399a61a50b57eaef79a282ee8082b2ea Mon Sep 17 00:00:00 2001 From: jzfai <869653722@qq.com> Date: Tue, 11 Jan 2022 16:10:31 +0800 Subject: [PATCH 16/36] add seata canal email send msg demo update fastJson version --- README-zh_CN.md | 2 +- README.md | 7 +- {ty-user => integration-front}/pom.xml | 2 +- .../IntegrationFrontApplication.java | 38 +- .../integrationfront}/config/BaseConfig.java | 54 +-- .../config/Swagger2Config.java | 112 ++--- .../controller/BrandController.java | 254 +++++----- .../controller/ErrorCollectionController.java | 246 +++++----- .../controller/UserController.java | 404 ++++++++------- .../controller/VciController.java | 341 +++++++------ .../integrationfront}/entity/Access.java | 90 ++-- .../integrationfront}/entity/Admin.java | 98 ++-- .../integrationfront}/entity/Brand.java | 100 ++-- .../entity/ErrorCollection.java | 72 ++- .../integrationfront}/entity/Role.java | 82 ++-- .../integrationfront}/entity/RoleAccess.java | 92 ++-- .../integrationfront}/entity/User.java | 130 ++--- .../integrationfront}/entity/UserRole.java | 90 ++-- .../integrationfront}/entity/Vci.java | 102 ++-- .../excel/cv/VciStatusImpCv.java | 68 +-- .../integrationfront}/excel/cv/VciTimeCv.java | 54 +-- .../excel/imp/VciExcelImp.java | 80 +-- .../mapper/AccessMapper.java | 26 +- .../integrationfront}/mapper/AdminMapper.java | 42 +- .../integrationfront}/mapper/BrandMapper.java | 16 +- .../mapper/ErrorCollectionMapper.java | 16 +- .../mapper/MultiPageMapper.java | 32 +- .../mapper/RoleAccessMapper.java | 26 +- .../integrationfront}/mapper/RoleMapper.java | 26 +- .../integrationfront}/mapper/UserMapper.java | 28 +- .../mapper/UserRoleMapper.java | 26 +- .../integrationfront}/mapper/VciMapper.java | 16 +- .../service/AccessService.java | 96 ++-- .../service/AdminService.java | 82 ++-- .../service/BrandService.java | 102 ++-- .../service/ErrorCollectionService.java | 102 ++-- .../service/RoleAccessService.java | 72 +-- .../service/RoleService.java | 72 +-- .../service/UserRoleService.java | 72 +-- .../service/UserService.java | 458 +++++++++--------- .../integrationfront}/service/VciService.java | 266 +++++----- .../vo/ExcelCheckResult.java | 58 +-- .../kuanghua/integrationfront}/vo/UserVo.java | 72 +-- .../src/main/resources/application.yml | 0 .../src/main/resources/bootstrap.yml | 0 .../src/main/resources/mapper/AdminMapper.xml | 220 ++++----- pom.xml | 31 +- .../tyauth/config/Swagger2Config.java | 2 +- ty-common/pom.xml | 2 +- .../controller/HstrixController.java | 5 +- .../feign/UserFeign.java | 32 +- .../feign/tyexecl/feign/ExcelFeign.java | 22 - .../tyexample/ExampleApplication.java | 2 +- .../kuanghua/tyexample/config/BaseConfig.java | 6 +- .../tyexample/config/Swagger2Config.java | 2 +- .../listener/CanalDataEventListener.java | 52 +- .../tyexample/service/SeataTestService.java | 6 +- .../tyexample/service/UploadService.java | 22 +- ty-example/src/main/resources/application.yml | 33 -- .../tyexcel/service/ExcelService.java | 2 - .../SpecialHystrixGatewayFilterFactory.java | 2 +- .../src/main/resources/application.yml | 55 ++- 62 files changed, 2325 insertions(+), 2395 deletions(-) rename {ty-user => integration-front}/pom.xml (97%) rename ty-user/src/main/java/top/kuanghua/tyuser/UserApplication.java => integration-front/src/main/java/top/kuanghua/integrationfront/IntegrationFrontApplication.java (72%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/config/BaseConfig.java (67%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/config/Swagger2Config.java (95%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/controller/BrandController.java (94%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/controller/ErrorCollectionController.java (94%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/controller/UserController.java (89%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/controller/VciController.java (93%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/entity/Access.java (93%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/entity/Admin.java (93%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/entity/Brand.java (94%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/entity/ErrorCollection.java (91%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/entity/Role.java (93%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/entity/RoleAccess.java (94%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/entity/User.java (95%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/entity/UserRole.java (93%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/entity/Vci.java (94%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/excel/cv/VciStatusImpCv.java (94%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/excel/cv/VciTimeCv.java (94%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/excel/imp/VciExcelImp.java (84%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/mapper/AccessMapper.java (69%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/mapper/AdminMapper.java (84%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/mapper/BrandMapper.java (54%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/mapper/ErrorCollectionMapper.java (56%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/mapper/MultiPageMapper.java (88%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/mapper/RoleAccessMapper.java (70%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/mapper/RoleMapper.java (69%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/mapper/UserMapper.java (72%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/mapper/UserRoleMapper.java (70%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/mapper/VciMapper.java (54%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/service/AccessService.java (90%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/service/AdminService.java (83%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/service/BrandService.java (87%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/service/ErrorCollectionService.java (88%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/service/RoleAccessService.java (84%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/service/RoleService.java (83%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/service/UserRoleService.java (84%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/service/UserService.java (70%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/service/VciService.java (91%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/vo/ExcelCheckResult.java (91%) rename {ty-user/src/main/java/top/kuanghua/tyuser => integration-front/src/main/java/top/kuanghua/integrationfront}/vo/UserVo.java (89%) rename {ty-user => integration-front}/src/main/resources/application.yml (100%) rename {ty-user => integration-front}/src/main/resources/bootstrap.yml (100%) rename {ty-user => integration-front}/src/main/resources/mapper/AdminMapper.xml (91%) rename {ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo => ty-common/src/main/java/top/kuanghua}/controller/HstrixController.java (83%) rename ty-common/src/main/java/top/kuanghua/feign/{tyuser => integrationfront}/feign/UserFeign.java (72%) delete mode 100644 ty-common/src/main/java/top/kuanghua/feign/tyexecl/feign/ExcelFeign.java diff --git a/README-zh_CN.md b/README-zh_CN.md index 19d331a..f198909 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -50,7 +50,7 @@ ty-common: 统一依赖,统一配置管理,feign接口整合等 本架构的微服务有: ty-gateway:网关微服务。使用的是spring-cloud-starter-gateway,先对于zull网关来说性能更好。主要实现了,权限控制和拦截,jwt token解析和校验,swagger文件整合,使用令牌技术请求限流等 ty-auth:权限服务。jwt token生成,解析,校验等,默认配置3天有效期,少于一天自动续约(此处感兴趣的可以查看下源码) -ty-user:用户服务。用户的登录,注册,查看用户信息等一系列功能 +integration-front:用户服务。用户的登录,注册,查看用户信息等一系列功能 ty-excel:excel文件的读取和导出 ty-upload:文件上传服务。使用的技术为fastDFS技术,此服务主要用于文件的上传和下载 ``` diff --git a/README.md b/README.md index 2c5c8cc..1eae783 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ mybatis-plus: 3.3.2 rabbitmq:3.7-management redis: 3.2.9 mysql:5.7 +seata:1.4.2 +cancel ``` @@ -51,9 +53,8 @@ ty-common: 统一依赖,统一配置管理,feign接口整合等 本架构的微服务有: ty-gateway:网关微服务。使用的是spring-cloud-starter-gateway,先对于zull网关来说性能更好。主要实现了,权限控制和拦截,jwt token解析和校验,swagger文件整合,使用令牌技术请求限流等 ty-auth:权限服务。jwt token生成,解析,校验等,默认配置3天有效期,少于一天自动续约(此处感兴趣的可以查看下源码) -ty-user:用户服务。用户的登录,注册,查看用户信息等一系列功能 -ty-excel:excel文件的读取和导出 -ty-upload:文件上传服务。使用的技术为fastDFS技术,此服务主要用于文件的上传和下载 +integration-front:前端实例数据。用户的登录,注册,查看用户信息等一系列功能 +ty-example:全分布式事务seata,rabbitmq延时队列,短信发送,email发送,canal等功能实例 ``` diff --git a/ty-user/pom.xml b/integration-front/pom.xml similarity index 97% rename from ty-user/pom.xml rename to integration-front/pom.xml index cb45de4..8fea0ed 100644 --- a/ty-user/pom.xml +++ b/integration-front/pom.xml @@ -9,7 +9,7 @@ 4.0.0 - ty-user + integration-front diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/UserApplication.java b/integration-front/src/main/java/top/kuanghua/integrationfront/IntegrationFrontApplication.java similarity index 72% rename from ty-user/src/main/java/top/kuanghua/tyuser/UserApplication.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/IntegrationFrontApplication.java index 836265c..ac8b53d 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/UserApplication.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/IntegrationFrontApplication.java @@ -1,19 +1,19 @@ -package top.kuanghua.tyuser; - -import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * @Title: UserApplication - * @Description: - * @Auther: kuanghua - * @create 2020/11/7 20:07 - */ -@SpringBootApplication -@EnableAutoDataSourceProxy -public class UserApplication { - public static void main(String[] args) { - SpringApplication.run(UserApplication.class, args); - } -} +package top.kuanghua.integrationfront; + +import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @Title: UserApplication + * @Description: + * @Auther: kuanghua + * @create 2020/11/7 20:07 + */ +@SpringBootApplication +@EnableAutoDataSourceProxy +public class IntegrationFrontApplication { + public static void main(String[] args) { + SpringApplication.run(IntegrationFrontApplication.class, args); + } +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/config/BaseConfig.java b/integration-front/src/main/java/top/kuanghua/integrationfront/config/BaseConfig.java similarity index 67% rename from ty-user/src/main/java/top/kuanghua/tyuser/config/BaseConfig.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/config/BaseConfig.java index b9b4cf5..6d960e2 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/config/BaseConfig.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/config/BaseConfig.java @@ -1,27 +1,27 @@ -package top.kuanghua.tyuser.config; - -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * @Title: BaseConfig - * @Description: - * @Auther: kuanghua - * @create 2020/8/23 21:52 - */ -/* - * 总结:1.@Configuration 下的@ComponentScan回将包下带有@Component扫描变成配置类, - * 而@SpringBootApplication扫描的只会变成普通类 - * */ -@Configuration -//扫描公用包的配置和自身的配置类 -@ComponentScan(basePackages = {"top.kuanghua.khcomomon","top.kuanghua.tyuser"}) -//feign扫描 -@EnableFeignClients(basePackages = {"top.kuanghua.feign.tyexecl","top.kuanghua.feign.tyauth"}) -//mapper包扫描 -@MapperScan(basePackages = {"top.kuanghua.tyuser.mapper"}) -public class BaseConfig { - -} +package top.kuanghua.integrationfront.config; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +/** + * @Title: BaseConfig + * @Description: + * @Auther: kuanghua + * @create 2020/8/23 21:52 + */ +/* + * 总结:1.@Configuration 下的@ComponentScan回将包下带有@Component扫描变成配置类, + * 而@SpringBootApplication扫描的只会变成普通类 + * */ +@Configuration +//扫描公用包的配置和自身的配置类 +@ComponentScan(basePackages = {"top.kuanghua.khcomomon", "top.kuanghua.integrationfront"}) +//feign扫描 +@EnableFeignClients(basePackages = {"top.kuanghua.feign.tyauth"}) +//mapper包扫描 +@MapperScan(basePackages = {"top.kuanghua.integrationfront.mapper"}) +public class BaseConfig { + +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/config/Swagger2Config.java b/integration-front/src/main/java/top/kuanghua/integrationfront/config/Swagger2Config.java similarity index 95% rename from ty-user/src/main/java/top/kuanghua/tyuser/config/Swagger2Config.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/config/Swagger2Config.java index 934deb1..0f38531 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/config/Swagger2Config.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/config/Swagger2Config.java @@ -1,56 +1,56 @@ -package top.kuanghua.tyuser.config; - -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Component -@EnableSwagger2 //开启在线接口文档 -//配置包扫描 -public class Swagger2Config { - private boolean swagger_is_enable = true; -// @Value("${.ipAddr}") -// private String ipAddr; - @Value("${server.port}") - private String port; - - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .enable(swagger_is_enable) - //.host(this.ipAddr + ":" + this.port) - .apiInfo(apiInfo()) - .select() - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) - //.apis(basePackage("top.kuanghua.swagger.controller")) - .paths(PathSelectors.any()) - .build(); - } - - /** - * 构建 api文档的详细信息函数 - * - * @return - */ - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("标题:swagger文档") - .description("描述:新一代的微服务架构") - .contact(new Contact("jzfai", null, "869653722@qq.com")) - .version("版本号:2.8") - .build(); - } - - /** - * http://localhost:8080/swagger-ui.html - */ -} +package top.kuanghua.integrationfront.config; + +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@Component +@EnableSwagger2 //开启在线接口文档 +//配置包扫描 +public class Swagger2Config { + private boolean swagger_is_enable = true; +// @Value("${.ipAddr}") +// private String ipAddr; + @Value("${server.port}") + private String port; + + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .enable(swagger_is_enable) + //.host(this.ipAddr + ":" + this.port) + .apiInfo(apiInfo()) + .select() + .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) + //.apis(basePackage("top.kuanghua.swagger.controller")) + .paths(PathSelectors.any()) + .build(); + } + + /** + * 构建 api文档的详细信息函数 + * + * @return + */ + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("标题:swagger文档") + .description("描述:新一代的微服务架构") + .contact(new Contact("jzfai", null, "869653722@qq.com")) + .version("版本号:2.8") + .build(); + } + + /** + * http://localhost:8080/swagger-ui.html + */ +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/controller/BrandController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/BrandController.java similarity index 94% rename from ty-user/src/main/java/top/kuanghua/tyuser/controller/BrandController.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/controller/BrandController.java index c171fa4..1a43e45 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/controller/BrandController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/BrandController.java @@ -1,127 +1,127 @@ -package top.kuanghua.tyuser.controller; - - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.apache.commons.lang3.StringUtils; -import org.springframework.web.bind.annotation.*; -import top.kuanghua.khcomomon.entity.KHCommonParams; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.tyuser.entity.Brand; -import top.kuanghua.tyuser.service.BrandService; - -import javax.annotation.Resource; -import java.util.List; - -@Api(tags = "品牌表(Brand)") -@RestController -@RequestMapping("brand") -public class BrandController { - - @Resource - private BrandService brandService; - - /** - * 分页查询所有数据 - * - * @param brand 查询实体 - * @return 所有数据 - */ - @GetMapping("selectPage") - @ApiOperation(value = "分页查询所有数据") - public ResResult selectPage(Brand brand, KHCommonParams commonParams) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - if (ObjectUtils.isNotEmpty(brand.getId())) { - queryWrapper.like("id", brand.getId()); - } - if (ObjectUtils.isNotEmpty(brand.getName())) { - queryWrapper.like("name", brand.getName()); - } - if (ObjectUtils.isNotEmpty(brand.getImage())) { - queryWrapper.like("image", brand.getImage()); - } - - if (ObjectUtils.isNotEmpty(brand.getLetter())) { - queryWrapper.like("letter", brand.getLetter()); - } - if (ObjectUtils.isNotEmpty(brand.getSeq())) { - queryWrapper.like("seq", brand.getSeq()); - } - queryWrapper.orderByDesc("create_time"); - if (StringUtils.isNotEmpty(commonParams.getStartTime())) { - queryWrapper.between("create_time", commonParams.getStartTime(), commonParams.getEndTime()); - } - queryWrapper.select("id,name,image,letter,seq,create_time,update_time"); - Page brandPage = this.brandService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); - return new ResResult().success(brandPage); - } - - /** - * 通过主键查询单条数据 - * - * @param id 主键 - * @return 单条数据 - */ - @GetMapping("selectById") - @ApiOperation(value = "通过id主键查询单条数据") - public ResResult selectById(@RequestParam("id") Integer id) { - return new ResResult().success(this.brandService.selectById(id)); - } - - /** - * @Description: 根据id数组查询品牌列表 - * @Param: idList id数组 - * @return: ids列表数据 - */ - @ApiOperation(value = "根据id数组查询品牌列表") - @PostMapping("selectBatchIds") - public ResResult selectBatchIds(@RequestParam("idList") List idList) { - return new ResResult().success(this.brandService.selectBatchIds(idList)); - } - - - /** - * 新增数据 - * - * @param brand 实体对象 - * @return 新增结果 - */ - @ApiOperation(value = "新增数据") - @PostMapping("insert") - public ResResult insert(@RequestBody Brand brand) { - return new ResResult().success(this.brandService.insert(brand)); - } - - /** - * 修改数据 - * - * @param brand 实体对象 - * @return 修改结果 - */ - @ApiOperation(value = "根据id修改数据") - @PutMapping("updateById") - public ResResult updateById(@RequestBody Brand brand) { - return new ResResult().success(this.brandService.updateById(brand)); - } - - /** - * 删除数据 - * - * @param idList 主键结合 - * @return 删除结果 - */ - @ApiOperation(value = "根据id数组删除数据") - @DeleteMapping("deleteBatchIds") - public ResResult deleteBatchIds(@RequestBody List idList) { - return new ResResult().success(this.brandService.deleteBatchIds(idList)); - } - - @DeleteMapping("deleteById") - @ApiOperation(value = "根据id数组删除数据") - public ResResult deleteById(@RequestParam("id") Integer id) { - return new ResResult().success(this.brandService.deleteById(id)); - } -} +package top.kuanghua.integrationfront.controller; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.springframework.web.bind.annotation.*; +import top.kuanghua.khcomomon.entity.KHCommonParams; +import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.integrationfront.entity.Brand; +import top.kuanghua.integrationfront.service.BrandService; + +import javax.annotation.Resource; +import java.util.List; + +@Api(tags = "品牌表(Brand)") +@RestController +@RequestMapping("brand") +public class BrandController { + + @Resource + private BrandService brandService; + + /** + * 分页查询所有数据 + * + * @param brand 查询实体 + * @return 所有数据 + */ + @GetMapping("selectPage") + @ApiOperation(value = "分页查询所有数据") + public ResResult selectPage(Brand brand, KHCommonParams commonParams) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (ObjectUtils.isNotEmpty(brand.getId())) { + queryWrapper.like("id", brand.getId()); + } + if (ObjectUtils.isNotEmpty(brand.getName())) { + queryWrapper.like("name", brand.getName()); + } + if (ObjectUtils.isNotEmpty(brand.getImage())) { + queryWrapper.like("image", brand.getImage()); + } + + if (ObjectUtils.isNotEmpty(brand.getLetter())) { + queryWrapper.like("letter", brand.getLetter()); + } + if (ObjectUtils.isNotEmpty(brand.getSeq())) { + queryWrapper.like("seq", brand.getSeq()); + } + queryWrapper.orderByDesc("create_time"); + if (StringUtils.isNotEmpty(commonParams.getStartTime())) { + queryWrapper.between("create_time", commonParams.getStartTime(), commonParams.getEndTime()); + } + queryWrapper.select("id,name,image,letter,seq,create_time,update_time"); + Page brandPage = this.brandService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); + return new ResResult().success(brandPage); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("selectById") + @ApiOperation(value = "通过id主键查询单条数据") + public ResResult selectById(@RequestParam("id") Integer id) { + return new ResResult().success(this.brandService.selectById(id)); + } + + /** + * @Description: 根据id数组查询品牌列表 + * @Param: idList id数组 + * @return: ids列表数据 + */ + @ApiOperation(value = "根据id数组查询品牌列表") + @PostMapping("selectBatchIds") + public ResResult selectBatchIds(@RequestParam("idList") List idList) { + return new ResResult().success(this.brandService.selectBatchIds(idList)); + } + + + /** + * 新增数据 + * + * @param brand 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping("insert") + public ResResult insert(@RequestBody Brand brand) { + return new ResResult().success(this.brandService.insert(brand)); + } + + /** + * 修改数据 + * + * @param brand 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "根据id修改数据") + @PutMapping("updateById") + public ResResult updateById(@RequestBody Brand brand) { + return new ResResult().success(this.brandService.updateById(brand)); + } + + /** + * 删除数据 + * + * @param idList 主键结合 + * @return 删除结果 + */ + @ApiOperation(value = "根据id数组删除数据") + @DeleteMapping("deleteBatchIds") + public ResResult deleteBatchIds(@RequestBody List idList) { + return new ResResult().success(this.brandService.deleteBatchIds(idList)); + } + + @DeleteMapping("deleteById") + @ApiOperation(value = "根据id数组删除数据") + public ResResult deleteById(@RequestParam("id") Integer id) { + return new ResResult().success(this.brandService.deleteById(id)); + } +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/ErrorCollectionController.java similarity index 94% rename from ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/controller/ErrorCollectionController.java index dcae33f..e474129 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/controller/ErrorCollectionController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/ErrorCollectionController.java @@ -1,123 +1,123 @@ -package top.kuanghua.tyuser.controller; - - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.apache.commons.lang3.StringUtils; -import org.springframework.web.bind.annotation.*; -import top.kuanghua.khcomomon.entity.KHCommonParams; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.tyuser.entity.ErrorCollection; -import top.kuanghua.tyuser.service.ErrorCollectionService; - -import javax.annotation.Resource; -import java.util.List; - -@Api(tags = "日志相关") -@RestController -@RequestMapping("errorCollection") -public class ErrorCollectionController { - - @Resource - private ErrorCollectionService errorCollectionService; - - /** - * 分页查询所有数据 - * - * @param errorCollection 查询实体 - * @return 所有数据 - */ - @GetMapping("selectPage") - @ApiOperation(value = "分页查询所有数据") - public ResResult selectPage(ErrorCollection errorCollection, KHCommonParams khCommonParams) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - if (ObjectUtils.isNotEmpty(errorCollection.getErrorLog())) { - queryWrapper.like("error_log", errorCollection.getErrorLog()); - } - if (ObjectUtils.isNotEmpty(errorCollection.getPageUrl())) { - queryWrapper.like("page_url", errorCollection.getPageUrl()); - } - if (ObjectUtils.isNotEmpty(errorCollection.getVersion())) { - queryWrapper.like("version", errorCollection.getVersion()); - } - if (ObjectUtils.isNotEmpty(errorCollection.getCreateTime())) { - queryWrapper.like("create_time", errorCollection.getCreateTime()); - } - - if (StringUtils.isNotEmpty(khCommonParams.getStartTime())) { - queryWrapper.between("create_time", khCommonParams.getStartTime(), khCommonParams.getEndTime()); - } - queryWrapper.orderByDesc("create_time"); - Page errorCollectionPage = this.errorCollectionService.selectPage(khCommonParams.getPageNum(), khCommonParams.getPageSize(), queryWrapper); - return new ResResult().success(errorCollectionPage); - } - - /** - * 通过主键查询单条数据 - * - * @param id 主键 - * @return 单条数据 - */ - @GetMapping("selectById") - @ApiOperation(value = "通过id主键查询单条数据") - public ResResult selectById(@RequestParam("id") Integer id) { - return new ResResult().success(this.errorCollectionService.selectById(id)); - } - - /** - * @Description: 根据id数组查询品牌列表 - * @Param: idList id数组 - * @return: ids列表数据 - */ - @ApiOperation(value = "根据id数组查询品牌列表") - @PostMapping("selectBatchIds") - public ResResult selectBatchIds(@RequestParam("idList") List idList) { - return new ResResult().success(this.errorCollectionService.selectBatchIds(idList)); - } - - - /** - * 新增数据 - * - * @param errorCollection 实体对象 - * @return 新增结果 - */ - @ApiOperation(value = "新增数据") - @PostMapping("insert") - public ResResult insert(@RequestBody ErrorCollection errorCollection) { - return new ResResult().success(this.errorCollectionService.insert(errorCollection)); - } - - /** - * 修改数据 - * - * @param errorCollection 实体对象 - * @return 修改结果 - */ - @ApiOperation(value = "根据id修改数据") - @PutMapping("updateById") - public ResResult updateById(@RequestBody ErrorCollection errorCollection) { - return new ResResult().success(this.errorCollectionService.updateById(errorCollection)); - } - - /** - * 删除数据 - * - * @param idList 主键结合 - * @return 删除结果 - */ - @ApiOperation(value = "根据id数组删除数据") - @DeleteMapping("deleteBatchIds") - public ResResult deleteBatchIds(@RequestBody List idList) { - return new ResResult().success(this.errorCollectionService.deleteBatchIds(idList)); - } - - @DeleteMapping("deleteById") - @ApiOperation(value = "根据id数组删除数据") - public ResResult deleteById(@RequestParam("id") Integer id) { - return new ResResult().success(this.errorCollectionService.deleteById(id)); - } -} +package top.kuanghua.integrationfront.controller; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.springframework.web.bind.annotation.*; +import top.kuanghua.khcomomon.entity.KHCommonParams; +import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.integrationfront.entity.ErrorCollection; +import top.kuanghua.integrationfront.service.ErrorCollectionService; + +import javax.annotation.Resource; +import java.util.List; + +@Api(tags = "日志相关") +@RestController +@RequestMapping("errorCollection") +public class ErrorCollectionController { + + @Resource + private ErrorCollectionService errorCollectionService; + + /** + * 分页查询所有数据 + * + * @param errorCollection 查询实体 + * @return 所有数据 + */ + @GetMapping("selectPage") + @ApiOperation(value = "分页查询所有数据") + public ResResult selectPage(ErrorCollection errorCollection, KHCommonParams khCommonParams) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (ObjectUtils.isNotEmpty(errorCollection.getErrorLog())) { + queryWrapper.like("error_log", errorCollection.getErrorLog()); + } + if (ObjectUtils.isNotEmpty(errorCollection.getPageUrl())) { + queryWrapper.like("page_url", errorCollection.getPageUrl()); + } + if (ObjectUtils.isNotEmpty(errorCollection.getVersion())) { + queryWrapper.like("version", errorCollection.getVersion()); + } + if (ObjectUtils.isNotEmpty(errorCollection.getCreateTime())) { + queryWrapper.like("create_time", errorCollection.getCreateTime()); + } + + if (StringUtils.isNotEmpty(khCommonParams.getStartTime())) { + queryWrapper.between("create_time", khCommonParams.getStartTime(), khCommonParams.getEndTime()); + } + queryWrapper.orderByDesc("create_time"); + Page errorCollectionPage = this.errorCollectionService.selectPage(khCommonParams.getPageNum(), khCommonParams.getPageSize(), queryWrapper); + return new ResResult().success(errorCollectionPage); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("selectById") + @ApiOperation(value = "通过id主键查询单条数据") + public ResResult selectById(@RequestParam("id") Integer id) { + return new ResResult().success(this.errorCollectionService.selectById(id)); + } + + /** + * @Description: 根据id数组查询品牌列表 + * @Param: idList id数组 + * @return: ids列表数据 + */ + @ApiOperation(value = "根据id数组查询品牌列表") + @PostMapping("selectBatchIds") + public ResResult selectBatchIds(@RequestParam("idList") List idList) { + return new ResResult().success(this.errorCollectionService.selectBatchIds(idList)); + } + + + /** + * 新增数据 + * + * @param errorCollection 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping("insert") + public ResResult insert(@RequestBody ErrorCollection errorCollection) { + return new ResResult().success(this.errorCollectionService.insert(errorCollection)); + } + + /** + * 修改数据 + * + * @param errorCollection 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "根据id修改数据") + @PutMapping("updateById") + public ResResult updateById(@RequestBody ErrorCollection errorCollection) { + return new ResResult().success(this.errorCollectionService.updateById(errorCollection)); + } + + /** + * 删除数据 + * + * @param idList 主键结合 + * @return 删除结果 + */ + @ApiOperation(value = "根据id数组删除数据") + @DeleteMapping("deleteBatchIds") + public ResResult deleteBatchIds(@RequestBody List idList) { + return new ResResult().success(this.errorCollectionService.deleteBatchIds(idList)); + } + + @DeleteMapping("deleteById") + @ApiOperation(value = "根据id数组删除数据") + public ResResult deleteById(@RequestParam("id") Integer id) { + return new ResResult().success(this.errorCollectionService.deleteById(id)); + } +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/controller/UserController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java similarity index 89% rename from ty-user/src/main/java/top/kuanghua/tyuser/controller/UserController.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java index 123f073..a082535 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/controller/UserController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java @@ -1,204 +1,202 @@ -package top.kuanghua.tyuser.controller; - - -import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.*; -import springfox.documentation.annotations.ApiIgnore; -import top.kuanghua.feign.tyauth.feign.TokenFeign; -import top.kuanghua.khcomomon.entity.KHCommonParams; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.tyuser.entity.User; -import top.kuanghua.tyuser.mapper.MultiPageMapper; -import top.kuanghua.tyuser.mapper.UserMapper; -import top.kuanghua.tyuser.service.UserService; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Api(tags = "用户相关") -@RestController -@RequestMapping("user") -@Transactional -public class UserController { - @Resource - private UserService userService; - @Resource - private UserMapper userMapper; - - @Resource - private MultiPageMapper multiPageMapper; - - - @Autowired - private TokenFeign tokenFeign; - /** - * 分页查询所有数据 - * @param user 查询实体 - * @return 所有数据 - */ - @GetMapping("selectPage") - @ApiOperation(value = "分页查询数据") - public ResResult selectPage(User user, KHCommonParams commonParams) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - if(StringUtils.isNotEmpty(user.getUsername())) { - queryWrapper.like("username",user.getUsername()); - } - if(StringUtils.isNotEmpty(user.getPhone())) { - queryWrapper.like("phone",user.getPhone()); - } - if(StringUtils.isNotEmpty(commonParams.getStartTime())) { - queryWrapper.between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); - } - queryWrapper.select("username","phone","create_time"); - Page userPage = this.userMapper.selectPage(new Page<>(commonParams.getPageNum(), commonParams.getPageSize()), queryWrapper); - return new ResResult().success(userPage); - } - - /** - * 通过主键查询单条数据 - * - * @param id 主键 - * @return 单条数据 - */ - @GetMapping("selectById") - @ApiOperation(value = "通过id主键查询单条数据") - public ResResult selectById(@RequestParam("id") Integer id) { - return new ResResult().success(this.userMapper.selectById(id)); - } -// -// /** -// * @Description: 根据id数组查询品牌列表 -// * @Param: idList id数组 -// * @return: ids列表数据 -// */ -// @ApiOperation(value = "根据id数组查询品牌列表") -// @PostMapping("selectBatchIds") -// public ResResult selectBatchIds(@RequestParam("idList") List idList) { -// return new ResResult().success(this.userMapper.selectBatchIds(idList)); -// } - - /** - * 新增数据 - * - * @param user 实体对象 - * @return 新增结果 - */ - @ApiOperation(value = "新增数据") - @PostMapping("insert") - - public ResResult insert(@Valid @RequestBody User user) { - //List userInfos = userInfoMapper.selectList(new EntityWrapper<>(userInfo).like("firstname", name) - // .like("lastname", name));52 - return new ResResult().success(this.userService.insert(user)); - } - /** - * 修改数据 - * - * @param user 实体对象 - * @return 修改结果 - */ - -// @ApiOperation(value = "根据id修改数据") -// @PutMapping("updateById") -// public ResResult updateById(@RequestBody User user) { -// return new ResResult().success(this.userService.updateById(user)); -// } -// /** -// * 删除数据 -// * -// * @param idList 主键结合 -// * @return 删除结果 -// */ - @ApiOperation(value = "根据id数组删除数据") - @DeleteMapping("deleteBatchIds") - public ResResult deleteBatchIds(@RequestBody List idList) { - return new ResResult().success(this.userMapper.deleteBatchIds(idList)); - } - @DeleteMapping("deleteById") - @ApiOperation(value = "根据id删除数据") - public ResResult deleteById(@RequestParam("id") Integer id) { - return new ResResult().success(this.userMapper.deleteById(id)); - } - - @PostMapping("registry") - @ApiOperation(value = "用户注册") - public ResResult registry(User user,String code,String password) throws Exception { - this.userService.registry(user,code); - return new ResResult().success(); - } - - @PostMapping("loginValid") - @ApiOperation(value = "登录校验") - public ResResult loginValid(User user) throws Exception { - HashMap hm = this.userService.loginValid(user); - return new ResResult().success(hm); - } - - @PostMapping("loginOut") - @ApiOperation(value = "退出登录") - - public ResResult loginOut() { - this.userService.loginOut(); - return new ResResult().success(); - } - @PostMapping("multiPageTest") - @ApiOperation(value = "多分页测试") - public Page> multiPageTest() { - Page> mapPage = multiPageMapper.queryAllUsers(new Page<>(1, 5)); - return mapPage; - } - - @PostMapping("userRegister") - @ApiOperation(value = "用户注册") - public ResResult userRegister(String email,String code,String username,String password){ - this.userService.userRegister(email,code,username,password); - return new ResResult().success(); - } - - @PostMapping("changePassword") - @ApiOperation(value = "修改密码") - public ResResult changePassword( - @ApiIgnore @RequestHeader("TOKEN_INFO") String TOKEN_INFO, - String oldPassword,String newPassword) throws UnsupportedEncodingException { - Map tokenInfo = JSON.parseObject(URLDecoder.decode(TOKEN_INFO, "utf-8")); - this.userService.changePassword(tokenInfo.get("username").toString(),oldPassword,newPassword); - return new ResResult().success(); - } - @PostMapping("getUserInfo") - @ApiOperation(value = "获取用户信息") - public ResResult changePassword(@ApiIgnore @RequestHeader("TOKEN_INFO") String TOKEN_INFO) throws UnsupportedEncodingException { - Map tokenInfo = JSON.parseObject(URLDecoder.decode(TOKEN_INFO, "utf-8")); - return new ResResult().success(tokenInfo); - } - - - @PostMapping("insertUser") - @ApiOperation(value = "插入用户") - public ResResult insertUser(String username){ - this.userService.insertUser(username); - return new ResResult().success(); - } - - - /** - * 重置用用户名:如果用用户存在先删除原有用户在新增一个用户,没有则新建用户 - */ - @PostMapping("resetUser") - @ApiOperation(value = "重置用户(有则删除在新增)") - public ResResult resetUser(String username) { - this.userService.resetUser(username); - return new ResResult().success(); - } +package top.kuanghua.integrationfront.controller; + + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; +import top.kuanghua.feign.tyauth.feign.TokenFeign; +import top.kuanghua.khcomomon.entity.KHCommonParams; +import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.integrationfront.entity.User; +import top.kuanghua.integrationfront.mapper.MultiPageMapper; +import top.kuanghua.integrationfront.mapper.UserMapper; +import top.kuanghua.integrationfront.service.UserService; + +import javax.annotation.Resource; +import javax.validation.Valid; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Api(tags = "用户相关") +@RestController +@RequestMapping("user") +@Transactional +public class UserController { + @Resource + private UserService userService; + @Resource + private UserMapper userMapper; + + @Resource + private MultiPageMapper multiPageMapper; + + + @Resource + private TokenFeign tokenFeign; + /** + * 分页查询所有数据 + * @param user 查询实体 + * @return 所有数据 + */ + @GetMapping("selectPage") + @ApiOperation(value = "分页查询数据") + public ResResult selectPage(User user, KHCommonParams commonParams) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + if(StringUtils.isNotEmpty(user.getUsername())) { + queryWrapper.like("username",user.getUsername()); + } + if(StringUtils.isNotEmpty(user.getPhone())) { + queryWrapper.like("phone",user.getPhone()); + } + if(StringUtils.isNotEmpty(commonParams.getStartTime())) { + queryWrapper.between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); + } + queryWrapper.select("username","phone","create_time"); + Page userPage = this.userMapper.selectPage(new Page<>(commonParams.getPageNum(), commonParams.getPageSize()), queryWrapper); + return new ResResult().success(userPage); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("selectById") + @ApiOperation(value = "通过id主键查询单条数据") + public ResResult selectById(@RequestParam("id") Integer id) { + return new ResResult().success(this.userMapper.selectById(id)); + } +// +// /** +// * @Description: 根据id数组查询品牌列表 +// * @Param: idList id数组 +// * @return: ids列表数据 +// */ +// @ApiOperation(value = "根据id数组查询品牌列表") +// @PostMapping("selectBatchIds") +// public ResResult selectBatchIds(@RequestParam("idList") List idList) { +// return new ResResult().success(this.userMapper.selectBatchIds(idList)); +// } + + /** + * 新增数据 + * + * @param user 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping("insert") + + public ResResult insert(@Valid @RequestBody User user) { + //List userInfos = userInfoMapper.selectList(new EntityWrapper<>(userInfo).like("firstname", name) + // .like("lastname", name));52 + return new ResResult().success(this.userService.insert(user)); + } + /** + * 修改数据 + * + * @return 修改结果 + */ + +// @ApiOperation(value = "根据id修改数据") +// @PutMapping("updateById") +// public ResResult updateById(@RequestBody User user) { +// return new ResResult().success(this.userService.updateById(user)); +// } +// /** +// * 删除数据 +// * +// * @param idList 主键结合 +// * @return 删除结果 +// */ + @ApiOperation(value = "根据id数组删除数据") + @DeleteMapping("deleteBatchIds") + public ResResult deleteBatchIds(@RequestBody List idList) { + return new ResResult().success(this.userMapper.deleteBatchIds(idList)); + } + @DeleteMapping("deleteById") + @ApiOperation(value = "根据id删除数据") + public ResResult deleteById(@RequestParam("id") Integer id) { + return new ResResult().success(this.userMapper.deleteById(id)); + } + + @PostMapping("registry") + @ApiOperation(value = "用户注册") + public ResResult registry(User user,String code,String password) throws Exception { + this.userService.registry(user,code); + return new ResResult().success(); + } + + @PostMapping("loginValid") + @ApiOperation(value = "登录校验") + public ResResult loginValid(User user) throws Exception { + HashMap hm = this.userService.loginValid(user); + return new ResResult().success(hm); + } + + @PostMapping("loginOut") + @ApiOperation(value = "退出登录") + + public ResResult loginOut() { + this.userService.loginOut(); + return new ResResult().success(); + } + @PostMapping("multiPageTest") + @ApiOperation(value = "多分页测试") + public Page> multiPageTest() { + Page> mapPage = multiPageMapper.queryAllUsers(new Page<>(1, 5)); + return mapPage; + } +// +// @PostMapping("userRegister") +// @ApiOperation(value = "用户注册") +// public ResResult userRegister(String email,String code,String username,String password){ +// this.userService.userRegister(email,code,username,password); +// return new ResResult().success(); +// } + + @PostMapping("changePassword") + @ApiOperation(value = "修改密码") + public ResResult changePassword( + @ApiIgnore @RequestHeader("TOKEN_INFO") String TOKEN_INFO, + String oldPassword,String newPassword) throws UnsupportedEncodingException { + Map tokenInfo = JSON.parseObject(URLDecoder.decode(TOKEN_INFO, "utf-8")); + this.userService.changePassword(tokenInfo.get("username").toString(),oldPassword,newPassword); + return new ResResult().success(); + } + @PostMapping("getUserInfo") + @ApiOperation(value = "获取用户信息") + public ResResult changePassword(@ApiIgnore @RequestHeader("TOKEN_INFO") String TOKEN_INFO) throws UnsupportedEncodingException { + Map tokenInfo = JSON.parseObject(URLDecoder.decode(TOKEN_INFO, "utf-8")); + return new ResResult().success(tokenInfo); + } + + + @PostMapping("insertUser") + @ApiOperation(value = "插入用户") + public ResResult insertUser(String username){ + this.userService.insertUser(username); + return new ResResult().success(); + } + + + /** + * 重置用用户名:如果用用户存在先删除原有用户在新增一个用户,没有则新建用户 + */ + @PostMapping("resetUser") + @ApiOperation(value = "重置用户(有则删除在新增)") + public ResResult resetUser(String username) { + this.userService.resetUser(username); + return new ResResult().success(); + } } \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/controller/VciController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/VciController.java similarity index 93% rename from ty-user/src/main/java/top/kuanghua/tyuser/controller/VciController.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/controller/VciController.java index 93a0285..3b57601 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/controller/VciController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/VciController.java @@ -1,171 +1,170 @@ -package top.kuanghua.tyuser.controller; - - -import com.alibaba.excel.EasyExcel; -import com.alibaba.nacos.api.naming.CommonParams; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.apache.commons.lang3.StringUtils; -import org.springframework.web.multipart.MultipartFile; -import top.kuanghua.khcomomon.entity.CommonParamsSelf; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; -import top.kuanghua.tyuser.entity.Vci; -import top.kuanghua.tyuser.excel.imp.VciExcelImp; -import top.kuanghua.tyuser.service.VciService; -import org.springframework.web.bind.annotation.*; -import top.kuanghua.tyuser.vo.ExcelCheckResult; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.net.URLEncoder; -import java.util.*; - - -@Api(tags = "VCI设备表(Vci)") -@RestController -@RequestMapping("vci") -public class VciController { - - @Resource - private VciService vciService; - - /** - * 分页查询所有数据 - * @param vci 查询实体 - * @return 所有数据 - */ - @GetMapping("selectPage") - @ApiOperation(value = "分页查询所有数据") - public ResResult selectPage(Vci vci, CommonParamsSelf commonParams) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - if (ObjectUtils.isNotEmpty(vci.getSn())) { - queryWrapper.like("sn", vci.getSn()); - } - if (ObjectUtils.isNotEmpty(vci.getHardVersion())) { - queryWrapper.like("hard_version", vci.getHardVersion()); - } - if (ObjectUtils.isNotEmpty(vci.getStatus())) { - queryWrapper.like("status", vci.getStatus()); - } - //根据创建时间查询 - queryWrapper.orderByDesc("create_time"); - if(StringUtils.isNotEmpty(commonParams.getStartTime())) { - queryWrapper.between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); - } - - queryWrapper.select("id,sn,hard_version,create_time,status,supplier,receipt_no,product_spec"); - Page vciPage = this.vciService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); - return new ResResult().success(vciPage); - } - - /** - * 通过主键查询单条数据 - * - * @param id 主键 - * @return 单条数据 - */ - @GetMapping("selectById") - @ApiOperation(value = "通过id主键查询单条数据") - public ResResult selectById(@RequestParam("id") Integer id) { - return new ResResult().success(this.vciService.selectById(id)); - } - /** - * @Description: 根据id数组查询品牌列表 - * @Param: idList id数组 - * @return: ids列表数据 - */ - @ApiOperation(value = "根据id数组查询品牌列表") - @PostMapping("selectBatchIds") - public ResResult selectBatchIds(@RequestParam("idList") List idList) { - return new ResResult().success(this.vciService.selectBatchIds(idList)); - } - /** - * 新增数据 - * @param vci 实体对象 - * @return 新增结果 - */ - @ApiOperation(value = "新增数据") - @PostMapping("insert") - public ResResult insert(@RequestBody Vci vci) { - return new ResResult().success(this.vciService.insert(vci)); - } - - /** - * 修改数据 - * @param vci 实体对象 - * @return 修改结果 - */ - @ApiOperation(value = "根据id修改数据") - @PutMapping("updateById") - public ResResult updateById(@RequestBody Vci vci) { - return new ResResult().success(this.vciService.updateById(vci)); - } - - /** - * 删除数据 - * @param idList 主键结合 - * @return 删除结果 - */ - @ApiOperation(value = "根据id数组删除数据") - @DeleteMapping("deleteBatchIds") - public ResResult deleteBatchIds(@RequestBody List idList) { - return new ResResult().success(this.vciService.deleteBatchIds(idList)); - } - - @DeleteMapping("deleteById") - @ApiOperation(value = "根据id数组删除数据") - public ResResult deleteById(@RequestParam("id") Integer id) { - return new ResResult().success(this.vciService.deleteById(id)); - } - - @ApiOperation("检查excel") - @PostMapping("validExcel") - public ResResult validExcel(@RequestParam("file") MultipartFile file) throws IOException { - ExcelCheckResult checkResult = vciService.validExcel(file.getInputStream()); - return new ResResult().success(checkResult); - } - - @ApiOperation("导入excel") - @PostMapping("importExcel") - public ResResult importExcel(@RequestBody List vciExcelBo) { - vciService.importExcel(vciExcelBo); - return new ResResult().success(); - } - - @ApiOperation("导出excel") - @GetMapping("exportExcel") - public void exportExcel(HttpServletResponse response,Vci vci, CommonParamsSelf commonParams) throws IOException { - QueryWrapper queryWrapper = new QueryWrapper<>(); - if (ObjectUtils.isNotEmpty(vci.getSn())) { - queryWrapper.like("sn", vci.getSn()); - } - if (ObjectUtils.isNotEmpty(vci.getHardVersion())) { - queryWrapper.like("hard_version", vci.getHardVersion()); - } - if (ObjectUtils.isNotEmpty(vci.getStatus())) { - queryWrapper.like("status", vci.getStatus()); - } - //根据创建时间查询 - queryWrapper.orderByDesc("create_time"); - if(StringUtils.isNotEmpty(commonParams.getStartTime())) { - queryWrapper.between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); - } - - queryWrapper.select("sn,hard_version,create_time,status,supplier,receipt_no,product_spec"); - Page vciPage = this.vciService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); - // 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - response.setCharacterEncoding("utf-8"); - - String fileName = URLEncoder.encode("Vci导出数据", "UTF-8")+"-"+ ObjectUtilsSelf.getCurrentDateTime(); - response.setHeader("Access-Control-Expose-Headers", "exportFileName"); - response.setHeader("exportFileName", fileName + ".xlsx" ); - EasyExcel.write(response.getOutputStream(), VciExcelImp.class).sheet("模板").doWrite(vciPage.getRecords()); - } - -} +package top.kuanghua.integrationfront.controller; + + +import com.alibaba.excel.EasyExcel; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.springframework.web.multipart.MultipartFile; +import top.kuanghua.khcomomon.entity.CommonParamsSelf; +import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; +import top.kuanghua.integrationfront.entity.Vci; +import top.kuanghua.integrationfront.excel.imp.VciExcelImp; +import top.kuanghua.integrationfront.service.VciService; +import org.springframework.web.bind.annotation.*; +import top.kuanghua.integrationfront.vo.ExcelCheckResult; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.*; + + +@Api(tags = "VCI设备表(Vci)") +@RestController +@RequestMapping("vci") +public class VciController { + + @Resource + private VciService vciService; + + /** + * 分页查询所有数据 + * @param vci 查询实体 + * @return 所有数据 + */ + @GetMapping("selectPage") + @ApiOperation(value = "分页查询所有数据") + public ResResult selectPage(Vci vci, CommonParamsSelf commonParams) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (ObjectUtils.isNotEmpty(vci.getSn())) { + queryWrapper.like("sn", vci.getSn()); + } + if (ObjectUtils.isNotEmpty(vci.getHardVersion())) { + queryWrapper.like("hard_version", vci.getHardVersion()); + } + if (ObjectUtils.isNotEmpty(vci.getStatus())) { + queryWrapper.like("status", vci.getStatus()); + } + //根据创建时间查询 + queryWrapper.orderByDesc("create_time"); + if(StringUtils.isNotEmpty(commonParams.getStartTime())) { + queryWrapper.between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); + } + + queryWrapper.select("id,sn,hard_version,create_time,status,supplier,receipt_no,product_spec"); + Page vciPage = this.vciService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); + return new ResResult().success(vciPage); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("selectById") + @ApiOperation(value = "通过id主键查询单条数据") + public ResResult selectById(@RequestParam("id") Integer id) { + return new ResResult().success(this.vciService.selectById(id)); + } + /** + * @Description: 根据id数组查询品牌列表 + * @Param: idList id数组 + * @return: ids列表数据 + */ + @ApiOperation(value = "根据id数组查询品牌列表") + @PostMapping("selectBatchIds") + public ResResult selectBatchIds(@RequestParam("idList") List idList) { + return new ResResult().success(this.vciService.selectBatchIds(idList)); + } + /** + * 新增数据 + * @param vci 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping("insert") + public ResResult insert(@RequestBody Vci vci) { + return new ResResult().success(this.vciService.insert(vci)); + } + + /** + * 修改数据 + * @param vci 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "根据id修改数据") + @PutMapping("updateById") + public ResResult updateById(@RequestBody Vci vci) { + return new ResResult().success(this.vciService.updateById(vci)); + } + + /** + * 删除数据 + * @param idList 主键结合 + * @return 删除结果 + */ + @ApiOperation(value = "根据id数组删除数据") + @DeleteMapping("deleteBatchIds") + public ResResult deleteBatchIds(@RequestBody List idList) { + return new ResResult().success(this.vciService.deleteBatchIds(idList)); + } + + @DeleteMapping("deleteById") + @ApiOperation(value = "根据id数组删除数据") + public ResResult deleteById(@RequestParam("id") Integer id) { + return new ResResult().success(this.vciService.deleteById(id)); + } + + @ApiOperation("检查excel") + @PostMapping("validExcel") + public ResResult validExcel(@RequestParam("file") MultipartFile file) throws IOException { + ExcelCheckResult checkResult = vciService.validExcel(file.getInputStream()); + return new ResResult().success(checkResult); + } + + @ApiOperation("导入excel") + @PostMapping("importExcel") + public ResResult importExcel(@RequestBody List vciExcelBo) { + vciService.importExcel(vciExcelBo); + return new ResResult().success(); + } + + @ApiOperation("导出excel") + @GetMapping("exportExcel") + public void exportExcel(HttpServletResponse response,Vci vci, CommonParamsSelf commonParams) throws IOException { + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (ObjectUtils.isNotEmpty(vci.getSn())) { + queryWrapper.like("sn", vci.getSn()); + } + if (ObjectUtils.isNotEmpty(vci.getHardVersion())) { + queryWrapper.like("hard_version", vci.getHardVersion()); + } + if (ObjectUtils.isNotEmpty(vci.getStatus())) { + queryWrapper.like("status", vci.getStatus()); + } + //根据创建时间查询 + queryWrapper.orderByDesc("create_time"); + if(StringUtils.isNotEmpty(commonParams.getStartTime())) { + queryWrapper.between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); + } + + queryWrapper.select("sn,hard_version,create_time,status,supplier,receipt_no,product_spec"); + Page vciPage = this.vciService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); + // 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setCharacterEncoding("utf-8"); + + String fileName = URLEncoder.encode("Vci导出数据", "UTF-8")+"-"+ ObjectUtilsSelf.getCurrentDateTime(); + response.setHeader("Access-Control-Expose-Headers", "exportFileName"); + response.setHeader("exportFileName", fileName + ".xlsx" ); + EasyExcel.write(response.getOutputStream(), VciExcelImp.class).sheet("模板").doWrite(vciPage.getRecords()); + } + +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/entity/Access.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Access.java similarity index 93% rename from ty-user/src/main/java/top/kuanghua/tyuser/entity/Access.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/entity/Access.java index 125e0f0..912a12c 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/entity/Access.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Access.java @@ -1,45 +1,45 @@ -package top.kuanghua.tyuser.entity; - -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.activerecord.Model; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; - -/** - * 权限表(Access)表实体类 - * - * @author kuanghua - * @since 2021-03-23 11:03:45 - */ -@Data -@ApiModel("权限表") -@TableName(value = "tb_access") -public class Access extends Model { - @ApiModelProperty(value = "主键id") - private Integer id; - @ApiModelProperty(value = "权限名称") - private String name; - @ApiModelProperty(value = "是否删除") - private String isDelete; - @ApiModelProperty(value = "更新时间") - private Date updatedTime; - @ApiModelProperty(value = "创建时间") - private Date createdTime; - @ApiModelProperty(value = "父id") - private Integer parentId; - @ApiModelProperty(value = "是否是父类") - private String isParent; - /** - * 获取主键值 - * - * @return 主键值 - */ - @Override - protected Serializable pkVal() { - return this.id; - } -} +package top.kuanghua.integrationfront.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 权限表(Access)表实体类 + * + * @author kuanghua + * @since 2021-03-23 11:03:45 + */ +@Data +@ApiModel("权限表") +@TableName(value = "tb_access") +public class Access extends Model { + @ApiModelProperty(value = "主键id") + private Integer id; + @ApiModelProperty(value = "权限名称") + private String name; + @ApiModelProperty(value = "是否删除") + private String isDelete; + @ApiModelProperty(value = "更新时间") + private Date updatedTime; + @ApiModelProperty(value = "创建时间") + private Date createdTime; + @ApiModelProperty(value = "父id") + private Integer parentId; + @ApiModelProperty(value = "是否是父类") + private String isParent; + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/entity/Admin.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Admin.java similarity index 93% rename from ty-user/src/main/java/top/kuanghua/tyuser/entity/Admin.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/entity/Admin.java index 3ec4619..3afb60b 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/entity/Admin.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Admin.java @@ -1,49 +1,49 @@ -package top.kuanghua.tyuser.entity; - -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.activerecord.Model; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; - -/** - * 用户列表(Admin)表实体类 - * - * @author kuanghua - * @since 2021-03-19 10:45:42 - */ -@Data -@ApiModel("用户列表") -@TableName(value = "tb_admin") -public class Admin extends Model { - private Integer id; - private String status; - private Date addTime; - @ApiModelProperty(value = "超级管理员(0.不是,1.是)") - private String isSuper; - @ApiModelProperty(value = "用户名") - private String username; - @ApiModelProperty(value = "密码") - private String password; - @ApiModelProperty(value = "是否删除") - private String isDelete; - @ApiModelProperty(value = "手机号") - private String mobile; - @ApiModelProperty(value = "邮箱") - private String email; - @ApiModelProperty(value = "角色id") - private Integer roleId; - - /** - * 获取主键值 - * - * @return 主键值 - */ - @Override - protected Serializable pkVal() { - return this.id; - } -} +package top.kuanghua.integrationfront.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 用户列表(Admin)表实体类 + * + * @author kuanghua + * @since 2021-03-19 10:45:42 + */ +@Data +@ApiModel("用户列表") +@TableName(value = "tb_admin") +public class Admin extends Model { + private Integer id; + private String status; + private Date addTime; + @ApiModelProperty(value = "超级管理员(0.不是,1.是)") + private String isSuper; + @ApiModelProperty(value = "用户名") + private String username; + @ApiModelProperty(value = "密码") + private String password; + @ApiModelProperty(value = "是否删除") + private String isDelete; + @ApiModelProperty(value = "手机号") + private String mobile; + @ApiModelProperty(value = "邮箱") + private String email; + @ApiModelProperty(value = "角色id") + private Integer roleId; + + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/entity/Brand.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Brand.java similarity index 94% rename from ty-user/src/main/java/top/kuanghua/tyuser/entity/Brand.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/entity/Brand.java index 272face..95f7886 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/entity/Brand.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Brand.java @@ -1,50 +1,50 @@ -package top.kuanghua.tyuser.entity; - -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.activerecord.Model; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; - -/** - * 品牌表(Brand)表实体类 - * - * @author kuanghua - * @since 2021-09-15 11:54:49 - */ -@Data -@ApiModel("品牌表") -@TableName(value = "tb_brand") -public class Brand extends Model { - @ApiModelProperty(value = "品牌id") - private Integer id; - @ApiModelProperty(value = "品牌名称") - private String name; - @ApiModelProperty(value = "品牌图片地址") - private String image; - @ApiModelProperty(value = "品牌的首字母") - private String letter; - @ApiModelProperty(value = "排序") - private Integer seq; - @ApiModelProperty(value = "创建时间",hidden = true) - @TableField(fill = FieldFill.INSERT) - private Date createTime; - @ApiModelProperty(value = "更新时间",hidden = true) - @TableField(fill = FieldFill.UPDATE) - private Date updateTime; - /** - * 获取主键值 - * - * @return 主键值 - */ - @Override - protected Serializable pkVal() { - return this.id; - } -} +package top.kuanghua.integrationfront.entity; + +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * 品牌表(Brand)表实体类 + * + * @author kuanghua + * @since 2021-09-15 11:54:49 + */ +@Data +@ApiModel("品牌表") +@TableName(value = "tb_brand") +public class Brand extends Model { + @ApiModelProperty(value = "品牌id") + private Integer id; + @ApiModelProperty(value = "品牌名称") + private String name; + @ApiModelProperty(value = "品牌图片地址") + private String image; + @ApiModelProperty(value = "品牌的首字母") + private String letter; + @ApiModelProperty(value = "排序") + private Integer seq; + @ApiModelProperty(value = "创建时间",hidden = true) + @TableField(fill = FieldFill.INSERT) + private Date createTime; + @ApiModelProperty(value = "更新时间",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private Date updateTime; + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/entity/ErrorCollection.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/ErrorCollection.java similarity index 91% rename from ty-user/src/main/java/top/kuanghua/tyuser/entity/ErrorCollection.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/entity/ErrorCollection.java index 3372821..ec1827a 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/entity/ErrorCollection.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/ErrorCollection.java @@ -1,37 +1,35 @@ -package top.kuanghua.tyuser.entity; - -import java.util.Date; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.activerecord.Model; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; - -/** - * error_log_collection(ErrorCollection)表实体类 - * @author kuanghua - * @since 2021-10-08 11:37:25 - */ -@Data -@ApiModel("错误日志相关") -@TableName(value = "tb_error_collection") -public class ErrorCollection extends Model { - @ApiModelProperty(value = "id主键") - private Long id; - @ApiModelProperty(value = "错误日志") - private String errorLog; - @ApiModelProperty(value = "页面路径") - private String pageUrl; - @ApiModelProperty(value = "当前版本") - private String version; - @ApiModelProperty(value = "浏览器类型",hidden = true) - private String browserType; - @TableField(fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建时间",hidden = true) - private Date createTime; -} +package top.kuanghua.integrationfront.entity; + +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * error_log_collection(ErrorCollection)表实体类 + * @author kuanghua + * @since 2021-10-08 11:37:25 + */ +@Data +@ApiModel("错误日志相关") +@TableName(value = "tb_error_collection") +public class ErrorCollection extends Model { + @ApiModelProperty(value = "id主键") + private Long id; + @ApiModelProperty(value = "错误日志") + private String errorLog; + @ApiModelProperty(value = "页面路径") + private String pageUrl; + @ApiModelProperty(value = "当前版本") + private String version; + @ApiModelProperty(value = "浏览器类型",hidden = true) + private String browserType; + @TableField(fill = FieldFill.INSERT) + @ApiModelProperty(value = "创建时间",hidden = true) + private Date createTime; +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/entity/Role.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java similarity index 93% rename from ty-user/src/main/java/top/kuanghua/tyuser/entity/Role.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java index 6718ccc..cdf87aa 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/entity/Role.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java @@ -1,42 +1,42 @@ -package top.kuanghua.tyuser.entity; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.activerecord.Model; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import java.io.Serializable; -import java.util.Date; - -/** - * 角色表(Role)表实体类 - * - * @author kuanghua - * @since 2021-01-18 12:12:37 - */ -@Data -@ApiModel("角色表") -@TableName(value = "tb_role") -public class Role extends Model { - @ApiModelProperty(value = "角色id") - private Integer id; - @ApiModelProperty(value = "角色名称") - private String name; - @ApiModelProperty(value = "更新时间") - @TableField(fill = FieldFill.UPDATE) - private Date updateTime; - @ApiModelProperty(value = "创建时间") - @TableField(fill = FieldFill.INSERT) - private Date createdTime; - /** - * 获取主键值 - * - * @return 主键值 - */ - @Override - protected Serializable pkVal() { - return this.id; - } +package top.kuanghua.integrationfront.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.io.Serializable; +import java.util.Date; + +/** + * 角色表(Role)表实体类 + * + * @author kuanghua + * @since 2021-01-18 12:12:37 + */ +@Data +@ApiModel("角色表") +@TableName(value = "tb_role") +public class Role extends Model { + @ApiModelProperty(value = "角色id") + private Integer id; + @ApiModelProperty(value = "角色名称") + private String name; + @ApiModelProperty(value = "更新时间") + @TableField(fill = FieldFill.UPDATE) + private Date updateTime; + @ApiModelProperty(value = "创建时间") + @TableField(fill = FieldFill.INSERT) + private Date createdTime; + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } } \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/entity/RoleAccess.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/RoleAccess.java similarity index 94% rename from ty-user/src/main/java/top/kuanghua/tyuser/entity/RoleAccess.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/entity/RoleAccess.java index 0a034be..2bccc92 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/entity/RoleAccess.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/RoleAccess.java @@ -1,47 +1,47 @@ -package top.kuanghua.tyuser.entity; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.activerecord.Model; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; - -/** - * 角色权限表(RoleAccess)表实体类 - * - * @author kuanghua - * @since 2021-01-18 12:12:38 - */ -@Data -@ApiModel("角色权限表") -@TableName(value = "tb_role_access") -public class RoleAccess extends Model { - @ApiModelProperty(value = "主键id") - private Integer id; - @ApiModelProperty(value = "角色id") - private Integer roleId; - @ApiModelProperty(value = "权限id") - private Integer accessId; - @ApiModelProperty(value = "更新时间") - @TableField(fill = FieldFill.UPDATE) - private Date updateTime; - @ApiModelProperty(value = "创建时间") - @TableField(fill = FieldFill.INSERT) - private Date createdTime; - @ApiModelProperty(value = "父id:(0,顶级父类") - private Integer parentId; - /** - * 获取主键值 - * - * @return 主键值 - */ - @Override - protected Serializable pkVal() { - return this.id; - } +package top.kuanghua.integrationfront.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 角色权限表(RoleAccess)表实体类 + * + * @author kuanghua + * @since 2021-01-18 12:12:38 + */ +@Data +@ApiModel("角色权限表") +@TableName(value = "tb_role_access") +public class RoleAccess extends Model { + @ApiModelProperty(value = "主键id") + private Integer id; + @ApiModelProperty(value = "角色id") + private Integer roleId; + @ApiModelProperty(value = "权限id") + private Integer accessId; + @ApiModelProperty(value = "更新时间") + @TableField(fill = FieldFill.UPDATE) + private Date updateTime; + @ApiModelProperty(value = "创建时间") + @TableField(fill = FieldFill.INSERT) + private Date createdTime; + @ApiModelProperty(value = "父id:(0,顶级父类") + private Integer parentId; + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } } \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/entity/User.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/User.java similarity index 95% rename from ty-user/src/main/java/top/kuanghua/tyuser/entity/User.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/entity/User.java index 386717d..afaf636 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/entity/User.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/User.java @@ -1,66 +1,66 @@ -package top.kuanghua.tyuser.entity; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableLogic; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.activerecord.Model; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Size; -import java.io.Serializable; -import java.util.Date; - -/** - * 用户表;uploadFileBtn;downloadFilebtn(User)表实体类 - * - * @author kuanghua - * @since 2020-12-13 16:59:51 - */ -@Data -@ApiModel("用户表") -@TableName(value = "tb_user") -//https://www.cnblogs.com/Nickc/p/12001764.html -public class User extends Model { - @ApiModelProperty(value = "id",hidden = false) - private Integer id; - @ApiModelProperty(value = "用户名") - @Size(max = 20,min = 5,message = "创建人姓名长度需要在2-20字符长度之间") - private String username; - @ApiModelProperty(value = "密码") - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - private String password; - @NotBlank(message = "电话不能为空") - @ApiModelProperty(value = "电话") - private String phone; - @NotBlank(message = "邮箱不能为空") - @ApiModelProperty(value = "邮箱") - private String email; - @ApiModelProperty(value = "创建时间",hidden = true) - @TableField(fill = FieldFill.INSERT) - private Date createTime; - @ApiModelProperty(value = "更新时间",hidden = true) - @TableField(fill = FieldFill.UPDATE) - private Date updateTime; - @ApiModelProperty(value = "是否删除",hidden = true) - @TableLogic - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - private String deleted; - @ApiModelProperty(value = "加密的盐",hidden = true) - @TableField() - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - private String salt; - /** - * 获取主键值 - * - * @return 主键值 - */ - @Override - protected Serializable pkVal() { - return this.id; - } +package top.kuanghua.integrationfront.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.io.Serializable; +import java.util.Date; + +/** + * 用户表;uploadFileBtn;downloadFilebtn(User)表实体类 + * + * @author kuanghua + * @since 2020-12-13 16:59:51 + */ +@Data +@ApiModel("用户表") +@TableName(value = "tb_user") +//https://www.cnblogs.com/Nickc/p/12001764.html +public class User extends Model { + @ApiModelProperty(value = "id",hidden = false) + private Integer id; + @ApiModelProperty(value = "用户名") + @Size(max = 20,min = 5,message = "创建人姓名长度需要在2-20字符长度之间") + private String username; + @ApiModelProperty(value = "密码") + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private String password; + @NotBlank(message = "电话不能为空") + @ApiModelProperty(value = "电话") + private String phone; + @NotBlank(message = "邮箱不能为空") + @ApiModelProperty(value = "邮箱") + private String email; + @ApiModelProperty(value = "创建时间",hidden = true) + @TableField(fill = FieldFill.INSERT) + private Date createTime; + @ApiModelProperty(value = "更新时间",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private Date updateTime; + @ApiModelProperty(value = "是否删除",hidden = true) + @TableLogic + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private String deleted; + @ApiModelProperty(value = "加密的盐",hidden = true) + @TableField() + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private String salt; + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } } \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/entity/UserRole.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/UserRole.java similarity index 93% rename from ty-user/src/main/java/top/kuanghua/tyuser/entity/UserRole.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/entity/UserRole.java index 8891008..2959f0a 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/entity/UserRole.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/UserRole.java @@ -1,46 +1,46 @@ -package top.kuanghua.tyuser.entity; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.activerecord.Model; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; - -/** - * 用户角色表(UserRole)表实体类 - * - * @author kuanghua - * @since 2021-01-18 12:12:37 - */ -@Data -@ApiModel("用户角色表") -@TableName(value = "tb_user_role") -public class UserRole extends Model { - @ApiModelProperty(value = "主键id") - private Integer id; - @ApiModelProperty(value = "用户id") - private Integer uid; - @ApiModelProperty(value = "角色id") - private Integer roleId; - @ApiModelProperty(value = "更新时间") - @TableField(fill = FieldFill.UPDATE) - private Date updateTime; - @ApiModelProperty(value = "创建时间") - @TableField(fill = FieldFill.INSERT) - private Date createdTime; - - /** - * 获取主键值 - * - * @return 主键值 - */ - @Override - protected Serializable pkVal() { - return this.id; - } +package top.kuanghua.integrationfront.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 用户角色表(UserRole)表实体类 + * + * @author kuanghua + * @since 2021-01-18 12:12:37 + */ +@Data +@ApiModel("用户角色表") +@TableName(value = "tb_user_role") +public class UserRole extends Model { + @ApiModelProperty(value = "主键id") + private Integer id; + @ApiModelProperty(value = "用户id") + private Integer uid; + @ApiModelProperty(value = "角色id") + private Integer roleId; + @ApiModelProperty(value = "更新时间") + @TableField(fill = FieldFill.UPDATE) + private Date updateTime; + @ApiModelProperty(value = "创建时间") + @TableField(fill = FieldFill.INSERT) + private Date createdTime; + + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } } \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/entity/Vci.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Vci.java similarity index 94% rename from ty-user/src/main/java/top/kuanghua/tyuser/entity/Vci.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/entity/Vci.java index b06117f..d93c11f 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/entity/Vci.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Vci.java @@ -1,51 +1,51 @@ -package top.kuanghua.tyuser.entity; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.activerecord.Model; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; - -/** - * VCI设备表(Vci)表实体类 - * - * @author kuanghua - * @since 2021-10-22 10:34:43 - */ -@Data -@ApiModel("VCI设备表") -@TableName(value = "tb_vci") -public class Vci extends Model { - @ApiModelProperty(value = "ID") - private Integer id; - @ApiModelProperty(value = "序列号,唯一") - private String sn; - @ApiModelProperty(value = "硬件版本") - private String hardVersion; - @ApiModelProperty(value = "状态:0:未出库、1:已入库") - private Integer status; - @ApiModelProperty(value = "供应商") - private String supplier; - @ApiModelProperty(value = "商品规格") - private String productSpec; - @ApiModelProperty(value = "入库单号") - private String receiptNo; - @ApiModelProperty(value = "入库时间") - @TableField(fill = FieldFill.INSERT) - private Date createTime; - /** - * 获取主键值 - * - * @return 主键值 - */ - @Override - protected Serializable pkVal() { - return this.id; - } -} - +package top.kuanghua.integrationfront.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * VCI设备表(Vci)表实体类 + * + * @author kuanghua + * @since 2021-10-22 10:34:43 + */ +@Data +@ApiModel("VCI设备表") +@TableName(value = "tb_vci") +public class Vci extends Model { + @ApiModelProperty(value = "ID") + private Integer id; + @ApiModelProperty(value = "序列号,唯一") + private String sn; + @ApiModelProperty(value = "硬件版本") + private String hardVersion; + @ApiModelProperty(value = "状态:0:未出库、1:已入库") + private Integer status; + @ApiModelProperty(value = "供应商") + private String supplier; + @ApiModelProperty(value = "商品规格") + private String productSpec; + @ApiModelProperty(value = "入库单号") + private String receiptNo; + @ApiModelProperty(value = "入库时间") + @TableField(fill = FieldFill.INSERT) + private Date createTime; + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } +} + diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/excel/cv/VciStatusImpCv.java b/integration-front/src/main/java/top/kuanghua/integrationfront/excel/cv/VciStatusImpCv.java similarity index 94% rename from ty-user/src/main/java/top/kuanghua/tyuser/excel/cv/VciStatusImpCv.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/excel/cv/VciStatusImpCv.java index 309d6fb..08810c3 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/excel/cv/VciStatusImpCv.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/excel/cv/VciStatusImpCv.java @@ -1,35 +1,35 @@ -package top.kuanghua.tyuser.excel.cv; - -import com.alibaba.excel.converters.Converter; -import com.alibaba.excel.metadata.GlobalConfiguration; -import com.alibaba.excel.metadata.data.ReadCellData; -import com.alibaba.excel.metadata.data.WriteCellData; -import com.alibaba.excel.metadata.property.ExcelContentProperty; - -public class VciStatusImpCv implements Converter { - @Override - public Integer convertToJavaData(ReadCellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { - String stringValue = cellData.getStringValue(); - int csId; - if("未入库".equals(stringValue)){ - csId=0; - }else if("已入库".equals(stringValue)){ - csId=1; - }else{ - csId=2; - } - return csId; - } - - //将java的数据类型转为excel数据类型 - @Override - public WriteCellData convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { - String cv=""; - if(0==value){ - cv="未入库"; - }else{ - cv="已入库"; - } - return new WriteCellData<>(cv); - } +package top.kuanghua.integrationfront.excel.cv; + +import com.alibaba.excel.converters.Converter; +import com.alibaba.excel.metadata.GlobalConfiguration; +import com.alibaba.excel.metadata.data.ReadCellData; +import com.alibaba.excel.metadata.data.WriteCellData; +import com.alibaba.excel.metadata.property.ExcelContentProperty; + +public class VciStatusImpCv implements Converter { + @Override + public Integer convertToJavaData(ReadCellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { + String stringValue = cellData.getStringValue(); + int csId; + if("未入库".equals(stringValue)){ + csId=0; + }else if("已入库".equals(stringValue)){ + csId=1; + }else{ + csId=2; + } + return csId; + } + + //将java的数据类型转为excel数据类型 + @Override + public WriteCellData convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { + String cv=""; + if(0==value){ + cv="未入库"; + }else{ + cv="已入库"; + } + return new WriteCellData<>(cv); + } } \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/excel/cv/VciTimeCv.java b/integration-front/src/main/java/top/kuanghua/integrationfront/excel/cv/VciTimeCv.java similarity index 94% rename from ty-user/src/main/java/top/kuanghua/tyuser/excel/cv/VciTimeCv.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/excel/cv/VciTimeCv.java index e11f0ff..c8d5e54 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/excel/cv/VciTimeCv.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/excel/cv/VciTimeCv.java @@ -1,28 +1,28 @@ -package top.kuanghua.tyuser.excel.cv; - -import com.alibaba.excel.converters.Converter; -import com.alibaba.excel.metadata.GlobalConfiguration; -import com.alibaba.excel.metadata.data.ReadCellData; -import com.alibaba.excel.metadata.data.WriteCellData; -import com.alibaba.excel.metadata.property.ExcelContentProperty; -import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; - -import java.text.SimpleDateFormat; -import java.util.Date; - -public class VciTimeCv implements Converter { - @Override - public Date convertToJavaData(ReadCellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { - String stringValue = cellData.getNumberValue().toString() ; - String DATE_FORMAT = "yyyyMMdd"; - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMAT); - Date parse = simpleDateFormat.parse(stringValue); - return parse; - } - - @Override - public WriteCellData convertToExcelData(Date value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { - return new WriteCellData<>(ObjectUtilsSelf.formatDateTime(value)); - } - +package top.kuanghua.integrationfront.excel.cv; + +import com.alibaba.excel.converters.Converter; +import com.alibaba.excel.metadata.GlobalConfiguration; +import com.alibaba.excel.metadata.data.ReadCellData; +import com.alibaba.excel.metadata.data.WriteCellData; +import com.alibaba.excel.metadata.property.ExcelContentProperty; +import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; + +import java.text.SimpleDateFormat; +import java.util.Date; + +public class VciTimeCv implements Converter { + @Override + public Date convertToJavaData(ReadCellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { + String stringValue = cellData.getNumberValue().toString() ; + String DATE_FORMAT = "yyyyMMdd"; + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMAT); + Date parse = simpleDateFormat.parse(stringValue); + return parse; + } + + @Override + public WriteCellData convertToExcelData(Date value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { + return new WriteCellData<>(ObjectUtilsSelf.formatDateTime(value)); + } + } \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/excel/imp/VciExcelImp.java b/integration-front/src/main/java/top/kuanghua/integrationfront/excel/imp/VciExcelImp.java similarity index 84% rename from ty-user/src/main/java/top/kuanghua/tyuser/excel/imp/VciExcelImp.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/excel/imp/VciExcelImp.java index 9fd85f9..578b9c3 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/excel/imp/VciExcelImp.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/excel/imp/VciExcelImp.java @@ -1,40 +1,40 @@ -package top.kuanghua.tyuser.excel.imp; - -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; -import top.kuanghua.tyuser.excel.cv.VciStatusImpCv; -import top.kuanghua.tyuser.excel.cv.VciTimeCv; - -import java.util.Date; - -/** - * VCI设备表(Vci)表实体类 - * @author kuanghua - * @since 2021-10-22 10:34:43 - */ -@Data -public class VciExcelImp{ - //供应商 - @ExcelProperty(value = "供应商") - private String supplier; - // 商品名称 - // 设备号 - @ExcelProperty(value = "设备号") - private String sn; - // 硬件版本 - @ExcelProperty(value = "硬件版本") - private String hardVersion; - // 商品规格 - @ExcelProperty(value = "商品规格") - private String productSpec; - // 入库单号(批次号) - @ExcelProperty(value = "入库单号(批次号)") - private String receiptNo; - // 入库状态 - @ExcelProperty(value = "入库状态",converter = VciStatusImpCv.class) - private Integer status; - // 入库时间 - @ExcelProperty(value = "入库时间",converter = VciTimeCv.class) - private Date createTime; -} - +package top.kuanghua.integrationfront.excel.imp; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; +import top.kuanghua.integrationfront.excel.cv.VciStatusImpCv; +import top.kuanghua.integrationfront.excel.cv.VciTimeCv; + +import java.util.Date; + +/** + * VCI设备表(Vci)表实体类 + * @author kuanghua + * @since 2021-10-22 10:34:43 + */ +@Data +public class VciExcelImp{ + //供应商 + @ExcelProperty(value = "供应商") + private String supplier; + // 商品名称 + // 设备号 + @ExcelProperty(value = "设备号") + private String sn; + // 硬件版本 + @ExcelProperty(value = "硬件版本") + private String hardVersion; + // 商品规格 + @ExcelProperty(value = "商品规格") + private String productSpec; + // 入库单号(批次号) + @ExcelProperty(value = "入库单号(批次号)") + private String receiptNo; + // 入库状态 + @ExcelProperty(value = "入库状态",converter = VciStatusImpCv.class) + private Integer status; + // 入库时间 + @ExcelProperty(value = "入库时间",converter = VciTimeCv.class) + private Date createTime; +} + diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/AccessMapper.java b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/AccessMapper.java similarity index 69% rename from ty-user/src/main/java/top/kuanghua/tyuser/mapper/AccessMapper.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/mapper/AccessMapper.java index 24012ff..e491c13 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/AccessMapper.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/AccessMapper.java @@ -1,14 +1,14 @@ -package top.kuanghua.tyuser.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import top.kuanghua.tyuser.entity.Access; - -/** - * 权限表(Access)表数据库访问层 - * - * @author kuanghua - * @since 2021-01-18 12:12:37 - */ -public interface AccessMapper extends BaseMapper { - +package top.kuanghua.integrationfront.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.integrationfront.entity.Access; + +/** + * 权限表(Access)表数据库访问层 + * + * @author kuanghua + * @since 2021-01-18 12:12:37 + */ +public interface AccessMapper extends BaseMapper { + } \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/AdminMapper.java b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/AdminMapper.java similarity index 84% rename from ty-user/src/main/java/top/kuanghua/tyuser/mapper/AdminMapper.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/mapper/AdminMapper.java index dc802f5..952659d 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/AdminMapper.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/AdminMapper.java @@ -1,21 +1,21 @@ -package top.kuanghua.tyuser.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.apache.ibatis.annotations.Param; -import top.kuanghua.tyuser.entity.Admin; - -import java.util.Map; - -/** - * 用户列表(Admin)表数据库访问层 - * - * @author kuanghua - * @since 2021-03-19 10:45:42 - */ -public interface AdminMapper extends BaseMapper { - -// List selectListAdmin(Admin admin); - Page> selectListAdmin(Page> pagination, @Param("admin") Admin admin); - -} +package top.kuanghua.integrationfront.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import top.kuanghua.integrationfront.entity.Admin; + +import java.util.Map; + +/** + * 用户列表(Admin)表数据库访问层 + * + * @author kuanghua + * @since 2021-03-19 10:45:42 + */ +public interface AdminMapper extends BaseMapper { + +// List selectListAdmin(Admin admin); + Page> selectListAdmin(Page> pagination, @Param("admin") Admin admin); + +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/BrandMapper.java b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/BrandMapper.java similarity index 54% rename from ty-user/src/main/java/top/kuanghua/tyuser/mapper/BrandMapper.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/mapper/BrandMapper.java index 71a79d2..1802051 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/BrandMapper.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/BrandMapper.java @@ -1,8 +1,8 @@ -package top.kuanghua.tyuser.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import top.kuanghua.tyuser.entity.Brand; - -public interface BrandMapper extends BaseMapper { - -} +package top.kuanghua.integrationfront.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.integrationfront.entity.Brand; + +public interface BrandMapper extends BaseMapper { + +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/ErrorCollectionMapper.java b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/ErrorCollectionMapper.java similarity index 56% rename from ty-user/src/main/java/top/kuanghua/tyuser/mapper/ErrorCollectionMapper.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/mapper/ErrorCollectionMapper.java index 0038cef..2502d46 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/ErrorCollectionMapper.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/ErrorCollectionMapper.java @@ -1,8 +1,8 @@ -package top.kuanghua.tyuser.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import top.kuanghua.tyuser.entity.ErrorCollection; - -public interface ErrorCollectionMapper extends BaseMapper { - -} +package top.kuanghua.integrationfront.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.integrationfront.entity.ErrorCollection; + +public interface ErrorCollectionMapper extends BaseMapper { + +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/MultiPageMapper.java b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/MultiPageMapper.java similarity index 88% rename from ty-user/src/main/java/top/kuanghua/tyuser/mapper/MultiPageMapper.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/mapper/MultiPageMapper.java index af9268b..042d753 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/MultiPageMapper.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/MultiPageMapper.java @@ -1,16 +1,16 @@ -package top.kuanghua.tyuser.mapper; - -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.apache.ibatis.annotations.Select; - -import java.util.Map; -/** - * @Title: MultiPageMapper - * @Description: - * @Auther: kuanghua - * @create 2020/12/15 19:34 - */ -public interface MultiPageMapper { - @Select("select phone,username,create_time from user") - Page> queryAllUsers(Page> pagination); -} +package top.kuanghua.integrationfront.mapper; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Select; + +import java.util.Map; +/** + * @Title: MultiPageMapper + * @Description: + * @Auther: kuanghua + * @create 2020/12/15 19:34 + */ +public interface MultiPageMapper { + @Select("select phone,username,create_time from user") + Page> queryAllUsers(Page> pagination); +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/RoleAccessMapper.java b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/RoleAccessMapper.java similarity index 70% rename from ty-user/src/main/java/top/kuanghua/tyuser/mapper/RoleAccessMapper.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/mapper/RoleAccessMapper.java index f3b2136..9ecc334 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/RoleAccessMapper.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/RoleAccessMapper.java @@ -1,14 +1,14 @@ -package top.kuanghua.tyuser.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import top.kuanghua.tyuser.entity.RoleAccess; - -/** - * 角色权限表(RoleAccess)表数据库访问层 - * - * @author kuanghua - * @since 2021-01-18 12:12:38 - */ -public interface RoleAccessMapper extends BaseMapper { - +package top.kuanghua.integrationfront.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.integrationfront.entity.RoleAccess; + +/** + * 角色权限表(RoleAccess)表数据库访问层 + * + * @author kuanghua + * @since 2021-01-18 12:12:38 + */ +public interface RoleAccessMapper extends BaseMapper { + } \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/RoleMapper.java b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/RoleMapper.java similarity index 69% rename from ty-user/src/main/java/top/kuanghua/tyuser/mapper/RoleMapper.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/mapper/RoleMapper.java index 9e088e9..3e09425 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/RoleMapper.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/RoleMapper.java @@ -1,14 +1,14 @@ -package top.kuanghua.tyuser.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import top.kuanghua.tyuser.entity.Role; - -/** - * 角色表(Role)表数据库访问层 - * - * @author kuanghua - * @since 2021-01-18 12:12:38 - */ -public interface RoleMapper extends BaseMapper { - +package top.kuanghua.integrationfront.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.integrationfront.entity.Role; + +/** + * 角色表(Role)表数据库访问层 + * + * @author kuanghua + * @since 2021-01-18 12:12:38 + */ +public interface RoleMapper extends BaseMapper { + } \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/UserMapper.java b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/UserMapper.java similarity index 72% rename from ty-user/src/main/java/top/kuanghua/tyuser/mapper/UserMapper.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/mapper/UserMapper.java index a56cd03..b96a25f 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/UserMapper.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/UserMapper.java @@ -1,15 +1,15 @@ -package top.kuanghua.tyuser.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import top.kuanghua.tyuser.entity.User; - - -/** - * 用户表;uploadFileBtn;downloadFilebtn(User)表数据库访问层 - * - * @author kuanghua - * @since 2020-12-13 16:13:15 - */ -public interface UserMapper extends BaseMapper { - +package top.kuanghua.integrationfront.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.integrationfront.entity.User; + + +/** + * 用户表;uploadFileBtn;downloadFilebtn(User)表数据库访问层 + * + * @author kuanghua + * @since 2020-12-13 16:13:15 + */ +public interface UserMapper extends BaseMapper { + } \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/UserRoleMapper.java b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/UserRoleMapper.java similarity index 70% rename from ty-user/src/main/java/top/kuanghua/tyuser/mapper/UserRoleMapper.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/mapper/UserRoleMapper.java index d776d97..24eccec 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/UserRoleMapper.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/UserRoleMapper.java @@ -1,14 +1,14 @@ -package top.kuanghua.tyuser.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import top.kuanghua.tyuser.entity.UserRole; - -/** - * 用户角色表(UserRole)表数据库访问层 - * - * @author kuanghua - * @since 2021-01-18 12:12:37 - */ -public interface UserRoleMapper extends BaseMapper { - +package top.kuanghua.integrationfront.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.integrationfront.entity.UserRole; + +/** + * 用户角色表(UserRole)表数据库访问层 + * + * @author kuanghua + * @since 2021-01-18 12:12:37 + */ +public interface UserRoleMapper extends BaseMapper { + } \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/VciMapper.java b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/VciMapper.java similarity index 54% rename from ty-user/src/main/java/top/kuanghua/tyuser/mapper/VciMapper.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/mapper/VciMapper.java index 7f1e3c9..e059109 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/mapper/VciMapper.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/VciMapper.java @@ -1,8 +1,8 @@ -package top.kuanghua.tyuser.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import top.kuanghua.tyuser.entity.Vci; - -public interface VciMapper extends BaseMapper { - -} +package top.kuanghua.integrationfront.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.integrationfront.entity.Vci; + +public interface VciMapper extends BaseMapper { + +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/service/AccessService.java b/integration-front/src/main/java/top/kuanghua/integrationfront/service/AccessService.java similarity index 90% rename from ty-user/src/main/java/top/kuanghua/tyuser/service/AccessService.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/service/AccessService.java index a93213c..b034640 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/service/AccessService.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/service/AccessService.java @@ -1,49 +1,49 @@ -package top.kuanghua.tyuser.service; - -import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.stereotype.Service; -import top.kuanghua.tyuser.entity.Access; -import top.kuanghua.tyuser.mapper.AccessMapper; - -import javax.annotation.Resource; -import java.util.*; -import java.util.stream.Collectors; - -/** - * @author kuanghua - * @since 2020-10-27 20:54:24 - */ -@Service -public class AccessService { - - @Resource - private AccessMapper accessMapper; - - public Page selectPage(Integer pageNum, Integer pageSize, - Access access) { - QueryWrapper queryWrapper = new QueryWrapper<>(access); - return this.accessMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); - } - - public int insert(Access access) { - return this.accessMapper.insert(access); - } - - public int updateById(Access access) { - return this.accessMapper.updateById(access); - } - /*查询权限树*/ - public List selectAccessTree(){ - /*根据id查询parent_id为0的父元素在查询下面的子元素*/ - List accessList = this.accessMapper.selectList(new QueryWrapper().eq("parent_id", 0)); - List listStreamMap = accessList.stream().map(mItem -> { - Map coversMap = JSON.parseObject(JSON.toJSONString(mItem), Map.class); - List selectList = this.accessMapper.selectList(new QueryWrapper().eq("parent_id", mItem.getId())); - coversMap.put("children",selectList); - return coversMap; - }).collect(Collectors.toList()); - return listStreamMap; - } +package top.kuanghua.integrationfront.service; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Service; +import top.kuanghua.integrationfront.entity.Access; +import top.kuanghua.integrationfront.mapper.AccessMapper; + +import javax.annotation.Resource; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author kuanghua + * @since 2020-10-27 20:54:24 + */ +@Service +public class AccessService { + + @Resource + private AccessMapper accessMapper; + + public Page selectPage(Integer pageNum, Integer pageSize, + Access access) { + QueryWrapper queryWrapper = new QueryWrapper<>(access); + return this.accessMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); + } + + public int insert(Access access) { + return this.accessMapper.insert(access); + } + + public int updateById(Access access) { + return this.accessMapper.updateById(access); + } + /*查询权限树*/ + public List selectAccessTree(){ + /*根据id查询parent_id为0的父元素在查询下面的子元素*/ + List accessList = this.accessMapper.selectList(new QueryWrapper().eq("parent_id", 0)); + List listStreamMap = accessList.stream().map(mItem -> { + Map coversMap = JSON.parseObject(JSON.toJSONString(mItem), Map.class); + List selectList = this.accessMapper.selectList(new QueryWrapper().eq("parent_id", mItem.getId())); + coversMap.put("children",selectList); + return coversMap; + }).collect(Collectors.toList()); + return listStreamMap; + } } \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/service/AdminService.java b/integration-front/src/main/java/top/kuanghua/integrationfront/service/AdminService.java similarity index 83% rename from ty-user/src/main/java/top/kuanghua/tyuser/service/AdminService.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/service/AdminService.java index 1ce4297..516747a 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/service/AdminService.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/service/AdminService.java @@ -1,41 +1,41 @@ -package top.kuanghua.tyuser.service; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.stereotype.Service; -import top.kuanghua.tyuser.entity.Admin; -import top.kuanghua.tyuser.mapper.AdminMapper; - -import javax.annotation.Resource; - -/** - * (Admin) - * - * @author kuanghua - * @since 2020-10-27 20:54:24 - */ -@Service -public class AdminService { - - @Resource - private AdminMapper adminMapper; - - public Page selectPage(Integer pageNum, Integer pageSize, - Admin admin) { - QueryWrapper queryWrapper = new QueryWrapper<>(admin); - return this.adminMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); - } - - public int insert(Admin admin) { - return this.adminMapper.insert(admin); - } - - public int updateById(Admin admin) { - return this.adminMapper.updateById(admin); - } - - - // - - -} +package top.kuanghua.integrationfront.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Service; +import top.kuanghua.integrationfront.entity.Admin; +import top.kuanghua.integrationfront.mapper.AdminMapper; + +import javax.annotation.Resource; + +/** + * (Admin) + * + * @author kuanghua + * @since 2020-10-27 20:54:24 + */ +@Service +public class AdminService { + + @Resource + private AdminMapper adminMapper; + + public Page selectPage(Integer pageNum, Integer pageSize, + Admin admin) { + QueryWrapper queryWrapper = new QueryWrapper<>(admin); + return this.adminMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); + } + + public int insert(Admin admin) { + return this.adminMapper.insert(admin); + } + + public int updateById(Admin admin) { + return this.adminMapper.updateById(admin); + } + + + // + + +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/service/BrandService.java b/integration-front/src/main/java/top/kuanghua/integrationfront/service/BrandService.java similarity index 87% rename from ty-user/src/main/java/top/kuanghua/tyuser/service/BrandService.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/service/BrandService.java index 8a0a519..a5578db 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/service/BrandService.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/service/BrandService.java @@ -1,51 +1,51 @@ -package top.kuanghua.tyuser.service; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.stereotype.Service; -import top.kuanghua.tyuser.entity.Brand; -import top.kuanghua.tyuser.mapper.BrandMapper; - -import javax.annotation.Resource; -import java.util.List; - -/** - * (Brand) - * - * @author kuanghua - * @since 2021-09-15 11:54:48 - */ -@Service -public class BrandService { - - @Resource - private BrandMapper brandMapper; - - public Page selectPage(Integer pageNum, Integer pageSize, QueryWrapper queryWrapper) { - return this.brandMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); - } - - public Brand selectById(Integer id) { - return this.brandMapper.selectById(id); - } - - public List selectBatchIds(List idList) { - return this.brandMapper.selectBatchIds(idList); - } - - public int insert(Brand brand) { - return this.brandMapper.insert(brand); - } - - public int updateById(Brand brand) { - return this.brandMapper.updateById(brand); - } - - public int deleteById(Integer id) { - return this.brandMapper.deleteById(id); - } - - public int deleteBatchIds(List idList) { - return this.brandMapper.deleteBatchIds(idList); - } -} +package top.kuanghua.integrationfront.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Service; +import top.kuanghua.integrationfront.entity.Brand; +import top.kuanghua.integrationfront.mapper.BrandMapper; + +import javax.annotation.Resource; +import java.util.List; + +/** + * (Brand) + * + * @author kuanghua + * @since 2021-09-15 11:54:48 + */ +@Service +public class BrandService { + + @Resource + private BrandMapper brandMapper; + + public Page selectPage(Integer pageNum, Integer pageSize, QueryWrapper queryWrapper) { + return this.brandMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); + } + + public Brand selectById(Integer id) { + return this.brandMapper.selectById(id); + } + + public List selectBatchIds(List idList) { + return this.brandMapper.selectBatchIds(idList); + } + + public int insert(Brand brand) { + return this.brandMapper.insert(brand); + } + + public int updateById(Brand brand) { + return this.brandMapper.updateById(brand); + } + + public int deleteById(Integer id) { + return this.brandMapper.deleteById(id); + } + + public int deleteBatchIds(List idList) { + return this.brandMapper.deleteBatchIds(idList); + } +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/service/ErrorCollectionService.java b/integration-front/src/main/java/top/kuanghua/integrationfront/service/ErrorCollectionService.java similarity index 88% rename from ty-user/src/main/java/top/kuanghua/tyuser/service/ErrorCollectionService.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/service/ErrorCollectionService.java index 8e6ae57..b773558 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/service/ErrorCollectionService.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/service/ErrorCollectionService.java @@ -1,51 +1,51 @@ -package top.kuanghua.tyuser.service; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.stereotype.Service; -import top.kuanghua.tyuser.entity.ErrorCollection; -import top.kuanghua.tyuser.mapper.ErrorCollectionMapper; - -import javax.annotation.Resource; -import java.util.List; - -/** - * (ErrorCollection) - * - * @author kuanghua - * @since 2021-10-08 11:37:24 - */ -@Service -public class ErrorCollectionService { - - @Resource - private ErrorCollectionMapper errorCollectionMapper; - - public Page selectPage(Integer pageNum, Integer pageSize, QueryWrapper queryWrapper) { - return this.errorCollectionMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); - } - - public ErrorCollection selectById(Integer id) { - return this.errorCollectionMapper.selectById(id); - } - - public List selectBatchIds(List idList) { - return this.errorCollectionMapper.selectBatchIds(idList); - } - - public int insert(ErrorCollection errorCollection) { - return this.errorCollectionMapper.insert(errorCollection); - } - - public int updateById(ErrorCollection errorCollection) { - return this.errorCollectionMapper.updateById(errorCollection); - } - - public int deleteById(Integer id) { - return this.errorCollectionMapper.deleteById(id); - } - - public int deleteBatchIds(List idList) { - return this.errorCollectionMapper.deleteBatchIds(idList); - } -} +package top.kuanghua.integrationfront.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Service; +import top.kuanghua.integrationfront.entity.ErrorCollection; +import top.kuanghua.integrationfront.mapper.ErrorCollectionMapper; + +import javax.annotation.Resource; +import java.util.List; + +/** + * (ErrorCollection) + * + * @author kuanghua + * @since 2021-10-08 11:37:24 + */ +@Service +public class ErrorCollectionService { + + @Resource + private ErrorCollectionMapper errorCollectionMapper; + + public Page selectPage(Integer pageNum, Integer pageSize, QueryWrapper queryWrapper) { + return this.errorCollectionMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); + } + + public ErrorCollection selectById(Integer id) { + return this.errorCollectionMapper.selectById(id); + } + + public List selectBatchIds(List idList) { + return this.errorCollectionMapper.selectBatchIds(idList); + } + + public int insert(ErrorCollection errorCollection) { + return this.errorCollectionMapper.insert(errorCollection); + } + + public int updateById(ErrorCollection errorCollection) { + return this.errorCollectionMapper.updateById(errorCollection); + } + + public int deleteById(Integer id) { + return this.errorCollectionMapper.deleteById(id); + } + + public int deleteBatchIds(List idList) { + return this.errorCollectionMapper.deleteBatchIds(idList); + } +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/service/RoleAccessService.java b/integration-front/src/main/java/top/kuanghua/integrationfront/service/RoleAccessService.java similarity index 84% rename from ty-user/src/main/java/top/kuanghua/tyuser/service/RoleAccessService.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/service/RoleAccessService.java index cdb6eec..5c44564 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/service/RoleAccessService.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/service/RoleAccessService.java @@ -1,37 +1,37 @@ -package top.kuanghua.tyuser.service; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.stereotype.Service; -import top.kuanghua.tyuser.entity.RoleAccess; -import top.kuanghua.tyuser.mapper.RoleAccessMapper; - -import javax.annotation.Resource; - -/** - * (RoleAccess) - * - * @author kuanghua - * @since 2020-10-27 20:54:24 - */ -@Service -public class RoleAccessService { - - @Resource - private RoleAccessMapper roleAccessMapper; - - public Page selectPage(Integer pageNum, Integer pageSize, - RoleAccess roleAccess) { - QueryWrapper queryWrapper = new QueryWrapper<>(roleAccess); - return this.roleAccessMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); - } - - public int insert(RoleAccess roleAccess) { - return this.roleAccessMapper.insert(roleAccess); - } - - public int updateById(RoleAccess roleAccess) { - return this.roleAccessMapper.updateById(roleAccess); - } - +package top.kuanghua.integrationfront.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Service; +import top.kuanghua.integrationfront.entity.RoleAccess; +import top.kuanghua.integrationfront.mapper.RoleAccessMapper; + +import javax.annotation.Resource; + +/** + * (RoleAccess) + * + * @author kuanghua + * @since 2020-10-27 20:54:24 + */ +@Service +public class RoleAccessService { + + @Resource + private RoleAccessMapper roleAccessMapper; + + public Page selectPage(Integer pageNum, Integer pageSize, + RoleAccess roleAccess) { + QueryWrapper queryWrapper = new QueryWrapper<>(roleAccess); + return this.roleAccessMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); + } + + public int insert(RoleAccess roleAccess) { + return this.roleAccessMapper.insert(roleAccess); + } + + public int updateById(RoleAccess roleAccess) { + return this.roleAccessMapper.updateById(roleAccess); + } + } \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/service/RoleService.java b/integration-front/src/main/java/top/kuanghua/integrationfront/service/RoleService.java similarity index 83% rename from ty-user/src/main/java/top/kuanghua/tyuser/service/RoleService.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/service/RoleService.java index 48ab56d..4bdf8e4 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/service/RoleService.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/service/RoleService.java @@ -1,37 +1,37 @@ -package top.kuanghua.tyuser.service; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.stereotype.Service; -import top.kuanghua.tyuser.entity.Role; -import top.kuanghua.tyuser.mapper.RoleMapper; - -import javax.annotation.Resource; - -/** - * (Role) - * - * @author kuanghua - * @since 2020-10-27 20:54:24 - */ -@Service -public class RoleService { - - @Resource - private RoleMapper roleMapper; - - public Page selectPage(Integer pageNum, Integer pageSize, - Role role) { - QueryWrapper queryWrapper = new QueryWrapper<>(role); - return this.roleMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); - } - - public int insert(Role role) { - return this.roleMapper.insert(role); - } - - public int updateById(Role role) { - return this.roleMapper.updateById(role); - } - +package top.kuanghua.integrationfront.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Service; +import top.kuanghua.integrationfront.entity.Role; +import top.kuanghua.integrationfront.mapper.RoleMapper; + +import javax.annotation.Resource; + +/** + * (Role) + * + * @author kuanghua + * @since 2020-10-27 20:54:24 + */ +@Service +public class RoleService { + + @Resource + private RoleMapper roleMapper; + + public Page selectPage(Integer pageNum, Integer pageSize, + Role role) { + QueryWrapper queryWrapper = new QueryWrapper<>(role); + return this.roleMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); + } + + public int insert(Role role) { + return this.roleMapper.insert(role); + } + + public int updateById(Role role) { + return this.roleMapper.updateById(role); + } + } \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/service/UserRoleService.java b/integration-front/src/main/java/top/kuanghua/integrationfront/service/UserRoleService.java similarity index 84% rename from ty-user/src/main/java/top/kuanghua/tyuser/service/UserRoleService.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/service/UserRoleService.java index 3d6da4c..827312b 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/service/UserRoleService.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/service/UserRoleService.java @@ -1,37 +1,37 @@ -package top.kuanghua.tyuser.service; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.stereotype.Service; -import top.kuanghua.tyuser.entity.UserRole; -import top.kuanghua.tyuser.mapper.UserRoleMapper; - -import javax.annotation.Resource; - -/** - * (UserRole) - * - * @author kuanghua - * @since 2020-10-27 20:54:24 - */ -@Service -public class UserRoleService { - - @Resource - private UserRoleMapper userRoleMapper; - - public Page selectPage(Integer pageNum, Integer pageSize, - UserRole userRole) { - QueryWrapper queryWrapper = new QueryWrapper<>(userRole); - return this.userRoleMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); - } - - public int insert(UserRole userRole) { - return this.userRoleMapper.insert(userRole); - } - - public int updateById(UserRole userRole) { - return this.userRoleMapper.updateById(userRole); - } - +package top.kuanghua.integrationfront.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Service; +import top.kuanghua.integrationfront.entity.UserRole; +import top.kuanghua.integrationfront.mapper.UserRoleMapper; + +import javax.annotation.Resource; + +/** + * (UserRole) + * + * @author kuanghua + * @since 2020-10-27 20:54:24 + */ +@Service +public class UserRoleService { + + @Resource + private UserRoleMapper userRoleMapper; + + public Page selectPage(Integer pageNum, Integer pageSize, + UserRole userRole) { + QueryWrapper queryWrapper = new QueryWrapper<>(userRole); + return this.userRoleMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); + } + + public int insert(UserRole userRole) { + return this.userRoleMapper.insert(userRole); + } + + public int updateById(UserRole userRole) { + return this.userRoleMapper.updateById(userRole); + } + } \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/service/UserService.java b/integration-front/src/main/java/top/kuanghua/integrationfront/service/UserService.java similarity index 70% rename from ty-user/src/main/java/top/kuanghua/tyuser/service/UserService.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/service/UserService.java index df5a045..96abf0d 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/service/UserService.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/service/UserService.java @@ -1,232 +1,228 @@ -package top.kuanghua.tyuser.service; - -import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.ObjectUtils; -import top.kuanghua.feign.tyauth.feign.TokenFeign; -import top.kuanghua.feign.tyexecl.feign.ExcelFeign; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.khcomomon.utils.CodecUtils; -import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; -import top.kuanghua.tyuser.entity.User; -import top.kuanghua.tyuser.mapper.UserMapper; - -import javax.annotation.Resource; -import java.text.MessageFormat; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -/** - * (User) - * - * @author kuanghua - * @since 2020-10-27 20:54:24 - */ -@Service -@Slf4j -public class UserService { - @Resource - private UserMapper userMapper; - - @Resource - private ExcelFeign excelFeign; - - @Resource - private TokenFeign tokenFeign; - @Autowired - private StringRedisTemplate stringRedisTemplate; - - public void registry(User user, String code) throws Exception { - QueryWrapper queryWrapper = new QueryWrapper() - .select("phone") - .eq("phone", user.getPhone()); - Boolean bl = this.userMapper.selectCount(queryWrapper) == 1; - if (bl) { - throw new Exception("手机号已存在"); - } - String codeStr = stringRedisTemplate.opsForValue().get("user:code:phone:" + user.getPhone()); - if (StringUtils.isEmpty(codeStr)) { - throw new Exception("验证码失效,请重新获取"); - } - if (!Objects.equals(codeStr, code)) { - throw new Exception("验证码输入错误"); - } - String salt = CodecUtils.generateSalt(); - user.setSalt(salt); - user.setPassword(CodecUtils.md5Hex(user.getPassword(), salt)); - boolean insertBl = this.userMapper.insert(user) == 1; - if (insertBl) { - //删除redis中的code - this.stringRedisTemplate.delete("user:code:phone:" + user.getPhone()); - } else { - throw new Exception("用户注册失败"); - } - } - - @Transactional(rollbackFor = Exception.class) - public Object insert(User user) { - return this.userMapper.insert(user); - } - - - @Transactional(rollbackFor = Exception.class) - public Object updateById(User user) { - int updateById = this.userMapper.updateById(user); - int i = 10 / 0; - return updateById; - } - - /** - * 登出 - */ - public void loginOut() { - return; - } - - /** - * 用户注册 - * - * @param code - * @param username - * @param password - */ - public void userRegister(String email, String code, String username, String password) { - - //user表中查询用户是否重复 - QueryWrapper queryWrapper = new QueryWrapper() - .eq("username", username); - if (this.userMapper.selectCount(queryWrapper) == 1) { - throw new RuntimeException(MessageFormat.format("账号【{0}】已存在,请误重复注册", username)); - } - - //去ty-execl中查询用户名是否存在 - ResResult resResult = excelFeign.selectExcelByUser(username); - List list = ObjectUtilsSelf.parseResToList(resResult); - if (list.size() == 0) { - throw new RuntimeException(MessageFormat.format("考勤表中不存在用户名【{0}】", username)); - } - - //校验验证码 - String codeInfo = stringRedisTemplate.opsForValue().get("email.code.routing.name" + email); - Map map = JSON.parseObject(codeInfo); - if (ObjectUtilsSelf.isEmpty(map)) { - throw new RuntimeException("验证码失效,请重新获取"); - } - if (!Objects.equals(map.get("code"), code)) { - throw new RuntimeException("验证码不正确"); - } - //插入数据,用户添加成功 - User userEt = new User(); - userEt.setPassword(password); - userEt.setEmail(email); - userEt.setUsername(username); - //添加盐设置密码为md5 - String salt = CodecUtils.generateSalt(); - userEt.setSalt(salt); - userEt.setPassword(CodecUtils.md5Hex(userEt.getPassword(), salt)); - boolean inResult = userMapper.insert(userEt) == 1; - if (!inResult) { - throw new RuntimeException("插入失败"); - } - } - - /** - * 用户登录 - * - * @param user - * @return - * @throws Exception - */ - public HashMap loginValid(User user) { - QueryWrapper phoneQW = new QueryWrapper().like("email", user.getEmail()) - .or().eq("username", user.getUsername()); - User resUser = this.userMapper.selectOne(phoneQW); - if (ObjectUtils.isEmpty(resUser)) { - throw new RuntimeException("用户不存在"); - } - - if (!resUser.getPassword().equals(CodecUtils.md5Hex(user.getPassword(), resUser.getSalt()))) { - throw new RuntimeException("用户名或密码错误"); - } - //生成jwt token - HashMap hm = new HashMap<>(); - hm.put("username", resUser.getUsername()); - hm.put("email", resUser.getEmail()); - ResResult resResult = tokenFeign.generateToken(hm); - - hm.put("jwtToken", resResult.getData()); - return hm; - } - - /*修改用户密码*/ - public void changePassword(String username, String oldPassword, String newPassword) { - //校验oldPassword是否正确 - QueryWrapper qw = new QueryWrapper() - .eq("username", username); - - User resUser = this.userMapper.selectOne(qw); - if (ObjectUtilsSelf.isEmpty(resUser)) { - throw new RuntimeException("用户不存在"); - } - if (!resUser.getPassword().equals(CodecUtils.md5Hex(oldPassword, resUser.getSalt()))) { - throw new RuntimeException("密码错误"); - } - - //设置新的密码 - String salt = CodecUtils.generateSalt(); - resUser.setSalt(salt); - resUser.setPassword(CodecUtils.md5Hex(newPassword, salt)); - boolean insertBl = this.userMapper.updateById(resUser) == 1; - if (!insertBl) { - throw new RuntimeException("修改密码失败"); - } - } - - - /** - * 插入用户 - * - * @param username 用户名 - */ - public void insertUser(String username) { - //先查询当前用户是否存在不存在则导入 - QueryWrapper qw = new QueryWrapper() - .eq("username", username); - - User resUser = this.userMapper.selectOne(qw); - if (ObjectUtilsSelf.isEmpty(resUser)) { - //添加盐设置密码为md5 - User user = new User(); - user.setPassword("123456"); - user.setUsername(username); - String salt = CodecUtils.generateSalt(); - user.setSalt(salt); - user.setPassword(CodecUtils.md5Hex(user.getPassword(), salt)); - userMapper.insert(user); - } - } - - - /** - * 重置用用户名:如果用用户存在先删除原有用户在新增一个用户,没有则新建用户 - */ - public void resetUser(String username) { - QueryWrapper userWrap = new QueryWrapper().eq("username", username); - List users = userMapper.selectList(userWrap); - //用户存在,先删除用户 - if (users.size() == 1) { - userMapper.delete(userWrap); - } else { - //新增用户 - this.insertUser(username); - } - } +package top.kuanghua.integrationfront.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ObjectUtils; +import top.kuanghua.feign.tyauth.feign.TokenFeign; +import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.khcomomon.utils.CodecUtils; +import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; +import top.kuanghua.integrationfront.entity.User; +import top.kuanghua.integrationfront.mapper.UserMapper; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; +import java.util.Objects; + +/** + * (User) + * + * @author kuanghua + * @since 2020-10-27 20:54:24 + */ +@Service +@Slf4j +public class UserService { + @Resource + private UserMapper userMapper; + +// @Resource +// private ExcelFeign excelFeign; + + @Resource + private TokenFeign tokenFeign; + @Autowired + private StringRedisTemplate stringRedisTemplate; + + public void registry(User user, String code) throws Exception { + QueryWrapper queryWrapper = new QueryWrapper() + .select("phone") + .eq("phone", user.getPhone()); + Boolean bl = this.userMapper.selectCount(queryWrapper) == 1; + if (bl) { + throw new Exception("手机号已存在"); + } + String codeStr = stringRedisTemplate.opsForValue().get("user:code:phone:" + user.getPhone()); + if (StringUtils.isEmpty(codeStr)) { + throw new Exception("验证码失效,请重新获取"); + } + if (!Objects.equals(codeStr, code)) { + throw new Exception("验证码输入错误"); + } + String salt = CodecUtils.generateSalt(); + user.setSalt(salt); + user.setPassword(CodecUtils.md5Hex(user.getPassword(), salt)); + boolean insertBl = this.userMapper.insert(user) == 1; + if (insertBl) { + //删除redis中的code + this.stringRedisTemplate.delete("user:code:phone:" + user.getPhone()); + } else { + throw new Exception("用户注册失败"); + } + } + + @Transactional(rollbackFor = Exception.class) + public Object insert(User user) { + return this.userMapper.insert(user); + } + + + @Transactional(rollbackFor = Exception.class) + public Object updateById(User user) { + int updateById = this.userMapper.updateById(user); + int i = 10 / 0; + return updateById; + } + + /** + * 登出 + */ + public void loginOut() { + return; + } +// +// /** +// * 用户注册 +// * +// * @param code +// * @param username +// * @param password +// */ +// public void userRegister(String email, String code, String username, String password) { +// +// //user表中查询用户是否重复 +// QueryWrapper queryWrapper = new QueryWrapper() +// .eq("username", username); +// if (this.userMapper.selectCount(queryWrapper) == 1) { +// throw new RuntimeException(MessageFormat.format("账号【{0}】已存在,请误重复注册", username)); +// } +// +// //去ty-execl中查询用户名是否存在 +// ResResult resResult = excelFeign.selectExcelByUser(username); +// List list = ObjectUtilsSelf.parseResToList(resResult); +// if (list.size() == 0) { +// throw new RuntimeException(MessageFormat.format("考勤表中不存在用户名【{0}】", username)); +// } +// +// //校验验证码 +// String codeInfo = stringRedisTemplate.opsForValue().get("email.code.routing.name" + email); +// Map map = JSON.parseObject(codeInfo); +// if (ObjectUtilsSelf.isEmpty(map)) { +// throw new RuntimeException("验证码失效,请重新获取"); +// } +// if (!Objects.equals(map.get("code"), code)) { +// throw new RuntimeException("验证码不正确"); +// } +// //插入数据,用户添加成功 +// User userEt = new User(); +// userEt.setPassword(password); +// userEt.setEmail(email); +// userEt.setUsername(username); +// //添加盐设置密码为md5 +// String salt = CodecUtils.generateSalt(); +// userEt.setSalt(salt); +// userEt.setPassword(CodecUtils.md5Hex(userEt.getPassword(), salt)); +// boolean inResult = userMapper.insert(userEt) == 1; +// if (!inResult) { +// throw new RuntimeException("插入失败"); +// } +// } + + /** + * 用户登录 + * + * @param user + * @return + * @throws Exception + */ + public HashMap loginValid(User user) { + QueryWrapper phoneQW = new QueryWrapper().like("email", user.getEmail()) + .or().eq("username", user.getUsername()); + User resUser = this.userMapper.selectOne(phoneQW); + if (ObjectUtils.isEmpty(resUser)) { + throw new RuntimeException("用户不存在"); + } + + if (!resUser.getPassword().equals(CodecUtils.md5Hex(user.getPassword(), resUser.getSalt()))) { + throw new RuntimeException("用户名或密码错误"); + } + //生成jwt token + HashMap hm = new HashMap<>(); + hm.put("username", resUser.getUsername()); + hm.put("email", resUser.getEmail()); + ResResult resResult = tokenFeign.generateToken(hm); + + hm.put("jwtToken", resResult.getData()); + return hm; + } + + /*修改用户密码*/ + public void changePassword(String username, String oldPassword, String newPassword) { + //校验oldPassword是否正确 + QueryWrapper qw = new QueryWrapper() + .eq("username", username); + + User resUser = this.userMapper.selectOne(qw); + if (ObjectUtilsSelf.isEmpty(resUser)) { + throw new RuntimeException("用户不存在"); + } + if (!resUser.getPassword().equals(CodecUtils.md5Hex(oldPassword, resUser.getSalt()))) { + throw new RuntimeException("密码错误"); + } + + //设置新的密码 + String salt = CodecUtils.generateSalt(); + resUser.setSalt(salt); + resUser.setPassword(CodecUtils.md5Hex(newPassword, salt)); + boolean insertBl = this.userMapper.updateById(resUser) == 1; + if (!insertBl) { + throw new RuntimeException("修改密码失败"); + } + } + + + /** + * 插入用户 + * + * @param username 用户名 + */ + public void insertUser(String username) { + //先查询当前用户是否存在不存在则导入 + QueryWrapper qw = new QueryWrapper() + .eq("username", username); + + User resUser = this.userMapper.selectOne(qw); + if (ObjectUtilsSelf.isEmpty(resUser)) { + //添加盐设置密码为md5 + User user = new User(); + user.setPassword("123456"); + user.setUsername(username); + String salt = CodecUtils.generateSalt(); + user.setSalt(salt); + user.setPassword(CodecUtils.md5Hex(user.getPassword(), salt)); + userMapper.insert(user); + } + } + + + /** + * 重置用用户名:如果用用户存在先删除原有用户在新增一个用户,没有则新建用户 + */ + public void resetUser(String username) { + QueryWrapper userWrap = new QueryWrapper().eq("username", username); + List users = userMapper.selectList(userWrap); + //用户存在,先删除用户 + if (users.size() == 1) { + userMapper.delete(userWrap); + } else { + //新增用户 + this.insertUser(username); + } + } } \ No newline at end of file diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/service/VciService.java b/integration-front/src/main/java/top/kuanghua/integrationfront/service/VciService.java similarity index 91% rename from ty-user/src/main/java/top/kuanghua/tyuser/service/VciService.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/service/VciService.java index 80ba931..10280f1 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/service/VciService.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/service/VciService.java @@ -1,133 +1,133 @@ -package top.kuanghua.tyuser.service; - -import com.alibaba.excel.EasyExcel; -import com.alibaba.excel.context.AnalysisContext; -import com.alibaba.excel.exception.ExcelDataConvertException; -import com.alibaba.excel.read.listener.ReadListener; -import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.stereotype.Service; -import top.kuanghua.tyuser.entity.Vci; -import top.kuanghua.tyuser.excel.imp.VciExcelImp; -import top.kuanghua.tyuser.mapper.VciMapper; -import top.kuanghua.tyuser.vo.ExcelCheckResult; - -import javax.annotation.Resource; -import java.io.InputStream; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.List; - -/** - * (Vci) - * - * @author kuanghua - * @since 2021-10-20 16:14:17 - */ -@Service -public class VciService { - - @Resource - private VciMapper vciMapper; - - public Page selectPage(Integer pageNum, Integer pageSize, QueryWrapper queryWrapper) { - return this.vciMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); - } - - public Vci selectById(Integer id) { - return this.vciMapper.selectById(id); - } - - public List selectBatchIds(List idList) { - return this.vciMapper.selectBatchIds(idList); - } - - public int insert(Vci vci) { - return this.vciMapper.insert(vci); - } - - public int updateById(Vci vci) { - return this.vciMapper.updateById(vci); - } - - public int deleteById(Integer id) { - return this.vciMapper.deleteById(id); - } - - public int deleteBatchIds(List idList) { - return this.vciMapper.deleteBatchIds(idList); - } - - /** - * 导入文件校验 - * @param fileName - * @return - */ - public ExcelCheckResult validExcel(InputStream fileName) { - List errLogList = new ArrayList<>(); - List successList = new ArrayList<>(); - EasyExcel.read(fileName, VciExcelImp.class, new ReadListener() { - /** - * 单次缓存的数据量 - */ - static final int BATCH_COUNT = 3000; - /** - * 临时存储 - */ - private List cachedData = new ArrayList<>(BATCH_COUNT); - - @Override - public void onException(Exception exception, AnalysisContext context) throws Exception { - // 如果是某一个单元格的转换异常 能获取到具体行号 - // 如果要获取头的信息 配合invokeHeadMap使用 - if (exception instanceof ExcelDataConvertException) { - ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception; - - String formatString = MessageFormat.format("第{0}行,第{1}列解析异常", - excelDataConvertException.getRowIndex(), excelDataConvertException.getColumnIndex()); - - errLogList.add(formatString); - - } - } - - @Override - public void invoke(VciExcelImp data, AnalysisContext context) { - successList.add(data); - cachedData.add(data); - if (cachedData.size() >= BATCH_COUNT) { - saveData(); - // 存储完成清理 list - cachedData = new ArrayList<>(BATCH_COUNT); - } - } - - @Override - public void doAfterAllAnalysed(AnalysisContext context) { - - } - - /** - * 加上存储数据库 - */ - private void saveData() { - - - } - }).sheet().headRowNumber(1).doRead(); - return new ExcelCheckResult<>(errLogList, successList); - } - - /** - * 导入 - * @param listData - */ - public void importExcel(List listData){ - listData.forEach((item) -> { - //售后维修表 - Vci vci = JSON.parseObject(JSON.toJSONString(item), Vci.class); - vciMapper.insert(vci); - }); - } -} +package top.kuanghua.integrationfront.service; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.exception.ExcelDataConvertException; +import com.alibaba.excel.read.listener.ReadListener; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Service; +import top.kuanghua.integrationfront.entity.Vci; +import top.kuanghua.integrationfront.excel.imp.VciExcelImp; +import top.kuanghua.integrationfront.mapper.VciMapper; +import top.kuanghua.integrationfront.vo.ExcelCheckResult; + +import javax.annotation.Resource; +import java.io.InputStream; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; + +/** + * (Vci) + * + * @author kuanghua + * @since 2021-10-20 16:14:17 + */ +@Service +public class VciService { + + @Resource + private VciMapper vciMapper; + + public Page selectPage(Integer pageNum, Integer pageSize, QueryWrapper queryWrapper) { + return this.vciMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); + } + + public Vci selectById(Integer id) { + return this.vciMapper.selectById(id); + } + + public List selectBatchIds(List idList) { + return this.vciMapper.selectBatchIds(idList); + } + + public int insert(Vci vci) { + return this.vciMapper.insert(vci); + } + + public int updateById(Vci vci) { + return this.vciMapper.updateById(vci); + } + + public int deleteById(Integer id) { + return this.vciMapper.deleteById(id); + } + + public int deleteBatchIds(List idList) { + return this.vciMapper.deleteBatchIds(idList); + } + + /** + * 导入文件校验 + * @param fileName + * @return + */ + public ExcelCheckResult validExcel(InputStream fileName) { + List errLogList = new ArrayList<>(); + List successList = new ArrayList<>(); + EasyExcel.read(fileName, VciExcelImp.class, new ReadListener() { + /** + * 单次缓存的数据量 + */ + static final int BATCH_COUNT = 3000; + /** + * 临时存储 + */ + private List cachedData = new ArrayList<>(BATCH_COUNT); + + @Override + public void onException(Exception exception, AnalysisContext context) throws Exception { + // 如果是某一个单元格的转换异常 能获取到具体行号 + // 如果要获取头的信息 配合invokeHeadMap使用 + if (exception instanceof ExcelDataConvertException) { + ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception; + + String formatString = MessageFormat.format("第{0}行,第{1}列解析异常", + excelDataConvertException.getRowIndex(), excelDataConvertException.getColumnIndex()); + + errLogList.add(formatString); + + } + } + + @Override + public void invoke(VciExcelImp data, AnalysisContext context) { + successList.add(data); + cachedData.add(data); + if (cachedData.size() >= BATCH_COUNT) { + saveData(); + // 存储完成清理 list + cachedData = new ArrayList<>(BATCH_COUNT); + } + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + + } + + /** + * 加上存储数据库 + */ + private void saveData() { + + + } + }).sheet().headRowNumber(1).doRead(); + return new ExcelCheckResult<>(errLogList, successList); + } + + /** + * 导入 + * @param listData + */ + public void importExcel(List listData){ + listData.forEach((item) -> { + //售后维修表 + Vci vci = JSON.parseObject(JSON.toJSONString(item), Vci.class); + vciMapper.insert(vci); + }); + } +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/vo/ExcelCheckResult.java b/integration-front/src/main/java/top/kuanghua/integrationfront/vo/ExcelCheckResult.java similarity index 91% rename from ty-user/src/main/java/top/kuanghua/tyuser/vo/ExcelCheckResult.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/vo/ExcelCheckResult.java index 483ecb6..a7b0a5d 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/vo/ExcelCheckResult.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/vo/ExcelCheckResult.java @@ -1,29 +1,29 @@ -package top.kuanghua.tyuser.vo; - -import lombok.Data; - -import java.util.List; - -/** - * @Title: ExcelCheckResult - * @Description: - * @Auther: kuanghua - * @create 2021-11-02 11:33 - */ - -@Data -public class ExcelCheckResult { - private int errNum; - private int successNum; - private boolean checkResult; - private List errList; - private List successList; - - public ExcelCheckResult(List errList, List successList) { - this.errList = errList; - this.successList = successList; - this.errNum=errList.size(); - this.successNum=successList.size(); - this.checkResult=errList.size()==0; - } -} +package top.kuanghua.integrationfront.vo; + +import lombok.Data; + +import java.util.List; + +/** + * @Title: ExcelCheckResult + * @Description: + * @Auther: kuanghua + * @create 2021-11-02 11:33 + */ + +@Data +public class ExcelCheckResult { + private int errNum; + private int successNum; + private boolean checkResult; + private List errList; + private List successList; + + public ExcelCheckResult(List errList, List successList) { + this.errList = errList; + this.successList = successList; + this.errNum=errList.size(); + this.successNum=successList.size(); + this.checkResult=errList.size()==0; + } +} diff --git a/ty-user/src/main/java/top/kuanghua/tyuser/vo/UserVo.java b/integration-front/src/main/java/top/kuanghua/integrationfront/vo/UserVo.java similarity index 89% rename from ty-user/src/main/java/top/kuanghua/tyuser/vo/UserVo.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/vo/UserVo.java index ecf4fe9..909798b 100644 --- a/ty-user/src/main/java/top/kuanghua/tyuser/vo/UserVo.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/vo/UserVo.java @@ -1,36 +1,36 @@ -package top.kuanghua.tyuser.vo; - -import io.swagger.annotations.ApiModel; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.util.Date; - -/** - * @Title: UserVo - * @Description: - * @Auther: kuanghua - * @create 2020/12/15 19:32 - */ -@Data -@EqualsAndHashCode(callSuper = false) -@Accessors(chain = true) -@ApiModel(value="多表分页测试") -public class UserVo { - private Integer id; - - private String username; - - private String password; - - private String phone; - - private Date createTime; - - private Date updateTime; - - private String deleted; - - private String salt; -} +package top.kuanghua.integrationfront.vo; + +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** + * @Title: UserVo + * @Description: + * @Auther: kuanghua + * @create 2020/12/15 19:32 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value="多表分页测试") +public class UserVo { + private Integer id; + + private String username; + + private String password; + + private String phone; + + private Date createTime; + + private Date updateTime; + + private String deleted; + + private String salt; +} diff --git a/ty-user/src/main/resources/application.yml b/integration-front/src/main/resources/application.yml similarity index 100% rename from ty-user/src/main/resources/application.yml rename to integration-front/src/main/resources/application.yml diff --git a/ty-user/src/main/resources/bootstrap.yml b/integration-front/src/main/resources/bootstrap.yml similarity index 100% rename from ty-user/src/main/resources/bootstrap.yml rename to integration-front/src/main/resources/bootstrap.yml diff --git a/ty-user/src/main/resources/mapper/AdminMapper.xml b/integration-front/src/main/resources/mapper/AdminMapper.xml similarity index 91% rename from ty-user/src/main/resources/mapper/AdminMapper.xml rename to integration-front/src/main/resources/mapper/AdminMapper.xml index b250fab..e0c5a4e 100644 --- a/ty-user/src/main/resources/mapper/AdminMapper.xml +++ b/integration-front/src/main/resources/mapper/AdminMapper.xml @@ -1,110 +1,110 @@ - - - - - - - - - - - - - - - - - - id, - status, - add_time, - is_super, - username, - password, - is_delete, - mobile, - email, - role_id - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + id, + status, + add_time, + is_super, + username, + password, + is_delete, + mobile, + email, + role_id + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index 5166516..6da9d61 100644 --- a/pom.xml +++ b/pom.xml @@ -12,10 +12,10 @@ ty-common ty-gateway ty-auth - ty-user - ty-upload - ty-excel + integration-front ty-example + + @@ -120,20 +120,17 @@ - - - - - - - - - - - - - - + + + + + + + + + + + diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java b/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java index fc50e49..78010c8 100644 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java +++ b/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java @@ -42,7 +42,7 @@ public Docket api() { */ private ApiInfo apiInfo() { return new ApiInfoBuilder() - .title("标题:kuanghua") + .title("title:micro-service-plus") .description("描述:新一代的微服务架构") .contact(new Contact("jzfai", null, "869653722@qq.com")) .version("版本号:2.9") diff --git a/ty-common/pom.xml b/ty-common/pom.xml index 1a35ee8..e94f862 100644 --- a/ty-common/pom.xml +++ b/ty-common/pom.xml @@ -136,7 +136,7 @@ io.seata seata-spring-boot-starter - 1.4.0 + 1.4.2 \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/controller/HstrixController.java b/ty-common/src/main/java/top/kuanghua/controller/HstrixController.java similarity index 83% rename from ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/controller/HstrixController.java rename to ty-common/src/main/java/top/kuanghua/controller/HstrixController.java index 9138091..8762eaf 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/controller/HstrixController.java +++ b/ty-common/src/main/java/top/kuanghua/controller/HstrixController.java @@ -1,7 +1,8 @@ -package top.kuanghua.gatewaytwo.controller; +package top.kuanghua.controller; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import top.kuanghua.khcomomon.entity.ResResult; @@ -14,7 +15,7 @@ @RestController public class HstrixController { @ApiOperation(value = "") - @GetMapping("fallback") + @RequestMapping("/fallback") public ResResult fallback() { ResResult resResult = new ResResult(); //设置20010为熔断状态吗 diff --git a/ty-common/src/main/java/top/kuanghua/feign/tyuser/feign/UserFeign.java b/ty-common/src/main/java/top/kuanghua/feign/integrationfront/feign/UserFeign.java similarity index 72% rename from ty-common/src/main/java/top/kuanghua/feign/tyuser/feign/UserFeign.java rename to ty-common/src/main/java/top/kuanghua/feign/integrationfront/feign/UserFeign.java index 79c0c79..e2a6fc8 100644 --- a/ty-common/src/main/java/top/kuanghua/feign/tyuser/feign/UserFeign.java +++ b/ty-common/src/main/java/top/kuanghua/feign/integrationfront/feign/UserFeign.java @@ -1,17 +1,15 @@ -package top.kuanghua.feign.tyuser.feign; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import top.kuanghua.feign.config.FeignConfiguration; -import top.kuanghua.khcomomon.entity.ResResult; - -@FeignClient(name="ty-user",configuration = FeignConfiguration.class) -@RequestMapping("user") -public interface UserFeign { - - @PostMapping("insertUser") - ResResult insertUser(@RequestParam("username") String username); -} +package top.kuanghua.feign.integrationfront.feign; + +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import top.kuanghua.feign.config.FeignConfiguration; +import top.kuanghua.khcomomon.entity.ResResult; + +@FeignClient(name="integration-front",configuration = FeignConfiguration.class) +@RequestMapping("user") +public interface UserFeign { + @PostMapping("insertUser") + ResResult insertUser(@RequestParam("username") String username); +} diff --git a/ty-common/src/main/java/top/kuanghua/feign/tyexecl/feign/ExcelFeign.java b/ty-common/src/main/java/top/kuanghua/feign/tyexecl/feign/ExcelFeign.java deleted file mode 100644 index 93cb15e..0000000 --- a/ty-common/src/main/java/top/kuanghua/feign/tyexecl/feign/ExcelFeign.java +++ /dev/null @@ -1,22 +0,0 @@ -package top.kuanghua.feign.tyexecl.feign; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import top.kuanghua.feign.config.FeignConfiguration; -import top.kuanghua.khcomomon.entity.ResResult; - -/** - * @Title: ExcelFeign - * @Description: - * @Auther: kuanghua - * @create 2021/7/12 10:09 - */ -@FeignClient(name="ty-excel",configuration = FeignConfiguration.class) -@RequestMapping("excel") -public interface ExcelFeign { - /*查询execl表中的用户*/ - @GetMapping("selectExcelByUser") - public ResResult selectExcelByUser(@RequestParam("username") String username); -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java b/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java index eb9767a..4d0b9d6 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java @@ -10,7 +10,7 @@ @SpringBootApplication @EnableScheduling @EnableAsync -//@EnableCanalClient +@EnableCanalClient @EnableAutoDataSourceProxy public class ExampleApplication { public static void main(String[] args) { diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java b/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java index 809d29d..4403c0f 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java @@ -18,10 +18,10 @@ @Configuration //扫描公用包的配置和自身的配置类 @ComponentScan(basePackages = {"top.kuanghua.khcomomon"}) -//mapper包扫描 +//mapper scanning @MapperScan(basePackages = {"top.kuanghua.tyexample.mapper"}) -//feign扫描 -@EnableFeignClients(basePackages = {"top.kuanghua.feign.tyuser"}) +//feign scanning +@EnableFeignClients(basePackages = {"top.kuanghua.feign"}) public class BaseConfig { } diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java b/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java index 4e14a84..e1e8d54 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java @@ -41,7 +41,7 @@ public Docket api() { */ private ApiInfo apiInfo() { return new ApiInfoBuilder() - .title("标题:kuanghua") + .title("title:micro-service-plus") .description("描述:新一代的微服务架构") .contact(new Contact("jzfai", null, "869653722@qq.com")) .version("版本号:2.9") diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/listener/CanalDataEventListener.java b/ty-example/src/main/java/top/kuanghua/tyexample/listener/CanalDataEventListener.java index 5e45cc6..5bef611 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/listener/CanalDataEventListener.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/listener/CanalDataEventListener.java @@ -11,35 +11,35 @@ */ @CanalEventListener public class CanalDataEventListener { - @InsertListenPoint - public void onEventInsert(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { - for (CanalEntry.Column column : rowData.getAfterColumnsList()) { - System.out.println("新增" + column.getName() + ":获取的数据" + column.getValue()); - } - } - - @UpdateListenPoint - public void onEventUpdate(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { - for (CanalEntry.Column column : rowData.getBeforeColumnsList()) { - System.out.println("修改前" + column.getName() + ":获取的数据" + column.getValue()); - } - for (CanalEntry.Column column : rowData.getAfterColumnsList()) { - System.out.println("修改后" + column.getName() + ":获取的数据" + column.getValue()); - } - } - - @DeleteListenPoint - public void onEventDelete(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { - for (CanalEntry.Column column : rowData.getBeforeColumnsList()) { - System.out.println("删除前" + column.getName() + ":获取的数据" + column.getValue()); - } - } +// @InsertListenPoint +// public void onEventInsert(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { +// for (CanalEntry.Column column : rowData.getAfterColumnsList()) { +// System.out.println("新增" + column.getName() + ":获取的数据" + column.getValue()); +// } +// } +// +// @UpdateListenPoint +// public void onEventUpdate(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { +// for (CanalEntry.Column column : rowData.getBeforeColumnsList()) { +// System.out.println("修改前" + column.getName() + ":获取的数据" + column.getValue()); +// } +// for (CanalEntry.Column column : rowData.getAfterColumnsList()) { +// System.out.println("修改后" + column.getName() + ":获取的数据" + column.getValue()); +// } +// } +// +// @DeleteListenPoint +// public void onEventDelete(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { +// for (CanalEntry.Column column : rowData.getBeforeColumnsList()) { +// System.out.println("删除前" + column.getName() + ":获取的数据" + column.getValue()); +// } +// } //自定义监听 @ListenPoint( - eventType = {CanalEntry.EventType.DELETE, CanalEntry.EventType.UPDATE}, //监听类型 - schema = {"changgou_content"}, - table = {"tb_content"}, //指定监控的表 + eventType = {CanalEntry.EventType.DELETE, CanalEntry.EventType.UPDATE,CanalEntry.EventType.UPDATE}, //监听类型 + schema = {"micro-service-plus"},//Library + table = {"tb_error_collection"}, //table destination = "example" //指定实例的地址 ) public void onEventCustomUpdate(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java index 3b733e7..5040928 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java @@ -1,8 +1,8 @@ package top.kuanghua.tyexample.service; +import io.seata.spring.annotation.GlobalTransactional; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import top.kuanghua.feign.tyuser.feign.UserFeign; +import top.kuanghua.feign.integrationfront.feign.UserFeign; import javax.annotation.Resource; @@ -18,7 +18,7 @@ public class SeataTestService { @Resource private UserFeign userFeign; - @Transactional(rollbackFor = Exception.class) + @GlobalTransactional(rollbackFor = Exception.class) public void testSeataRollback(){ userFeign.insertUser("jzfai"); int i=10/0; diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java index eb5317b..6c04b9a 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java @@ -30,17 +30,17 @@ public class UploadService { @Resource private FastFileStorageClient storageClient; - private static final List CONTENT_TYPES = Arrays.asList("image/jpeg", "image/gif"); + //private static final List CONTENT_TYPES = Arrays.asList("image/jpeg", "image/gif"); public String upload(MultipartFile file) throws IOException { String originalFilename = file.getOriginalFilename(); //检验文件类型 - String contentType = file.getContentType(); - if (!CONTENT_TYPES.contains(contentType)) { - //文件类型不合法 - log.info("文件类型不合法:{}", originalFilename); - throw new RuntimeException("文件内容不合法"); - } +// String contentType = file.getContentType(); +// if (!CONTENT_TYPES.contains(contentType)) { +// //文件类型不合法 +// log.info("文件类型不合法:{}", originalFilename); +// throw new RuntimeException("文件内容不合法"); +// } //检验文件内容 BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); if (bufferedImage == null) { @@ -62,10 +62,10 @@ public Map uploadGetMetaData(MultipartFile file) throws IOExcept String originalFilename = file.getOriginalFilename(); //检验文件类型 String contentType = file.getContentType(); - if (!CONTENT_TYPES.contains(contentType)) { - //文件类型不合法 - log.info("文件类型不合法:{}", originalFilename); - } +// if (!CONTENT_TYPES.contains(contentType)) { +// //文件类型不合法 +// log.info("文件类型不合法:{}", originalFilename); +// } //检验文件内容 BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); if (bufferedImage == null) { diff --git a/ty-example/src/main/resources/application.yml b/ty-example/src/main/resources/application.yml index 5d95712..e69de29 100644 --- a/ty-example/src/main/resources/application.yml +++ b/ty-example/src/main/resources/application.yml @@ -1,33 +0,0 @@ -#msg config, place change to you sms config -kuanghua: - sms: - accessKeyId: LTAI4FrD2voTK2wTgRCPwT6d - accessKeySecret: Zj07thnb2jiBkl4wtqgvPeuSzkJRJ3 - signName: 品优商城 # 签名名称 - verifyCodeTemplate: SMS_189216068 # 模板名称 - - - -#email config, place change to you email -spring: - mail: - username: 869653722@qq.com - password: xbthzedhnxatbcab - host: smtp.qq.com - properties: - mail.smtp.starttls.enable: true - - - -server: - port: ${envpt.tomcatPortPre}0121 - - - -#canal配置 -canal: - client: - instances: - example: - host: 8.135.1.141 - port: 11111 diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/service/ExcelService.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/service/ExcelService.java index 82ec61b..acfbf48 100644 --- a/ty-excel/src/main/java/top/kuanghua/tyexcel/service/ExcelService.java +++ b/ty-excel/src/main/java/top/kuanghua/tyexcel/service/ExcelService.java @@ -131,8 +131,6 @@ private void saveData() { } - - //注:headRowNumber(1)如果不写会自动匹配 })// 需要读取批注 默认不读取 .extraRead(CellExtraTypeEnum.COMMENT) diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SpecialHystrixGatewayFilterFactory.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SpecialHystrixGatewayFilterFactory.java index a206eeb..440d247 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SpecialHystrixGatewayFilterFactory.java +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SpecialHystrixGatewayFilterFactory.java @@ -82,7 +82,7 @@ public GatewayFilter apply(Config config) { HystrixRuntimeException.FailureType failureType = e.getFailureType(); switch (failureType) { case TIMEOUT: - return Mono.error(new TimeoutException()); + return Mono.error(new TimeoutException("接口请求超时了")); case COMMAND_EXCEPTION: { Throwable cause = e.getCause(); if (cause instanceof ResponseStatusException || AnnotatedElementUtils diff --git a/ty-gateway/ty-gateway-one/src/main/resources/application.yml b/ty-gateway/ty-gateway-one/src/main/resources/application.yml index b77388d..678e70c 100644 --- a/ty-gateway/ty-gateway-one/src/main/resources/application.yml +++ b/ty-gateway/ty-gateway-one/src/main/resources/application.yml @@ -4,24 +4,24 @@ server: spring: cloud: gateway: - globalcors: - corsConfigurations: - '[/**]': - # 允许携带认证信息 - # 允许跨域的源(网站域名/ip),设置*为全部 - # 允许跨域请求里的head字段,设置*为全部 - # 允许跨域的method, 默认为GET和OPTIONS,设置*为全部 - # 跨域允许的有效期 - allow-credentials: true - allowed-origins: "*" - allowed-headers: "*" - allowed-methods: - - OPTIONS - - GET - - POST - - PUT - - DELETE - #max-age: 3600 +# globalcors: +# corsConfigurations: +# '[/**]': +# # 允许携带认证信息 +# # 允许跨域的源(网站域名/ip),设置*为全部 +# # 允许跨域请求里的head字段,设置*为全部 +# # 允许跨域的method, 默认为GET和OPTIONS,设置*为全部 +# # 跨域允许的有效期 +# allow-credentials: true +# allowed-origins: "*" +# allowed-headers: "*" +# allowed-methods: +# - OPTIONS +# - GET +# - POST +# - PUT +# - DELETE +# #max-age: 3600 routes: - id: ty-auth uri: lb://ty-auth @@ -61,14 +61,13 @@ spring: #指定接口超时处理 hystrixRibbon -> @RequestMapping("hystrixRibbon") #timeoutTest-> @GetMapping("timeoutTest") , - > / hystrixRibbon-timeoutTest: 11000 - #file-upload-: 20000 - #file-download-: 20000 - #course-file-upload-local-: 20000 + upload-image: 2000 + upload-file: 30000 - - id: ty-user - uri: lb://ty-user + - id: integration-front + uri: lb://integration-front predicates: - - Path=/api/ty-user/** + - Path=/api/integration-front/** filters: - StripPrefix=2 @@ -90,20 +89,20 @@ management: #白名单过滤 filter: - allowPaths: / + #not filter , you can config it when dev + #allowPaths: / + allowPaths: swagger,docs,userRegister,userLogin,sendEmailCode,registry,login,loginOut,insertUser,example notValidExpList: export,excel - token-properties: renewTokenMinute: 1440 #默认1天时间告知前端刷新token - #config the visit service of gateway swagger swagger-doc: serviceMap: { - ty-user: "用户模块", + integration-front: "前端数据整合", ty-upload: "文件上传", ty-example: "使用例子" } \ No newline at end of file From ae66f9a0245a4fd82e8b7935d3e49067d2151caa Mon Sep 17 00:00:00 2001 From: jzfai <869653722@qq.com> Date: Wed, 12 Jan 2022 17:12:37 +0800 Subject: [PATCH 17/36] update fastdfst to gofastdfs --- controller.mv => easycode-temp/controller.mv | 278 ++++---- .../element-form.mv | 606 +++++++++--------- .../element-table.mv | 600 ++++++++--------- entity.mv => easycode-temp/entity.mv | 112 ++-- mapper.mv => easycode-temp/mapper.mv | 36 +- service.mv => easycode-temp/service.mv | 106 +-- pom.xml | 28 +- ty-example/pom.xml | 8 + .../controller/GoFastDFSController.java | 49 ++ .../controller/UploadController.java | 84 --- ty-example/src/main/resources/bootstrap.yml | 40 +- ty-upload/pom.xml | 50 -- .../kuanghua/tyupload/UploadApplication.java | 18 - .../kuanghua/tyupload/config/BaseConfig.java | 21 - .../tyupload/config/Swagger2Config.java | 52 -- .../tyupload/controller/NacosTestDemo.java | 44 -- .../tyupload/controller/TestController.java | 14 - .../tyupload/controller/UploadController.java | 83 --- .../tyupload/service/UploadService.java | 91 --- ty-upload/src/main/javabrandE/BrandE.vue | 266 -------- ty-upload/src/main/javabrandE/BrandEForm.vue | 227 ------- ty-upload/src/main/main11.iml | 13 - ty-upload/src/main/resources/application.yml | 0 ty-upload/src/main/resources/bootstrap.yml | 35 - .../controller/UploadControllerTest.java | 28 - ty-upload/src/test/test2.iml | 11 - 26 files changed, 958 insertions(+), 1942 deletions(-) rename controller.mv => easycode-temp/controller.mv (97%) rename element-form.mv => easycode-temp/element-form.mv (97%) rename element-table.mv => easycode-temp/element-table.mv (96%) rename entity.mv => easycode-temp/entity.mv (96%) rename mapper.mv => easycode-temp/mapper.mv (95%) rename service.mv => easycode-temp/service.mv (96%) create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/GoFastDFSController.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/UploadController.java delete mode 100644 ty-upload/pom.xml delete mode 100644 ty-upload/src/main/java/top/kuanghua/tyupload/UploadApplication.java delete mode 100644 ty-upload/src/main/java/top/kuanghua/tyupload/config/BaseConfig.java delete mode 100644 ty-upload/src/main/java/top/kuanghua/tyupload/config/Swagger2Config.java delete mode 100644 ty-upload/src/main/java/top/kuanghua/tyupload/controller/NacosTestDemo.java delete mode 100644 ty-upload/src/main/java/top/kuanghua/tyupload/controller/TestController.java delete mode 100644 ty-upload/src/main/java/top/kuanghua/tyupload/controller/UploadController.java delete mode 100644 ty-upload/src/main/java/top/kuanghua/tyupload/service/UploadService.java delete mode 100644 ty-upload/src/main/javabrandE/BrandE.vue delete mode 100644 ty-upload/src/main/javabrandE/BrandEForm.vue delete mode 100644 ty-upload/src/main/main11.iml delete mode 100644 ty-upload/src/main/resources/application.yml delete mode 100644 ty-upload/src/main/resources/bootstrap.yml delete mode 100644 ty-upload/src/test/java/top/kuanghua/tyupload/controller/UploadControllerTest.java delete mode 100644 ty-upload/src/test/test2.iml diff --git a/controller.mv b/easycode-temp/controller.mv similarity index 97% rename from controller.mv rename to easycode-temp/controller.mv index 48c3e1a..6564d95 100644 --- a/controller.mv +++ b/easycode-temp/controller.mv @@ -1,140 +1,140 @@ -##导入宏定义 -$!init -$!define - -##设置表后缀(宏定义) -#setTableSuffix("Controller") - -##保存文件(宏定义) -#save("/controller", "Controller.java") - -##包路径(宏定义) -#setPackageSuffix("controller") - -##定义服务名 -#set($serviceName = $!tool.append($!tool.firstLowerCase($!tableInfo.name), "Service")) - -##定义实体对象名 -#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) - - -import org.apache.commons.lang3.StringUtils; -import top.kuanghua.khcomomon.entity.CommonParams; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.api.ApiController; -import com.baomidou.mybatisplus.extension.api.R; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -##import $!{tableInfo.savePackageName}api.entity.$!tableInfo.name; -import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.io.Serializable; -import java.util.*; - -##表注释(宏定义) -@Api(tags = "$!{tableInfo.comment}($!{tableInfo.name})") -@RestController -@RequestMapping("$!tool.firstLowerCase($!tableInfo.name)") -public class $!{tableInfo.name}Controller { - -@Resource -private $!{tableInfo.name}Service $!{serviceName}; - -/** -* 分页查询所有数据 -* @param $!entityName 查询实体 -* @return 所有数据 -*/ -@GetMapping("selectPage") -@ApiOperation(value = "分页查询所有数据") -public ResResult selectPage($!{tableInfo.name} $!entityName, CommonParams commonParams) { -QueryWrapper<$!{tableInfo.name}> queryWrapper = new QueryWrapper<>(); -#foreach($column in $tableInfo.fullColumn) - #if( $!column.comment ) - if(ObjectUtils.isNotEmpty($!{entityName}.get$!{tool.firstUpperCase($column.name)}())) { - queryWrapper.like("$!{tool.hump2Underline($column.name)}",$!{entityName}.get$!{tool.firstUpperCase($column.name)}()); - } - #end -#end - -#set($StringBj="") -#foreach($column in $tableInfo.fullColumn) - #if( $!column.comment ) - #set($StringBj=$!{StringBj}+$!{tool.hump2Underline($column.name)}+",") - #end -#end - - - -if(StringUtils.isNotEmpty(commonParams.getStartTime())) { -queryWrapper.between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); -queryWrapper.or().orderByDesc("create_time"); -} - -queryWrapper.select("$StringBj.substring(0,$StringBj.lastIndexOf(','))"); -Page<$!{tableInfo.name}> $!{entityName}Page = this.$!{entityName}Service.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); -return new ResResult().success($!{entityName}Page); -} - -/** -* 通过主键查询单条数据 -* @param id 主键 -* @return 单条数据 -*/ -@GetMapping("selectById") -@ApiOperation(value = "通过id主键查询单条数据") -public ResResult selectById(@RequestParam("id") Integer id) { -return new ResResult().success(this.$!{serviceName}.selectById(id)); -} - -/** -* @Description: 根据id数组查询品牌列表 -* @Param: idList id数组 -* @return: ids列表数据 -*/ -@ApiOperation(value = "根据id数组查询品牌列表") -@PostMapping("selectBatchIds") -public ResResult selectBatchIds(@RequestParam("idList") List - idList) { - return new ResResult().success(this.$!{serviceName}.selectBatchIds(idList)); - } - /** - * 新增数据 - * @param $!entityName 实体对象 - * @return 新增结果 - */ - @ApiOperation(value = "新增数据") - @PostMapping("insert") - public ResResult insert(@RequestBody $!{tableInfo.name} $!entityName) { - return new ResResult().success(this.$!{serviceName}.insert($!entityName)); - } - - /** - * 修改数据 - * @param $!entityName 实体对象 - * @return 修改结果 - */ - @ApiOperation(value = "根据id修改数据") - @PutMapping("updateById") - public ResResult updateById(@RequestBody $!{tableInfo.name} $!entityName) { - return new ResResult().success(this.$!{serviceName}.updateById($!entityName)); - } - - /** - * 删除数据 - * @param idList 主键结合 - * @return 删除结果 - */ - @ApiOperation(value = "根据id数组删除数据") - @DeleteMapping("deleteBatchIds") - public ResResult deleteBatchIds(@RequestBody List - idList) { - return new ResResult().success(this.$!{serviceName}.deleteBatchIds(idList)); - } - @DeleteMapping("deleteById") - @ApiOperation(value = "根据id删除数据") - public ResResult deleteById(@RequestParam("id") Integer id) { - return new ResResult().success(this.$!{serviceName}.deleteById(id)); - } +##导入宏定义 +$!init +$!define + +##设置表后缀(宏定义) +#setTableSuffix("Controller") + +##保存文件(宏定义) +#save("/controller", "Controller.java") + +##包路径(宏定义) +#setPackageSuffix("controller") + +##定义服务名 +#set($serviceName = $!tool.append($!tool.firstLowerCase($!tableInfo.name), "Service")) + +##定义实体对象名 +#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) + + +import org.apache.commons.lang3.StringUtils; +import top.kuanghua.khcomomon.entity.CommonParams; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.api.ApiController; +import com.baomidou.mybatisplus.extension.api.R; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +##import $!{tableInfo.savePackageName}api.entity.$!tableInfo.name; +import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.io.Serializable; +import java.util.*; + +##表注释(宏定义) +@Api(tags = "$!{tableInfo.comment}($!{tableInfo.name})") +@RestController +@RequestMapping("$!tool.firstLowerCase($!tableInfo.name)") +public class $!{tableInfo.name}Controller { + +@Resource +private $!{tableInfo.name}Service $!{serviceName}; + +/** +* 分页查询所有数据 +* @param $!entityName 查询实体 +* @return 所有数据 +*/ +@GetMapping("selectPage") +@ApiOperation(value = "分页查询所有数据") +public ResResult selectPage($!{tableInfo.name} $!entityName, CommonParams commonParams) { +QueryWrapper<$!{tableInfo.name}> queryWrapper = new QueryWrapper<>(); +#foreach($column in $tableInfo.fullColumn) + #if( $!column.comment ) + if(ObjectUtils.isNotEmpty($!{entityName}.get$!{tool.firstUpperCase($column.name)}())) { + queryWrapper.like("$!{tool.hump2Underline($column.name)}",$!{entityName}.get$!{tool.firstUpperCase($column.name)}()); + } + #end +#end + +#set($StringBj="") +#foreach($column in $tableInfo.fullColumn) + #if( $!column.comment ) + #set($StringBj=$!{StringBj}+$!{tool.hump2Underline($column.name)}+",") + #end +#end + + + +if(StringUtils.isNotEmpty(commonParams.getStartTime())) { +queryWrapper.between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); +queryWrapper.or().orderByDesc("create_time"); +} + +queryWrapper.select("$StringBj.substring(0,$StringBj.lastIndexOf(','))"); +Page<$!{tableInfo.name}> $!{entityName}Page = this.$!{entityName}Service.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); +return new ResResult().success($!{entityName}Page); +} + +/** +* 通过主键查询单条数据 +* @param id 主键 +* @return 单条数据 +*/ +@GetMapping("selectById") +@ApiOperation(value = "通过id主键查询单条数据") +public ResResult selectById(@RequestParam("id") Integer id) { +return new ResResult().success(this.$!{serviceName}.selectById(id)); +} + +/** +* @Description: 根据id数组查询品牌列表 +* @Param: idList id数组 +* @return: ids列表数据 +*/ +@ApiOperation(value = "根据id数组查询品牌列表") +@PostMapping("selectBatchIds") +public ResResult selectBatchIds(@RequestParam("idList") List + idList) { + return new ResResult().success(this.$!{serviceName}.selectBatchIds(idList)); + } + /** + * 新增数据 + * @param $!entityName 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping("insert") + public ResResult insert(@RequestBody $!{tableInfo.name} $!entityName) { + return new ResResult().success(this.$!{serviceName}.insert($!entityName)); + } + + /** + * 修改数据 + * @param $!entityName 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "根据id修改数据") + @PutMapping("updateById") + public ResResult updateById(@RequestBody $!{tableInfo.name} $!entityName) { + return new ResResult().success(this.$!{serviceName}.updateById($!entityName)); + } + + /** + * 删除数据 + * @param idList 主键结合 + * @return 删除结果 + */ + @ApiOperation(value = "根据id数组删除数据") + @DeleteMapping("deleteBatchIds") + public ResResult deleteBatchIds(@RequestBody List + idList) { + return new ResResult().success(this.$!{serviceName}.deleteBatchIds(idList)); + } + @DeleteMapping("deleteById") + @ApiOperation(value = "根据id删除数据") + public ResResult deleteById(@RequestParam("id") Integer id) { + return new ResResult().success(this.$!{serviceName}.deleteById(id)); + } } \ No newline at end of file diff --git a/element-form.mv b/easycode-temp/element-form.mv similarity index 97% rename from element-form.mv rename to easycode-temp/element-form.mv index d76b914..ee97b17 100644 --- a/element-form.mv +++ b/easycode-temp/element-form.mv @@ -1,303 +1,303 @@ -##导入宏定义 -$!init -$!define -##定义实体对象名 -#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) -#set($serviceName = 'rbox-service') - -##保存文件(宏定义) -#save($!{entityName}, "Form.vue") - - - - - +##导入宏定义 +$!init +$!define +##定义实体对象名 +#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) +#set($serviceName = 'rbox-service') + +##保存文件(宏定义) +#save($!{entityName}, "Form.vue") + + + + + diff --git a/element-table.mv b/easycode-temp/element-table.mv similarity index 96% rename from element-table.mv rename to easycode-temp/element-table.mv index 6b8b811..92b49c5 100644 --- a/element-table.mv +++ b/easycode-temp/element-table.mv @@ -1,300 +1,300 @@ -##导入宏定义 -$!init -$!define -##定义实体对象名 -#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) -#set($serviceName = 'rbox-service') - -##保存文件(宏定义) -#save($!{entityName}, ".vue") - - - - - +##导入宏定义 +$!init +$!define +##定义实体对象名 +#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) +#set($serviceName = 'rbox-service') + +##保存文件(宏定义) +#save($!{entityName}, ".vue") + + + + + diff --git a/entity.mv b/easycode-temp/entity.mv similarity index 96% rename from entity.mv rename to easycode-temp/entity.mv index ff51046..451ce4f 100644 --- a/entity.mv +++ b/easycode-temp/entity.mv @@ -1,56 +1,56 @@ -##导入宏定义 -$!init -$!define - -##保存文件(宏定义) -#save("/entity", ".java") - -##包路径(宏定义) -#setPackageSuffix("entity") - -##自动导入包(全局变量) -##$!autoImport -import com.baomidou.mybatisplus.extension.activerecord.Model; -import java.io.Serializable; -import lombok.Data; -##表注释(宏定义) -#tableComment("表实体类") -@Data -@ApiModel("$!tableInfo.comment") -@TableName(value = "tb_$!{tool.hump2Underline($tableInfo.name)}") -public class $!{tableInfo.name} extends Model<$!{tableInfo.name}> { -#foreach($column in $tableInfo.fullColumn) - #if( $!column.comment ) - #set($listSize=$!{column.comment.split(';')}) - #if( $!listSize.size() > 0 ) - @ApiModelProperty(value="$!listSize[0]") - #end - #if($column.name.indexOf("updateTime") != -1) - @TableField(fill = FieldFill.UPDATE) - #end - #if($column.name.indexOf("createTime") != -1) - @TableField(fill = FieldFill.INSERT) - #end - #if($column.name.indexOf("isDeleted") != -1) - @TableLogic - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - #end - #end -private $!{tool.getClsNameByFullName($column.type)} $!{column.name}; -#end -###foreach($column in $tableInfo.fullColumn) -###getSetMethod($column) -###end -#foreach($column in $tableInfo.pkColumn) -/** -* 获取主键值 -* -* @return 主键值 -*/ -@Override -protected Serializable pkVal() { -return this.$!column.name; -} - #break -#end -} +##导入宏定义 +$!init +$!define + +##保存文件(宏定义) +#save("/entity", ".java") + +##包路径(宏定义) +#setPackageSuffix("entity") + +##自动导入包(全局变量) +##$!autoImport +import com.baomidou.mybatisplus.extension.activerecord.Model; +import java.io.Serializable; +import lombok.Data; +##表注释(宏定义) +#tableComment("表实体类") +@Data +@ApiModel("$!tableInfo.comment") +@TableName(value = "tb_$!{tool.hump2Underline($tableInfo.name)}") +public class $!{tableInfo.name} extends Model<$!{tableInfo.name}> { +#foreach($column in $tableInfo.fullColumn) + #if( $!column.comment ) + #set($listSize=$!{column.comment.split(';')}) + #if( $!listSize.size() > 0 ) + @ApiModelProperty(value="$!listSize[0]") + #end + #if($column.name.indexOf("updateTime") != -1) + @TableField(fill = FieldFill.UPDATE) + #end + #if($column.name.indexOf("createTime") != -1) + @TableField(fill = FieldFill.INSERT) + #end + #if($column.name.indexOf("isDeleted") != -1) + @TableLogic + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + #end + #end +private $!{tool.getClsNameByFullName($column.type)} $!{column.name}; +#end +###foreach($column in $tableInfo.fullColumn) +###getSetMethod($column) +###end +#foreach($column in $tableInfo.pkColumn) +/** +* 获取主键值 +* +* @return 主键值 +*/ +@Override +protected Serializable pkVal() { +return this.$!column.name; +} + #break +#end +} diff --git a/mapper.mv b/easycode-temp/mapper.mv similarity index 95% rename from mapper.mv rename to easycode-temp/mapper.mv index ec158b1..875226c 100644 --- a/mapper.mv +++ b/easycode-temp/mapper.mv @@ -1,19 +1,19 @@ -##导入宏定义 -$!init -$!define - -##设置表后缀(宏定义) -#setTableSuffix("Mapper") - -##保存文件(宏定义) -#save("/mapper", "Mapper.java") - -##包路径(宏定义) -#setPackageSuffix("mapper") - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -##表注释(宏定义) -public interface $!{tableName} extends BaseMapper<$!tableInfo.name> { - +##导入宏定义 +$!init +$!define + +##设置表后缀(宏定义) +#setTableSuffix("Mapper") + +##保存文件(宏定义) +#save("/mapper", "Mapper.java") + +##包路径(宏定义) +#setPackageSuffix("mapper") + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +##表注释(宏定义) +public interface $!{tableName} extends BaseMapper<$!tableInfo.name> { + } \ No newline at end of file diff --git a/service.mv b/easycode-temp/service.mv similarity index 96% rename from service.mv rename to easycode-temp/service.mv index 4658d24..fa646ee 100644 --- a/service.mv +++ b/easycode-temp/service.mv @@ -1,54 +1,54 @@ -##导入宏定义 -$!init -$!define - -##设置表后缀(宏定义) -#setTableSuffix("Service") - -##保存文件(宏定义) -#save("/service", "Service.java") -##定义服务名 -##定义实体对象名 -#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) -##包路径(宏定义) -#setPackageSuffix("service") -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -/** -* ($!{tableInfo.name}) -* @author kuanghua -* @since $time.currTime() -*/ -@Service -public class $!{tableInfo.name}Service{ - - @Resource - private $!{tableInfo.name}Mapper $!{entityName}Mapper; - - public Page<$!{tableInfo.name}> selectPage(Integer pageNum, Integer pageSize, QueryWrapper<$!{tableInfo.name}> queryWrapper) { - return this.$!{entityName}Mapper.selectPage(new Page<$!{tableInfo.name}>(pageNum, pageSize),queryWrapper); - } - - public $!{tableInfo.name} selectById(Integer id) { - return this.$!{entityName}Mapper.selectById(id); - } - - public List<$!{tableInfo.name}> selectBatchIds(List idList) { - return this.$!{entityName}Mapper.selectBatchIds(idList); - } - - public int insert($!{tableInfo.name} $!{entityName}) { - return this.$!{entityName}Mapper.insert($!{entityName}); - } - - public int updateById($!{tableInfo.name} $!{entityName}) { - return this.$!{entityName}Mapper.updateById($!{entityName}); - } - - public int deleteById(Integer id) { - return this.$!{entityName}Mapper.deleteById(id); - } - - public int deleteBatchIds(List idList) { - return this.$!{entityName}Mapper.deleteBatchIds(idList); - } +##导入宏定义 +$!init +$!define + +##设置表后缀(宏定义) +#setTableSuffix("Service") + +##保存文件(宏定义) +#save("/service", "Service.java") +##定义服务名 +##定义实体对象名 +#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) +##包路径(宏定义) +#setPackageSuffix("service") +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +/** +* ($!{tableInfo.name}) +* @author kuanghua +* @since $time.currTime() +*/ +@Service +public class $!{tableInfo.name}Service{ + + @Resource + private $!{tableInfo.name}Mapper $!{entityName}Mapper; + + public Page<$!{tableInfo.name}> selectPage(Integer pageNum, Integer pageSize, QueryWrapper<$!{tableInfo.name}> queryWrapper) { + return this.$!{entityName}Mapper.selectPage(new Page<$!{tableInfo.name}>(pageNum, pageSize),queryWrapper); + } + + public $!{tableInfo.name} selectById(Integer id) { + return this.$!{entityName}Mapper.selectById(id); + } + + public List<$!{tableInfo.name}> selectBatchIds(List idList) { + return this.$!{entityName}Mapper.selectBatchIds(idList); + } + + public int insert($!{tableInfo.name} $!{entityName}) { + return this.$!{entityName}Mapper.insert($!{entityName}); + } + + public int updateById($!{tableInfo.name} $!{entityName}) { + return this.$!{entityName}Mapper.updateById($!{entityName}); + } + + public int deleteById(Integer id) { + return this.$!{entityName}Mapper.deleteById(id); + } + + public int deleteBatchIds(List idList) { + return this.$!{entityName}Mapper.deleteBatchIds(idList); + } } \ No newline at end of file diff --git a/pom.xml b/pom.xml index 6da9d61..c10642e 100644 --- a/pom.xml +++ b/pom.xml @@ -119,19 +119,19 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/ty-example/pom.xml b/ty-example/pom.xml index bc88a27..b63dc78 100644 --- a/ty-example/pom.xml +++ b/ty-example/pom.xml @@ -34,6 +34,14 @@ fastdfs-client 1.27.2 + + + + cn.hutool + hutool-all + 4.5.1 + + com.xpand diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/GoFastDFSController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/GoFastDFSController.java new file mode 100644 index 0000000..5f9e1a5 --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/controller/GoFastDFSController.java @@ -0,0 +1,49 @@ +package top.kuanghua.tyexample.controller; + +import cn.hutool.core.io.resource.InputStreamResource; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSON; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; +import top.kuanghua.khcomomon.entity.ResResult; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * @Title: GoFastFDfs + * @Description: according to https://sjqzhang.github.io/go-fastdfs/usage.html + * @Auther: kuanghua + * @create 2022-01-12 13:35 + */ + +@RestController +@RequestMapping("upload") +@Api(tags = "文件上传") +@Slf4j +public class GoFastDFSController { + @ApiOperation(value = "上传图片或文件") + @PostMapping("file") + public ResResult goFastfdfs(@RequestParam("file") MultipartFile file) { + try { + InputStreamResource isr = new InputStreamResource(file.getInputStream(), file.getOriginalFilename()); + Map params = new HashMap<>(); + params.put("file", isr); + params.put("path", "86501729"); + params.put("output", "json"); + String resp = HttpUtil.post("http://8.135.1.141:8080/group1/upload", params); + Map coversMap = JSON.parseObject(resp, Map.class); + log.info(coversMap.toString()); + return new ResResult().success(coversMap); + } catch (IOException e) { + throw new RuntimeException("上传文件异常"); + } + } +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/UploadController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/UploadController.java deleted file mode 100644 index cd46146..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/UploadController.java +++ /dev/null @@ -1,84 +0,0 @@ -package top.kuanghua.tyexample.controller; - -import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cloud.context.config.annotation.RefreshScope; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.tyexample.service.UploadService; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; - -/** - * @Title: UploadController @Description: @Auther:jzfai @Version: 1.0 - * @create 2020/3/4 21:58 - */ -@RestController -@RequestMapping("upload") -@Api(tags = "图片上传") -@DefaultProperties(defaultFallback = "fallBackMethod") // 指定一个类的全局熔断方法 -@RefreshScope -public class UploadController { - - - @Autowired - private UploadService uploadService; - - @ApiOperation(value = "上传图片或文件", notes = "上传图片接口") - @PostMapping("image") - public ResResult uploadImage(@RequestParam("file") MultipartFile file) - throws IOException, InterruptedException { - String url = this.uploadService.upload(file); - Thread.sleep(20000); - HashMap map = new HashMap<>(); - map.put("shortPath", url); - return new ResResult().success(map); - } - - // -// @ApiOperation(value = "上传图片(多张)") -// @PostMapping("uploadGetMetaData") -// public ResResult uploadGetMetaData(@RequestParam("files") MultipartFile[] files) -// throws IOException, InterruptedException { -// ArrayList strings = new ArrayList<>(); -// for (MultipartFile file : files) { -// Map stringStringMap = this.uploadService.uploadGetMetaData(file); -// strings.add(stringStringMap); -// } -// //Thread.sleep(5000); -// return new ResResult().success(strings); -// } - @ApiOperation(value = "批量上传图片或文件") - @PostMapping("files") - public ResResult uploadFileList(@RequestParam("files") MultipartFile[] files) throws IOException { - ArrayList strings = new ArrayList<>(); - for (MultipartFile file : files) { - String url = this.uploadService.upload(file); - strings.add(url); - } - return new ResResult().success(strings); - } - - public String fallBackMethod() { - return "请求繁忙,请稍后再试!"; - } - -// @Value(value = "${demo.a}") -// private String data12; -// @Value(value = "${demo.b}") -// private String datas; -// @ApiOperation(value = "test") -// @GetMapping("test") -// public String test() { -// System.out.println("data :" + data12 + ",datas="+datas); -// return "data :" + data12 + ",datas="+datas; -// } -} diff --git a/ty-example/src/main/resources/bootstrap.yml b/ty-example/src/main/resources/bootstrap.yml index 883a2b2..f486be5 100644 --- a/ty-example/src/main/resources/bootstrap.yml +++ b/ty-example/src/main/resources/bootstrap.yml @@ -16,30 +16,26 @@ spring: file-extension: yml # 用于共享的配置文件 shared-configs: - - data-id: application-main.yml - group: @nacosGroup@ - refresh: true + - data-id: application-main.yml + group: @nacosGroup@ + refresh: true # 额外的配置文件 extension-configs: - #get mysql config - - data-id: application-db.yml - group: @nacosGroup@ - refresh: true - - data-id: application-rabbit.yml - group: @nacosGroup@ - refresh: true - #get redis config - - data-id: application-redis.yml - group: @nacosGroup@ - refresh: true - #get fdfs config - - data-id: application-upload.yml - group: @nacosGroup@ - refresh: true - #get seata config need after db config - - data-id: application-seata.yml - group: @nacosGroup@ - refresh: true + #get mysql config + - data-id: application-db.yml + group: @nacosGroup@ + refresh: true + - data-id: application-rabbit.yml + group: @nacosGroup@ + refresh: true + #get redis config + - data-id: application-redis.yml + group: @nacosGroup@ + refresh: true + #get seata config need after db config + - data-id: application-seata.yml + group: @nacosGroup@ + refresh: true discovery: namespace: @nacosNamespace@ group: @nacosGroup@ diff --git a/ty-upload/pom.xml b/ty-upload/pom.xml deleted file mode 100644 index cf71082..0000000 --- a/ty-upload/pom.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - micro-service-plus - top.kuanghua - 1.0-SNAPSHOT - - 4.0.0 - - ty-upload - - - top.kuanghua - ty-common - 1.0-SNAPSHOT - - - com.github.tobato - fastdfs-client - 1.27.2 - - - - - ${project.artifactId} - - - src/main/resources - true - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.1 - - true - - - - - - \ No newline at end of file diff --git a/ty-upload/src/main/java/top/kuanghua/tyupload/UploadApplication.java b/ty-upload/src/main/java/top/kuanghua/tyupload/UploadApplication.java deleted file mode 100644 index cb54be9..0000000 --- a/ty-upload/src/main/java/top/kuanghua/tyupload/UploadApplication.java +++ /dev/null @@ -1,18 +0,0 @@ -package top.kuanghua.tyupload; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; - -/** - * @Title: SmsApplication - * @Description: - * @Auther: - * @create 2020/8/20 10:46 - */ -@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) -public class UploadApplication { - public static void main(String[] args) { - SpringApplication.run(UploadApplication.class, args); - } -} diff --git a/ty-upload/src/main/java/top/kuanghua/tyupload/config/BaseConfig.java b/ty-upload/src/main/java/top/kuanghua/tyupload/config/BaseConfig.java deleted file mode 100644 index d8d6063..0000000 --- a/ty-upload/src/main/java/top/kuanghua/tyupload/config/BaseConfig.java +++ /dev/null @@ -1,21 +0,0 @@ -package top.kuanghua.tyupload.config; - -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * @Title: BaseConfig - * @Description: - * @Auther: kuanghua - * @create 2020/8/23 21:52 - */ -/* - * 总结:1.@Configuration 下的@ComponentScan回将包下带有@Component扫描变成配置类, - * 而@SpringBootApplication扫描的只会变成普通类 - * */ -@Configuration -//dao包扫描 -@ComponentScan(basePackages = {"top.kuanghua.khcomomon"}) -@EnableFeignClients(basePackages = {"top.kuanghua.feign"}) -public class BaseConfig {} diff --git a/ty-upload/src/main/java/top/kuanghua/tyupload/config/Swagger2Config.java b/ty-upload/src/main/java/top/kuanghua/tyupload/config/Swagger2Config.java deleted file mode 100644 index 731ecc1..0000000 --- a/ty-upload/src/main/java/top/kuanghua/tyupload/config/Swagger2Config.java +++ /dev/null @@ -1,52 +0,0 @@ -package top.kuanghua.tyupload.config; - -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Component -@EnableSwagger2 //开启在线接口文档 -//配置包扫描 -public class Swagger2Config { - private boolean swagger_is_enable = true; - -// @Value("${.ipAddr}") -// private String ipAddr; - @Value("${server.port}") - private String port; - - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .enable(swagger_is_enable) - //.host(this.ipAddr + ":" + this.port) - .apiInfo(apiInfo()) - .select() - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) - //.apis(basePackage("top.kuanghua.swagger.controller")) - .paths(PathSelectors.any()) - .build(); - } - - /** - * 构建 api文档的详细信息函数 - * @return - */ - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("标题:kuanghua") - .description("描述:新一代的微服务架构") - .contact(new Contact("jzfai", null, "869653722@qq.com")) - .version("版本号:2.9") - .build(); - } -} diff --git a/ty-upload/src/main/java/top/kuanghua/tyupload/controller/NacosTestDemo.java b/ty-upload/src/main/java/top/kuanghua/tyupload/controller/NacosTestDemo.java deleted file mode 100644 index 17b6a68..0000000 --- a/ty-upload/src/main/java/top/kuanghua/tyupload/controller/NacosTestDemo.java +++ /dev/null @@ -1,44 +0,0 @@ -package top.kuanghua.tyupload.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.CrossOrigin; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import top.kuanghua.feign.tyauth.feign.TokenFeign; -import top.kuanghua.khcomomon.entity.ResResult; - -import java.util.HashMap; - -/** - * @Title: NacosTestDemo - * @Description: - * @Auther: kuanghua - * @create 2021/5/12 11:16 - */ - -@Api("nacos测试") -@RequestMapping("NacosTestDemo") -@RestController -public class NacosTestDemo { - @Autowired - private TokenFeign tokenFeign; - @ApiOperation("第一个") - @GetMapping("test") - public ResResult test(){ - HashMap hashMap = new HashMap(); - hashMap.put("username","邝华"); - ResResult resResult = tokenFeign.generateToken(hashMap); - //System.out.println(resResult); - return resResult; - } - - @ApiOperation("第二个") - @GetMapping("test2") - public ResResult test2(String token){ - ResResult resResult = tokenFeign.parseToken(token); - return resResult; - } -} diff --git a/ty-upload/src/main/java/top/kuanghua/tyupload/controller/TestController.java b/ty-upload/src/main/java/top/kuanghua/tyupload/controller/TestController.java deleted file mode 100644 index 89b5141..0000000 --- a/ty-upload/src/main/java/top/kuanghua/tyupload/controller/TestController.java +++ /dev/null @@ -1,14 +0,0 @@ -package top.kuanghua.tyupload.controller; - -import org.springframework.web.bind.annotation.CrossOrigin; - -/** - * @Title: TestController - * @Description: - * @Auther: kuanghua - * @create 2021-11-09 10:57 - */ -@CrossOrigin -public class TestController { - -} \ No newline at end of file diff --git a/ty-upload/src/main/java/top/kuanghua/tyupload/controller/UploadController.java b/ty-upload/src/main/java/top/kuanghua/tyupload/controller/UploadController.java deleted file mode 100644 index 86d6752..0000000 --- a/ty-upload/src/main/java/top/kuanghua/tyupload/controller/UploadController.java +++ /dev/null @@ -1,83 +0,0 @@ -package top.kuanghua.tyupload.controller; - -import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cloud.context.config.annotation.RefreshScope; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.tyupload.service.UploadService; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; - -/** - * @Title: UploadController @Description: @Auther:jzfai @Version: 1.0 - * @create 2020/3/4 21:58 - */ -@RestController -@RequestMapping("upload") -@Api(tags = "图片上传") -@DefaultProperties(defaultFallback = "fallBackMethod") // 指定一个类的全局熔断方法 - -@RefreshScope -public class UploadController { - - @Autowired - private UploadService uploadService; - - @ApiOperation(value = "上传图片", notes = "上传图片接口") - @PostMapping("image") - public ResResult uploadImage(@RequestParam("file") MultipartFile file) - throws IOException, InterruptedException { - String url = this.uploadService.upload(file); - // Thread.sleep(5000); - HashMap map = new HashMap<>(); - map.put("shortPath",url); - return new ResResult().success(map); - } -// -// @ApiOperation(value = "上传图片(多张)") -// @PostMapping("uploadGetMetaData") -// public ResResult uploadGetMetaData(@RequestParam("files") MultipartFile[] files) -// throws IOException, InterruptedException { -// ArrayList strings = new ArrayList<>(); -// for (MultipartFile file : files) { -// Map stringStringMap = this.uploadService.uploadGetMetaData(file); -// strings.add(stringStringMap); -// } -// //Thread.sleep(5000); -// return new ResResult().success(strings); -// } - @ApiOperation(value = "批量上传文件") - @PostMapping("files") - public ResResult uploadFileList(@RequestParam("files") MultipartFile[] files) throws IOException { - ArrayList strings = new ArrayList<>(); - for (MultipartFile file : files) { - String url = this.uploadService.upload(file); - strings.add(url); - } - return new ResResult().success(strings); - } - - public String fallBackMethod() { - return "请求繁忙,请稍后再试!"; - } - -// @Value(value = "${demo.a}") -// private String data12; -// @Value(value = "${demo.b}") -// private String datas; -// @ApiOperation(value = "test") -// @GetMapping("test") -// public String test() { -// System.out.println("data :" + data12 + ",datas="+datas); -// return "data :" + data12 + ",datas="+datas; -// } -} diff --git a/ty-upload/src/main/java/top/kuanghua/tyupload/service/UploadService.java b/ty-upload/src/main/java/top/kuanghua/tyupload/service/UploadService.java deleted file mode 100644 index 782685f..0000000 --- a/ty-upload/src/main/java/top/kuanghua/tyupload/service/UploadService.java +++ /dev/null @@ -1,91 +0,0 @@ -package top.kuanghua.tyupload.service; - - -import com.alibaba.fastjson.JSON; -import com.github.tobato.fastdfs.domain.fdfs.MetaData; -import com.github.tobato.fastdfs.domain.fdfs.StorePath; -import com.github.tobato.fastdfs.service.FastFileStorageClient; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; - -import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.util.*; - -/** - * @Title: UploadService - * @Description: - * @Auther:jzfai - * @Version: 1.0 - * @create 2020/3/4 21:58 - */ -@Service -@Slf4j -public class UploadService { - - @Autowired - private FastFileStorageClient storageClient; - - private static final List CONTENT_TYPES = Arrays.asList("image/jpeg", "image/gif"); - - public String upload(MultipartFile file) throws IOException { - String originalFilename = file.getOriginalFilename(); - //检验文件类型 - String contentType = file.getContentType(); - if (!CONTENT_TYPES.contains(contentType)) { - //文件类型不合法 - log.info("文件类型不合法:{}", originalFilename); - throw new RuntimeException("文件内容不合法"); - } - //检验文件内容 - BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); - if (bufferedImage == null) { - log.info("文件内容不合法:{}", originalFilename); - throw new RuntimeException("文件内容不合法"); - } - //保存到服务器 - //file.transferTo(new File("D:\\java\\javaproject\\pinyou\\pinyou-upload\\src\\main\\resources\\static\\" + originalFilename)); - //上传到FastDfs - String ext = StringUtils.substringAfterLast(originalFilename, "."); - HashSet metaData = new HashSet<>(); - metaData.add(new MetaData("name", file.getOriginalFilename())); - metaData.add(new MetaData("createTime", JSON.toJSONString(new Date()))); - StorePath storePath = this.storageClient.uploadFile(file.getInputStream(), file.getSize(), ext, metaData); - return storePath.getFullPath(); - } - - public Map uploadGetMetaData(MultipartFile file) throws IOException { - String originalFilename = file.getOriginalFilename(); - //检验文件类型 - String contentType = file.getContentType(); - if (!CONTENT_TYPES.contains(contentType)) { - //文件类型不合法 - log.info("文件类型不合法:{}", originalFilename); - } - //检验文件内容 - BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); - if (bufferedImage == null) { - log.info("文件内容不合法:{}", originalFilename); - } - //保存到服务器 - //file.transferTo(new File("D:\\java\\javaproject\\pinyou\\pinyou-upload\\src\\main\\resources\\static\\" + originalFilename)); - //上传到FastDfs - String ext = StringUtils.substringAfterLast(originalFilename, "."); - HashSet metaData = new HashSet<>(); - metaData.add(new MetaData("name", file.getOriginalFilename())); - StorePath storePath = this.storageClient.uploadFile(file.getInputStream(), file.getSize(), ext, metaData); - //获取数据源信息 - Set metadata = this.storageClient.getMetadata(storePath.getGroup(), storePath.getPath()); - ArrayList metaDataArrayList = new ArrayList<>(metadata); - String name = metaDataArrayList.get(0).getValue(); - //拼接name和url返回 - Map hashMap = new HashMap<>(); - hashMap.put("name", name); - hashMap.put("url", storePath.getFullPath()); - return hashMap; - } -} diff --git a/ty-upload/src/main/javabrandE/BrandE.vue b/ty-upload/src/main/javabrandE/BrandE.vue deleted file mode 100644 index 070a2e6..0000000 --- a/ty-upload/src/main/javabrandE/BrandE.vue +++ /dev/null @@ -1,266 +0,0 @@ - - - - - - diff --git a/ty-upload/src/main/javabrandE/BrandEForm.vue b/ty-upload/src/main/javabrandE/BrandEForm.vue deleted file mode 100644 index b212c74..0000000 --- a/ty-upload/src/main/javabrandE/BrandEForm.vue +++ /dev/null @@ -1,227 +0,0 @@ - - - - - - diff --git a/ty-upload/src/main/main11.iml b/ty-upload/src/main/main11.iml deleted file mode 100644 index f608aea..0000000 --- a/ty-upload/src/main/main11.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/ty-upload/src/main/resources/application.yml b/ty-upload/src/main/resources/application.yml deleted file mode 100644 index e69de29..0000000 diff --git a/ty-upload/src/main/resources/bootstrap.yml b/ty-upload/src/main/resources/bootstrap.yml deleted file mode 100644 index 3609f31..0000000 --- a/ty-upload/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,35 +0,0 @@ -spring: - application: - name: @project.artifactId@ - profiles: - active: @activatedProperties@ - cloud: - nacos: - config: - enabled: true - namespace: @nacosNamespace@ - group: @nacosGroup@ - username: @nacosUsername@ - password: @nacosPassword@ - server-addr: @nacosIpPort@ - prefix: @project.artifactId@ - file-extension: yml - # 用于共享的配置文件 - shared-configs: - - data-id: application-main.yml - group: @nacosGroup@ - refresh: true - extension-configs: - - data-id: @project.artifactId@.yml - group: @nacosGroup@ - refresh: true - - data-id: application-upload.yml - group: @nacosGroup@ - refresh: true - discovery: - namespace: @nacosNamespace@ - group: @nacosGroup@ - username: @nacosUsername@ - password: @nacosPassword@ - server-addr: @nacosIpPort@ - weight: @nacosWeight@ \ No newline at end of file diff --git a/ty-upload/src/test/java/top/kuanghua/tyupload/controller/UploadControllerTest.java b/ty-upload/src/test/java/top/kuanghua/tyupload/controller/UploadControllerTest.java deleted file mode 100644 index 9134a1d..0000000 --- a/ty-upload/src/test/java/top/kuanghua/tyupload/controller/UploadControllerTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package top.kuanghua.tyupload.controller; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -import java.util.HashMap; -import java.util.Map; - -/** - * @Title: UploadControllerTest @Description: @Auther: kuanghua - * @create 2020/8/20 21:34 - */ -@SpringBootTest -@RunWith(SpringRunner.class) -class UploadControllerTest { - - @Autowired - private UploadControllerTest uploadControllerTest; - - @Test - void uploadImage() { - Map hashMap = new HashMap<>(); - hashMap.put("", ""); - } -} diff --git a/ty-upload/src/test/test2.iml b/ty-upload/src/test/test2.iml deleted file mode 100644 index a0e49a3..0000000 --- a/ty-upload/src/test/test2.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file From 925b3bee0a10e845f4326436060c887b945de66e Mon Sep 17 00:00:00 2001 From: jzfai <869653722@qq.com> Date: Thu, 13 Jan 2022 18:15:48 +0800 Subject: [PATCH 18/36] update README.md --- README-zh_CN.md | 90 ++++++--- README.md | 187 ++++++++++++++---- .../controller/RedisTestController.java | 2 +- 3 files changed, 215 insertions(+), 64 deletions(-) diff --git a/README-zh_CN.md b/README-zh_CN.md index f198909..b922264 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -1,19 +1,42 @@ +# micro-service-plus + +**中文** | [English](./README.md) + +``` +> micro-service-plus提供企业级的开发demo +``` + ### 前言 -本架构为springCloud微服务架构,提供基本的jwt权限认证,token更新,以及各微服务之间调用等 -使用的技术如下: +本架构为springCloud微服务架构,提供基本的jwt权限认证,token更新,以及各微服务之间调用,以及提供企业级的使用例子 ```java spring-boot:2.1.4.RELEASE -spring-cloud:Greenwich.SR1 -spring-cloud-starter-gateway:2.1.1.RELEASE -nacos:2.1.3.RELEASE -mybatis-plus: 3.3.2 -rabbitmq:3.7-management -redis: 3.2.9 -mysql:5.7 + spring-cloud:Greenwich.SR1 + spring-cloud-starter-gateway:2.1.1.RELEASE + nacos:2.1.3.RELEASE + mybatis-plus:3.3.2 + rabbitmq:3.7-management + redis:3.2.9 + mysql:5.7 + seata:1.4.2 + canal:1.2.1 ``` +> 以上部分版本后续会升级 + +### 推荐阅读: + +使用save action 保存自动格式化代码 + +http://www.360doc.com/content/21/1130/10/77916903_1006517212.shtml + +网关hystix和ribbon超时时间熔断设置 +https://blog.csdn.net/u014203449/article/details/105248914?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~aggregatepage~first_rank_ecpm_v1~rank_v31_ecpm-1-105248914.pc_agg_new_rank&utm_term=gateway%E8%AE%BE%E7%BD%AE%E8%B6%85%E6%97%B6%E6%97%B6%E9%97%B4&spm=1000.2123.3001.4430 + +高并发架构系列:Kafka、RocketMQ、RabbitMQ的优劣势比较 +https://www.jianshu.com/p/fec054f3e496 + #### 更新日志: to look doc ---- @@ -30,7 +53,6 @@ to look doc ---- [nacos地址](http://8.135.1.141:8848/nacos/) naocs: 用户名:jzfai; 密码:123456 - #### 线上体验地址: [github address](https://github.com/jzfai/micro-service-plus.git) @@ -41,31 +63,49 @@ to look doc ---- github 地址: https://github.com/jzfai/micro-service-plus.git - - #### 目前实现的微服务(后续还会新增新的微服务) -``` -ty-common: 统一依赖,统一配置管理,feign接口整合等 -本架构的微服务有: -ty-gateway:网关微服务。使用的是spring-cloud-starter-gateway,先对于zull网关来说性能更好。主要实现了,权限控制和拦截,jwt token解析和校验,swagger文件整合,使用令牌技术请求限流等 -ty-auth:权限服务。jwt token生成,解析,校验等,默认配置3天有效期,少于一天自动续约(此处感兴趣的可以查看下源码) -integration-front:用户服务。用户的登录,注册,查看用户信息等一系列功能 -ty-excel:excel文件的读取和导出 -ty-upload:文件上传服务。使用的技术为fastDFS技术,此服务主要用于文件的上传和下载 +```javascript +ty - gateway - one +: +网关微服务。使用的是spring - cloud - starter - gateway,相对于zull网关来说性能更好。主要实现了,权限控制和拦截,jwt +token解析和校验, swagger文件整合,使用令牌技术请求限流等。可启动多个 +ty - auth:权限服务。jwt +token生成,解析,校验等,默认配置3天有效期,少于一天自动续约(此处感兴趣的可以查看下源码) +ty - example +: +提供一些例子。包括,rabbitmq延时队列,goFastDFS文件上传,canal, seata分部式事务,短信发送,邮件发送等。 +integration - front:数据整合。vue3 - admin - plus +数据来源 +easycode - temp:easycode前后端模板 ``` - #### 如何运行 -```java -//git clone项目 -git clone https://github.com/jzfai/micro-service-plus.git +运行micro-service-plus,默认选择的是test分支 +``` +git clone https://github.com/jzfai/micro-service-plus.git //maven 下载依赖,即可运行 ``` ->注:在Maven Projects->Profies 选择环境时,请不要选择prod环境。目前线上是prod环境下构建的包 +如何配合vue3-admin-plus ,前后端一起开发 + +```java +#vue3-admin-plus + git clone https://github.com/jzfai/vue3-admin-plus.git + pnpm i + #test分支请求本地的网关 + pnpm run test + + #micro-service-plus 至少需要运行 + ty-auth + ty-gateway-one + ty-integration-front + 以上三个服务 +``` + +> 注:在Maven Projects->Profies 选择环境。目前线上是prod环境下构建的包,请不要选择。 #### 架构亮点 diff --git a/README.md b/README.md index 1eae783..bfcfd5d 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,52 @@ -### 前言 +### foreword -本架构为springCloud微服务架构,提供基本的jwt权限认证,token更新,以及各微服务之间调用等 -使用的技术如下: +this architecture is the springCloud microservice architecture, which provides basic jwt authorization authentication, +token update, and calls between microservices, as well as enterprise-level usage examples. ```java spring-boot:2.1.4.RELEASE -spring-cloud:Greenwich.SR1 -spring-cloud-starter-gateway:2.1.1.RELEASE -nacos:2.1.3.RELEASE -mybatis-plus: 3.3.2 -rabbitmq:3.7-management -redis: 3.2.9 -mysql:5.7 -seata:1.4.2 -cancel + spring-cloud:Greenwich.SR1 + spring-cloud-starter-gateway:2.1.1.RELEASE + nacos:2.1.3.RELEASE + mybatis-plus:3.3.2 + rabbitmq:3.7-management + redis:3.2.9 + mysql:5.7 + seata:1.4.2 + canal:1.2.1 ``` +> some of the above versions will be upgraded in the future -#### 更新日志: +### Recommended reading + +使用save action 保存自动格式化代码 + +http://www.360doc.com/content/21/1130/10/77916903_1006517212.shtml + +网关hystix和ribbon超时时间熔断设置 +https://blog.csdn.net/u014203449/article/details/105248914?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~aggregatepage~first_rank_ecpm_v1~rank_v31_ecpm-1-105248914.pc_agg_new_rank&utm_term=gateway%E8%AE%BE%E7%BD%AE%E8%B6%85%E6%97%B6%E6%97%B6%E9%97%B4&spm=1000.2123.3001.4430 + +高并发架构系列:Kafka、RocketMQ、RabbitMQ的优劣势比较 +https://www.jianshu.com/p/fec054f3e496 + +#### update log to look doc ---- [带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7044843310204059655) -#### 线上文档: +#### online documentation [带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7044843310204059655) -#### 开发接口和nacos地址 +#### Interface documentation and nacos address [swager文档地址](http://8.135.1.141/micro-service-doc/swagger-ui.html) [nacos地址](http://8.135.1.141:8848/nacos/) naocs: 用户名:jzfai; 密码:123456 - -#### 线上体验地址: +#### Online experience address [github address](https://github.com/jzfai/micro-service-plus.git) @@ -44,40 +56,139 @@ to look doc ---- github 地址: https://github.com/jzfai/micro-service-plus.git +#### Introduction to Microservices + +```javascript +ty - gateway - one +: +Gateway +Microservices.The +spring - cloud - starter - gateway +is +used, which +has +better +performance +than +the +zull +gateway.It +mainly +implements +permission +control +and +interception, jwt +token +parsing +and +verification, swagger +file +integration, and +request +current +limiting +using +token +technology.Can +start +multiple + +ty - auth:Permission +service.jwt +token +generation, parsing, verification, etc., the +default +configuration +is +valid +for 3 days, and +the +contract +is +automatically +renewed +if it is +less +than +one +day( +if you are +interested +here, you +can +view +the +source +code +) + +ty - example +: +Provide +some +examples.Including, rabbitmq +delay +queue, goFastDFS +file +upload, canal, seata +partial +transaction, SMS +sending, mail +sending, etc.integration - front:Data +Integration.vue3 - admin - plus +data +source + +easycode - temp:easycode +front - end +and +back - end +templates +``` +#### How to run -#### 目前实现的微服务(后续还会新增新的微服务) +Run micro-service-plus, the default selection is the test branch ``` -ty-common: 统一依赖,统一配置管理,feign接口整合等 -本架构的微服务有: -ty-gateway:网关微服务。使用的是spring-cloud-starter-gateway,先对于zull网关来说性能更好。主要实现了,权限控制和拦截,jwt token解析和校验,swagger文件整合,使用令牌技术请求限流等 -ty-auth:权限服务。jwt token生成,解析,校验等,默认配置3天有效期,少于一天自动续约(此处感兴趣的可以查看下源码) -integration-front:前端实例数据。用户的登录,注册,查看用户信息等一系列功能 -ty-example:全分布式事务seata,rabbitmq延时队列,短信发送,email发送,canal等功能实例 +git clone https://github.com/jzfai/micro-service-plus.git +//maven download the depdences ``` - -#### 如何运行 +How to cooperate with vue3-admin-plus to develop front-end and back-end together ```java -//git clone项目 -git clone https://github.com/jzfai/micro-service-plus.git - -//maven 下载依赖,即可运行 +#vue3-admin-plus + git clone https://github.com/jzfai/vue3-admin-plus.git + pnpm i + #test Branch requests local gateway + pnpm run test + + #micro-service-plus At least need to run + ty-auth + ty-gateway-one + ty-integration-front + + The above three service ``` ->注:在Maven Projects->Profies 选择环境时,请不要选择prod环境。目前线上是prod环境下构建的包 - +> Note: Select the environment in Maven Projects->Profies. Currently online is a package built in the prod environment, please do not select. -#### 架构亮点 +#### Architecture Highlights -1.网关中将jwt token和解析后的token信息已经设置在请求头中,在后续转发的微服务可以在请求头中,轻松的拿到token和token解析后的数据。不用再通过feign去调用ty-auth,获取token信息。 +1. In the gateway, the jwt token and the parsed token information have been set in the request header, and the + subsequent forwarding microservices can easily get the token and token parsed data in the request header. There is no + need to call ty-auth through feign to obtain token information. -2.各微服务在调用期间,会将请求头的token进行转发。所以在用feign调用微服务时token也不会丢失。 +2. During the invocation of each microservice, the token in the request header will be forwarded. So the token will not + be lost when calling the microservice with feign. -3.少于1天时间自动更新token,通过isNeedUpdateToken字段告诉前端需要更新token,实现了token续约的功能 +3. The token is automatically updated in less than 1 day, and the isNeedUpdateToken field is used to tell the front end + that the token needs to be updated, realizing the function of token renewal -4.多环境随意切换。在根目录下的pom.xml配置了profiles可以根据你的需要进行切换环境 +4. Switch between multiple environments at will. In the pom.xml in the root directory, profiles are configured to switch + the environment according to your needs. -5.提供了vue3+element-plus和mybits-plus相关的easycode模板。你可以一次性生成前后端模板,极大提高开发效率 \ No newline at end of file +5. Provides easycode templates related to vue3+element-plus and mybits-plus. You can generate front-end and back-end + templates at one time, greatly improving development efficiency \ No newline at end of file diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java index 69a2a70..ea895c9 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java @@ -26,7 +26,7 @@ * @Auther: kuanghua * @create 2022-01-09 16:48 */ -@Api(tags = "缓存击穿和雪崩解决方案") +@Api(tags = "缓存击穿和雪崩,redis锁") @RestController @RequestMapping("redisCache") public class RedisTestController { From c64284a42ad67c2b0282cd99b5069a27a33c600a Mon Sep 17 00:00:00 2001 From: jzfai <869653722@qq.com> Date: Fri, 14 Jan 2022 14:50:41 +0800 Subject: [PATCH 19/36] leave ty-excel --- README-zh_CN.md | 74 +++++---- README.md | 148 +++++------------- ty-example/src/main/resources/bootstrap.yml | 2 +- .../filter/AuthorizeFilterAfter.java | 62 ++------ .../filter/AuthorizeFilterBefore.java | 11 +- .../src/main/resources/application.yml | 140 ++++++++--------- 6 files changed, 167 insertions(+), 270 deletions(-) diff --git a/README-zh_CN.md b/README-zh_CN.md index b922264..db9583c 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -10,17 +10,17 @@ 本架构为springCloud微服务架构,提供基本的jwt权限认证,token更新,以及各微服务之间调用,以及提供企业级的使用例子 -```java +```yaml spring-boot:2.1.4.RELEASE - spring-cloud:Greenwich.SR1 - spring-cloud-starter-gateway:2.1.1.RELEASE - nacos:2.1.3.RELEASE - mybatis-plus:3.3.2 - rabbitmq:3.7-management - redis:3.2.9 - mysql:5.7 - seata:1.4.2 - canal:1.2.1 +spring-cloud:Greenwich.SR1 +spring-cloud-starter-gateway:2.1.1.RELEASE +nacos:2.1.3.RELEASE +mybatis-plus:3.3.2 +rabbitmq:3.7-management +redis:3.2.9 +mysql:5.7 +seata:1.4.2 +canal:1.2.1 ``` > 以上部分版本后续会升级 @@ -65,20 +65,26 @@ github 地址: https://github.com/jzfai/micro-service-plus.git #### 目前实现的微服务(后续还会新增新的微服务) -```javascript -ty - gateway - one -: -网关微服务。使用的是spring - cloud - starter - gateway,相对于zull网关来说性能更好。主要实现了,权限控制和拦截,jwt -token解析和校验, swagger文件整合,使用令牌技术请求限流等。可启动多个 -ty - auth:权限服务。jwt -token生成,解析,校验等,默认配置3天有效期,少于一天自动续约(此处感兴趣的可以查看下源码) -ty - example -: +##### ty - gateway - one + +网关微服务。使用的是spring - cloud - starter - gateway,相对于zull网关来说性能更好。主要实现了,权限控制和拦截,jwt token解析和校验, +swagger文件整合,使用令牌技术请求限流等。可启动多个实例 + +##### ty - auth + +权限服务。jwt token生成,解析,校验等,默认配置3天有效期,少于一天自动续约 + +##### ty - example + 提供一些例子。包括,rabbitmq延时队列,goFastDFS文件上传,canal, seata分部式事务,短信发送,邮件发送等。 -integration - front:数据整合。vue3 - admin - plus -数据来源 -easycode - temp:easycode前后端模板 -``` + +##### integration - front + +数据整合。vue3 - admin - plus 数据来源 + +##### easycode - temp + +easycode前后端模板 #### 如何运行 @@ -91,18 +97,18 @@ git clone https://github.com/jzfai/micro-service-plus.git 如何配合vue3-admin-plus ,前后端一起开发 -```java +```shell #vue3-admin-plus - git clone https://github.com/jzfai/vue3-admin-plus.git - pnpm i - #test分支请求本地的网关 - pnpm run test - - #micro-service-plus 至少需要运行 - ty-auth - ty-gateway-one - ty-integration-front - 以上三个服务 +git clone https://github.com/jzfai/vue3-admin-plus.git +pnpm i +#test分支请求本地的网关 +pnpm run test + +#micro-service-plus 至少需要运行 +ty-auth +ty-gateway-one +ty-integration-front +以上三个服务 ``` > 注:在Maven Projects->Profies 选择环境。目前线上是prod环境下构建的包,请不要选择。 diff --git a/README.md b/README.md index bfcfd5d..1b08ea7 100644 --- a/README.md +++ b/README.md @@ -3,17 +3,17 @@ this architecture is the springCloud microservice architecture, which provides basic jwt authorization authentication, token update, and calls between microservices, as well as enterprise-level usage examples. -```java +```yml spring-boot:2.1.4.RELEASE - spring-cloud:Greenwich.SR1 - spring-cloud-starter-gateway:2.1.1.RELEASE - nacos:2.1.3.RELEASE - mybatis-plus:3.3.2 - rabbitmq:3.7-management - redis:3.2.9 - mysql:5.7 - seata:1.4.2 - canal:1.2.1 + spring-cloud:Greenwich.SR1 + spring-cloud-starter-gateway:2.1.1.RELEASE + nacos:2.1.3.RELEASE +mybatis-plus: 3.3.2 + rabbitmq:3.7-management +redis: 3.2.9 + mysql:5.7 + seata:1.4.2 + canal:1.2.1 ``` > some of the above versions will be upgraded in the future @@ -58,94 +58,26 @@ github 地址: https://github.com/jzfai/micro-service-plus.git #### Introduction to Microservices -```javascript -ty - gateway - one -: -Gateway -Microservices.The -spring - cloud - starter - gateway -is -used, which -has -better -performance -than -the -zull -gateway.It -mainly -implements -permission -control -and -interception, jwt -token -parsing -and -verification, swagger -file -integration, and -request -current -limiting -using -token -technology.Can -start -multiple - -ty - auth:Permission -service.jwt -token -generation, parsing, verification, etc., the -default -configuration -is -valid -for 3 days, and -the -contract -is -automatically -renewed -if it is -less -than -one -day( -if you are -interested -here, you -can -view -the -source -code -) - -ty - example -: -Provide -some -examples.Including, rabbitmq -delay -queue, goFastDFS -file -upload, canal, seata -partial -transaction, SMS -sending, mail -sending, etc.integration - front:Data -Integration.vue3 - admin - plus -data -source - -easycode - temp:easycode -front - end -and -back - end -templates -``` +##### ty-gateway-one: + +gateway Microservices. The spring-cloud-starter-gateway is used, which has better performance than the zull gateway. It +mainly implements permission control and interception, jwt token parsing and verification, swagger file integration, and +request current limiting using token technology. Can start multiple + +##### ty-auth: + +permission service. jwt token generation, parsing, verification, etc., the default configuration is valid for 3 days, +and the contract is automatically renewed if it is less than one day (if you are interested here, you can view the +source code) + +##### ty-example: + +provide some examples. Including, rabbitmq delay queue, goFastDFS file upload, canal, seata partial transaction, SMS +sending, mail sending, etc. + +##### integration-front: + +data Integration. vue3-admin-plus data source easycode-temp:easycode front-end and back-end templates #### How to run @@ -158,19 +90,19 @@ git clone https://github.com/jzfai/micro-service-plus.git How to cooperate with vue3-admin-plus to develop front-end and back-end together -```java +```shell #vue3-admin-plus - git clone https://github.com/jzfai/vue3-admin-plus.git - pnpm i - #test Branch requests local gateway - pnpm run test +git clone https://github.com/jzfai/vue3-admin-plus.git +pnpm i + #test Branch requests local gateway +pnpm run test - #micro-service-plus At least need to run - ty-auth - ty-gateway-one - ty-integration-front + #micro-service-plus At least need to run +ty-auth +ty-gateway-one +ty-integration-front - The above three service +The above three service ``` > Note: Select the environment in Maven Projects->Profies. Currently online is a package built in the prod environment, please do not select. diff --git a/ty-example/src/main/resources/bootstrap.yml b/ty-example/src/main/resources/bootstrap.yml index f486be5..191e96f 100644 --- a/ty-example/src/main/resources/bootstrap.yml +++ b/ty-example/src/main/resources/bootstrap.yml @@ -2,7 +2,7 @@ spring: application: name: @project.artifactId@ profiles: - active: @activatedProperties@ + active: "" cloud: nacos: config: diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java index f3ca5c0..d9bc688 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java @@ -1,13 +1,11 @@ package top.kuanghua.gatewaytwo.filter; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.joda.time.DateTime; import org.reactivestreams.Publisher; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.cloud.gateway.filter.GatewayFilterChain; import org.springframework.cloud.gateway.filter.GlobalFilter; @@ -16,7 +14,6 @@ import org.springframework.core.io.buffer.DataBufferFactory; import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.io.buffer.DefaultDataBufferFactory; -import org.springframework.http.HttpHeaders; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.http.server.reactive.ServerHttpResponseDecorator; @@ -29,12 +26,10 @@ import javax.annotation.Resource; import java.net.URLDecoder; -import java.net.URLEncoder; import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; import java.util.List; import java.util.Map; + /** * @Title: AuthorizeFilter * @Description: @@ -47,15 +42,10 @@ public class AuthorizeFilterAfter implements GlobalFilter, Ordered { @Value("#{'${filter.allowPaths:}'.empty ? null : '${filter.allowPaths:}'.split(',')}") private List allowPaths; - - - @Value("#{'${filter.notValidExpList:}'.empty ? null : '${filter.notValidExpList:}'.split(',')}") - private List notValidExpList; - + @Resource private TokenFeign tokenFeign; - // @Value("${jwt-properties.pubKeyPath}") -// private String pubKeyPath; + @Value("${token-properties.renewTokenMinute}") private int renewTokenMinute; @@ -68,17 +58,11 @@ public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { //白名单拦截 for (String allowPath : allowPaths) { - if(StringUtils.contains(path,allowPath)){ - return chain.filter(exchange); + if (StringUtils.contains(path, allowPath)) { + return chain.filter(exchange); } } - //不校验exp时间 - for (String allowPath : notValidExpList) { - if(StringUtils.contains(path,allowPath)){ - return chain.filter(exchange); - } - } //获取token信息比较exp和当前时间进行比较 ServerHttpResponseDecorator decoratedResponse = null; @@ -101,38 +85,33 @@ public Mono writeWith(Publisher body) { //2.1.2 如果小于一个小时 刷新token //String jwtToken = request.getHeaders().getFirst("AUTHORIZE_TOKEN"); Long expValue = null; - Map dataMap=null; + Map dataMap = null; try { - //Object reqData=tokenFeign.parseToken(jwtToken); - // Map map = JSON.parseObject(JSON.toJSONString(reqData), Map.class); String tokenInfo = request.getHeaders().getFirst("TOKEN_INFO"); - //System.out.println("获取到新的token"+tokenInfo); dataMap = JSON.parseObject(URLDecoder.decode(tokenInfo, "utf-8"), Map.class); - expValue = ObjectUtilsSelf.toLong(ObjectUtilsSelf.toString(dataMap.get("exp"))+"000"); + expValue = ObjectUtilsSelf.toLong(ObjectUtilsSelf.toString(dataMap.get("exp")) + "000"); } catch (Exception e) { e.printStackTrace(); } - Long currentData= DateTime.now().plusMinutes(renewTokenMinute).getMillis(); - Map strMap=JSON.parseObject(str, Map.class); - if(ObjectUtils.isNotEmpty(expValue)&&expValue < currentData){ - String generateToken=null; + Long currentData = DateTime.now().plusMinutes(renewTokenMinute).getMillis(); + Map strMap = JSON.parseObject(str, Map.class); + if (ObjectUtils.isNotEmpty(expValue) && expValue < currentData) { + String generateToken = null; try { - //使用本地生成 - //generateToken = JwtUtilsKh.updateToken(dataMap, RsaUtils.getPrivateKey(priKeyPath), 62); //调用ty-auth进行生成 dataMap.remove("exp"); dataMap.remove("iat"); Object object = tokenFeign.updateToken(dataMap); - if(ObjectUtilsSelf.isEmpty(object)){ + if (ObjectUtilsSelf.isEmpty(object)) { return bufferFactory.wrap(str.getBytes()); } Map map = JSON.parseObject(JSON.toJSONString(object), Map.class); generateToken = ObjectUtilsSelf.toString(map.get("data")); } catch (Exception e) { - //log.error(e.toString()); + log.error(e.toString()); } - strMap.put("isNeedUpdateToken",true); - strMap.put("updateToken",generateToken); + strMap.put("isNeedUpdateToken", true); + strMap.put("updateToken", generateToken); } response.getHeaders().setContentLength(JSON.toJSONString(strMap).getBytes().length); return bufferFactory.wrap(JSON.toJSONString(strMap).getBytes()); @@ -143,20 +122,11 @@ public Mono writeWith(Publisher body) { } }; } catch (Exception e) { - return chain.filter(exchange); + return chain.filter(exchange); } return chain.filter(exchange.mutate().response(decoratedResponse).build()); } - private DataBuffer getDataBuffer(ServerHttpResponse response, JSONObject message) { - byte[] bits = message.toJSONString().getBytes(StandardCharsets.UTF_8); - DataBuffer buffer = response.bufferFactory().wrap(bits); - //response.setStatusCode(HttpStatus.UNAUTHORIZED); - //指定编码,否则在浏览器中会中文乱码 - response.getHeaders().add("Content-Type", "text/plain;charset=UTF-8"); - return buffer; - } - /*-1代表请求后触发*/ @Override public int getOrder() { diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java index 75eecf8..e902ea0 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java @@ -47,12 +47,6 @@ public class AuthorizeFilterBefore implements GlobalFilter, Ordered { private static final String AUTHORIZE_TOKEN = "AUTHORIZE_TOKEN"; @Value("#{'${filter.allowPaths:}'.empty ? null : '${filter.allowPaths:}'.split(',')}") private List allowPaths; -// @Value("${filter.allowPaths}") -// private String allowPaths; -// @Value("${jwt-properties.pubKeyPath}") -// private String pubKeyPath; -// @Value("${jwt-properties.priKeyPath}") -// private String priKeyPath; @Resource private TokenFeign tokenFeign; @@ -63,7 +57,7 @@ public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { ServerHttpResponse response = exchange.getResponse(); String path = request.getURI().getPath(); - //List stringList = Arrays.asList("/api/user/login","/api/search/searchData"); + //1.白名单放行 for (String allowPath : allowPaths) { if (StringUtils.contains(path, allowPath)) { @@ -82,9 +76,6 @@ public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { } //2.1 将解析到的jwt数据保存到线程中(转发过去的服务都能接收) try { - //本地文件解析 - //Claims claims = JwtUtilsKh.parserTokenGetBody(jwtToken, RsaUtils.getPublicKey(pubKeyPath)); - //System.out.println("解析出来的body"+claims); //调用feign服务进行解析 Object resResult = tokenFeign.parseToken(jwtToken); diff --git a/ty-gateway/ty-gateway-one/src/main/resources/application.yml b/ty-gateway/ty-gateway-one/src/main/resources/application.yml index 678e70c..e3f338e 100644 --- a/ty-gateway/ty-gateway-one/src/main/resources/application.yml +++ b/ty-gateway/ty-gateway-one/src/main/resources/application.yml @@ -4,79 +4,79 @@ server: spring: cloud: gateway: -# globalcors: -# corsConfigurations: -# '[/**]': -# # 允许携带认证信息 -# # 允许跨域的源(网站域名/ip),设置*为全部 -# # 允许跨域请求里的head字段,设置*为全部 -# # 允许跨域的method, 默认为GET和OPTIONS,设置*为全部 -# # 跨域允许的有效期 -# allow-credentials: true -# allowed-origins: "*" -# allowed-headers: "*" -# allowed-methods: -# - OPTIONS -# - GET -# - POST -# - PUT -# - DELETE -# #max-age: 3600 + globalcors: + corsConfigurations: + '[/**]': + # 允许携带认证信息 + # 允许跨域的源(网站域名/ip),设置*为全部 + # 允许跨域请求里的head字段,设置*为全部 + # 允许跨域的method, 默认为GET和OPTIONS,设置*为全部 + # 跨域允许的有效期 + allow-credentials: true + allowed-origins: "*" + allowed-headers: "*" + allowed-methods: + - OPTIONS + - GET + - POST + - PUT + - DELETE + #max-age: 3600 routes: - - id: ty-auth - uri: lb://ty-auth - predicates: - - Path=/api/ty-auth/** - filters: - - StripPrefix=2 + - id: ty-auth + uri: lb://ty-auth + predicates: + - Path=/api/ty-auth/** + filters: + - StripPrefix=2 - - id: ty-email - uri: lb://ty-email - predicates: - - Path=/api/ty-email/** - filters: - - StripPrefix=2 + - id: ty-email + uri: lb://ty-email + predicates: + - Path=/api/ty-email/** + filters: + - StripPrefix=2 - - id: ty-example - uri: lb://ty-example - predicates: - - Path=/api/ty-example/** - filters: - - StripPrefix=2 + - id: ty-example + uri: lb://ty-example + predicates: + - Path=/api/ty-example/** + filters: + - StripPrefix=2 - #请求数限流 名字不能随便写 ,使用默认的facatory - - name: RequestRateLimiter - args: - key-resolver: "#{@ipKeyResolver}" - redis-rate-limiter.replenishRate: 2 - redis-rate-limiter.burstCapacity: 2 + #请求数限流 名字不能随便写 ,使用默认的facatory + - name: RequestRateLimiter + args: + key-resolver: "#{@ipKeyResolver}" + redis-rate-limiter.replenishRate: 2 + redis-rate-limiter.burstCapacity: 2 - # hystrix 熔断配置 - - RemoveRequestHeader=Origin # 去除请求头的origin字段,此字段导致post请求 无法进入网关post熔断 - - name: SpecialHystrix #自定义熔断 - args: - id: SpecialHystrix - fallbackUri: forward:/fallback - timeout: - #指定接口超时处理 hystrixRibbon -> @RequestMapping("hystrixRibbon") - #timeoutTest-> @GetMapping("timeoutTest") , - > / - hystrixRibbon-timeoutTest: 11000 - upload-image: 2000 - upload-file: 30000 + # hystrix 熔断配置 + - RemoveRequestHeader=Origin # 去除请求头的origin字段,此字段导致post请求 无法进入网关post熔断 + - name: SpecialHystrix #自定义熔断 + args: + id: SpecialHystrix + fallbackUri: forward:/fallback + timeout: + #指定接口超时处理 hystrixRibbon -> @RequestMapping("hystrixRibbon") + #timeoutTest-> @GetMapping("timeoutTest") , - > / + hystrixRibbon-timeoutTest: 11000 + upload-image: 2000 + upload-file: 30000 - - id: integration-front - uri: lb://integration-front - predicates: - - Path=/api/integration-front/** - filters: - - StripPrefix=2 + - id: integration-front + uri: lb://integration-front + predicates: + - Path=/api/integration-front/** + filters: + - StripPrefix=2 - - id: ty-upload - uri: lb://ty-upload - predicates: - - Path=/api/ty-upload/** - filters: - - StripPrefix=2 + - id: ty-upload + uri: lb://ty-upload + predicates: + - Path=/api/ty-upload/** + filters: + - StripPrefix=2 management: endpoint: @@ -91,18 +91,16 @@ management: filter: #not filter , you can config it when dev #allowPaths: / - allowPaths: swagger,docs,userRegister,userLogin,sendEmailCode,registry,login,loginOut,insertUser,example - notValidExpList: export,excel - + allowPaths: swagger,docs,userRegister,userLogin,sendEmailCode,registry,login,loginOut,insertUser,export,excel,example +#默认3天时间告知前端刷新token token-properties: - renewTokenMinute: 1440 #默认1天时间告知前端刷新token + renewTokenMinute: 1440*3 #config the visit service of gateway swagger swagger-doc: serviceMap: { integration-front: "前端数据整合", - ty-upload: "文件上传", ty-example: "使用例子" } \ No newline at end of file From 44b128927c4067aa04d9ab8e989bb83a147fc04d Mon Sep 17 00:00:00 2001 From: jzfai <869653722@qq.com> Date: Fri, 14 Jan 2022 19:09:20 +0800 Subject: [PATCH 20/36] judge to doc --- .../controller/BrandController.java | 4 +- .../controller/ErrorCollectionController.java | 4 +- .../controller/UserController.java | 40 +- .../controller/VciController.java | 34 +- .../integrationfront/excel/cv/VciTimeCv.java | 2 +- .../integrationfront/service/UserService.java | 4 +- .../tyauth/config/Swagger2Config.java | 2 +- .../controller/TestGetTokenController.java | 46 + .../tyauth/controller/TokenController.java | 21 +- .../kuanghua/tyauth/utils/JwtUtilsSelf.java | 18 +- .../kuanghua/controller/HstrixController.java | 1 - .../feign/config/FeignConfiguration.java | 71 +- .../feign/tyauth/feign/TestGetTokenFeign.java | 14 + .../feign/tyauth/feign/TokenFeign.java | 90 +- .../config/MetaObjectHandlerConfig.java | 48 +- .../khcomomon/config/MybatisPlusConfig.java | 116 +- .../khcomomon/config/TokenParseInfo.java | 50 +- .../khcomomon/config/TyCommonConfig.java | 49 +- .../top/kuanghua/khcomomon/entity/BCrypt.java | 1584 ++++++++--------- .../kuanghua/khcomomon/entity/CacheKey.java | 48 +- .../khcomomon/entity/CommonParamsSelf.java | 40 +- .../kuanghua/khcomomon/entity/HttpClient.java | 338 ++-- .../kuanghua/khcomomon/entity/IdWorker.java | 342 ++-- .../khcomomon/entity/KHCommonPageParams.java | 72 +- .../khcomomon/entity/KHCommonParams.java | 40 +- .../kuanghua/khcomomon/entity/PageResult.java | 72 +- .../kuanghua/khcomomon/entity/ResResult.java | 130 +- .../top/kuanghua/khcomomon/entity/Result.java | 138 +- .../kuanghua/khcomomon/entity/StatusCode.java | 28 +- .../exception/BaseExceptionHandler.java | 56 +- .../khcomomon/utils/ChineseUtils.java | 130 +- .../khcomomon/utils/DateUtilSelf.java | 328 ++-- .../top/kuanghua/khcomomon/utils/JwtUtil.java | 208 +-- .../khcomomon/utils/RandomValueUtil.java | 252 +-- .../kuanghua/tyexample/config/BaseConfig.java | 2 +- .../tyexample/config/Swagger2Config.java | 5 +- .../controller/GetTokenFromOtherService.java | 35 + .../controller/RabbitDelayController.java | 1 - .../controller/SendEmailController.java | 12 +- .../tyexample/service/SendMsgService.java | 12 +- .../tyexample/service/UploadService.java | 4 +- ty-example/src/main/resources/application.yml | 7 + ty-excel/pom.xml | 51 - .../kuanghua/tyexcel/ExcelApplication.java | 13 - .../kuanghua/tyexcel/bo/ComplexHeadData.java | 16 - .../bo/CustomStringStringConverter.java | 15 - .../top/kuanghua/tyexcel/bo/DemoData.java | 24 - .../kuanghua/tyexcel/bo/DemoExtraData.java | 11 - .../top/kuanghua/tyexcel/bo/RuiDeKqBo.java | 28 - .../kuanghua/tyexcel/config/BaseConfig.java | 25 - .../tyexcel/config/Swagger2Config.java | 56 - .../tyexcel/controller/ExcelController.java | 81 - .../kuanghua/tyexcel/service/DaoService.java | 36 - .../tyexcel/service/ExcelService.java | 158 -- .../kuanghua/tyexcel/vo/ExcelCheckResult.java | 29 - ty-excel/src/main/resources/application.yml | 9 - ty-excel/src/main/resources/bootstrap.yml | 32 - .../gatewaytwo/config/SwaggerHandler.java | 2 +- .../config/SwaggerHeaderFilter.java | 2 +- .../gatewaytwo/config/SwaggerProvider.java | 11 +- .../filter/AuthorizeFilterAfter.java | 2 +- .../kuanghua/gatewaytwo/service/JwtTest.java | 14 - .../src/main/resources/application.yml | 111 +- 63 files changed, 2312 insertions(+), 2912 deletions(-) create mode 100644 ty-auth/src/main/java/top/kuanghua/tyauth/controller/TestGetTokenController.java create mode 100644 ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TestGetTokenFeign.java create mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/GetTokenFromOtherService.java delete mode 100644 ty-excel/pom.xml delete mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/ExcelApplication.java delete mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/bo/ComplexHeadData.java delete mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/bo/CustomStringStringConverter.java delete mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/bo/DemoData.java delete mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/bo/DemoExtraData.java delete mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/bo/RuiDeKqBo.java delete mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/config/BaseConfig.java delete mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/config/Swagger2Config.java delete mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/controller/ExcelController.java delete mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/service/DaoService.java delete mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/service/ExcelService.java delete mode 100644 ty-excel/src/main/java/top/kuanghua/tyexcel/vo/ExcelCheckResult.java delete mode 100644 ty-excel/src/main/resources/application.yml delete mode 100644 ty-excel/src/main/resources/bootstrap.yml delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/service/JwtTest.java diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/BrandController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/BrandController.java index 1a43e45..89d3974 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/BrandController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/BrandController.java @@ -8,10 +8,10 @@ import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; -import top.kuanghua.khcomomon.entity.KHCommonParams; -import top.kuanghua.khcomomon.entity.ResResult; import top.kuanghua.integrationfront.entity.Brand; import top.kuanghua.integrationfront.service.BrandService; +import top.kuanghua.khcomomon.entity.KHCommonParams; +import top.kuanghua.khcomomon.entity.ResResult; import javax.annotation.Resource; import java.util.List; diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/ErrorCollectionController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/ErrorCollectionController.java index e474129..47283aa 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/ErrorCollectionController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/ErrorCollectionController.java @@ -8,10 +8,10 @@ import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; -import top.kuanghua.khcomomon.entity.KHCommonParams; -import top.kuanghua.khcomomon.entity.ResResult; import top.kuanghua.integrationfront.entity.ErrorCollection; import top.kuanghua.integrationfront.service.ErrorCollectionService; +import top.kuanghua.khcomomon.entity.KHCommonParams; +import top.kuanghua.khcomomon.entity.ResResult; import javax.annotation.Resource; import java.util.List; diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java index a082535..888ea63 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java @@ -11,12 +11,12 @@ import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; import top.kuanghua.feign.tyauth.feign.TokenFeign; -import top.kuanghua.khcomomon.entity.KHCommonParams; -import top.kuanghua.khcomomon.entity.ResResult; import top.kuanghua.integrationfront.entity.User; import top.kuanghua.integrationfront.mapper.MultiPageMapper; import top.kuanghua.integrationfront.mapper.UserMapper; import top.kuanghua.integrationfront.service.UserService; +import top.kuanghua.khcomomon.entity.KHCommonParams; +import top.kuanghua.khcomomon.entity.ResResult; import javax.annotation.Resource; import javax.validation.Valid; @@ -42,25 +42,27 @@ public class UserController { @Resource private TokenFeign tokenFeign; + /** * 分页查询所有数据 - * @param user 查询实体 + * + * @param user 查询实体 * @return 所有数据 */ @GetMapping("selectPage") @ApiOperation(value = "分页查询数据") public ResResult selectPage(User user, KHCommonParams commonParams) { QueryWrapper queryWrapper = new QueryWrapper<>(); - if(StringUtils.isNotEmpty(user.getUsername())) { - queryWrapper.like("username",user.getUsername()); + if (StringUtils.isNotEmpty(user.getUsername())) { + queryWrapper.like("username", user.getUsername()); } - if(StringUtils.isNotEmpty(user.getPhone())) { - queryWrapper.like("phone",user.getPhone()); + if (StringUtils.isNotEmpty(user.getPhone())) { + queryWrapper.like("phone", user.getPhone()); } - if(StringUtils.isNotEmpty(commonParams.getStartTime())) { - queryWrapper.between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); + if (StringUtils.isNotEmpty(commonParams.getStartTime())) { + queryWrapper.between("create_time", commonParams.getStartTime(), commonParams.getEndTime()); } - queryWrapper.select("username","phone","create_time"); + queryWrapper.select("username", "phone", "create_time"); Page userPage = this.userMapper.selectPage(new Page<>(commonParams.getPageNum(), commonParams.getPageSize()), queryWrapper); return new ResResult().success(userPage); } @@ -102,6 +104,7 @@ public ResResult insert(@Valid @RequestBody User user) { // .like("lastname", name));52 return new ResResult().success(this.userService.insert(user)); } + /** * 修改数据 * @@ -124,6 +127,7 @@ public ResResult insert(@Valid @RequestBody User user) { public ResResult deleteBatchIds(@RequestBody List idList) { return new ResResult().success(this.userMapper.deleteBatchIds(idList)); } + @DeleteMapping("deleteById") @ApiOperation(value = "根据id删除数据") public ResResult deleteById(@RequestParam("id") Integer id) { @@ -132,8 +136,8 @@ public ResResult deleteById(@RequestParam("id") Integer id) { @PostMapping("registry") @ApiOperation(value = "用户注册") - public ResResult registry(User user,String code,String password) throws Exception { - this.userService.registry(user,code); + public ResResult registry(User user, String code, String password) throws Exception { + this.userService.registry(user, code); return new ResResult().success(); } @@ -141,7 +145,7 @@ public ResResult registry(User user,String code,String password) throws Exceptio @ApiOperation(value = "登录校验") public ResResult loginValid(User user) throws Exception { HashMap hm = this.userService.loginValid(user); - return new ResResult().success(hm); + return new ResResult().success(hm); } @PostMapping("loginOut") @@ -151,6 +155,7 @@ public ResResult loginOut() { this.userService.loginOut(); return new ResResult().success(); } + @PostMapping("multiPageTest") @ApiOperation(value = "多分页测试") public Page> multiPageTest() { @@ -169,11 +174,12 @@ public Page> multiPageTest() { @ApiOperation(value = "修改密码") public ResResult changePassword( @ApiIgnore @RequestHeader("TOKEN_INFO") String TOKEN_INFO, - String oldPassword,String newPassword) throws UnsupportedEncodingException { + String oldPassword, String newPassword) throws UnsupportedEncodingException { Map tokenInfo = JSON.parseObject(URLDecoder.decode(TOKEN_INFO, "utf-8")); - this.userService.changePassword(tokenInfo.get("username").toString(),oldPassword,newPassword); + this.userService.changePassword(tokenInfo.get("username").toString(), oldPassword, newPassword); return new ResResult().success(); } + @PostMapping("getUserInfo") @ApiOperation(value = "获取用户信息") public ResResult changePassword(@ApiIgnore @RequestHeader("TOKEN_INFO") String TOKEN_INFO) throws UnsupportedEncodingException { @@ -184,7 +190,7 @@ public ResResult changePassword(@ApiIgnore @RequestHeader("TOKEN_INFO") String T @PostMapping("insertUser") @ApiOperation(value = "插入用户") - public ResResult insertUser(String username){ + public ResResult insertUser(String username) { this.userService.insertUser(username); return new ResResult().success(); } @@ -197,6 +203,6 @@ public ResResult insertUser(String username){ @ApiOperation(value = "重置用户(有则删除在新增)") public ResResult resetUser(String username) { this.userService.resetUser(username); - return new ResResult().success(); + return new ResResult().success(); } } \ No newline at end of file diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/VciController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/VciController.java index 3b57601..8d93778 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/VciController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/VciController.java @@ -8,21 +8,21 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import top.kuanghua.khcomomon.entity.CommonParamsSelf; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; import top.kuanghua.integrationfront.entity.Vci; import top.kuanghua.integrationfront.excel.imp.VciExcelImp; import top.kuanghua.integrationfront.service.VciService; -import org.springframework.web.bind.annotation.*; import top.kuanghua.integrationfront.vo.ExcelCheckResult; +import top.kuanghua.khcomomon.entity.CommonParamsSelf; +import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.net.URLEncoder; -import java.util.*; +import java.util.List; @Api(tags = "VCI设备表(Vci)") @@ -35,7 +35,8 @@ public class VciController { /** * 分页查询所有数据 - * @param vci 查询实体 + * + * @param vci 查询实体 * @return 所有数据 */ @GetMapping("selectPage") @@ -53,8 +54,8 @@ public ResResult selectPage(Vci vci, CommonParamsSelf commonParams) { } //根据创建时间查询 queryWrapper.orderByDesc("create_time"); - if(StringUtils.isNotEmpty(commonParams.getStartTime())) { - queryWrapper.between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); + if (StringUtils.isNotEmpty(commonParams.getStartTime())) { + queryWrapper.between("create_time", commonParams.getStartTime(), commonParams.getEndTime()); } queryWrapper.select("id,sn,hard_version,create_time,status,supplier,receipt_no,product_spec"); @@ -73,6 +74,7 @@ public ResResult selectPage(Vci vci, CommonParamsSelf commonParams) { public ResResult selectById(@RequestParam("id") Integer id) { return new ResResult().success(this.vciService.selectById(id)); } + /** * @Description: 根据id数组查询品牌列表 * @Param: idList id数组 @@ -83,8 +85,10 @@ public ResResult selectById(@RequestParam("id") Integer id) { public ResResult selectBatchIds(@RequestParam("idList") List idList) { return new ResResult().success(this.vciService.selectBatchIds(idList)); } + /** * 新增数据 + * * @param vci 实体对象 * @return 新增结果 */ @@ -96,6 +100,7 @@ public ResResult insert(@RequestBody Vci vci) { /** * 修改数据 + * * @param vci 实体对象 * @return 修改结果 */ @@ -107,6 +112,7 @@ public ResResult updateById(@RequestBody Vci vci) { /** * 删除数据 + * * @param idList 主键结合 * @return 删除结果 */ @@ -131,14 +137,14 @@ public ResResult validExcel(@RequestParam("file") MultipartFile file) throws IOE @ApiOperation("导入excel") @PostMapping("importExcel") - public ResResult importExcel(@RequestBody List vciExcelBo) { + public ResResult importExcel(@RequestBody List vciExcelBo) { vciService.importExcel(vciExcelBo); return new ResResult().success(); } @ApiOperation("导出excel") @GetMapping("exportExcel") - public void exportExcel(HttpServletResponse response,Vci vci, CommonParamsSelf commonParams) throws IOException { + public void exportExcel(HttpServletResponse response, Vci vci, CommonParamsSelf commonParams) throws IOException { QueryWrapper queryWrapper = new QueryWrapper<>(); if (ObjectUtils.isNotEmpty(vci.getSn())) { queryWrapper.like("sn", vci.getSn()); @@ -151,8 +157,8 @@ public void exportExcel(HttpServletResponse response,Vci vci, CommonParamsSelf c } //根据创建时间查询 queryWrapper.orderByDesc("create_time"); - if(StringUtils.isNotEmpty(commonParams.getStartTime())) { - queryWrapper.between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); + if (StringUtils.isNotEmpty(commonParams.getStartTime())) { + queryWrapper.between("create_time", commonParams.getStartTime(), commonParams.getEndTime()); } queryWrapper.select("sn,hard_version,create_time,status,supplier,receipt_no,product_spec"); @@ -161,9 +167,9 @@ public void exportExcel(HttpServletResponse response,Vci vci, CommonParamsSelf c response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); - String fileName = URLEncoder.encode("Vci导出数据", "UTF-8")+"-"+ ObjectUtilsSelf.getCurrentDateTime(); + String fileName = URLEncoder.encode("Vci导出数据", "UTF-8") + "-" + ObjectUtilsSelf.getCurrentDateTime(); response.setHeader("Access-Control-Expose-Headers", "exportFileName"); - response.setHeader("exportFileName", fileName + ".xlsx" ); + response.setHeader("exportFileName", fileName + ".xlsx"); EasyExcel.write(response.getOutputStream(), VciExcelImp.class).sheet("模板").doWrite(vciPage.getRecords()); } diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/excel/cv/VciTimeCv.java b/integration-front/src/main/java/top/kuanghua/integrationfront/excel/cv/VciTimeCv.java index c8d5e54..35b0ebf 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/excel/cv/VciTimeCv.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/excel/cv/VciTimeCv.java @@ -13,7 +13,7 @@ public class VciTimeCv implements Converter { @Override public Date convertToJavaData(ReadCellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { - String stringValue = cellData.getNumberValue().toString() ; + String stringValue = cellData.getNumberValue().toString(); String DATE_FORMAT = "yyyyMMdd"; SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMAT); Date parse = simpleDateFormat.parse(stringValue); diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/service/UserService.java b/integration-front/src/main/java/top/kuanghua/integrationfront/service/UserService.java index 96abf0d..2e9ff69 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/service/UserService.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/service/UserService.java @@ -9,11 +9,11 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; import top.kuanghua.feign.tyauth.feign.TokenFeign; +import top.kuanghua.integrationfront.entity.User; +import top.kuanghua.integrationfront.mapper.UserMapper; import top.kuanghua.khcomomon.entity.ResResult; import top.kuanghua.khcomomon.utils.CodecUtils; import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; -import top.kuanghua.integrationfront.entity.User; -import top.kuanghua.integrationfront.mapper.UserMapper; import javax.annotation.Resource; import java.util.HashMap; diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java b/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java index 78010c8..779709f 100644 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java +++ b/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java @@ -42,7 +42,7 @@ public Docket api() { */ private ApiInfo apiInfo() { return new ApiInfoBuilder() - .title("title:micro-service-plus") + .title("micro-service-pluss") .description("描述:新一代的微服务架构") .contact(new Contact("jzfai", null, "869653722@qq.com")) .version("版本号:2.9") diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TestGetTokenController.java b/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TestGetTokenController.java new file mode 100644 index 0000000..f305678 --- /dev/null +++ b/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TestGetTokenController.java @@ -0,0 +1,46 @@ +package top.kuanghua.tyauth.controller; + +import com.alibaba.fastjson.JSON; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import springfox.documentation.annotations.ApiIgnore; +import top.kuanghua.khcomomon.entity.ResResult; + +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.util.Map; + +/** + * @Title: TokenController + * @Description: + * @Auther: kuanghua + * @create 2021/1/31 16:31 + */ + +@RestController +@RequestMapping("feignTest") +@Slf4j +public class TestGetTokenController { + /* + * 解析token + * */ + @PostMapping("getTokenInfo") + public ResResult getTokenInfo( + @ApiIgnore @RequestHeader("TOKEN_INFO") String TOKEN_INFO, + @ApiIgnore @RequestHeader("AUTHORIZE_TOKEN") String AUTHORIZE_TOKEN + ) { + try { + Map tokenInfo = JSON.parseObject(URLDecoder.decode(TOKEN_INFO, "utf-8")); + log.info(tokenInfo.toString()); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + log.info(AUTHORIZE_TOKEN); + return new ResResult().success(TOKEN_INFO); + } +} + + diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TokenController.java b/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TokenController.java index 19130a1..12e59ca 100644 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TokenController.java +++ b/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TokenController.java @@ -26,14 +26,15 @@ public class TokenController { @Autowired private TokenService tokenService; + /* * 解析token * */ @ApiOperation("获取token信息") @PostMapping("parseToken") - public ResResult parseToken(@RequestParam("jwtToken") String jwtToken){ + public ResResult parseToken(@RequestParam("jwtToken") String jwtToken) { Claims claims = this.tokenService.parseToken(jwtToken); - return new ResResult().success(claims); + return new ResResult().success(claims); } /* @@ -42,17 +43,9 @@ public ResResult parseToken(@RequestParam("jwtToken") String jwtToken){ @ApiOperation("生成token") @PostMapping("generateToken") //@RequestHeader("authorize_token") String authorize_token - public ResResult generateToken(@RequestBody Map tokenMap){ -// System.out.println("生成的代码信息"); -// System.out.println(tokenMap); - - - // System.out.println("generateToken获得请求头的信息"); - // 获取一个参数 - // System.out.println(authorize_token); - + public ResResult generateToken(@RequestBody Map tokenMap) { String generateToken = this.tokenService.generateToken(tokenMap); - return new ResResult().success(generateToken); + return new ResResult().success(generateToken); } /* @@ -60,11 +53,11 @@ public ResResult generateToken(@RequestBody Map tokenMap){ * */ @ApiOperation("更新token") @PostMapping("updateToken") - public ResResult updateToken(@RequestBody Map map){ + public ResResult updateToken(@RequestBody Map map) { String updateToken = this.tokenService.updateToken(map); // System.out.println("生成信息的token"+updateToken); // System.out.println("生成信息的token"+map.toString()); - return new ResResult().success(updateToken); + return new ResResult().success(updateToken); } } diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/utils/JwtUtilsSelf.java b/ty-auth/src/main/java/top/kuanghua/tyauth/utils/JwtUtilsSelf.java index bd38ef3..7c482af 100644 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/utils/JwtUtilsSelf.java +++ b/ty-auth/src/main/java/top/kuanghua/tyauth/utils/JwtUtilsSelf.java @@ -26,10 +26,12 @@ public class JwtUtilsSelf { public static final Long JWT_TTL = 259200000L;//60 * 60 * 1000 * 24 * 3 三天 //Jwt令牌信息 public static final String JWT_KEY = "kh@Login(Auth}*^31)&kuanghua%"; + /** * 生成令牌 - //* @param id - //* @param subject + * //* @param id + * //* @param subject + * * @param ttlMillis * @return */ @@ -89,16 +91,4 @@ public static Claims parseJWT(String jwt) throws Exception { .parseClaimsJws(jwt) .getBody(); } -// public static void main(String[] args) { -// String jwt = JwtUtil.createJWT("weiyibiaoshi", ) -// System.out.println(jwt); -// try { -// Claims claims = JwtUtil.parseJWT(jwt); -// System.out.println(claims); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// -// -// } } diff --git a/ty-common/src/main/java/top/kuanghua/controller/HstrixController.java b/ty-common/src/main/java/top/kuanghua/controller/HstrixController.java index 8762eaf..fddc203 100644 --- a/ty-common/src/main/java/top/kuanghua/controller/HstrixController.java +++ b/ty-common/src/main/java/top/kuanghua/controller/HstrixController.java @@ -1,7 +1,6 @@ package top.kuanghua.controller; import io.swagger.annotations.ApiOperation; -import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import top.kuanghua.khcomomon.entity.ResResult; diff --git a/ty-common/src/main/java/top/kuanghua/feign/config/FeignConfiguration.java b/ty-common/src/main/java/top/kuanghua/feign/config/FeignConfiguration.java index ba14433..80eac4d 100644 --- a/ty-common/src/main/java/top/kuanghua/feign/config/FeignConfiguration.java +++ b/ty-common/src/main/java/top/kuanghua/feign/config/FeignConfiguration.java @@ -1,37 +1,36 @@ -package top.kuanghua.feign.config; - -import feign.RequestInterceptor; -import feign.RequestTemplate; -import lombok.Data; -import lombok.extern.log4j.Log4j2; -import org.springframework.context.annotation.Configuration; -import org.springframework.util.ObjectUtils; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; - -import javax.servlet.http.HttpServletRequest; -import java.util.Enumeration; - - -/*feign转发时将请求的参数设转发到请求头上*/ -@Configuration -@Log4j2 -public class FeignConfiguration implements RequestInterceptor { - @Override - public void apply(RequestTemplate template) { - ServletRequestAttributes attributes = (ServletRequestAttributes) - RequestContextHolder.getRequestAttributes(); - if(!ObjectUtils.isEmpty(attributes)){ - HttpServletRequest request = attributes.getRequest(); - Enumeration headerNames = request.getHeaderNames(); - if (headerNames != null) { - while (headerNames.hasMoreElements()) { - String name = headerNames.nextElement(); - String values = request.getHeader(name); - - template.header(name, values); - } - } - } - } +package top.kuanghua.feign.config; + +import feign.RequestInterceptor; +import feign.RequestTemplate; +import lombok.extern.log4j.Log4j2; +import org.springframework.context.annotation.Configuration; +import org.springframework.util.ObjectUtils; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import java.util.Enumeration; + + +/*feign转发时将请求的参数设转发到请求头上*/ +@Configuration +@Log4j2 +public class FeignConfiguration implements RequestInterceptor { + @Override + public void apply(RequestTemplate template) { + ServletRequestAttributes attributes = (ServletRequestAttributes) + RequestContextHolder.getRequestAttributes(); + if (!ObjectUtils.isEmpty(attributes)) { + HttpServletRequest request = attributes.getRequest(); + Enumeration headerNames = request.getHeaderNames(); + if (headerNames != null) { + while (headerNames.hasMoreElements()) { + String name = headerNames.nextElement(); + String values = request.getHeader(name); + + template.header(name, values); + } + } + } + } } \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TestGetTokenFeign.java b/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TestGetTokenFeign.java new file mode 100644 index 0000000..17e523a --- /dev/null +++ b/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TestGetTokenFeign.java @@ -0,0 +1,14 @@ +package top.kuanghua.feign.tyauth.feign; + +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import top.kuanghua.feign.config.FeignConfiguration; +import top.kuanghua.khcomomon.entity.ResResult; + +@FeignClient(name = "ty-auth", configuration = FeignConfiguration.class) +@RequestMapping("feignTest") +public interface TestGetTokenFeign { + @PostMapping("getTokenInfo") + public ResResult getTokenInfo(); +} \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TokenFeign.java b/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TokenFeign.java index e58032b..4c2b8d2 100644 --- a/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TokenFeign.java +++ b/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TokenFeign.java @@ -1,45 +1,45 @@ -package top.kuanghua.feign.tyauth.feign; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import top.kuanghua.feign.config.FeignConfiguration; -import top.kuanghua.khcomomon.entity.ResResult; - -import java.util.Map; - -/** - * @Title: TokenController - * @Description: - * @Auther: kuanghua - * @create 2021/1/31 16:31 - */ - - -//FeignConfiguration.class -> forward req params of include the token -@FeignClient(name="ty-auth",configuration = FeignConfiguration.class) -@RequestMapping("token") -public interface TokenFeign { - - /* - * parse token - * */ - @PostMapping("parseToken") - ResResult parseToken(@RequestParam("jwtToken") String jwtToken); - - /* - * create token - * */ - @PostMapping("generateToken") - ResResult generateToken(@RequestBody Map map); - - /* - * update token - * */ - @PostMapping("updateToken") - ResResult updateToken(@RequestBody Map map); -} - - +package top.kuanghua.feign.tyauth.feign; + +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import top.kuanghua.feign.config.FeignConfiguration; +import top.kuanghua.khcomomon.entity.ResResult; + +import java.util.Map; + +/** + * @Title: TokenController + * @Description: + * @Auther: kuanghua + * @create 2021/1/31 16:31 + */ + + +//FeignConfiguration.class -> forward req params of include the token +@FeignClient(name="ty-auth",configuration = FeignConfiguration.class) +@RequestMapping("token") +public interface TokenFeign { + + /* + * parse token + * */ + @PostMapping("parseToken") + ResResult parseToken(@RequestParam("jwtToken") String jwtToken); + + /* + * create token + * */ + @PostMapping("generateToken") + ResResult generateToken(@RequestBody Map map); + + /* + * update token + * */ + @PostMapping("updateToken") + ResResult updateToken(@RequestBody Map map); +} + + diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/config/MetaObjectHandlerConfig.java b/ty-common/src/main/java/top/kuanghua/khcomomon/config/MetaObjectHandlerConfig.java index 407c23e..6c6dce1 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/config/MetaObjectHandlerConfig.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/config/MetaObjectHandlerConfig.java @@ -1,25 +1,25 @@ -package top.kuanghua.khcomomon.config; - -import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; -import lombok.extern.slf4j.Slf4j; -import org.apache.ibatis.reflection.MetaObject; -import org.springframework.stereotype.Component; - -import java.time.LocalDateTime; -import java.util.Date; - -@Component -@Slf4j -public class MetaObjectHandlerConfig implements MetaObjectHandler { - @Override - public void insertFill(MetaObject metaObject) { - log.info("start insert fill ...."); - //有值不进行填充fillStrategy - this.strictInsertFill(metaObject, "createTime", Date.class, new Date()); - } - @Override - public void updateFill(MetaObject metaObject) { - log.info("start update fill ...."); - this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date()); - } +package top.kuanghua.khcomomon.config; + +import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; +import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.reflection.MetaObject; +import org.springframework.stereotype.Component; + +import java.util.Date; + +@Component +@Slf4j +public class MetaObjectHandlerConfig implements MetaObjectHandler { + @Override + public void insertFill(MetaObject metaObject) { + log.info("start insert fill ...."); + //有值不进行填充fillStrategy + this.strictInsertFill(metaObject, "createTime", Date.class, new Date()); + } + + @Override + public void updateFill(MetaObject metaObject) { + log.info("start update fill ...."); + this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date()); + } } \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/config/MybatisPlusConfig.java b/ty-common/src/main/java/top/kuanghua/khcomomon/config/MybatisPlusConfig.java index 9fccd77..5378349 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/config/MybatisPlusConfig.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/config/MybatisPlusConfig.java @@ -1,58 +1,58 @@ -package top.kuanghua.khcomomon.config; - - -import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer; -import com.baomidou.mybatisplus.extension.MybatisMapWrapperFactory; -import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor; -import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; -import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; - -/** - * @Title: MybatisPlusConfig - * @Description: - * @Auther: - * @create 2020/8/13 22:55 - */ -@Component -public class MybatisPlusConfig { - /** - * 分页插件 - */ - @Bean - public PaginationInterceptor paginationInterceptor() { - PaginationInterceptor paginationInterceptor = new PaginationInterceptor(); - // 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false - // paginationInterceptor.setOverflow(false); - // 设置最大单页限制数量,默认 500 条,-1 不受限制 - // paginationInterceptor.setLimit(100); - // 开启 count 的 join 优化,只针对部分 left join - paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true)); - return paginationInterceptor; - } - - /** - * 乐观锁插件 - * - * @return - */ - @Bean - public OptimisticLockerInterceptor optimisticLockerInterceptor() { - return new OptimisticLockerInterceptor(); - } - - /*map转驼峰*/ - @Bean - public ConfigurationCustomizer mybatisConfigurationCustomizer(){ - return new ConfigurationCustomizer() { - @Override - public void customize(org.apache.ibatis.session.Configuration configuration) { - configuration.setObjectWrapperFactory(new MybatisMapWrapperFactory()); - } - }; - } - - - -} +package top.kuanghua.khcomomon.config; + + +import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer; +import com.baomidou.mybatisplus.extension.MybatisMapWrapperFactory; +import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor; +import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; +import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +/** + * @Title: MybatisPlusConfig + * @Description: + * @Auther: + * @create 2020/8/13 22:55 + */ +@Component +public class MybatisPlusConfig { + /** + * 分页插件 + */ + @Bean + public PaginationInterceptor paginationInterceptor() { + PaginationInterceptor paginationInterceptor = new PaginationInterceptor(); + // 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false + // paginationInterceptor.setOverflow(false); + // 设置最大单页限制数量,默认 500 条,-1 不受限制 + // paginationInterceptor.setLimit(100); + // 开启 count 的 join 优化,只针对部分 left join + paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true)); + return paginationInterceptor; + } + + /** + * 乐观锁插件 + * + * @return + */ + @Bean + public OptimisticLockerInterceptor optimisticLockerInterceptor() { + return new OptimisticLockerInterceptor(); + } + + /*map转驼峰*/ + @Bean + public ConfigurationCustomizer mybatisConfigurationCustomizer(){ + return new ConfigurationCustomizer() { + @Override + public void customize(org.apache.ibatis.session.Configuration configuration) { + configuration.setObjectWrapperFactory(new MybatisMapWrapperFactory()); + } + }; + } + + + +} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/config/TokenParseInfo.java b/ty-common/src/main/java/top/kuanghua/khcomomon/config/TokenParseInfo.java index 74bb142..704d981 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/config/TokenParseInfo.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/config/TokenParseInfo.java @@ -1,24 +1,26 @@ -package top.kuanghua.khcomomon.config; -import java.util.*; -/** - * @Title: TokenParseInfo - * @Description: - * @Auther: kuanghua - * @create 2021/3/15 14:37 - */ -public class TokenParseInfo { - // 定义一个线程域,存放登录用户 - private static final ThreadLocal t1 = new ThreadLocal<>(); - - public TokenParseInfo(Map map) { - t1.set(map); - } - - public static Map getT1() { - return t1.get(); - } - - public static void removeT1() { - t1.remove(); - } -} +package top.kuanghua.khcomomon.config; + +import java.util.Map; + +/** + * @Title: TokenParseInfo + * @Description: + * @Auther: kuanghua + * @create 2021/3/15 14:37 + */ +public class TokenParseInfo { + // 定义一个线程域,存放登录用户 + private static final ThreadLocal t1 = new ThreadLocal<>(); + + public TokenParseInfo(Map map) { + t1.set(map); + } + + public static Map getT1() { + return t1.get(); + } + + public static void removeT1() { + t1.remove(); + } +} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/config/TyCommonConfig.java b/ty-common/src/main/java/top/kuanghua/khcomomon/config/TyCommonConfig.java index b812f84..e770241 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/config/TyCommonConfig.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/config/TyCommonConfig.java @@ -1,24 +1,25 @@ -package top.kuanghua.khcomomon.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.stereotype.Component; -import top.kuanghua.khcomomon.utils.IdWorker;; - -/** - * @Title: TyCommonConfig - * @Description: - * @Auther: kuanghua - * @create 2020/12/22 15:49 - */ -@Configuration -public class TyCommonConfig { - /*** - * IdWorker - * @return - */ - @Bean - public IdWorker idWorker(){ - return new IdWorker(0,0); - } -} +package top.kuanghua.khcomomon.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import top.kuanghua.khcomomon.utils.IdWorker; + +; + +/** + * @Title: TyCommonConfig + * @Description: + * @Auther: kuanghua + * @create 2020/12/22 15:49 + */ +@Configuration +public class TyCommonConfig { + /*** + * IdWorker + * @return + */ + @Bean + public IdWorker idWorker() { + return new IdWorker(0, 0); + } +} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/BCrypt.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/BCrypt.java index d1670a0..7a234e8 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/BCrypt.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/BCrypt.java @@ -1,792 +1,792 @@ -// Copyright (c) 2006 Damien Miller -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -package top.kuanghua.khcomomon.entity; - -import java.io.UnsupportedEncodingException; -import java.security.SecureRandom; - -/** - * BCrypt implements OpenBSD-style Blowfish password hashing using - * the scheme described in "A Future-Adaptable Password Scheme" by - * Niels Provos and David Mazieres. - *

- * This password hashing system tries to thwart off-line password - * cracking using a computationally-intensive hashing algorithm, - * based on Bruce Schneier's Blowfish cipher. The work factor of - * the algorithm is parameterised, so it can be increased as - * computers get faster. - *

- * Usage is really simple. To hash a password for the first time, - * call the hashpw method with a random salt, like this: - *

- * - * String pw_hash = BCrypt.hashpw(plain_password, BCrypt.gensalt());
- *
- *

- * To check whether a plaintext password matches one that has been - * hashed previously, use the checkpw method: - *

- * - * if (BCrypt.checkpw(candidate_password, stored_hash))
- *     System.out.println("It matches");
- * else
- *     System.out.println("It does not match");
- *
- *

- * The gensalt() method takes an optional parameter (log_rounds) - * that determines the computational complexity of the hashing: - *

- * - * String strong_salt = BCrypt.gensalt(10)
- * String stronger_salt = BCrypt.gensalt(12)
- *
- *

- * The amount of work increases exponentially (2**log_rounds), so - * each increment is twice as much work. The default log_rounds is - * 10, and the valid range is 4 to 30. - * - * @version 0.2 - */ -public class BCrypt { - // BCrypt parameters - private static final int GENSALT_DEFAULT_LOG2_ROUNDS = 10; - private static final int BCRYPT_SALT_LEN = 16; - - // Blowfish parameters - private static final int BLOWFISH_NUM_ROUNDS = 16; - - // Initial contents of key schedule - private static final int P_orig[] = { - 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, - 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, - 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, - 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, - 0x9216d5d9, 0x8979fb1b - }; - private static final int S_orig[] = { - 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, - 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99, - 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, - 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, - 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, - 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013, - 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, - 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e, - 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60, - 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, - 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce, - 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a, - 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, - 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677, - 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193, - 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, - 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88, - 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239, - 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, - 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0, - 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3, - 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, - 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88, - 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe, - 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, - 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d, - 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b, - 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, - 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba, - 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463, - 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, - 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09, - 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, - 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, - 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279, - 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8, - 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, - 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82, - 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db, - 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, - 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0, - 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b, - 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, - 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8, - 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4, - 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, - 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7, - 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c, - 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, - 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1, - 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299, - 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, - 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, - 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf, - 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, - 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af, - 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa, - 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, - 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41, - 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915, - 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, - 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915, - 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, - 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a, - 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, - 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266, - 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, - 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, - 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, - 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1, - 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, - 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1, - 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, - 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, - 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff, - 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd, - 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, - 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7, - 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41, - 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, - 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf, - 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af, - 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, - 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87, - 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, - 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, - 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16, - 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd, - 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, - 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509, - 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, - 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, - 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f, - 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a, - 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, - 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960, - 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66, - 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, - 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802, - 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84, - 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, - 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf, - 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, - 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, - 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50, - 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7, - 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, - 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281, - 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, - 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, - 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128, - 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73, - 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, - 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0, - 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105, - 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, - 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3, - 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285, - 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, - 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061, - 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, - 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, - 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, - 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc, - 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, - 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340, - 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, - 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7, - 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, - 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068, - 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, - 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, - 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45, - 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504, - 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, - 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb, - 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, - 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, - 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42, - 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b, - 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, - 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb, - 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, - 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, - 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33, - 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c, - 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, - 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc, - 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17, - 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, - 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b, - 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115, - 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, - 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728, - 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, - 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, - 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37, - 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d, - 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, - 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b, - 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, - 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, - 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d, - 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c, - 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, - 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9, - 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a, - 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, - 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d, - 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc, - 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, - 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61, - 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, - 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, - 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2, - 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c, - 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, - 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633, - 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, - 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, - 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52, - 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027, - 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, - 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62, - 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634, - 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, - 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, - 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc, - 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, - 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c, - 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, - 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0, - 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, - 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe, - 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, - 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, - 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, - 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6, - 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, - 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22, - 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4, - 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, - 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9, - 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59, - 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, - 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51, - 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28, - 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, - 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, - 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28, - 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, - 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd, - 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, - 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, - 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb, - 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f, - 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, - 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32, - 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680, - 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, - 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae, - 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb, - 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, - 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47, - 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370, - 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, - 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84, - 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048, - 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, - 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd, - 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9, - 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, - 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, - 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f, - 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, - 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525, - 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1, - 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, - 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964, - 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e, - 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, - 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d, - 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f, - 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, - 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02, - 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc, - 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, - 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a, - 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, - 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, - 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, - 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060, - 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, - 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9, - 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, - 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6 - }; - - // bcrypt IV: "OrpheanBeholderScryDoubt". The C implementation calls - // this "ciphertext", but it is really plaintext or an IV. We keep - // the name to make code comparison easier. - static private final int bf_crypt_ciphertext[] = { - 0x4f727068, 0x65616e42, 0x65686f6c, - 0x64657253, 0x63727944, 0x6f756274 - }; - - // Table for Base64 encoding - static private final char base64_code[] = { - '.', '/', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', - 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', - 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', - 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', - 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', - '6', '7', '8', '9' - }; - - // Table for Base64 decoding - static private final byte index_64[] = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 0, 1, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, -1, -1, - -1, -1, -1, -1, -1, 2, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - -1, -1, -1, -1, -1, -1, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, -1, -1, -1, -1, -1 - }; - - // Expanded Blowfish key - private int P[]; - private int S[]; - - /** - * Encode a byte array using bcrypt's slightly-modified base64 - * encoding scheme. Note that this is *not* compatible with - * the standard MIME-base64 encoding. - * - * @param d the byte array to encode - * @param len the number of bytes to encode - * @return base64-encoded string - * @exception IllegalArgumentException if the length is invalid - */ - private static String encode_base64(byte d[], int len) - throws IllegalArgumentException { - int off = 0; - StringBuffer rs = new StringBuffer(); - int c1, c2; - - if (len <= 0 || len > d.length) { - throw new IllegalArgumentException("Invalid len"); - } - while (off < len) { - c1 = d[off++] & 0xff; - rs.append(base64_code[(c1 >> 2) & 0x3f]); - c1 = (c1 & 0x03) << 4; - if (off >= len) { - rs.append(base64_code[c1 & 0x3f]); - break; - } - c2 = d[off++] & 0xff; - c1 |= (c2 >> 4) & 0x0f; - rs.append(base64_code[c1 & 0x3f]); - c1 = (c2 & 0x0f) << 2; - if (off >= len) { - rs.append(base64_code[c1 & 0x3f]); - break; - } - c2 = d[off++] & 0xff; - c1 |= (c2 >> 6) & 0x03; - rs.append(base64_code[c1 & 0x3f]); - rs.append(base64_code[c2 & 0x3f]); - } - return rs.toString(); - } - - /** - * Look up the 3 bits base64-encoded by the specified character, - * range-checking againt conversion table - * @param x the base64-encoded value - * @return the decoded value of x - */ - private static byte char64(char x) { - if ((int)x < 0 || (int)x > index_64.length) { - return -1; - } - return index_64[(int)x]; - } - - /** - * Decode a string encoded using bcrypt's base64 scheme to a - * byte array. Note that this is *not* compatible with - * the standard MIME-base64 encoding. - * @param s the string to decode - * @param maxolen the maximum number of bytes to decode - * @return an array containing the decoded bytes - * @throws IllegalArgumentException if maxolen is invalid - */ - private static byte[] decode_base64(String s, int maxolen) - throws IllegalArgumentException { - StringBuffer rs = new StringBuffer(); - int off = 0, slen = s.length(), olen = 0; - byte ret[]; - byte c1, c2, c3, c4, o; - - if (maxolen <= 0) { - throw new IllegalArgumentException("Invalid maxolen"); - } - while (off < slen - 1 && olen < maxolen) { - c1 = char64(s.charAt(off++)); - c2 = char64(s.charAt(off++)); - if (c1 == -1 || c2 == -1) { - break; - } - o = (byte)(c1 << 2); - o |= (c2 & 0x30) >> 4; - rs.append((char)o); - if (++olen >= maxolen || off >= slen) { - break; - } - c3 = char64(s.charAt(off++)); - if (c3 == -1) { - break; - } - o = (byte)((c2 & 0x0f) << 4); - o |= (c3 & 0x3c) >> 2; - rs.append((char)o); - if (++olen >= maxolen || off >= slen) { - break; - } - c4 = char64(s.charAt(off++)); - o = (byte)((c3 & 0x03) << 6); - o |= c4; - rs.append((char)o); - ++olen; - } - - ret = new byte[olen]; - for (off = 0; off < olen; off++) { - ret[off] = (byte) rs.charAt(off); - } - return ret; - } - - /** - * Blowfish encipher a single 64-bit block encoded as - * two 32-bit halves - * @param lr an array containing the two 32-bit half blocks - * @param off the position in the array of the blocks - */ - private final void encipher(int lr[], int off) { - int i, n, l = lr[off], r = lr[off + 1]; - - l ^= P[0]; - for (i = 0; i <= BLOWFISH_NUM_ROUNDS - 2;) { - // Feistel substitution on left word - n = S[(l >> 24) & 0xff]; - n += S[0x100 | ((l >> 16) & 0xff)]; - n ^= S[0x200 | ((l >> 8) & 0xff)]; - n += S[0x300 | (l & 0xff)]; - r ^= n ^ P[++i]; - - // Feistel substitution on right word - n = S[(r >> 24) & 0xff]; - n += S[0x100 | ((r >> 16) & 0xff)]; - n ^= S[0x200 | ((r >> 8) & 0xff)]; - n += S[0x300 | (r & 0xff)]; - l ^= n ^ P[++i]; - } - lr[off] = r ^ P[BLOWFISH_NUM_ROUNDS + 1]; - lr[off + 1] = l; - } - - /** - * Cycically extract a word of key material - * @param data the string to extract the data from - * @param offp a "pointer" (as a one-entry array) to the - * current offset into data - * @return the next word of material from data - */ - private static int streamtoword(byte data[], int offp[]) { - int i; - int word = 0; - int off = offp[0]; - - for (i = 0; i < 4; i++) { - word = (word << 8) | (data[off] & 0xff); - off = (off + 1) % data.length; - } - - offp[0] = off; - return word; - } - - /** - * Initialise the Blowfish key schedule - */ - private void init_key() { - P = (int[])P_orig.clone(); - S = (int[])S_orig.clone(); - } - - /** - * Key the Blowfish cipher - * @param key an array containing the key - */ - private void key(byte key[]) { - int i; - int koffp[] = { 0 }; - int lr[] = { 0, 0 }; - int plen = P.length, slen = S.length; - - for (i = 0; i < plen; i++) { - P[i] = P[i] ^ streamtoword(key, koffp); - } - for (i = 0; i < plen; i += 2) { - encipher(lr, 0); - P[i] = lr[0]; - P[i + 1] = lr[1]; - } - - for (i = 0; i < slen; i += 2) { - encipher(lr, 0); - S[i] = lr[0]; - S[i + 1] = lr[1]; - } - } - - /** - * Perform the "enhanced key schedule" step described by - * Provos and Mazieres in "A Future-Adaptable Password Scheme" - * http://www.openbsd.org/papers/bcrypt-paper.ps - * @param data salt information - * @param key password information - */ - private void ekskey(byte data[], byte key[]) { - int i; - int koffp[] = { 0 }, doffp[] = { 0 }; - int lr[] = { 0, 0 }; - int plen = P.length, slen = S.length; - - for (i = 0; i < plen; i++) { - P[i] = P[i] ^ streamtoword(key, koffp); - } - for (i = 0; i < plen; i += 2) { - lr[0] ^= streamtoword(data, doffp); - lr[1] ^= streamtoword(data, doffp); - encipher(lr, 0); - P[i] = lr[0]; - P[i + 1] = lr[1]; - } - - for (i = 0; i < slen; i += 2) { - lr[0] ^= streamtoword(data, doffp); - lr[1] ^= streamtoword(data, doffp); - encipher(lr, 0); - S[i] = lr[0]; - S[i + 1] = lr[1]; - } - } - - /** - * Perform the central password hashing step in the - * bcrypt scheme - * @param password the password to hash - * @param salt the binary salt to hash with the password - * @param log_rounds the binary logarithm of the number - * of rounds of hashing to apply - * @param cdata the plaintext to encrypt - * @return an array containing the binary hashed password - */ - public byte[] crypt_raw(byte password[], byte salt[], int log_rounds, - int cdata[]) { - int rounds, i, j; - int clen = cdata.length; - byte ret[]; - - if (log_rounds < 4 || log_rounds > 30) { - throw new IllegalArgumentException("Bad number of rounds"); - } - rounds = 1 << log_rounds; - if (salt.length != BCRYPT_SALT_LEN) { - throw new IllegalArgumentException("Bad salt length"); - } - init_key(); - ekskey(salt, password); - for (i = 0; i != rounds; i++) { - key(password); - key(salt); - } - - for (i = 0; i < 64; i++) { - for (j = 0; j < (clen >> 1); j++) { - encipher(cdata, j << 1); - } - } - - ret = new byte[clen * 4]; - for (i = 0, j = 0; i < clen; i++) { - ret[j++] = (byte)((cdata[i] >> 24) & 0xff); - ret[j++] = (byte)((cdata[i] >> 16) & 0xff); - ret[j++] = (byte)((cdata[i] >> 8) & 0xff); - ret[j++] = (byte)(cdata[i] & 0xff); - } - return ret; - } - - /** - * Hash a password using the OpenBSD bcrypt scheme - * @param password the password to hash - * @param salt the salt to hash with (perhaps generated - * using BCrypt.gensalt) - * @return the hashed password - */ - public static String hashpw(String password, String salt) { - BCrypt B; - String real_salt; - byte passwordb[], saltb[], hashed[]; - char minor = (char)0; - int rounds, off = 0; - StringBuffer rs = new StringBuffer(); - - if (salt.charAt(0) != '$' || salt.charAt(1) != '2') { - throw new IllegalArgumentException("Invalid salt version"); - } - if (salt.charAt(2) == '$') { - off = 3; - } else { - minor = salt.charAt(2); - if (minor != 'a' || salt.charAt(3) != '$') { - throw new IllegalArgumentException("Invalid salt revision"); - } - off = 4; - } - - // Extract number of rounds - if (salt.charAt(off + 2) > '$') { - throw new IllegalArgumentException("Missing salt rounds"); - } - rounds = Integer.parseInt(salt.substring(off, off + 2)); - - real_salt = salt.substring(off + 3, off + 25); - try { - passwordb = (password + (minor >= 'a' ? "\000" : "")).getBytes("UTF-8"); - } catch (UnsupportedEncodingException uee) { - throw new AssertionError("UTF-8 is not supported"); - } - - saltb = decode_base64(real_salt, BCRYPT_SALT_LEN); - - B = new BCrypt(); - hashed = B.crypt_raw(passwordb, saltb, rounds, - (int[])bf_crypt_ciphertext.clone()); - - rs.append("$2"); - if (minor >= 'a') { - rs.append(minor); - } - rs.append("$"); - if (rounds < 10) { - rs.append("0"); - } - if (rounds > 30) { - throw new IllegalArgumentException( - "rounds exceeds maximum (30)"); - } - rs.append(Integer.toString(rounds)); - rs.append("$"); - rs.append(encode_base64(saltb, saltb.length)); - rs.append(encode_base64(hashed, - bf_crypt_ciphertext.length * 4 - 1)); - return rs.toString(); - } - - /** - * Generate a salt for use with the BCrypt.hashpw() method - * @param log_rounds the log2 of the number of rounds of - * hashing to apply - the work factor therefore increases as - * 2**log_rounds. - * @param random an instance of SecureRandom to use - * @return an encoded salt value - */ - public static String gensalt(int log_rounds, SecureRandom random) { - StringBuffer rs = new StringBuffer(); - byte rnd[] = new byte[BCRYPT_SALT_LEN]; - - random.nextBytes(rnd); - - rs.append("$2a$"); - if (log_rounds < 10) { - rs.append("0"); - } - if (log_rounds > 30) { - throw new IllegalArgumentException( - "log_rounds exceeds maximum (30)"); - } - rs.append(Integer.toString(log_rounds)); - rs.append("$"); - rs.append(encode_base64(rnd, rnd.length)); - return rs.toString(); - } - - /** - * Generate a salt for use with the BCrypt.hashpw() method - * @param log_rounds the log2 of the number of rounds of - * hashing to apply - the work factor therefore increases as - * 2**log_rounds. - * @return an encoded salt value - */ - public static String gensalt(int log_rounds) { - return gensalt(log_rounds, new SecureRandom()); - } - - /** - * Generate a salt for use with the BCrypt.hashpw() method, - * selecting a reasonable default for the number of hashing - * rounds to apply - * @return an encoded salt value - */ - public static String gensalt() { - return gensalt(GENSALT_DEFAULT_LOG2_ROUNDS); - } - - /** - * Check that a plaintext password matches a previously hashed - * one - * @param plaintext the plaintext password to verify - * @param hashed the previously-hashed password - * @return true if the passwords match, false otherwise - */ - public static boolean checkpw(String plaintext, String hashed) { - byte hashed_bytes[]; - byte try_bytes[]; - try { - String try_pw = hashpw(plaintext, hashed); - hashed_bytes = hashed.getBytes("UTF-8"); - try_bytes = try_pw.getBytes("UTF-8"); - } catch (UnsupportedEncodingException uee) { - return false; - } - if (hashed_bytes.length != try_bytes.length) { - return false; - } - byte ret = 0; - for (int i = 0; i < try_bytes.length; i++) { - ret |= hashed_bytes[i] ^ try_bytes[i]; - } - return ret == 0; - } -} +// Copyright (c) 2006 Damien Miller +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +package top.kuanghua.khcomomon.entity; + +import java.io.UnsupportedEncodingException; +import java.security.SecureRandom; + +/** + * BCrypt implements OpenBSD-style Blowfish password hashing using + * the scheme described in "A Future-Adaptable Password Scheme" by + * Niels Provos and David Mazieres. + *

+ * This password hashing system tries to thwart off-line password + * cracking using a computationally-intensive hashing algorithm, + * based on Bruce Schneier's Blowfish cipher. The work factor of + * the algorithm is parameterised, so it can be increased as + * computers get faster. + *

+ * Usage is really simple. To hash a password for the first time, + * call the hashpw method with a random salt, like this: + *

+ * + * String pw_hash = BCrypt.hashpw(plain_password, BCrypt.gensalt());
+ *
+ *

+ * To check whether a plaintext password matches one that has been + * hashed previously, use the checkpw method: + *

+ * + * if (BCrypt.checkpw(candidate_password, stored_hash))
+ *     System.out.println("It matches");
+ * else
+ *     System.out.println("It does not match");
+ *
+ *

+ * The gensalt() method takes an optional parameter (log_rounds) + * that determines the computational complexity of the hashing: + *

+ * + * String strong_salt = BCrypt.gensalt(10)
+ * String stronger_salt = BCrypt.gensalt(12)
+ *
+ *

+ * The amount of work increases exponentially (2**log_rounds), so + * each increment is twice as much work. The default log_rounds is + * 10, and the valid range is 4 to 30. + * + * @version 0.2 + */ +public class BCrypt { + // BCrypt parameters + private static final int GENSALT_DEFAULT_LOG2_ROUNDS = 10; + private static final int BCRYPT_SALT_LEN = 16; + + // Blowfish parameters + private static final int BLOWFISH_NUM_ROUNDS = 16; + + // Initial contents of key schedule + private static final int P_orig[] = { + 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, + 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, + 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, + 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, + 0x9216d5d9, 0x8979fb1b + }; + private static final int S_orig[] = { + 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, + 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99, + 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, + 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, + 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, + 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013, + 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, + 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e, + 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60, + 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, + 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce, + 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a, + 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, + 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677, + 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193, + 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, + 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88, + 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239, + 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, + 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0, + 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3, + 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, + 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88, + 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe, + 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, + 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d, + 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b, + 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, + 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba, + 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463, + 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, + 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09, + 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, + 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, + 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279, + 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8, + 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, + 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82, + 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db, + 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, + 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0, + 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b, + 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, + 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8, + 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4, + 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, + 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7, + 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c, + 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, + 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1, + 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299, + 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, + 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, + 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf, + 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, + 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af, + 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa, + 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, + 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41, + 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915, + 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, + 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915, + 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, + 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a, + 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, + 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266, + 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, + 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, + 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, + 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1, + 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, + 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1, + 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, + 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, + 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff, + 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd, + 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, + 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7, + 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41, + 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, + 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf, + 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af, + 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, + 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87, + 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, + 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, + 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16, + 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd, + 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, + 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509, + 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, + 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, + 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f, + 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a, + 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, + 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960, + 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66, + 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, + 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802, + 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84, + 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, + 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf, + 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, + 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, + 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50, + 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7, + 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, + 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281, + 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, + 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, + 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128, + 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73, + 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, + 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0, + 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105, + 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, + 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3, + 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285, + 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, + 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061, + 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, + 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, + 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, + 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc, + 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, + 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340, + 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, + 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7, + 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, + 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068, + 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, + 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, + 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45, + 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504, + 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, + 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb, + 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, + 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, + 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42, + 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b, + 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, + 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb, + 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, + 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, + 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33, + 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c, + 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, + 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc, + 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17, + 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, + 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b, + 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115, + 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, + 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728, + 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, + 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, + 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37, + 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d, + 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, + 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b, + 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, + 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, + 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d, + 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c, + 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, + 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9, + 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a, + 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, + 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d, + 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc, + 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, + 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61, + 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, + 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, + 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2, + 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c, + 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, + 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633, + 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, + 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, + 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52, + 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027, + 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, + 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62, + 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634, + 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, + 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, + 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc, + 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, + 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c, + 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, + 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0, + 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, + 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe, + 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, + 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, + 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, + 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6, + 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, + 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22, + 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4, + 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, + 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9, + 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59, + 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, + 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51, + 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28, + 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, + 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, + 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28, + 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, + 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd, + 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, + 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, + 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb, + 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f, + 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, + 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32, + 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680, + 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, + 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae, + 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb, + 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, + 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47, + 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370, + 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, + 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84, + 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048, + 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, + 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd, + 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9, + 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, + 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, + 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f, + 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, + 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525, + 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1, + 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, + 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964, + 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e, + 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, + 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d, + 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f, + 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, + 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02, + 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc, + 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, + 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a, + 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, + 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, + 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, + 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060, + 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, + 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9, + 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, + 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6 + }; + + // bcrypt IV: "OrpheanBeholderScryDoubt". The C implementation calls + // this "ciphertext", but it is really plaintext or an IV. We keep + // the name to make code comparison easier. + static private final int bf_crypt_ciphertext[] = { + 0x4f727068, 0x65616e42, 0x65686f6c, + 0x64657253, 0x63727944, 0x6f756274 + }; + + // Table for Base64 encoding + static private final char base64_code[] = { + '.', '/', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', + 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', + 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', + 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', + 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', + '6', '7', '8', '9' + }; + + // Table for Base64 decoding + static private final byte index_64[] = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 0, 1, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, -1, -1, + -1, -1, -1, -1, -1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + -1, -1, -1, -1, -1, -1, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, -1, -1, -1, -1, -1 + }; + + // Expanded Blowfish key + private int P[]; + private int S[]; + + /** + * Encode a byte array using bcrypt's slightly-modified base64 + * encoding scheme. Note that this is *not* compatible with + * the standard MIME-base64 encoding. + * + * @param d the byte array to encode + * @param len the number of bytes to encode + * @return base64-encoded string + * @exception IllegalArgumentException if the length is invalid + */ + private static String encode_base64(byte d[], int len) + throws IllegalArgumentException { + int off = 0; + StringBuffer rs = new StringBuffer(); + int c1, c2; + + if (len <= 0 || len > d.length) { + throw new IllegalArgumentException("Invalid len"); + } + while (off < len) { + c1 = d[off++] & 0xff; + rs.append(base64_code[(c1 >> 2) & 0x3f]); + c1 = (c1 & 0x03) << 4; + if (off >= len) { + rs.append(base64_code[c1 & 0x3f]); + break; + } + c2 = d[off++] & 0xff; + c1 |= (c2 >> 4) & 0x0f; + rs.append(base64_code[c1 & 0x3f]); + c1 = (c2 & 0x0f) << 2; + if (off >= len) { + rs.append(base64_code[c1 & 0x3f]); + break; + } + c2 = d[off++] & 0xff; + c1 |= (c2 >> 6) & 0x03; + rs.append(base64_code[c1 & 0x3f]); + rs.append(base64_code[c2 & 0x3f]); + } + return rs.toString(); + } + + /** + * Look up the 3 bits base64-encoded by the specified character, + * range-checking againt conversion table + * @param x the base64-encoded value + * @return the decoded value of x + */ + private static byte char64(char x) { + if ((int)x < 0 || (int)x > index_64.length) { + return -1; + } + return index_64[(int)x]; + } + + /** + * Decode a string encoded using bcrypt's base64 scheme to a + * byte array. Note that this is *not* compatible with + * the standard MIME-base64 encoding. + * @param s the string to decode + * @param maxolen the maximum number of bytes to decode + * @return an array containing the decoded bytes + * @throws IllegalArgumentException if maxolen is invalid + */ + private static byte[] decode_base64(String s, int maxolen) + throws IllegalArgumentException { + StringBuffer rs = new StringBuffer(); + int off = 0, slen = s.length(), olen = 0; + byte ret[]; + byte c1, c2, c3, c4, o; + + if (maxolen <= 0) { + throw new IllegalArgumentException("Invalid maxolen"); + } + while (off < slen - 1 && olen < maxolen) { + c1 = char64(s.charAt(off++)); + c2 = char64(s.charAt(off++)); + if (c1 == -1 || c2 == -1) { + break; + } + o = (byte)(c1 << 2); + o |= (c2 & 0x30) >> 4; + rs.append((char)o); + if (++olen >= maxolen || off >= slen) { + break; + } + c3 = char64(s.charAt(off++)); + if (c3 == -1) { + break; + } + o = (byte)((c2 & 0x0f) << 4); + o |= (c3 & 0x3c) >> 2; + rs.append((char)o); + if (++olen >= maxolen || off >= slen) { + break; + } + c4 = char64(s.charAt(off++)); + o = (byte)((c3 & 0x03) << 6); + o |= c4; + rs.append((char)o); + ++olen; + } + + ret = new byte[olen]; + for (off = 0; off < olen; off++) { + ret[off] = (byte) rs.charAt(off); + } + return ret; + } + + /** + * Blowfish encipher a single 64-bit block encoded as + * two 32-bit halves + * @param lr an array containing the two 32-bit half blocks + * @param off the position in the array of the blocks + */ + private final void encipher(int lr[], int off) { + int i, n, l = lr[off], r = lr[off + 1]; + + l ^= P[0]; + for (i = 0; i <= BLOWFISH_NUM_ROUNDS - 2;) { + // Feistel substitution on left word + n = S[(l >> 24) & 0xff]; + n += S[0x100 | ((l >> 16) & 0xff)]; + n ^= S[0x200 | ((l >> 8) & 0xff)]; + n += S[0x300 | (l & 0xff)]; + r ^= n ^ P[++i]; + + // Feistel substitution on right word + n = S[(r >> 24) & 0xff]; + n += S[0x100 | ((r >> 16) & 0xff)]; + n ^= S[0x200 | ((r >> 8) & 0xff)]; + n += S[0x300 | (r & 0xff)]; + l ^= n ^ P[++i]; + } + lr[off] = r ^ P[BLOWFISH_NUM_ROUNDS + 1]; + lr[off + 1] = l; + } + + /** + * Cycically extract a word of key material + * @param data the string to extract the data from + * @param offp a "pointer" (as a one-entry array) to the + * current offset into data + * @return the next word of material from data + */ + private static int streamtoword(byte data[], int offp[]) { + int i; + int word = 0; + int off = offp[0]; + + for (i = 0; i < 4; i++) { + word = (word << 8) | (data[off] & 0xff); + off = (off + 1) % data.length; + } + + offp[0] = off; + return word; + } + + /** + * Initialise the Blowfish key schedule + */ + private void init_key() { + P = (int[])P_orig.clone(); + S = (int[])S_orig.clone(); + } + + /** + * Key the Blowfish cipher + * @param key an array containing the key + */ + private void key(byte key[]) { + int i; + int koffp[] = { 0 }; + int lr[] = { 0, 0 }; + int plen = P.length, slen = S.length; + + for (i = 0; i < plen; i++) { + P[i] = P[i] ^ streamtoword(key, koffp); + } + for (i = 0; i < plen; i += 2) { + encipher(lr, 0); + P[i] = lr[0]; + P[i + 1] = lr[1]; + } + + for (i = 0; i < slen; i += 2) { + encipher(lr, 0); + S[i] = lr[0]; + S[i + 1] = lr[1]; + } + } + + /** + * Perform the "enhanced key schedule" step described by + * Provos and Mazieres in "A Future-Adaptable Password Scheme" + * http://www.openbsd.org/papers/bcrypt-paper.ps + * @param data salt information + * @param key password information + */ + private void ekskey(byte data[], byte key[]) { + int i; + int koffp[] = { 0 }, doffp[] = { 0 }; + int lr[] = { 0, 0 }; + int plen = P.length, slen = S.length; + + for (i = 0; i < plen; i++) { + P[i] = P[i] ^ streamtoword(key, koffp); + } + for (i = 0; i < plen; i += 2) { + lr[0] ^= streamtoword(data, doffp); + lr[1] ^= streamtoword(data, doffp); + encipher(lr, 0); + P[i] = lr[0]; + P[i + 1] = lr[1]; + } + + for (i = 0; i < slen; i += 2) { + lr[0] ^= streamtoword(data, doffp); + lr[1] ^= streamtoword(data, doffp); + encipher(lr, 0); + S[i] = lr[0]; + S[i + 1] = lr[1]; + } + } + + /** + * Perform the central password hashing step in the + * bcrypt scheme + * @param password the password to hash + * @param salt the binary salt to hash with the password + * @param log_rounds the binary logarithm of the number + * of rounds of hashing to apply + * @param cdata the plaintext to encrypt + * @return an array containing the binary hashed password + */ + public byte[] crypt_raw(byte password[], byte salt[], int log_rounds, + int cdata[]) { + int rounds, i, j; + int clen = cdata.length; + byte ret[]; + + if (log_rounds < 4 || log_rounds > 30) { + throw new IllegalArgumentException("Bad number of rounds"); + } + rounds = 1 << log_rounds; + if (salt.length != BCRYPT_SALT_LEN) { + throw new IllegalArgumentException("Bad salt length"); + } + init_key(); + ekskey(salt, password); + for (i = 0; i != rounds; i++) { + key(password); + key(salt); + } + + for (i = 0; i < 64; i++) { + for (j = 0; j < (clen >> 1); j++) { + encipher(cdata, j << 1); + } + } + + ret = new byte[clen * 4]; + for (i = 0, j = 0; i < clen; i++) { + ret[j++] = (byte)((cdata[i] >> 24) & 0xff); + ret[j++] = (byte)((cdata[i] >> 16) & 0xff); + ret[j++] = (byte)((cdata[i] >> 8) & 0xff); + ret[j++] = (byte)(cdata[i] & 0xff); + } + return ret; + } + + /** + * Hash a password using the OpenBSD bcrypt scheme + * @param password the password to hash + * @param salt the salt to hash with (perhaps generated + * using BCrypt.gensalt) + * @return the hashed password + */ + public static String hashpw(String password, String salt) { + BCrypt B; + String real_salt; + byte passwordb[], saltb[], hashed[]; + char minor = (char)0; + int rounds, off = 0; + StringBuffer rs = new StringBuffer(); + + if (salt.charAt(0) != '$' || salt.charAt(1) != '2') { + throw new IllegalArgumentException("Invalid salt version"); + } + if (salt.charAt(2) == '$') { + off = 3; + } else { + minor = salt.charAt(2); + if (minor != 'a' || salt.charAt(3) != '$') { + throw new IllegalArgumentException("Invalid salt revision"); + } + off = 4; + } + + // Extract number of rounds + if (salt.charAt(off + 2) > '$') { + throw new IllegalArgumentException("Missing salt rounds"); + } + rounds = Integer.parseInt(salt.substring(off, off + 2)); + + real_salt = salt.substring(off + 3, off + 25); + try { + passwordb = (password + (minor >= 'a' ? "\000" : "")).getBytes("UTF-8"); + } catch (UnsupportedEncodingException uee) { + throw new AssertionError("UTF-8 is not supported"); + } + + saltb = decode_base64(real_salt, BCRYPT_SALT_LEN); + + B = new BCrypt(); + hashed = B.crypt_raw(passwordb, saltb, rounds, + (int[])bf_crypt_ciphertext.clone()); + + rs.append("$2"); + if (minor >= 'a') { + rs.append(minor); + } + rs.append("$"); + if (rounds < 10) { + rs.append("0"); + } + if (rounds > 30) { + throw new IllegalArgumentException( + "rounds exceeds maximum (30)"); + } + rs.append(Integer.toString(rounds)); + rs.append("$"); + rs.append(encode_base64(saltb, saltb.length)); + rs.append(encode_base64(hashed, + bf_crypt_ciphertext.length * 4 - 1)); + return rs.toString(); + } + + /** + * Generate a salt for use with the BCrypt.hashpw() method + * @param log_rounds the log2 of the number of rounds of + * hashing to apply - the work factor therefore increases as + * 2**log_rounds. + * @param random an instance of SecureRandom to use + * @return an encoded salt value + */ + public static String gensalt(int log_rounds, SecureRandom random) { + StringBuffer rs = new StringBuffer(); + byte rnd[] = new byte[BCRYPT_SALT_LEN]; + + random.nextBytes(rnd); + + rs.append("$2a$"); + if (log_rounds < 10) { + rs.append("0"); + } + if (log_rounds > 30) { + throw new IllegalArgumentException( + "log_rounds exceeds maximum (30)"); + } + rs.append(Integer.toString(log_rounds)); + rs.append("$"); + rs.append(encode_base64(rnd, rnd.length)); + return rs.toString(); + } + + /** + * Generate a salt for use with the BCrypt.hashpw() method + * @param log_rounds the log2 of the number of rounds of + * hashing to apply - the work factor therefore increases as + * 2**log_rounds. + * @return an encoded salt value + */ + public static String gensalt(int log_rounds) { + return gensalt(log_rounds, new SecureRandom()); + } + + /** + * Generate a salt for use with the BCrypt.hashpw() method, + * selecting a reasonable default for the number of hashing + * rounds to apply + * @return an encoded salt value + */ + public static String gensalt() { + return gensalt(GENSALT_DEFAULT_LOG2_ROUNDS); + } + + /** + * Check that a plaintext password matches a previously hashed + * one + * @param plaintext the plaintext password to verify + * @param hashed the previously-hashed password + * @return true if the passwords match, false otherwise + */ + public static boolean checkpw(String plaintext, String hashed) { + byte hashed_bytes[]; + byte try_bytes[]; + try { + String try_pw = hashpw(plaintext, hashed); + hashed_bytes = hashed.getBytes("UTF-8"); + try_bytes = try_pw.getBytes("UTF-8"); + } catch (UnsupportedEncodingException uee) { + return false; + } + if (hashed_bytes.length != try_bytes.length) { + return false; + } + byte ret = 0; + for (int i = 0; i < try_bytes.length; i++) { + ret |= hashed_bytes[i] ^ try_bytes[i]; + } + return ret == 0; + } +} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CacheKey.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CacheKey.java index ca0930f..e5af96e 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CacheKey.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CacheKey.java @@ -1,24 +1,24 @@ -package top.kuanghua.khcomomon.entity; - -/**** - * @Author:kuanghua - * @Description: - *****/ -public class CacheKey { - - /** - * 商品分类 - */ - public static String CATEGORY="CATEGORY"; - - /** - * 品牌缓存 - */ - public static String BRAND="BRAND"; - - /** - * 规格 - */ - public static String SPEC="SPEC"; - -} +package top.kuanghua.khcomomon.entity; + +/**** + * @Author:kuanghua + * @Description: + *****/ +public class CacheKey { + + /** + * 商品分类 + */ + public static String CATEGORY="CATEGORY"; + + /** + * 品牌缓存 + */ + public static String BRAND="BRAND"; + + /** + * 规格 + */ + public static String SPEC="SPEC"; + +} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CommonParamsSelf.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CommonParamsSelf.java index 2d63707..2185366 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CommonParamsSelf.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CommonParamsSelf.java @@ -1,20 +1,20 @@ -package top.kuanghua.khcomomon.entity; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * @Title: CommonParams - * @Description: - * @Auther: kuanghua - * @create 2020/12/15 12:01 - */ -@Data -@ApiModel -public class CommonParamsSelf extends KHCommonPageParams{ - @ApiModelProperty("开始时间") - private String startTime; - @ApiModelProperty("结束时间") - private String endTime; -} +package top.kuanghua.khcomomon.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Title: CommonParams + * @Description: + * @Auther: kuanghua + * @create 2020/12/15 12:01 + */ +@Data +@ApiModel +public class CommonParamsSelf extends KHCommonPageParams{ + @ApiModelProperty("开始时间") + private String startTime; + @ApiModelProperty("结束时间") + private String endTime; +} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/HttpClient.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/HttpClient.java index 27ce239..70c9d3a 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/HttpClient.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/HttpClient.java @@ -1,170 +1,170 @@ -package top.kuanghua.khcomomon.entity; - -import org.apache.http.Consts; -import org.apache.http.HttpEntity; -import org.apache.http.NameValuePair; -import org.apache.http.ParseException; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.client.methods.*; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.conn.ssl.TrustStrategy; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.message.BasicNameValuePair; -import org.apache.http.ssl.SSLContextBuilder; -import org.apache.http.util.EntityUtils; - -import javax.net.ssl.SSLContext; -import java.io.IOException; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -/***** - * @Author: kuanghua - * @Description: entity - ****/ -public class HttpClient { - private String url; - private Map param; - private int statusCode; - private String content; - private String xmlParam; - private boolean isHttps; - - public boolean isHttps() { - return isHttps; - } - - public void setHttps(boolean isHttps) { - this.isHttps = isHttps; - } - - public String getXmlParam() { - return xmlParam; - } - - public void setXmlParam(String xmlParam) { - this.xmlParam = xmlParam; - } - - public HttpClient(String url, Map param) { - this.url = url; - this.param = param; - } - - public HttpClient(String url) { - this.url = url; - } - - public void setParameter(Map map) { - param = map; - } - - public void addParameter(String key, String value) { - if (param == null) - param = new HashMap(); - param.put(key, value); - } - - public void post() throws ClientProtocolException, IOException { - HttpPost http = new HttpPost(url); - setEntity(http); - execute(http); - } - - public void put() throws ClientProtocolException, IOException { - HttpPut http = new HttpPut(url); - setEntity(http); - execute(http); - } - - public void get() throws ClientProtocolException, IOException { - if (param != null) { - StringBuilder url = new StringBuilder(this.url); - boolean isFirst = true; - for (String key : param.keySet()) { - if (isFirst) { - url.append("?"); - }else { - url.append("&"); - } - url.append(key).append("=").append(param.get(key)); - } - this.url = url.toString(); - } - HttpGet http = new HttpGet(url); - execute(http); - } - - /** - * set http post,put param - */ - private void setEntity(HttpEntityEnclosingRequestBase http) { - if (param != null) { - List nvps = new LinkedList(); - for (String key : param.keySet()) { - nvps.add(new BasicNameValuePair(key, param.get(key))); // 参数 - } - http.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8)); // 设置参数 - } - if (xmlParam != null) { - http.setEntity(new StringEntity(xmlParam, Consts.UTF_8)); - } - } - - private void execute(HttpUriRequest http) throws ClientProtocolException, - IOException { - CloseableHttpClient httpClient = null; - try { - if (isHttps) { - SSLContext sslContext = new SSLContextBuilder() - .loadTrustMaterial(null, new TrustStrategy() { - // 信任所有 - @Override - public boolean isTrusted(X509Certificate[] chain, - String authType) - throws CertificateException { - return true; - } - }).build(); - SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( - sslContext); - httpClient = HttpClients.custom().setSSLSocketFactory(sslsf) - .build(); - } else { - httpClient = HttpClients.createDefault(); - } - CloseableHttpResponse response = httpClient.execute(http); - try { - if (response != null) { - if (response.getStatusLine() != null) { - statusCode = response.getStatusLine().getStatusCode(); - } - HttpEntity entity = response.getEntity(); - // 响应内容 - content = EntityUtils.toString(entity, Consts.UTF_8); - } - } finally { - response.close(); - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - httpClient.close(); - } - } - - public int getStatusCode() { - return statusCode; - } - - public String getContent() throws ParseException, IOException { - return content; - } +package top.kuanghua.khcomomon.entity; + +import org.apache.http.Consts; +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.ParseException; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.*; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.TrustStrategy; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.ssl.SSLContextBuilder; +import org.apache.http.util.EntityUtils; + +import javax.net.ssl.SSLContext; +import java.io.IOException; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +/***** + * @Author: kuanghua + * @Description: entity + ****/ +public class HttpClient { + private String url; + private Map param; + private int statusCode; + private String content; + private String xmlParam; + private boolean isHttps; + + public boolean isHttps() { + return isHttps; + } + + public void setHttps(boolean isHttps) { + this.isHttps = isHttps; + } + + public String getXmlParam() { + return xmlParam; + } + + public void setXmlParam(String xmlParam) { + this.xmlParam = xmlParam; + } + + public HttpClient(String url, Map param) { + this.url = url; + this.param = param; + } + + public HttpClient(String url) { + this.url = url; + } + + public void setParameter(Map map) { + param = map; + } + + public void addParameter(String key, String value) { + if (param == null) + param = new HashMap(); + param.put(key, value); + } + + public void post() throws ClientProtocolException, IOException { + HttpPost http = new HttpPost(url); + setEntity(http); + execute(http); + } + + public void put() throws ClientProtocolException, IOException { + HttpPut http = new HttpPut(url); + setEntity(http); + execute(http); + } + + public void get() throws ClientProtocolException, IOException { + if (param != null) { + StringBuilder url = new StringBuilder(this.url); + boolean isFirst = true; + for (String key : param.keySet()) { + if (isFirst) { + url.append("?"); + }else { + url.append("&"); + } + url.append(key).append("=").append(param.get(key)); + } + this.url = url.toString(); + } + HttpGet http = new HttpGet(url); + execute(http); + } + + /** + * set http post,put param + */ + private void setEntity(HttpEntityEnclosingRequestBase http) { + if (param != null) { + List nvps = new LinkedList(); + for (String key : param.keySet()) { + nvps.add(new BasicNameValuePair(key, param.get(key))); // 参数 + } + http.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8)); // 设置参数 + } + if (xmlParam != null) { + http.setEntity(new StringEntity(xmlParam, Consts.UTF_8)); + } + } + + private void execute(HttpUriRequest http) throws ClientProtocolException, + IOException { + CloseableHttpClient httpClient = null; + try { + if (isHttps) { + SSLContext sslContext = new SSLContextBuilder() + .loadTrustMaterial(null, new TrustStrategy() { + // 信任所有 + @Override + public boolean isTrusted(X509Certificate[] chain, + String authType) + throws CertificateException { + return true; + } + }).build(); + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( + sslContext); + httpClient = HttpClients.custom().setSSLSocketFactory(sslsf) + .build(); + } else { + httpClient = HttpClients.createDefault(); + } + CloseableHttpResponse response = httpClient.execute(http); + try { + if (response != null) { + if (response.getStatusLine() != null) { + statusCode = response.getStatusLine().getStatusCode(); + } + HttpEntity entity = response.getEntity(); + // 响应内容 + content = EntityUtils.toString(entity, Consts.UTF_8); + } + } finally { + response.close(); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + httpClient.close(); + } + } + + public int getStatusCode() { + return statusCode; + } + + public String getContent() throws ParseException, IOException { + return content; + } } \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/IdWorker.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/IdWorker.java index f39e9ea..a741d39 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/IdWorker.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/IdWorker.java @@ -1,172 +1,172 @@ -package top.kuanghua.khcomomon.entity; - -import java.lang.management.ManagementFactory; -import java.net.InetAddress; -import java.net.NetworkInterface; - -/** - *

名称:IdWorker.java

- *

描述:分布式自增长ID

- *
- *     Twitter的 Snowflake JAVA实现方案
- * 
- * 核心代码为其IdWorker这个类实现,其原理结构如下,我分别用一个0表示一位,用—分割开部分的作用: - * 1||0---0000000000 0000000000 0000000000 0000000000 0 --- 00000 ---00000 ---000000000000 - * 在上面的字符串中,第一位为未使用(实际上也可作为long的符号位),接下来的41位为毫秒级时间, - * 然后5位datacenter标识位,5位机器ID(并不算标识符,实际是为线程标识), - * 然后12位该毫秒内的当前毫秒内的计数,加起来刚好64位,为一个Long型。 - * 这样的好处是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由datacenter和机器ID作区分), - * 并且效率较高,经测试,snowflake每秒能够产生26万ID左右,完全满足需要。 - *

- * 64位ID (42(毫秒)+5(机器ID)+5(业务编码)+12(重复累加)) - * - * @author Polim - */ -public class IdWorker { - // 时间起始标记点,作为基准,一般取系统的最近时间(一旦确定不能变动) - private final static long twepoch = 1288834974657L; - // 机器标识位数 - private final static long workerIdBits = 5L; - // 数据中心标识位数 - private final static long datacenterIdBits = 5L; - // 机器ID最大值 - private final static long maxWorkerId = -1L ^ (-1L << workerIdBits); - // 数据中心ID最大值 - private final static long maxDatacenterId = -1L ^ (-1L << datacenterIdBits); - // 毫秒内自增位 - private final static long sequenceBits = 12L; - // 机器ID偏左移12位 - private final static long workerIdShift = sequenceBits; - // 数据中心ID左移17位 - private final static long datacenterIdShift = sequenceBits + workerIdBits; - // 时间毫秒左移22位 - private final static long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits; - - private final static long sequenceMask = -1L ^ (-1L << sequenceBits); - /* 上次生产id时间戳 */ - private static long lastTimestamp = -1L; - // 0,并发控制 - private long sequence = 0L; - - private final long workerId; - // 数据标识id部分 - private final long datacenterId; - - public IdWorker(){ - this.datacenterId = getDatacenterId(maxDatacenterId); - this.workerId = getMaxWorkerId(datacenterId, maxWorkerId); - } - /** - * @param workerId - * 工作机器ID - * @param datacenterId - * 序列号 - */ - public IdWorker(long workerId, long datacenterId) { - if (workerId > maxWorkerId || workerId < 0) { - throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId)); - } - if (datacenterId > maxDatacenterId || datacenterId < 0) { - throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId)); - } - this.workerId = workerId; - this.datacenterId = datacenterId; - } - /** - * 获取下一个ID - * - * @return - */ - public synchronized long nextId() { - long timestamp = timeGen(); - if (timestamp < lastTimestamp) { - throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp)); - } - - if (lastTimestamp == timestamp) { - // 当前毫秒内,则+1 - sequence = (sequence + 1) & sequenceMask; - if (sequence == 0) { - // 当前毫秒内计数满了,则等待下一秒 - timestamp = tilNextMillis(lastTimestamp); - } - } else { - sequence = 0L; - } - lastTimestamp = timestamp; - // ID偏移组合生成最终的ID,并返回ID - long nextId = ((timestamp - twepoch) << timestampLeftShift) - | (datacenterId << datacenterIdShift) - | (workerId << workerIdShift) | sequence; - - return nextId; - } - - private long tilNextMillis(final long lastTimestamp) { - long timestamp = this.timeGen(); - while (timestamp <= lastTimestamp) { - timestamp = this.timeGen(); - } - return timestamp; - } - - private long timeGen() { - return System.currentTimeMillis(); - } - - /** - *

- * 获取 maxWorkerId - *

- */ - protected static long getMaxWorkerId(long datacenterId, long maxWorkerId) { - StringBuffer mpid = new StringBuffer(); - mpid.append(datacenterId); - String name = ManagementFactory.getRuntimeMXBean().getName(); - if (!name.isEmpty()) { - /* - * GET jvmPid - */ - mpid.append(name.split("@")[0]); - } - /* - * MAC + PID 的 hashcode 获取16个低位 - */ - return (mpid.toString().hashCode() & 0xffff) % (maxWorkerId + 1); - } - - /** - *

- * 数据标识id部分 - *

- */ - protected static long getDatacenterId(long maxDatacenterId) { - long id = 0L; - try { - InetAddress ip = InetAddress.getLocalHost(); - NetworkInterface network = NetworkInterface.getByInetAddress(ip); - if (network == null) { - id = 1L; - } else { - byte[] mac = network.getHardwareAddress(); - id = ((0x000000FF & (long) mac[mac.length - 1]) - | (0x0000FF00 & (((long) mac[mac.length - 2]) << 8))) >> 6; - id = id % (maxDatacenterId + 1); - } - } catch (Exception e) { - // System.out.println(" getDatacenterId: " + e.getMessage()); - } - return id; - } - - - public static void main(String[] args) { - //推特 26万个不重复的ID - //参数1 参数2 是在0 -31 之间 - IdWorker idWorker = new IdWorker(0,1); - for (int i = 0; i <100 ; i++) { - System.out.println(idWorker.nextId());//用于生成唯一的ID - } - } - +package top.kuanghua.khcomomon.entity; + +import java.lang.management.ManagementFactory; +import java.net.InetAddress; +import java.net.NetworkInterface; + +/** + *

名称:IdWorker.java

+ *

描述:分布式自增长ID

+ *
+ *     Twitter的 Snowflake JAVA实现方案
+ * 
+ * 核心代码为其IdWorker这个类实现,其原理结构如下,我分别用一个0表示一位,用—分割开部分的作用: + * 1||0---0000000000 0000000000 0000000000 0000000000 0 --- 00000 ---00000 ---000000000000 + * 在上面的字符串中,第一位为未使用(实际上也可作为long的符号位),接下来的41位为毫秒级时间, + * 然后5位datacenter标识位,5位机器ID(并不算标识符,实际是为线程标识), + * 然后12位该毫秒内的当前毫秒内的计数,加起来刚好64位,为一个Long型。 + * 这样的好处是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由datacenter和机器ID作区分), + * 并且效率较高,经测试,snowflake每秒能够产生26万ID左右,完全满足需要。 + *

+ * 64位ID (42(毫秒)+5(机器ID)+5(业务编码)+12(重复累加)) + * + * @author Polim + */ +public class IdWorker { + // 时间起始标记点,作为基准,一般取系统的最近时间(一旦确定不能变动) + private final static long twepoch = 1288834974657L; + // 机器标识位数 + private final static long workerIdBits = 5L; + // 数据中心标识位数 + private final static long datacenterIdBits = 5L; + // 机器ID最大值 + private final static long maxWorkerId = -1L ^ (-1L << workerIdBits); + // 数据中心ID最大值 + private final static long maxDatacenterId = -1L ^ (-1L << datacenterIdBits); + // 毫秒内自增位 + private final static long sequenceBits = 12L; + // 机器ID偏左移12位 + private final static long workerIdShift = sequenceBits; + // 数据中心ID左移17位 + private final static long datacenterIdShift = sequenceBits + workerIdBits; + // 时间毫秒左移22位 + private final static long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits; + + private final static long sequenceMask = -1L ^ (-1L << sequenceBits); + /* 上次生产id时间戳 */ + private static long lastTimestamp = -1L; + // 0,并发控制 + private long sequence = 0L; + + private final long workerId; + // 数据标识id部分 + private final long datacenterId; + + public IdWorker(){ + this.datacenterId = getDatacenterId(maxDatacenterId); + this.workerId = getMaxWorkerId(datacenterId, maxWorkerId); + } + /** + * @param workerId + * 工作机器ID + * @param datacenterId + * 序列号 + */ + public IdWorker(long workerId, long datacenterId) { + if (workerId > maxWorkerId || workerId < 0) { + throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId)); + } + if (datacenterId > maxDatacenterId || datacenterId < 0) { + throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId)); + } + this.workerId = workerId; + this.datacenterId = datacenterId; + } + /** + * 获取下一个ID + * + * @return + */ + public synchronized long nextId() { + long timestamp = timeGen(); + if (timestamp < lastTimestamp) { + throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp)); + } + + if (lastTimestamp == timestamp) { + // 当前毫秒内,则+1 + sequence = (sequence + 1) & sequenceMask; + if (sequence == 0) { + // 当前毫秒内计数满了,则等待下一秒 + timestamp = tilNextMillis(lastTimestamp); + } + } else { + sequence = 0L; + } + lastTimestamp = timestamp; + // ID偏移组合生成最终的ID,并返回ID + long nextId = ((timestamp - twepoch) << timestampLeftShift) + | (datacenterId << datacenterIdShift) + | (workerId << workerIdShift) | sequence; + + return nextId; + } + + private long tilNextMillis(final long lastTimestamp) { + long timestamp = this.timeGen(); + while (timestamp <= lastTimestamp) { + timestamp = this.timeGen(); + } + return timestamp; + } + + private long timeGen() { + return System.currentTimeMillis(); + } + + /** + *

+ * 获取 maxWorkerId + *

+ */ + protected static long getMaxWorkerId(long datacenterId, long maxWorkerId) { + StringBuffer mpid = new StringBuffer(); + mpid.append(datacenterId); + String name = ManagementFactory.getRuntimeMXBean().getName(); + if (!name.isEmpty()) { + /* + * GET jvmPid + */ + mpid.append(name.split("@")[0]); + } + /* + * MAC + PID 的 hashcode 获取16个低位 + */ + return (mpid.toString().hashCode() & 0xffff) % (maxWorkerId + 1); + } + + /** + *

+ * 数据标识id部分 + *

+ */ + protected static long getDatacenterId(long maxDatacenterId) { + long id = 0L; + try { + InetAddress ip = InetAddress.getLocalHost(); + NetworkInterface network = NetworkInterface.getByInetAddress(ip); + if (network == null) { + id = 1L; + } else { + byte[] mac = network.getHardwareAddress(); + id = ((0x000000FF & (long) mac[mac.length - 1]) + | (0x0000FF00 & (((long) mac[mac.length - 2]) << 8))) >> 6; + id = id % (maxDatacenterId + 1); + } + } catch (Exception e) { + // System.out.println(" getDatacenterId: " + e.getMessage()); + } + return id; + } + + + public static void main(String[] args) { + //推特 26万个不重复的ID + //参数1 参数2 是在0 -31 之间 + IdWorker idWorker = new IdWorker(0,1); + for (int i = 0; i <100 ; i++) { + System.out.println(idWorker.nextId());//用于生成唯一的ID + } + } + } \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonPageParams.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonPageParams.java index 6e7259b..93859f2 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonPageParams.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonPageParams.java @@ -1,36 +1,36 @@ -package top.kuanghua.khcomomon.entity; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * @Title: CommonParams - * @Description: - * @Auther: kuanghua - * @create 2020/12/15 12:01 - */ -@Data -@ApiModel -public class KHCommonPageParams { - - @ApiModelProperty("页数") - private Integer pageSize; - - @ApiModelProperty("页码") - private Integer pageNum; - public Integer getPageSize() { - if(pageSize ==null ){ - return 10; - }else{ - return pageSize; - } - } - public Integer getPageNum() { - if(pageSize ==null){ - return 1; - }else{ - return pageNum; - } - } -} +package top.kuanghua.khcomomon.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Title: CommonParams + * @Description: + * @Auther: kuanghua + * @create 2020/12/15 12:01 + */ +@Data +@ApiModel +public class KHCommonPageParams { + + @ApiModelProperty("页数") + private Integer pageSize; + + @ApiModelProperty("页码") + private Integer pageNum; + public Integer getPageSize() { + if(pageSize ==null ){ + return 10; + }else{ + return pageSize; + } + } + public Integer getPageNum() { + if(pageSize ==null){ + return 1; + }else{ + return pageNum; + } + } +} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonParams.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonParams.java index bc05006..fbbad77 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonParams.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonParams.java @@ -1,20 +1,20 @@ -package top.kuanghua.khcomomon.entity; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * @Title: CommonParams - * @Description: - * @Auther: kuanghua - * @create 2020/12/15 12:01 - */ -@Data -@ApiModel -public class KHCommonParams extends KHCommonPageParams{ - @ApiModelProperty("开始时间") - private String startTime; - @ApiModelProperty("结束时间") - private String endTime; -} +package top.kuanghua.khcomomon.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Title: CommonParams + * @Description: + * @Auther: kuanghua + * @create 2020/12/15 12:01 + */ +@Data +@ApiModel +public class KHCommonParams extends KHCommonPageParams{ + @ApiModelProperty("开始时间") + private String startTime; + @ApiModelProperty("结束时间") + private String endTime; +} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/PageResult.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/PageResult.java index effbc11..17f2f1f 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/PageResult.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/PageResult.java @@ -1,36 +1,36 @@ -package top.kuanghua.khcomomon.entity; - -import java.util.List; - -/** - * 分页结果类 - */ -public class PageResult { - - private Long total;//总记录数 - private List rows;//记录 - - public PageResult(Long total, List rows) { - this.total = total; - this.rows = rows; - } - - public PageResult() { - } - - public Long getTotal() { - return total; - } - - public void setTotal(Long total) { - this.total = total; - } - - public List getRows() { - return rows; - } - - public void setRows(List rows) { - this.rows = rows; - } -} +package top.kuanghua.khcomomon.entity; + +import java.util.List; + +/** + * 分页结果类 + */ +public class PageResult { + + private Long total;//总记录数 + private List rows;//记录 + + public PageResult(Long total, List rows) { + this.total = total; + this.rows = rows; + } + + public PageResult() { + } + + public Long getTotal() { + return total; + } + + public void setTotal(Long total) { + this.total = total; + } + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } +} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/ResResult.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/ResResult.java index f6686a7..082ab6a 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/ResResult.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/ResResult.java @@ -1,65 +1,65 @@ -package top.kuanghua.khcomomon.entity; - -import lombok.AllArgsConstructor; -import lombok.Data; - -import java.io.Serializable; - -/** - * 描述 - * - * @author kuanghua - * @version 1.0 - * @package entity * - * @since 1.0 - */ -@Data -@AllArgsConstructor -public class ResResult implements Serializable { - private static final long serialVersionUID = 2344775856369318037L; - private boolean flag;//是否成功 - private Integer code;//返回码 - private String msg;//返回消息 - private T data;//返回数据 - - public ResResult success(Object data) { - this.flag = true; - this.code = StatusCode.OK; - this.data = (T) data; - return this; - } - - public ResResult success() { - this.flag = true; - this.code = StatusCode.OK; - this.msg = "操作成功!"; - return this; - } - - public ResResult error(String msg) { - this.flag = false; - this.code = StatusCode.ERROR; - this.msg = msg; - return this; - } - - public ResResult(String msg, Object data) { - this.flag = true; - this.code = StatusCode.OK; - this.msg = msg; - this.data = (T) data; - } - - public ResResult(boolean flag, Integer code, String msg) { - this.flag = flag; - this.code = code; - this.msg = msg; - } - - public ResResult() { - this.flag = true; - this.code = StatusCode.OK; - this.msg = "操作成功!"; - } - -} +package top.kuanghua.khcomomon.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.io.Serializable; + +/** + * 描述 + * + * @author kuanghua + * @version 1.0 + * @package entity * + * @since 1.0 + */ +@Data +@AllArgsConstructor +public class ResResult implements Serializable { + private static final long serialVersionUID = 2344775856369318037L; + private boolean flag;//是否成功 + private Integer code;//返回码 + private String msg;//返回消息 + private T data;//返回数据 + + public ResResult success(Object data) { + this.flag = true; + this.code = StatusCode.OK; + this.data = (T) data; + return this; + } + + public ResResult success() { + this.flag = true; + this.code = StatusCode.OK; + this.msg = "操作成功!"; + return this; + } + + public ResResult error(String msg) { + this.flag = false; + this.code = StatusCode.ERROR; + this.msg = msg; + return this; + } + + public ResResult(String msg, Object data) { + this.flag = true; + this.code = StatusCode.OK; + this.msg = msg; + this.data = (T) data; + } + + public ResResult(boolean flag, Integer code, String msg) { + this.flag = flag; + this.code = code; + this.msg = msg; + } + + public ResResult() { + this.flag = true; + this.code = StatusCode.OK; + this.msg = "操作成功!"; + } + +} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/Result.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/Result.java index c3a3dab..62ddcc2 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/Result.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/Result.java @@ -1,69 +1,69 @@ -package top.kuanghua.khcomomon.entity; - -import java.io.Serializable; - -/** - * 描述 - * - * @author 三国的包子 - * @version 1.0 - * @package entity * - * @since 1.0 - */ -public class Result implements Serializable { - private boolean flag;//是否成功 - private Integer code;//返回码 - private String msg;//返回消息 - private T data;//返回数据 - - public Result(boolean flag, Integer code, String msg, Object data) { - this.flag = flag; - this.code = code; - this.msg = msg; - this.data = (T) data; - } - - public Result(boolean flag, Integer code, String msg) { - this.flag = flag; - this.code = code; - this.msg = msg; - } - - public Result() { - this.flag = true; - this.code = StatusCode.OK; - this.msg = "操作成功!"; - } - - public boolean isFlag() { - return flag; - } - - public void setFlag(boolean flag) { - this.flag = flag; - } - - public Integer getCode() { - return code; - } - - public void setCode(Integer code) { - this.code = code; - } - - public String getMessage() { - return msg; - } - - public void setMessage(String msg) { - this.msg = msg; - } - - public T getData() { - return data; - } - - public void setData(T data) { - this.data = data; - } -} +package top.kuanghua.khcomomon.entity; + +import java.io.Serializable; + +/** + * 描述 + * + * @author 三国的包子 + * @version 1.0 + * @package entity * + * @since 1.0 + */ +public class Result implements Serializable { + private boolean flag;//是否成功 + private Integer code;//返回码 + private String msg;//返回消息 + private T data;//返回数据 + + public Result(boolean flag, Integer code, String msg, Object data) { + this.flag = flag; + this.code = code; + this.msg = msg; + this.data = (T) data; + } + + public Result(boolean flag, Integer code, String msg) { + this.flag = flag; + this.code = code; + this.msg = msg; + } + + public Result() { + this.flag = true; + this.code = StatusCode.OK; + this.msg = "操作成功!"; + } + + public boolean isFlag() { + return flag; + } + + public void setFlag(boolean flag) { + this.flag = flag; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public String getMessage() { + return msg; + } + + public void setMessage(String msg) { + this.msg = msg; + } + + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } +} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/StatusCode.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/StatusCode.java index 50a103e..587a48f 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/StatusCode.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/StatusCode.java @@ -1,14 +1,14 @@ -package top.kuanghua.khcomomon.entity; - -/** - * 返回码 - */ -public class StatusCode { - public static final int OK = 20000;//成功 - public static final int ERROR = 20001;//失败 - public static final int LOGINERROR = 20002;//用户名或密码错误 - public static final int ACCESSERROR = 20003;//权限不足 - public static final int REMOTEERROR = 20004;//远程调用失败 - public static final int REPERROR = 20005;//重复操作 - public static final int NOTFOUNDERROR = 20006;//没有对应的抢购数据 -} +package top.kuanghua.khcomomon.entity; + +/** + * 返回码 + */ +public class StatusCode { + public static final int OK = 20000;//成功 + public static final int ERROR = 20001;//失败 + public static final int LOGINERROR = 20002;//用户名或密码错误 + public static final int ACCESSERROR = 20003;//权限不足 + public static final int REMOTEERROR = 20004;//远程调用失败 + public static final int REPERROR = 20005;//重复操作 + public static final int NOTFOUNDERROR = 20006;//没有对应的抢购数据 +} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/exception/BaseExceptionHandler.java b/ty-common/src/main/java/top/kuanghua/khcomomon/exception/BaseExceptionHandler.java index a32852e..da5ad7c 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/exception/BaseExceptionHandler.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/exception/BaseExceptionHandler.java @@ -1,29 +1,29 @@ -package top.kuanghua.khcomomon.exception; - -import org.springframework.validation.ObjectError; -import org.springframework.web.bind.MethodArgumentNotValidException; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.RestControllerAdvice; -import top.kuanghua.khcomomon.entity.ResResult; - -/* -* 全局异常处理 -* */ -@RestControllerAdvice -public class BaseExceptionHandler { - /*** - * 异常处理 - * @param: - * @return - */ - @ExceptionHandler(MethodArgumentNotValidException.class) - public ResResult MethodArgumentNotValidExceptionHandler(MethodArgumentNotValidException e) { - ObjectError objectError = e.getBindingResult().getAllErrors().get(0); - return new ResResult().error(objectError.getDefaultMessage()); - } - @ExceptionHandler(value = Exception.class) - public ResResult error(Exception e) { - e.printStackTrace(); - return new ResResult().error(e.getMessage()); - } +package top.kuanghua.khcomomon.exception; + +import org.springframework.validation.ObjectError; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import top.kuanghua.khcomomon.entity.ResResult; + +/* +* 全局异常处理 +* */ +@RestControllerAdvice +public class BaseExceptionHandler { + /*** + * 异常处理 + * @param: + * @return + */ + @ExceptionHandler(MethodArgumentNotValidException.class) + public ResResult MethodArgumentNotValidExceptionHandler(MethodArgumentNotValidException e) { + ObjectError objectError = e.getBindingResult().getAllErrors().get(0); + return new ResResult().error(objectError.getDefaultMessage()); + } + @ExceptionHandler(value = Exception.class) + public ResResult error(Exception e) { + e.printStackTrace(); + return new ResResult().error(e.getMessage()); + } } \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ChineseUtils.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ChineseUtils.java index 48f83b7..15036ed 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ChineseUtils.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ChineseUtils.java @@ -1,65 +1,65 @@ -package top.kuanghua.khcomomon.utils; - -import java.io.UnsupportedEncodingException; -import java.util.Random; - -/*** - * - * @Author:kuanghua - * - ****/ -public class ChineseUtils { - - private static Random random = null; - - private static Random getRandomInstance() { - if (random == null) { - random = new Random(System.currentTimeMillis()); - } - return random; - } - - public static String getChinese() { - String str = null; - int highPos, lowPos; - Random random = getRandomInstance(); - highPos = (176 + Math.abs(random.nextInt(39))); - lowPos = 161 + Math.abs(random.nextInt(93)); - byte[] b = new byte[2]; - b[0] = (new Integer(highPos)).byteValue(); - b[1] = (new Integer(lowPos)).byteValue(); - try { - str = new String(b, "GB2312"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - return str; - } - - public static String getFixedLengthChinese(int length) { - String str = ""; - for (int i = length; i > 0; i--) { - str = str + ChineseUtils.getChinese(); - } - return str; - } - - public static String getRandomLengthChiness(int start, int end) { - String str = ""; - int length = new Random().nextInt(end + 1); - if (length < start) { - str = getRandomLengthChiness(start, end); - } else { - for (int i = 0; i < length; i++) { - str = str + getChinese(); - } - } - return str; - } - - public static void main(String args[]) { -// System.out.println(ChineseUtils.getChinese()); -// System.out.println(ChineseUtils.getFixedLengthChinese(20)); -// System.out.println(ChineseUtils.getRandomLengthChiness(2, 5)); - } -} +package top.kuanghua.khcomomon.utils; + +import java.io.UnsupportedEncodingException; +import java.util.Random; + +/*** + * + * @Author:kuanghua + * + ****/ +public class ChineseUtils { + + private static Random random = null; + + private static Random getRandomInstance() { + if (random == null) { + random = new Random(System.currentTimeMillis()); + } + return random; + } + + public static String getChinese() { + String str = null; + int highPos, lowPos; + Random random = getRandomInstance(); + highPos = (176 + Math.abs(random.nextInt(39))); + lowPos = 161 + Math.abs(random.nextInt(93)); + byte[] b = new byte[2]; + b[0] = (new Integer(highPos)).byteValue(); + b[1] = (new Integer(lowPos)).byteValue(); + try { + str = new String(b, "GB2312"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return str; + } + + public static String getFixedLengthChinese(int length) { + String str = ""; + for (int i = length; i > 0; i--) { + str = str + ChineseUtils.getChinese(); + } + return str; + } + + public static String getRandomLengthChiness(int start, int end) { + String str = ""; + int length = new Random().nextInt(end + 1); + if (length < start) { + str = getRandomLengthChiness(start, end); + } else { + for (int i = 0; i < length; i++) { + str = str + getChinese(); + } + } + return str; + } + + public static void main(String args[]) { +// System.out.println(ChineseUtils.getChinese()); +// System.out.println(ChineseUtils.getFixedLengthChinese(20)); +// System.out.println(ChineseUtils.getRandomLengthChiness(2, 5)); + } +} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/DateUtilSelf.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/DateUtilSelf.java index 5b67b39..8d0c2de 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/DateUtilSelf.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/DateUtilSelf.java @@ -1,164 +1,164 @@ -package top.kuanghua.khcomomon.utils; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.*; - -/*** - * @Description: 时间操作工具类 - * @Author:kuanghua - ****/ -public class DateUtilSelf { - - //时间格式 - public static final String PATTERN_YYYYMMDDHH = "yyyyMMddHH"; - public static final String PATTERN_YYYY_MM_DDHHMM = "yyyy-MM-dd HH:mm"; - /*** - * 从yyyy-MM-dd HH:mm格式转成yyyyMMddHH格式 - * @param dateStr - * @return - */ - public static String formatStr(String dateStr,String opattern,String npattern){ - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(opattern); - try { - Date date = simpleDateFormat.parse(dateStr); - simpleDateFormat = new SimpleDateFormat(npattern); - return simpleDateFormat.format(date); - } catch (ParseException e) { - e.printStackTrace(); - } - return null; - } - - /*获取当前时间*/ - public static String getCurrentTime(){ - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); - String format = simpleDateFormat.format(new Date()); - return format; - } - - /*** - * 获取指定日期的凌晨 - * @return - */ - public static Date toDayStartHour(Date date){ - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - calendar.set(Calendar.MILLISECOND, 0); - Date start = calendar.getTime(); - return start; - } - - - /*** - * 时间增加N分钟 - * @param date - * @param minutes - * @return - */ - public static Date addDateMinutes(Date date,int minutes){ - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - calendar.add(Calendar.MINUTE, minutes);// 24小时制 - date = calendar.getTime(); - return date; - } - - /*** - * 时间递增N小时 - * @param hour - * @return - */ - public static Date addDateHour(Date date,int hour){//Jota-time - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - calendar.add(Calendar.HOUR, hour);// 24小时制 - date = calendar.getTime(); - return date; - } - - /*** - * 获取时间菜单 - * @return - */ - public static List getDateMenus(){ - //定义一个List集合,存储所有时间段 - List dates = getDates(12); - //判断当前时间属于哪个时间范围 - Date now = new Date(); - for (Date cdate : dates) { - //开始时间<=当前时间<开始时间+2小时 - if(cdate.getTime()<=now.getTime() && now.getTime() dateMenus = new ArrayList(); - for (int i = 0; i <5 ; i++) { - dateMenus.add(addDateHour(now,i*2)); - } - return dateMenus; - } - - /*** - * 指定时间往后N个时间间隔 - * @param hours - * @return - */ - public static List getDates(int hours) { - List dates = new ArrayList(); - //循环12次 - Date date = toDayStartHour(new Date()); //凌晨 - for (int i = 0; i 集合中 - dates.add(addDateHour(date,i*2)); - } - return dates; - } - - /*** - * 时间转换(yyyyMMddHH) - * @param date - * @param pattern - * @return - */ - public static String data2str(Date date, String pattern){ - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); - return simpleDateFormat.format(date); - } - - - /** - * 计算时间差 - * @param startTime - * @param endTime - * @param format - * @return 两个时间的差(小时,分钟等) - * @throws ParseException - */ - public static HashMap dateDiff(String startTime, String endTime, String format) throws ParseException { - //按照dao传入的格式生成一个simpledateformate对象 - SimpleDateFormat sd = new SimpleDateFormat(format); - long nd = 1000 * 24 * 60 * 60;//一天的毫秒数 - long nh = 1000 * 60 * 60;//一小时的毫秒数 - long nm = 1000 * 60;//一分钟的毫秒数 - long ns = 1000;//一秒钟的毫秒数long diff;try { - //获得两个时间的毫秒时间差异 - long diff = sd.parse(endTime).getTime() - sd.parse(startTime).getTime(); - long day = diff / nd;//计算差多少天 - long hour = diff % nd / nh;//计算差多少小时 - long min = diff % nd % nh / nm;//计算差多少分钟 - long sec = diff % nd % nh % nm / ns;//计算差多少秒//输出结果 - HashMap map = new HashMap<>(); - map.put("day",day); - map.put("hour",hour); - map.put("min",min>=10?min:'0'+min); - map.put("sec",sec); - return map; - } -} +package top.kuanghua.khcomomon.utils; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +/*** + * @Description: 时间操作工具类 + * @Author:kuanghua + ****/ +public class DateUtilSelf { + + //时间格式 + public static final String PATTERN_YYYYMMDDHH = "yyyyMMddHH"; + public static final String PATTERN_YYYY_MM_DDHHMM = "yyyy-MM-dd HH:mm"; + /*** + * 从yyyy-MM-dd HH:mm格式转成yyyyMMddHH格式 + * @param dateStr + * @return + */ + public static String formatStr(String dateStr,String opattern,String npattern){ + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(opattern); + try { + Date date = simpleDateFormat.parse(dateStr); + simpleDateFormat = new SimpleDateFormat(npattern); + return simpleDateFormat.format(date); + } catch (ParseException e) { + e.printStackTrace(); + } + return null; + } + + /*获取当前时间*/ + public static String getCurrentTime(){ + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + String format = simpleDateFormat.format(new Date()); + return format; + } + + /*** + * 获取指定日期的凌晨 + * @return + */ + public static Date toDayStartHour(Date date){ + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + Date start = calendar.getTime(); + return start; + } + + + /*** + * 时间增加N分钟 + * @param date + * @param minutes + * @return + */ + public static Date addDateMinutes(Date date,int minutes){ + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.MINUTE, minutes);// 24小时制 + date = calendar.getTime(); + return date; + } + + /*** + * 时间递增N小时 + * @param hour + * @return + */ + public static Date addDateHour(Date date,int hour){//Jota-time + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.HOUR, hour);// 24小时制 + date = calendar.getTime(); + return date; + } + + /*** + * 获取时间菜单 + * @return + */ + public static List getDateMenus(){ + //定义一个List集合,存储所有时间段 + List dates = getDates(12); + //判断当前时间属于哪个时间范围 + Date now = new Date(); + for (Date cdate : dates) { + //开始时间<=当前时间<开始时间+2小时 + if(cdate.getTime()<=now.getTime() && now.getTime() dateMenus = new ArrayList(); + for (int i = 0; i <5 ; i++) { + dateMenus.add(addDateHour(now,i*2)); + } + return dateMenus; + } + + /*** + * 指定时间往后N个时间间隔 + * @param hours + * @return + */ + public static List getDates(int hours) { + List dates = new ArrayList(); + //循环12次 + Date date = toDayStartHour(new Date()); //凌晨 + for (int i = 0; i 集合中 + dates.add(addDateHour(date,i*2)); + } + return dates; + } + + /*** + * 时间转换(yyyyMMddHH) + * @param date + * @param pattern + * @return + */ + public static String data2str(Date date, String pattern){ + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); + return simpleDateFormat.format(date); + } + + + /** + * 计算时间差 + * @param startTime + * @param endTime + * @param format + * @return 两个时间的差(小时,分钟等) + * @throws ParseException + */ + public static HashMap dateDiff(String startTime, String endTime, String format) throws ParseException { + //按照dao传入的格式生成一个simpledateformate对象 + SimpleDateFormat sd = new SimpleDateFormat(format); + long nd = 1000 * 24 * 60 * 60;//一天的毫秒数 + long nh = 1000 * 60 * 60;//一小时的毫秒数 + long nm = 1000 * 60;//一分钟的毫秒数 + long ns = 1000;//一秒钟的毫秒数long diff;try { + //获得两个时间的毫秒时间差异 + long diff = sd.parse(endTime).getTime() - sd.parse(startTime).getTime(); + long day = diff / nd;//计算差多少天 + long hour = diff % nd / nh;//计算差多少小时 + long min = diff % nd % nh / nm;//计算差多少分钟 + long sec = diff % nd % nh % nm / ns;//计算差多少秒//输出结果 + HashMap map = new HashMap<>(); + map.put("day",day); + map.put("hour",hour); + map.put("min",min>=10?min:'0'+min); + map.put("sec",sec); + return map; + } +} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/JwtUtil.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/JwtUtil.java index 423307d..ff2f3f7 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/JwtUtil.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/JwtUtil.java @@ -1,104 +1,104 @@ -package top.kuanghua.khcomomon.utils; - -import io.jsonwebtoken.Claims; -import io.jsonwebtoken.JwtBuilder; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; - -import javax.crypto.SecretKey; -import javax.crypto.spec.SecretKeySpec; -import java.util.Base64; -import java.util.Date; -import java.util.*; - -/** - * 描述 - * - * @author kuanghua - * @version 1.0 - * @package entity * - * @since 1.0 - */ -public class JwtUtil { - //有效期为 - public static final Long JWT_TTL = 3600000L;// 60 * 60 *1000 一个小时 - - //Jwt令牌信息 - public static final String JWT_KEY = "@Kuanghua8866"; - - /** - * 生成令牌 - //* @param id - //* @param subject - * @param ttlMillis - * @return - */ - public static String createJWT(Map userInfo, Long ttlMillis) { - //指定算法 - SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; - //当前系统时间 - long nowMillis = System.currentTimeMillis(); - //令牌签发时间 - Date now = new Date(nowMillis); - //如果令牌有效期为null,则默认设置有效期1小时 - if (ttlMillis == null) { - ttlMillis = JwtUtil.JWT_TTL; - } - //令牌过期时间设置 - long expMillis = nowMillis + ttlMillis; - Date expDate = new Date(expMillis); - - //生成秘钥 - SecretKey secretKey = generalKey(); - - //封装Jwt令牌信息 - JwtBuilder builder = Jwts.builder() - //.setId(id) - //.setSubject(subject) // 主题 可以是JSON数据 - //.setIssuer("admin") // 签发者 - .setIssuedAt(now) // 签发时间 - .signWith(signatureAlgorithm, secretKey) // 签名算法以及密匙 - .setExpiration(expDate); // 设置过期时间 - - JwtBuilder jwtBuilder = builder.addClaims(userInfo); - return builder.compact(); - } - - /** - * 生成加密 secretKey - * - * @return - */ - public static SecretKey generalKey() { - byte[] encodedKey = Base64.getEncoder().encode(JwtUtil.JWT_KEY.getBytes()); - SecretKey key = new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES"); - return key; - } - - /** - * 解析令牌数据 - * - * @param jwt - * @return - * @throws Exception - */ - public static Claims parseJWT(String jwt) throws Exception { - SecretKey secretKey = generalKey(); - return Jwts.parser() - .setSigningKey(secretKey) - .parseClaimsJws(jwt) - .getBody(); - } -// public static void main(String[] args) { -// String jwt = JwtUtil.createJWT("weiyibiaoshi", ) -// System.out.println(jwt); -// try { -// Claims claims = JwtUtil.parseJWT(jwt); -// System.out.println(claims); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// -// -// } -} +package top.kuanghua.khcomomon.utils; + +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.JwtBuilder; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; + +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import java.util.Base64; +import java.util.Date; +import java.util.Map; + +/** + * 描述 + * + * @author kuanghua + * @version 1.0 + * @package entity * + * @since 1.0 + */ +public class JwtUtil { + //有效期为 + public static final Long JWT_TTL = 3600000L;// 60 * 60 *1000 一个小时 + + //Jwt令牌信息 + public static final String JWT_KEY = "@Kuanghua8866"; + + /** + * 生成令牌 + //* @param id + //* @param subject + * @param ttlMillis + * @return + */ + public static String createJWT(Map userInfo, Long ttlMillis) { + //指定算法 + SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; + //当前系统时间 + long nowMillis = System.currentTimeMillis(); + //令牌签发时间 + Date now = new Date(nowMillis); + //如果令牌有效期为null,则默认设置有效期1小时 + if (ttlMillis == null) { + ttlMillis = JwtUtil.JWT_TTL; + } + //令牌过期时间设置 + long expMillis = nowMillis + ttlMillis; + Date expDate = new Date(expMillis); + + //生成秘钥 + SecretKey secretKey = generalKey(); + + //封装Jwt令牌信息 + JwtBuilder builder = Jwts.builder() + //.setId(id) + //.setSubject(subject) // 主题 可以是JSON数据 + //.setIssuer("admin") // 签发者 + .setIssuedAt(now) // 签发时间 + .signWith(signatureAlgorithm, secretKey) // 签名算法以及密匙 + .setExpiration(expDate); // 设置过期时间 + + JwtBuilder jwtBuilder = builder.addClaims(userInfo); + return builder.compact(); + } + + /** + * 生成加密 secretKey + * + * @return + */ + public static SecretKey generalKey() { + byte[] encodedKey = Base64.getEncoder().encode(JwtUtil.JWT_KEY.getBytes()); + SecretKey key = new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES"); + return key; + } + + /** + * 解析令牌数据 + * + * @param jwt + * @return + * @throws Exception + */ + public static Claims parseJWT(String jwt) throws Exception { + SecretKey secretKey = generalKey(); + return Jwts.parser() + .setSigningKey(secretKey) + .parseClaimsJws(jwt) + .getBody(); + } +// public static void main(String[] args) { +// String jwt = JwtUtil.createJWT("weiyibiaoshi", ) +// System.out.println(jwt); +// try { +// Claims claims = JwtUtil.parseJWT(jwt); +// System.out.println(claims); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// +// } +} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RandomValueUtil.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RandomValueUtil.java index 5d51c90..d35f22d 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RandomValueUtil.java +++ b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RandomValueUtil.java @@ -1,126 +1,126 @@ -package top.kuanghua.khcomomon.utils; - -/*** - * - * @Author:kuanghua - * - ****/ -public class RandomValueUtil { - public static String base = "abcdefghijklmnopqrstuvwxyz0123456789"; - private static String firstName="赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卞齐康伍余元卜顾孟平黄和穆萧尹姚邵湛汪祁毛禹狄米贝明臧计伏成戴谈宋茅庞熊纪舒屈项祝董梁杜阮蓝闵席季麻强贾路娄危江童颜郭梅盛林刁钟徐邱骆高夏蔡田樊胡凌霍虞万支柯咎管卢莫经房裘缪干解应宗宣丁贲邓郁单杭洪包诸左石崔吉钮龚程嵇邢滑裴陆荣翁荀羊於惠甄魏加封芮羿储靳汲邴糜松井段富巫乌焦巴弓牧隗山谷车侯宓蓬全郗班仰秋仲伊宫宁仇栾暴甘钭厉戎祖武符刘姜詹束龙叶幸司韶郜黎蓟薄印宿白怀蒲台从鄂索咸籍赖卓蔺屠蒙池乔阴郁胥能苍双闻莘党翟谭贡劳逄姬申扶堵冉宰郦雍却璩桑桂濮牛寿通边扈燕冀郏浦尚农温别庄晏柴瞿阎充慕连茹习宦艾鱼容向古易慎戈廖庚终暨居衡步都耿满弘匡国文寇广禄阙东殴殳沃利蔚越夔隆师巩厍聂晁勾敖融冷訾辛阚那简饶空曾毋沙乜养鞠须丰巢关蒯相查后江红游竺权逯盖益桓公万俟司马上官欧阳夏侯诸葛闻人东方赫连皇甫尉迟公羊澹台公冶宗政濮阳淳于仲孙太叔申屠公孙乐正轩辕令狐钟离闾丘长孙慕容鲜于宇文司徒司空亓官司寇仉督子车颛孙端木巫马公西漆雕乐正壤驷公良拓拔夹谷宰父谷粱晋楚阎法汝鄢涂钦段干百里东郭南门呼延归海羊舌微生岳帅缑亢况后有琴梁丘左丘东门西门商牟佘佴伯赏南宫墨哈谯笪年爱阳佟第五言福百家姓续"; - private static String girl="秀娟英华慧巧美娜静淑惠珠翠雅芝玉萍红娥玲芬芳燕彩春菊兰凤洁梅琳素云莲真环雪荣爱妹霞香月莺媛艳瑞凡佳嘉琼勤珍贞莉桂娣叶璧璐娅琦晶妍茜秋珊莎锦黛青倩婷姣婉娴瑾颖露瑶怡婵雁蓓纨仪荷丹蓉眉君琴蕊薇菁梦岚苑婕馨瑗琰韵融园艺咏卿聪澜纯毓悦昭冰爽琬茗羽希宁欣飘育滢馥筠柔竹霭凝晓欢霄枫芸菲寒伊亚宜可姬舒影荔枝思丽 "; - public static String boy="伟刚勇毅俊峰强军平保东文辉力明永健世广志义兴良海山仁波宁贵福生龙元全国胜学祥才发武新利清飞彬富顺信子杰涛昌成康星光天达安岩中茂进林有坚和彪博诚先敬震振壮会思群豪心邦承乐绍功松善厚庆磊民友裕河哲江超浩亮政谦亨奇固之轮翰朗伯宏言若鸣朋斌梁栋维启克伦翔旭鹏泽晨辰士以建家致树炎德行时泰盛雄琛钧冠策腾楠榕风航弘"; - public static final String[] email_suffix="@gmail.com,@yahoo.com,@msn.com,@hotmail.com,@aol.com,@ask.com,@live.com,@qq.com,@0355.net,@163.com,@163.net,@263.net,@3721.net,@yeah.net,@googlemail.com,@126.com,@sina.com,@sohu.com,@yahoo.com.cn".split(","); - - public static int getNum(int start,int end) { - return (int)(Math.random()*(end-start+1)+start); - } - - /*** - * - * Project Name: recruit-helper-util - *

随机生成Email - * - * @author youqiang.xiong - * @date 2018年5月23日 下午2:13:06 - * @version v1.0 - * @since - * @param lMin - * 最小长度 - * @param lMax - * 最大长度 - * @return - */ - public static String getEmail(int lMin,int lMax) { - int length=getNum(lMin,lMax); - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < length; i++) { - int number = (int)(Math.random()*base.length()); - sb.append(base.charAt(number)); - } - sb.append(email_suffix[(int)(Math.random()*email_suffix.length)]); - return sb.toString(); - } - - private static String[] telFirst="134,135,136,137,138,139,150,151,152,157,158,159,130,131,132,155,156,133,153".split(","); - - /*** - * - * Project Name: recruit-helper-util - *

随机生成手机号码 - * - * @author youqiang.xiong - * @date 2018年5月23日 下午2:14:17 - * @version v1.0 - * @since - * @return - */ - public static String getTelephone() { - int index=getNum(0,telFirst.length-1); - String first=telFirst[index]; - String second=String.valueOf(getNum(1,888)+10000).substring(1); - String thrid=String.valueOf(getNum(1,9100)+10000).substring(1); - return first+second+thrid; - } - - /*** - * - * Project Name: recruit-helper-util - *

随机生成8位电话号码 - * - * @author youqiang.xiong - * @date 2018年5月23日 下午2:15:31 - * @version v1.0 - * @since - * @return - */ - public static String getLandline() { - int index=getNum(0,telFirst.length-1); - String first=telFirst[index]; - String second=String.valueOf(getNum(1,888)+10000).substring(1); - String thrid=String.valueOf(getNum(1,9100)+10000).substring(1); - return first+second+thrid; - } - - - - /** - * 返回中文姓名 - */ - public static String name_sex = ""; - - /*** - * - * Project Name: recruit-helper-util - *

返回中文姓名 - * - * @author youqiang.xiong - * @date 2018年5月23日 下午2:16:16 - * @version v1.0 - * @since - * @return - */ - public static String getChineseName() { - int index = getNum(0, firstName.length() - 1); - String first = firstName.substring(index, index + 1); - int sex = getNum(0, 1); - String str = boy; - int length = boy.length(); - if (sex == 0) { - str = girl; - length = girl.length(); - name_sex = "女"; - } else { - name_sex = "男"; - } - index = getNum(0, length - 1); - String second = str.substring(index, index + 1); - int hasThird = getNum(0, 1); - String third = ""; - if (hasThird == 1) { - index = getNum(0, length - 1); - third = str.substring(index, index + 1); - } - return first + second + third; - } -} +package top.kuanghua.khcomomon.utils; + +/*** + * + * @Author:kuanghua + * + ****/ +public class RandomValueUtil { + public static String base = "abcdefghijklmnopqrstuvwxyz0123456789"; + private static String firstName="赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卞齐康伍余元卜顾孟平黄和穆萧尹姚邵湛汪祁毛禹狄米贝明臧计伏成戴谈宋茅庞熊纪舒屈项祝董梁杜阮蓝闵席季麻强贾路娄危江童颜郭梅盛林刁钟徐邱骆高夏蔡田樊胡凌霍虞万支柯咎管卢莫经房裘缪干解应宗宣丁贲邓郁单杭洪包诸左石崔吉钮龚程嵇邢滑裴陆荣翁荀羊於惠甄魏加封芮羿储靳汲邴糜松井段富巫乌焦巴弓牧隗山谷车侯宓蓬全郗班仰秋仲伊宫宁仇栾暴甘钭厉戎祖武符刘姜詹束龙叶幸司韶郜黎蓟薄印宿白怀蒲台从鄂索咸籍赖卓蔺屠蒙池乔阴郁胥能苍双闻莘党翟谭贡劳逄姬申扶堵冉宰郦雍却璩桑桂濮牛寿通边扈燕冀郏浦尚农温别庄晏柴瞿阎充慕连茹习宦艾鱼容向古易慎戈廖庚终暨居衡步都耿满弘匡国文寇广禄阙东殴殳沃利蔚越夔隆师巩厍聂晁勾敖融冷訾辛阚那简饶空曾毋沙乜养鞠须丰巢关蒯相查后江红游竺权逯盖益桓公万俟司马上官欧阳夏侯诸葛闻人东方赫连皇甫尉迟公羊澹台公冶宗政濮阳淳于仲孙太叔申屠公孙乐正轩辕令狐钟离闾丘长孙慕容鲜于宇文司徒司空亓官司寇仉督子车颛孙端木巫马公西漆雕乐正壤驷公良拓拔夹谷宰父谷粱晋楚阎法汝鄢涂钦段干百里东郭南门呼延归海羊舌微生岳帅缑亢况后有琴梁丘左丘东门西门商牟佘佴伯赏南宫墨哈谯笪年爱阳佟第五言福百家姓续"; + private static String girl="秀娟英华慧巧美娜静淑惠珠翠雅芝玉萍红娥玲芬芳燕彩春菊兰凤洁梅琳素云莲真环雪荣爱妹霞香月莺媛艳瑞凡佳嘉琼勤珍贞莉桂娣叶璧璐娅琦晶妍茜秋珊莎锦黛青倩婷姣婉娴瑾颖露瑶怡婵雁蓓纨仪荷丹蓉眉君琴蕊薇菁梦岚苑婕馨瑗琰韵融园艺咏卿聪澜纯毓悦昭冰爽琬茗羽希宁欣飘育滢馥筠柔竹霭凝晓欢霄枫芸菲寒伊亚宜可姬舒影荔枝思丽 "; + public static String boy="伟刚勇毅俊峰强军平保东文辉力明永健世广志义兴良海山仁波宁贵福生龙元全国胜学祥才发武新利清飞彬富顺信子杰涛昌成康星光天达安岩中茂进林有坚和彪博诚先敬震振壮会思群豪心邦承乐绍功松善厚庆磊民友裕河哲江超浩亮政谦亨奇固之轮翰朗伯宏言若鸣朋斌梁栋维启克伦翔旭鹏泽晨辰士以建家致树炎德行时泰盛雄琛钧冠策腾楠榕风航弘"; + public static final String[] email_suffix="@gmail.com,@yahoo.com,@msn.com,@hotmail.com,@aol.com,@ask.com,@live.com,@qq.com,@0355.net,@163.com,@163.net,@263.net,@3721.net,@yeah.net,@googlemail.com,@126.com,@sina.com,@sohu.com,@yahoo.com.cn".split(","); + + public static int getNum(int start,int end) { + return (int)(Math.random()*(end-start+1)+start); + } + + /*** + * + * Project Name: recruit-helper-util + *

随机生成Email + * + * @author youqiang.xiong + * @date 2018年5月23日 下午2:13:06 + * @version v1.0 + * @since + * @param lMin + * 最小长度 + * @param lMax + * 最大长度 + * @return + */ + public static String getEmail(int lMin,int lMax) { + int length=getNum(lMin,lMax); + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < length; i++) { + int number = (int)(Math.random()*base.length()); + sb.append(base.charAt(number)); + } + sb.append(email_suffix[(int)(Math.random()*email_suffix.length)]); + return sb.toString(); + } + + private static String[] telFirst="134,135,136,137,138,139,150,151,152,157,158,159,130,131,132,155,156,133,153".split(","); + + /*** + * + * Project Name: recruit-helper-util + *

随机生成手机号码 + * + * @author youqiang.xiong + * @date 2018年5月23日 下午2:14:17 + * @version v1.0 + * @since + * @return + */ + public static String getTelephone() { + int index=getNum(0,telFirst.length-1); + String first=telFirst[index]; + String second=String.valueOf(getNum(1,888)+10000).substring(1); + String thrid=String.valueOf(getNum(1,9100)+10000).substring(1); + return first+second+thrid; + } + + /*** + * + * Project Name: recruit-helper-util + *

随机生成8位电话号码 + * + * @author youqiang.xiong + * @date 2018年5月23日 下午2:15:31 + * @version v1.0 + * @since + * @return + */ + public static String getLandline() { + int index=getNum(0,telFirst.length-1); + String first=telFirst[index]; + String second=String.valueOf(getNum(1,888)+10000).substring(1); + String thrid=String.valueOf(getNum(1,9100)+10000).substring(1); + return first+second+thrid; + } + + + + /** + * 返回中文姓名 + */ + public static String name_sex = ""; + + /*** + * + * Project Name: recruit-helper-util + *

返回中文姓名 + * + * @author youqiang.xiong + * @date 2018年5月23日 下午2:16:16 + * @version v1.0 + * @since + * @return + */ + public static String getChineseName() { + int index = getNum(0, firstName.length() - 1); + String first = firstName.substring(index, index + 1); + int sex = getNum(0, 1); + String str = boy; + int length = boy.length(); + if (sex == 0) { + str = girl; + length = girl.length(); + name_sex = "女"; + } else { + name_sex = "男"; + } + index = getNum(0, length - 1); + String second = str.substring(index, index + 1); + int hasThird = getNum(0, 1); + String third = ""; + if (hasThird == 1) { + index = getNum(0, length - 1); + third = str.substring(index, index + 1); + } + return first + second + third; + } +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java b/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java index 4403c0f..bac5ac1 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java @@ -21,7 +21,7 @@ //mapper scanning @MapperScan(basePackages = {"top.kuanghua.tyexample.mapper"}) //feign scanning -@EnableFeignClients(basePackages = {"top.kuanghua.feign"}) +@EnableFeignClients(basePackages = {"top.kuanghua.feign.integrationfront", "top.kuanghua.feign.tyauth",}) public class BaseConfig { } diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java b/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java index e1e8d54..4c95ca9 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java @@ -37,13 +37,14 @@ public Docket api() { /** * 构建 api文档的详细信息函数 + * * @return */ private ApiInfo apiInfo() { return new ApiInfoBuilder() - .title("title:micro-service-plus") + .title("micro-service-pluss") .description("描述:新一代的微服务架构") - .contact(new Contact("jzfai", null, "869653722@qq.com")) + .contact(new Contact("kuanghua", null, "869653722@qq.com")) .version("版本号:2.9") .build(); } diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/GetTokenFromOtherService.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/GetTokenFromOtherService.java new file mode 100644 index 0000000..7403115 --- /dev/null +++ b/ty-example/src/main/java/top/kuanghua/tyexample/controller/GetTokenFromOtherService.java @@ -0,0 +1,35 @@ +package top.kuanghua.tyexample.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import top.kuanghua.feign.tyauth.feign.TestGetTokenFeign; +import top.kuanghua.khcomomon.entity.ResResult; + +import javax.annotation.Resource; + +/** + * @Title: GetTokenFromOtherService + * @Description: + * @Auther: kuanghua + * @create 2022-01-14 17:31 + */ +@RestController +@Api(tags = "feign转发请求头测试") +@RequestMapping("testFeign") +@Slf4j +public class GetTokenFromOtherService { + @Resource + private TestGetTokenFeign testGetTokenFeign; + + @ApiOperation(value = "上传图片或文件") + @PostMapping("getTokenFromService") + public void getTokenFromService() { + ResResult tokenInfo = testGetTokenFeign.getTokenInfo(); + log.info(tokenInfo.getData().toString()); + + } +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/RabbitDelayController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/RabbitDelayController.java index 8c4f6f0..a67d5f4 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/RabbitDelayController.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/controller/RabbitDelayController.java @@ -3,7 +3,6 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/SendEmailController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/SendEmailController.java index 7762880..afbb0f0 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/SendEmailController.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/controller/SendEmailController.java @@ -27,18 +27,18 @@ public class SendEmailController { @ApiOperation(value = "发送普通文本邮件") @GetMapping("sendEmailText") - public ResResult sendEmailText(@RequestParam(name = "subject",defaultValue = "这是主题") String subject, - @RequestParam(name = "text",defaultValue = "发送的文本(这是测试文本)") String text, - @RequestParam(name = "sendTo",defaultValue = "1319404169@qq.com") String sendTo) { + public ResResult sendEmailText(@RequestParam(name = "subject", defaultValue = "这是主题") String subject, + @RequestParam(name = "text", defaultValue = "发送的文本(这是测试文本)") String text, + @RequestParam(name = "sendTo", defaultValue = "1319404169@qq.com") String sendTo) { sendEmailService.sendEmailText(subject, text, sendTo); return new ResResult().success("发送邮件成功"); } @ApiOperation(value = "发送文本邮件(可以带附件)", notes = "可以带附件 ") @PostMapping("sendMimeMail") - public ResResult sendMimeMail(@RequestParam(name = "subject",defaultValue = "这是主题") String subject, - @RequestParam(name = "text",defaultValue = "发送的文本(这是测试文本)") String text, - @RequestParam(name = "sendTo",defaultValue = "1319404169@qq.com") String sendTo, + public ResResult sendMimeMail(@RequestParam(name = "subject", defaultValue = "这是主题") String subject, + @RequestParam(name = "text", defaultValue = "发送的文本(这是测试文本)") String text, + @RequestParam(name = "sendTo", defaultValue = "1319404169@qq.com") String sendTo, MultipartFile file) throws IOException, MessagingException, InterruptedException { if (file.getOriginalFilename().isEmpty()) { diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/SendMsgService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/SendMsgService.java index 2a00645..088f049 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/service/SendMsgService.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/service/SendMsgService.java @@ -26,15 +26,15 @@ public class SendMsgService { @Autowired private StringRedisTemplate stringRedisTemplate; - + public void sendMsg(String phone) { String code = NumberUtilsSelf.generateCode(6); Map smsMap = new HashMap(); - smsMap.put("phone",phone); - smsMap.put("code",code); - amqpTemplate.convertAndSend("kuanghua.sms.exchange", "sms.verify.code",smsMap); - stringRedisTemplate.opsForValue().set("user:code:phone:"+phone,code,60, TimeUnit.SECONDS); - log.info("发送短信的code"+code); + smsMap.put("phone", phone); + smsMap.put("code", code); + amqpTemplate.convertAndSend("kuanghua.sms.exchange", "sms.verify.code", smsMap); + stringRedisTemplate.opsForValue().set("user:code:phone:" + phone, code, 60, TimeUnit.SECONDS); + log.info("发送短信的code" + code); } } diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java index 6c04b9a..11ef1e9 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java @@ -44,8 +44,8 @@ public String upload(MultipartFile file) throws IOException { //检验文件内容 BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); if (bufferedImage == null) { - log.info("文件内容不合法:{}", originalFilename); - throw new RuntimeException("文件内容不合法"); + log.info("文件不能为空:{}", originalFilename); + throw new RuntimeException("文件不能为空"); } //保存到服务器 //file.transferTo(new File("D:\\java\\javaproject\\pinyou\\pinyou-upload\\src\\main\\resources\\static\\" + originalFilename)); diff --git a/ty-example/src/main/resources/application.yml b/ty-example/src/main/resources/application.yml index e69de29..0397283 100644 --- a/ty-example/src/main/resources/application.yml +++ b/ty-example/src/main/resources/application.yml @@ -0,0 +1,7 @@ +spring: + main: + allow-bean-definition-overriding: true + #解决查询时间和返回的时间不一致问题 + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 \ No newline at end of file diff --git a/ty-excel/pom.xml b/ty-excel/pom.xml deleted file mode 100644 index 83ad1ef..0000000 --- a/ty-excel/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - micro-service-plus - top.kuanghua - 1.0-SNAPSHOT - - 4.0.0 - ty-excel - - - - com.alibaba - easyexcel - 3.0.1 - - - top.kuanghua - ty-common - 1.0-SNAPSHOT - - - - - ${project.artifactId} - - - src/main/resources - - true - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.1 - - true - - - - - \ No newline at end of file diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/ExcelApplication.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/ExcelApplication.java deleted file mode 100644 index 900de90..0000000 --- a/ty-excel/src/main/java/top/kuanghua/tyexcel/ExcelApplication.java +++ /dev/null @@ -1,13 +0,0 @@ -package top.kuanghua.tyexcel; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; - -@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) -public class ExcelApplication { - public static void main(String[] args) { - SpringApplication.run(ExcelApplication.class,args); - } -} - diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/ComplexHeadData.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/ComplexHeadData.java deleted file mode 100644 index c216b31..0000000 --- a/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/ComplexHeadData.java +++ /dev/null @@ -1,16 +0,0 @@ -package top.kuanghua.tyexcel.bo; - -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -import java.util.Date; - -@Data -public class ComplexHeadData { - @ExcelProperty({"主标题", "字符串标题"}) - private String string; - @ExcelProperty({"主标题", "日期标题"}) - private Date date; - @ExcelProperty({"主标题", "数字标题"}) - private Double doubleData; -} \ No newline at end of file diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/CustomStringStringConverter.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/CustomStringStringConverter.java deleted file mode 100644 index 1b18c3c..0000000 --- a/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/CustomStringStringConverter.java +++ /dev/null @@ -1,15 +0,0 @@ -package top.kuanghua.tyexcel.bo; - -import com.alibaba.excel.converters.Converter; -import com.alibaba.excel.enums.CellDataTypeEnum; -import com.alibaba.excel.metadata.GlobalConfiguration; -import com.alibaba.excel.metadata.data.ReadCellData; -import com.alibaba.excel.metadata.property.ExcelContentProperty; - - -public class CustomStringStringConverter implements Converter { - @Override - public String convertToJavaData(ReadCellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { - return "自定义:" + cellData.getStringValue(); - } -} \ No newline at end of file diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/DemoData.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/DemoData.java deleted file mode 100644 index c047e4c..0000000 --- a/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/DemoData.java +++ /dev/null @@ -1,24 +0,0 @@ -package top.kuanghua.tyexcel.bo; - -import com.alibaba.excel.annotation.ExcelIgnore; -import com.alibaba.excel.annotation.ExcelProperty; -import com.alibaba.excel.annotation.format.DateTimeFormat; -import lombok.Data; - -import java.util.Date; - -@Data -public class DemoData { - @ExcelProperty("字符串标题") - private String string; - @ExcelProperty("日期标题") - @DateTimeFormat("yyyy年MM月dd日HH时mm分ss秒") - private Date date; - @ExcelProperty(value="数字标题",index = 3) - private Double doubleData; - /** - * 忽略这个字段 - */ - @ExcelIgnore - private String ignore; -} \ No newline at end of file diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/DemoExtraData.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/DemoExtraData.java deleted file mode 100644 index 40726ca..0000000 --- a/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/DemoExtraData.java +++ /dev/null @@ -1,11 +0,0 @@ -package top.kuanghua.tyexcel.bo; - -import lombok.Data; - -@Data -public class DemoExtraData { - - private String row1; - - private String row2; -} \ No newline at end of file diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/RuiDeKqBo.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/RuiDeKqBo.java deleted file mode 100644 index f0e6ba9..0000000 --- a/ty-excel/src/main/java/top/kuanghua/tyexcel/bo/RuiDeKqBo.java +++ /dev/null @@ -1,28 +0,0 @@ -package top.kuanghua.tyexcel.bo; - -import com.alibaba.excel.annotation.ExcelProperty; -import com.alibaba.excel.annotation.format.DateTimeFormat; -import lombok.Data; - -import java.util.Date; - -/** - * @Title: RuiDeKqBo - * @Description: - * @Auther: kuanghua - * @create 2021/7/9 10:27 - */ -@Data -public class RuiDeKqBo { - @ExcelProperty(value = "部门",converter = CustomStringStringConverter.class) - private String department; - @ExcelProperty("姓名") - private String username; - @ExcelProperty("日期") - @DateTimeFormat("yyyy年") - private Date dateTime; - @ExcelProperty("签到时间") - private String checkInTime; - private String row1; - private String row2; -} diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/config/BaseConfig.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/config/BaseConfig.java deleted file mode 100644 index db4a35f..0000000 --- a/ty-excel/src/main/java/top/kuanghua/tyexcel/config/BaseConfig.java +++ /dev/null @@ -1,25 +0,0 @@ -package top.kuanghua.tyexcel.config; - -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * @Title: BaseConfig - * @Description: - * @Auther: kuanghua - * @create 2020/8/23 21:52 - */ -/* - * 总结:1.@Configuration 下的@ComponentScan回将包下带有@Component扫描变成配置类, - * 而@SpringBootApplication扫描的只会变成普通类 - * */ -@Configuration -//扫描公用包的配置和自身的配置类 -@ComponentScan(basePackages = {"top.kuanghua.khcomomon","top.kuanghua.tyexcel"}) -//feign扫描 -//@EnableFeignClients(basePackages = {"top.kuanghua.feign.tyexecl","top.kuanghua.feign.tyauth"}) -//mapper包扫描 -//@MapperScan(basePackages = {"top.kuanghua.tyuser.mapper"}) -public class BaseConfig {} diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/config/Swagger2Config.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/config/Swagger2Config.java deleted file mode 100644 index cbccfd4..0000000 --- a/ty-excel/src/main/java/top/kuanghua/tyexcel/config/Swagger2Config.java +++ /dev/null @@ -1,56 +0,0 @@ -package top.kuanghua.tyexcel.config; - -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Component -@EnableSwagger2 //开启在线接口文档 -//配置包扫描 -public class Swagger2Config { - private boolean swagger_is_enable = true; -// @Value("${.ipAddr}") -// private String ipAddr; - @Value("${server.port}") - private String port; - - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .enable(swagger_is_enable) - //.host(this.ipAddr + ":" + this.port) - .apiInfo(apiInfo()) - .select() - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) - //.apis(basePackage("top.kuanghua.swagger.controller")) - .paths(PathSelectors.any()) - .build(); - } - - /** - * 构建 api文档的详细信息函数 - * - * @return - */ - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("标题:swagger文档") - .description("描述:新一代的微服务架构") - .contact(new Contact("jzfai", null, "869653722@qq.com")) - .version("版本号:2.8") - .build(); - } - - /** - * http://localhost:8080/swagger-ui.html - */ -} diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/controller/ExcelController.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/controller/ExcelController.java deleted file mode 100644 index 99e9669..0000000 --- a/ty-excel/src/main/java/top/kuanghua/tyexcel/controller/ExcelController.java +++ /dev/null @@ -1,81 +0,0 @@ -package top.kuanghua.tyexcel.controller; - -import com.alibaba.excel.EasyExcel; -import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; -import springfox.documentation.annotations.ApiIgnore; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; -import top.kuanghua.tyexcel.bo.ComplexHeadData; -import top.kuanghua.tyexcel.bo.DemoData; -import top.kuanghua.tyexcel.bo.RuiDeKqBo; -import top.kuanghua.tyexcel.service.ExcelService; -import top.kuanghua.tyexcel.vo.ExcelCheckResult; - - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; - -/** - * @Title: ExcelController - * @Description: - * @Auther: kuanghua - * @create 2021/7/9 11:37 - */ -@RestController -@RequestMapping("excel") -@Api(tags="文档导入相关") -@Slf4j -public class ExcelController { - - @Autowired - private ExcelService excelService; - - @ApiOperation("导入excel") - @PostMapping("importExcel") - public ResResult importExcel(@RequestParam("file") MultipartFile file) throws IOException { - ExcelCheckResult excelCheckResult = excelService.importExcel(file.getInputStream()); - return new ResResult().success(excelCheckResult); - } - - private List data() { - List list = new ArrayList(); - for (int i = 0; i < 10; i++) { - DemoData data = new DemoData(); - data.setString("字符串" + i); - data.setDate(new Date()); - data.setDoubleData(0.56); - list.add(data); - } - return list; - } - - @ApiOperation("导出excel") - @PostMapping("exportExcel") - public void exportExcel(HttpServletResponse response) throws IOException { - - // 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - response.setCharacterEncoding("utf-8"); - // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 - String fileName = URLEncoder.encode("测试", "UTF-8").replaceAll("\\+", "%20"); - response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); - EasyExcel.write(response.getOutputStream(), ComplexHeadData.class).sheet("模板").doWrite(data()); - -// excelService.exportExcel(); -// return new ResResult().success(); - } -} diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/service/DaoService.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/service/DaoService.java deleted file mode 100644 index 90805f7..0000000 --- a/ty-excel/src/main/java/top/kuanghua/tyexcel/service/DaoService.java +++ /dev/null @@ -1,36 +0,0 @@ -package top.kuanghua.tyexcel.service; - -import com.alibaba.excel.EasyExcel; -import com.alibaba.excel.context.AnalysisContext; -import com.alibaba.excel.enums.CellExtraTypeEnum; -import com.alibaba.excel.exception.ExcelDataConvertException; -import com.alibaba.excel.metadata.CellExtra; -import com.alibaba.excel.metadata.data.ReadCellData; -import com.alibaba.excel.read.listener.ReadListener; -import com.alibaba.fastjson.JSON; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import top.kuanghua.tyexcel.bo.RuiDeKqBo; - -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -; - -/** - * @Title: ExeclService - * @Description: - * @Auther: kuanghua - * @create 2021/7/9 11:35 - */ -@Service -@Slf4j -public class DaoService { - public void test(){ - log.info("testInfo"); - } - -} - diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/service/ExcelService.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/service/ExcelService.java deleted file mode 100644 index acfbf48..0000000 --- a/ty-excel/src/main/java/top/kuanghua/tyexcel/service/ExcelService.java +++ /dev/null @@ -1,158 +0,0 @@ -package top.kuanghua.tyexcel.service; - -import com.alibaba.excel.context.AnalysisContext; - -import com.alibaba.excel.enums.CellExtraTypeEnum; -import com.alibaba.excel.exception.ExcelDataConvertException; -import com.alibaba.excel.metadata.CellExtra; -import com.alibaba.excel.metadata.data.ReadCellData; -import com.alibaba.excel.read.listener.ReadListener; -import com.alibaba.fastjson.JSON; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import top.kuanghua.tyexcel.bo.RuiDeKqBo; -import com.alibaba.excel.EasyExcel; -import org.springframework.stereotype.Service; -import top.kuanghua.tyexcel.vo.ExcelCheckResult; - - -import java.io.InputStream; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.*; - -; - -/** - * @Title: ExeclService - * @Description: - * @Auther: kuanghua - * @create 2021/7/9 11:35 - */ -@Service -@Slf4j -public class ExcelService { - - @Autowired - private DaoService daoService; - - public ExcelCheckResult importExcel(InputStream fileName) { - - List errLogList = new ArrayList<>(); - List successList = new ArrayList<>(); - - EasyExcel.read(fileName, RuiDeKqBo.class, new ReadListener() { - /** - * 单次缓存的数据量 - */ - public static final int BATCH_COUNT = 3000; - /** - *临时存储 - */ - private List cachedData = new ArrayList<>(BATCH_COUNT); - - @Override - public void onException(Exception exception, AnalysisContext context) throws Exception { - log.error("解析失败,但是继续解析下一行:{}", exception.getMessage()); - // 如果是某一个单元格的转换异常 能获取到具体行号 - // 如果要获取头的信息 配合invokeHeadMap使用 - if (exception instanceof ExcelDataConvertException) { - ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception; - - String formatString = MessageFormat.format("第{0}行,第{1}列解析异常", - excelDataConvertException.getRowIndex(), excelDataConvertException.getColumnIndex()); - - errLogList.add(formatString); - - } - } - - @Override - public void invokeHead(Map> headMap, AnalysisContext context) { -// System.out.println("头数据"); -// System.out.println(JSON.toJSONString(headMap)); - } - - @Override - public void invoke(RuiDeKqBo data, AnalysisContext context) { - successList.add(data); - cachedData.add(data); - if (cachedData.size() >= BATCH_COUNT) { - saveData(); - // 存储完成清理 list - cachedData = new ArrayList<>(BATCH_COUNT); - } - } - @Override - public void extra(CellExtra extra, AnalysisContext context) { - log.info("读取到了一条额外信息:{}", JSON.toJSONString(extra)); - switch (extra.getType()) { - case COMMENT: - log.info("额外信息是批注,在rowIndex:{},columnIndex;{},内容是:{}", extra.getRowIndex(), extra.getColumnIndex(), - extra.getText()); - break; - case HYPERLINK: - if ("Sheet1!A1".equals(extra.getText())) { - log.info("额外信息是超链接,在rowIndex:{},columnIndex;{},内容是:{}", extra.getRowIndex(), - extra.getColumnIndex(), extra.getText()); - } else if ("Sheet2!A1".equals(extra.getText())) { - log.info("额外信息是超链接,而且覆盖了一个区间,在firstRowIndex:{},firstColumnIndex;{},lastRowIndex:{},lastColumnIndex:{}," - + "内容是:{}", - extra.getFirstRowIndex(), extra.getFirstColumnIndex(), extra.getLastRowIndex(), - extra.getLastColumnIndex(), extra.getText()); - } else { - log.info("Unknown hyperlink!"); - } - break; - case MERGE: - log.info( - "额外信息是超链接,而且覆盖了一个区间,在firstRowIndex:{},firstColumnIndex;{},lastRowIndex:{},lastColumnIndex:{}", - extra.getFirstRowIndex(), extra.getFirstColumnIndex(), extra.getLastRowIndex(), - extra.getLastColumnIndex()); - break; - default: - } - - } - - @Override - public void doAfterAllAnalysed(AnalysisContext context) { -// daoService.test(); -// saveData(); -// log.info(excelCheckResult.toString()); - } - - /** - * 加上存储数据库 - */ - private void saveData() { - log.info("{}条数据,开始存储数据库!", cachedData.size()); - log.info("存储数据库成功!"); - - - } - //注:headRowNumber(1)如果不写会自动匹配 - })// 需要读取批注 默认不读取 - .extraRead(CellExtraTypeEnum.COMMENT) - // 需要读取超链接 默认不读取 - .extraRead(CellExtraTypeEnum.HYPERLINK) - // 需要读取合并单元格信息 默认不读取 - .extraRead(CellExtraTypeEnum.MERGE).sheet().headRowNumber(1).doRead(); - - return new ExcelCheckResult(errLogList, successList); - } - - /* - * 导出Excel - * */ -// public void exportExcel() { -// String fileName = "D:\\construct\\micro-service-plus\\ty-excel\\src\\main\\java\\top\\kuanghua\\tyexcel\\" + System.currentTimeMillis() + ".xlsx"; -// -// Set excludeColumnFiledNames = new HashSet(); -// excludeColumnFiledNames.add("date"); -// // 这里 需要指定写用哪个class去写,然后写到第一个sheet,名字为模板 然后文件流会自动关闭 -// EasyExcel.write(fileName, ComplexHeadData.class).sheet("模板") -// .doWrite(data()); -// } -} - diff --git a/ty-excel/src/main/java/top/kuanghua/tyexcel/vo/ExcelCheckResult.java b/ty-excel/src/main/java/top/kuanghua/tyexcel/vo/ExcelCheckResult.java deleted file mode 100644 index c1ae3e1..0000000 --- a/ty-excel/src/main/java/top/kuanghua/tyexcel/vo/ExcelCheckResult.java +++ /dev/null @@ -1,29 +0,0 @@ -package top.kuanghua.tyexcel.vo; - -import lombok.Data; - -import java.util.List; - -/** - * @Title: ExcelCheckResult - * @Description: - * @Auther: kuanghua - * @create 2021-11-02 11:33 - */ - -@Data -public class ExcelCheckResult { - private int errNum; - private int successNum; - private boolean checkResult; - private List errList; - private List successList; - - public ExcelCheckResult(List errList, List successList) { - this.errList = errList; - this.successList = successList; - this.errNum=errList.size(); - this.successNum=successList.size(); - this.checkResult=errList.size()==0; - } -} diff --git a/ty-excel/src/main/resources/application.yml b/ty-excel/src/main/resources/application.yml deleted file mode 100644 index 3cd6781..0000000 --- a/ty-excel/src/main/resources/application.yml +++ /dev/null @@ -1,9 +0,0 @@ -server: - port: ${envpt.tomcatPortPre}0135 - -#限制spring上传文件大小为20M -spring: - servlet: - multipart: - max-file-size: 20MB - max-request-size: 20MB \ No newline at end of file diff --git a/ty-excel/src/main/resources/bootstrap.yml b/ty-excel/src/main/resources/bootstrap.yml deleted file mode 100644 index 5336782..0000000 --- a/ty-excel/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,32 +0,0 @@ -spring: - application: - name: @project.artifactId@ - profiles: - active: @activatedProperties@ - cloud: - nacos: - config: - enabled: true - namespace: @nacosNamespace@ - group: @nacosGroup@ - username: @nacosUsername@ - password: @nacosPassword@ - server-addr: @nacosIpPort@ - prefix: @project.artifactId@ - file-extension: yml - # 用于共享的配置文件 - shared-configs: - - data-id: application-main.yml - group: @nacosGroup@ - refresh: true - extension-configs: - - data-id: @project.artifactId@.yml - group: @nacosGroup@ - refresh: true - discovery: - namespace: @nacosNamespace@ - group: @nacosGroup@ - username: @nacosUsername@ - password: @nacosPassword@ - server-addr: @nacosIpPort@ - weight: @nacosWeight@ \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHandler.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHandler.java index a94907a..8a630ff 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHandler.java +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHandler.java @@ -13,7 +13,7 @@ /** * @introduce: Swagger处理器 - * @author: lk + * @author: kuanghua * @date: 2020/6/4 **/ @RestController diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHeaderFilter.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHeaderFilter.java index a51bf67..a9df815 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHeaderFilter.java +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHeaderFilter.java @@ -9,7 +9,7 @@ /** * @introduce: swagger请求头过滤器 - * @author: lk + * @author: kuanghua * @date: 2020/6/4 **/ @Component diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerProvider.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerProvider.java index 6cee91e..00de5e7 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerProvider.java +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerProvider.java @@ -1,8 +1,6 @@ package top.kuanghua.gatewaytwo.config; import lombok.AllArgsConstructor; -import org.springframework.cloud.gateway.config.GatewayProperties; -import org.springframework.cloud.gateway.route.RouteLocator; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; import springfox.documentation.swagger.web.SwaggerResource; @@ -12,7 +10,7 @@ import java.util.List; /** - * @introduce: SwaggerProvider + * @introduce: gateway集成各微服务swagger * @author: kuanghua * @date: 2020/6/4 **/ @@ -22,11 +20,12 @@ public class SwaggerProvider implements SwaggerResourcesProvider { static final String API_URI = "/v2/api-docs"; - private final RouteLocator routeLocator; - private final GatewayProperties gatewayProperties; +// private final RouteLocator routeLocator; +// private final GatewayProperties gatewayProperties; - private SwaggerDocConfig swaggerDocConfig; + private SwaggerDocConfig swaggerDocConfig; + /** * @return */ diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java index d9bc688..ff859cf 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java +++ b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java @@ -42,7 +42,7 @@ public class AuthorizeFilterAfter implements GlobalFilter, Ordered { @Value("#{'${filter.allowPaths:}'.empty ? null : '${filter.allowPaths:}'.split(',')}") private List allowPaths; - + @Resource private TokenFeign tokenFeign; diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/service/JwtTest.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/service/JwtTest.java deleted file mode 100644 index 60f8edf..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/service/JwtTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package top.kuanghua.gatewaytwo.service; - -import org.springframework.stereotype.Service; - -/** - * @Title: JwtTest - * @Description: - * @Auther: kuanghua - * @create 2020/9/8 20:39 - */ - -@Service -public class JwtTest { -} diff --git a/ty-gateway/ty-gateway-one/src/main/resources/application.yml b/ty-gateway/ty-gateway-one/src/main/resources/application.yml index e3f338e..6457115 100644 --- a/ty-gateway/ty-gateway-one/src/main/resources/application.yml +++ b/ty-gateway/ty-gateway-one/src/main/resources/application.yml @@ -1,106 +1,7 @@ -server: - port: ${envpt.tomcatPortPre}0156 - spring: - cloud: - gateway: - globalcors: - corsConfigurations: - '[/**]': - # 允许携带认证信息 - # 允许跨域的源(网站域名/ip),设置*为全部 - # 允许跨域请求里的head字段,设置*为全部 - # 允许跨域的method, 默认为GET和OPTIONS,设置*为全部 - # 跨域允许的有效期 - allow-credentials: true - allowed-origins: "*" - allowed-headers: "*" - allowed-methods: - - OPTIONS - - GET - - POST - - PUT - - DELETE - #max-age: 3600 - routes: - - id: ty-auth - uri: lb://ty-auth - predicates: - - Path=/api/ty-auth/** - filters: - - StripPrefix=2 - - - id: ty-email - uri: lb://ty-email - predicates: - - Path=/api/ty-email/** - filters: - - StripPrefix=2 - - - id: ty-example - uri: lb://ty-example - predicates: - - Path=/api/ty-example/** - filters: - - StripPrefix=2 - - #请求数限流 名字不能随便写 ,使用默认的facatory - - name: RequestRateLimiter - args: - key-resolver: "#{@ipKeyResolver}" - redis-rate-limiter.replenishRate: 2 - redis-rate-limiter.burstCapacity: 2 - - # hystrix 熔断配置 - - RemoveRequestHeader=Origin # 去除请求头的origin字段,此字段导致post请求 无法进入网关post熔断 - - name: SpecialHystrix #自定义熔断 - args: - id: SpecialHystrix - fallbackUri: forward:/fallback - timeout: - #指定接口超时处理 hystrixRibbon -> @RequestMapping("hystrixRibbon") - #timeoutTest-> @GetMapping("timeoutTest") , - > / - hystrixRibbon-timeoutTest: 11000 - upload-image: 2000 - upload-file: 30000 - - - id: integration-front - uri: lb://integration-front - predicates: - - Path=/api/integration-front/** - filters: - - StripPrefix=2 - - - id: ty-upload - uri: lb://ty-upload - predicates: - - Path=/api/ty-upload/** - filters: - - StripPrefix=2 - -management: - endpoint: - gateway: - enabled: true - web: - exposure: - include: true - - -#白名单过滤 -filter: - #not filter , you can config it when dev - #allowPaths: / - allowPaths: swagger,docs,userRegister,userLogin,sendEmailCode,registry,login,loginOut,insertUser,export,excel,example - -#默认3天时间告知前端刷新token -token-properties: - renewTokenMinute: 1440*3 - - -#config the visit service of gateway swagger -swagger-doc: - serviceMap: { - integration-front: "前端数据整合", - ty-example: "使用例子" - } \ No newline at end of file + main: + allow-bean-definition-overriding: true + #解决查询时间和返回的时间不一致问题 + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 \ No newline at end of file From cb16c37d2a9e5720ce3d5dc3d27a4c8b03ac3f39 Mon Sep 17 00:00:00 2001 From: jzfai <869653722@qq.com> Date: Sat, 15 Jan 2022 13:32:56 +0800 Subject: [PATCH 21/36] judge to doc --- README-zh_CN.md | 4 +- README.md | 55 ++++++++++++------- .../tyauth/config/Swagger2Config.java | 2 +- .../controller/TestGetTokenController.java | 5 +- .../src/main/resources/application-dev.yml | 7 +++ .../src/main/resources/application-prod.yml | 7 +++ .../src/main/resources/application-test.yml | 7 +++ .../tyexample/config/Swagger2Config.java | 2 +- .../controller/GetTokenFromOtherService.java | 6 +- .../src/main/resources/application.yml | 14 ++--- 10 files changed, 72 insertions(+), 37 deletions(-) create mode 100644 ty-common/src/main/resources/application-dev.yml create mode 100644 ty-common/src/main/resources/application-prod.yml create mode 100644 ty-common/src/main/resources/application-test.yml diff --git a/README-zh_CN.md b/README-zh_CN.md index db9583c..59620bb 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -10,7 +10,7 @@ 本架构为springCloud微服务架构,提供基本的jwt权限认证,token更新,以及各微服务之间调用,以及提供企业级的使用例子 -```yaml +```text spring-boot:2.1.4.RELEASE spring-cloud:Greenwich.SR1 spring-cloud-starter-gateway:2.1.1.RELEASE @@ -119,7 +119,7 @@ ty-integration-front 2.各微服务在调用期间,会将请求头的token进行转发。所以在用feign调用微服务时token也不会丢失。 -3.少于1天时间自动更新token,通过isNeedUpdateToken字段告诉前端需要更新token,实现了token续约的功能 +3.少于3天时间自动更新token,通过isNeedUpdateToken字段告诉前端需要更新token,实现了token续约的功能 4.多环境随意切换。在根目录下的pom.xml配置了profiles可以根据你的需要进行切换环境 diff --git a/README.md b/README.md index 1b08ea7..761f311 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,36 @@ -### foreword +# micro-service-plus + +**English** | [中文](./README-zh_CN.md) + +> micro-service-plus provides enterprise-level development demo + +## foreword this architecture is the springCloud microservice architecture, which provides basic jwt authorization authentication, token update, and calls between microservices, as well as enterprise-level usage examples. -```yml +```text spring-boot:2.1.4.RELEASE - spring-cloud:Greenwich.SR1 - spring-cloud-starter-gateway:2.1.1.RELEASE - nacos:2.1.3.RELEASE +spring-cloud:Greenwich.SR1 +spring-cloud-starter-gateway:2.1.1.RELEASE +nacos:2.1.3.RELEASE mybatis-plus: 3.3.2 - rabbitmq:3.7-management +rabbitmq:3.7-management redis: 3.2.9 - mysql:5.7 - seata:1.4.2 - canal:1.2.1 +mysql:5.7 +seata:1.4.2 +canal:1.2.1 ``` > some of the above versions will be upgraded in the future -### Recommended reading +## Doc and Example + +[swager文档地址](http://8.135.1.141/micro-service-doc/swagger-ui.html) + +![1642222390648](http://8.135.1.141/file/micro-service-assets/1642222390648.png) + +## Recommended reading 使用save action 保存自动格式化代码 @@ -30,23 +42,23 @@ https://blog.csdn.net/u014203449/article/details/105248914?utm_medium=distribute 高并发架构系列:Kafka、RocketMQ、RabbitMQ的优劣势比较 https://www.jianshu.com/p/fec054f3e496 -#### update log +## update log to look doc ---- [带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7044843310204059655) -#### online documentation +## online documentation [带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7044843310204059655) -#### Interface documentation and nacos address +## Interface documentation and nacos address [swager文档地址](http://8.135.1.141/micro-service-doc/swagger-ui.html) [nacos地址](http://8.135.1.141:8848/nacos/) naocs: 用户名:jzfai; 密码:123456 -#### Online experience address +## Online experience address [github address](https://github.com/jzfai/micro-service-plus.git) @@ -56,7 +68,7 @@ to look doc ---- github 地址: https://github.com/jzfai/micro-service-plus.git -#### Introduction to Microservices +## Introduction to Microservices ##### ty-gateway-one: @@ -79,7 +91,7 @@ sending, mail sending, etc. data Integration. vue3-admin-plus data source easycode-temp:easycode front-end and back-end templates -#### How to run +## How to run Run micro-service-plus, the default selection is the test branch @@ -94,10 +106,10 @@ How to cooperate with vue3-admin-plus to develop front-end and back-end together #vue3-admin-plus git clone https://github.com/jzfai/vue3-admin-plus.git pnpm i - #test Branch requests local gateway +#test Branch requests local gateway pnpm run test - #micro-service-plus At least need to run +#micro-service-plus At least need to run ty-auth ty-gateway-one ty-integration-front @@ -107,7 +119,7 @@ The above three service > Note: Select the environment in Maven Projects->Profies. Currently online is a package built in the prod environment, please do not select. -#### Architecture Highlights +## Architecture Highlights 1. In the gateway, the jwt token and the parsed token information have been set in the request header, and the subsequent forwarding microservices can easily get the token and token parsed data in the request header. There is no @@ -116,11 +128,12 @@ The above three service 2. During the invocation of each microservice, the token in the request header will be forwarded. So the token will not be lost when calling the microservice with feign. -3. The token is automatically updated in less than 1 day, and the isNeedUpdateToken field is used to tell the front end +3. The token is automatically updated in less than 3 day, and the isNeedUpdateToken field is used to tell the front end that the token needs to be updated, realizing the function of token renewal 4. Switch between multiple environments at will. In the pom.xml in the root directory, profiles are configured to switch the environment according to your needs. 5. Provides easycode templates related to vue3+element-plus and mybits-plus. You can generate front-end and back-end - templates at one time, greatly improving development efficiency \ No newline at end of file + templates at one time, greatly improving development efficiency + diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java b/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java index 779709f..0a0c936 100644 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java +++ b/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java @@ -42,7 +42,7 @@ public Docket api() { */ private ApiInfo apiInfo() { return new ApiInfoBuilder() - .title("micro-service-pluss") + .title("micro-service-plus") .description("描述:新一代的微服务架构") .contact(new Contact("jzfai", null, "869653722@qq.com")) .version("版本号:2.9") diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TestGetTokenController.java b/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TestGetTokenController.java index f305678..e596f80 100644 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TestGetTokenController.java +++ b/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TestGetTokenController.java @@ -32,14 +32,15 @@ public ResResult getTokenInfo( @ApiIgnore @RequestHeader("TOKEN_INFO") String TOKEN_INFO, @ApiIgnore @RequestHeader("AUTHORIZE_TOKEN") String AUTHORIZE_TOKEN ) { + Map tokenInfo=null; try { - Map tokenInfo = JSON.parseObject(URLDecoder.decode(TOKEN_INFO, "utf-8")); + tokenInfo = JSON.parseObject(URLDecoder.decode(TOKEN_INFO, "utf-8"), Map.class); log.info(tokenInfo.toString()); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } log.info(AUTHORIZE_TOKEN); - return new ResResult().success(TOKEN_INFO); + return new ResResult().success(tokenInfo.toString()); } } diff --git a/ty-common/src/main/resources/application-dev.yml b/ty-common/src/main/resources/application-dev.yml new file mode 100644 index 0000000..0397283 --- /dev/null +++ b/ty-common/src/main/resources/application-dev.yml @@ -0,0 +1,7 @@ +spring: + main: + allow-bean-definition-overriding: true + #解决查询时间和返回的时间不一致问题 + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 \ No newline at end of file diff --git a/ty-common/src/main/resources/application-prod.yml b/ty-common/src/main/resources/application-prod.yml new file mode 100644 index 0000000..0397283 --- /dev/null +++ b/ty-common/src/main/resources/application-prod.yml @@ -0,0 +1,7 @@ +spring: + main: + allow-bean-definition-overriding: true + #解决查询时间和返回的时间不一致问题 + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 \ No newline at end of file diff --git a/ty-common/src/main/resources/application-test.yml b/ty-common/src/main/resources/application-test.yml new file mode 100644 index 0000000..0397283 --- /dev/null +++ b/ty-common/src/main/resources/application-test.yml @@ -0,0 +1,7 @@ +spring: + main: + allow-bean-definition-overriding: true + #解决查询时间和返回的时间不一致问题 + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 \ No newline at end of file diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java b/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java index 4c95ca9..85efbcf 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java @@ -42,7 +42,7 @@ public Docket api() { */ private ApiInfo apiInfo() { return new ApiInfoBuilder() - .title("micro-service-pluss") + .title("micro-service-plus") .description("描述:新一代的微服务架构") .contact(new Contact("kuanghua", null, "869653722@qq.com")) .version("版本号:2.9") diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/GetTokenFromOtherService.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/GetTokenFromOtherService.java index 7403115..204e161 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/GetTokenFromOtherService.java +++ b/ty-example/src/main/java/top/kuanghua/tyexample/controller/GetTokenFromOtherService.java @@ -25,11 +25,11 @@ public class GetTokenFromOtherService { @Resource private TestGetTokenFeign testGetTokenFeign; - @ApiOperation(value = "上传图片或文件") + @ApiOperation(value = "获取token信息(需要配置gateway拦截,然后用postman在头部添加token进行测试,token可以从vue3-admin-plus中获取)") @PostMapping("getTokenFromService") - public void getTokenFromService() { + public ResResult getTokenFromService() { ResResult tokenInfo = testGetTokenFeign.getTokenInfo(); log.info(tokenInfo.getData().toString()); - + return new ResResult<>().success(tokenInfo); } } diff --git a/ty-gateway/ty-gateway-one/src/main/resources/application.yml b/ty-gateway/ty-gateway-one/src/main/resources/application.yml index 6457115..f635f78 100644 --- a/ty-gateway/ty-gateway-one/src/main/resources/application.yml +++ b/ty-gateway/ty-gateway-one/src/main/resources/application.yml @@ -1,7 +1,7 @@ -spring: - main: - allow-bean-definition-overriding: true - #解决查询时间和返回的时间不一致问题 - jackson: - date-format: yyyy-MM-dd HH:mm:ss - time-zone: GMT+8 \ No newline at end of file +#spring: +# main: +# allow-bean-definition-overriding: true +# #解决查询时间和返回的时间不一致问题 +# jackson: +# date-format: yyyy-MM-dd HH:mm:ss +# time-zone: GMT+8 \ No newline at end of file From aace851955eda76a7c02515edf506b9d510d15ae Mon Sep 17 00:00:00 2001 From: jzfai <869653722@qq.com> Date: Sat, 15 Jan 2022 13:41:18 +0800 Subject: [PATCH 22/36] adjust soming accroing to doc --- nacos_config_export_20211223172459.zip | Bin 14041 -> 0 bytes nacos_config_export_20220115133818.zip | Bin 0 -> 16104 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 nacos_config_export_20211223172459.zip create mode 100644 nacos_config_export_20220115133818.zip diff --git a/nacos_config_export_20211223172459.zip b/nacos_config_export_20211223172459.zip deleted file mode 100644 index bca293f7bce58839ec88bcef50e7bcb35cef970a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14041 zcmeHOWmJ?~+Xe)NRDq#E>FyAuTUuafrMqEY@T_`vTy zOTgptobSiG*7v^bS+i!I`EkwO_rC9Iu6;fCD9Buc2f`pBA;A!b#DHMV4f50X)_Mju z5JnTQje{+tp^+oAo~^B=nSq|YnT_??HIs{#r3a`}eoP2BLB4r|yjRO8hGu?V3pbmD zlg|9xH3PSB+0DFLgpzsEj|e0mXq#V4d-Ui_B%Ob{&kGpgBm6Nt)kBdYeo}wc4hDvv z%EjbL$U3pUtoqY|3IFF$@LeR(oy-Tq->1e(?gSyTZgOKlw}{+citqV4QApq1cs^B* zY>>GoNfWoa_KYMUJJO*e2$?TS@Gc8bR6RPUpOx15bAIiycP$b`R;z*ajxiQ86nmG% zFYs}kD7M6_0z=-Q<9iDSL1~6I4`dr2d-J+}jv17Grs|~Tgj-^1Zm1vOARD>|Ak8;h zNGHLvM52=d`SJ{Kz(ah7@2HRqfGuO18)r6a1)T_1i5^GQq}oq1B<<_qG){?oL8^*3 zy~(w$dh_H0zM6FRNkMG*JKRE}?2IRqv-AUy%=(8|2cmr`)0KR3UxZ;ueV}aN?o8vs zn2bl<+vC_?p3znIdS-0Qc8F+u56aO8%mvl680%5f3&-;NJVRSVK72hJStvZyeW?HO zfI>ZCxA5Ij6lJLFO-7nE#5{j>x=F}jc1Se$x;}Y?Lvi+EYG>nzvnUA8z}K+vLDm!Yy%N zNDl>KH0KLxnov%OV;BV)08$YgRumKt1||$1=JfhkRYCTaB8EE-H?+BCQxu14qsX z74pih&$W@yCZQ6Zm2H3|XxeV?FfeZAMiP0dff?J|%uL|jt*Gt9BVQ^f2ag?c zRw~(Kq$xlb;TOPTJ>yM6EglsHs*&dSRFp8;?&3N$?Ldd9SY;LJ^#;$B#xBiD8<3 zco|+u;1!jvFiu3eMZ9p%+FYVlZ=NjFVfr?I&8BYEI%>Q!m=}ao^^AOHNng=rI00>= zhS}I=e}7E0GHe5}mm<@hLGsaEqE#6Gl~slWF|6lw@@CBv1jN)!vTmz`o(p8no7(8v z>r3J7u~Z{lJiuAhY@x`is-t}E37~(1XC;b*ZOj+_ZE<%FwS8VMdTH@Fi+iQe^*O~g zuHA;Wf?rYhf*UOq6A&Qx0vZ|EGFe)uml&2miKUQ-%VYUB`Gt;9aVj$ktn&?mbH#fy zSh5_s>GiVgE#q0r2|)Gl&kgd-&#NAcZ{D~S(l{#QwNiPjQUy2!b<~b5(_I1_C;~{J3lV|K!=uPclP48VpTa?* zAMvv35R9JpX7uJw-MMy+uKX~o{O(3~0fJpnlZP`VRK>}&WSdBAV9x{JgPn&vQ2&9+ zO)R{cn5yFWSbDjjOzAu2EYxv{PtaOg1Fa<(k(e#2^MlHxT(^^H1im=lI6C^U-qo?0 z)5vj;i=tH_D5Ig!H?uL`Og{m^7a7+HM?knQQ#S%^8hhPs8D5mUZt*rB5NZR(VKvx6k^9~Lq-#r^Rjq1Pe;2z%}LQ|@tzdbtA+Zbi4)xG zoV>zemP!>eMFJA1ul3{N#MgJ-3`-?P$sBi%l-?j*Q`62r;bcs<2^1kU7sy9r{RUX- zb5jU9vTrPIR{EfeEvZ4254+Oe7#AOpk}*UPFuz!<6>#^d11zc308-nqRJ?NrJRzlU zCO50)FnN%{B7Ae0QEn0*n)JYJ)kUzi&{6W2RW)T)tkA6m^%=xqBf!Cv%=YUziOq58 z^=e3O&=Ni#xzeb&V+P?hFgSaS*SeF1n>k6d?&t;q;r#ph!W>EF{u(dGXf`OS_-=A*3ldB~!HGx&<-L zC%2?4yYvTU{LL7_md;EYk16|aXqV?hjMCvTLf|vH!FP($?Pj(QWY4#N7g<~ z{Q>*wcgXysS=fSY3@-?=vk(5R5(`(2g5i8#Ry}|y0t-7&tAZkhAP(zuz+Uz-f6rgr z4er-UjEl=$%2Yv?;#;#{taD(HpQ|K;Gs-~^N*fgomlbvrskR&iuE}JvAzRm%lnmQ!U_n; z)wpuw4Nkp`i$kk}9am%xHlXkLTdu%8zsCh87QXst%R z#e1$%Z{=u=A_A&IG-z1!<-V0tDm+T5$hAzqd#4*J2a?rleeBvV6y8#}@WzRy`0k5} z-uL5VNQ%bhd$-X@72pZkT###sAXEbZ*yZ!dPjz8wD$o?Lr^3`(S-z2c7H3o|4Nw&Ju7 z`Ubo%w50j#5`E$QYYsL&;VhoE{moLZazL{c*J-Wm8R^o%C~^#|G{@|3Ben+W-dFOE z@U%PT>JlTZxqt2UDB)$N$8Cl~^04>28GxD-(Sy^VZ97NV9)cLfZkmAcibG%%TG|`d zi}3-Y>m9vQ(`<5%Cq{S{ru3UWt(nnT4Rid56|Gbh)8O#2yV1MwQBTI~ot~f$)oyQf+=`ZMY|6C{@m7nxCe8V*Y9<>? z>uRHo-$A{mipnf*Yle=hm(*?uW;?E{3F2hbRN)>TiJBN;H(@`DKh{YQUR$F^6t>1N z^iF6aPx94aL74MMire+lPD+kDF+NxrzlrfuU2&YHGUl0Y=)H!{HBUivjp}rKIN4W} zFQfCYX!*FI$g-iR(I(D_6s*zQ6Xad^&8>Vdy2icP`z5)Gh1reyP2=N|dCjUE8n;x8 z>DW{7hoi_CEjVuQRD!MC50S9OBi@73F^p%KlsT5$MV@USXJXOkW%W~&0Lq`~eG=tk z1d1EYxW@CW26_*UHbJ_=Ne=KKN-Tf`>eh}A%mLl(sYt<*8YYqi^^begX%=x+?o7)n z9t|tJ5b3BCcVP--=hzl)l0?B@RGU*zj5jeOfC*5_;7%!|$H$F+xmt*-jOSmKi~e+` zqP~q3al2h+XL7I~S241}pgN050{=O#sHJAJM3VmozwJCjtz|GaJ|aoGX$K;q4bOv> zhA|_b5(0o#N$pVW)Kc|c&i>4MuL^Nni93V=1tx>0ezRy@iUVEZlsg1OvSd@#w1?xq z!BqA0s?NP(V&F}g1$We_kwPnghyoZ+=d+YpbG+@9~w48@C1NMRbWIS1#q?fQXnwB13}N zXAu-zbJ=F!Mfz@Er|yG@ zg>O>>4i#J9rD(o>R7}e?7#Kd}zd9)XsTBP)TA2D5EqJM?i)g+KS>@<%5>A~CR$3lt zaXe6xR-Xu!mys|3P{S|NxYr;DqHf5P&-uucUIAO4?bkueQT*!VUP^CLde$*&(pW^U zj^cM(=yHclb*;P8-)JU4@^B5l8FNYtyF(2cka?qaRKzG5(+8NZSb2AQOF!j&qV2)% zDps!0gG?#cAr)u)kuiRxlNxA!?GinTh^yW6_~yeN2z4uijzW6{`!wZTpW3ImxFTkB z0%WQ1>2>2gO;o4*zM~rj%Ze+`C3eRg<9xTUhIw+}0|L5Rr~I?3Hn>)9B=lUjC0<=m zkNegjSXB04@I$w&L#84x`nu|<6P=A*KaT+N$w667Y3TkJq3-FPqgMyBS|ubEFl;?? z@ZmcnJ?aQ>g5CLug4WDT1)gPl&<+aPkA`-$*|pTWO*L*a5lv}A=3~{_r^H}O@v`jQ2fd}Sqt3qqVIy#X}hX6$td)rSF=v}AsV2JxBtNW z=7B`!J=W_>5cHd}JCj2Oc%s0XlS6(_kLPJE+b%?!^@>`LZQMW4vDI37W8+bgw5vm! zY8KagCq6@|gg;4)SPeL8IxVlY3UX+t0H$u=1a?UrRqul+hd={OMB?urMgr`;Q7puw ztVK1jrtNs&9!io`9@=(6?ys4nHk@&#?BeR7NTGO`UL}$^l;xxYzQ|w zF^h>amVsVu3z+R2t|FAC`VHmjC-9KQ)>OWormg7^VoBa&SPs%ia@8ET2lu^`SggTt zEwYv$4@tML>p)*p&CtH8vm*yT_C}%zE&sC}{J}|jrB1jow#u1|7pxkHAuf11IH*KL zp^*Vk*u(m|AXrKw2!Y@ZRr&3jrB2`^Gs#@{J4>F2o>ErE#?tF>k5_`rpXWSH7JD{V z-q8E7L94m=T`H1oY6XFdHB0NWQ30pzWd^AhfG!jF0r|Ms$m9vH^IodU-UC~&to>E) z3MWhf*TTLWFBUr~g6MQ5vX`93_2|pXhWzWA_b@*{oE|~J&~_m>e4Qe>U2V?Mds|@C zJh8@d;1-AWQGDPy;R)Q?VRh&6yAQpm459Fs3~^b$T)vs+U~6fk_ua*jk&&V=`|c#Y z`@q=VCD+Z&Sggdt!O5bmpz2&)usyP6CA0-Tzl(Zpm)h9vbgWnPAL_5>SXe zge^oy$TjUS3v!1qY3#FSPd>F9E?>&v7yX5NlZme>-6PwU@*Dky{`XA^AJM$`taUx= zKZb7X+E@m*gVq@cAbFIt5GOQ@{k#;cG)({TTR?@f2y>F~-=5HcgfUS>c`8jENoh6(dnul!n4LLTk?#HTRWv}# z;Z_$PdTU?!6U_o{15vrs)xPHHttWkADhNjYi|kH<6TI6aKK{&V+h@sW?=jXXB{Q}0 z$yvay@f&{yGY#qi$G|yt zQvVY0dr!}0yz}jRXHM&n!G!eJct5nrWz6%#d|bdUb>!q5Bo7b8iJdlBysJMcGv=Z)-(i5IUNVI*&+a_X8EyU;2e&Q){Sm@HNc1w& zuPX&WauMk#A$|t^&no5i>2{wF-A|DJv{JZfegpV_sT6eD-+}(BQhuG;k$;By^Ks(x r?)*9n%NTz%$-kF{7n29T{3oF2?05wk1jMsc!#;f!oxTIIoL&77Vh_6& diff --git a/nacos_config_export_20220115133818.zip b/nacos_config_export_20220115133818.zip new file mode 100644 index 0000000000000000000000000000000000000000..d0eca68f1a8888f3ed438b34f29ec777da6133db GIT binary patch literal 16104 zcmeHuWl){V)+X-m9tiHTvEaIK*8suY-6c2#cbDMqZoyrG1}8W{g9ZpPD2Zx&`xSN(F&mBfS8xN5 zSn1PJB7E^u$=7(|n%d^zZ(qMYi>C?9^UDDdyvJR#Q@sU!ALbY0fRLaRVN76E zxgmGxgV@e(=vzY@P3f*6UvBr$NwbnssxE3S*tM4ChWc?%(h=9tBxPnhdBo_JFf?)*u_LfP#-Rq|v{4RKh1VIVy*^aAp88d5V4|IWedbAISSTN8WOwuBJj=U$b8B zuj?xNL>U{i+(Frj^|4N2lqhvF8S7Ef3MTXVMIr3M-qmcxR|u|;-RW=MlBuVCsTjXc zAdiqnp{F{6Dh*VpS#_8#3QOcX)+dc~sxI2i9*KXMIwC@-iB(OWhqf>V(oC-L^2(gw zuUzzT+T~;ezzL$ty7Q(>BL&}Hi4h_}AIh3H)WIsPJ2$0Y_NL$gHQ+9HLDyrXb#?nq zXLT`M8qhTp+J0ou-{8bP^Z?8^*m@s+Y{Ba!=i@BLohQki$~HtNej3~3Ep1+%;fclV zY}WfipdB>9XNKME-YTw5wIo4M?~Rh07d!KgG}fv5`&{fZOHi?_&TNJC{-GJq-{2$4 z;0uPZDD^z*!uUR)j~Ff4YD|)p(77 z{vpnkX%!-D9jmyz#Q1pn3NH)5gv$X+9Y0Q`wM99m1RhILfm#IPC6F4g!>=m`y*CyEajC&jH)Bv- z&%K++CaoEQnPrAJ^rPMNT}a9Sat3L(ff-9nK>@~#i-gPcdw&WSC$B3~W(w&{m^J88 z{4?kvJ>ygSS6nJ|6brqn*>Ew^W7Y2vv_qT{_P4kI;%gs-)s{RMbU2UZ4QI09lq8-t z64+}D>BG~etE(X}38{J^$pu@JlKOj@l`W7VA;aW4()GI<0!RiVjEiH+TMIc@Og?co zm}(&hIP#F2vC42FzUReexS&`MUX*W7tyI&w2_8B2XR|q_th`X>S$4^4vlt~LntgLT z7xZOgQo-uB$a&324Wu>eola%qGRMSyLd5OETQv>rK1f&V<@*JCLXciRZn_*GPG!RZ z{Ytz?T#jqu=^nLu?`nk(!`E$an|FuS3CqoIxRtP4qe!pz^cCFZ(-2PD8I5gjZkB|b zV@{wZ$qGE_#9zN4I0OkiIHXGxL64@9HR}c95mN3+dmPSs?>z54)kZ8j-isYdrdYV( z!q|W>5{PeYy)V;V!3a$AZiaKRO*+%R6!m0PyW#esl@#5w5UcMy-cmT?_|nzFe-3~B zrrSax4bnj@xSNipfN9|49^L*Yku1_!S@gi3fQSVOHf4IgW1d<2648l#rb1^96j{&vSmy{=L|x)M|7nYEP+K4x8{z=`HWRt6BB>Gat0xOnX>Rr z1m9!UGr8WwNX_&w=a8mgJkaIpbb;!bfFbe-{j~WWR3Tt`N~j$)eoC1?IuCX@fq0No zriD-iPUHh4vAilAAfsdyR0Xm`x{Iuz_!@i{Bz009&LXxuoOP_%e}Uo+_pv9rB;rlN z(!*SOV*?%5oB>H8-vzWtd&>u^g!UueYER_1dCQ9gZ+*QVk7=uGmfew@M#`gGHJ4A3 ziNd-U1$+*giJDa~=K7qq;~RAMpl=nRiTifqLiXnuVfR)an<68@`ua9;ifAB>q9^kw zOV`-J!D$-r3L9UXjFm&$h4y&4qV=h`c-LMMh|FAj;d%kMI79R`O;FHr+LKzVx07jQ zLJK6>8<{9m(!&w@2STiY^e~JTZDpa23GSDfRD5U7$oKajjz@=2i@RCHILHR%L-V^T z{0q8M&GgeC{b8|Pu=oV03UuS_O_Py4_928x-|ar*!RRxI2%H7#LFIXR=2au8kR_M~ zpi@f=11Hnq6vOPeZJtww6z5idDb>*~S94Kt*%gzZsM_hgUwOnvV&fK!u~cl5s^kMc z{q0;9B}Dq-VOTG|_}uyGUa<}mTur;|k&QmnCPawDoUaUl`789^l!tuiy<>NEui^(? zO!1clWuOPs-6^T5aQSm&!P~nXuYzAhI)Rc%%)kuJOQgEyL*SDO7H~3K&Xa~3>_YU$ z7?ot;AV|(UQ{A<<7P!wmJ5*DKM~}GJQD298V+4I0UND4&mEN0@*Qo|mhmf{;?@pyY zgcgd^#SqjVtW)9h8!ysO6dn#fabgklU-2Tv-|(Wnp1!`B<2P=!8skOkW2ctX))QA>k@vu^+$e#D5op*z*kF~RL$}lbWe3wG?UA4kfO0pbs z3L~|a(@GTGAb#i2-?+XwWb^s!ry2J>egB;6$^ULmMuuh%-(C{HCR zGeiefi-Ey%7A94OpYN?H9wsqNyMb6bL`GKvAnG)wUfR9w;MG{ z*)eb`cKXQ4W+Il!+jhEFqN-SFqX~)Hx|5#ftv#F!-67Qjpe62N=H2^d-UY59=Mr5) zm?O{gF|S%~04;Ve7>t)=07@`?aohw}m$vN|`A`^C0>Cs4wThMRw6A_LW)k%S>gYJF zOV37Tu{UaLA(~{})T{NyjhE)QT1^8KWFPHgmtG`(fk+5nvWt#}U&|lpKi1l-MU5qU z@ZWYWCn`Jndda_7pK*0;fBspes?DQC$D?xJ#->sG4(G7aXVsj?s(rP){#{3+@pzxl zT4jU9GmVHv_1caT{vzjNHGZu8_Ezk>dtnnJ%pT0wsSi47f=5S`P=eN|hQ4Woq#6D? zOpse%87W_Uv@nYjlv($OgrZJh3(#px3#TcGp&O(0J_+;CV~859yQgv; zhWO4d_Bf2j65rxFC^A8(Q4S1$U<@7uWW&6Pe`z9)*BLaKN41Ns!v0ZO;eK8|M`*ZN z)QuqozjJ*gzOnm>Cr%zrrJse!fOYeYfoYhN5#@)pasP z#Qs!j#}htbp~8%s`QtO|;L>$W$W+YGHnPs@PGf5l<%+nG$B9Ar?u59Rw@`7IeK1+i z>+N(g?YK&nAeS6D4;W-ub9AT6AdNjkl8Bf5N03~2L94;^8uZ*K2$+?9>l*OZ6DzFh zkk$PBGbUs9wlJi|PCuvH4Yrb}PWX$bEZZvS#f=JOHt!WseAwjonp%8V@oAfLZ$IE)gwK4Zus-uHfr=ba zNs&Zh5)AMW%E_??=SahaSof8#6{L7&$C=NHbe?;Wxpc4pF724V%h+w)&eydWr>2W% z-?*tvKOw0f90Y_1_OG}J{|~t7i52vm98G^?Bw2bIDf*h<7-^7^rdmaN z&HLy>1n8{0i%}lLfvMPVjdD%{VVU~Fsou7W@F@`$NTa}AfD8W$_vM0LAfwtPPuA?2 zqu0`igw)!}Cs#g??ytNV#BuSMqX-yv!~t)8K|@$rK+*c);N+Yg`Ciqa}|HhCYlUEx(Pb;1JONRV8Q*|_QaQrb<{U<2@Cn*0XDE}uY{|^hw zDStX7ej&#H7o+l@GmT#t^?xKR|HDJ)*SNe~RZ|XM48vP&gFjq4A7U$_InS+11S2#j zkA^yAL}@m-`pY~~_3Fa-_@a6UbZW8`e5g{OyeXN+ta2SHg^GAKN_W<2#ZloyVCD*& zZW~my)!dZ3$+%I6gYh`W07MKZ>d_%_??)lv5M^z)34)u{nPd7eb2>gc(}$%mpEAag z9!>E4K1ocFRoF>gcECs|!oEx`jj}B}#hKmEO5Rm6eceM+L8(54rp!{o0SDWBs*+c@ zdw`#`1M}&*vv-FEmm{3m)w<2BVs#6L4&QxW%9=&F8t;5{V*^cER7P(1*zi#8a490e zQs68Mpyko~og%$gQF^@laIl!Ocj1-kE*Il$JNWK|jYSyk9s{Iuy~~G;sU@FJ5LVN~ zN?M}airf#V!UC;dd*ZH;X>$$YvZB0SOa_UqC7pagJl?LUZP;pCZYdLEi!e!O0>N|~ zDl!I!Vqn$DgQ=|hk>ehN!d?bwSTr&FH_7%yjan`OgfJA5>8Uyg{o@RB(aVhsHKe`S zd02Q}EXQZDW+<4VIU|%v|ZpuLd38<<=vox++qb~&!5?3mC1rgKU)r)2x|wcGvx2N|6S1q;z8_YUeNWpW~Jx2o;bN!Z0=O*fYX9 zjjbB=V@Kmx%8dp3QCLq&LrS1yjOiRCf=EY=kH*6jOWrQAym{FjFFccNN8ymE0GPUW^}f=Q8CQlxgH=H1IR}``VOG_=Mtr4gX{CZc$(>b`cj|QXs#UV?$)P6 zta}@e6E7#bwT}fC^`W&7wdcm=?zeFnYry@6a~rL<$oZEP(l{t$nI7_DD=M${ zcdBdK8J8~3r*`>OwuujRSYdVki@8FGSC;W&I2WMbWR|r+4&OR+Lh4I9i7@eUTUbnXE6KXt}%wt;|MG9 zPDvik@1TZlQmb?hYYl?OlQrm~r!AJ)f5Z7^vhl8xb6R;|MZzHN<0rogy!20JZ;X)~ z@umf=4#{g!T2Ur+6Ewi^5{=xoYLz)_ZGB!PM4%_Rs#SMjXKd=51V_!)?oTzBurmDy1KH&E+QsN``{!T+(!15>Bjm;J!u)soHgr(IoljlpRu*qN z?hjjs=Nj7EG~DV<7zsHUwWatF-A#hO6yo^d?}g2BsJup6kWf2|{**Yf3f^e*Wo}v- zS)<^!VRC3S>1%{A@b%F13=$JPeg0z~DxAvQ){2NrBJ$dYAP89wZ7x3LHnfb{*xCjg z>_j0wov$0mqHK>sbUxRstMslPrk44?Whw)hGg0$T$`AnIuQC;aKRSf|Q&W{^fATVn zT=lGMEq_yTtfEI`@tHA#zQmj%C3e@~^~Es-lnslD3uuZOs;&@6IV3ZuR8wB1Xce{W z<-AHLK@-wfQh8O6kAf^PGJ^74)hm!IGeBE;Dc0!m(dY1dmIWQXVk;)ZXSI!zOb!>i z8=b;{xM)xWv)9mAuUPdqP$kx{z7&%Mds!A{lOTK{c*wd^CNmJfb&Rn62wA1+B&z#b zw-f;9zsf(yV2e0U!5DR5kvurakCk>`_o7>n=TKmh_tOdCA=_{?YPDwfoNhxr=Dj~{jx|b?V>TB){30#8Mz>Q zXSd6`qNW?9eR6Iv%_ai(RYmT)Q^xHD_P33&3LU0a2?_$@@>D+hugi(Q1TI#3X4c=5 zcQ54?S$r{^cCigYU=H??C}AtZ`$NJK`7jK)=WU&b?v_!>8BQ+7#pNZ60?c-jog(Xn zGU%~1WHD2C{)>v81#T%BE0>s+?`=#7pv42|%bh1&#&3+r?@&6_W9B}i2(e>rVQmXK zmFT~%WNE%LrAQj`N|Ca#mhqfWyo-A#K{KdD{K!f?>fTW&&zD6gMUsV4)Fhh=3j`!S zdsj?ixumR3JB5&oM~MGShWS%7(%gKR9NmTJn+W0nm>wZTF_c5@?E`6kV*JPDF;Dg{ z700^cr}emPCYRfvY+MKL#FEu$6tw+{e0N>j#HFz8vx|##Up8dZS$FpIk9Y6pY=E;V zIpH>4?OU8Kc-MI`9ugEsI03O>!<;k4G!d=x-$huYijdc$=xWnIb8gNNQ`6AUq2OYx z(eyUT`_2o(4th;H19-gAd0#5=KN4k@T{%BQK3j`WW6wQOt#g3L+Fb$8tkUU8cz3cD z;j+5bWAIyKxSaUMxYrXL@xe}H;){K}o@wCCB$)NJyf!~^a&58p^wpKzU4d@j#$J~o zJ>*lp1fEU!l7J9BI+u+T`R3VpEGQ8Y1Pxf6?f}Gzd0zRFP(VxVXTu_W&Jk0ofc-RG zvN{*J+meiZ!R>d0ZP#h|2(Q{MnJ%Chg^UtV^cknaj|3tTMY!1b?NZz{dhOcysEjt< zNR6EBdMud0J{n`Rl4mLl5YpF(5e7cOq;_GQ1VCAy4F0KYz5B+OhR(xh_$bocS_c9B zEObt%WCy<9g=1A6_jPoryL^=DqjJXdb=2(E5yN|FHmlS6ffsgL+YJ5`kHFv&HB12f z`6@w-w^fiF6Fc~lSTNWoqdo-;Ug!i-$*oTNIOEVm=KiVz{?TfCeO`M)WL143l1nak zW!(Lvu3ErAAuu=9M)~Vj+K}6{eJAo7pUk4vzTpe&6=;=3Z#*?huwpR*Sk^H?iq|AW zP3)&JY5`w`lcEPmy!;@X*9GrHi@YUEkl^8LLmZ36y+}}{w`-9z-jS-fX_ihAscG0! zUGYK^Fs#&E*}3#gA%?He(`*q?--^T+HbKAun)VzIKjzv2tO17e&(JWvCfKsEuaTPD z(k|G*zQpz3kCNPFB))iU%iNohxNlv2D<$0QYQgHwb^zeXvv8k4jkE&7-Ooz5KmJw_ zAPxbCw|NrX;GzC%2mfvA;b5fasP}CPuPBblc0YAR#C=9av~--Lz+{p^$EFLXeRf*S zZonPQJkLH&?ME9@85oVC*8g#wYVtKjlc{GwRCRvU8Fsp}MsYxbRO_d$Oox*f4m$-h zFfig2ep%_#wgfYs+OQ=oVpWiokVNVtyDGyQGArG1TZm<9CFpoe;b@8=f-U`|i?VvN ziZC`pT0!$Bc>_m_dlkpp?5x>)1qLnyg)%3(y9m}n5iJHEfV+%uDlp|0h%viwBE)@# znnRpM)br0{R584xw!tkW0wHx1LKuZ;Jm&|i%t*`j0V&G1CX1?U*`tsh>Li>&y31T? z8x7pnrGoU_S3Om0b`yKe2S|~GU!R-n^|qDhr^G=p$DxY|j=rfOGs-Wn4&UeH8`D!4 zq3BYf={+3tncMfp#7a;Uk|(WAImIFMW%4WEzH|0=F>>%SAr+#dX@Nr8%UAj;2KibM zRTpHMXNK9UE50duXa@_NEcUCW){O1)$_I}gt1F+_@P@8dK08gBlZTXz&BjuNleuag z|Gsegn8!X)lUr0cUW(;B-^C!;{ z#~@dc5cIsr-|t!EXi!VHsr2w*$J+3v@T`yKRDlTu=BUVs;_E2}lCi?BXPss|$%^n9 zt@WFX;^Gd8WvwY|qvLnZCdO7MFHx#jiG=7F48uKHppEBZlgK8>iU`COnqJ@dc1=`V zU0qzwC+Zs0yrx7r-s{3Ap{5}bJHN)H=!#=;O~->}I4nSr`RtLLCXs0WRPRr-(hy?s zL_a!tyb@}Sj%KpM#xBVxt^7R2dz-64ql%0*O!>|Y9@+$?l<{ggBV+iA@Wg0cfBV{d z`xMK&HSm(E_V&T6U6sDQm>}tPM2vBzuYK{T-KC|NsO|H^Lq|hf(8H8~lZ($ZE$>%( zM$>fAlpQX-*u~N;W_Z>%W|r-TI(Bxx%f5NFxLv#Abm{?b?N&(X= zH4|b$u>v61&CvUo5e39RzIHCA>_`d{KW?-`^-U#GX)&%dJSW2z60%-YI$*df9o~`R z%R$l}eN#KM08t}%DoOges?MIJ8OjtA!8%Q8$u2s&Lb5c%mct|^F_GxEqnxC9NGopo zaMFByMK4pU5jbhfWRIG`lz@*Mtjne<@vHrDi>h574FXjS)eIwI2eV59^+z7t9F)gX zSY2;uo@FT$9Txlb_(>=tM1*-B&`^wh3{81`LQu600puHIK`=1W{~R5rY+?EU0C$sl zJ%;$sCsy9|n5(uU;7;Tf>ofD(X)CeU7^evbI_hGQG7_AjRrV_b;F=ZTR=&_9Dp_>E^aF{EeN3)Ulqmj`bD1G-=j!`vFvU;h z^akRqE3dw+p3Lrst?oE9x)v&`o6GZbZP;0(9pN==7oKC)(-DMY3tNTA>m(iArYf0k zrmej$FbkuZ5fdl-7_LQ1w)iRE3bnkC0SE;Rotja3%9+?zT=5jbMu3|LSHY!)T&Z?S z!&0*~)aQLH;3+3<1HV}9e{b}4vRsPX3AnqjoLOi`orWAmD=d@8=ikHG>07Lso>Fsg zl}GSeViRgFBIPK|9>u1_q`Hj&lwOJjpvTF@N_VHzRO58$(&t1sYILGf-6$rCryeN7 za1gWkV#FbstSIyY;L#kIOxDbrED~(_8WE~Z4m|SlBUJ<3A%RT3fQVye6=@`*KA7St z@Lksc)c_J&HS-#(4;G>W;q&JpA)dW3@m-I}q@=Fkpd^K-j8iPiOz$g;yDnm0TEyQ# zFHdNT2at8jr%3XF7Z}4@zvV5p$pS&QSL)co0ua7yN78O)5$HBYLul#auP(7j3qHPo zM#J5Dyzjn!>f3tO?QuR4)Jl zX@~!-aQ$bQ@n6jOAK4M{v&{Ifm+_Cx_@5^;{u0UjC^KSo{7;#&oTgPBL)Z-rG8@x1QisT_w-pD1$7>%U;G?Sd^{f0wvn^*2eme#iE$ik@jmS` z=ZTwfmvPVCQ4-4h?px#4j8RRI7At)x_DBG?b4Z#Wm%VrrlH9kmx-vCs2ZTYJazGXk+K z&Sq7w&q5onFUjBWVUBrOS`)FZb%bno^z=ixRGg)#M~jTxSs~OXtV77K&)ftRPS!Te!PtJylVBS0fBpsv3{sgr7-KK#lGXes6ixqkCU{-B6?EL zbF^=?NsTh(0_d8vc)W`+h6tCceHkn|fCCU1N9Y&D1~K)^kVO5ltbv@{fD00c|@ zqiyEILwXZv<^0L>Xv}S{ri)ksR4#O$BS9!keh4@Ac)WO{2;oQ(;fUHUVSZ9oZlprU zew(3siEk4{U-&kp@kHFVwzhI}U!*Aa;sium&}s307FyC2tH>Bih&a&qk0z^!knzl=-TO&?VS zI)dkWs*oda|H9JFuciBZx904v+tqWf`Gg4SW(|vRdeQpJrtbX;o<+EVt6YB{U7EYw z;>Z}<6QiT8u8&Q!3;kcQ--*_nxv`+DW(g^$^Z84GXUb#BgGnf5!_K3eAJW;y#QCoj zY7OdT^9d3xeSXfM<$dvj8aEN!24s6!Aqid`a+{IQ=piw_mlP9ow<*ETx3+I+-M%<} z`_bg7Z(d-UH%}`(CSA%^FBz6e4?eLjme4i+)rWGapc@pbU9JXpu1t&QwCTJ#m_t=x z%~b#EG!-vUJ>~!tl?C;r1YX4E4z?Yi*?V6$ystB(s6n+@%$h5AzZEEkAwKHvKB-+j z|CYS@3v>JJ@B2$m-vrJd$A96vpS;wMfZyK^_|~cZ`@nkgx4#7Z zttst4+faO#`|4$_!;y2KKpMy{l5>erykqCnxp-{lK!6|zi-n0aoHh% z0QqYI|1;kAjjrEXdw(C9h`&zpyXyJRK;PTrM+282{Rs3+`O)xi4f0L-`F-@D{|(@O z%_2WqIT_>cK>y4n-*+SYxbkP1e}MV#+2mVx@%s?R`(wa=Agd-xoxFGzU7#-$4GaBjIPvKX*is zC+mE_=3kDPf7cOlss0A=f5#Dz{}%Mm9P#^n^+!i^qW*)4{&yU)lHrd5|9wYnWBg;J tzi`CwgNh#=v5EN)!2WxVc*gcOkl#5X Date: Sat, 15 Jan 2022 13:48:52 +0800 Subject: [PATCH 23/36] judge to doc --- ty-auth/src/main/resources/application.yml | 8 -------- ty-example/src/main/resources/application.yml | 7 ------- .../ty-gateway-one/src/main/resources/application.yml | 7 ------- 3 files changed, 22 deletions(-) diff --git a/ty-auth/src/main/resources/application.yml b/ty-auth/src/main/resources/application.yml index 8290243..d3f5a12 100644 --- a/ty-auth/src/main/resources/application.yml +++ b/ty-auth/src/main/resources/application.yml @@ -1,9 +1 @@ -#server: -# port: ${envpt.tomcatPortPre}0131 -# -##jwt相关 -#jwt-properties: -# secret: kh@Login(Auth}*^31)&kuanghua% # 登录校验的密钥(盐) -# # 60 * 60 * 1000 * 24 * 3 三天 -# expire: 259200000L; diff --git a/ty-example/src/main/resources/application.yml b/ty-example/src/main/resources/application.yml index 0397283..e69de29 100644 --- a/ty-example/src/main/resources/application.yml +++ b/ty-example/src/main/resources/application.yml @@ -1,7 +0,0 @@ -spring: - main: - allow-bean-definition-overriding: true - #解决查询时间和返回的时间不一致问题 - jackson: - date-format: yyyy-MM-dd HH:mm:ss - time-zone: GMT+8 \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/src/main/resources/application.yml b/ty-gateway/ty-gateway-one/src/main/resources/application.yml index f635f78..e69de29 100644 --- a/ty-gateway/ty-gateway-one/src/main/resources/application.yml +++ b/ty-gateway/ty-gateway-one/src/main/resources/application.yml @@ -1,7 +0,0 @@ -#spring: -# main: -# allow-bean-definition-overriding: true -# #解决查询时间和返回的时间不一致问题 -# jackson: -# date-format: yyyy-MM-dd HH:mm:ss -# time-zone: GMT+8 \ No newline at end of file From cd009ec6fd71e80c8c35d7929fb54bb13e74f829 Mon Sep 17 00:00:00 2001 From: jzfai <869653722@qq.com> Date: Sat, 15 Jan 2022 13:56:54 +0800 Subject: [PATCH 24/36] update readme --- README-zh_CN.md | 8 +++++--- README.md | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README-zh_CN.md b/README-zh_CN.md index 59620bb..1322dab 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -41,17 +41,19 @@ https://www.jianshu.com/p/fec054f3e496 to look doc ---- -[带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7044843310204059655) +[带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7044841692008038431) #### 线上文档: -[带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7044843310204059655) +[带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7044841692008038431) #### 开发接口和nacos地址 [swager文档地址](http://8.135.1.141/micro-service-doc/swagger-ui.html) -[nacos地址](http://8.135.1.141:8848/nacos/) naocs: 用户名:jzfai; 密码:123456 +[nacos地址](http://8.135.1.141:8848/nacos/) + +naocs: 用户名:jzfai; 密码:123456 #### 线上体验地址: diff --git a/README.md b/README.md index 761f311..884ff1f 100644 --- a/README.md +++ b/README.md @@ -46,17 +46,19 @@ https://www.jianshu.com/p/fec054f3e496 to look doc ---- -[带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7044843310204059655) +[带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7044841692008038431) ## online documentation -[带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7044843310204059655) +[带你用springcloud微服务撸后台(系列文章入口)](https://juejin.cn/post/7044841692008038431) ## Interface documentation and nacos address [swager文档地址](http://8.135.1.141/micro-service-doc/swagger-ui.html) -[nacos地址](http://8.135.1.141:8848/nacos/) naocs: 用户名:jzfai; 密码:123456 +[nacos地址](http://8.135.1.141:8848/nacos/) + +naocs: 用户名:jzfai; 密码:123456 ## Online experience address From 7cd0e17e4df74cf6b6d3d50a26dc5e0ee7602c59 Mon Sep 17 00:00:00 2001 From: kuanghua <869653722@qq.com> Date: Sun, 26 Jun 2022 19:13:11 +0800 Subject: [PATCH 25/36] update springboot and springcloud version and add generator plateform --- .gitignore | 6 +- README-zh_CN.md | 33 +- README.md | 33 +- auth-pom/pom.xml | 32 + .../authpom}/controller/TokenController.java | 128 +- .../authpom/service/TokenService.java | 50 + .../kuanghua/authpom}/utils/JwtUtilsSelf.java | 188 +- {ty-auth => auth-pom}/src/main/main12.iml | 0 auth-pom/src/main/resources/application.yml | 11 + .../src/main/resources/bootstrap.yml | 56 +- .../src/main/resources/rsa.pri | Bin .../src/main/resources/rsa.pub | Bin {ty-example => basis-func}/pom.xml | 46 +- .../basisfunc/BasisFuncApplication.java | 17 + .../kuanghua/basisfunc/config/BaseConfig.java | 17 + .../config/Knife4jConfiguration.java | 39 + .../controller/DataBaseController.java | 48 + .../controller/GeneratorController.java | 115 + .../controller/GoFastDFSController.java | 7 +- .../basisfunc/mapper/DataBaseMapper.java | 35 + .../basisfunc/service/DataBaseService.java | 40 + .../service/GeneratorCustromService.java | 315 ++ .../basisfunc/service/GeneratorService.java | 232 ++ .../basisfunc/utils/GeneratorTempUtils.java | 353 ++ .../src/main/resources/application-db.yml | 39 + basis-func/src/main/resources/application.yml | 2 + basis-func/src/main/resources/bootstrap.yml | 15 + .../resources/mapper/RepairInfoMapper.xml | 69 + .../src/main/resources/velocity-tools.xml | 13 + .../service/GeneratorServiceTest.java | 180 + common-pom/pom.xml | 78 + .../commonpom}/config/FeignConfiguration.java | 6 +- .../config/MetaObjectHandlerConfig.java | 2 +- .../commonpom}/config/MybatisPlusConfig.java | 6 +- .../commonpom/entity/CommonPageParams.java | 18 +- .../commonpom}/entity/PageResult.java | 2 +- .../kuanghua/commonpom}/entity/ResResult.java | 18 +- .../commonpom/entity/SelfCommonParams.java | 8 +- .../commonpom}/entity/StatusCode.java | 2 +- .../exception/BaseExceptionHandler.java | 11 +- .../commonpom/feign/tyauth/TokenFeign.java | 43 + .../commonpom/utils/ObjSelfUtils.java | 178 + .../commonpom/utils/SelfObjUtils.java | 80 +- .../src/main/resources/application-main.yml | 17 + .../src/main/resources/config/banner.txt | 12 +- .../src/main/resources/config/emp.properties | 2 +- .../main/resources/logs/logback-spring.xml | 0 .../src/main/resources/spy.properties | 44 +- easycode-temp/controller.mv | 140 - easycode-temp/element-form.mv | 303 -- easycode-temp/element-table.mv | 300 -- easycode-temp/entity.mv | 56 - easycode-temp/mapper.mv | 19 - easycode-temp/service.mv | 54 - {ty-auth => gateway}/pom.xml | 37 +- .../kuanghua/gateway/GatewayApplication.java | 30 +- .../kuanghua/gateway/config/BaseConfig.java | 86 +- .../config/MySwaggerResourceProvider.java | 64 + .../controller/SwaggerResourceController.java | 24 + .../gateway}/filter/AuthorizeFilterAfter.java | 268 +- .../filter/AuthorizeFilterBefore.java | 227 +- gateway/src/main/resources/application.yml | 58 + gateway/src/main/resources/bootstrap.yml | 15 + integration-front/pom.xml | 29 +- .../IntegrationFrontApplication.java | 2 - .../integrationfront/config/BaseConfig.java | 22 +- .../config/Knife4jConfiguration.java | 39 + .../config/Swagger2Config.java | 56 - .../controller/BrandController.java | 6 +- .../controller/ErrorCollectionController.java | 6 +- .../controller/PairmentController.java | 89 + .../controller/UserController.java | 10 +- .../controller/VciController.java | 13 +- .../integrationfront/entity/Brand.java | 8 +- .../entity/ErrorCollection.java | 4 +- .../integrationfront/entity/Pairment.java | 63 + .../integrationfront/entity/Repair.java | 70 + .../integrationfront/entity/Replacement.java | 46 + .../integrationfront/entity/Role.java | 1 + .../integrationfront/excel/cv/VciTimeCv.java | 4 +- .../mapper/PairmentMapper.java | 18 + .../integrationfront/mapper/RepairMapper.java | 14 + .../mapper/ReplacementMapper.java | 14 + .../service/PairmentService.java | 76 + .../integrationfront/service/UserService.java | 26 +- .../integrationfront}/utils/CodecUtils.java | 4 +- .../integrationfront/vo/PairmentVo.java | 29 + .../src/main/resources/application-db.yml | 45 + .../src/main/resources/application-rabbit.yml | 8 + .../src/main/resources/application-redis.yml | 4 + .../src/main/resources/application-seata.yml | 26 + .../src/main/resources/application.yml | 2 + .../src/main/resources/bootstrap.yml | 37 +- .../src/main/resources/mapper/AdminMapper.xml | 107 +- .../main/resources/mapper/PairmentMapper.xml | 57 + nacos_config_export_20220115133818.zip | Bin 16104 -> 0 bytes pom.xml | 84 +- springboot-cloud-mapping.json | 113 - .../kuanghua/tyauth/config/BaseConfig.java | 21 - .../tyauth/config/Swagger2Config.java | 54 - .../controller/TestGetTokenController.java | 47 - .../kuanghua/tyauth/service/TokenService.java | 70 - ty-auth/src/main/resources/application.yml | 1 - ty-common/pom.xml | 142 - .../kuanghua/controller/HstrixController.java | 26 - .../integrationfront/feign/UserFeign.java | 15 - .../feign/tyauth/feign/TestGetTokenFeign.java | 14 - .../feign/tyauth/feign/TokenFeign.java | 45 - .../khcomomon/config/TokenParseInfo.java | 26 - .../khcomomon/config/TyCommonConfig.java | 25 - .../top/kuanghua/khcomomon/entity/BCrypt.java | 792 ----- .../kuanghua/khcomomon/entity/CacheKey.java | 24 - .../khcomomon/entity/CommonParamsSelf.java | 20 - .../kuanghua/khcomomon/entity/HttpClient.java | 170 - .../kuanghua/khcomomon/entity/IdWorker.java | 172 - .../top/kuanghua/khcomomon/entity/Result.java | 69 - .../khcomomon/utils/ChineseUtils.java | 65 - .../khcomomon/utils/DateUtilSelf.java | 164 - .../kuanghua/khcomomon/utils/IdWorker.java | 163 - .../top/kuanghua/khcomomon/utils/JwtUtil.java | 104 - .../khcomomon/utils/NumberUtilsSelf.java | 73 - .../khcomomon/utils/RandomValueUtil.java | 126 - .../khcomomon/utils/RedisClientUtils.java | 577 ---- .../kuanghua/khcomomon/utils/ThreadUtils.java | 13 - .../src/main/resources/application-dev.yml | 7 - .../src/main/resources/application-prod.yml | 7 - .../src/main/resources/application-test.yml | 7 - .../tyexample/ExampleApplication.java | 19 - .../kuanghua/tyexample/config/BaseConfig.java | 27 - .../tyexample/config/RabbitDelayConfig.java | 67 - .../tyexample/config/SmsProperties.java | 25 - .../tyexample/config/Swagger2Config.java | 55 - .../controller/GetTokenFromOtherService.java | 35 - .../controller/HystrixRibbonController.java | 31 - .../controller/RabbitDelayController.java | 35 - .../controller/RedisTestController.java | 131 - .../controller/SeataTestController.java | 30 - .../controller/SendEmailController.java | 50 - .../tyexample/entity/ErrorCollection.java | 36 - .../listener/CanalDataEventListener.java | 53 - .../listener/RabbitDelayListener.java | 29 - .../tyexample/listener/SmsListener.java | 50 - .../mapper/ErrorCollectionMapper.java | 9 - .../tyexample/service/RabbitDelayService.java | 33 - .../tyexample/service/SeataTestService.java | 26 - .../tyexample/service/SendEmailService.java | 99 - .../tyexample/service/SendMsgService.java | 42 - .../tyexample/service/UploadService.java | 92 - .../tyexample/utils/SendSmsUtils.java | 54 - ty-example/src/main/resources/bootstrap.yml | 46 - .../service/CacheAvalancheServiceTest.java | 32 - ty-gateway/pom.xml | 44 - ty-gateway/ty-gateway-one/pom.xml | 39 - .../gatewaytwo/config/BaseConfig.java | 23 - .../gatewaytwo/config/JwtProperties.java | 54 - .../SpecialHystrixGatewayFilterFactory.java | 241 -- .../gatewaytwo/config/SwaggerDocConfig.java | 21 - .../gatewaytwo/config/SwaggerHandler.java | 49 - .../config/SwaggerHeaderFilter.java | 34 - .../gatewaytwo/config/SwaggerProvider.java | 62 - .../gatewaytwo/utils/ChangeObjectUtils.java | 38 - .../kuanghua/gatewaytwo/utils/JwtUtilsKh.java | 42 - .../kuanghua/gatewaytwo/utils/RsaUtils.java | 92 - .../src/main/resources/application.yml | 0 .../src/main/resources/bootstrap.yml | 38 - .../mybatis-plus-multb/controllerMul.vm | 75 + .../back-vms/mybatis-plus-multb/entity.vm | 37 + .../back-vms/mybatis-plus-multb/entityMul.vm | 29 + .../back-vms/mybatis-plus-multb/entityVo.vm | 19 + .../back-vms/mybatis-plus-multb/mapper.vm | 10 + .../back-vms/mybatis-plus-multb/mapperMul.vm | 16 + .../back-vms/mybatis-plus-multb/serviceMul.vm | 57 + .../back-vms/mybatis-plus-multb/utils.vm | 8 + .../back-vms/mybatis-plus-multb/xmlMul.vm | 60 + .../back-vms/mybatis-plus/controller.vm | 112 + .../back-vms/mybatis-plus/entity.vm | 37 + .../back-vms/mybatis-plus/mapper.vm | 10 + .../back-vms/mybatis-plus/service.vm | 42 + .../back-vms/mybatis-plus/utils.vm | 6 + .../back-vms/mybatis-plus/xml.vm | 0 .../front-vms/element-plus/CRUD.vm | 96 + .../front-vms/element-plus/CRUDForm.vm | 87 + .../front-vms/element-plus/formUtils.vm | 268 ++ .../front-vms/element-plus/queryUtils.vm | 139 + .../front-vms/element-plus/tableUtils.vm | 214 ++ .../front-vms/element-plus/utils.vm | 30 + velocity-tmp-dir/json-data/brandData.json | 135 + velocity-tmp-dir/json-data/cascadeData.json | 16 + velocity-tmp-dir/json-data/data.json | 192 + .../json-data/multiTableData.json | 3076 +++++++++++++++++ velocity-tmp-dir/json-data/tb_brand.json | 877 +++++ 191 files changed, 9202 insertions(+), 6827 deletions(-) create mode 100644 auth-pom/pom.xml rename {ty-auth/src/main/java/top/kuanghua/tyauth => auth-pom/src/main/java/top/kuanghua/authpom}/controller/TokenController.java (89%) create mode 100644 auth-pom/src/main/java/top/kuanghua/authpom/service/TokenService.java rename {ty-auth/src/main/java/top/kuanghua/tyauth => auth-pom/src/main/java/top/kuanghua/authpom}/utils/JwtUtilsSelf.java (95%) rename {ty-auth => auth-pom}/src/main/main12.iml (100%) create mode 100644 auth-pom/src/main/resources/application.yml rename {ty-auth => auth-pom}/src/main/resources/bootstrap.yml (92%) rename {ty-auth => auth-pom}/src/main/resources/rsa.pri (100%) rename {ty-auth => auth-pom}/src/main/resources/rsa.pub (100%) rename {ty-example => basis-func}/pom.xml (63%) create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/BasisFuncApplication.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/config/BaseConfig.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/config/Knife4jConfiguration.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/controller/DataBaseController.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/controller/GeneratorController.java rename {ty-example/src/main/java/top/kuanghua/tyexample => basis-func/src/main/java/top/kuanghua/basisfunc}/controller/GoFastDFSController.java (89%) create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/mapper/DataBaseMapper.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/service/DataBaseService.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorCustromService.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorService.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java create mode 100644 basis-func/src/main/resources/application-db.yml create mode 100644 basis-func/src/main/resources/application.yml create mode 100644 basis-func/src/main/resources/bootstrap.yml create mode 100644 basis-func/src/main/resources/mapper/RepairInfoMapper.xml create mode 100644 basis-func/src/main/resources/velocity-tools.xml create mode 100644 basis-func/src/test/java/top/kuanghua/basisfunc/service/GeneratorServiceTest.java create mode 100644 common-pom/pom.xml rename {ty-common/src/main/java/top/kuanghua/feign => common-pom/src/main/java/top/kuanghua/commonpom}/config/FeignConfiguration.java (89%) rename {ty-common/src/main/java/top/kuanghua/khcomomon => common-pom/src/main/java/top/kuanghua/commonpom}/config/MetaObjectHandlerConfig.java (95%) rename {ty-common/src/main/java/top/kuanghua/khcomomon => common-pom/src/main/java/top/kuanghua/commonpom}/config/MybatisPlusConfig.java (97%) rename ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonPageParams.java => common-pom/src/main/java/top/kuanghua/commonpom/entity/CommonPageParams.java (68%) rename {ty-common/src/main/java/top/kuanghua/khcomomon => common-pom/src/main/java/top/kuanghua/commonpom}/entity/PageResult.java (93%) rename {ty-common/src/main/java/top/kuanghua/khcomomon => common-pom/src/main/java/top/kuanghua/commonpom}/entity/ResResult.java (69%) rename ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonParams.java => common-pom/src/main/java/top/kuanghua/commonpom/entity/SelfCommonParams.java (62%) rename {ty-common/src/main/java/top/kuanghua/khcomomon => common-pom/src/main/java/top/kuanghua/commonpom}/entity/StatusCode.java (92%) rename {ty-common/src/main/java/top/kuanghua/khcomomon => common-pom/src/main/java/top/kuanghua/commonpom}/exception/BaseExceptionHandler.java (80%) create mode 100644 common-pom/src/main/java/top/kuanghua/commonpom/feign/tyauth/TokenFeign.java create mode 100644 common-pom/src/main/java/top/kuanghua/commonpom/utils/ObjSelfUtils.java rename ty-common/src/main/java/top/kuanghua/khcomomon/utils/ObjectUtilsSelf.java => common-pom/src/main/java/top/kuanghua/commonpom/utils/SelfObjUtils.java (64%) create mode 100644 common-pom/src/main/resources/application-main.yml rename {ty-common => common-pom}/src/main/resources/config/banner.txt (98%) rename {ty-common => common-pom}/src/main/resources/config/emp.properties (91%) rename {ty-common => common-pom}/src/main/resources/logs/logback-spring.xml (100%) rename {ty-common => common-pom}/src/main/resources/spy.properties (98%) delete mode 100644 easycode-temp/controller.mv delete mode 100644 easycode-temp/element-form.mv delete mode 100644 easycode-temp/element-table.mv delete mode 100644 easycode-temp/entity.mv delete mode 100644 easycode-temp/mapper.mv delete mode 100644 easycode-temp/service.mv rename {ty-auth => gateway}/pom.xml (53%) rename ty-auth/src/main/java/top/kuanghua/tyauth/AuthApplication.java => gateway/src/main/java/top/kuanghua/gateway/GatewayApplication.java (58%) rename ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/GatewayOneApplication.java => gateway/src/main/java/top/kuanghua/gateway/config/BaseConfig.java (57%) create mode 100644 gateway/src/main/java/top/kuanghua/gateway/config/MySwaggerResourceProvider.java create mode 100644 gateway/src/main/java/top/kuanghua/gateway/controller/SwaggerResourceController.java rename {ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo => gateway/src/main/java/top/kuanghua/gateway}/filter/AuthorizeFilterAfter.java (85%) rename {ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo => gateway/src/main/java/top/kuanghua/gateway}/filter/AuthorizeFilterBefore.java (81%) create mode 100644 gateway/src/main/resources/application.yml create mode 100644 gateway/src/main/resources/bootstrap.yml create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/config/Knife4jConfiguration.java delete mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/config/Swagger2Config.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/controller/PairmentController.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/entity/Pairment.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/entity/Repair.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/entity/Replacement.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/mapper/PairmentMapper.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/mapper/RepairMapper.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/mapper/ReplacementMapper.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/service/PairmentService.java rename {ty-common/src/main/java/top/kuanghua/khcomomon => integration-front/src/main/java/top/kuanghua/integrationfront}/utils/CodecUtils.java (88%) create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/vo/PairmentVo.java create mode 100644 integration-front/src/main/resources/application-db.yml create mode 100644 integration-front/src/main/resources/application-rabbit.yml create mode 100644 integration-front/src/main/resources/application-redis.yml create mode 100644 integration-front/src/main/resources/application-seata.yml create mode 100644 integration-front/src/main/resources/mapper/PairmentMapper.xml delete mode 100644 nacos_config_export_20220115133818.zip delete mode 100644 springboot-cloud-mapping.json delete mode 100644 ty-auth/src/main/java/top/kuanghua/tyauth/config/BaseConfig.java delete mode 100644 ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java delete mode 100644 ty-auth/src/main/java/top/kuanghua/tyauth/controller/TestGetTokenController.java delete mode 100644 ty-auth/src/main/java/top/kuanghua/tyauth/service/TokenService.java delete mode 100644 ty-auth/src/main/resources/application.yml delete mode 100644 ty-common/pom.xml delete mode 100644 ty-common/src/main/java/top/kuanghua/controller/HstrixController.java delete mode 100644 ty-common/src/main/java/top/kuanghua/feign/integrationfront/feign/UserFeign.java delete mode 100644 ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TestGetTokenFeign.java delete mode 100644 ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TokenFeign.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/config/TokenParseInfo.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/config/TyCommonConfig.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/entity/BCrypt.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/entity/CacheKey.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/entity/CommonParamsSelf.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/entity/HttpClient.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/entity/IdWorker.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/entity/Result.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/utils/ChineseUtils.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/utils/DateUtilSelf.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/utils/IdWorker.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/utils/JwtUtil.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/utils/NumberUtilsSelf.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/utils/RandomValueUtil.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/utils/RedisClientUtils.java delete mode 100644 ty-common/src/main/java/top/kuanghua/khcomomon/utils/ThreadUtils.java delete mode 100644 ty-common/src/main/resources/application-dev.yml delete mode 100644 ty-common/src/main/resources/application-prod.yml delete mode 100644 ty-common/src/main/resources/application-test.yml delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/config/RabbitDelayConfig.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/config/SmsProperties.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/GetTokenFromOtherService.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/HystrixRibbonController.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/RabbitDelayController.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/SeataTestController.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/controller/SendEmailController.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/entity/ErrorCollection.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/listener/CanalDataEventListener.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/listener/RabbitDelayListener.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/listener/SmsListener.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/mapper/ErrorCollectionMapper.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/service/RabbitDelayService.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/service/SendEmailService.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/service/SendMsgService.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java delete mode 100644 ty-example/src/main/java/top/kuanghua/tyexample/utils/SendSmsUtils.java delete mode 100644 ty-example/src/main/resources/bootstrap.yml delete mode 100644 ty-example/src/test/java/top/kuanghua/tyexample/service/CacheAvalancheServiceTest.java delete mode 100644 ty-gateway/pom.xml delete mode 100644 ty-gateway/ty-gateway-one/pom.xml delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/BaseConfig.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/JwtProperties.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SpecialHystrixGatewayFilterFactory.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerDocConfig.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHandler.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHeaderFilter.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerProvider.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/ChangeObjectUtils.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/JwtUtilsKh.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/RsaUtils.java delete mode 100644 ty-gateway/ty-gateway-one/src/main/resources/application.yml delete mode 100644 ty-gateway/ty-gateway-one/src/main/resources/bootstrap.yml create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multb/controllerMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multb/entity.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multb/entityMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multb/entityVo.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multb/mapper.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multb/mapperMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multb/serviceMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multb/utils.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multb/xmlMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus/controller.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus/entity.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus/mapper.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus/service.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus/utils.vm rename ty-example/src/main/resources/application.yml => velocity-tmp-dir/back-vms/mybatis-plus/xml.vm (100%) create mode 100644 velocity-tmp-dir/front-vms/element-plus/CRUD.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/CRUDForm.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/formUtils.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/queryUtils.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/tableUtils.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/utils.vm create mode 100644 velocity-tmp-dir/json-data/brandData.json create mode 100644 velocity-tmp-dir/json-data/cascadeData.json create mode 100644 velocity-tmp-dir/json-data/data.json create mode 100644 velocity-tmp-dir/json-data/multiTableData.json create mode 100644 velocity-tmp-dir/json-data/tb_brand.json diff --git a/.gitignore b/.gitignore index 67f963d..6bb120a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,11 @@ .history .idea +target node_modules .DS_Store dist dist-ssr *.local -target -*.iml \ No newline at end of file +yarn* +pnpm* +coverage diff --git a/README-zh_CN.md b/README-zh_CN.md index 1322dab..7f52489 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -11,16 +11,11 @@ 本架构为springCloud微服务架构,提供基本的jwt权限认证,token更新,以及各微服务之间调用,以及提供企业级的使用例子 ```text -spring-boot:2.1.4.RELEASE -spring-cloud:Greenwich.SR1 -spring-cloud-starter-gateway:2.1.1.RELEASE -nacos:2.1.3.RELEASE -mybatis-plus:3.3.2 -rabbitmq:3.7-management -redis:3.2.9 +spring-boot:2.4.13 +spring-cloud:2020.0.5 +mybatis-plus: 3.3.2 mysql:5.7 -seata:1.4.2 -canal:1.2.1 +knife4j:2.0.9 ``` > 以上部分版本后续会升级 @@ -49,7 +44,7 @@ to look doc ---- #### 开发接口和nacos地址 -[swager文档地址](http://8.135.1.141/micro-service-doc/swagger-ui.html) +[swager文档地址](https://github.jzfai.top/micro-service-doc/doc.html) [nacos地址](http://8.135.1.141:8848/nacos/) @@ -67,16 +62,17 @@ github 地址: https://github.com/jzfai/micro-service-plus.git #### 目前实现的微服务(后续还会新增新的微服务) -##### ty - gateway - one +##### gateway: 网关微服务。使用的是spring - cloud - starter - gateway,相对于zull网关来说性能更好。主要实现了,权限控制和拦截,jwt token解析和校验, swagger文件整合,使用令牌技术请求限流等。可启动多个实例 -##### ty - auth + +##### auth-pom 权限服务。jwt token生成,解析,校验等,默认配置3天有效期,少于一天自动续约 -##### ty - example +##### basic-func: 提供一些例子。包括,rabbitmq延时队列,goFastDFS文件上传,canal, seata分部式事务,短信发送,邮件发送等。 @@ -84,9 +80,9 @@ swagger文件整合,使用令牌技术请求限流等。可启动多个实例 数据整合。vue3 - admin - plus 数据来源 -##### easycode - temp +##### velocity-tmp-dir -easycode前后端模板 +velocity 前后端模板 #### 如何运行 @@ -95,6 +91,7 @@ easycode前后端模板 ``` git clone https://github.com/jzfai/micro-service-plus.git //maven 下载依赖,即可运行 +建议先运行下 maven insall 避免出现依赖不在情况 ``` 如何配合vue3-admin-plus ,前后端一起开发 @@ -107,9 +104,9 @@ pnpm i pnpm run test #micro-service-plus 至少需要运行 -ty-auth -ty-gateway-one -ty-integration-front +basic-func +gateway +integration-front 以上三个服务 ``` diff --git a/README.md b/README.md index 884ff1f..c039d60 100644 --- a/README.md +++ b/README.md @@ -10,23 +10,16 @@ this architecture is the springCloud microservice architecture, which provides b token update, and calls between microservices, as well as enterprise-level usage examples. ```text -spring-boot:2.1.4.RELEASE -spring-cloud:Greenwich.SR1 -spring-cloud-starter-gateway:2.1.1.RELEASE -nacos:2.1.3.RELEASE +spring-boot:2.4.13 +spring-cloud:2020.0.5 mybatis-plus: 3.3.2 -rabbitmq:3.7-management -redis: 3.2.9 mysql:5.7 -seata:1.4.2 -canal:1.2.1 +knife4j:2.0.9 ``` > some of the above versions will be upgraded in the future -## Doc and Example - -[swager文档地址](http://8.135.1.141/micro-service-doc/swagger-ui.html) +## Example ![1642222390648](http://8.135.1.141/file/micro-service-assets/1642222390648.png) @@ -54,10 +47,9 @@ to look doc ---- ## Interface documentation and nacos address -[swager文档地址](http://8.135.1.141/micro-service-doc/swagger-ui.html) - -[nacos地址](http://8.135.1.141:8848/nacos/) +[swager文档地址](https://github.jzfai.top/micro-service-doc/doc.html) +[nacos地址](https://github.jzfai.top/nacos/) naocs: 用户名:jzfai; 密码:123456 ## Online experience address @@ -72,19 +64,19 @@ github 地址: https://github.com/jzfai/micro-service-plus.git ## Introduction to Microservices -##### ty-gateway-one: +##### gateway: gateway Microservices. The spring-cloud-starter-gateway is used, which has better performance than the zull gateway. It mainly implements permission control and interception, jwt token parsing and verification, swagger file integration, and request current limiting using token technology. Can start multiple -##### ty-auth: +##### auth-pom: permission service. jwt token generation, parsing, verification, etc., the default configuration is valid for 3 days, and the contract is automatically renewed if it is less than one day (if you are interested here, you can view the source code) -##### ty-example: +##### basic-func: provide some examples. Including, rabbitmq delay queue, goFastDFS file upload, canal, seata partial transaction, SMS sending, mail sending, etc. @@ -112,11 +104,12 @@ pnpm i pnpm run test #micro-service-plus At least need to run -ty-auth -ty-gateway-one -ty-integration-front +basic-func +gateway +integration-front The above three service +建议先运行下 maven insall 避免出现依赖不在情况 ``` > Note: Select the environment in Maven Projects->Profies. Currently online is a package built in the prod environment, please do not select. diff --git a/auth-pom/pom.xml b/auth-pom/pom.xml new file mode 100644 index 0000000..74210e2 --- /dev/null +++ b/auth-pom/pom.xml @@ -0,0 +1,32 @@ + + + + micro-service-plus + top.kuanghua + 1.0-SNAPSHOT + + 4.0.0 + + auth-pom + + + + top.kuanghua + common-pom + 1.0-SNAPSHOT + + + io.jsonwebtoken + jjwt + 0.9.0 + + + + com.github.xiaoymin + knife4j-aggregation-spring-boot-starter + 2.0.9 + + + \ No newline at end of file diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TokenController.java b/auth-pom/src/main/java/top/kuanghua/authpom/controller/TokenController.java similarity index 89% rename from ty-auth/src/main/java/top/kuanghua/tyauth/controller/TokenController.java rename to auth-pom/src/main/java/top/kuanghua/authpom/controller/TokenController.java index 12e59ca..f04f5a3 100644 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TokenController.java +++ b/auth-pom/src/main/java/top/kuanghua/authpom/controller/TokenController.java @@ -1,64 +1,64 @@ -package top.kuanghua.tyauth.controller; - -import io.jsonwebtoken.Claims; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.tyauth.service.TokenService; - -import java.util.Map; - -/** - * @Title: TokenController - * @Description: - * @Auther: kuanghua - * @create 2021/1/31 16:31 - */ - -@RestController -@RequestMapping("token") -@Api(tags = "token相关") -@Slf4j -public class TokenController { - - @Autowired - private TokenService tokenService; - - /* - * 解析token - * */ - @ApiOperation("获取token信息") - @PostMapping("parseToken") - public ResResult parseToken(@RequestParam("jwtToken") String jwtToken) { - Claims claims = this.tokenService.parseToken(jwtToken); - return new ResResult().success(claims); - } - - /* - * 生成token - * */ - @ApiOperation("生成token") - @PostMapping("generateToken") - //@RequestHeader("authorize_token") String authorize_token - public ResResult generateToken(@RequestBody Map tokenMap) { - String generateToken = this.tokenService.generateToken(tokenMap); - return new ResResult().success(generateToken); - } - - /* - * 更新token - * */ - @ApiOperation("更新token") - @PostMapping("updateToken") - public ResResult updateToken(@RequestBody Map map) { - String updateToken = this.tokenService.updateToken(map); -// System.out.println("生成信息的token"+updateToken); -// System.out.println("生成信息的token"+map.toString()); - return new ResResult().success(updateToken); - } -} - - +package top.kuanghua.authpom.controller; + +import io.jsonwebtoken.Claims; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import top.kuanghua.authpom.service.TokenService; +import top.kuanghua.commonpom.entity.ResResult; + +import java.util.Map; + +/** + * @Title: TokenController + * @Description: + * @Auther: kuanghua + * @create 2021/1/31 16:31 + */ + +@RestController +@RequestMapping("token") +@Api(tags = "token相关") +@Slf4j +public class TokenController { + + @Autowired + private TokenService tokenService; + + /* + * 解析token + * */ + @ApiOperation("获取token信息") + @PostMapping("parseToken") + public ResResult parseToken(@RequestParam("jwtToken") String jwtToken) { + Claims claims = this.tokenService.parseToken(jwtToken); + return new ResResult().success(claims); + } + + /* + * 生成token + * */ + @ApiOperation("生成token") + @PostMapping("generateToken") + //@RequestHeader("authorize_token") String authorize_token + public ResResult generateToken(@RequestBody Map tokenMap) { + String generateToken = this.tokenService.generateToken(tokenMap); + return new ResResult().success(generateToken); + } + + /* + * 更新token + * */ + @ApiOperation("更新token") + @PostMapping("updateToken") + public ResResult updateToken(@RequestBody Map map) { + String updateToken = this.tokenService.updateToken(map); +// System.out.println("生成信息的token"+updateToken); +// System.out.println("生成信息的token"+map.toString()); + return new ResResult().success(updateToken); + } +} + + diff --git a/auth-pom/src/main/java/top/kuanghua/authpom/service/TokenService.java b/auth-pom/src/main/java/top/kuanghua/authpom/service/TokenService.java new file mode 100644 index 0000000..edb82d4 --- /dev/null +++ b/auth-pom/src/main/java/top/kuanghua/authpom/service/TokenService.java @@ -0,0 +1,50 @@ +package top.kuanghua.authpom.service; + +import io.jsonwebtoken.Claims; +import org.springframework.stereotype.Service; +import top.kuanghua.authpom.utils.JwtUtilsSelf; + +import java.util.Map; + +/** + * @Title: TokenService + * @Description: + * @Auther: kuanghua + * @create 2021/1/31 16:19 + */ +@Service +public class TokenService { + + private static final String AUTHORIZE_TOKEN = "AUTHORIZE_TOKEN"; + + public String generateToken(Map map) { + try { + return JwtUtilsSelf.createJWT(map, null); + } catch (Exception e) { + throw new RuntimeException("token生成有误"); + } + } + + /* + * 更新token + * */ + public String updateToken(Map map) { + try { + String updateToken = JwtUtilsSelf.createJWT(map, null); + return updateToken; + } catch (Exception e) { + throw new RuntimeException("token更新有误"); + } + } + /* + * 解析token + * */ + public Claims parseToken(String jwtToken) { + try { + Claims claims = JwtUtilsSelf.parseJWT(jwtToken); + return claims; + } catch (Exception e) { + throw new RuntimeException("token解析错误"); + } + } +} diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/utils/JwtUtilsSelf.java b/auth-pom/src/main/java/top/kuanghua/authpom/utils/JwtUtilsSelf.java similarity index 95% rename from ty-auth/src/main/java/top/kuanghua/tyauth/utils/JwtUtilsSelf.java rename to auth-pom/src/main/java/top/kuanghua/authpom/utils/JwtUtilsSelf.java index 7c482af..476819b 100644 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/utils/JwtUtilsSelf.java +++ b/auth-pom/src/main/java/top/kuanghua/authpom/utils/JwtUtilsSelf.java @@ -1,94 +1,94 @@ -package top.kuanghua.tyauth.utils; - -import io.jsonwebtoken.Claims; -import io.jsonwebtoken.JwtBuilder; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; - -import javax.crypto.SecretKey; -import javax.crypto.spec.SecretKeySpec; -import java.util.Base64; -import java.util.Date; -import java.util.Map; - -/** - * 描述 - * - * @author kuanghua - * @version 1.0 - * @package entity * - * @since 1.0 - */ -public class JwtUtilsSelf { - - //https://www.cnblogs.com/passedbylove/p/11207827.html - //有效期为 - public static final Long JWT_TTL = 259200000L;//60 * 60 * 1000 * 24 * 3 三天 - //Jwt令牌信息 - public static final String JWT_KEY = "kh@Login(Auth}*^31)&kuanghua%"; - - /** - * 生成令牌 - * //* @param id - * //* @param subject - * - * @param ttlMillis - * @return - */ - public static String createJWT(Map userInfo, Long ttlMillis) { - //指定算法 - SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; - //当前系统时间 - long nowMillis = System.currentTimeMillis(); - //令牌签发时间 - Date now = new Date(nowMillis); - //如果令牌有效期为null,则默认设置有效期1小时 - if (ttlMillis == null) { - ttlMillis = JwtUtilsSelf.JWT_TTL; - } - //令牌过期时间设置 - long expMillis = nowMillis + ttlMillis; - Date expDate = new Date(expMillis); - - //生成秘钥 - SecretKey secretKey = generalKey(); - - //封装Jwt令牌信息 - JwtBuilder builder = Jwts.builder() - //.setId(id) - //.setSubject(subject) // 主题 可以是JSON数据 - //.setIssuer("admin") // 签发者 - .setIssuedAt(now) // 签发时间 - .signWith(signatureAlgorithm, secretKey) // 签名算法以及密匙 - .setExpiration(expDate); // 设置过期时间 - - JwtBuilder jwtBuilder = builder.addClaims(userInfo); - return builder.compact(); - } - - /** - * 生成加密 secretKey - * - * @return - */ - public static SecretKey generalKey() { - byte[] encodedKey = Base64.getEncoder().encode(JwtUtilsSelf.JWT_KEY.getBytes()); - SecretKey key = new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES"); - return key; - } - - /** - * 解析令牌数据 - * - * @param jwt - * @return - * @throws Exception - */ - public static Claims parseJWT(String jwt) throws Exception { - SecretKey secretKey = generalKey(); - return Jwts.parser() - .setSigningKey(secretKey) - .parseClaimsJws(jwt) - .getBody(); - } -} +package top.kuanghua.authpom.utils; + +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.JwtBuilder; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; + +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import java.util.Base64; +import java.util.Date; +import java.util.Map; + +/** + * 描述 + * + * @author kuanghua + * @version 1.0 + * @package entity * + * @since 1.0 + */ +public class JwtUtilsSelf { + + //https://www.cnblogs.com/passedbylove/p/11207827.html + //有效期为 + public static final Long JWT_TTL = 259200000L;//60 * 60 * 1000 * 24 * 3 三天 + //Jwt令牌信息 + public static final String JWT_KEY = "kh@Login(Auth}*^31)&kuanghua%"; + + /** + * 生成令牌 + * //* @param id + * //* @param subject + * + * @param ttlMillis + * @return + */ + public static String createJWT(Map userInfo, Long ttlMillis) { + //指定算法 + SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; + //当前系统时间 + long nowMillis = System.currentTimeMillis(); + //令牌签发时间 + Date now = new Date(nowMillis); + //如果令牌有效期为null,则默认设置有效期1小时 + if (ttlMillis == null) { + ttlMillis = JwtUtilsSelf.JWT_TTL; + } + //令牌过期时间设置 + long expMillis = nowMillis + ttlMillis; + Date expDate = new Date(expMillis); + + //生成秘钥 + SecretKey secretKey = generalKey(); + + //封装Jwt令牌信息 + JwtBuilder builder = Jwts.builder() + //.setId(id) + //.setSubject(subject) // 主题 可以是JSON数据 + //.setIssuer("admin") // 签发者 + .setIssuedAt(now) // 签发时间 + .signWith(signatureAlgorithm, secretKey) // 签名算法以及密匙 + .setExpiration(expDate); // 设置过期时间 + + JwtBuilder jwtBuilder = builder.addClaims(userInfo); + return builder.compact(); + } + + /** + * 生成加密 secretKey + * + * @return + */ + public static SecretKey generalKey() { + byte[] encodedKey = Base64.getEncoder().encode(JwtUtilsSelf.JWT_KEY.getBytes()); + SecretKey key = new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES"); + return key; + } + + /** + * 解析令牌数据 + * + * @param jwt + * @return + * @throws Exception + */ + public static Claims parseJWT(String jwt) throws Exception { + SecretKey secretKey = generalKey(); + return Jwts.parser() + .setSigningKey(secretKey) + .parseClaimsJws(jwt) + .getBody(); + } +} diff --git a/ty-auth/src/main/main12.iml b/auth-pom/src/main/main12.iml similarity index 100% rename from ty-auth/src/main/main12.iml rename to auth-pom/src/main/main12.iml diff --git a/auth-pom/src/main/resources/application.yml b/auth-pom/src/main/resources/application.yml new file mode 100644 index 0000000..d3a13fc --- /dev/null +++ b/auth-pom/src/main/resources/application.yml @@ -0,0 +1,11 @@ +server: + port: ${envpt.tomcatPortPre}0131 + +#jwt相关 +jwt-properties: + secret: kh@Login(Auth}*^31)&kuanghua% # 登录校验的密钥(盐) + # 60 * 60 * 1000 * 24 * 3 三天 + expire: 259200000L; + + + diff --git a/ty-auth/src/main/resources/bootstrap.yml b/auth-pom/src/main/resources/bootstrap.yml similarity index 92% rename from ty-auth/src/main/resources/bootstrap.yml rename to auth-pom/src/main/resources/bootstrap.yml index bc12133..f32e54b 100644 --- a/ty-auth/src/main/resources/bootstrap.yml +++ b/auth-pom/src/main/resources/bootstrap.yml @@ -1,29 +1,29 @@ -spring: - application: - name: @project.artifactId@ - profiles: - active: @activatedProperties@ - cloud: - nacos: - config: - enabled: true - namespace: @nacosNamespace@ - group: @nacosGroup@ - username: @nacosUsername@ - password: @nacosPassword@ - server-addr: @nacosIpPort@ - prefix: @project.artifactId@ - file-extension: yml - # 用于共享的配置文件 - shared-configs: - - data-id: application-main.yml - group: @nacosGroup@ - refresh: true - discovery: - namespace: @nacosNamespace@ - group: @nacosGroup@ - username: @nacosUsername@ - password: @nacosPassword@ - server-addr: @nacosIpPort@ - weight: @nacosWeight@ +spring: + application: + name: @project.artifactId@ + profiles: + active: @activatedProperties@,main + cloud: + nacos: + config: + enabled: true + namespace: @nacosNamespace@ + group: @nacosGroup@ + username: @nacosUsername@ + password: @nacosPassword@ + server-addr: @nacosIpPort@ + prefix: @project.artifactId@ + file-extension: yml + # 用于共享的配置文件 + shared-configs: + - data-id: application-main.yml + group: @nacosGroup@ + refresh: true + discovery: + namespace: @nacosNamespace@ + group: @nacosGroup@ + username: @nacosUsername@ + password: @nacosPassword@ + server-addr: @nacosIpPort@ + weight: @nacosWeight@ ip: @nacosDiscoveryIp@ \ No newline at end of file diff --git a/ty-auth/src/main/resources/rsa.pri b/auth-pom/src/main/resources/rsa.pri similarity index 100% rename from ty-auth/src/main/resources/rsa.pri rename to auth-pom/src/main/resources/rsa.pri diff --git a/ty-auth/src/main/resources/rsa.pub b/auth-pom/src/main/resources/rsa.pub similarity index 100% rename from ty-auth/src/main/resources/rsa.pub rename to auth-pom/src/main/resources/rsa.pub diff --git a/ty-example/pom.xml b/basis-func/pom.xml similarity index 63% rename from ty-example/pom.xml rename to basis-func/pom.xml index b63dc78..7914137 100644 --- a/ty-example/pom.xml +++ b/basis-func/pom.xml @@ -1,6 +1,6 @@ - micro-service-plus @@ -9,47 +9,37 @@ 4.0.0 - ty-example + basis-func + + top.kuanghua - ty-common + common-pom 1.0-SNAPSHOT - - com.aliyun - aliyun-java-sdk-core - 4.5.3 + net.lingala.zip4j + zip4j + 2.9.1 - - org.springframework.boot - spring-boot-starter-mail + org.apache.velocity + velocity-engine-core + 2.3 - - - com.github.tobato - fastdfs-client - 1.27.2 + org.apache.velocity.tools + velocity-tools-generic + 3.1 - cn.hutool hutool-all 4.5.1 - - - - com.xpand - starter-canal - 0.0.1-SNAPSHOT - - ${project.artifactId} @@ -63,10 +53,14 @@ org.springframework.boot spring-boot-maven-plugin + + org.apache.maven.plugins + maven-resources-plugin + 3.1.0 + org.apache.maven.plugins maven-surefire-plugin - 2.22.1 true diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/BasisFuncApplication.java b/basis-func/src/main/java/top/kuanghua/basisfunc/BasisFuncApplication.java new file mode 100644 index 0000000..951cb74 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/BasisFuncApplication.java @@ -0,0 +1,17 @@ +package top.kuanghua.basisfunc; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @Title: VgApplication + * @Description: + * @Auther: kuanghua + * @create 2022/6/1 21:19 + */ +@SpringBootApplication +public class BasisFuncApplication { + public static void main(String[] args) { + SpringApplication.run(BasisFuncApplication.class, args); + } +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/config/BaseConfig.java b/basis-func/src/main/java/top/kuanghua/basisfunc/config/BaseConfig.java new file mode 100644 index 0000000..e869698 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/config/BaseConfig.java @@ -0,0 +1,17 @@ +package top.kuanghua.basisfunc.config; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + + +@Configuration +@ComponentScan(basePackages = { + "top.kuanghua.commonpom", + "top.kuanghua.basisfunc" +}) +@MapperScan(basePackages = {"top.kuanghua.basisfunc.mapper"}) +public class BaseConfig { + +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/config/Knife4jConfiguration.java b/basis-func/src/main/java/top/kuanghua/basisfunc/config/Knife4jConfiguration.java new file mode 100644 index 0000000..0c7ceda --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/config/Knife4jConfiguration.java @@ -0,0 +1,39 @@ +package top.kuanghua.basisfunc.config; + +import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; + +@Configuration +@EnableSwagger2WebMvc +@EnableKnife4j +public class Knife4jConfiguration { + @Bean + public Docket createRestApi() { + return new Docket(DocumentationType.SWAGGER_2) + .useDefaultResponseMessages(false) + .apiInfo(apiInfo()) + .select().apis(RequestHandlerSelectors.basePackage("top.kuanghua.basisfunc")) + .paths(PathSelectors.any()) + .build(); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .description("Kinfe4j 集成测试文档") + .contact(new Contact("熊猫哥", "https://github.com/jzfai/", "869653722@qq.com")) + .version("v1.1.0") + .title("API测试文档") + .build(); + } + +} + diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/controller/DataBaseController.java b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/DataBaseController.java new file mode 100644 index 0000000..1b5f96b --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/DataBaseController.java @@ -0,0 +1,48 @@ +package top.kuanghua.basisfunc.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import top.kuanghua.basisfunc.service.DataBaseService; +import top.kuanghua.commonpom.entity.ResResult; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Map; + +/** + * @Title: DataBaseController + * @Description: + * @Auther: kuanghua + * @create 2022/6/3 8:53 + */ +@Api(tags = "获取数据库表和字段信息") +@RestController +@RequestMapping("dataBase") +public class DataBaseController { + @Resource + private DataBaseService dataBaseService; + + @GetMapping("getAllDatabaseOrTable/{dbName}") + @ApiOperation(value = "mysql获取所有表") + public ResResult getAllTableFromDb(@PathVariable String dbName) { + ArrayList allTableFromDb = this.dataBaseService.getAllTableFromDb(dbName); + return new ResResult().success(allTableFromDb); + } + + /** + * @param dbName + * @param tbName + * @return + */ + @GetMapping("getAllDatabaseOrTable/{dbName}/{tbName}") + @ApiOperation(value = "mysql获取表及字段信息") + public ResResult getAllColumnFromTb(@PathVariable String dbName, @PathVariable String tbName) { + ArrayList allColumnFromTb = this.dataBaseService.getAllColumnFromTb(dbName, tbName); + return new ResResult().success(allColumnFromTb); + + } +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/controller/GeneratorController.java b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/GeneratorController.java new file mode 100644 index 0000000..2c07931 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/GeneratorController.java @@ -0,0 +1,115 @@ +package top.kuanghua.basisfunc.controller; + +import com.alibaba.fastjson.JSON; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import top.kuanghua.basisfunc.service.GeneratorCustromService; +import top.kuanghua.basisfunc.service.GeneratorService; +import top.kuanghua.basisfunc.utils.GeneratorTempUtils; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + +/** + * @author 猫哥 + * @email kuanghua@aulton.com + * @date 2022-06-06 13:39 + * @Copyright Copyright (c) aulton Inc. All Rights Reserved. + **/ +@Api(tags = "模板生成") +@RestController +@RequestMapping("generator") +public class GeneratorController { + @Resource + private GeneratorService generatorService; + + @Resource + private GeneratorCustromService generatorCustromService; + + @ApiOperation(value = "生成前后端模版") + @PostMapping("generatorFrontBackTempZip") + public void generatorFrontBackTempZip(HttpServletResponse response, @RequestBody Map generatorData) { + //生成模板 + String exportFilePath = this.generatorService.generatorFrontBackTempZip(generatorData); + response.setContentType("application/zip"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Access-Control-Expose-Headers", "exportFileName"); + response.setHeader("exportFileName", "font-back-temp-" + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"); + //你压缩包路径 + GeneratorTempUtils.downloadZip(response, exportFilePath); + } + + @ApiOperation(value = "生成前端模版") + @PostMapping("generatorFrontTempZip") + public void generatorFrontTempZip(HttpServletResponse response, @RequestBody Map generatorData) { + //生成模板 + String exportFilePath = this.generatorService.generatorFrontTempZip(generatorData); + response.setContentType("application/zip"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Access-Control-Expose-Headers", "exportFileName"); + response.setHeader("exportFileName", "front-temp-" + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"); + //你压缩包路径 + GeneratorTempUtils.downloadZip(response, exportFilePath); + } + + @ApiOperation(value = "生成后端模版") + @PostMapping("generatorBackTempZip") + public void generatorBackTempZip(HttpServletResponse response, @RequestBody Map generatorData) { + //生成模板 + String exportFilePath = this.generatorService.generatorBackTempZip(generatorData); + response.setContentType("application/zip"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Access-Control-Expose-Headers", "exportFileName"); + response.setHeader("exportFileName", "back-temp-" + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"); + //你压缩包路径 + GeneratorTempUtils.downloadZip(response, exportFilePath); + } + + /*自定义模版*/ + @ApiOperation(value = "生成前端自定义模版") + @PostMapping("generatorFrontCustomTemp") + public void generatorFrontCustomTemp(HttpServletResponse response, @RequestParam("file") List files, @RequestParam("jsonData") String jsonData) { + Map JsonMap = JSON.parseObject(jsonData, Map.class); + //生成模板 + String exportFilePath = generatorCustromService.generatorFrontCustomTemp(files, JsonMap); + response.setContentType("application/zip"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Access-Control-Expose-Headers", "exportFileName"); + response.setHeader("exportFileName", "custom-front-temp-" + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"); + //你压缩包路径 + GeneratorTempUtils.downloadZip(response, exportFilePath); + } + + @ApiOperation(value = "生成后端自定义模版") + @PostMapping("generatorBackCustomTemp") + public void generatorBackCustomTemp(HttpServletResponse response, @RequestParam("file") List files, @RequestParam("jsonData") String jsonData) { + Map JsonMap = JSON.parseObject(jsonData, Map.class); + //生成模板 + String exportFilePath = generatorCustromService.generatorBackCustomTemp(files, JsonMap); + response.setContentType("application/zip"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Access-Control-Expose-Headers", "exportFileName"); + response.setHeader("exportFileName", "custom-back-temp-" + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"); + //你压缩包路径 + GeneratorTempUtils.downloadZip(response, exportFilePath); + } + + @ApiOperation(value = "自定义生成模版(只提供数据源能力,导入的模版是什么则返回什么, 返回后会对模版里的插槽字段进行填充)") + @PostMapping("generatorCustomTemp") + public void generatorCustomTemp(HttpServletResponse response, @RequestParam("file") List files, @RequestParam("jsonData") String jsonData) { + Map JsonMap = JSON.parseObject(jsonData, Map.class); + //生成模板 + String exportFilePath = generatorCustromService.generatorCustomTemp(files, JsonMap); + response.setContentType("application/zip"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Access-Control-Expose-Headers", "exportFileName"); + response.setHeader("exportFileName", "custom-temp-" + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"); + //你压缩包路径 + GeneratorTempUtils.downloadZip(response, exportFilePath); + } +} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/GoFastDFSController.java b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/GoFastDFSController.java similarity index 89% rename from ty-example/src/main/java/top/kuanghua/tyexample/controller/GoFastDFSController.java rename to basis-func/src/main/java/top/kuanghua/basisfunc/controller/GoFastDFSController.java index 5f9e1a5..2d59264 100644 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/GoFastDFSController.java +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/GoFastDFSController.java @@ -1,4 +1,4 @@ -package top.kuanghua.tyexample.controller; +package top.kuanghua.basisfunc.controller; import cn.hutool.core.io.resource.InputStreamResource; import cn.hutool.http.HttpUtil; @@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.commonpom.entity.ResResult; import java.io.IOException; import java.util.HashMap; @@ -36,7 +36,8 @@ public ResResult goFastfdfs(@RequestParam("file") MultipartFile file) { InputStreamResource isr = new InputStreamResource(file.getInputStream(), file.getOriginalFilename()); Map params = new HashMap<>(); params.put("file", isr); - params.put("path", "86501729"); + params.put("name", file.getOriginalFilename()); + params.put("size", file.getSize()); params.put("output", "json"); String resp = HttpUtil.post("http://8.135.1.141:8080/group1/upload", params); Map coversMap = JSON.parseObject(resp, Map.class); diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/mapper/DataBaseMapper.java b/basis-func/src/main/java/top/kuanghua/basisfunc/mapper/DataBaseMapper.java new file mode 100644 index 0000000..955359c --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/mapper/DataBaseMapper.java @@ -0,0 +1,35 @@ +package top.kuanghua.basisfunc.mapper; + +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.ArrayList; +import java.util.Map; + +/** + * @Title: DataBaseMapper + * @Description: + * @Auther: kuanghua + * @create 2022/6/3 8:38 + */ +public interface DataBaseMapper { + + /** + * mysql获取所有表 + * + * @param dbName + * @return + */ + @Select("SELECT table_schema,table_name,table_comment,create_time,update_time FROM information_schema.tables WHERE TABLE_SCHEMA = #{dbName}") + ArrayList getAllTableFromDb(@Param("dbName") String dbName); + + + /** + * mysql获取表所有字段信息 + * + * @param tbName + * @return + */ + @Select("SELECT table_schema,table_name,column_name,is_nullable,data_type,column_type,column_key,extra,column_comment FROM INFORMATION_SCHEMA.COLUMNS COL Where TABLE_SCHEMA=#{dbName} AND COL.TABLE_NAME=#{tbName}") + ArrayList getAllColumnFromTb(@Param("dbName") String dbName, @Param("tbName") String tbName); +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/service/DataBaseService.java b/basis-func/src/main/java/top/kuanghua/basisfunc/service/DataBaseService.java new file mode 100644 index 0000000..2011e90 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/service/DataBaseService.java @@ -0,0 +1,40 @@ +package top.kuanghua.basisfunc.service; + +import org.springframework.stereotype.Service; +import top.kuanghua.basisfunc.mapper.DataBaseMapper; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Map; + +/** + * @Title: DataBaseService + * @Description: + * @Auther: kuanghua + * @create 2022/6/3 8:50 + * https://blog.csdn.net/qq_39323945/article/details/124661309 + */ +@Service +public class DataBaseService { + @Resource + private DataBaseMapper dataBaseMapper; + + /** + * @param dbName + * @return + */ + public ArrayList getAllTableFromDb(String dbName) { + ArrayList allTableFromDb = this.dataBaseMapper.getAllTableFromDb(dbName); + return allTableFromDb; + } + + /** + * @param dbName + * @param tbName + * @return + */ + public ArrayList getAllColumnFromTb(String dbName, String tbName) { + ArrayList allColumnFromTb = this.dataBaseMapper.getAllColumnFromTb(dbName, tbName); + return allColumnFromTb; + } +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorCustromService.java b/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorCustromService.java new file mode 100644 index 0000000..ce7496d --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorCustromService.java @@ -0,0 +1,315 @@ +package top.kuanghua.basisfunc.service; + +import com.alibaba.fastjson.JSON; +import org.apache.velocity.Template; +import org.apache.velocity.context.Context; +import org.jetbrains.annotations.NotNull; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; +import top.kuanghua.basisfunc.utils.GeneratorTempUtils; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @author 猫哥 + * @date 2022-06-06 13:31 + **/ +@Service +public class GeneratorCustromService { + + /** + * mybatis-plus多表生成模版 + */ + public void generatorMybatisPlusMulTemp(Map jsonData, String tmpSaveDir) { + Context context = getContext(jsonData); + Map dbTableConfig = ObjSelfUtils.changeToMap(jsonData.get("dbTableConfig")); + ArrayList> multiTableConfig = ObjSelfUtils.changeToArrayMap(jsonData.get("multiTableConfig")); + multiTableConfig.forEach((fItem) -> { + //entity + FileWriter entityWriter = null; + try { + Template entityTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "entity.vm"); + context.put("currentTbConfig", fItem); + context.put("tableFieldArr", fItem.get("tableFieldArr")); + entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("entity") + fItem.get("tableNameCase") + ".java"); + entityTemp.merge(context, entityWriter); + entityWriter.close(); + + //single-mapper + Template mapperTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "mapper.vm"); + FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("mapper") + fItem.get("tableNameCase") + "Mapper.java"); + mapperTemp.merge(context, mapperWriter); + mapperWriter.close(); + } catch (IOException e) { + throw new RuntimeException(" mybatis-plus多表生成模版报错" + e); + } + }); + String tbName = dbTableConfig.get("multiTableNameCase").toString(); + try { + //controller + Template controllerTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "controllerMul.vm"); + FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("controller") + tbName + "Controller.java"); + controllerTemp.merge(context, controllerWriter); + controllerWriter.close(); + //service + Template serviceTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "serviceMul.vm"); + FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("service") + tbName + "Service.java"); + serviceTemp.merge(context, serviceWriter); + serviceWriter.close(); + + //mul-entity + Template mapperMulTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "mapperMul.vm"); + FileWriter mapperMulWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("mapper") + tbName + "Mapper.java"); + mapperMulTemp.merge(context, mapperMulWriter); + mapperMulWriter.close(); + + //entity-vo + Template entityVoTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "entityVo.vm"); + FileWriter entityVoWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("vo") + tbName + "Vo.java"); + entityVoTemp.merge(context, entityVoWriter); + entityVoWriter.close(); + + //entity-mul + Template entityMulTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "entityMul.vm"); + FileWriter entityMulWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("entity") + tbName + ".java"); + entityMulTemp.merge(context, entityMulWriter); + entityMulWriter.close(); + //xml + Template xmlTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "xmlMul.vm"); + FileWriter xmlWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("xml") + tbName + "Mapper.xml"); + xmlTemp.merge(context, xmlWriter); + xmlWriter.close(); + + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + + } catch (IOException e) { + throw new RuntimeException("生成实体类报错" + e); + } + } + + @NotNull + private Context getContext(Map jsonData) { + Context context = GeneratorTempUtils.getVelocityContext(); + context.put("totalData", jsonData); + context.put("projectOrAuthor", jsonData.get("projectOrAuthor")); + context.put("multiTableConfig", jsonData.get("multiTableConfig")); + context.put("queryConfig", jsonData.get("queryConfig")); + context.put("tableConfig", jsonData.get("tableConfig")); + context.put("formConfig", jsonData.get("formConfig")); + context.put("dbTableConfig", jsonData.get("dbTableConfig")); + return context; + } + + /** + * Mybatis-plus单表生成模版 + */ + public void generatorMybatisPlusTemp(Map jsonData, String tmpSaveDir) { + try { + Context context = getContext(jsonData); + Map dbTableConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("dbTableConfig")), Map.class); + String tbName = dbTableConfig.get("tableNameCase").toString(); + //entity + Template entityTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "entity.vm"); + FileWriter entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("entity") + tbName + ".java"); + entityTemp.merge(context, entityWriter); + entityWriter.close(); + //controller + Template controllerTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "controller.vm"); + FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("controller") + tbName + "Controller.java"); + controllerTemp.merge(context, controllerWriter); + controllerWriter.close(); + //service + Template serviceTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "service.vm"); + FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("service") + tbName + "Service.java"); + serviceTemp.merge(context, serviceWriter); + serviceWriter.close(); + //mapper + Template mapperTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "mapper.vm"); + FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("mapper") + tbName + "Mapper.java"); + mapperTemp.merge(context, mapperWriter); + mapperWriter.close(); + } catch (IOException e) { + throw new RuntimeException("Mybatis-plus单表生成模版报错" + e); + } + } + + /** + * element-plus多表生成模版 + */ + public void generatorElementPlusTemp(Map jsonData, String tmpSaveDir) { + try { + Context context = getContext(jsonData); + Template template = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "CRUD.vm"); + FileWriter fileWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUD.vue"); + template.merge(context, fileWriter); + fileWriter.close(); + //第二个模板 + Template addModal = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "CRUDForm.vm"); + FileWriter addModalWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUDForm.vue"); + addModal.merge(context, addModalWriter); + addModalWriter.close(); + } catch (IOException e) { + throw new RuntimeException("element-plus多表生成模版报错" + e); + } + } + + /** + * 生成my模版 + * + * @param jsonData + * @return + */ + public String generatorBackTempZip(Map jsonData, String tmpSaveDir) { + Map commonConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("commonConfig")), Map.class); + if ("true".equals(commonConfig.get("isTableMulChoose").toString())) { + //生成前端模板 + generatorMybatisPlusMulTemp(jsonData, tmpSaveDir); + } else { + /*单表*/ + //生成前端模板 + generatorMybatisPlusTemp(jsonData, tmpSaveDir); + } + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + return exportFilePath; + } + + /** + * 生成前端模版 + * + * @param jsonData + * @return + */ + public String generatorFrontTempZip(Map jsonData, String tmpSaveDir) { + Map commonConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("commonConfig")), Map.class); + //多表 + if ("true".equals(commonConfig.get("isTableMulChoose").toString())) { + //生成前端模板 + generatorElementPlusTemp(jsonData, tmpSaveDir); + } else { + /*单表*/ + //生成前端模板 + generatorElementPlusTemp(jsonData, tmpSaveDir); + } + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + return exportFilePath; + } + +// /** +// * 生成前后端模版 +// * +// * @param jsonData +// * @return +// */ +// public String generatorFrontBackTempZip(Map jsonData, String tmpSaveDir) { +// Map commonConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("commonConfig")), Map.class); +// //多表 +// if ("true".equals(commonConfig.get("isTableMulChoose").toString())) { +// //生成前端模板 +// generatorElementPlusTemp(jsonData, tmpSaveDir); +// //生成后端模板 +// generatorMybatisPlusMulTemp(jsonData, tmpSaveDir); +// } else { +// /*单表*/ +// //生成前端模板 +// generatorElementPlusTemp(jsonData, tmpSaveDir); +// //生成后端模板 +// generatorMybatisPlusTemp(jsonData, tmpSaveDir); +// } +// +// String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; +// //生成zip包 +// GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); +// return exportFilePath; +// } + + /** + * 生成前端自定义模版 + * + * @param files + * @param jsonData + * @return + */ + public String generatorFrontCustomTemp(List files, Map jsonData) { + String tempSaveDir = getSaveDir(files); + String tempZip = generatorFrontTempZip(jsonData, tempSaveDir); + GeneratorTempUtils.deleteDir(tempSaveDir); + return tempZip; + } + + /** + * 生成后端自定义模版 + * + * @param files + * @param jsonData + * @return + */ + public String generatorBackCustomTemp(List files, Map jsonData) { + String tempSaveDir = getSaveDir(files); + String tempZip = generatorBackTempZip(jsonData, tempSaveDir); + GeneratorTempUtils.deleteDir(tempSaveDir); + return tempZip; + } + + + /** + * 接收文件并保存文件到本地 + * + * @param files + * @return 保存后的文件路径 + */ + private String getSaveDir(List files) { + String tmpSaveDir = GeneratorTempUtils.getTmpSaveDir(); + for (MultipartFile file : files) { + String filename = file.getOriginalFilename(); + File f = new File(tmpSaveDir + filename); + //保存文件 + try { + file.transferTo(f); + } catch (IOException e) { + e.printStackTrace(); + } + } + return tmpSaveDir; + } + + + /** + * 只提供数据源能力,导入的模版是什么则返回什么, 返回后会对模版里的插槽字段进行填充 + * + * @param files + * @param jsonData + * @return + */ + public String generatorCustomTemp(List files, Map jsonData) { + Context context = getContext(jsonData); + String tempSaveDir = getSaveDir(files); + files.forEach((file) -> { + String originalFilename = file.getOriginalFilename(); + Template xmlTemp = GeneratorTempUtils.getTmpSaveDirTemp(tempSaveDir, originalFilename); + try { + FileWriter xmlWriter = new FileWriter(GeneratorTempUtils.getExportFileDir() + originalFilename); + xmlTemp.merge(context, xmlWriter); + xmlWriter.close(); + } catch (IOException e) { + throw new RuntimeException("生成临时模版报错" + e); + } + }); + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + GeneratorTempUtils.deleteDir(tempSaveDir); + return exportFilePath; + } + +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorService.java b/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorService.java new file mode 100644 index 0000000..1ae5b40 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorService.java @@ -0,0 +1,232 @@ +package top.kuanghua.basisfunc.service; + +import com.alibaba.fastjson.JSON; +import org.apache.velocity.Template; +import org.apache.velocity.context.Context; +import org.springframework.stereotype.Service; +import top.kuanghua.basisfunc.utils.GeneratorTempUtils; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Map; + +/** + * @author 猫哥 + * @date 2022-06-06 13:31 + **/ +@Service +public class GeneratorService { + + /** + * mybatis-plus多表生成模版 + */ + public void generatorMybatisPlusMulTemp(Map jsonData) { + Context context = getContext(jsonData); + Map dbTableConfig = ObjSelfUtils.changeToMap(jsonData.get("dbTableConfig")); + ArrayList> multiTableConfig = ObjSelfUtils.changeToArrayMap(jsonData.get("multiTableConfig")); + multiTableConfig.forEach((fItem) -> { + //entity + FileWriter entityWriter = null; + try { + Template entityTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entity.vm"); + context.put("currentTbConfig", fItem); + context.put("tableFieldArr", fItem.get("tableFieldArr")); + entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("entity") + fItem.get("tableNameCase") + ".java"); + entityTemp.merge(context, entityWriter); + entityWriter.close(); + + //single-mapper + Template mapperTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("mapper.vm"); + FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("mapper") + fItem.get("tableNameCase") + "Mapper.java"); + mapperTemp.merge(context, mapperWriter); + mapperWriter.close(); + } catch (IOException e) { + throw new RuntimeException(" mybatis-plus多表生成模版报错" + e); + } + }); + String tbName = dbTableConfig.get("multiTableNameCase").toString(); + try { + //controller + Template controllerTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("controllerMul.vm"); + FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("controller") + tbName + "Controller.java"); + controllerTemp.merge(context, controllerWriter); + controllerWriter.close(); + //service + Template serviceTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("serviceMul.vm"); + FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("service") + tbName + "Service.java"); + serviceTemp.merge(context, serviceWriter); + serviceWriter.close(); + + //mul-entity + Template mapperMulTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("mapperMul.vm"); + FileWriter mapperMulWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("mapper") + tbName + "Mapper.java"); + mapperMulTemp.merge(context, mapperMulWriter); + mapperMulWriter.close(); + + //entity-vo + Template entityVoTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entityVo.vm"); + FileWriter entityVoWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("vo") + tbName + "Vo.java"); + entityVoTemp.merge(context, entityVoWriter); + entityVoWriter.close(); + + //entity-mul + Template entityMulTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entityMul.vm"); + FileWriter entityMulWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("entity") + tbName + ".java"); + entityMulTemp.merge(context, entityMulWriter); + entityMulWriter.close(); + //xml + Template xmlTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("xmlMul.vm"); + FileWriter xmlWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("xml") + tbName + "Mapper.xml"); + xmlTemp.merge(context, xmlWriter); + xmlWriter.close(); + + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + } catch (IOException e) { + throw new RuntimeException("生成实体类报错" + e); + } + } + + /** + * Mybatis-plus单表生成模版 + */ + public void generatorMybatisPlusTemp(Map jsonData) { + try { + Context context = getContext(jsonData); + Map dbTableConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("dbTableConfig")), Map.class); + String tbName = dbTableConfig.get("tableNameCase").toString(); + //entity + Template entityTemp = GeneratorTempUtils.getMybatisPlusTemp("entity.vm"); + FileWriter entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("entity") + tbName + ".java"); + entityTemp.merge(context, entityWriter); + entityWriter.close(); + //controller + Template controllerTemp = GeneratorTempUtils.getMybatisPlusTemp("controller.vm"); + FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("controller") + tbName + "Controller.java"); + controllerTemp.merge(context, controllerWriter); + controllerWriter.close(); + //service + Template serviceTemp = GeneratorTempUtils.getMybatisPlusTemp("service.vm"); + FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("service") + tbName + "Service.java"); + serviceTemp.merge(context, serviceWriter); + serviceWriter.close(); + //mapper + Template mapperTemp = GeneratorTempUtils.getMybatisPlusTemp("mapper.vm"); + FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("mapper") + tbName + "Mapper.java"); + mapperTemp.merge(context, mapperWriter); + mapperWriter.close(); + } catch (IOException e) { + throw new RuntimeException("Mybatis-plus单表生成模版报错" + e); + } + } + + /** + * element-plus多表生成模版 + */ + public void generatorElementPlusTemp(Map jsonData) { + try { + Context context = getContext(jsonData); + Template template = GeneratorTempUtils.getElementPlusTemp("CRUD.vm"); + FileWriter fileWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUD.vue"); + template.merge(context, fileWriter); + fileWriter.close(); + //第二个模板 + Template addModal = GeneratorTempUtils.getElementPlusTemp("CRUDForm.vm"); + FileWriter addModalWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUDForm.vue"); + addModal.merge(context, addModalWriter); + addModalWriter.close(); + } catch (IOException e) { + throw new RuntimeException("element-plus多表生成模版报错" + e); + } + } + + /** + * 生成后端模版 + * + * @param jsonData + * @return + */ + public String generatorBackTempZip(Map jsonData) { + Map commonConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("commonConfig")), Map.class); + if ("true".equals(commonConfig.get("isTableMulChoose").toString())) { + //多表模版 + generatorMybatisPlusMulTemp(jsonData); + } else { + /*单表*/ + generatorMybatisPlusTemp(jsonData); + } + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + return exportFilePath; + } + + /** + * 生成前端模版 + * + * @param jsonData + * @return + */ + public String generatorFrontTempZip(Map jsonData) { + Map commonConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("commonConfig")), Map.class); + //多表 + if ("true".equals(commonConfig.get("isTableMulChoose").toString())) { + //生成前端模板 + generatorElementPlusTemp(jsonData); + } else { + /*单表*/ + //生成前端模板 + generatorElementPlusTemp(jsonData); + } + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + return exportFilePath; + } + + /** + * 生成前后端模版 + * + * @param jsonData + * @return + */ + public String generatorFrontBackTempZip(Map jsonData) { + Map commonConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("commonConfig")), Map.class); + //多表 + if ("true".equals(commonConfig.get("isTableMulChoose").toString())) { + //生成前端模板 + generatorElementPlusTemp(jsonData); + //生成后端模板 + generatorMybatisPlusMulTemp(jsonData); + } else { + /*单表*/ + //生成前端模板 + generatorElementPlusTemp(jsonData); + //生成后端模板 + generatorMybatisPlusTemp(jsonData); + } + + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + return exportFilePath; + } + + + private Context getContext(Map jsonData) { + Context context = GeneratorTempUtils.getVelocityContext(); + context.put("totalData", jsonData); + context.put("projectOrAuthor", jsonData.get("projectOrAuthor")); + context.put("commonConfig", jsonData.get("commonConfig")); + context.put("multiTableConfig", jsonData.get("multiTableConfig")); + context.put("dbTableConfig", jsonData.get("dbTableConfig")); + context.put("apiConfig", jsonData.get("apiConfig")); + context.put("queryConfig", jsonData.get("queryConfig")); + context.put("tableConfig", jsonData.get("tableConfig")); + context.put("formConfig", jsonData.get("formConfig")); + return context; + } + +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java b/basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java new file mode 100644 index 0000000..799bb7d --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java @@ -0,0 +1,353 @@ +package top.kuanghua.basisfunc.utils; + +import lombok.extern.log4j.Log4j2; +import net.lingala.zip4j.ZipFile; +import net.lingala.zip4j.exception.ZipException; +import org.apache.tomcat.util.http.fileupload.IOUtils; +import org.apache.velocity.Template; +import org.apache.velocity.app.VelocityEngine; +import org.apache.velocity.context.Context; +import org.apache.velocity.runtime.RuntimeConstants; +import org.apache.velocity.tools.ToolManager; +import org.springframework.util.StreamUtils; + +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.UUID; + +/** + * @Title: FrontVmsUtils + * @Description: 前端模板生成工具类 + * @Auther: kuanghua + * @create 2022-05-17 13:57 + */ +@Log4j2 +public class GeneratorTempUtils { + //velocity tools配置文件路径 + public static final String ToolManagerConfigPath = "velocity-tools.xml"; + public static final String VelocityTemplateDir = "D:\\github\\velocity-tmp-dir\\"; + public static final String VelocityTemplateDirMac = "/deploy/velocity-tmp-dir/"; + public static final String ElementPlusDir = "front-vms" + File.separator + "element-plus"; + public static final String MybatisPlusDir = "back-vms" + File.separator + "mybatis-plus"; + public static final String MybatisPlusMulTbDir = "back-vms" + File.separator + "mybatis-plus-multb"; + + //win + public static final String ExportFileDir = "D:\\temp-dir\\export-dir\\"; + public static final String NeedZipDir = "D:\\temp-dir\\export-dir\\"; + public static final String OutputZipPath = "D:\\temp-dir\\"; + public static final String TmpSaveDir = "D:\\temp-dir\\"; + //mac和Linux + public static final String MacExportFileDir = "/tmp/export-dir/"; + public static final String MacNeedZipDir = "/tmp/export-dir/"; + public static final String MacOutputZipPath = "/tmp/"; + public static final String MacTmpSaveDir = "/tmp/"; + + /** + * @return + * @author 邝华 + * @date 2022-06-10 13:54 + */ + public static String getExportFileDir(String dir) { + String os = System.getProperty("os.name"); + String path = ""; + if (os.toLowerCase().startsWith("win")) { + path = ExportFileDir + dir + File.separator; + } else { + path = MacExportFileDir + dir + File.separator; + } + return fileMkdir(path); + } + + public static String getExportMybatisPlusMulDir(String dir) { + String os = System.getProperty("os.name"); + String path = ""; + if (os.toLowerCase().startsWith("win")) { + path = ExportFileDir + "mybatis-plus-mul" + File.separator + dir + File.separator; + } else { + path = MacExportFileDir + "mybatis-plus-mul" + File.separator + dir + File.separator; + } + return fileMkdir(path); + } + + public static String getExportMybatisPlusDir(String dir) { + String os = System.getProperty("os.name"); + String path = ""; + if (os.toLowerCase().startsWith("win")) { + path = ExportFileDir + "mybatis-plus" + File.separator + dir + File.separator; + } else { + path = MacExportFileDir + "mybatis-plus" + File.separator + dir + File.separator; + } + return fileMkdir(path); + } + + public static String getExportElementPlusDir(String dir) { + String os = System.getProperty("os.name"); + String path = ""; + if (os.toLowerCase().startsWith("win")) { + path = ExportFileDir + "element-plus" + File.separator + dir + File.separator; + } else { + path = MacExportFileDir + "element-plus" + File.separator + dir + File.separator; + } + return fileMkdir(path); + } + + /** + * @return + * @author 邝华 + * @date 2022-06-26 13:54 + */ + public static String getExportFileDir() { + String os = System.getProperty("os.name"); + String path = ""; + if (os.toLowerCase().startsWith("win")) { + path = ExportFileDir; + } else { + path = MacExportFileDir; + } + return fileMkdir(path); + } + + /** + * 获取临时存储目录路径 + * + * @return + * @author 邝华 + * @date 2022-06-10 13:54 + */ + public static String getTmpSaveDir() { + String os = System.getProperty("os.name"); + String path = ""; + String uuid = UUID.randomUUID().toString().replaceAll("-", ""); + if (os.toLowerCase().startsWith("win")) { + path = TmpSaveDir + uuid + File.separator; + } else { + path = MacTmpSaveDir + uuid + File.separator; + } + return fileMkdir(path); + } + + /** + * @return + * @author 邝华 + * @date 2022-06-10 13:53 + */ + public static String getNeedZipDir() { + String os = System.getProperty("os.name"); + String path = ""; + if (os.toLowerCase().startsWith("win")) { + path = NeedZipDir; + } else { + path = MacNeedZipDir; + } + return fileMkdir(path); + } + + /** + * @return + * @author 邝华 + * @date 2022-06-10 13:53 + */ + public static String getOutputZipPath() { + String os = System.getProperty("os.name"); + String path = ""; + if (os.toLowerCase().startsWith("win")) { + path = OutputZipPath; + } else { + path = MacOutputZipPath; + } + return fileMkdir(path); + } + + /** + * @return + * @author 邝华 + * @date 2022-06-10 13:56 + */ + public static String fileMkdir(String path) { + File file = new File(path); + if (!file.exists()) { + file.mkdirs(); + } + return path; + } + + + /** + * @return + * @author 邝华 + * @date 2022-06-10 13:56 + */ + public static String getTemplateDir(String dirPath) { + String os = System.getProperty("os.name"); + String path = ""; + if (os.toLowerCase().startsWith("win")) { + path = VelocityTemplateDir + dirPath; + } else { + path = VelocityTemplateDirMac + dirPath; + } + return fileMkdir(path); + } + + + /** + * @return velocity Context + */ + public static Context getVelocityContext() { + // 加载toolbox + ToolManager manager = new ToolManager(); + manager.configure(ToolManagerConfigPath); + return manager.createContext(); + } + + /** + * @param response + * @param exportFilePath 导出文件的路径 + */ + public static void downloadZip(HttpServletResponse response, String exportFilePath) { + File file = new File(exportFilePath); + if (!file.exists()) { + throw new RuntimeException("文件不存在"); + } + try { + ZipFile zipFile = new ZipFile(file); + InputStream fis = new FileInputStream(zipFile.getFile()); + IOUtils.copy(fis, response.getOutputStream()); + fis.close(); + } catch (Exception e) { + e.printStackTrace(); + } + log.info(exportFilePath + "被删除了"); + log.info(getNeedZipDir() + "被删除了"); + deleteFile(exportFilePath); + deleteDir(getNeedZipDir()); + } + + /** + * 删除导出后文件夹下的文件 + * + * @return + * @author 邝华 + * @email kuanghua@aulton.com + * @date 2022-06-10 14:13 + */ + public static void deleteDir(String path) { + File directory = new File(path); + deleteDeepDir(directory); + } + + public static void deleteDeepDir(File directory) { + //获取目录下所有文件和目录 + File files[] = directory.listFiles(); + for (File file : files) { + if (file.isDirectory()) { + deleteDeepDir(file); + } else { + file.delete(); + log.info(file.getName() + "::文件已删除"); + } + } + //最终把该目录也删除 + directory.delete(); + log.info(directory.getName() + "::目录已删除"); + } + + /** + * 删除文件 + * + * @param path 要删除的文件路径 + * @return + * @author 邝华 + * @email kuanghua@aulton.com + * @date 2022-06-13 11:22 + */ + public static void deleteFile(String path) { + File file = new File(path); + if (file.exists()) { + file.delete();//只有为空的文件夹才能执行true + } + } + + /** + * @param tempName 模板名称 + * @return Template + */ + public static Template getMybatisPlusTemp(String tempName) { + VelocityEngine ve = new VelocityEngine(); + ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, getTemplateDir(MybatisPlusDir)); + ve.init(); + return ve.getTemplate(tempName); + } + + /** + * @param tempName 模板名称 + * @return Template + */ + public static Template getTmpSaveDirTemp(String tmpSaveDir, String tempName) { + VelocityEngine ve = new VelocityEngine(); + ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, tmpSaveDir); + ve.init(); + return ve.getTemplate(tempName); + } + + /** + * @param tempName 模板名称 + * @return Template + */ + public static Template getMybatisPlusMulTbTemp(String tempName) { + VelocityEngine ve = new VelocityEngine(); + ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, getTemplateDir(MybatisPlusMulTbDir)); + ve.init(); + return ve.getTemplate(tempName); + } + + + /** + * @param tempName 模板名称 + * @return Template + */ + public static Template getElementPlusTemp(String tempName) { + VelocityEngine ve = new VelocityEngine(); + ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, getTemplateDir(ElementPlusDir)); + ve.init(); + return ve.getTemplate(tempName); + } +// +// /** +// * 获取JsonData下的目录路径 +// * +// * @return 得到的目录名称 +// */ +// public static String getJsonDataDirPath() { +// return ClassUtils.getDefaultClassLoader().getResource("json-data").getPath() + File.separator; +// } + + /** + * @param filePath 相对于resource的路径 + * @return 读取的文件内容 + * @throws IOException + */ + public static String readFileToString(String filePath) throws IOException { + FileInputStream fileInputStream = new FileInputStream(new File(filePath)); +// ClassPathResource classPathResource = new ClassPathResource(filePath); +// InputStream inputStream = classPathResource.getInputStream(); + String s = StreamUtils.copyToString(fileInputStream, StandardCharsets.UTF_8); + fileInputStream.close(); + return s; + } + + /** + * @param outputZipPath 导出zip包的路径 如 file://xxx.zip + * @param needZipDir 需要压缩的目录名字 如 file://doc + */ + public static void createZipFile(String outputZipPath, String needZipDir) { + try { + new ZipFile(outputZipPath).addFolder(new File(needZipDir)); + } catch (ZipException e) { + throw new RuntimeException("压缩文件夹报错" + e); + } + } +} diff --git a/basis-func/src/main/resources/application-db.yml b/basis-func/src/main/resources/application-db.yml new file mode 100644 index 0000000..842d8ed --- /dev/null +++ b/basis-func/src/main/resources/application-db.yml @@ -0,0 +1,39 @@ +spring: + datasource: + driver-class-name: com.p6spy.engine.spy.P6SpyDriver + url: jdbc:p6spy:mysql://${envpt.mysqlIp}:${envpt.mysqlPort}/micro-service-plus?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&useSSL=false + username: root + password: root123 + hikari: + max-lifetime: 28830000 # 一个连接的生命时长(毫秒),超时而且没被使用则被释放(retired),缺省:30分钟,建议设置比数据库超时时长少30秒,参考MySQL wait_timeout参数(show variables like '%timeout%';) + maximum-pool-size: 9 # 连接池中允许的最大连接数。缺省值:10;推荐的公式:((core_count * 2) + effective_spindle_count) + +mybatis-plus: + mapper-locations: classpath:/mapper/*Mapper.xml + #实体扫描,多个package用逗号或者分号分隔 + #typeAliasesPackage: top.kuanghua.tyuser.entity + #typeEnumsPackage: com.baomidou.springboot.entity.enums + global-config: + #刷新mapper 调试神器 + db-config: + #主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID"; + id-type: AUTO + #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断" + field-strategy: not_empty + #驼峰下划线转换 + column-underline: true + #数据库大写下划线转换 + #capital-mode: true + #逻辑删除配置 + logic-delete-field: deleted # 逻辑已删除值(默认为 1) + logic-delete-value: 1 # 逻辑已删除值(默认为 1) + logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) + db-type: mysql + refresh: true + #自定义填充策略接口实现 + #meta-object-handler: com.baomidou.springboot.xxx + #自定义SQL注入器 + sql-injector: com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteByIdWithFill + configuration: + map-underscore-to-camel-case: true + cache-enabled: false \ No newline at end of file diff --git a/basis-func/src/main/resources/application.yml b/basis-func/src/main/resources/application.yml new file mode 100644 index 0000000..7b0a0f2 --- /dev/null +++ b/basis-func/src/main/resources/application.yml @@ -0,0 +1,2 @@ +server: + port: ${envpt.tomcatPortPre}0121 \ No newline at end of file diff --git a/basis-func/src/main/resources/bootstrap.yml b/basis-func/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..f38cf92 --- /dev/null +++ b/basis-func/src/main/resources/bootstrap.yml @@ -0,0 +1,15 @@ +spring: + application: + name: @project.artifactId@ + profiles: + active: @activatedProperties@,main,db + cloud: + nacos: + discovery: + namespace: @nacosNamespace@ + group: @nacosGroup@ + username: @nacosUsername@ + password: @nacosPassword@ + server-addr: @nacosIpPort@ + weight: @nacosWeight@ + diff --git a/basis-func/src/main/resources/mapper/RepairInfoMapper.xml b/basis-func/src/main/resources/mapper/RepairInfoMapper.xml new file mode 100644 index 0000000..962b471 --- /dev/null +++ b/basis-func/src/main/resources/mapper/RepairInfoMapper.xml @@ -0,0 +1,69 @@ + + + + + + + + + rp + . + sn + ,rp.equip_type, rp.replacement_id, rp.express_id, rp.problem_classification_id + ,rp.current_status, rp.problem_description, + rp.feedback_time, rp.proposer, rp.contact_info, rp.recovery_date, + rp.return_date, rp.problems_analyzed, rp.reason, rp.processing_method, rp.remarks, + rm.new_sn_id + + + + + + + \ No newline at end of file diff --git a/basis-func/src/main/resources/velocity-tools.xml b/basis-func/src/main/resources/velocity-tools.xml new file mode 100644 index 0000000..891958c --- /dev/null +++ b/basis-func/src/main/resources/velocity-tools.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/basis-func/src/test/java/top/kuanghua/basisfunc/service/GeneratorServiceTest.java b/basis-func/src/test/java/top/kuanghua/basisfunc/service/GeneratorServiceTest.java new file mode 100644 index 0000000..4e5b939 --- /dev/null +++ b/basis-func/src/test/java/top/kuanghua/basisfunc/service/GeneratorServiceTest.java @@ -0,0 +1,180 @@ +package top.kuanghua.basisfunc.service; + +import com.alibaba.fastjson.JSON; +import org.apache.velocity.Template; +import org.apache.velocity.context.Context; +import org.junit.jupiter.api.Test; +import top.kuanghua.basisfunc.utils.GeneratorTempUtils; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Map; + +/** + * @Title: BackVmsMulTableServiceTest + * @Description: + * @Auther: kuanghua + * @create 2022/6/26 11:11 + */ +public class GeneratorServiceTest { + + /** + * mybatis-plus多表生成模版 + */ + @Test + public void generatorMybatisPlusMulTemp() throws IOException { + String string = GeneratorTempUtils.readFileToString("D:\\github\\velocity-tmp-dir\\json-data\\" + "multiTableData.json"); + Map jsonData = JSON.parseObject(string, Map.class); + Context context = GeneratorTempUtils.getVelocityContext(); + context.put("totalData", jsonData); + context.put("projectOrAuthor", jsonData.get("projectOrAuthor")); + context.put("multiTableConfig", jsonData.get("multiTableConfig")); + context.put("queryConfig", jsonData.get("queryConfig")); + context.put("tableConfig", jsonData.get("tableConfig")); + context.put("formConfig", jsonData.get("formConfig")); + context.put("dbTableConfig", jsonData.get("dbTableConfig")); + + Map dbTableConfig = ObjSelfUtils.changeToMap(jsonData.get("dbTableConfig")); + ArrayList> multiTableConfig = ObjSelfUtils.changeToArrayMap(jsonData.get("multiTableConfig")); + + multiTableConfig.forEach((fItem) -> { + //entity + FileWriter entityWriter = null; + try { + Template entityTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entity.vm"); + context.put("currentTbConfig", fItem); + context.put("tableFieldArr", fItem.get("tableFieldArr")); + entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("entity") + fItem.get("tableNameCase") + ".java"); + entityTemp.merge(context, entityWriter); + entityWriter.close(); + + //single-mapper + Template mapperTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("mapper.vm"); + FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("mapper") + fItem.get("tableNameCase") + "Mapper.java"); + mapperTemp.merge(context, mapperWriter); + mapperWriter.close(); + } catch (IOException e) { + throw new RuntimeException("生成实体类报错" + e); + } + }); + String tbName = dbTableConfig.get("multiTableNameCase").toString(); + + try { + //controller + Template controllerTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("controllerMul.vm"); + FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("controller") + tbName + "Controller.java"); + controllerTemp.merge(context, controllerWriter); + controllerWriter.close(); + //service + Template serviceTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("serviceMul.vm"); + FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("service") + tbName + "Service.java"); + serviceTemp.merge(context, serviceWriter); + serviceWriter.close(); + + //mul-entity + Template mapperMulTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("mapperMul.vm"); + FileWriter mapperMulWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("mapper") + tbName + "Mapper.java"); + mapperMulTemp.merge(context, mapperMulWriter); + mapperMulWriter.close(); + + //entity-vo + Template entityVoTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entityVo.vm"); + FileWriter entityVoWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("vo") + tbName + "Vo.java"); + entityVoTemp.merge(context, entityVoWriter); + entityVoWriter.close(); + + //entity-mul + Template entityMulTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entityMul.vm"); + FileWriter entityMulWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("entity") + tbName + ".java"); + entityMulTemp.merge(context, entityMulWriter); + entityMulWriter.close(); + //xml + Template xmlTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("xmlMul.vm"); + FileWriter xmlWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("xml") + tbName + "Mapper.xml"); + xmlTemp.merge(context, xmlWriter); + xmlWriter.close(); + + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + + } catch (IOException e) { + throw new RuntimeException("生成实体类报错" + e); + } + } + + /** + * element-plus单表生成模版 + */ + @Test + public void generatorMybatisPlusTemp() throws IOException { + String string = GeneratorTempUtils.readFileToString("D:\\github\\velocity-tmp-dir\\json-data\\" + "tb_brand.json"); + Map jsonData = JSON.parseObject(string, Map.class); + + Context context = GeneratorTempUtils.getVelocityContext(); + context.put("configData", jsonData); + context.put("projectOrAuthor", jsonData.get("projectOrAuthor")); + context.put("dbTableConfig", jsonData.get("dbTableConfig")); + context.put("apiConfig", jsonData.get("apiConfig")); + context.put("queryConfig", jsonData.get("queryConfig")); + context.put("tableConfig", jsonData.get("tableConfig")); + context.put("formConfig", jsonData.get("formConfig")); + context.put("commonConfig", jsonData.get("commonConfig")); + + + Map dbTableConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("dbTableConfig")), Map.class); + + String tbName = dbTableConfig.get("tableNameCase").toString(); + //entity + Template entityTemp = GeneratorTempUtils.getMybatisPlusTemp("entity.vm"); + FileWriter entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("entity") + tbName + ".java"); + entityTemp.merge(context, entityWriter); + entityWriter.close(); + //controller + Template controllerTemp = GeneratorTempUtils.getMybatisPlusTemp("controller.vm"); + FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("controller") + tbName + "Controller.java"); + controllerTemp.merge(context, controllerWriter); + controllerWriter.close(); + //service + Template serviceTemp = GeneratorTempUtils.getMybatisPlusTemp("service.vm"); + FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("service") + tbName + "Service.java"); + serviceTemp.merge(context, serviceWriter); + serviceWriter.close(); + //mapper + Template mapperTemp = GeneratorTempUtils.getMybatisPlusTemp("mapper.vm"); + FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("mapper") + tbName + "Mapper.java"); + mapperTemp.merge(context, mapperWriter); + mapperWriter.close(); + } + + + /** + * element-plus多表生成模版 + */ + @Test + public void generatorElementPlusTemp() throws IOException { + String string = GeneratorTempUtils.readFileToString("D:\\github\\velocity-tmp-dir\\json-data\\" + "tb_brand.json"); + Map jsonData = JSON.parseObject(string, Map.class); + Context context = GeneratorTempUtils.getVelocityContext(); + context.put("configData", jsonData); + context.put("companyOrAuthor", jsonData.get("companyOrAuthor")); + context.put("dbTableConfig", jsonData.get("dbTableConfig")); + context.put("apiConfig", jsonData.get("apiConfig")); + context.put("queryConfig", jsonData.get("queryConfig")); + context.put("tableConfig", jsonData.get("tableConfig")); + context.put("formConfig", jsonData.get("formConfig")); + context.put("commonConfig", jsonData.get("commonConfig")); + Template template = GeneratorTempUtils.getElementPlusTemp("CRUD.vm"); + FileWriter fileWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUD.vue"); + template.merge(context, fileWriter); + fileWriter.close(); + //第二个模板 + Template addModal = GeneratorTempUtils.getElementPlusTemp("CRUDForm.vm"); + FileWriter addModalWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUDForm.vue"); + addModal.merge(context, addModalWriter); + addModalWriter.close(); + } + +} \ No newline at end of file diff --git a/common-pom/pom.xml b/common-pom/pom.xml new file mode 100644 index 0000000..77f1901 --- /dev/null +++ b/common-pom/pom.xml @@ -0,0 +1,78 @@ + + + + micro-service-plus + top.kuanghua + 1.0-SNAPSHOT + + 4.0.0 + + common-pom + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-validation + + + + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + org.springframework.cloud + spring-cloud-starter-loadbalancer + + + com.github.ben-manes.caffeine + caffeine + 2.6.2 + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + org.springframework.cloud + spring-cloud-starter-netflix-ribbon + + + + + + mysql + mysql-connector-java + + + + com.baomidou + mybatis-plus-boot-starter + 3.3.2 + + + p6spy + p6spy + 3.9.1 + + + + org.springframework.boot + spring-boot-starter-data-redis + + + + com.github.xiaoymin + knife4j-spring-boot-starter + 2.0.9 + + + \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/feign/config/FeignConfiguration.java b/common-pom/src/main/java/top/kuanghua/commonpom/config/FeignConfiguration.java similarity index 89% rename from ty-common/src/main/java/top/kuanghua/feign/config/FeignConfiguration.java rename to common-pom/src/main/java/top/kuanghua/commonpom/config/FeignConfiguration.java index 80eac4d..140bf3e 100644 --- a/ty-common/src/main/java/top/kuanghua/feign/config/FeignConfiguration.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/config/FeignConfiguration.java @@ -1,4 +1,4 @@ -package top.kuanghua.feign.config; +package top.kuanghua.commonpom.config; import feign.RequestInterceptor; import feign.RequestTemplate; @@ -27,7 +27,9 @@ public void apply(RequestTemplate template) { while (headerNames.hasMoreElements()) { String name = headerNames.nextElement(); String values = request.getHeader(name); - + if (name.equals("content-length")){ + continue; + } template.header(name, values); } } diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/config/MetaObjectHandlerConfig.java b/common-pom/src/main/java/top/kuanghua/commonpom/config/MetaObjectHandlerConfig.java similarity index 95% rename from ty-common/src/main/java/top/kuanghua/khcomomon/config/MetaObjectHandlerConfig.java rename to common-pom/src/main/java/top/kuanghua/commonpom/config/MetaObjectHandlerConfig.java index 6c6dce1..24a9a8c 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/config/MetaObjectHandlerConfig.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/config/MetaObjectHandlerConfig.java @@ -1,4 +1,4 @@ -package top.kuanghua.khcomomon.config; +package top.kuanghua.commonpom.config; import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; import lombok.extern.slf4j.Slf4j; diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/config/MybatisPlusConfig.java b/common-pom/src/main/java/top/kuanghua/commonpom/config/MybatisPlusConfig.java similarity index 97% rename from ty-common/src/main/java/top/kuanghua/khcomomon/config/MybatisPlusConfig.java rename to common-pom/src/main/java/top/kuanghua/commonpom/config/MybatisPlusConfig.java index 5378349..e675026 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/config/MybatisPlusConfig.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/config/MybatisPlusConfig.java @@ -1,5 +1,4 @@ -package top.kuanghua.khcomomon.config; - +package top.kuanghua.commonpom.config; import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer; import com.baomidou.mybatisplus.extension.MybatisMapWrapperFactory; @@ -44,7 +43,7 @@ public OptimisticLockerInterceptor optimisticLockerInterceptor() { /*map转驼峰*/ @Bean - public ConfigurationCustomizer mybatisConfigurationCustomizer(){ + public ConfigurationCustomizer mybatisConfigurationCustomizer() { return new ConfigurationCustomizer() { @Override public void customize(org.apache.ibatis.session.Configuration configuration) { @@ -54,5 +53,4 @@ public void customize(org.apache.ibatis.session.Configuration configuration) { } - } diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonPageParams.java b/common-pom/src/main/java/top/kuanghua/commonpom/entity/CommonPageParams.java similarity index 68% rename from ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonPageParams.java rename to common-pom/src/main/java/top/kuanghua/commonpom/entity/CommonPageParams.java index 93859f2..866b997 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonPageParams.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/entity/CommonPageParams.java @@ -1,4 +1,4 @@ -package top.kuanghua.khcomomon.entity; +package top.kuanghua.commonpom.entity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -12,24 +12,26 @@ */ @Data @ApiModel -public class KHCommonPageParams { +public class CommonPageParams { @ApiModelProperty("页数") - private Integer pageSize; + private Integer pageSize; @ApiModelProperty("页码") - private Integer pageNum; + private Integer pageNum; + public Integer getPageSize() { - if(pageSize ==null ){ + if (pageSize == null) { return 10; - }else{ + } else { return pageSize; } } + public Integer getPageNum() { - if(pageSize ==null){ + if (pageSize == null) { return 1; - }else{ + } else { return pageNum; } } diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/PageResult.java b/common-pom/src/main/java/top/kuanghua/commonpom/entity/PageResult.java similarity index 93% rename from ty-common/src/main/java/top/kuanghua/khcomomon/entity/PageResult.java rename to common-pom/src/main/java/top/kuanghua/commonpom/entity/PageResult.java index 17f2f1f..67f169a 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/PageResult.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/entity/PageResult.java @@ -1,4 +1,4 @@ -package top.kuanghua.khcomomon.entity; +package top.kuanghua.commonpom.entity; import java.util.List; diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/ResResult.java b/common-pom/src/main/java/top/kuanghua/commonpom/entity/ResResult.java similarity index 69% rename from ty-common/src/main/java/top/kuanghua/khcomomon/entity/ResResult.java rename to common-pom/src/main/java/top/kuanghua/commonpom/entity/ResResult.java index 082ab6a..1b71683 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/ResResult.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/entity/ResResult.java @@ -1,4 +1,4 @@ -package top.kuanghua.khcomomon.entity; +package top.kuanghua.commonpom.entity; import lombok.AllArgsConstructor; import lombok.Data; @@ -22,30 +22,30 @@ public class ResResult implements Serializable { private String msg;//返回消息 private T data;//返回数据 - public ResResult success(Object data) { + public ResResult success(Object data) { this.flag = true; - this.code = StatusCode.OK; + this.code = top.kuanghua.commonpom.entity.StatusCode.OK; this.data = (T) data; return this; } - public ResResult success() { + public ResResult success() { this.flag = true; - this.code = StatusCode.OK; + this.code = top.kuanghua.commonpom.entity.StatusCode.OK; this.msg = "操作成功!"; return this; } - public ResResult error(String msg) { + public ResResult error(String msg) { this.flag = false; - this.code = StatusCode.ERROR; + this.code = top.kuanghua.commonpom.entity.StatusCode.ERROR; this.msg = msg; return this; } public ResResult(String msg, Object data) { this.flag = true; - this.code = StatusCode.OK; + this.code = top.kuanghua.commonpom.entity.StatusCode.OK; this.msg = msg; this.data = (T) data; } @@ -58,7 +58,7 @@ public ResResult(boolean flag, Integer code, String msg) { public ResResult() { this.flag = true; - this.code = StatusCode.OK; + this.code = top.kuanghua.commonpom.entity.StatusCode.OK; this.msg = "操作成功!"; } diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonParams.java b/common-pom/src/main/java/top/kuanghua/commonpom/entity/SelfCommonParams.java similarity index 62% rename from ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonParams.java rename to common-pom/src/main/java/top/kuanghua/commonpom/entity/SelfCommonParams.java index fbbad77..6625c78 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/KHCommonParams.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/entity/SelfCommonParams.java @@ -1,4 +1,4 @@ -package top.kuanghua.khcomomon.entity; +package top.kuanghua.commonpom.entity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -12,9 +12,9 @@ */ @Data @ApiModel -public class KHCommonParams extends KHCommonPageParams{ +public class SelfCommonParams extends top.kuanghua.commonpom.entity.CommonPageParams { @ApiModelProperty("开始时间") - private String startTime; + private String startTime; @ApiModelProperty("结束时间") - private String endTime; + private String endTime; } diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/StatusCode.java b/common-pom/src/main/java/top/kuanghua/commonpom/entity/StatusCode.java similarity index 92% rename from ty-common/src/main/java/top/kuanghua/khcomomon/entity/StatusCode.java rename to common-pom/src/main/java/top/kuanghua/commonpom/entity/StatusCode.java index 587a48f..4c63336 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/StatusCode.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/entity/StatusCode.java @@ -1,4 +1,4 @@ -package top.kuanghua.khcomomon.entity; +package top.kuanghua.commonpom.entity; /** * 返回码 diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/exception/BaseExceptionHandler.java b/common-pom/src/main/java/top/kuanghua/commonpom/exception/BaseExceptionHandler.java similarity index 80% rename from ty-common/src/main/java/top/kuanghua/khcomomon/exception/BaseExceptionHandler.java rename to common-pom/src/main/java/top/kuanghua/commonpom/exception/BaseExceptionHandler.java index da5ad7c..ea0552f 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/exception/BaseExceptionHandler.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/exception/BaseExceptionHandler.java @@ -1,14 +1,14 @@ -package top.kuanghua.khcomomon.exception; +package top.kuanghua.commonpom.exception; import org.springframework.validation.ObjectError; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; -import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.commonpom.entity.ResResult; /* -* 全局异常处理 -* */ + * 全局异常处理 + * */ @RestControllerAdvice public class BaseExceptionHandler { /*** @@ -19,8 +19,9 @@ public class BaseExceptionHandler { @ExceptionHandler(MethodArgumentNotValidException.class) public ResResult MethodArgumentNotValidExceptionHandler(MethodArgumentNotValidException e) { ObjectError objectError = e.getBindingResult().getAllErrors().get(0); - return new ResResult().error(objectError.getDefaultMessage()); + return new ResResult().error(objectError.getDefaultMessage()); } + @ExceptionHandler(value = Exception.class) public ResResult error(Exception e) { e.printStackTrace(); diff --git a/common-pom/src/main/java/top/kuanghua/commonpom/feign/tyauth/TokenFeign.java b/common-pom/src/main/java/top/kuanghua/commonpom/feign/tyauth/TokenFeign.java new file mode 100644 index 0000000..42b93fa --- /dev/null +++ b/common-pom/src/main/java/top/kuanghua/commonpom/feign/tyauth/TokenFeign.java @@ -0,0 +1,43 @@ +//package top.kuanghua.commonpom.feign.tyauth; +// +//import org.springframework.cloud.openfeign.FeignClient; +//import org.springframework.web.bind.annotation.PostMapping; +//import org.springframework.web.bind.annotation.RequestBody; +//import org.springframework.web.bind.annotation.RequestParam; +//import top.kuanghua.commonpom.config.FeignConfiguration; +//import top.kuanghua.commonpom.entity.ResResult; +// +//import java.util.Map; +// +///** +// * @Title: TokenController +// * @Description: +// * @Auther: kuanghua +// * @create 2021/1/31 16:31 +// */ +// +// +////FeignConfiguration.class -> forward req params of include the token +//@FeignClient(name="ty-auth",configuration = FeignConfiguration.class,path = "token") +//public interface TokenFeign { +// +// /* +// * parse token +// * */ +// @PostMapping("parseToken") +// ResResult parseToken(@RequestParam("jwtToken") String jwtToken); +// +// /* +// * create token +// * */ +// @PostMapping("generateToken") +// ResResult generateToken(@RequestBody Map map); +// +// /* +// * update token +// * */ +// @PostMapping("updateToken") +// ResResult updateToken(@RequestBody Map map); +//} +// +// diff --git a/common-pom/src/main/java/top/kuanghua/commonpom/utils/ObjSelfUtils.java b/common-pom/src/main/java/top/kuanghua/commonpom/utils/ObjSelfUtils.java new file mode 100644 index 0000000..2c0689b --- /dev/null +++ b/common-pom/src/main/java/top/kuanghua/commonpom/utils/ObjSelfUtils.java @@ -0,0 +1,178 @@ +package top.kuanghua.commonpom.utils; + +import com.alibaba.fastjson.JSON; +import org.apache.commons.lang3.StringUtils; +import org.springframework.web.multipart.MultipartFile; +import top.kuanghua.commonpom.entity.ResResult; + +import java.io.File; +import java.lang.reflect.Array; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 从jwt解析得到的数据是Object类型,转换为具体类型可能出现空指针, + * 这个工具类进行了一些转换 + */ +public class ObjSelfUtils { + /*类型转换*/ + public static String toString(Object obj) { + if (obj == null) { + return null; + } + return obj.toString(); + } + + public static Long toLong(Object obj) { + if (obj == null) { + return 0L; + } + if (obj instanceof Double || obj instanceof Float) { + return Long.valueOf(StringUtils.substringBefore(obj.toString(), ".")); + } + if (obj instanceof Number) { + return Long.valueOf(obj.toString()); + } + if (obj instanceof String) { + return Long.valueOf(obj.toString()); + } else { + return 0L; + } + } + + public static Integer toInt(Object obj) { + return toLong(obj).intValue(); + } + + /*非空判断*/ + public static boolean isNotEmpty(Object obj) { + return !isEmpty(obj); + } + + public static boolean isEmpty(Object obj) { + if (obj == null) { + return true; + } else if (obj.getClass().isArray()) { + return Array.getLength(obj) == 0; + } else if (obj instanceof CharSequence) { + return ((CharSequence) obj).length() == 0; + } else if (obj instanceof Collection) { + return ((Collection) obj).isEmpty(); + } else { + return obj instanceof Map ? ((Map) obj).isEmpty() : false; + } + } + + //解析请求数据 + public static ResResult parseRes(Object resResult) { + ResResult res = JSON.parseObject(JSON.toJSONString(resResult), ResResult.class); + return res; + } + + //解析请求数据到data + public static Map parseResToData(Object result) { + ResResult resResult = parseRes(result); + if (resResult.isFlag()) { + return JSON.parseObject(JSON.toJSONString(resResult.getData()), Map.class); + } else { + throw new RuntimeException(resResult.getMsg()); + } + } + + //解析请求数据到data + public static Map parseResToMap(ResResult resResult) { + if (resResult.isFlag()) { + return JSON.parseObject(JSON.toJSONString(resResult.getData()), Map.class); + } else { + throw new RuntimeException(resResult.getMsg()); + } + } + + public static List parseResToList(ResResult resResult) { + if (resResult.isFlag()) { + return JSON.parseObject(JSON.toJSONString(resResult.getData()), List.class); + } else { + throw new RuntimeException(resResult.getMsg()); + } + } + + //将一般的数据转化为map + public static Map changeToMap(Object resResult) { + return JSON.parseObject(JSON.toJSONString(resResult), Map.class); + } + + /** + * 将Object数据转化为 ArrayList + * + * @param resResult + * @return + */ + public static ArrayList> changeToArrayMap(Object resResult) { + return JSON.parseObject(JSON.toJSONString(resResult), ArrayList.class); + } + + public static ArrayList changeToArrayString(Object resResult) { + return JSON.parseObject(JSON.toJSONString(resResult), ArrayList.class); + } + + public static ArrayList changeToArrayInteger(Object resResult) { + return JSON.parseObject(JSON.toJSONString(resResult), ArrayList.class); + } + + /** + * @return 时间年月日 + */ + public static String getCurrentDateTimeTrim() { + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式 + return df.format(new Date()); + } + + /** + * @return 时间年月日 + */ + public static String getCurrentDateTime() { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式 + return df.format(new Date()); + } + + /** + * @return 当前年月 + */ + public static String getCurrentDate() { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式 + return df.format(new Date()); + } + + /** + * @param date + * @return + */ + public static String formatDateTime(Date date) { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式 + return df.format(date); + } + + + /** + * MultipartFile change to file + * + * @param multiFile + * @return + */ + public static File MultipartFileToFile(MultipartFile multiFile) { + // 获取文件名 + String fileName = multiFile.getOriginalFilename(); + // 获取文件后缀 + String prefix = fileName.substring(fileName.lastIndexOf(".")); + // 若须要防止生成的临时文件重复,能够在文件名后添加随机码 + + try { + File file = File.createTempFile(fileName, prefix); + multiFile.transferTo(file); + return file; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } +} \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ObjectUtilsSelf.java b/common-pom/src/main/java/top/kuanghua/commonpom/utils/SelfObjUtils.java similarity index 64% rename from ty-common/src/main/java/top/kuanghua/khcomomon/utils/ObjectUtilsSelf.java rename to common-pom/src/main/java/top/kuanghua/commonpom/utils/SelfObjUtils.java index b8422c0..45375ad 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ObjectUtilsSelf.java +++ b/common-pom/src/main/java/top/kuanghua/commonpom/utils/SelfObjUtils.java @@ -1,23 +1,20 @@ -package top.kuanghua.khcomomon.utils; +package top.kuanghua.commonpom.utils; import com.alibaba.fastjson.JSON; import org.apache.commons.lang3.StringUtils; import org.springframework.web.multipart.MultipartFile; -import top.kuanghua.khcomomon.entity.ResResult; +import top.kuanghua.commonpom.entity.ResResult; import java.io.File; import java.lang.reflect.Array; import java.text.SimpleDateFormat; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 从jwt解析得到的数据是Object类型,转换为具体类型可能出现空指针, * 这个工具类进行了一些转换 */ -public class ObjectUtilsSelf { +public class SelfObjUtils { /*类型转换*/ public static String toString(Object obj) { if (obj == null) { @@ -58,53 +55,81 @@ public static boolean isEmpty(Object obj) { } else if (obj.getClass().isArray()) { return Array.getLength(obj) == 0; } else if (obj instanceof CharSequence) { - return ((CharSequence)obj).length() == 0; + return ((CharSequence) obj).length() == 0; } else if (obj instanceof Collection) { - return ((Collection)obj).isEmpty(); + return ((Collection) obj).isEmpty(); } else { - return obj instanceof Map ? ((Map)obj).isEmpty() : false; + return obj instanceof Map ? ((Map) obj).isEmpty() : false; } } //解析请求数据 - public static ResResult parseRes(Object resResult){ + public static ResResult parseRes(Object resResult) { ResResult res = JSON.parseObject(JSON.toJSONString(resResult), ResResult.class); return res; } + //解析请求数据到data - public static Map parseResToData(Object result){ + public static Map parseResToData(Object result) { ResResult resResult = parseRes(result); if (resResult.isFlag()) { return JSON.parseObject(JSON.toJSONString(resResult.getData()), Map.class); - }else{ - throw new RuntimeException(resResult.getMsg()); + } else { + throw new RuntimeException(resResult.getMsg()); } } + //解析请求数据到data - public static Map parseResToMap(ResResult resResult){ + public static Map parseResToMap(ResResult resResult) { if (resResult.isFlag()) { return JSON.parseObject(JSON.toJSONString(resResult.getData()), Map.class); - }else{ - throw new RuntimeException(resResult.getMsg()); + } else { + throw new RuntimeException(resResult.getMsg()); } } - public static List parseResToList(ResResult resResult){ + + public static List parseResToList(ResResult resResult) { if (resResult.isFlag()) { return JSON.parseObject(JSON.toJSONString(resResult.getData()), List.class); - }else{ - throw new RuntimeException(resResult.getMsg()); + } else { + throw new RuntimeException(resResult.getMsg()); } } + //将一般的数据转化为map - public static Map changeToMap(Object resResult){ - Map res = JSON.parseObject(JSON.toJSONString(resResult), Map.class); - return res; + public static Map changeToMap(Object resResult) { + return JSON.parseObject(JSON.toJSONString(resResult), Map.class); + } + + /** + * 将Object数据转化为 ArrayList + * + * @param resResult + * @return + */ + public static ArrayList> changeToArrayMap(Object resResult) { + return JSON.parseObject(JSON.toJSONString(resResult), ArrayList.class); + } + + public static ArrayList changeToArrayString(Object resResult) { + return JSON.parseObject(JSON.toJSONString(resResult), ArrayList.class); + } + + public static ArrayList changeToArrayInteger(Object resResult) { + return JSON.parseObject(JSON.toJSONString(resResult), ArrayList.class); } /** * @return 时间年月日 */ - public static String getCurrentDateTime(){ + public static String getCurrentDateTimeTrim() { + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式 + return df.format(new Date()); + } + /** + * @return 时间年月日 + */ + public static String getCurrentDateTime() { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式 return df.format(new Date()); } @@ -112,7 +137,7 @@ public static String getCurrentDateTime(){ /** * @return 当前年月 */ - public static String getCurrentDate(){ + public static String getCurrentDate() { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式 return df.format(new Date()); } @@ -121,14 +146,15 @@ public static String getCurrentDate(){ * @param date * @return */ - public static String formatDateTime(Date date){ + public static String formatDateTime(Date date) { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式 return df.format(date); } /** - * MultipartFile change to file + * MultipartFile change to file + * * @param multiFile * @return */ diff --git a/common-pom/src/main/resources/application-main.yml b/common-pom/src/main/resources/application-main.yml new file mode 100644 index 0000000..7c6bef4 --- /dev/null +++ b/common-pom/src/main/resources/application-main.yml @@ -0,0 +1,17 @@ +envpt: + baseLinuxIp: 8.135.1.141 + mysqlIp: ${envpt.baseLinuxIp} + mysqlPort: 3306 + redisIp: ${envpt.baseLinuxIp} + redisPort: 6379 + rabbitIp: ${envpt.baseLinuxIp} + rabbitPort: 5675 + tomcatPortPre: 2 + +spring: + main: + allow-bean-definition-overriding: true + #解决查询时间和返回的时间不一致问题 + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 diff --git a/ty-common/src/main/resources/config/banner.txt b/common-pom/src/main/resources/config/banner.txt similarity index 98% rename from ty-common/src/main/resources/config/banner.txt rename to common-pom/src/main/resources/config/banner.txt index 1a1dcb9..9cab9d3 100644 --- a/ty-common/src/main/resources/config/banner.txt +++ b/common-pom/src/main/resources/config/banner.txt @@ -1,7 +1,7 @@ - . ____ _ __ _ _ - /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ -( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ - \\/ ___)| |_)| | | | | || (_| | ) ) ) )----☺ ☺ ☺ ☺ ☺ ☺ ☺ ☺ ☺ - ' |____| .__|_| |_|_| |_\__, | / / / / - =========|_|==============|___/=/_/_/_/ + . ____ _ __ _ _ + /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ +( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ + \\/ ___)| |_)| | | | | || (_| | ) ) ) )----☺ ☺ ☺ ☺ ☺ ☺ ☺ ☺ ☺ + ' |____| .__|_| |_|_| |_\__, | / / / / + =========|_|==============|___/=/_/_/_/ :: new general micro service construct:: (v2.2.4RELEASE) \ No newline at end of file diff --git a/ty-common/src/main/resources/config/emp.properties b/common-pom/src/main/resources/config/emp.properties similarity index 91% rename from ty-common/src/main/resources/config/emp.properties rename to common-pom/src/main/resources/config/emp.properties index c9f9905..32cda57 100644 --- a/ty-common/src/main/resources/config/emp.properties +++ b/common-pom/src/main/resources/config/emp.properties @@ -1 +1 @@ -emp.age=30 +emp.age=30 diff --git a/ty-common/src/main/resources/logs/logback-spring.xml b/common-pom/src/main/resources/logs/logback-spring.xml similarity index 100% rename from ty-common/src/main/resources/logs/logback-spring.xml rename to common-pom/src/main/resources/logs/logback-spring.xml diff --git a/ty-common/src/main/resources/spy.properties b/common-pom/src/main/resources/spy.properties similarity index 98% rename from ty-common/src/main/resources/spy.properties rename to common-pom/src/main/resources/spy.properties index b38335b..9e311eb 100644 --- a/ty-common/src/main/resources/spy.properties +++ b/common-pom/src/main/resources/spy.properties @@ -1,23 +1,23 @@ -modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory -# \u81EA\u5B9A\u4E49\u65E5\u5FD7\u6253\u5370 -logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger -#\u65E5\u5FD7\u8F93\u51FA\u5230\u63A7\u5236\u53F0 -appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger -# \u4F7F\u7528\u65E5\u5FD7\u7CFB\u7EDF\u8BB0\u5F55 sql -#appender=com.p6spy.engine.spy.appender.Slf4JLogger -# \u8BBE\u7F6E p6spy driver \u4EE3\u7406 -deregisterdrivers=true -# \u53D6\u6D88JDBC URL\u524D\u7F00 -useprefix=true -# \u914D\u7F6E\u8BB0\u5F55 Log \u4F8B\u5916,\u53EF\u53BB\u6389\u7684\u7ED3\u679C\u96C6\u6709error,info,batch,debug,statement,commit,rollback,result,resultset. -excludecategories=info,debug,result,commit,resultset -# \u65E5\u671F\u683C\u5F0F -dateformat=yyyy-MM-dd HH:mm:ss -# \u5B9E\u9645\u9A71\u52A8\u53EF\u591A\u4E2A -#driverlist=org.h2.Driver -# \u662F\u5426\u5F00\u542F\u6162SQL\u8BB0\u5F55 -outagedetection=true -# \u6162SQL\u8BB0\u5F55\u6807\u51C6 2 \u79D2 -outagedetectioninterval=1 -# \u771F\u5B9EJDBC driver +modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory +# \u81EA\u5B9A\u4E49\u65E5\u5FD7\u6253\u5370 +logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger +#\u65E5\u5FD7\u8F93\u51FA\u5230\u63A7\u5236\u53F0 +appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger +# \u4F7F\u7528\u65E5\u5FD7\u7CFB\u7EDF\u8BB0\u5F55 sql +#appender=com.p6spy.engine.spy.appender.Slf4JLogger +# \u8BBE\u7F6E p6spy driver \u4EE3\u7406 +deregisterdrivers=true +# \u53D6\u6D88JDBC URL\u524D\u7F00 +useprefix=true +# \u914D\u7F6E\u8BB0\u5F55 Log \u4F8B\u5916,\u53EF\u53BB\u6389\u7684\u7ED3\u679C\u96C6\u6709error,info,batch,debug,statement,commit,rollback,result,resultset. +excludecategories=info,debug,result,commit,resultset +# \u65E5\u671F\u683C\u5F0F +dateformat=yyyy-MM-dd HH:mm:ss +# \u5B9E\u9645\u9A71\u52A8\u53EF\u591A\u4E2A +#driverlist=org.h2.Driver +# \u662F\u5426\u5F00\u542F\u6162SQL\u8BB0\u5F55 +outagedetection=true +# \u6162SQL\u8BB0\u5F55\u6807\u51C6 2 \u79D2 +outagedetectioninterval=1 +# \u771F\u5B9EJDBC driver driverlist=com.mysql.cj.jdbc.Driver \ No newline at end of file diff --git a/easycode-temp/controller.mv b/easycode-temp/controller.mv deleted file mode 100644 index 6564d95..0000000 --- a/easycode-temp/controller.mv +++ /dev/null @@ -1,140 +0,0 @@ -##导入宏定义 -$!init -$!define - -##设置表后缀(宏定义) -#setTableSuffix("Controller") - -##保存文件(宏定义) -#save("/controller", "Controller.java") - -##包路径(宏定义) -#setPackageSuffix("controller") - -##定义服务名 -#set($serviceName = $!tool.append($!tool.firstLowerCase($!tableInfo.name), "Service")) - -##定义实体对象名 -#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) - - -import org.apache.commons.lang3.StringUtils; -import top.kuanghua.khcomomon.entity.CommonParams; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.api.ApiController; -import com.baomidou.mybatisplus.extension.api.R; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -##import $!{tableInfo.savePackageName}api.entity.$!tableInfo.name; -import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.io.Serializable; -import java.util.*; - -##表注释(宏定义) -@Api(tags = "$!{tableInfo.comment}($!{tableInfo.name})") -@RestController -@RequestMapping("$!tool.firstLowerCase($!tableInfo.name)") -public class $!{tableInfo.name}Controller { - -@Resource -private $!{tableInfo.name}Service $!{serviceName}; - -/** -* 分页查询所有数据 -* @param $!entityName 查询实体 -* @return 所有数据 -*/ -@GetMapping("selectPage") -@ApiOperation(value = "分页查询所有数据") -public ResResult selectPage($!{tableInfo.name} $!entityName, CommonParams commonParams) { -QueryWrapper<$!{tableInfo.name}> queryWrapper = new QueryWrapper<>(); -#foreach($column in $tableInfo.fullColumn) - #if( $!column.comment ) - if(ObjectUtils.isNotEmpty($!{entityName}.get$!{tool.firstUpperCase($column.name)}())) { - queryWrapper.like("$!{tool.hump2Underline($column.name)}",$!{entityName}.get$!{tool.firstUpperCase($column.name)}()); - } - #end -#end - -#set($StringBj="") -#foreach($column in $tableInfo.fullColumn) - #if( $!column.comment ) - #set($StringBj=$!{StringBj}+$!{tool.hump2Underline($column.name)}+",") - #end -#end - - - -if(StringUtils.isNotEmpty(commonParams.getStartTime())) { -queryWrapper.between("create_time",commonParams.getStartTime(),commonParams.getEndTime()); -queryWrapper.or().orderByDesc("create_time"); -} - -queryWrapper.select("$StringBj.substring(0,$StringBj.lastIndexOf(','))"); -Page<$!{tableInfo.name}> $!{entityName}Page = this.$!{entityName}Service.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); -return new ResResult().success($!{entityName}Page); -} - -/** -* 通过主键查询单条数据 -* @param id 主键 -* @return 单条数据 -*/ -@GetMapping("selectById") -@ApiOperation(value = "通过id主键查询单条数据") -public ResResult selectById(@RequestParam("id") Integer id) { -return new ResResult().success(this.$!{serviceName}.selectById(id)); -} - -/** -* @Description: 根据id数组查询品牌列表 -* @Param: idList id数组 -* @return: ids列表数据 -*/ -@ApiOperation(value = "根据id数组查询品牌列表") -@PostMapping("selectBatchIds") -public ResResult selectBatchIds(@RequestParam("idList") List - idList) { - return new ResResult().success(this.$!{serviceName}.selectBatchIds(idList)); - } - /** - * 新增数据 - * @param $!entityName 实体对象 - * @return 新增结果 - */ - @ApiOperation(value = "新增数据") - @PostMapping("insert") - public ResResult insert(@RequestBody $!{tableInfo.name} $!entityName) { - return new ResResult().success(this.$!{serviceName}.insert($!entityName)); - } - - /** - * 修改数据 - * @param $!entityName 实体对象 - * @return 修改结果 - */ - @ApiOperation(value = "根据id修改数据") - @PutMapping("updateById") - public ResResult updateById(@RequestBody $!{tableInfo.name} $!entityName) { - return new ResResult().success(this.$!{serviceName}.updateById($!entityName)); - } - - /** - * 删除数据 - * @param idList 主键结合 - * @return 删除结果 - */ - @ApiOperation(value = "根据id数组删除数据") - @DeleteMapping("deleteBatchIds") - public ResResult deleteBatchIds(@RequestBody List - idList) { - return new ResResult().success(this.$!{serviceName}.deleteBatchIds(idList)); - } - @DeleteMapping("deleteById") - @ApiOperation(value = "根据id删除数据") - public ResResult deleteById(@RequestParam("id") Integer id) { - return new ResResult().success(this.$!{serviceName}.deleteById(id)); - } - } \ No newline at end of file diff --git a/easycode-temp/element-form.mv b/easycode-temp/element-form.mv deleted file mode 100644 index ee97b17..0000000 --- a/easycode-temp/element-form.mv +++ /dev/null @@ -1,303 +0,0 @@ -##导入宏定义 -$!init -$!define -##定义实体对象名 -#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) -#set($serviceName = 'rbox-service') - -##保存文件(宏定义) -#save($!{entityName}, "Form.vue") - - - - - diff --git a/easycode-temp/element-table.mv b/easycode-temp/element-table.mv deleted file mode 100644 index 92b49c5..0000000 --- a/easycode-temp/element-table.mv +++ /dev/null @@ -1,300 +0,0 @@ -##导入宏定义 -$!init -$!define -##定义实体对象名 -#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) -#set($serviceName = 'rbox-service') - -##保存文件(宏定义) -#save($!{entityName}, ".vue") - - - - - diff --git a/easycode-temp/entity.mv b/easycode-temp/entity.mv deleted file mode 100644 index 451ce4f..0000000 --- a/easycode-temp/entity.mv +++ /dev/null @@ -1,56 +0,0 @@ -##导入宏定义 -$!init -$!define - -##保存文件(宏定义) -#save("/entity", ".java") - -##包路径(宏定义) -#setPackageSuffix("entity") - -##自动导入包(全局变量) -##$!autoImport -import com.baomidou.mybatisplus.extension.activerecord.Model; -import java.io.Serializable; -import lombok.Data; -##表注释(宏定义) -#tableComment("表实体类") -@Data -@ApiModel("$!tableInfo.comment") -@TableName(value = "tb_$!{tool.hump2Underline($tableInfo.name)}") -public class $!{tableInfo.name} extends Model<$!{tableInfo.name}> { -#foreach($column in $tableInfo.fullColumn) - #if( $!column.comment ) - #set($listSize=$!{column.comment.split(';')}) - #if( $!listSize.size() > 0 ) - @ApiModelProperty(value="$!listSize[0]") - #end - #if($column.name.indexOf("updateTime") != -1) - @TableField(fill = FieldFill.UPDATE) - #end - #if($column.name.indexOf("createTime") != -1) - @TableField(fill = FieldFill.INSERT) - #end - #if($column.name.indexOf("isDeleted") != -1) - @TableLogic - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - #end - #end -private $!{tool.getClsNameByFullName($column.type)} $!{column.name}; -#end -###foreach($column in $tableInfo.fullColumn) -###getSetMethod($column) -###end -#foreach($column in $tableInfo.pkColumn) -/** -* 获取主键值 -* -* @return 主键值 -*/ -@Override -protected Serializable pkVal() { -return this.$!column.name; -} - #break -#end -} diff --git a/easycode-temp/mapper.mv b/easycode-temp/mapper.mv deleted file mode 100644 index 875226c..0000000 --- a/easycode-temp/mapper.mv +++ /dev/null @@ -1,19 +0,0 @@ -##导入宏定义 -$!init -$!define - -##设置表后缀(宏定义) -#setTableSuffix("Mapper") - -##保存文件(宏定义) -#save("/mapper", "Mapper.java") - -##包路径(宏定义) -#setPackageSuffix("mapper") - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; - -##表注释(宏定义) -public interface $!{tableName} extends BaseMapper<$!tableInfo.name> { - -} \ No newline at end of file diff --git a/easycode-temp/service.mv b/easycode-temp/service.mv deleted file mode 100644 index fa646ee..0000000 --- a/easycode-temp/service.mv +++ /dev/null @@ -1,54 +0,0 @@ -##导入宏定义 -$!init -$!define - -##设置表后缀(宏定义) -#setTableSuffix("Service") - -##保存文件(宏定义) -#save("/service", "Service.java") -##定义服务名 -##定义实体对象名 -#set($entityName = $!tool.firstLowerCase($!tableInfo.name)) -##包路径(宏定义) -#setPackageSuffix("service") -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -/** -* ($!{tableInfo.name}) -* @author kuanghua -* @since $time.currTime() -*/ -@Service -public class $!{tableInfo.name}Service{ - - @Resource - private $!{tableInfo.name}Mapper $!{entityName}Mapper; - - public Page<$!{tableInfo.name}> selectPage(Integer pageNum, Integer pageSize, QueryWrapper<$!{tableInfo.name}> queryWrapper) { - return this.$!{entityName}Mapper.selectPage(new Page<$!{tableInfo.name}>(pageNum, pageSize),queryWrapper); - } - - public $!{tableInfo.name} selectById(Integer id) { - return this.$!{entityName}Mapper.selectById(id); - } - - public List<$!{tableInfo.name}> selectBatchIds(List idList) { - return this.$!{entityName}Mapper.selectBatchIds(idList); - } - - public int insert($!{tableInfo.name} $!{entityName}) { - return this.$!{entityName}Mapper.insert($!{entityName}); - } - - public int updateById($!{tableInfo.name} $!{entityName}) { - return this.$!{entityName}Mapper.updateById($!{entityName}); - } - - public int deleteById(Integer id) { - return this.$!{entityName}Mapper.deleteById(id); - } - - public int deleteBatchIds(List idList) { - return this.$!{entityName}Mapper.deleteBatchIds(idList); - } -} \ No newline at end of file diff --git a/ty-auth/pom.xml b/gateway/pom.xml similarity index 53% rename from ty-auth/pom.xml rename to gateway/pom.xml index c04f8eb..0e4b8f4 100644 --- a/ty-auth/pom.xml +++ b/gateway/pom.xml @@ -9,20 +9,39 @@ 4.0.0 - ty-auth - + gateway top.kuanghua - ty-common + common-pom 1.0-SNAPSHOT + + top.kuanghua + auth-pom + 1.0-SNAPSHOT + + + org.springframework.cloud + spring-cloud-starter-gateway + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework + spring-webmvc + + + org.apache.tomcat.embed + tomcat-embed-core + + + - - ${project.artifactId} - src/main/resources @@ -34,10 +53,14 @@ org.springframework.boot spring-boot-maven-plugin + + org.apache.maven.plugins + maven-resources-plugin + 3.1.0 + org.apache.maven.plugins maven-surefire-plugin - 2.22.1 true diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/AuthApplication.java b/gateway/src/main/java/top/kuanghua/gateway/GatewayApplication.java similarity index 58% rename from ty-auth/src/main/java/top/kuanghua/tyauth/AuthApplication.java rename to gateway/src/main/java/top/kuanghua/gateway/GatewayApplication.java index 35c4842..e736d4a 100644 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/AuthApplication.java +++ b/gateway/src/main/java/top/kuanghua/gateway/GatewayApplication.java @@ -1,12 +1,18 @@ -package top.kuanghua.tyauth; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; - -@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) -public class AuthApplication { - public static void main(String[] args) { - SpringApplication.run(AuthApplication.class,args); - } -} +package top.kuanghua.gateway; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; + +/** + * @Title: GatewayTwoApplication + * @Description: + * @Auther: kuanghua + * @create 2020/10/27 10:32 + */ +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) +public class GatewayApplication { + public static void main(String[] args) { + SpringApplication.run(GatewayApplication.class, args); + } +} diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/GatewayOneApplication.java b/gateway/src/main/java/top/kuanghua/gateway/config/BaseConfig.java similarity index 57% rename from ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/GatewayOneApplication.java rename to gateway/src/main/java/top/kuanghua/gateway/config/BaseConfig.java index 4b46482..b0873f4 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/GatewayOneApplication.java +++ b/gateway/src/main/java/top/kuanghua/gateway/config/BaseConfig.java @@ -1,40 +1,46 @@ -package top.kuanghua.gatewaytwo; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver; -import org.springframework.context.annotation.Bean; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.web.server.ServerWebExchange; -import reactor.core.publisher.Mono; - -/** - * @Title: GatewayTwoApplication - * @Description: - * @Auther: kuanghua - * @create 2020/10/27 10:32 - */ -@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) -public class GatewayOneApplication { - public static void main(String[] args) { - SpringApplication.run(GatewayOneApplication.class, args); - } - - //创建一个ipKeyResolver 指定用户的IP - @Bean(name = "ipKeyResolver") - public KeyResolver keyResolver() { - return new KeyResolver() { - @Override - public Mono resolve(ServerWebExchange exchange) { - //1.获取请求request对象 - ServerHttpRequest request = exchange.getRequest(); - //2.从request中获取ip地址 - String hostString = request.getRemoteAddress().getHostString(); - //3.返回 - return Mono.just(hostString); - } - }; - } - -} +package top.kuanghua.gateway.config; + +import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Mono; + +/** + * @Title: BaseConfig + * @Description: + * @Auther: kuanghua + * @create 2020/8/23 21:52 + */ +/* + * 总结:1.@Configuration 下的@ComponentScan回将包下带有@Component扫描变成配置类, + * 而@SpringBootApplication扫描的只会变成普通类 + * */ +@Configuration +@ComponentScan(basePackages = { + "top.kuanghua.commonpom", + "top.kuanghua.authpom", + "top.kuanghua.gateway" +}) +@EnableFeignClients(basePackages = {"top.kuanghua.commonpom.feign"}) +public class BaseConfig { + //创建一个ipKeyResolver 指定用户的IP + @Bean(name = "ipKeyResolver") + public KeyResolver keyResolver() { + return new KeyResolver() { + @Override + public Mono resolve(ServerWebExchange exchange) { + //1.获取请求request对象 + ServerHttpRequest request = exchange.getRequest(); + //2.从request中获取ip地址 + String hostString = request.getRemoteAddress().getHostString(); + //3.返回 + return Mono.just(hostString); + } + }; + } + +} diff --git a/gateway/src/main/java/top/kuanghua/gateway/config/MySwaggerResourceProvider.java b/gateway/src/main/java/top/kuanghua/gateway/config/MySwaggerResourceProvider.java new file mode 100644 index 0000000..0d7bff7 --- /dev/null +++ b/gateway/src/main/java/top/kuanghua/gateway/config/MySwaggerResourceProvider.java @@ -0,0 +1,64 @@ +package top.kuanghua.gateway.config; + +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.gateway.route.RouteLocator; +import org.springframework.stereotype.Component; +import springfox.documentation.swagger.web.SwaggerResource; +import springfox.documentation.swagger.web.SwaggerResourcesProvider; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Component +@RequiredArgsConstructor +public class MySwaggerResourceProvider implements SwaggerResourcesProvider { + + /** + * swagger2默认的url后缀 + */ + private static final String SWAGGER2_URL = "/v2/api-docs"; + + /** + * 路由定位器 + */ + private final RouteLocator routeLocator; + + /** + * 网关应用名称 + */ + @Value("${spring.application.name}") + private String gatewayName; + + /** + * 获取 Swagger 资源 + */ + @Override + public List get() { + List resources = new ArrayList<>(); + List> routeInfoList = new ArrayList>(); + // 1. 获取路由Uri 中的Host=> 服务注册则为服务名=》app-service001 + routeLocator.getRoutes() + .filter(route -> route.getUri().getHost() != null) + .filter(route -> !gatewayName.equals(route.getUri().getHost())) + .subscribe(route -> { + HashMap hashMap = new HashMap<>(); + hashMap.put("serviceId", route.getUri().getHost()); + hashMap.put("serviceName", route.getMetadata().get("name").toString()); + routeInfoList.add(hashMap); + }); + // 2. 创建自定义资源 + routeInfoList.forEach((feMap) -> { + String serviceUrl = "/micro-service-api/" + feMap.get("serviceId") + SWAGGER2_URL; // 后台访问添加服务名前缀 + SwaggerResource swaggerResource = new SwaggerResource(); // 创建Swagger 资源 + swaggerResource.setUrl(serviceUrl); // 设置访问地址 + swaggerResource.setName(feMap.get("serviceName")); // 设置名称 + swaggerResource.setSwaggerVersion("2.0.9"); + resources.add(swaggerResource); + }); + return resources; + } +} + diff --git a/gateway/src/main/java/top/kuanghua/gateway/controller/SwaggerResourceController.java b/gateway/src/main/java/top/kuanghua/gateway/controller/SwaggerResourceController.java new file mode 100644 index 0000000..009e595 --- /dev/null +++ b/gateway/src/main/java/top/kuanghua/gateway/controller/SwaggerResourceController.java @@ -0,0 +1,24 @@ +package top.kuanghua.gateway.controller; + +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import springfox.documentation.swagger.web.SwaggerResource; +import top.kuanghua.gateway.config.MySwaggerResourceProvider; + +import java.util.List; + +@RestController +@RequestMapping("/swagger-resources") +@RequiredArgsConstructor +public class SwaggerResourceController { + private final MySwaggerResourceProvider swaggerResourceProvider; + + @RequestMapping + public ResponseEntity> swaggerResources() { + return new ResponseEntity<>(swaggerResourceProvider.get(), HttpStatus.OK); + } +} + diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java b/gateway/src/main/java/top/kuanghua/gateway/filter/AuthorizeFilterAfter.java similarity index 85% rename from ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java rename to gateway/src/main/java/top/kuanghua/gateway/filter/AuthorizeFilterAfter.java index ff859cf..4e1ed83 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterAfter.java +++ b/gateway/src/main/java/top/kuanghua/gateway/filter/AuthorizeFilterAfter.java @@ -1,135 +1,133 @@ -package top.kuanghua.gatewaytwo.filter; - -import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.joda.time.DateTime; -import org.reactivestreams.Publisher; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.cloud.gateway.filter.GatewayFilterChain; -import org.springframework.cloud.gateway.filter.GlobalFilter; -import org.springframework.core.Ordered; -import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.io.buffer.DataBufferFactory; -import org.springframework.core.io.buffer.DataBufferUtils; -import org.springframework.core.io.buffer.DefaultDataBufferFactory; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.http.server.reactive.ServerHttpResponse; -import org.springframework.http.server.reactive.ServerHttpResponseDecorator; -import org.springframework.stereotype.Component; -import org.springframework.web.server.ServerWebExchange; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import top.kuanghua.feign.tyauth.feign.TokenFeign; -import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; - -import javax.annotation.Resource; -import java.net.URLDecoder; -import java.nio.charset.Charset; -import java.util.List; -import java.util.Map; - -/** - * @Title: AuthorizeFilter - * @Description: - * @Auther: kuanghua - * @create 2020/9/8 21:26 - */ -@Slf4j -@Component -public class AuthorizeFilterAfter implements GlobalFilter, Ordered { - - @Value("#{'${filter.allowPaths:}'.empty ? null : '${filter.allowPaths:}'.split(',')}") - private List allowPaths; - - @Resource - private TokenFeign tokenFeign; - - @Value("${token-properties.renewTokenMinute}") - private int renewTokenMinute; - - @Override - public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { - ServerHttpRequest request = exchange.getRequest(); - ServerHttpResponse response = exchange.getResponse(); - DataBufferFactory bufferFactory = response.bufferFactory(); - String path = request.getURI().getPath(); - - //白名单拦截 - for (String allowPath : allowPaths) { - if (StringUtils.contains(path, allowPath)) { - return chain.filter(exchange); - } - } - - - //获取token信息比较exp和当前时间进行比较 - ServerHttpResponseDecorator decoratedResponse = null; - try { - decoratedResponse = new ServerHttpResponseDecorator(response) { - @Override - public Mono writeWith(Publisher body) { - if (body instanceof Flux) { - Flux fluxBody = (Flux) body; - return super.writeWith(fluxBody.buffer().map(dataBuffers -> { - DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory(); - DataBuffer join = dataBufferFactory.join(dataBuffers); - byte[] content = new byte[join.readableByteCount()]; - join.read(content); - // 释放掉内存 - DataBufferUtils.release(join); - String str = new String(content, Charset.forName("UTF-8")); - // log.info("返回体:{}", str); - //todo 拦截到的返回体内容,可以随意去操作了 - //2.1.2 如果小于一个小时 刷新token - //String jwtToken = request.getHeaders().getFirst("AUTHORIZE_TOKEN"); - Long expValue = null; - Map dataMap = null; - try { - String tokenInfo = request.getHeaders().getFirst("TOKEN_INFO"); - dataMap = JSON.parseObject(URLDecoder.decode(tokenInfo, "utf-8"), Map.class); - expValue = ObjectUtilsSelf.toLong(ObjectUtilsSelf.toString(dataMap.get("exp")) + "000"); - } catch (Exception e) { - e.printStackTrace(); - } - Long currentData = DateTime.now().plusMinutes(renewTokenMinute).getMillis(); - Map strMap = JSON.parseObject(str, Map.class); - if (ObjectUtils.isNotEmpty(expValue) && expValue < currentData) { - String generateToken = null; - try { - //调用ty-auth进行生成 - dataMap.remove("exp"); - dataMap.remove("iat"); - Object object = tokenFeign.updateToken(dataMap); - if (ObjectUtilsSelf.isEmpty(object)) { - return bufferFactory.wrap(str.getBytes()); - } - Map map = JSON.parseObject(JSON.toJSONString(object), Map.class); - generateToken = ObjectUtilsSelf.toString(map.get("data")); - } catch (Exception e) { - log.error(e.toString()); - } - strMap.put("isNeedUpdateToken", true); - strMap.put("updateToken", generateToken); - } - response.getHeaders().setContentLength(JSON.toJSONString(strMap).getBytes().length); - return bufferFactory.wrap(JSON.toJSONString(strMap).getBytes()); - })); - } - // if body is not a flux. never got there. - return super.writeWith(body); - } - }; - } catch (Exception e) { - return chain.filter(exchange); - } - return chain.filter(exchange.mutate().response(decoratedResponse).build()); - } - - /*-1代表请求后触发*/ - @Override - public int getOrder() { - return -1; - } -} +package top.kuanghua.gateway.filter; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.joda.time.DateTime; +import org.reactivestreams.Publisher; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.gateway.filter.GatewayFilterChain; +import org.springframework.cloud.gateway.filter.GlobalFilter; +import org.springframework.core.Ordered; +import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.core.io.buffer.DataBufferFactory; +import org.springframework.core.io.buffer.DataBufferUtils; +import org.springframework.core.io.buffer.DefaultDataBufferFactory; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.http.server.reactive.ServerHttpResponse; +import org.springframework.http.server.reactive.ServerHttpResponseDecorator; +import org.springframework.stereotype.Component; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import top.kuanghua.authpom.service.TokenService; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import javax.annotation.Resource; +import java.net.URLDecoder; +import java.nio.charset.Charset; +import java.util.List; +import java.util.Map; + +/** + * @Title: AuthorizeFilter + * @Description: + * @Auther: kuanghua + * @create 2020/9/8 21:26 + */ +@Slf4j +@Component +public class AuthorizeFilterAfter implements GlobalFilter, Ordered { + + @Value("#{'${filter.afterNeedFilterPaths:}'.empty ? null : '${filter.afterNeedFilterPaths:}'.split(',')}") + private List afterNeedFilterPaths; + + @Resource + private TokenService tokenService; + + @Value("${token-properties.renewTokenMinute}") + private int renewTokenMinute; + + @Override + public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { + ServerHttpRequest request = exchange.getRequest(); + ServerHttpResponse response = exchange.getResponse(); + DataBufferFactory bufferFactory = response.bufferFactory(); + String path = request.getURI().getPath(); + + //白名单拦截 + for (String allowPath : afterNeedFilterPaths) { + if (!StringUtils.contains(path, allowPath)) { + return chain.filter(exchange); + } + } + //获取token信息比较exp和当前时间进行比较 + ServerHttpResponseDecorator decoratedResponse = null; + try { + decoratedResponse = new ServerHttpResponseDecorator(response) { + @Override + public Mono writeWith(Publisher body) { + if (body instanceof Flux) { + Flux fluxBody = (Flux) body; + return super.writeWith(fluxBody.buffer().map(dataBuffers -> { + DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory(); + DataBuffer join = dataBufferFactory.join(dataBuffers); + byte[] content = new byte[join.readableByteCount()]; + join.read(content); + // 释放掉内存 + DataBufferUtils.release(join); + String str = new String(content, Charset.forName("UTF-8")); + // log.info("返回体:{}", str); + //todo 拦截到的返回体内容,可以随意去操作了 + //2.1.2 如果小于一个小时 刷新token + //String jwtToken = request.getHeaders().getFirst("AUTHORIZE_TOKEN"); + Long expValue = null; + Map dataMap = null; + try { + String tokenInfo = request.getHeaders().getFirst("TOKEN_INFO"); + dataMap = JSON.parseObject(URLDecoder.decode(tokenInfo, "utf-8"), Map.class); + expValue = ObjSelfUtils.toLong(ObjSelfUtils.toString(dataMap.get("exp")) + "000"); + } catch (Exception e) { + e.printStackTrace(); + } + Long currentData = DateTime.now().plusMinutes(renewTokenMinute).getMillis(); + Map strMap = JSON.parseObject(str, Map.class); + if (ObjectUtils.isNotEmpty(expValue) && expValue < currentData) { + String generateToken = null; + try { + //调用ty-auth进行生成 + dataMap.remove("exp"); + dataMap.remove("iat"); + Object object = tokenService.updateToken(dataMap); + if (ObjSelfUtils.isEmpty(object)) { + return bufferFactory.wrap(str.getBytes()); + } + Map map = JSON.parseObject(JSON.toJSONString(object), Map.class); + generateToken = ObjSelfUtils.toString(map.get("data")); + } catch (Exception e) { + log.error(e.toString()); + } + strMap.put("isNeedUpdateToken", true); + strMap.put("updateToken", generateToken); + } + response.getHeaders().setContentLength(JSON.toJSONString(strMap).getBytes().length); + return bufferFactory.wrap(JSON.toJSONString(strMap).getBytes()); + })); + } + // if body is not a flux. never got there. + return super.writeWith(body); + } + }; + } catch (Exception e) { + return chain.filter(exchange); + } + return chain.filter(exchange.mutate().response(decoratedResponse).build()); + } + + /*-1代表请求后触发*/ + @Override + public int getOrder() { + return -1; + } +} diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java b/gateway/src/main/java/top/kuanghua/gateway/filter/AuthorizeFilterBefore.java similarity index 81% rename from ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java rename to gateway/src/main/java/top/kuanghua/gateway/filter/AuthorizeFilterBefore.java index e902ea0..1aa2af6 100644 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/filter/AuthorizeFilterBefore.java +++ b/gateway/src/main/java/top/kuanghua/gateway/filter/AuthorizeFilterBefore.java @@ -1,119 +1,108 @@ -package top.kuanghua.gatewaytwo.filter; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.cloud.gateway.filter.GatewayFilterChain; -import org.springframework.cloud.gateway.filter.GlobalFilter; -import org.springframework.core.Ordered; -import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.http.server.reactive.ServerHttpResponse; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; -import org.springframework.web.server.ServerWebExchange; -import reactor.core.publisher.Mono; -import top.kuanghua.feign.tyauth.feign.TokenFeign; -import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; - -import javax.annotation.Resource; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.List; -import java.util.Map; - -/** - * @Title: AuthorizeFilter - * @Description: - * @Auther: kuanghua - * @create 2020/9/8 21:26 - */ -@Slf4j -@Component -//https://www.cnblogs.com/javastack/archive/2020/10/23/13862164.html -//https://www.jianshu.com/p/f3383e7b1faf -//https://blog.csdn.net/weixin_41187876/article/details/103645102?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-1.control -/* -* @Value("#{'${scio.cloud.list}'.split(',')}") -private List list; -@Value("#{${scio.cloud.maps}}") -private Map maps; -* */ -public class AuthorizeFilterBefore implements GlobalFilter, Ordered { - - private static final String AUTHORIZE_TOKEN = "AUTHORIZE_TOKEN"; - @Value("#{'${filter.allowPaths:}'.empty ? null : '${filter.allowPaths:}'.split(',')}") - private List allowPaths; - - @Resource - private TokenFeign tokenFeign; - - @Override - public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { - ServerHttpRequest request = exchange.getRequest(); - ServerHttpResponse response = exchange.getResponse(); - - String path = request.getURI().getPath(); - - //1.白名单放行 - for (String allowPath : allowPaths) { - if (StringUtils.contains(path, allowPath)) { - return chain.filter(exchange); - } - } - //2.解析jwt token放行 - String jwtToken = request.getHeaders().getFirst(AUTHORIZE_TOKEN); - - if (ObjectUtils.isEmpty(jwtToken)) { - JSONObject message = new JSONObject(); - message.put("code", 403); - message.put("msg", "token为空"); - DataBuffer buffer = getDataBuffer(response, message); - return response.writeWith(Mono.just(buffer)); - } - //2.1 将解析到的jwt数据保存到线程中(转发过去的服务都能接收) - try { - //调用feign服务进行解析 - Object resResult = tokenFeign.parseToken(jwtToken); - - Map tokenInfo = ObjectUtilsSelf.parseResToData(resResult); - log.info("解析的token数据", tokenInfo.toString()); - //将信息设置到头部 - ServerHttpRequest httpRequest = exchange.getRequest().mutate().headers(httpHeaders -> { - String decode = ""; - try { - decode = URLEncoder.encode(JSON.toJSONString(tokenInfo), "utf-8"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - httpHeaders.add("TOKEN_INFO", decode); - }).build(); - //将信息设置到线程中 - ServerWebExchange build = exchange.mutate().request(httpRequest).build(); - return chain.filter(build); - } catch (Exception e) { - JSONObject message = new JSONObject(); - message.put("code", 403); - message.put("msg", "token解析失败" + e.getMessage()); - log.error("token解析失败" + e); - return response.writeWith(Mono.just(getDataBuffer(response, message))); - } - } - - private DataBuffer getDataBuffer(ServerHttpResponse response, JSONObject message) { - byte[] bits = message.toJSONString().getBytes(StandardCharsets.UTF_8); - DataBuffer buffer = response.bufferFactory().wrap(bits); - //response.setStatusCode(HttpStatus.UNAUTHORIZED); - //指定编码,否则在浏览器中会中文乱码 - response.getHeaders().add("Content-Type", "text/plain;charset=UTF-8"); - return buffer; - } - - @Override - public int getOrder() { - return 1; - } -} +package top.kuanghua.gateway.filter; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.gateway.filter.GatewayFilterChain; +import org.springframework.cloud.gateway.filter.GlobalFilter; +import org.springframework.core.Ordered; +import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.http.server.reactive.ServerHttpResponse; +import org.springframework.stereotype.Component; +import org.springframework.util.ObjectUtils; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Mono; +import top.kuanghua.authpom.service.TokenService; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import javax.annotation.Resource; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Map; + +/** + * @Title: AuthorizeFilter + * @Description: + * @Auther: kuanghua + * @create 2020/9/8 21:26 + */ +@Slf4j +@Component +public class AuthorizeFilterBefore implements GlobalFilter, Ordered { + + private static final String AUTHORIZE_TOKEN = "AUTHORIZE_TOKEN"; + @Value("#{'${filter.allowPaths:}'.empty ? null : '${filter.allowPaths:}'.split(',')}") + private List allowPaths; + + @Resource + private TokenService tokenService; + + @Override + public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { + ServerHttpRequest request = exchange.getRequest(); + ServerHttpResponse response = exchange.getResponse(); + + String path = request.getURI().getPath(); + log.info(path); + //1.白名单放行 + for (String allowPath : allowPaths) { + if (StringUtils.contains(path, allowPath)) { + return chain.filter(exchange); + } + } + //2.解析jwt token放行 + String jwtToken = request.getHeaders().getFirst(AUTHORIZE_TOKEN); + + if (ObjectUtils.isEmpty(jwtToken)) { + JSONObject message = new JSONObject(); + message.put("code", 403); + message.put("msg", "token为空"); + DataBuffer buffer = getDataBuffer(response, message); + return response.writeWith(Mono.just(buffer)); + } + //2.1 将解析到的jwt数据保存到线程中(转发过去的服务都能接收) + try { + //调用feign服务进行解析 + Object resResult = tokenService.parseToken(jwtToken); + + Map tokenInfo = ObjSelfUtils.changeToMap(resResult); + log.info("解析的token数据", tokenInfo.toString()); + //将信息设置到头部 + ServerHttpRequest httpRequest = exchange.getRequest().mutate().headers(httpHeaders -> { + String decode = ""; + try { + decode = URLEncoder.encode(JSON.toJSONString(tokenInfo), "utf-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + httpHeaders.add("TOKEN_INFO", decode); + }).build(); + //将信息设置到线程中 + ServerWebExchange build = exchange.mutate().request(httpRequest).build(); + return chain.filter(build); + } catch (Exception e) { + JSONObject message = new JSONObject(); + message.put("code", 403); + message.put("msg", "token解析失败" + e.getMessage()); + log.error("token解析失败" + e); + return response.writeWith(Mono.just(getDataBuffer(response, message))); + } + } + private DataBuffer getDataBuffer(ServerHttpResponse response, JSONObject message) { + byte[] bits = message.toJSONString().getBytes(StandardCharsets.UTF_8); + DataBuffer buffer = response.bufferFactory().wrap(bits); + //response.setStatusCode(HttpStatus.UNAUTHORIZED); + //指定编码,否则在浏览器中会中文乱码 + response.getHeaders().add("Content-Type", "text/plain;charset=UTF-8"); + return buffer; + } + @Override + public int getOrder() { + return 1; + } +} diff --git a/gateway/src/main/resources/application.yml b/gateway/src/main/resources/application.yml new file mode 100644 index 0000000..ca61614 --- /dev/null +++ b/gateway/src/main/resources/application.yml @@ -0,0 +1,58 @@ +server: + port: ${envpt.tomcatPortPre}0156 +spring: + cloud: + gateway: + # globalcors: + # corsConfigurations: + # '[/**]': + # allow-credentials: true + # allowed-origin-patterns: "*" + # allowed-headers: "*" + # allowed-methods: + # - OPTIONS + # - GET + # - POST + # - PUT + # - DELETE + # #max-age: 3600 + routes: + - id: integration-front + uri: lb://integration-front + metadata: + name: "集成前端服务" + predicates: + - Path=/micro-service-api/integration-front/** + filters: + - StripPrefix=2 + - id: basis-func + uri: lb://basis-func + metadata: + name: "基础功能服务" + predicates: + - Path=/micro-service-api/basis-func/** + filters: + - StripPrefix=2 +management: + endpoint: + gateway: + enabled: true + web: + exposure: + include: true + + +#白名单过滤 +filter: + afterNeedFilterPaths: user + allowPaths: swagger,docs,userRegister,userLogin,sendEmailCode,registry,login,loginOut,insertUser,export,excel,file,zip + +#默认3天时间告知前端刷新token +token-properties: + renewTokenMinute: 3440 + + + + + + diff --git a/gateway/src/main/resources/bootstrap.yml b/gateway/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..d92ceb4 --- /dev/null +++ b/gateway/src/main/resources/bootstrap.yml @@ -0,0 +1,15 @@ +spring: + application: + name: @project.artifactId@ + profiles: + active: @activatedProperties@,main + cloud: + nacos: + discovery: + namespace: @nacosNamespace@ + group: @nacosGroup@ + username: @nacosUsername@ + password: @nacosPassword@ + server-addr: @nacosIpPort@ + weight: @nacosWeight@ + ip: @nacosDiscoveryIp@ diff --git a/integration-front/pom.xml b/integration-front/pom.xml index 8fea0ed..af765c7 100644 --- a/integration-front/pom.xml +++ b/integration-front/pom.xml @@ -8,29 +8,33 @@ 1.0-SNAPSHOT 4.0.0 - integration-front - - com.alibaba - easyexcel - 3.0.1 + top.kuanghua + common-pom + 1.0-SNAPSHOT top.kuanghua - ty-common + auth-pom 1.0-SNAPSHOT + + com.alibaba + easyexcel + 3.0.1 + + + + + - ${project.artifactId} - src/main/resources - true @@ -39,11 +43,14 @@ org.springframework.boot spring-boot-maven-plugin - + + org.apache.maven.plugins + maven-resources-plugin + 3.1.0 + org.apache.maven.plugins maven-surefire-plugin - 2.22.1 true diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/IntegrationFrontApplication.java b/integration-front/src/main/java/top/kuanghua/integrationfront/IntegrationFrontApplication.java index ac8b53d..e6fb78b 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/IntegrationFrontApplication.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/IntegrationFrontApplication.java @@ -1,6 +1,5 @@ package top.kuanghua.integrationfront; -import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -11,7 +10,6 @@ * @create 2020/11/7 20:07 */ @SpringBootApplication -@EnableAutoDataSourceProxy public class IntegrationFrontApplication { public static void main(String[] args) { SpringApplication.run(IntegrationFrontApplication.class, args); diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/config/BaseConfig.java b/integration-front/src/main/java/top/kuanghua/integrationfront/config/BaseConfig.java index 6d960e2..309ec76 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/config/BaseConfig.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/config/BaseConfig.java @@ -5,22 +5,14 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -/** - * @Title: BaseConfig - * @Description: - * @Auther: kuanghua - * @create 2020/8/23 21:52 - */ -/* - * 总结:1.@Configuration 下的@ComponentScan回将包下带有@Component扫描变成配置类, - * 而@SpringBootApplication扫描的只会变成普通类 - * */ + @Configuration -//扫描公用包的配置和自身的配置类 -@ComponentScan(basePackages = {"top.kuanghua.khcomomon", "top.kuanghua.integrationfront"}) -//feign扫描 -@EnableFeignClients(basePackages = {"top.kuanghua.feign.tyauth"}) -//mapper包扫描 +@ComponentScan(basePackages = { + "top.kuanghua.commonpom", + "top.kuanghua.authpom", + "top.kuanghua.integrationfront" +}) +@EnableFeignClients(basePackages = {"top.kuanghua.commonpom.feign.tyauth"}) @MapperScan(basePackages = {"top.kuanghua.integrationfront.mapper"}) public class BaseConfig { diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/config/Knife4jConfiguration.java b/integration-front/src/main/java/top/kuanghua/integrationfront/config/Knife4jConfiguration.java new file mode 100644 index 0000000..fa9eb0b --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/config/Knife4jConfiguration.java @@ -0,0 +1,39 @@ +package top.kuanghua.integrationfront.config; + +import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; + +@Configuration +@EnableSwagger2WebMvc +@EnableKnife4j +public class Knife4jConfiguration { + @Bean + public Docket createRestApi() { + return new Docket(DocumentationType.SWAGGER_2) + .useDefaultResponseMessages(false) + .apiInfo(apiInfo()) + .select().apis(RequestHandlerSelectors.basePackage("top.kuanghua.integrationfront")) + .paths(PathSelectors.any()) + .build(); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .description("Kinfe4j 集成测试文档") + .contact(new Contact("熊猫哥", "https://github.com/jzfai/", "869653722@qq.com")) + .version("v1.1.0") + .title("API测试文档") + .build(); + } + +} + diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/config/Swagger2Config.java b/integration-front/src/main/java/top/kuanghua/integrationfront/config/Swagger2Config.java deleted file mode 100644 index 0f38531..0000000 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/config/Swagger2Config.java +++ /dev/null @@ -1,56 +0,0 @@ -package top.kuanghua.integrationfront.config; - -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Component -@EnableSwagger2 //开启在线接口文档 -//配置包扫描 -public class Swagger2Config { - private boolean swagger_is_enable = true; -// @Value("${.ipAddr}") -// private String ipAddr; - @Value("${server.port}") - private String port; - - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .enable(swagger_is_enable) - //.host(this.ipAddr + ":" + this.port) - .apiInfo(apiInfo()) - .select() - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) - //.apis(basePackage("top.kuanghua.swagger.controller")) - .paths(PathSelectors.any()) - .build(); - } - - /** - * 构建 api文档的详细信息函数 - * - * @return - */ - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("标题:swagger文档") - .description("描述:新一代的微服务架构") - .contact(new Contact("jzfai", null, "869653722@qq.com")) - .version("版本号:2.8") - .build(); - } - - /** - * http://localhost:8080/swagger-ui.html - */ -} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/BrandController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/BrandController.java index 89d3974..73229e0 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/BrandController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/BrandController.java @@ -8,10 +8,10 @@ import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; +import top.kuanghua.commonpom.entity.ResResult; +import top.kuanghua.commonpom.entity.SelfCommonParams; import top.kuanghua.integrationfront.entity.Brand; import top.kuanghua.integrationfront.service.BrandService; -import top.kuanghua.khcomomon.entity.KHCommonParams; -import top.kuanghua.khcomomon.entity.ResResult; import javax.annotation.Resource; import java.util.List; @@ -32,7 +32,7 @@ public class BrandController { */ @GetMapping("selectPage") @ApiOperation(value = "分页查询所有数据") - public ResResult selectPage(Brand brand, KHCommonParams commonParams) { + public ResResult selectPage(Brand brand, SelfCommonParams commonParams) { QueryWrapper queryWrapper = new QueryWrapper<>(); if (ObjectUtils.isNotEmpty(brand.getId())) { queryWrapper.like("id", brand.getId()); diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/ErrorCollectionController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/ErrorCollectionController.java index 47283aa..94bb5d8 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/ErrorCollectionController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/ErrorCollectionController.java @@ -8,10 +8,10 @@ import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; +import top.kuanghua.commonpom.entity.ResResult; +import top.kuanghua.commonpom.entity.SelfCommonParams; import top.kuanghua.integrationfront.entity.ErrorCollection; import top.kuanghua.integrationfront.service.ErrorCollectionService; -import top.kuanghua.khcomomon.entity.KHCommonParams; -import top.kuanghua.khcomomon.entity.ResResult; import javax.annotation.Resource; import java.util.List; @@ -32,7 +32,7 @@ public class ErrorCollectionController { */ @GetMapping("selectPage") @ApiOperation(value = "分页查询所有数据") - public ResResult selectPage(ErrorCollection errorCollection, KHCommonParams khCommonParams) { + public ResResult selectPage(ErrorCollection errorCollection, SelfCommonParams khCommonParams) { QueryWrapper queryWrapper = new QueryWrapper<>(); if (ObjectUtils.isNotEmpty(errorCollection.getErrorLog())) { queryWrapper.like("error_log", errorCollection.getErrorLog()); diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/PairmentController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/PairmentController.java new file mode 100644 index 0000000..38e3e7f --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/PairmentController.java @@ -0,0 +1,89 @@ +package top.kuanghua.integrationfront.controller; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; +import top.kuanghua.commonpom.entity.ResResult; +import top.kuanghua.commonpom.entity.SelfCommonParams; +import top.kuanghua.integrationfront.entity.Pairment; +import top.kuanghua.integrationfront.service.PairmentService; +import top.kuanghua.integrationfront.vo.PairmentVo; + +import javax.annotation.Resource; +import java.util.Map; + +/** + * 多表中实体类的注释Controller + * + * @author 熊猫哥 + * @since 2022-06-25 10:32:12 + */ +@Api(tags = "维修信息") +@RestController +@RequestMapping("pairment") +public class PairmentController { + @Resource + private PairmentService pairmentService; + + @ApiOperation(value = "多表测试") + @GetMapping("selectPairment") + public Page selectPairment(SelfCommonParams commonParams, PairmentVo pairmentVo) { + Map pairmentMap = JSON.parseObject(JSON.toJSONString(pairmentVo), Map.class); + return pairmentService.selectPairment(commonParams, pairmentMap); + } + + + /** + * 新增数据 + * + * @param pairment 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping("insert") + public ResResult insert(@RequestBody Pairment pairment) { + this.pairmentService.insert(pairment); + return new ResResult().success(); + } + + + /** + * 通过主键查询单条数据 + * + * @param sn 主键 + * @return 单条数据 + */ + @GetMapping("selectByKey") + @ApiOperation(value = "通过联合key查询连表数据") + public ResResult selectByKey(@RequestParam("sn") String sn) { + return new ResResult().success(pairmentService.selectByKey(sn)); + } + + /** + * 修改数据 + * + * @param pairment 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "根据sn修改数据") + @PutMapping("updateByKey") + public ResResult updateByKey(@RequestBody Pairment pairment) { + this.pairmentService.updateByKey(pairment); + return new ResResult().success(); + } + + + /** + * 删除项根据主键key + * + * @param sn + * @return + */ + @DeleteMapping("deleteByKey") + public ResResult deleteByKey(@RequestParam("sn") String sn) { + this.pairmentService.deleteByKey(sn); + return new ResResult().success(); + } +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java index 888ea63..673c3aa 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java @@ -10,13 +10,12 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; -import top.kuanghua.feign.tyauth.feign.TokenFeign; +import top.kuanghua.commonpom.entity.ResResult; +import top.kuanghua.commonpom.entity.SelfCommonParams; import top.kuanghua.integrationfront.entity.User; import top.kuanghua.integrationfront.mapper.MultiPageMapper; import top.kuanghua.integrationfront.mapper.UserMapper; import top.kuanghua.integrationfront.service.UserService; -import top.kuanghua.khcomomon.entity.KHCommonParams; -import top.kuanghua.khcomomon.entity.ResResult; import javax.annotation.Resource; import javax.validation.Valid; @@ -40,9 +39,6 @@ public class UserController { private MultiPageMapper multiPageMapper; - @Resource - private TokenFeign tokenFeign; - /** * 分页查询所有数据 * @@ -51,7 +47,7 @@ public class UserController { */ @GetMapping("selectPage") @ApiOperation(value = "分页查询数据") - public ResResult selectPage(User user, KHCommonParams commonParams) { + public ResResult selectPage(User user, SelfCommonParams commonParams) { QueryWrapper queryWrapper = new QueryWrapper<>(); if (StringUtils.isNotEmpty(user.getUsername())) { queryWrapper.like("username", user.getUsername()); diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/VciController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/VciController.java index 8d93778..718e320 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/VciController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/VciController.java @@ -14,9 +14,10 @@ import top.kuanghua.integrationfront.excel.imp.VciExcelImp; import top.kuanghua.integrationfront.service.VciService; import top.kuanghua.integrationfront.vo.ExcelCheckResult; -import top.kuanghua.khcomomon.entity.CommonParamsSelf; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; +import top.kuanghua.commonpom.entity.SelfCommonParams; +import top.kuanghua.commonpom.entity.ResResult; +import top.kuanghua.commonpom.utils.SelfObjUtils; + import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; @@ -41,7 +42,7 @@ public class VciController { */ @GetMapping("selectPage") @ApiOperation(value = "分页查询所有数据") - public ResResult selectPage(Vci vci, CommonParamsSelf commonParams) { + public ResResult selectPage(Vci vci, SelfCommonParams commonParams) { QueryWrapper queryWrapper = new QueryWrapper<>(); if (ObjectUtils.isNotEmpty(vci.getSn())) { queryWrapper.like("sn", vci.getSn()); @@ -144,7 +145,7 @@ public ResResult importExcel(@RequestBody List vciExcelBo) { @ApiOperation("导出excel") @GetMapping("exportExcel") - public void exportExcel(HttpServletResponse response, Vci vci, CommonParamsSelf commonParams) throws IOException { + public void exportExcel(HttpServletResponse response, Vci vci, SelfCommonParams commonParams) throws IOException { QueryWrapper queryWrapper = new QueryWrapper<>(); if (ObjectUtils.isNotEmpty(vci.getSn())) { queryWrapper.like("sn", vci.getSn()); @@ -167,7 +168,7 @@ public void exportExcel(HttpServletResponse response, Vci vci, CommonParamsSelf response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); - String fileName = URLEncoder.encode("Vci导出数据", "UTF-8") + "-" + ObjectUtilsSelf.getCurrentDateTime(); + String fileName = URLEncoder.encode("Vci导出数据", "UTF-8") + "-" + SelfObjUtils.getCurrentDateTime(); response.setHeader("Access-Control-Expose-Headers", "exportFileName"); response.setHeader("exportFileName", fileName + ".xlsx"); EasyExcel.write(response.getOutputStream(), VciExcelImp.class).sheet("模板").doWrite(vciPage.getRecords()); diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Brand.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Brand.java index 95f7886..c288ca7 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Brand.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Brand.java @@ -1,7 +1,5 @@ package top.kuanghua.integrationfront.entity; -import java.util.Date; - import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -11,6 +9,7 @@ import lombok.Data; import java.io.Serializable; +import java.util.Date; /** * 品牌表(Brand)表实体类 @@ -32,12 +31,13 @@ public class Brand extends Model { private String letter; @ApiModelProperty(value = "排序") private Integer seq; - @ApiModelProperty(value = "创建时间",hidden = true) + @ApiModelProperty(value = "创建时间", hidden = true) @TableField(fill = FieldFill.INSERT) private Date createTime; - @ApiModelProperty(value = "更新时间",hidden = true) + @ApiModelProperty(value = "更新时间", hidden = true) @TableField(fill = FieldFill.UPDATE) private Date updateTime; + /** * 获取主键值 * diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/ErrorCollection.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/ErrorCollection.java index ec1827a..1b25daa 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/ErrorCollection.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/ErrorCollection.java @@ -1,7 +1,5 @@ package top.kuanghua.integrationfront.entity; -import java.util.Date; - import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -10,6 +8,8 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.Date; + /** * error_log_collection(ErrorCollection)表实体类 * @author kuanghua diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Pairment.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Pairment.java new file mode 100644 index 0000000..db76671 --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Pairment.java @@ -0,0 +1,63 @@ +package top.kuanghua.integrationfront.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * 售后维修表实体类 + * + * @author 熊猫哥 + * @since 2022-06-25 10:32:12 + */ +@Data +@ApiModel("售后维修表") +@TableName(value = "tb_repair") +public class Pairment { + @ApiModelProperty(value = "ID") + private Integer id; + @ApiModelProperty(value = "SN_ID") + private String sn; + @ApiModelProperty(value = "设备类型") + private Integer equipType; + @ApiModelProperty(value = "换件_ID") + private String replacementId; + @ApiModelProperty(value = "快递信息ID") + private String expressId; + @ApiModelProperty(value = "问题归类id") + private String problemClassificationId; + @ApiModelProperty(value = "目前状态") + private Integer currentStatus; + @ApiModelProperty(value = "问题描述") + private String problemDescription; + @ApiModelProperty(value = "反馈时间") + private Date feedbackTime; + @ApiModelProperty(value = "提出人") + private String proposer; + @ApiModelProperty(value = "联系方式") + private String contactInfo; + @ApiModelProperty(value = "回收日期") + private Date recoveryDate; + @ApiModelProperty(value = "返回日期") + private Date returnDate; + @ApiModelProperty(value = "返修分析的问题") + private String problemsAnalyzed; + @ApiModelProperty(value = "返修分析的原因") + private String reason; + @ApiModelProperty(value = "处理方法") + private String processingMethod; + @ApiModelProperty(value = "备注") + private String remarks; + @ApiModelProperty(value = "创建时间") + private Date createTime; + @ApiModelProperty(value = "更新时间") + private Date updateTime; + @ApiModelProperty(value = "新SN_ID") + private String newSnId; + @ApiModelProperty(value = "深度") + private Integer depth; + +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Repair.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Repair.java new file mode 100644 index 0000000..87f0447 --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Repair.java @@ -0,0 +1,70 @@ +package top.kuanghua.integrationfront.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 售后维修表实体类 + * + * @author 熊猫哥 + * @since 2022-06-25 10:32:12 + */ +@Data +@ApiModel("售后维修表") +@TableName(value = "tb_repair") +public class Repair extends Model { + @ApiModelProperty(value = "ID") + private Integer id; + @ApiModelProperty(value = "SN_ID") + private String sn; + @ApiModelProperty(value = "设备类型") + private Integer equipType; + @ApiModelProperty(value = "换件_ID") + private String replacementId; + @ApiModelProperty(value = "快递信息ID") + private String expressId; + @ApiModelProperty(value = "问题归类id") + private String problemClassificationId; + @ApiModelProperty(value = "目前状态") + private Integer currentStatus; + @ApiModelProperty(value = "问题描述") + private String problemDescription; + @ApiModelProperty(value = "反馈时间") + private Date feedbackTime; + @ApiModelProperty(value = "提出人") + private String proposer; + @ApiModelProperty(value = "联系方式") + private String contactInfo; + @ApiModelProperty(value = "回收日期") + private Date recoveryDate; + @ApiModelProperty(value = "返回日期") + private Date returnDate; + @ApiModelProperty(value = "返修分析的问题") + private String problemsAnalyzed; + @ApiModelProperty(value = "返修分析的原因") + private String reason; + @ApiModelProperty(value = "处理方法") + private String processingMethod; + @ApiModelProperty(value = "备注") + private String remarks; + @ApiModelProperty(value = "创建时间") + private Date createTime; + @ApiModelProperty(value = "更新时间") + private Date updateTime; + + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Replacement.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Replacement.java new file mode 100644 index 0000000..bcb7bfe --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Replacement.java @@ -0,0 +1,46 @@ +package top.kuanghua.integrationfront.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 换件表实体类 + * + * @author 熊猫哥 + * @since 2022-06-25 10:32:12 + */ +@Data +@ApiModel("换件表") +@TableName(value = "tb_replacement") +public class Replacement extends Model { + @ApiModelProperty(value = "ID") + private Integer id; + @ApiModelProperty(value = "SN_ID") + private String sn; + @ApiModelProperty(value = "设备类型;0:T-BOX,1:VCI") + private Integer equipType; + @ApiModelProperty(value = "新SN_ID") + private String newSnId; + @ApiModelProperty(value = "深度") + private Integer depth; + @ApiModelProperty(value = "创建时间") + private Date createTime; + @ApiModelProperty(value = "更新时间") + private Date updateTime; + + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java index cdf87aa..a950502 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java @@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; + import java.io.Serializable; import java.util.Date; diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/excel/cv/VciTimeCv.java b/integration-front/src/main/java/top/kuanghua/integrationfront/excel/cv/VciTimeCv.java index 35b0ebf..fcec3ee 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/excel/cv/VciTimeCv.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/excel/cv/VciTimeCv.java @@ -5,7 +5,7 @@ import com.alibaba.excel.metadata.data.ReadCellData; import com.alibaba.excel.metadata.data.WriteCellData; import com.alibaba.excel.metadata.property.ExcelContentProperty; -import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; +import top.kuanghua.commonpom.utils.SelfObjUtils; import java.text.SimpleDateFormat; import java.util.Date; @@ -22,7 +22,7 @@ public Date convertToJavaData(ReadCellData cellData, ExcelContentProperty conten @Override public WriteCellData convertToExcelData(Date value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { - return new WriteCellData<>(ObjectUtilsSelf.formatDateTime(value)); + return new WriteCellData<>(SelfObjUtils.formatDateTime(value)); } } \ No newline at end of file diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/PairmentMapper.java b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/PairmentMapper.java new file mode 100644 index 0000000..f08bfde --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/PairmentMapper.java @@ -0,0 +1,18 @@ +package top.kuanghua.integrationfront.mapper; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; + +import java.util.Map; + +/** + * 多表中实体类的注释Mapper + * + * @author 熊猫哥 + * @since 2022-06-25 10:32:12 + */ +public interface PairmentMapper { + Page selectPairment(Page pagination, @Param("params") Map params); + + Map selectByKey(@Param("sn") String sn); +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/RepairMapper.java b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/RepairMapper.java new file mode 100644 index 0000000..c39c4e6 --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/RepairMapper.java @@ -0,0 +1,14 @@ +package top.kuanghua.integrationfront.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.integrationfront.entity.Repair; + +/** + * 售后维修表Mapper + * + * @author 熊猫哥 + * @since 2022-06-25 10:32:12 + */ +public interface RepairMapper extends BaseMapper { + +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/ReplacementMapper.java b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/ReplacementMapper.java new file mode 100644 index 0000000..1fbe496 --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/ReplacementMapper.java @@ -0,0 +1,14 @@ +package top.kuanghua.integrationfront.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.integrationfront.entity.Replacement; + +/** + * 换件表Mapper + * + * @author 熊猫哥 + * @since 2022-06-25 10:32:12 + */ +public interface ReplacementMapper extends BaseMapper { + +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/service/PairmentService.java b/integration-front/src/main/java/top/kuanghua/integrationfront/service/PairmentService.java new file mode 100644 index 0000000..1f457a9 --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/service/PairmentService.java @@ -0,0 +1,76 @@ +package top.kuanghua.integrationfront.service; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import top.kuanghua.commonpom.entity.SelfCommonParams; +import top.kuanghua.integrationfront.entity.Pairment; +import top.kuanghua.integrationfront.entity.Repair; +import top.kuanghua.integrationfront.entity.Replacement; +import top.kuanghua.integrationfront.mapper.PairmentMapper; +import top.kuanghua.integrationfront.mapper.RepairMapper; +import top.kuanghua.integrationfront.mapper.ReplacementMapper; + +import javax.annotation.Resource; +import java.util.Map; + +/** + * 多表中实体类的注释Service + * + * @author 熊猫哥 + * @since 2022-06-25 10:32:12 + */ +@Service +public class PairmentService { + + @Resource + private PairmentMapper pairmentMapper; + + @Resource + private RepairMapper repairMapper; + @Resource + private ReplacementMapper replacementMapper; + + + public Page selectPairment(SelfCommonParams commonParams, Map repairVo) { + return pairmentMapper.selectPairment(new Page(commonParams.getPageNum(), commonParams.getPageSize()), repairVo); + } + + public Map selectByKey(String pairment) { + return pairmentMapper.selectByKey(pairment); + } + + @Transactional + public void insert(Pairment pairment) { + this.repairMapper.insert(JSON.parseObject(JSON.toJSONString(pairment), Repair.class)); + this.replacementMapper.insert(JSON.parseObject(JSON.toJSONString(pairment), Replacement.class)); + } + + @Transactional + public void updateByKey(Pairment pairment) { + //售后维修表 + Repair repair = JSON.parseObject(JSON.toJSONString(pairment), Repair.class); + QueryWrapper repairWrapper = new QueryWrapper<>(); + repairWrapper.eq("sn", pairment.getSn()); + this.repairMapper.update(repair, repairWrapper); + //换件表 + Replacement replacement = JSON.parseObject(JSON.toJSONString(pairment), Replacement.class); + QueryWrapper replacementWrapper = new QueryWrapper<>(); + replacementWrapper.eq("sn", pairment.getSn()); + this.replacementMapper.update(replacement, replacementWrapper); + } + + @Transactional + public void deleteByKey(String sn) { + //repair + QueryWrapper repairWrapper = new QueryWrapper<>(); + repairWrapper.eq("sn", sn); + this.repairMapper.delete(repairWrapper); + //replacement + QueryWrapper replacementWrapper = new QueryWrapper<>(); + replacementWrapper.eq("sn", sn); + this.replacementMapper.delete(replacementWrapper); + } +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/service/UserService.java b/integration-front/src/main/java/top/kuanghua/integrationfront/service/UserService.java index 2e9ff69..4fc0708 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/service/UserService.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/service/UserService.java @@ -8,12 +8,12 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; -import top.kuanghua.feign.tyauth.feign.TokenFeign; +import top.kuanghua.authpom.service.TokenService; import top.kuanghua.integrationfront.entity.User; import top.kuanghua.integrationfront.mapper.UserMapper; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.khcomomon.utils.CodecUtils; -import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; +import top.kuanghua.integrationfront.utils.CodecUtils; +import top.kuanghua.commonpom.utils.SelfObjUtils; + import javax.annotation.Resource; import java.util.HashMap; @@ -32,11 +32,10 @@ public class UserService { @Resource private UserMapper userMapper; -// @Resource -// private ExcelFeign excelFeign; + @Resource + private TokenService tokenService; @Resource - private TokenFeign tokenFeign; @Autowired private StringRedisTemplate stringRedisTemplate; @@ -105,7 +104,7 @@ public void loginOut() { // // //去ty-execl中查询用户名是否存在 // ResResult resResult = excelFeign.selectExcelByUser(username); -// List list = ObjectUtilsSelf.parseResToList(resResult); +// List list = ObjSelfUtils.parseResToList(resResult); // if (list.size() == 0) { // throw new RuntimeException(MessageFormat.format("考勤表中不存在用户名【{0}】", username)); // } @@ -113,7 +112,7 @@ public void loginOut() { // //校验验证码 // String codeInfo = stringRedisTemplate.opsForValue().get("email.code.routing.name" + email); // Map map = JSON.parseObject(codeInfo); -// if (ObjectUtilsSelf.isEmpty(map)) { +// if (ObjSelfUtils.isEmpty(map)) { // throw new RuntimeException("验证码失效,请重新获取"); // } // if (!Objects.equals(map.get("code"), code)) { @@ -156,9 +155,8 @@ public HashMap loginValid(User user) { HashMap hm = new HashMap<>(); hm.put("username", resUser.getUsername()); hm.put("email", resUser.getEmail()); - ResResult resResult = tokenFeign.generateToken(hm); - - hm.put("jwtToken", resResult.getData()); + String generateToken = tokenService.generateToken(hm); + hm.put("jwtToken", generateToken); return hm; } @@ -169,7 +167,7 @@ public void changePassword(String username, String oldPassword, String newPasswo .eq("username", username); User resUser = this.userMapper.selectOne(qw); - if (ObjectUtilsSelf.isEmpty(resUser)) { + if (SelfObjUtils.isEmpty(resUser)) { throw new RuntimeException("用户不存在"); } if (!resUser.getPassword().equals(CodecUtils.md5Hex(oldPassword, resUser.getSalt()))) { @@ -198,7 +196,7 @@ public void insertUser(String username) { .eq("username", username); User resUser = this.userMapper.selectOne(qw); - if (ObjectUtilsSelf.isEmpty(resUser)) { + if (SelfObjUtils.isEmpty(resUser)) { //添加盐设置密码为md5 User user = new User(); user.setPassword("123456"); diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/CodecUtils.java b/integration-front/src/main/java/top/kuanghua/integrationfront/utils/CodecUtils.java similarity index 88% rename from ty-common/src/main/java/top/kuanghua/khcomomon/utils/CodecUtils.java rename to integration-front/src/main/java/top/kuanghua/integrationfront/utils/CodecUtils.java index 48d5407..84b2d66 100644 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/CodecUtils.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/utils/CodecUtils.java @@ -1,7 +1,7 @@ -package top.kuanghua.khcomomon.utils; +package top.kuanghua.integrationfront.utils; import org.apache.commons.codec.digest.DigestUtils; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import java.util.UUID; diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/vo/PairmentVo.java b/integration-front/src/main/java/top/kuanghua/integrationfront/vo/PairmentVo.java new file mode 100644 index 0000000..2bd6729 --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/vo/PairmentVo.java @@ -0,0 +1,29 @@ +package top.kuanghua.integrationfront.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * 多表中实体类的注释实体类 + * + * @author 熊猫哥 + * @since 2022-06-25 10:32:12 + */ +@Data +@ApiModel("多表中实体类的注释") +public class PairmentVo { + @ApiModelProperty(value = "目前状态") + private Integer currentStatus; + @ApiModelProperty(value = "回收日期") + private Date recoveryDate; + @ApiModelProperty(value = "联系方式") + private String contactInfo; + @ApiModelProperty(value = "设备类型") + private Integer equipType; + @ApiModelProperty(value = "深度") + private Integer depth; + +} diff --git a/integration-front/src/main/resources/application-db.yml b/integration-front/src/main/resources/application-db.yml new file mode 100644 index 0000000..b1abd47 --- /dev/null +++ b/integration-front/src/main/resources/application-db.yml @@ -0,0 +1,45 @@ +spring: + datasource: + driver-class-name: com.p6spy.engine.spy.P6SpyDriver + url: jdbc:p6spy:mysql://${envpt.mysqlIp}:${envpt.mysqlPort}/micro-service-plus?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&useSSL=false + username: root + password: root123 + hikari: + connection-timeout: 60000 + validation-timeout: 3000 + idle-timeout: 60000 + login-timeout: 5 + max-lifetime: 60000 + maximum-pool-size: 10 + minimum-idle: 10 + read-only: false + +mybatis-plus: + mapper-locations: classpath:/mapper/*Mapper.xml + #实体扫描,多个package用逗号或者分号分隔 + #typeAliasesPackage: top.kuanghua.tyuser.entity + #typeEnumsPackage: com.baomidou.springboot.entity.enums + global-config: + #刷新mapper 调试神器 + db-config: + #主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID"; + id-type: AUTO + #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断" + field-strategy: not_empty + #驼峰下划线转换 + column-underline: true + #数据库大写下划线转换 + #capital-mode: true + #逻辑删除配置 + logic-delete-field: deleted # 逻辑已删除值(默认为 1) + logic-delete-value: 1 # 逻辑已删除值(默认为 1) + logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) + db-type: mysql + refresh: true + #自定义填充策略接口实现 + #meta-object-handler: com.baomidou.springboot.xxx + #自定义SQL注入器 + sql-injector: com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteByIdWithFill + configuration: + map-underscore-to-camel-case: true + cache-enabled: false \ No newline at end of file diff --git a/integration-front/src/main/resources/application-rabbit.yml b/integration-front/src/main/resources/application-rabbit.yml new file mode 100644 index 0000000..e3421c2 --- /dev/null +++ b/integration-front/src/main/resources/application-rabbit.yml @@ -0,0 +1,8 @@ +spring: + rabbitmq: + host: ${envpt.rabbitIp} + port: ${envpt.rabbitPort} + username: Kuanghua8866 + password: Kuanghua8866 + virtual-host: / + publisher-confirm-type: correlated \ No newline at end of file diff --git a/integration-front/src/main/resources/application-redis.yml b/integration-front/src/main/resources/application-redis.yml new file mode 100644 index 0000000..b193c8b --- /dev/null +++ b/integration-front/src/main/resources/application-redis.yml @@ -0,0 +1,4 @@ +spring: + redis: + host: ${envpt.redisIp} + port: ${envpt.redisPort} \ No newline at end of file diff --git a/integration-front/src/main/resources/application-seata.yml b/integration-front/src/main/resources/application-seata.yml new file mode 100644 index 0000000..0d5c50c --- /dev/null +++ b/integration-front/src/main/resources/application-seata.yml @@ -0,0 +1,26 @@ +#seata +seata: + enabled: true + enable-auto-data-source-proxy: true + application-id: product-server + #需要和nacos中配置保持一致config.txt service.vgroupMapping.product-server-group=default + tx-service-group: product-server-group + config: + type: nacos + nacos: + #需要和server在同一个注册中心下 + serverAddr: 8.135.1.141:8848 + #需要server端(registry和config)、nacos配置client端(registry和config)保持一致 + group: SEATA_GROUP + userName: "jzfai" + password: "123456" + registry: + type: nacos + nacos: + #需要和server端保持一致,即server在nacos中的名称,默认为seata-server + application: seata-server + server-addr: 8.135.1.141:8848 + #需要server端(registry和config)、nacos配置client端(registry和config)保持一致 + group: SEATA_GROUP + userName: "jzfai" + password: "123456" \ No newline at end of file diff --git a/integration-front/src/main/resources/application.yml b/integration-front/src/main/resources/application.yml index e69de29..4864d15 100644 --- a/integration-front/src/main/resources/application.yml +++ b/integration-front/src/main/resources/application.yml @@ -0,0 +1,2 @@ +server: + port: ${envpt.tomcatPortPre}0106 \ No newline at end of file diff --git a/integration-front/src/main/resources/bootstrap.yml b/integration-front/src/main/resources/bootstrap.yml index 98d883d..cb9d248 100644 --- a/integration-front/src/main/resources/bootstrap.yml +++ b/integration-front/src/main/resources/bootstrap.yml @@ -2,40 +2,9 @@ spring: application: name: @project.artifactId@ profiles: - active: @activatedProperties@ + active: @activatedProperties@,main,db,redis cloud: nacos: - config: - enabled: true - namespace: @nacosNamespace@ - group: @nacosGroup@ - username: @nacosUsername@ - password: @nacosPassword@ - server-addr: @nacosIpPort@ - prefix: @project.artifactId@ - file-extension: yml - # 用于共享的配置文件 - shared-configs: - - data-id: application-main.yml - group: @nacosGroup@ - refresh: true - extension-configs: - - data-id: @project.artifactId@.yml - group: @nacosGroup@ - refresh: true - - data-id: application-rabbit.yml - group: @nacosGroup@ - refresh: true - - data-id: application-redis.yml - group: @nacosGroup@ - refresh: true - - data-id: application-db.yml - group: @nacosGroup@ - refresh: true - #get seata config need after db config - - data-id: application-seata.yml - group: @nacosGroup@ - refresh: true discovery: namespace: @nacosNamespace@ group: @nacosGroup@ @@ -44,7 +13,3 @@ spring: server-addr: @nacosIpPort@ weight: @nacosWeight@ - - -server: - port: ${envpt.tomcatPortPre}0106 \ No newline at end of file diff --git a/integration-front/src/main/resources/mapper/AdminMapper.xml b/integration-front/src/main/resources/mapper/AdminMapper.xml index e0c5a4e..e512173 100644 --- a/integration-front/src/main/resources/mapper/AdminMapper.xml +++ b/integration-front/src/main/resources/mapper/AdminMapper.xml @@ -1,21 +1,22 @@ - + - - - - - - - - - - - - - id, + + + + + + + + + + + + + id + , status, add_time, is_super, @@ -28,47 +29,47 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - select from tb_admin diff --git a/integration-front/src/main/resources/mapper/PairmentMapper.xml b/integration-front/src/main/resources/mapper/PairmentMapper.xml new file mode 100644 index 0000000..aa40eae --- /dev/null +++ b/integration-front/src/main/resources/mapper/PairmentMapper.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + repair + . + current_status + ,repair.recovery_date,repair.contact_info,repair.equip_type,replacement.depth + + + + + + + \ No newline at end of file diff --git a/nacos_config_export_20220115133818.zip b/nacos_config_export_20220115133818.zip deleted file mode 100644 index d0eca68f1a8888f3ed438b34f29ec777da6133db..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16104 zcmeHuWl){V)+X-m9tiHTvEaIK*8suY-6c2#cbDMqZoyrG1}8W{g9ZpPD2Zx&`xSN(F&mBfS8xN5 zSn1PJB7E^u$=7(|n%d^zZ(qMYi>C?9^UDDdyvJR#Q@sU!ALbY0fRLaRVN76E zxgmGxgV@e(=vzY@P3f*6UvBr$NwbnssxE3S*tM4ChWc?%(h=9tBxPnhdBo_JFf?)*u_LfP#-Rq|v{4RKh1VIVy*^aAp88d5V4|IWedbAISSTN8WOwuBJj=U$b8B zuj?xNL>U{i+(Frj^|4N2lqhvF8S7Ef3MTXVMIr3M-qmcxR|u|;-RW=MlBuVCsTjXc zAdiqnp{F{6Dh*VpS#_8#3QOcX)+dc~sxI2i9*KXMIwC@-iB(OWhqf>V(oC-L^2(gw zuUzzT+T~;ezzL$ty7Q(>BL&}Hi4h_}AIh3H)WIsPJ2$0Y_NL$gHQ+9HLDyrXb#?nq zXLT`M8qhTp+J0ou-{8bP^Z?8^*m@s+Y{Ba!=i@BLohQki$~HtNej3~3Ep1+%;fclV zY}WfipdB>9XNKME-YTw5wIo4M?~Rh07d!KgG}fv5`&{fZOHi?_&TNJC{-GJq-{2$4 z;0uPZDD^z*!uUR)j~Ff4YD|)p(77 z{vpnkX%!-D9jmyz#Q1pn3NH)5gv$X+9Y0Q`wM99m1RhILfm#IPC6F4g!>=m`y*CyEajC&jH)Bv- z&%K++CaoEQnPrAJ^rPMNT}a9Sat3L(ff-9nK>@~#i-gPcdw&WSC$B3~W(w&{m^J88 z{4?kvJ>ygSS6nJ|6brqn*>Ew^W7Y2vv_qT{_P4kI;%gs-)s{RMbU2UZ4QI09lq8-t z64+}D>BG~etE(X}38{J^$pu@JlKOj@l`W7VA;aW4()GI<0!RiVjEiH+TMIc@Og?co zm}(&hIP#F2vC42FzUReexS&`MUX*W7tyI&w2_8B2XR|q_th`X>S$4^4vlt~LntgLT z7xZOgQo-uB$a&324Wu>eola%qGRMSyLd5OETQv>rK1f&V<@*JCLXciRZn_*GPG!RZ z{Ytz?T#jqu=^nLu?`nk(!`E$an|FuS3CqoIxRtP4qe!pz^cCFZ(-2PD8I5gjZkB|b zV@{wZ$qGE_#9zN4I0OkiIHXGxL64@9HR}c95mN3+dmPSs?>z54)kZ8j-isYdrdYV( z!q|W>5{PeYy)V;V!3a$AZiaKRO*+%R6!m0PyW#esl@#5w5UcMy-cmT?_|nzFe-3~B zrrSax4bnj@xSNipfN9|49^L*Yku1_!S@gi3fQSVOHf4IgW1d<2648l#rb1^96j{&vSmy{=L|x)M|7nYEP+K4x8{z=`HWRt6BB>Gat0xOnX>Rr z1m9!UGr8WwNX_&w=a8mgJkaIpbb;!bfFbe-{j~WWR3Tt`N~j$)eoC1?IuCX@fq0No zriD-iPUHh4vAilAAfsdyR0Xm`x{Iuz_!@i{Bz009&LXxuoOP_%e}Uo+_pv9rB;rlN z(!*SOV*?%5oB>H8-vzWtd&>u^g!UueYER_1dCQ9gZ+*QVk7=uGmfew@M#`gGHJ4A3 ziNd-U1$+*giJDa~=K7qq;~RAMpl=nRiTifqLiXnuVfR)an<68@`ua9;ifAB>q9^kw zOV`-J!D$-r3L9UXjFm&$h4y&4qV=h`c-LMMh|FAj;d%kMI79R`O;FHr+LKzVx07jQ zLJK6>8<{9m(!&w@2STiY^e~JTZDpa23GSDfRD5U7$oKajjz@=2i@RCHILHR%L-V^T z{0q8M&GgeC{b8|Pu=oV03UuS_O_Py4_928x-|ar*!RRxI2%H7#LFIXR=2au8kR_M~ zpi@f=11Hnq6vOPeZJtww6z5idDb>*~S94Kt*%gzZsM_hgUwOnvV&fK!u~cl5s^kMc z{q0;9B}Dq-VOTG|_}uyGUa<}mTur;|k&QmnCPawDoUaUl`789^l!tuiy<>NEui^(? zO!1clWuOPs-6^T5aQSm&!P~nXuYzAhI)Rc%%)kuJOQgEyL*SDO7H~3K&Xa~3>_YU$ z7?ot;AV|(UQ{A<<7P!wmJ5*DKM~}GJQD298V+4I0UND4&mEN0@*Qo|mhmf{;?@pyY zgcgd^#SqjVtW)9h8!ysO6dn#fabgklU-2Tv-|(Wnp1!`B<2P=!8skOkW2ctX))QA>k@vu^+$e#D5op*z*kF~RL$}lbWe3wG?UA4kfO0pbs z3L~|a(@GTGAb#i2-?+XwWb^s!ry2J>egB;6$^ULmMuuh%-(C{HCR zGeiefi-Ey%7A94OpYN?H9wsqNyMb6bL`GKvAnG)wUfR9w;MG{ z*)eb`cKXQ4W+Il!+jhEFqN-SFqX~)Hx|5#ftv#F!-67Qjpe62N=H2^d-UY59=Mr5) zm?O{gF|S%~04;Ve7>t)=07@`?aohw}m$vN|`A`^C0>Cs4wThMRw6A_LW)k%S>gYJF zOV37Tu{UaLA(~{})T{NyjhE)QT1^8KWFPHgmtG`(fk+5nvWt#}U&|lpKi1l-MU5qU z@ZWYWCn`Jndda_7pK*0;fBspes?DQC$D?xJ#->sG4(G7aXVsj?s(rP){#{3+@pzxl zT4jU9GmVHv_1caT{vzjNHGZu8_Ezk>dtnnJ%pT0wsSi47f=5S`P=eN|hQ4Woq#6D? zOpse%87W_Uv@nYjlv($OgrZJh3(#px3#TcGp&O(0J_+;CV~859yQgv; zhWO4d_Bf2j65rxFC^A8(Q4S1$U<@7uWW&6Pe`z9)*BLaKN41Ns!v0ZO;eK8|M`*ZN z)QuqozjJ*gzOnm>Cr%zrrJse!fOYeYfoYhN5#@)pasP z#Qs!j#}htbp~8%s`QtO|;L>$W$W+YGHnPs@PGf5l<%+nG$B9Ar?u59Rw@`7IeK1+i z>+N(g?YK&nAeS6D4;W-ub9AT6AdNjkl8Bf5N03~2L94;^8uZ*K2$+?9>l*OZ6DzFh zkk$PBGbUs9wlJi|PCuvH4Yrb}PWX$bEZZvS#f=JOHt!WseAwjonp%8V@oAfLZ$IE)gwK4Zus-uHfr=ba zNs&Zh5)AMW%E_??=SahaSof8#6{L7&$C=NHbe?;Wxpc4pF724V%h+w)&eydWr>2W% z-?*tvKOw0f90Y_1_OG}J{|~t7i52vm98G^?Bw2bIDf*h<7-^7^rdmaN z&HLy>1n8{0i%}lLfvMPVjdD%{VVU~Fsou7W@F@`$NTa}AfD8W$_vM0LAfwtPPuA?2 zqu0`igw)!}Cs#g??ytNV#BuSMqX-yv!~t)8K|@$rK+*c);N+Yg`Ciqa}|HhCYlUEx(Pb;1JONRV8Q*|_QaQrb<{U<2@Cn*0XDE}uY{|^hw zDStX7ej&#H7o+l@GmT#t^?xKR|HDJ)*SNe~RZ|XM48vP&gFjq4A7U$_InS+11S2#j zkA^yAL}@m-`pY~~_3Fa-_@a6UbZW8`e5g{OyeXN+ta2SHg^GAKN_W<2#ZloyVCD*& zZW~my)!dZ3$+%I6gYh`W07MKZ>d_%_??)lv5M^z)34)u{nPd7eb2>gc(}$%mpEAag z9!>E4K1ocFRoF>gcECs|!oEx`jj}B}#hKmEO5Rm6eceM+L8(54rp!{o0SDWBs*+c@ zdw`#`1M}&*vv-FEmm{3m)w<2BVs#6L4&QxW%9=&F8t;5{V*^cER7P(1*zi#8a490e zQs68Mpyko~og%$gQF^@laIl!Ocj1-kE*Il$JNWK|jYSyk9s{Iuy~~G;sU@FJ5LVN~ zN?M}airf#V!UC;dd*ZH;X>$$YvZB0SOa_UqC7pagJl?LUZP;pCZYdLEi!e!O0>N|~ zDl!I!Vqn$DgQ=|hk>ehN!d?bwSTr&FH_7%yjan`OgfJA5>8Uyg{o@RB(aVhsHKe`S zd02Q}EXQZDW+<4VIU|%v|ZpuLd38<<=vox++qb~&!5?3mC1rgKU)r)2x|wcGvx2N|6S1q;z8_YUeNWpW~Jx2o;bN!Z0=O*fYX9 zjjbB=V@Kmx%8dp3QCLq&LrS1yjOiRCf=EY=kH*6jOWrQAym{FjFFccNN8ymE0GPUW^}f=Q8CQlxgH=H1IR}``VOG_=Mtr4gX{CZc$(>b`cj|QXs#UV?$)P6 zta}@e6E7#bwT}fC^`W&7wdcm=?zeFnYry@6a~rL<$oZEP(l{t$nI7_DD=M${ zcdBdK8J8~3r*`>OwuujRSYdVki@8FGSC;W&I2WMbWR|r+4&OR+Lh4I9i7@eUTUbnXE6KXt}%wt;|MG9 zPDvik@1TZlQmb?hYYl?OlQrm~r!AJ)f5Z7^vhl8xb6R;|MZzHN<0rogy!20JZ;X)~ z@umf=4#{g!T2Ur+6Ewi^5{=xoYLz)_ZGB!PM4%_Rs#SMjXKd=51V_!)?oTzBurmDy1KH&E+QsN``{!T+(!15>Bjm;J!u)soHgr(IoljlpRu*qN z?hjjs=Nj7EG~DV<7zsHUwWatF-A#hO6yo^d?}g2BsJup6kWf2|{**Yf3f^e*Wo}v- zS)<^!VRC3S>1%{A@b%F13=$JPeg0z~DxAvQ){2NrBJ$dYAP89wZ7x3LHnfb{*xCjg z>_j0wov$0mqHK>sbUxRstMslPrk44?Whw)hGg0$T$`AnIuQC;aKRSf|Q&W{^fATVn zT=lGMEq_yTtfEI`@tHA#zQmj%C3e@~^~Es-lnslD3uuZOs;&@6IV3ZuR8wB1Xce{W z<-AHLK@-wfQh8O6kAf^PGJ^74)hm!IGeBE;Dc0!m(dY1dmIWQXVk;)ZXSI!zOb!>i z8=b;{xM)xWv)9mAuUPdqP$kx{z7&%Mds!A{lOTK{c*wd^CNmJfb&Rn62wA1+B&z#b zw-f;9zsf(yV2e0U!5DR5kvurakCk>`_o7>n=TKmh_tOdCA=_{?YPDwfoNhxr=Dj~{jx|b?V>TB){30#8Mz>Q zXSd6`qNW?9eR6Iv%_ai(RYmT)Q^xHD_P33&3LU0a2?_$@@>D+hugi(Q1TI#3X4c=5 zcQ54?S$r{^cCigYU=H??C}AtZ`$NJK`7jK)=WU&b?v_!>8BQ+7#pNZ60?c-jog(Xn zGU%~1WHD2C{)>v81#T%BE0>s+?`=#7pv42|%bh1&#&3+r?@&6_W9B}i2(e>rVQmXK zmFT~%WNE%LrAQj`N|Ca#mhqfWyo-A#K{KdD{K!f?>fTW&&zD6gMUsV4)Fhh=3j`!S zdsj?ixumR3JB5&oM~MGShWS%7(%gKR9NmTJn+W0nm>wZTF_c5@?E`6kV*JPDF;Dg{ z700^cr}emPCYRfvY+MKL#FEu$6tw+{e0N>j#HFz8vx|##Up8dZS$FpIk9Y6pY=E;V zIpH>4?OU8Kc-MI`9ugEsI03O>!<;k4G!d=x-$huYijdc$=xWnIb8gNNQ`6AUq2OYx z(eyUT`_2o(4th;H19-gAd0#5=KN4k@T{%BQK3j`WW6wQOt#g3L+Fb$8tkUU8cz3cD z;j+5bWAIyKxSaUMxYrXL@xe}H;){K}o@wCCB$)NJyf!~^a&58p^wpKzU4d@j#$J~o zJ>*lp1fEU!l7J9BI+u+T`R3VpEGQ8Y1Pxf6?f}Gzd0zRFP(VxVXTu_W&Jk0ofc-RG zvN{*J+meiZ!R>d0ZP#h|2(Q{MnJ%Chg^UtV^cknaj|3tTMY!1b?NZz{dhOcysEjt< zNR6EBdMud0J{n`Rl4mLl5YpF(5e7cOq;_GQ1VCAy4F0KYz5B+OhR(xh_$bocS_c9B zEObt%WCy<9g=1A6_jPoryL^=DqjJXdb=2(E5yN|FHmlS6ffsgL+YJ5`kHFv&HB12f z`6@w-w^fiF6Fc~lSTNWoqdo-;Ug!i-$*oTNIOEVm=KiVz{?TfCeO`M)WL143l1nak zW!(Lvu3ErAAuu=9M)~Vj+K}6{eJAo7pUk4vzTpe&6=;=3Z#*?huwpR*Sk^H?iq|AW zP3)&JY5`w`lcEPmy!;@X*9GrHi@YUEkl^8LLmZ36y+}}{w`-9z-jS-fX_ihAscG0! zUGYK^Fs#&E*}3#gA%?He(`*q?--^T+HbKAun)VzIKjzv2tO17e&(JWvCfKsEuaTPD z(k|G*zQpz3kCNPFB))iU%iNohxNlv2D<$0QYQgHwb^zeXvv8k4jkE&7-Ooz5KmJw_ zAPxbCw|NrX;GzC%2mfvA;b5fasP}CPuPBblc0YAR#C=9av~--Lz+{p^$EFLXeRf*S zZonPQJkLH&?ME9@85oVC*8g#wYVtKjlc{GwRCRvU8Fsp}MsYxbRO_d$Oox*f4m$-h zFfig2ep%_#wgfYs+OQ=oVpWiokVNVtyDGyQGArG1TZm<9CFpoe;b@8=f-U`|i?VvN ziZC`pT0!$Bc>_m_dlkpp?5x>)1qLnyg)%3(y9m}n5iJHEfV+%uDlp|0h%viwBE)@# znnRpM)br0{R584xw!tkW0wHx1LKuZ;Jm&|i%t*`j0V&G1CX1?U*`tsh>Li>&y31T? z8x7pnrGoU_S3Om0b`yKe2S|~GU!R-n^|qDhr^G=p$DxY|j=rfOGs-Wn4&UeH8`D!4 zq3BYf={+3tncMfp#7a;Uk|(WAImIFMW%4WEzH|0=F>>%SAr+#dX@Nr8%UAj;2KibM zRTpHMXNK9UE50duXa@_NEcUCW){O1)$_I}gt1F+_@P@8dK08gBlZTXz&BjuNleuag z|Gsegn8!X)lUr0cUW(;B-^C!;{ z#~@dc5cIsr-|t!EXi!VHsr2w*$J+3v@T`yKRDlTu=BUVs;_E2}lCi?BXPss|$%^n9 zt@WFX;^Gd8WvwY|qvLnZCdO7MFHx#jiG=7F48uKHppEBZlgK8>iU`COnqJ@dc1=`V zU0qzwC+Zs0yrx7r-s{3Ap{5}bJHN)H=!#=;O~->}I4nSr`RtLLCXs0WRPRr-(hy?s zL_a!tyb@}Sj%KpM#xBVxt^7R2dz-64ql%0*O!>|Y9@+$?l<{ggBV+iA@Wg0cfBV{d z`xMK&HSm(E_V&T6U6sDQm>}tPM2vBzuYK{T-KC|NsO|H^Lq|hf(8H8~lZ($ZE$>%( zM$>fAlpQX-*u~N;W_Z>%W|r-TI(Bxx%f5NFxLv#Abm{?b?N&(X= zH4|b$u>v61&CvUo5e39RzIHCA>_`d{KW?-`^-U#GX)&%dJSW2z60%-YI$*df9o~`R z%R$l}eN#KM08t}%DoOges?MIJ8OjtA!8%Q8$u2s&Lb5c%mct|^F_GxEqnxC9NGopo zaMFByMK4pU5jbhfWRIG`lz@*Mtjne<@vHrDi>h574FXjS)eIwI2eV59^+z7t9F)gX zSY2;uo@FT$9Txlb_(>=tM1*-B&`^wh3{81`LQu600puHIK`=1W{~R5rY+?EU0C$sl zJ%;$sCsy9|n5(uU;7;Tf>ofD(X)CeU7^evbI_hGQG7_AjRrV_b;F=ZTR=&_9Dp_>E^aF{EeN3)Ulqmj`bD1G-=j!`vFvU;h z^akRqE3dw+p3Lrst?oE9x)v&`o6GZbZP;0(9pN==7oKC)(-DMY3tNTA>m(iArYf0k zrmej$FbkuZ5fdl-7_LQ1w)iRE3bnkC0SE;Rotja3%9+?zT=5jbMu3|LSHY!)T&Z?S z!&0*~)aQLH;3+3<1HV}9e{b}4vRsPX3AnqjoLOi`orWAmD=d@8=ikHG>07Lso>Fsg zl}GSeViRgFBIPK|9>u1_q`Hj&lwOJjpvTF@N_VHzRO58$(&t1sYILGf-6$rCryeN7 za1gWkV#FbstSIyY;L#kIOxDbrED~(_8WE~Z4m|SlBUJ<3A%RT3fQVye6=@`*KA7St z@Lksc)c_J&HS-#(4;G>W;q&JpA)dW3@m-I}q@=Fkpd^K-j8iPiOz$g;yDnm0TEyQ# zFHdNT2at8jr%3XF7Z}4@zvV5p$pS&QSL)co0ua7yN78O)5$HBYLul#auP(7j3qHPo zM#J5Dyzjn!>f3tO?QuR4)Jl zX@~!-aQ$bQ@n6jOAK4M{v&{Ifm+_Cx_@5^;{u0UjC^KSo{7;#&oTgPBL)Z-rG8@x1QisT_w-pD1$7>%U;G?Sd^{f0wvn^*2eme#iE$ik@jmS` z=ZTwfmvPVCQ4-4h?px#4j8RRI7At)x_DBG?b4Z#Wm%VrrlH9kmx-vCs2ZTYJazGXk+K z&Sq7w&q5onFUjBWVUBrOS`)FZb%bno^z=ixRGg)#M~jTxSs~OXtV77K&)ftRPS!Te!PtJylVBS0fBpsv3{sgr7-KK#lGXes6ixqkCU{-B6?EL zbF^=?NsTh(0_d8vc)W`+h6tCceHkn|fCCU1N9Y&D1~K)^kVO5ltbv@{fD00c|@ zqiyEILwXZv<^0L>Xv}S{ri)ksR4#O$BS9!keh4@Ac)WO{2;oQ(;fUHUVSZ9oZlprU zew(3siEk4{U-&kp@kHFVwzhI}U!*Aa;sium&}s307FyC2tH>Bih&a&qk0z^!knzl=-TO&?VS zI)dkWs*oda|H9JFuciBZx904v+tqWf`Gg4SW(|vRdeQpJrtbX;o<+EVt6YB{U7EYw z;>Z}<6QiT8u8&Q!3;kcQ--*_nxv`+DW(g^$^Z84GXUb#BgGnf5!_K3eAJW;y#QCoj zY7OdT^9d3xeSXfM<$dvj8aEN!24s6!Aqid`a+{IQ=piw_mlP9ow<*ETx3+I+-M%<} z`_bg7Z(d-UH%}`(CSA%^FBz6e4?eLjme4i+)rWGapc@pbU9JXpu1t&QwCTJ#m_t=x z%~b#EG!-vUJ>~!tl?C;r1YX4E4z?Yi*?V6$ystB(s6n+@%$h5AzZEEkAwKHvKB-+j z|CYS@3v>JJ@B2$m-vrJd$A96vpS;wMfZyK^_|~cZ`@nkgx4#7Z zttst4+faO#`|4$_!;y2KKpMy{l5>erykqCnxp-{lK!6|zi-n0aoHh% z0QqYI|1;kAjjrEXdw(C9h`&zpyXyJRK;PTrM+282{Rs3+`O)xi4f0L-`F-@D{|(@O z%_2WqIT_>cK>y4n-*+SYxbkP1e}MV#+2mVx@%s?R`(wa=Agd-xoxFGzU7#-$4GaBjIPvKX*is zC+mE_=3kDPf7cOlss0A=f5#Dz{}%Mm9P#^n^+!i^qW*)4{&yU)lHrd5|9wYnWBg;J tzi`CwgNh#=v5EN)!2WxVc*gcOkl#5X - 4.0.0 @@ -9,24 +9,20 @@ pom 1.0-SNAPSHOT - ty-common - ty-gateway - ty-auth + auth-pom + common-pom + gateway integration-front - ty-example - - + basis-func - org.springframework.boot spring-boot-starter-parent - 2.1.4.RELEASE - + 2.4.13 - Greenwich.SR1 + 2020.0.5 @@ -36,37 +32,32 @@ spring-cloud-dependencies ${spring-cloud.version} pom - import com.alibaba.cloud spring-cloud-alibaba-dependencies - 2.1.3.RELEASE + 2.2.3.RELEASE pom import - - org.springframework.boot spring-boot-starter-test - - com.alibaba - fastjson - 1.2.79 + org.springframework.cloud + spring-cloud-starter-bootstrap - + - io.jsonwebtoken - jjwt - 0.9.0 + com.alibaba + fastjson + 2.0.3 org.projectlombok @@ -77,14 +68,18 @@ joda-time joda-time + 2.10.5 - - org.apache.commons - commons-lang3 - - + + + + + + + + + - dev @@ -102,7 +97,6 @@ test - true @@ -119,19 +113,19 @@ - - - - - - - - - - - - - - + + prod + + prod + 8.135.1.141 + ${baseLinuxIp}:8848 + 1000 + 127.0.0.1 + df87d91b-b1ab-4720-8e1c-5a147edc6ddc + nacos-group-${activatedProperties} + jzfai + 123456 + + diff --git a/springboot-cloud-mapping.json b/springboot-cloud-mapping.json deleted file mode 100644 index c970a57..0000000 --- a/springboot-cloud-mapping.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "git": { - "branch": "dc8e0454e3d0299e7002610a3f82af001013e959", - "commit": { - "id": "dc8e045", - "time": "2022-01-02T10:10:06Z" - } - }, - "build": { - "version": "0.0.1-SNAPSHOT", - "artifact": "start-site", - "versions": { - "spring-boot": "2.6.2", - "initializr": "0.12.0-SNAPSHOT" - }, - "name": "start.spring.io website", - "time": "2022-01-02T10:11:21.501Z", - "group": "io.spring.start" - }, - "bom-ranges": { - "azure": { - "3.2.0": "Spring Boot >=2.3.0.M1 and <2.4.0-M1", - "3.5.0": "Spring Boot >=2.4.0.M1 and <2.5.0-M1", - "3.10.0": "Spring Boot >=2.5.0.M1 and <2.6.0-M1" - }, - "codecentric-spring-boot-admin": { - "2.4.3": "Spring Boot >=2.3.0.M1 and <2.5.0-M1", - "2.5.5": "Spring Boot >=2.5.0.M1 and <2.6.0-M1" - }, - "solace-spring-boot": { - "1.1.0": "Spring Boot >=2.3.0.M1 and <2.6.0-M1" - }, - "solace-spring-cloud": { - "1.1.1": "Spring Boot >=2.3.0.M1 and <2.4.0-M1", - "2.1.0": "Spring Boot >=2.4.0.M1 and <2.6.0-M1" - }, - "spring-cloud": { - "Hoxton.SR12": "Spring Boot >=2.2.0.RELEASE and <2.4.0.M1", - "2020.0.5": "Spring Boot >=2.4.0.M1 and <2.6.0-M1", - "2021.0.0-M1": "Spring Boot >=2.6.0-M1 and <2.6.0-M3", - "2021.0.0-M3": "Spring Boot >=2.6.0-M3 and <2.6.0-RC1", - "2021.0.0-RC1": "Spring Boot >=2.6.0-RC1 and <2.6.1", - "2021.0.0": "Spring Boot >=2.6.1 and <2.6.3-SNAPSHOT", - "2021.0.1-SNAPSHOT": "Spring Boot >=2.6.3-SNAPSHOT and <2.7.0-M1" - }, - "spring-cloud-gcp": { - "2.0.7": "Spring Boot >=2.4.0-M1 and <2.6.0-M1" - }, - "spring-cloud-services": { - "2.3.0.RELEASE": "Spring Boot >=2.3.0.RELEASE and <2.4.0-M1", - "2.4.1": "Spring Boot >=2.4.0-M1 and <2.5.0-M1", - "3.3.0": "Spring Boot >=2.5.0-M1 and <2.6.0-M1" - }, - "spring-geode": { - "1.3.12.RELEASE": "Spring Boot >=2.3.0.M1 and <2.4.0-M1", - "1.4.13": "Spring Boot >=2.4.0-M1 and <2.5.0-M1", - "1.5.7": "Spring Boot >=2.5.0-M1 and <2.6.0-M1", - "1.6.1": "Spring Boot >=2.6.0-M1 and <2.7.0-M1" - }, - "vaadin": { - "14.8.1": "Spring Boot >=2.1.0.RELEASE and <2.8.0-M1" - }, - "wavefront": { - "2.0.2": "Spring Boot >=2.1.0.RELEASE and <2.4.0-M1", - "2.1.1": "Spring Boot >=2.4.0-M1 and <2.5.0-M1", - "2.2.2": "Spring Boot >=2.5.0-M1 and <2.7.0-M1" - } - }, - "dependency-ranges": { - "native": { - "0.9.0": "Spring Boot >=2.4.3 and <2.4.4", - "0.9.1": "Spring Boot >=2.4.4 and <2.4.5", - "0.9.2": "Spring Boot >=2.4.5 and <2.5.0-M1", - "0.10.0": "Spring Boot >=2.5.0-M1 and <2.5.2", - "0.10.1": "Spring Boot >=2.5.2 and <2.5.3", - "0.10.2": "Spring Boot >=2.5.3 and <2.5.4", - "0.10.3": "Spring Boot >=2.5.4 and <2.5.5", - "0.10.4": "Spring Boot >=2.5.5 and <2.5.6", - "0.10.5": "Spring Boot >=2.5.6 and <2.5.9-SNAPSHOT", - "0.10.6-SNAPSHOT": "Spring Boot >=2.5.9-SNAPSHOT and <2.6.0-M1", - "0.11.0-M1": "Spring Boot >=2.6.0-M1 and <2.6.0-RC1", - "0.11.0-M2": "Spring Boot >=2.6.0-RC1 and <2.6.0", - "0.11.0-RC1": "Spring Boot >=2.6.0 and <2.6.1", - "0.11.0": "Spring Boot >=2.6.1 and <2.6.2", - "0.11.1": "Spring Boot >=2.6.2 and <2.6.3-SNAPSHOT", - "0.11.2-SNAPSHOT": "Spring Boot >=2.6.3-SNAPSHOT and <2.7.0-M1" - }, - "okta": { - "1.4.0": "Spring Boot >=2.2.0.RELEASE and <2.4.0-M1", - "1.5.1": "Spring Boot >=2.4.0-M1 and <2.4.1", - "2.0.1": "Spring Boot >=2.4.1 and <2.5.0-M1", - "2.1.4": "Spring Boot >=2.5.0-M1 and <2.6.0-M1" - }, - "mybatis": { - "2.1.4": "Spring Boot >=2.1.0.RELEASE and <2.5.0-M1", - "2.2.1": "Spring Boot >=2.5.0-M1" - }, - "camel": { - "3.5.0": "Spring Boot >=2.3.0.M1 and <2.4.0-M1", - "3.10.0": "Spring Boot >=2.4.0.M1 and <2.5.0-M1", - "3.13.0": "Spring Boot >=2.5.0.M1 and <2.6.0-M1", - "3.14.0": "Spring Boot >=2.6.0.M1 and <2.7.0-M1" - }, - "picocli": { - "4.6.2": "Spring Boot >=2.4.0.RELEASE and <2.6.0-M1" - }, - "open-service-broker": { - "3.2.0": "Spring Boot >=2.3.0.M1 and <2.4.0-M1", - "3.3.1": "Spring Boot >=2.4.0-M1 and <2.5.0-M1", - "3.4.0-M2": "Spring Boot >=2.5.0-M1 and <2.6.0-M1" - } - } -} \ No newline at end of file diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/config/BaseConfig.java b/ty-auth/src/main/java/top/kuanghua/tyauth/config/BaseConfig.java deleted file mode 100644 index 1e13944..0000000 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/config/BaseConfig.java +++ /dev/null @@ -1,21 +0,0 @@ -package top.kuanghua.tyauth.config; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * @Title: BaseConfig - * @Description: - * @Auther: kuanghua - * @create 2020/8/23 21:52 - */ -/* - * 总结:1.@Configuration 下的@ComponentScan回将包下带有@Component扫描变成配置类, - * 而@SpringBootApplication扫描的只会变成普通类 - * */ -@Configuration -//扫描公用包的配置和自身的配置类 -@ComponentScan(basePackages = {"top.kuanghua.khcomomon"}) -public class BaseConfig { - -} diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java b/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java deleted file mode 100644 index 0a0c936..0000000 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/config/Swagger2Config.java +++ /dev/null @@ -1,54 +0,0 @@ -package top.kuanghua.tyauth.config; - -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Component -@EnableSwagger2 //开启在线接口文档 -//配置包扫描 -public class Swagger2Config { - private boolean swagger_is_enable = true; - - @Value("${server.port}") - private String port; - - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .enable(swagger_is_enable) - //.host(this.ipAddr + ":" + this.port) - .apiInfo(apiInfo()) - .select() - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) - //.apis(basePackage("top.kuanghua.swagger.controller")) - .paths(PathSelectors.any()) - .build(); - } - - /** - * 构建 api文档的详细信息函数 - * - * @return - */ - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("micro-service-plus") - .description("描述:新一代的微服务架构") - .contact(new Contact("jzfai", null, "869653722@qq.com")) - .version("版本号:2.9") - .build(); - } - /** - * http://localhost:8080/swagger-ui.html - */ -} diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TestGetTokenController.java b/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TestGetTokenController.java deleted file mode 100644 index e596f80..0000000 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/controller/TestGetTokenController.java +++ /dev/null @@ -1,47 +0,0 @@ -package top.kuanghua.tyauth.controller; - -import com.alibaba.fastjson.JSON; -import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import springfox.documentation.annotations.ApiIgnore; -import top.kuanghua.khcomomon.entity.ResResult; - -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.util.Map; - -/** - * @Title: TokenController - * @Description: - * @Auther: kuanghua - * @create 2021/1/31 16:31 - */ - -@RestController -@RequestMapping("feignTest") -@Slf4j -public class TestGetTokenController { - /* - * 解析token - * */ - @PostMapping("getTokenInfo") - public ResResult getTokenInfo( - @ApiIgnore @RequestHeader("TOKEN_INFO") String TOKEN_INFO, - @ApiIgnore @RequestHeader("AUTHORIZE_TOKEN") String AUTHORIZE_TOKEN - ) { - Map tokenInfo=null; - try { - tokenInfo = JSON.parseObject(URLDecoder.decode(TOKEN_INFO, "utf-8"), Map.class); - log.info(tokenInfo.toString()); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - log.info(AUTHORIZE_TOKEN); - return new ResResult().success(tokenInfo.toString()); - } -} - - diff --git a/ty-auth/src/main/java/top/kuanghua/tyauth/service/TokenService.java b/ty-auth/src/main/java/top/kuanghua/tyauth/service/TokenService.java deleted file mode 100644 index 43e0b20..0000000 --- a/ty-auth/src/main/java/top/kuanghua/tyauth/service/TokenService.java +++ /dev/null @@ -1,70 +0,0 @@ -package top.kuanghua.tyauth.service; - -import io.jsonwebtoken.Claims; -import org.springframework.stereotype.Service; -import top.kuanghua.tyauth.utils.JwtUtilsSelf; - -import java.util.Map; - -/** - * @Title: TokenService - * @Description: - * @Auther: kuanghua - * @create 2021/1/31 16:19 - */ -@Service -public class TokenService { - - private static final String AUTHORIZE_TOKEN="AUTHORIZE_TOKEN"; -// @Value("#{'${filter.allowPaths:}'.empty ? null : '${filter.allowPaths:}'.split(',')}") -// private List allowPaths; -// @Value("${jwt-properties.pubKeyPath}") -// private String pubKeyPath; -// @Value("${jwt-properties.priKeyPath}") -// private String priKeyPath; - - -// @PostConstruct -// public void postConstruct(){ -// try { -// String classPath = ResourceUtils.getURL("classpath:").getPath(); -// this.pubKeyPath=classPath+""; -// this.priKeyPath=classPath+""; -// } catch (Exception e) { -// throw new RuntimeException(); -// } -// } - - /* - * 生成token - * */ - public String generateToken(Map map){ - try { - return JwtUtilsSelf.createJWT(map,null); - } catch (Exception e) { - throw new RuntimeException("token生成有误"); - } - } - /* - * 更新token - * */ - public String updateToken(Map map){ - try { - String updateToken = JwtUtilsSelf.createJWT(map, null); - return updateToken; - } catch (Exception e) { - throw new RuntimeException("token更新有误"); - } - } - /* - * 解析token - * */ - public Claims parseToken(String jwtToken){ - try { - Claims claims = JwtUtilsSelf.parseJWT(jwtToken); - return claims; - } catch (Exception e) { - throw new RuntimeException("token解析错误"); - } - } -} diff --git a/ty-auth/src/main/resources/application.yml b/ty-auth/src/main/resources/application.yml deleted file mode 100644 index d3f5a12..0000000 --- a/ty-auth/src/main/resources/application.yml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/ty-common/pom.xml b/ty-common/pom.xml deleted file mode 100644 index e94f862..0000000 --- a/ty-common/pom.xml +++ /dev/null @@ -1,142 +0,0 @@ - - - - micro-service-plus - top.kuanghua - 1.0-SNAPSHOT - - 4.0.0 - - ty-common - - - - org.springframework.boot - spring-boot-starter-web - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - mysql - mysql-connector-java - - - - com.baomidou - mybatis-plus-boot-starter - 3.3.2 - - - p6spy - p6spy - 3.9.1 - - - - org.springframework.boot - spring-boot-starter-data-redis - - - - - - - - org.springframework.cloud - spring-cloud-starter-netflix-hystrix - - - - org.springframework.cloud - spring-cloud-starter-openfeign - - - org.springframework.boot - spring-boot-starter-amqp - - - - - - - - - - - - - - - - - - - - - - - com.github.wxpay - wxpay-sdk - 0.0.3 - - - - org.apache.httpcomponents - httpclient - - - - io.springfox - springfox-swagger2 - 2.9.2 - - - io.springfox - springfox-swagger-ui - 2.9.2 - - - - io.swagger - swagger-annotations - 1.5.21 - - - io.swagger - swagger-models - 1.5.21 - - - - - org.springframework.boot - spring-boot-devtools - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-seata - - - io.seata - seata-spring-boot-starter - - - - - io.seata - seata-spring-boot-starter - 1.4.2 - - - \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/controller/HstrixController.java b/ty-common/src/main/java/top/kuanghua/controller/HstrixController.java deleted file mode 100644 index fddc203..0000000 --- a/ty-common/src/main/java/top/kuanghua/controller/HstrixController.java +++ /dev/null @@ -1,26 +0,0 @@ -package top.kuanghua.controller; - -import io.swagger.annotations.ApiOperation; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import top.kuanghua.khcomomon.entity.ResResult; - -/** - * @Title: hstrixController - * @Description: - * @Auther: kuanghua - * @create 2022-01-08 18:15 - */ -@RestController -public class HstrixController { - @ApiOperation(value = "") - @RequestMapping("/fallback") - public ResResult fallback() { - ResResult resResult = new ResResult(); - //设置20010为熔断状态吗 - resResult.setCode(20010); - resResult.setMsg("接口发生了熔断"); - resResult.setFlag(false); - return resResult; - } -} \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/feign/integrationfront/feign/UserFeign.java b/ty-common/src/main/java/top/kuanghua/feign/integrationfront/feign/UserFeign.java deleted file mode 100644 index e2a6fc8..0000000 --- a/ty-common/src/main/java/top/kuanghua/feign/integrationfront/feign/UserFeign.java +++ /dev/null @@ -1,15 +0,0 @@ -package top.kuanghua.feign.integrationfront.feign; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import top.kuanghua.feign.config.FeignConfiguration; -import top.kuanghua.khcomomon.entity.ResResult; - -@FeignClient(name="integration-front",configuration = FeignConfiguration.class) -@RequestMapping("user") -public interface UserFeign { - @PostMapping("insertUser") - ResResult insertUser(@RequestParam("username") String username); -} diff --git a/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TestGetTokenFeign.java b/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TestGetTokenFeign.java deleted file mode 100644 index 17e523a..0000000 --- a/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TestGetTokenFeign.java +++ /dev/null @@ -1,14 +0,0 @@ -package top.kuanghua.feign.tyauth.feign; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import top.kuanghua.feign.config.FeignConfiguration; -import top.kuanghua.khcomomon.entity.ResResult; - -@FeignClient(name = "ty-auth", configuration = FeignConfiguration.class) -@RequestMapping("feignTest") -public interface TestGetTokenFeign { - @PostMapping("getTokenInfo") - public ResResult getTokenInfo(); -} \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TokenFeign.java b/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TokenFeign.java deleted file mode 100644 index 4c2b8d2..0000000 --- a/ty-common/src/main/java/top/kuanghua/feign/tyauth/feign/TokenFeign.java +++ /dev/null @@ -1,45 +0,0 @@ -package top.kuanghua.feign.tyauth.feign; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import top.kuanghua.feign.config.FeignConfiguration; -import top.kuanghua.khcomomon.entity.ResResult; - -import java.util.Map; - -/** - * @Title: TokenController - * @Description: - * @Auther: kuanghua - * @create 2021/1/31 16:31 - */ - - -//FeignConfiguration.class -> forward req params of include the token -@FeignClient(name="ty-auth",configuration = FeignConfiguration.class) -@RequestMapping("token") -public interface TokenFeign { - - /* - * parse token - * */ - @PostMapping("parseToken") - ResResult parseToken(@RequestParam("jwtToken") String jwtToken); - - /* - * create token - * */ - @PostMapping("generateToken") - ResResult generateToken(@RequestBody Map map); - - /* - * update token - * */ - @PostMapping("updateToken") - ResResult updateToken(@RequestBody Map map); -} - - diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/config/TokenParseInfo.java b/ty-common/src/main/java/top/kuanghua/khcomomon/config/TokenParseInfo.java deleted file mode 100644 index 704d981..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/config/TokenParseInfo.java +++ /dev/null @@ -1,26 +0,0 @@ -package top.kuanghua.khcomomon.config; - -import java.util.Map; - -/** - * @Title: TokenParseInfo - * @Description: - * @Auther: kuanghua - * @create 2021/3/15 14:37 - */ -public class TokenParseInfo { - // 定义一个线程域,存放登录用户 - private static final ThreadLocal t1 = new ThreadLocal<>(); - - public TokenParseInfo(Map map) { - t1.set(map); - } - - public static Map getT1() { - return t1.get(); - } - - public static void removeT1() { - t1.remove(); - } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/config/TyCommonConfig.java b/ty-common/src/main/java/top/kuanghua/khcomomon/config/TyCommonConfig.java deleted file mode 100644 index e770241..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/config/TyCommonConfig.java +++ /dev/null @@ -1,25 +0,0 @@ -package top.kuanghua.khcomomon.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import top.kuanghua.khcomomon.utils.IdWorker; - -; - -/** - * @Title: TyCommonConfig - * @Description: - * @Auther: kuanghua - * @create 2020/12/22 15:49 - */ -@Configuration -public class TyCommonConfig { - /*** - * IdWorker - * @return - */ - @Bean - public IdWorker idWorker() { - return new IdWorker(0, 0); - } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/BCrypt.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/BCrypt.java deleted file mode 100644 index 7a234e8..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/BCrypt.java +++ /dev/null @@ -1,792 +0,0 @@ -// Copyright (c) 2006 Damien Miller -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -package top.kuanghua.khcomomon.entity; - -import java.io.UnsupportedEncodingException; -import java.security.SecureRandom; - -/** - * BCrypt implements OpenBSD-style Blowfish password hashing using - * the scheme described in "A Future-Adaptable Password Scheme" by - * Niels Provos and David Mazieres. - *

- * This password hashing system tries to thwart off-line password - * cracking using a computationally-intensive hashing algorithm, - * based on Bruce Schneier's Blowfish cipher. The work factor of - * the algorithm is parameterised, so it can be increased as - * computers get faster. - *

- * Usage is really simple. To hash a password for the first time, - * call the hashpw method with a random salt, like this: - *

- * - * String pw_hash = BCrypt.hashpw(plain_password, BCrypt.gensalt());
- *
- *

- * To check whether a plaintext password matches one that has been - * hashed previously, use the checkpw method: - *

- * - * if (BCrypt.checkpw(candidate_password, stored_hash))
- *     System.out.println("It matches");
- * else
- *     System.out.println("It does not match");
- *
- *

- * The gensalt() method takes an optional parameter (log_rounds) - * that determines the computational complexity of the hashing: - *

- * - * String strong_salt = BCrypt.gensalt(10)
- * String stronger_salt = BCrypt.gensalt(12)
- *
- *

- * The amount of work increases exponentially (2**log_rounds), so - * each increment is twice as much work. The default log_rounds is - * 10, and the valid range is 4 to 30. - * - * @version 0.2 - */ -public class BCrypt { - // BCrypt parameters - private static final int GENSALT_DEFAULT_LOG2_ROUNDS = 10; - private static final int BCRYPT_SALT_LEN = 16; - - // Blowfish parameters - private static final int BLOWFISH_NUM_ROUNDS = 16; - - // Initial contents of key schedule - private static final int P_orig[] = { - 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, - 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, - 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, - 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, - 0x9216d5d9, 0x8979fb1b - }; - private static final int S_orig[] = { - 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, - 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99, - 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, - 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, - 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, - 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013, - 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, - 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e, - 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60, - 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, - 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce, - 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a, - 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, - 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677, - 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193, - 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, - 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88, - 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239, - 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, - 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0, - 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3, - 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, - 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88, - 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe, - 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, - 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d, - 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b, - 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, - 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba, - 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463, - 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, - 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09, - 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, - 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, - 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279, - 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8, - 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, - 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82, - 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db, - 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, - 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0, - 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b, - 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, - 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8, - 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4, - 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, - 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7, - 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c, - 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, - 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1, - 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299, - 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, - 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, - 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf, - 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, - 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af, - 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa, - 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, - 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41, - 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915, - 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, - 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915, - 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, - 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a, - 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, - 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266, - 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, - 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, - 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, - 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1, - 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, - 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1, - 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, - 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, - 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff, - 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd, - 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, - 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7, - 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41, - 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, - 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf, - 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af, - 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, - 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87, - 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, - 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, - 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16, - 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd, - 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, - 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509, - 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, - 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, - 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f, - 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a, - 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, - 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960, - 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66, - 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, - 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802, - 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84, - 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, - 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf, - 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, - 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, - 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50, - 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7, - 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, - 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281, - 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, - 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, - 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128, - 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73, - 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, - 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0, - 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105, - 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, - 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3, - 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285, - 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, - 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061, - 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, - 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, - 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, - 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc, - 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, - 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340, - 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, - 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7, - 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, - 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068, - 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, - 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, - 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45, - 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504, - 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, - 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb, - 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, - 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, - 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42, - 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b, - 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, - 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb, - 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, - 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, - 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33, - 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c, - 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, - 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc, - 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17, - 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, - 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b, - 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115, - 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, - 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728, - 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, - 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, - 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37, - 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d, - 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, - 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b, - 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, - 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, - 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d, - 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c, - 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, - 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9, - 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a, - 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, - 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d, - 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc, - 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, - 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61, - 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, - 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, - 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2, - 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c, - 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, - 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633, - 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, - 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, - 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52, - 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027, - 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, - 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62, - 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634, - 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, - 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, - 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc, - 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, - 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c, - 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, - 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0, - 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, - 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe, - 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, - 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, - 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, - 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6, - 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, - 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22, - 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4, - 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, - 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9, - 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59, - 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, - 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51, - 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28, - 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, - 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, - 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28, - 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, - 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd, - 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, - 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, - 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb, - 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f, - 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, - 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32, - 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680, - 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, - 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae, - 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb, - 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, - 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47, - 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370, - 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, - 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84, - 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048, - 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, - 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd, - 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9, - 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, - 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, - 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f, - 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, - 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525, - 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1, - 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, - 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964, - 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e, - 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, - 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d, - 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f, - 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, - 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02, - 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc, - 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, - 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a, - 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, - 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, - 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, - 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060, - 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, - 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9, - 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, - 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6 - }; - - // bcrypt IV: "OrpheanBeholderScryDoubt". The C implementation calls - // this "ciphertext", but it is really plaintext or an IV. We keep - // the name to make code comparison easier. - static private final int bf_crypt_ciphertext[] = { - 0x4f727068, 0x65616e42, 0x65686f6c, - 0x64657253, 0x63727944, 0x6f756274 - }; - - // Table for Base64 encoding - static private final char base64_code[] = { - '.', '/', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', - 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', - 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', - 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', - 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', - '6', '7', '8', '9' - }; - - // Table for Base64 decoding - static private final byte index_64[] = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 0, 1, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, -1, -1, - -1, -1, -1, -1, -1, 2, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - -1, -1, -1, -1, -1, -1, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, -1, -1, -1, -1, -1 - }; - - // Expanded Blowfish key - private int P[]; - private int S[]; - - /** - * Encode a byte array using bcrypt's slightly-modified base64 - * encoding scheme. Note that this is *not* compatible with - * the standard MIME-base64 encoding. - * - * @param d the byte array to encode - * @param len the number of bytes to encode - * @return base64-encoded string - * @exception IllegalArgumentException if the length is invalid - */ - private static String encode_base64(byte d[], int len) - throws IllegalArgumentException { - int off = 0; - StringBuffer rs = new StringBuffer(); - int c1, c2; - - if (len <= 0 || len > d.length) { - throw new IllegalArgumentException("Invalid len"); - } - while (off < len) { - c1 = d[off++] & 0xff; - rs.append(base64_code[(c1 >> 2) & 0x3f]); - c1 = (c1 & 0x03) << 4; - if (off >= len) { - rs.append(base64_code[c1 & 0x3f]); - break; - } - c2 = d[off++] & 0xff; - c1 |= (c2 >> 4) & 0x0f; - rs.append(base64_code[c1 & 0x3f]); - c1 = (c2 & 0x0f) << 2; - if (off >= len) { - rs.append(base64_code[c1 & 0x3f]); - break; - } - c2 = d[off++] & 0xff; - c1 |= (c2 >> 6) & 0x03; - rs.append(base64_code[c1 & 0x3f]); - rs.append(base64_code[c2 & 0x3f]); - } - return rs.toString(); - } - - /** - * Look up the 3 bits base64-encoded by the specified character, - * range-checking againt conversion table - * @param x the base64-encoded value - * @return the decoded value of x - */ - private static byte char64(char x) { - if ((int)x < 0 || (int)x > index_64.length) { - return -1; - } - return index_64[(int)x]; - } - - /** - * Decode a string encoded using bcrypt's base64 scheme to a - * byte array. Note that this is *not* compatible with - * the standard MIME-base64 encoding. - * @param s the string to decode - * @param maxolen the maximum number of bytes to decode - * @return an array containing the decoded bytes - * @throws IllegalArgumentException if maxolen is invalid - */ - private static byte[] decode_base64(String s, int maxolen) - throws IllegalArgumentException { - StringBuffer rs = new StringBuffer(); - int off = 0, slen = s.length(), olen = 0; - byte ret[]; - byte c1, c2, c3, c4, o; - - if (maxolen <= 0) { - throw new IllegalArgumentException("Invalid maxolen"); - } - while (off < slen - 1 && olen < maxolen) { - c1 = char64(s.charAt(off++)); - c2 = char64(s.charAt(off++)); - if (c1 == -1 || c2 == -1) { - break; - } - o = (byte)(c1 << 2); - o |= (c2 & 0x30) >> 4; - rs.append((char)o); - if (++olen >= maxolen || off >= slen) { - break; - } - c3 = char64(s.charAt(off++)); - if (c3 == -1) { - break; - } - o = (byte)((c2 & 0x0f) << 4); - o |= (c3 & 0x3c) >> 2; - rs.append((char)o); - if (++olen >= maxolen || off >= slen) { - break; - } - c4 = char64(s.charAt(off++)); - o = (byte)((c3 & 0x03) << 6); - o |= c4; - rs.append((char)o); - ++olen; - } - - ret = new byte[olen]; - for (off = 0; off < olen; off++) { - ret[off] = (byte) rs.charAt(off); - } - return ret; - } - - /** - * Blowfish encipher a single 64-bit block encoded as - * two 32-bit halves - * @param lr an array containing the two 32-bit half blocks - * @param off the position in the array of the blocks - */ - private final void encipher(int lr[], int off) { - int i, n, l = lr[off], r = lr[off + 1]; - - l ^= P[0]; - for (i = 0; i <= BLOWFISH_NUM_ROUNDS - 2;) { - // Feistel substitution on left word - n = S[(l >> 24) & 0xff]; - n += S[0x100 | ((l >> 16) & 0xff)]; - n ^= S[0x200 | ((l >> 8) & 0xff)]; - n += S[0x300 | (l & 0xff)]; - r ^= n ^ P[++i]; - - // Feistel substitution on right word - n = S[(r >> 24) & 0xff]; - n += S[0x100 | ((r >> 16) & 0xff)]; - n ^= S[0x200 | ((r >> 8) & 0xff)]; - n += S[0x300 | (r & 0xff)]; - l ^= n ^ P[++i]; - } - lr[off] = r ^ P[BLOWFISH_NUM_ROUNDS + 1]; - lr[off + 1] = l; - } - - /** - * Cycically extract a word of key material - * @param data the string to extract the data from - * @param offp a "pointer" (as a one-entry array) to the - * current offset into data - * @return the next word of material from data - */ - private static int streamtoword(byte data[], int offp[]) { - int i; - int word = 0; - int off = offp[0]; - - for (i = 0; i < 4; i++) { - word = (word << 8) | (data[off] & 0xff); - off = (off + 1) % data.length; - } - - offp[0] = off; - return word; - } - - /** - * Initialise the Blowfish key schedule - */ - private void init_key() { - P = (int[])P_orig.clone(); - S = (int[])S_orig.clone(); - } - - /** - * Key the Blowfish cipher - * @param key an array containing the key - */ - private void key(byte key[]) { - int i; - int koffp[] = { 0 }; - int lr[] = { 0, 0 }; - int plen = P.length, slen = S.length; - - for (i = 0; i < plen; i++) { - P[i] = P[i] ^ streamtoword(key, koffp); - } - for (i = 0; i < plen; i += 2) { - encipher(lr, 0); - P[i] = lr[0]; - P[i + 1] = lr[1]; - } - - for (i = 0; i < slen; i += 2) { - encipher(lr, 0); - S[i] = lr[0]; - S[i + 1] = lr[1]; - } - } - - /** - * Perform the "enhanced key schedule" step described by - * Provos and Mazieres in "A Future-Adaptable Password Scheme" - * http://www.openbsd.org/papers/bcrypt-paper.ps - * @param data salt information - * @param key password information - */ - private void ekskey(byte data[], byte key[]) { - int i; - int koffp[] = { 0 }, doffp[] = { 0 }; - int lr[] = { 0, 0 }; - int plen = P.length, slen = S.length; - - for (i = 0; i < plen; i++) { - P[i] = P[i] ^ streamtoword(key, koffp); - } - for (i = 0; i < plen; i += 2) { - lr[0] ^= streamtoword(data, doffp); - lr[1] ^= streamtoword(data, doffp); - encipher(lr, 0); - P[i] = lr[0]; - P[i + 1] = lr[1]; - } - - for (i = 0; i < slen; i += 2) { - lr[0] ^= streamtoword(data, doffp); - lr[1] ^= streamtoword(data, doffp); - encipher(lr, 0); - S[i] = lr[0]; - S[i + 1] = lr[1]; - } - } - - /** - * Perform the central password hashing step in the - * bcrypt scheme - * @param password the password to hash - * @param salt the binary salt to hash with the password - * @param log_rounds the binary logarithm of the number - * of rounds of hashing to apply - * @param cdata the plaintext to encrypt - * @return an array containing the binary hashed password - */ - public byte[] crypt_raw(byte password[], byte salt[], int log_rounds, - int cdata[]) { - int rounds, i, j; - int clen = cdata.length; - byte ret[]; - - if (log_rounds < 4 || log_rounds > 30) { - throw new IllegalArgumentException("Bad number of rounds"); - } - rounds = 1 << log_rounds; - if (salt.length != BCRYPT_SALT_LEN) { - throw new IllegalArgumentException("Bad salt length"); - } - init_key(); - ekskey(salt, password); - for (i = 0; i != rounds; i++) { - key(password); - key(salt); - } - - for (i = 0; i < 64; i++) { - for (j = 0; j < (clen >> 1); j++) { - encipher(cdata, j << 1); - } - } - - ret = new byte[clen * 4]; - for (i = 0, j = 0; i < clen; i++) { - ret[j++] = (byte)((cdata[i] >> 24) & 0xff); - ret[j++] = (byte)((cdata[i] >> 16) & 0xff); - ret[j++] = (byte)((cdata[i] >> 8) & 0xff); - ret[j++] = (byte)(cdata[i] & 0xff); - } - return ret; - } - - /** - * Hash a password using the OpenBSD bcrypt scheme - * @param password the password to hash - * @param salt the salt to hash with (perhaps generated - * using BCrypt.gensalt) - * @return the hashed password - */ - public static String hashpw(String password, String salt) { - BCrypt B; - String real_salt; - byte passwordb[], saltb[], hashed[]; - char minor = (char)0; - int rounds, off = 0; - StringBuffer rs = new StringBuffer(); - - if (salt.charAt(0) != '$' || salt.charAt(1) != '2') { - throw new IllegalArgumentException("Invalid salt version"); - } - if (salt.charAt(2) == '$') { - off = 3; - } else { - minor = salt.charAt(2); - if (minor != 'a' || salt.charAt(3) != '$') { - throw new IllegalArgumentException("Invalid salt revision"); - } - off = 4; - } - - // Extract number of rounds - if (salt.charAt(off + 2) > '$') { - throw new IllegalArgumentException("Missing salt rounds"); - } - rounds = Integer.parseInt(salt.substring(off, off + 2)); - - real_salt = salt.substring(off + 3, off + 25); - try { - passwordb = (password + (minor >= 'a' ? "\000" : "")).getBytes("UTF-8"); - } catch (UnsupportedEncodingException uee) { - throw new AssertionError("UTF-8 is not supported"); - } - - saltb = decode_base64(real_salt, BCRYPT_SALT_LEN); - - B = new BCrypt(); - hashed = B.crypt_raw(passwordb, saltb, rounds, - (int[])bf_crypt_ciphertext.clone()); - - rs.append("$2"); - if (minor >= 'a') { - rs.append(minor); - } - rs.append("$"); - if (rounds < 10) { - rs.append("0"); - } - if (rounds > 30) { - throw new IllegalArgumentException( - "rounds exceeds maximum (30)"); - } - rs.append(Integer.toString(rounds)); - rs.append("$"); - rs.append(encode_base64(saltb, saltb.length)); - rs.append(encode_base64(hashed, - bf_crypt_ciphertext.length * 4 - 1)); - return rs.toString(); - } - - /** - * Generate a salt for use with the BCrypt.hashpw() method - * @param log_rounds the log2 of the number of rounds of - * hashing to apply - the work factor therefore increases as - * 2**log_rounds. - * @param random an instance of SecureRandom to use - * @return an encoded salt value - */ - public static String gensalt(int log_rounds, SecureRandom random) { - StringBuffer rs = new StringBuffer(); - byte rnd[] = new byte[BCRYPT_SALT_LEN]; - - random.nextBytes(rnd); - - rs.append("$2a$"); - if (log_rounds < 10) { - rs.append("0"); - } - if (log_rounds > 30) { - throw new IllegalArgumentException( - "log_rounds exceeds maximum (30)"); - } - rs.append(Integer.toString(log_rounds)); - rs.append("$"); - rs.append(encode_base64(rnd, rnd.length)); - return rs.toString(); - } - - /** - * Generate a salt for use with the BCrypt.hashpw() method - * @param log_rounds the log2 of the number of rounds of - * hashing to apply - the work factor therefore increases as - * 2**log_rounds. - * @return an encoded salt value - */ - public static String gensalt(int log_rounds) { - return gensalt(log_rounds, new SecureRandom()); - } - - /** - * Generate a salt for use with the BCrypt.hashpw() method, - * selecting a reasonable default for the number of hashing - * rounds to apply - * @return an encoded salt value - */ - public static String gensalt() { - return gensalt(GENSALT_DEFAULT_LOG2_ROUNDS); - } - - /** - * Check that a plaintext password matches a previously hashed - * one - * @param plaintext the plaintext password to verify - * @param hashed the previously-hashed password - * @return true if the passwords match, false otherwise - */ - public static boolean checkpw(String plaintext, String hashed) { - byte hashed_bytes[]; - byte try_bytes[]; - try { - String try_pw = hashpw(plaintext, hashed); - hashed_bytes = hashed.getBytes("UTF-8"); - try_bytes = try_pw.getBytes("UTF-8"); - } catch (UnsupportedEncodingException uee) { - return false; - } - if (hashed_bytes.length != try_bytes.length) { - return false; - } - byte ret = 0; - for (int i = 0; i < try_bytes.length; i++) { - ret |= hashed_bytes[i] ^ try_bytes[i]; - } - return ret == 0; - } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CacheKey.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CacheKey.java deleted file mode 100644 index e5af96e..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CacheKey.java +++ /dev/null @@ -1,24 +0,0 @@ -package top.kuanghua.khcomomon.entity; - -/**** - * @Author:kuanghua - * @Description: - *****/ -public class CacheKey { - - /** - * 商品分类 - */ - public static String CATEGORY="CATEGORY"; - - /** - * 品牌缓存 - */ - public static String BRAND="BRAND"; - - /** - * 规格 - */ - public static String SPEC="SPEC"; - -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CommonParamsSelf.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CommonParamsSelf.java deleted file mode 100644 index 2185366..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/CommonParamsSelf.java +++ /dev/null @@ -1,20 +0,0 @@ -package top.kuanghua.khcomomon.entity; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * @Title: CommonParams - * @Description: - * @Auther: kuanghua - * @create 2020/12/15 12:01 - */ -@Data -@ApiModel -public class CommonParamsSelf extends KHCommonPageParams{ - @ApiModelProperty("开始时间") - private String startTime; - @ApiModelProperty("结束时间") - private String endTime; -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/HttpClient.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/HttpClient.java deleted file mode 100644 index 70c9d3a..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/HttpClient.java +++ /dev/null @@ -1,170 +0,0 @@ -package top.kuanghua.khcomomon.entity; - -import org.apache.http.Consts; -import org.apache.http.HttpEntity; -import org.apache.http.NameValuePair; -import org.apache.http.ParseException; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.client.methods.*; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.conn.ssl.TrustStrategy; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.message.BasicNameValuePair; -import org.apache.http.ssl.SSLContextBuilder; -import org.apache.http.util.EntityUtils; - -import javax.net.ssl.SSLContext; -import java.io.IOException; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -/***** - * @Author: kuanghua - * @Description: entity - ****/ -public class HttpClient { - private String url; - private Map param; - private int statusCode; - private String content; - private String xmlParam; - private boolean isHttps; - - public boolean isHttps() { - return isHttps; - } - - public void setHttps(boolean isHttps) { - this.isHttps = isHttps; - } - - public String getXmlParam() { - return xmlParam; - } - - public void setXmlParam(String xmlParam) { - this.xmlParam = xmlParam; - } - - public HttpClient(String url, Map param) { - this.url = url; - this.param = param; - } - - public HttpClient(String url) { - this.url = url; - } - - public void setParameter(Map map) { - param = map; - } - - public void addParameter(String key, String value) { - if (param == null) - param = new HashMap(); - param.put(key, value); - } - - public void post() throws ClientProtocolException, IOException { - HttpPost http = new HttpPost(url); - setEntity(http); - execute(http); - } - - public void put() throws ClientProtocolException, IOException { - HttpPut http = new HttpPut(url); - setEntity(http); - execute(http); - } - - public void get() throws ClientProtocolException, IOException { - if (param != null) { - StringBuilder url = new StringBuilder(this.url); - boolean isFirst = true; - for (String key : param.keySet()) { - if (isFirst) { - url.append("?"); - }else { - url.append("&"); - } - url.append(key).append("=").append(param.get(key)); - } - this.url = url.toString(); - } - HttpGet http = new HttpGet(url); - execute(http); - } - - /** - * set http post,put param - */ - private void setEntity(HttpEntityEnclosingRequestBase http) { - if (param != null) { - List nvps = new LinkedList(); - for (String key : param.keySet()) { - nvps.add(new BasicNameValuePair(key, param.get(key))); // 参数 - } - http.setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8)); // 设置参数 - } - if (xmlParam != null) { - http.setEntity(new StringEntity(xmlParam, Consts.UTF_8)); - } - } - - private void execute(HttpUriRequest http) throws ClientProtocolException, - IOException { - CloseableHttpClient httpClient = null; - try { - if (isHttps) { - SSLContext sslContext = new SSLContextBuilder() - .loadTrustMaterial(null, new TrustStrategy() { - // 信任所有 - @Override - public boolean isTrusted(X509Certificate[] chain, - String authType) - throws CertificateException { - return true; - } - }).build(); - SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( - sslContext); - httpClient = HttpClients.custom().setSSLSocketFactory(sslsf) - .build(); - } else { - httpClient = HttpClients.createDefault(); - } - CloseableHttpResponse response = httpClient.execute(http); - try { - if (response != null) { - if (response.getStatusLine() != null) { - statusCode = response.getStatusLine().getStatusCode(); - } - HttpEntity entity = response.getEntity(); - // 响应内容 - content = EntityUtils.toString(entity, Consts.UTF_8); - } - } finally { - response.close(); - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - httpClient.close(); - } - } - - public int getStatusCode() { - return statusCode; - } - - public String getContent() throws ParseException, IOException { - return content; - } -} \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/IdWorker.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/IdWorker.java deleted file mode 100644 index a741d39..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/IdWorker.java +++ /dev/null @@ -1,172 +0,0 @@ -package top.kuanghua.khcomomon.entity; - -import java.lang.management.ManagementFactory; -import java.net.InetAddress; -import java.net.NetworkInterface; - -/** - *

名称:IdWorker.java

- *

描述:分布式自增长ID

- *
- *     Twitter的 Snowflake JAVA实现方案
- * 
- * 核心代码为其IdWorker这个类实现,其原理结构如下,我分别用一个0表示一位,用—分割开部分的作用: - * 1||0---0000000000 0000000000 0000000000 0000000000 0 --- 00000 ---00000 ---000000000000 - * 在上面的字符串中,第一位为未使用(实际上也可作为long的符号位),接下来的41位为毫秒级时间, - * 然后5位datacenter标识位,5位机器ID(并不算标识符,实际是为线程标识), - * 然后12位该毫秒内的当前毫秒内的计数,加起来刚好64位,为一个Long型。 - * 这样的好处是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由datacenter和机器ID作区分), - * 并且效率较高,经测试,snowflake每秒能够产生26万ID左右,完全满足需要。 - *

- * 64位ID (42(毫秒)+5(机器ID)+5(业务编码)+12(重复累加)) - * - * @author Polim - */ -public class IdWorker { - // 时间起始标记点,作为基准,一般取系统的最近时间(一旦确定不能变动) - private final static long twepoch = 1288834974657L; - // 机器标识位数 - private final static long workerIdBits = 5L; - // 数据中心标识位数 - private final static long datacenterIdBits = 5L; - // 机器ID最大值 - private final static long maxWorkerId = -1L ^ (-1L << workerIdBits); - // 数据中心ID最大值 - private final static long maxDatacenterId = -1L ^ (-1L << datacenterIdBits); - // 毫秒内自增位 - private final static long sequenceBits = 12L; - // 机器ID偏左移12位 - private final static long workerIdShift = sequenceBits; - // 数据中心ID左移17位 - private final static long datacenterIdShift = sequenceBits + workerIdBits; - // 时间毫秒左移22位 - private final static long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits; - - private final static long sequenceMask = -1L ^ (-1L << sequenceBits); - /* 上次生产id时间戳 */ - private static long lastTimestamp = -1L; - // 0,并发控制 - private long sequence = 0L; - - private final long workerId; - // 数据标识id部分 - private final long datacenterId; - - public IdWorker(){ - this.datacenterId = getDatacenterId(maxDatacenterId); - this.workerId = getMaxWorkerId(datacenterId, maxWorkerId); - } - /** - * @param workerId - * 工作机器ID - * @param datacenterId - * 序列号 - */ - public IdWorker(long workerId, long datacenterId) { - if (workerId > maxWorkerId || workerId < 0) { - throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId)); - } - if (datacenterId > maxDatacenterId || datacenterId < 0) { - throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId)); - } - this.workerId = workerId; - this.datacenterId = datacenterId; - } - /** - * 获取下一个ID - * - * @return - */ - public synchronized long nextId() { - long timestamp = timeGen(); - if (timestamp < lastTimestamp) { - throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp)); - } - - if (lastTimestamp == timestamp) { - // 当前毫秒内,则+1 - sequence = (sequence + 1) & sequenceMask; - if (sequence == 0) { - // 当前毫秒内计数满了,则等待下一秒 - timestamp = tilNextMillis(lastTimestamp); - } - } else { - sequence = 0L; - } - lastTimestamp = timestamp; - // ID偏移组合生成最终的ID,并返回ID - long nextId = ((timestamp - twepoch) << timestampLeftShift) - | (datacenterId << datacenterIdShift) - | (workerId << workerIdShift) | sequence; - - return nextId; - } - - private long tilNextMillis(final long lastTimestamp) { - long timestamp = this.timeGen(); - while (timestamp <= lastTimestamp) { - timestamp = this.timeGen(); - } - return timestamp; - } - - private long timeGen() { - return System.currentTimeMillis(); - } - - /** - *

- * 获取 maxWorkerId - *

- */ - protected static long getMaxWorkerId(long datacenterId, long maxWorkerId) { - StringBuffer mpid = new StringBuffer(); - mpid.append(datacenterId); - String name = ManagementFactory.getRuntimeMXBean().getName(); - if (!name.isEmpty()) { - /* - * GET jvmPid - */ - mpid.append(name.split("@")[0]); - } - /* - * MAC + PID 的 hashcode 获取16个低位 - */ - return (mpid.toString().hashCode() & 0xffff) % (maxWorkerId + 1); - } - - /** - *

- * 数据标识id部分 - *

- */ - protected static long getDatacenterId(long maxDatacenterId) { - long id = 0L; - try { - InetAddress ip = InetAddress.getLocalHost(); - NetworkInterface network = NetworkInterface.getByInetAddress(ip); - if (network == null) { - id = 1L; - } else { - byte[] mac = network.getHardwareAddress(); - id = ((0x000000FF & (long) mac[mac.length - 1]) - | (0x0000FF00 & (((long) mac[mac.length - 2]) << 8))) >> 6; - id = id % (maxDatacenterId + 1); - } - } catch (Exception e) { - // System.out.println(" getDatacenterId: " + e.getMessage()); - } - return id; - } - - - public static void main(String[] args) { - //推特 26万个不重复的ID - //参数1 参数2 是在0 -31 之间 - IdWorker idWorker = new IdWorker(0,1); - for (int i = 0; i <100 ; i++) { - System.out.println(idWorker.nextId());//用于生成唯一的ID - } - } - -} \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/Result.java b/ty-common/src/main/java/top/kuanghua/khcomomon/entity/Result.java deleted file mode 100644 index 62ddcc2..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/entity/Result.java +++ /dev/null @@ -1,69 +0,0 @@ -package top.kuanghua.khcomomon.entity; - -import java.io.Serializable; - -/** - * 描述 - * - * @author 三国的包子 - * @version 1.0 - * @package entity * - * @since 1.0 - */ -public class Result implements Serializable { - private boolean flag;//是否成功 - private Integer code;//返回码 - private String msg;//返回消息 - private T data;//返回数据 - - public Result(boolean flag, Integer code, String msg, Object data) { - this.flag = flag; - this.code = code; - this.msg = msg; - this.data = (T) data; - } - - public Result(boolean flag, Integer code, String msg) { - this.flag = flag; - this.code = code; - this.msg = msg; - } - - public Result() { - this.flag = true; - this.code = StatusCode.OK; - this.msg = "操作成功!"; - } - - public boolean isFlag() { - return flag; - } - - public void setFlag(boolean flag) { - this.flag = flag; - } - - public Integer getCode() { - return code; - } - - public void setCode(Integer code) { - this.code = code; - } - - public String getMessage() { - return msg; - } - - public void setMessage(String msg) { - this.msg = msg; - } - - public T getData() { - return data; - } - - public void setData(T data) { - this.data = data; - } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ChineseUtils.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ChineseUtils.java deleted file mode 100644 index 15036ed..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ChineseUtils.java +++ /dev/null @@ -1,65 +0,0 @@ -package top.kuanghua.khcomomon.utils; - -import java.io.UnsupportedEncodingException; -import java.util.Random; - -/*** - * - * @Author:kuanghua - * - ****/ -public class ChineseUtils { - - private static Random random = null; - - private static Random getRandomInstance() { - if (random == null) { - random = new Random(System.currentTimeMillis()); - } - return random; - } - - public static String getChinese() { - String str = null; - int highPos, lowPos; - Random random = getRandomInstance(); - highPos = (176 + Math.abs(random.nextInt(39))); - lowPos = 161 + Math.abs(random.nextInt(93)); - byte[] b = new byte[2]; - b[0] = (new Integer(highPos)).byteValue(); - b[1] = (new Integer(lowPos)).byteValue(); - try { - str = new String(b, "GB2312"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - return str; - } - - public static String getFixedLengthChinese(int length) { - String str = ""; - for (int i = length; i > 0; i--) { - str = str + ChineseUtils.getChinese(); - } - return str; - } - - public static String getRandomLengthChiness(int start, int end) { - String str = ""; - int length = new Random().nextInt(end + 1); - if (length < start) { - str = getRandomLengthChiness(start, end); - } else { - for (int i = 0; i < length; i++) { - str = str + getChinese(); - } - } - return str; - } - - public static void main(String args[]) { -// System.out.println(ChineseUtils.getChinese()); -// System.out.println(ChineseUtils.getFixedLengthChinese(20)); -// System.out.println(ChineseUtils.getRandomLengthChiness(2, 5)); - } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/DateUtilSelf.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/DateUtilSelf.java deleted file mode 100644 index 8d0c2de..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/DateUtilSelf.java +++ /dev/null @@ -1,164 +0,0 @@ -package top.kuanghua.khcomomon.utils; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.*; - -/*** - * @Description: 时间操作工具类 - * @Author:kuanghua - ****/ -public class DateUtilSelf { - - //时间格式 - public static final String PATTERN_YYYYMMDDHH = "yyyyMMddHH"; - public static final String PATTERN_YYYY_MM_DDHHMM = "yyyy-MM-dd HH:mm"; - /*** - * 从yyyy-MM-dd HH:mm格式转成yyyyMMddHH格式 - * @param dateStr - * @return - */ - public static String formatStr(String dateStr,String opattern,String npattern){ - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(opattern); - try { - Date date = simpleDateFormat.parse(dateStr); - simpleDateFormat = new SimpleDateFormat(npattern); - return simpleDateFormat.format(date); - } catch (ParseException e) { - e.printStackTrace(); - } - return null; - } - - /*获取当前时间*/ - public static String getCurrentTime(){ - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); - String format = simpleDateFormat.format(new Date()); - return format; - } - - /*** - * 获取指定日期的凌晨 - * @return - */ - public static Date toDayStartHour(Date date){ - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - calendar.set(Calendar.MILLISECOND, 0); - Date start = calendar.getTime(); - return start; - } - - - /*** - * 时间增加N分钟 - * @param date - * @param minutes - * @return - */ - public static Date addDateMinutes(Date date,int minutes){ - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - calendar.add(Calendar.MINUTE, minutes);// 24小时制 - date = calendar.getTime(); - return date; - } - - /*** - * 时间递增N小时 - * @param hour - * @return - */ - public static Date addDateHour(Date date,int hour){//Jota-time - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - calendar.add(Calendar.HOUR, hour);// 24小时制 - date = calendar.getTime(); - return date; - } - - /*** - * 获取时间菜单 - * @return - */ - public static List getDateMenus(){ - //定义一个List集合,存储所有时间段 - List dates = getDates(12); - //判断当前时间属于哪个时间范围 - Date now = new Date(); - for (Date cdate : dates) { - //开始时间<=当前时间<开始时间+2小时 - if(cdate.getTime()<=now.getTime() && now.getTime() dateMenus = new ArrayList(); - for (int i = 0; i <5 ; i++) { - dateMenus.add(addDateHour(now,i*2)); - } - return dateMenus; - } - - /*** - * 指定时间往后N个时间间隔 - * @param hours - * @return - */ - public static List getDates(int hours) { - List dates = new ArrayList(); - //循环12次 - Date date = toDayStartHour(new Date()); //凌晨 - for (int i = 0; i 集合中 - dates.add(addDateHour(date,i*2)); - } - return dates; - } - - /*** - * 时间转换(yyyyMMddHH) - * @param date - * @param pattern - * @return - */ - public static String data2str(Date date, String pattern){ - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); - return simpleDateFormat.format(date); - } - - - /** - * 计算时间差 - * @param startTime - * @param endTime - * @param format - * @return 两个时间的差(小时,分钟等) - * @throws ParseException - */ - public static HashMap dateDiff(String startTime, String endTime, String format) throws ParseException { - //按照dao传入的格式生成一个simpledateformate对象 - SimpleDateFormat sd = new SimpleDateFormat(format); - long nd = 1000 * 24 * 60 * 60;//一天的毫秒数 - long nh = 1000 * 60 * 60;//一小时的毫秒数 - long nm = 1000 * 60;//一分钟的毫秒数 - long ns = 1000;//一秒钟的毫秒数long diff;try { - //获得两个时间的毫秒时间差异 - long diff = sd.parse(endTime).getTime() - sd.parse(startTime).getTime(); - long day = diff / nd;//计算差多少天 - long hour = diff % nd / nh;//计算差多少小时 - long min = diff % nd % nh / nm;//计算差多少分钟 - long sec = diff % nd % nh % nm / ns;//计算差多少秒//输出结果 - HashMap map = new HashMap<>(); - map.put("day",day); - map.put("hour",hour); - map.put("min",min>=10?min:'0'+min); - map.put("sec",sec); - return map; - } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/IdWorker.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/IdWorker.java deleted file mode 100644 index 520a05f..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/IdWorker.java +++ /dev/null @@ -1,163 +0,0 @@ -package top.kuanghua.khcomomon.utils; - -import java.lang.management.ManagementFactory; -import java.net.InetAddress; -import java.net.NetworkInterface; - -/** - *

名称:IdWorker.java

- *

描述:分布式自增长ID

- *
- *     Twitter的 Snowflake JAVA实现方案
- * 
- * 核心代码为其IdWorker这个类实现,其原理结构如下,我分别用一个0表示一位,用—分割开部分的作用: - * 1||0---0000000000 0000000000 0000000000 0000000000 0 --- 00000 ---00000 ---000000000000 - * 在上面的字符串中,第一位为未使用(实际上也可作为long的符号位),接下来的41位为毫秒级时间, - * 然后5位datacenter标识位,5位机器ID(并不算标识符,实际是为线程标识), - * 然后12位该毫秒内的当前毫秒内的计数,加起来刚好64位,为一个Long型。 - * 这样的好处是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由datacenter和机器ID作区分), - * 并且效率较高,经测试,snowflake每秒能够产生26万ID左右,完全满足需要。 - *

- * 64位ID (42(毫秒)+5(机器ID)+5(业务编码)+12(重复累加)) - * - * @author Polim - */ -public class IdWorker { - // 时间起始标记点,作为基准,一般取系统的最近时间(一旦确定不能变动) - private final static long twepoch = 1288834974657L; - // 机器标识位数 - private final static long workerIdBits = 5L; - // 数据中心标识位数 - private final static long datacenterIdBits = 5L; - // 机器ID最大值 - private final static long maxWorkerId = -1L ^ (-1L << workerIdBits); - // 数据中心ID最大值 - private final static long maxDatacenterId = -1L ^ (-1L << datacenterIdBits); - // 毫秒内自增位 - private final static long sequenceBits = 12L; - // 机器ID偏左移12位 - private final static long workerIdShift = sequenceBits; - // 数据中心ID左移17位 - private final static long datacenterIdShift = sequenceBits + workerIdBits; - // 时间毫秒左移22位 - private final static long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits; - - private final static long sequenceMask = -1L ^ (-1L << sequenceBits); - /* 上次生产id时间戳 */ - private static long lastTimestamp = -1L; - // 0,并发控制 - private long sequence = 0L; - - private final long workerId; - // 数据标识id部分 - private final long datacenterId; - - public IdWorker() { - this.datacenterId = getDatacenterId(maxDatacenterId); - this.workerId = getMaxWorkerId(datacenterId, maxWorkerId); - } - - /** - * @param workerId 工作机器ID - * @param datacenterId 序列号 - */ - public IdWorker(long workerId, long datacenterId) { - if (workerId > maxWorkerId || workerId < 0) { - throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId)); - } - if (datacenterId > maxDatacenterId || datacenterId < 0) { - throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId)); - } - this.workerId = workerId; - this.datacenterId = datacenterId; - } - - /** - * 获取下一个ID - * - * @return - */ - public synchronized long nextId() { - long timestamp = timeGen(); - if (timestamp < lastTimestamp) { - throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp)); - } - - if (lastTimestamp == timestamp) { - // 当前毫秒内,则+1 - sequence = (sequence + 1) & sequenceMask; - if (sequence == 0) { - // 当前毫秒内计数满了,则等待下一秒 - timestamp = tilNextMillis(lastTimestamp); - } - } else { - sequence = 0L; - } - lastTimestamp = timestamp; - // ID偏移组合生成最终的ID,并返回ID - long nextId = ((timestamp - twepoch) << timestampLeftShift) - | (datacenterId << datacenterIdShift) - | (workerId << workerIdShift) | sequence; - - return nextId; - } - - private long tilNextMillis(final long lastTimestamp) { - long timestamp = this.timeGen(); - while (timestamp <= lastTimestamp) { - timestamp = this.timeGen(); - } - return timestamp; - } - - private long timeGen() { - return System.currentTimeMillis(); - } - - /** - *

- * 获取 maxWorkerId - *

- */ - protected static long getMaxWorkerId(long datacenterId, long maxWorkerId) { - StringBuffer mpid = new StringBuffer(); - mpid.append(datacenterId); - String name = ManagementFactory.getRuntimeMXBean().getName(); - if (!name.isEmpty()) { - /* - * GET jvmPid - */ - mpid.append(name.split("@")[0]); - } - /* - * MAC + PID 的 hashcode 获取16个低位 - */ - return (mpid.toString().hashCode() & 0xffff) % (maxWorkerId + 1); - } - - /** - *

- * 数据标识id部分 - *

- */ - protected static long getDatacenterId(long maxDatacenterId) { - long id = 0L; - try { - InetAddress ip = InetAddress.getLocalHost(); - NetworkInterface network = NetworkInterface.getByInetAddress(ip); - if (network == null) { - id = 1L; - } else { - byte[] mac = network.getHardwareAddress(); - id = ((0x000000FF & (long) mac[mac.length - 1]) - | (0x0000FF00 & (((long) mac[mac.length - 2]) << 8))) >> 6; - id = id % (maxDatacenterId + 1); - } - } catch (Exception e) { - //System.out.println(" getDatacenterId: " + e.getMessage()); - } - return id; - } - - -} \ No newline at end of file diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/JwtUtil.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/JwtUtil.java deleted file mode 100644 index ff2f3f7..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/JwtUtil.java +++ /dev/null @@ -1,104 +0,0 @@ -package top.kuanghua.khcomomon.utils; - -import io.jsonwebtoken.Claims; -import io.jsonwebtoken.JwtBuilder; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; - -import javax.crypto.SecretKey; -import javax.crypto.spec.SecretKeySpec; -import java.util.Base64; -import java.util.Date; -import java.util.Map; - -/** - * 描述 - * - * @author kuanghua - * @version 1.0 - * @package entity * - * @since 1.0 - */ -public class JwtUtil { - //有效期为 - public static final Long JWT_TTL = 3600000L;// 60 * 60 *1000 一个小时 - - //Jwt令牌信息 - public static final String JWT_KEY = "@Kuanghua8866"; - - /** - * 生成令牌 - //* @param id - //* @param subject - * @param ttlMillis - * @return - */ - public static String createJWT(Map userInfo, Long ttlMillis) { - //指定算法 - SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; - //当前系统时间 - long nowMillis = System.currentTimeMillis(); - //令牌签发时间 - Date now = new Date(nowMillis); - //如果令牌有效期为null,则默认设置有效期1小时 - if (ttlMillis == null) { - ttlMillis = JwtUtil.JWT_TTL; - } - //令牌过期时间设置 - long expMillis = nowMillis + ttlMillis; - Date expDate = new Date(expMillis); - - //生成秘钥 - SecretKey secretKey = generalKey(); - - //封装Jwt令牌信息 - JwtBuilder builder = Jwts.builder() - //.setId(id) - //.setSubject(subject) // 主题 可以是JSON数据 - //.setIssuer("admin") // 签发者 - .setIssuedAt(now) // 签发时间 - .signWith(signatureAlgorithm, secretKey) // 签名算法以及密匙 - .setExpiration(expDate); // 设置过期时间 - - JwtBuilder jwtBuilder = builder.addClaims(userInfo); - return builder.compact(); - } - - /** - * 生成加密 secretKey - * - * @return - */ - public static SecretKey generalKey() { - byte[] encodedKey = Base64.getEncoder().encode(JwtUtil.JWT_KEY.getBytes()); - SecretKey key = new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES"); - return key; - } - - /** - * 解析令牌数据 - * - * @param jwt - * @return - * @throws Exception - */ - public static Claims parseJWT(String jwt) throws Exception { - SecretKey secretKey = generalKey(); - return Jwts.parser() - .setSigningKey(secretKey) - .parseClaimsJws(jwt) - .getBody(); - } -// public static void main(String[] args) { -// String jwt = JwtUtil.createJWT("weiyibiaoshi", ) -// System.out.println(jwt); -// try { -// Claims claims = JwtUtil.parseJWT(jwt); -// System.out.println(claims); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// -// -// } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/NumberUtilsSelf.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/NumberUtilsSelf.java deleted file mode 100644 index eaae4c6..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/NumberUtilsSelf.java +++ /dev/null @@ -1,73 +0,0 @@ -package top.kuanghua.khcomomon.utils; - -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import java.util.regex.MatchResult; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author: HuYi.Zhang - * @create: 2018-04-25 09:13 - **/ -public class NumberUtilsSelf { - - public static boolean isInt(Double num) { - return num.intValue() == num; - } - - /** - * 判断字符串是否是数值格式 - * - * @param str - * @return - */ - public static boolean isDigit(String str) { - if (str == null || str.trim().equals("")) { - return false; - } - return str.matches("^\\d+$"); - } - - /** - * 将一个小数精确到指定位数 - * - * @param num - * @param scale - * @return - */ - public static double scale(double num, int scale) { - BigDecimal bd = new BigDecimal(num); - return bd.setScale(scale, RoundingMode.HALF_UP).doubleValue(); - } - - // 从字符串中根据正则表达式寻找,返回找到的数字数组 - public static Double[] searchNumber(String value, String regex) { - List doubles = new ArrayList<>(); - Pattern pattern = Pattern.compile(regex); - Matcher matcher = pattern.matcher(value); - if (matcher.find()) { - MatchResult result = matcher.toMatchResult(); - for (int i = 1; i <= result.groupCount(); i++) { - doubles.add(Double.valueOf(result.group(i))); - } - } - return doubles.toArray(new Double[doubles.size()]); - } - - /** - * 生成指定位数的随机数字 - * - * @param len - * @return - */ - public static String generateCode(int len) { - len = Math.min(len, 8); - int min = Double.valueOf(Math.pow(10, len - 1)).intValue(); - int num = new Random().nextInt(Double.valueOf(Math.pow(10, len + 1)).intValue() - 1) + min; - return String.valueOf(num).substring(0, len); - } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RandomValueUtil.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RandomValueUtil.java deleted file mode 100644 index d35f22d..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RandomValueUtil.java +++ /dev/null @@ -1,126 +0,0 @@ -package top.kuanghua.khcomomon.utils; - -/*** - * - * @Author:kuanghua - * - ****/ -public class RandomValueUtil { - public static String base = "abcdefghijklmnopqrstuvwxyz0123456789"; - private static String firstName="赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卞齐康伍余元卜顾孟平黄和穆萧尹姚邵湛汪祁毛禹狄米贝明臧计伏成戴谈宋茅庞熊纪舒屈项祝董梁杜阮蓝闵席季麻强贾路娄危江童颜郭梅盛林刁钟徐邱骆高夏蔡田樊胡凌霍虞万支柯咎管卢莫经房裘缪干解应宗宣丁贲邓郁单杭洪包诸左石崔吉钮龚程嵇邢滑裴陆荣翁荀羊於惠甄魏加封芮羿储靳汲邴糜松井段富巫乌焦巴弓牧隗山谷车侯宓蓬全郗班仰秋仲伊宫宁仇栾暴甘钭厉戎祖武符刘姜詹束龙叶幸司韶郜黎蓟薄印宿白怀蒲台从鄂索咸籍赖卓蔺屠蒙池乔阴郁胥能苍双闻莘党翟谭贡劳逄姬申扶堵冉宰郦雍却璩桑桂濮牛寿通边扈燕冀郏浦尚农温别庄晏柴瞿阎充慕连茹习宦艾鱼容向古易慎戈廖庚终暨居衡步都耿满弘匡国文寇广禄阙东殴殳沃利蔚越夔隆师巩厍聂晁勾敖融冷訾辛阚那简饶空曾毋沙乜养鞠须丰巢关蒯相查后江红游竺权逯盖益桓公万俟司马上官欧阳夏侯诸葛闻人东方赫连皇甫尉迟公羊澹台公冶宗政濮阳淳于仲孙太叔申屠公孙乐正轩辕令狐钟离闾丘长孙慕容鲜于宇文司徒司空亓官司寇仉督子车颛孙端木巫马公西漆雕乐正壤驷公良拓拔夹谷宰父谷粱晋楚阎法汝鄢涂钦段干百里东郭南门呼延归海羊舌微生岳帅缑亢况后有琴梁丘左丘东门西门商牟佘佴伯赏南宫墨哈谯笪年爱阳佟第五言福百家姓续"; - private static String girl="秀娟英华慧巧美娜静淑惠珠翠雅芝玉萍红娥玲芬芳燕彩春菊兰凤洁梅琳素云莲真环雪荣爱妹霞香月莺媛艳瑞凡佳嘉琼勤珍贞莉桂娣叶璧璐娅琦晶妍茜秋珊莎锦黛青倩婷姣婉娴瑾颖露瑶怡婵雁蓓纨仪荷丹蓉眉君琴蕊薇菁梦岚苑婕馨瑗琰韵融园艺咏卿聪澜纯毓悦昭冰爽琬茗羽希宁欣飘育滢馥筠柔竹霭凝晓欢霄枫芸菲寒伊亚宜可姬舒影荔枝思丽 "; - public static String boy="伟刚勇毅俊峰强军平保东文辉力明永健世广志义兴良海山仁波宁贵福生龙元全国胜学祥才发武新利清飞彬富顺信子杰涛昌成康星光天达安岩中茂进林有坚和彪博诚先敬震振壮会思群豪心邦承乐绍功松善厚庆磊民友裕河哲江超浩亮政谦亨奇固之轮翰朗伯宏言若鸣朋斌梁栋维启克伦翔旭鹏泽晨辰士以建家致树炎德行时泰盛雄琛钧冠策腾楠榕风航弘"; - public static final String[] email_suffix="@gmail.com,@yahoo.com,@msn.com,@hotmail.com,@aol.com,@ask.com,@live.com,@qq.com,@0355.net,@163.com,@163.net,@263.net,@3721.net,@yeah.net,@googlemail.com,@126.com,@sina.com,@sohu.com,@yahoo.com.cn".split(","); - - public static int getNum(int start,int end) { - return (int)(Math.random()*(end-start+1)+start); - } - - /*** - * - * Project Name: recruit-helper-util - *

随机生成Email - * - * @author youqiang.xiong - * @date 2018年5月23日 下午2:13:06 - * @version v1.0 - * @since - * @param lMin - * 最小长度 - * @param lMax - * 最大长度 - * @return - */ - public static String getEmail(int lMin,int lMax) { - int length=getNum(lMin,lMax); - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < length; i++) { - int number = (int)(Math.random()*base.length()); - sb.append(base.charAt(number)); - } - sb.append(email_suffix[(int)(Math.random()*email_suffix.length)]); - return sb.toString(); - } - - private static String[] telFirst="134,135,136,137,138,139,150,151,152,157,158,159,130,131,132,155,156,133,153".split(","); - - /*** - * - * Project Name: recruit-helper-util - *

随机生成手机号码 - * - * @author youqiang.xiong - * @date 2018年5月23日 下午2:14:17 - * @version v1.0 - * @since - * @return - */ - public static String getTelephone() { - int index=getNum(0,telFirst.length-1); - String first=telFirst[index]; - String second=String.valueOf(getNum(1,888)+10000).substring(1); - String thrid=String.valueOf(getNum(1,9100)+10000).substring(1); - return first+second+thrid; - } - - /*** - * - * Project Name: recruit-helper-util - *

随机生成8位电话号码 - * - * @author youqiang.xiong - * @date 2018年5月23日 下午2:15:31 - * @version v1.0 - * @since - * @return - */ - public static String getLandline() { - int index=getNum(0,telFirst.length-1); - String first=telFirst[index]; - String second=String.valueOf(getNum(1,888)+10000).substring(1); - String thrid=String.valueOf(getNum(1,9100)+10000).substring(1); - return first+second+thrid; - } - - - - /** - * 返回中文姓名 - */ - public static String name_sex = ""; - - /*** - * - * Project Name: recruit-helper-util - *

返回中文姓名 - * - * @author youqiang.xiong - * @date 2018年5月23日 下午2:16:16 - * @version v1.0 - * @since - * @return - */ - public static String getChineseName() { - int index = getNum(0, firstName.length() - 1); - String first = firstName.substring(index, index + 1); - int sex = getNum(0, 1); - String str = boy; - int length = boy.length(); - if (sex == 0) { - str = girl; - length = girl.length(); - name_sex = "女"; - } else { - name_sex = "男"; - } - index = getNum(0, length - 1); - String second = str.substring(index, index + 1); - int hasThird = getNum(0, 1); - String third = ""; - if (hasThird == 1) { - index = getNum(0, length - 1); - third = str.substring(index, index + 1); - } - return first + second + third; - } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RedisClientUtils.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RedisClientUtils.java deleted file mode 100644 index 841c22b..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/RedisClientUtils.java +++ /dev/null @@ -1,577 +0,0 @@ -package top.kuanghua.khcomomon.utils; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -/** - * Redis工具类 - */ -@Component -public class RedisClientUtils { - - @Autowired - private RedisTemplate redisTemplate; - - /** - * 指定缓存失效时间 - * - * @param key 键 - * @param time 时间(秒) - * @return - */ - public boolean expire(String key, long time) { - try { - if (time > 0) { - redisTemplate.expire(key, time, TimeUnit.SECONDS); - } - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - /** - * 根据key 获取过期时间 - * - * @param key 键 不能为null - * @return 时间(秒) 返回0代表为永久有效 - */ - public long getExpire(String key) { - return redisTemplate.getExpire(key, TimeUnit.SECONDS); - } - - /** - * 判断key是否存在 - * - * @param key 键 - * @return true 存在 false不存在 - */ - public boolean hasKey(String key) { - try { - return redisTemplate.hasKey(key); - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - /** - * 删除缓存 - * - * @param key 可以传一个值 或多个 - */ - @SuppressWarnings("unchecked") - public void del(String... key) { - if (key != null && key.length > 0) { - if (key.length == 1) { - redisTemplate.delete(key[0]); - } else { - redisTemplate.delete(CollectionUtils.arrayToList(key)); - } - } - } - - public void del(Integer key) { - this.del(String.valueOf(key)); - } - - // ============================String============================= - - /** - * 普通缓存获取 - * - * @param key 键 - * @return 值 - */ - public Object get(String key) { - return key == null ? null : redisTemplate.opsForValue().get(key); - } - - public Object get(Integer key) { - return this.get(String.valueOf(key)); - } - - /** - * 普通缓存放入 - * - * @param key 键 - * @param value 值 - * @return true成功 false失败 - */ - public boolean set(String key, Object value) { - try { - redisTemplate.opsForValue().set(key, value); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - public boolean set(Integer key, Object value) { - return this.set(String.valueOf(key), value); - } - - /** - * 普通缓存放入并设置时间 - * - * @param key 键 - * @param value 值 - * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期 - * @return true成功 false 失败 - */ - public boolean set(String key, Object value, long time) { - try { - if (time > 0) { - redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS); - } else { - set(key, value); - } - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - /** - * 递增 - * - * @param key 键 - * @param delta 要增加几(大于0) - * @return - */ - public long incr(String key, long delta) { - if (delta < 0) { - throw new RuntimeException("递增因子必须大于0"); - } - return redisTemplate.opsForValue().increment(key, delta); - } - - /** - * 递减 - * - * @param key 键 - * @param delta 要减少几(小于0) - * @return - */ - public long decr(String key, long delta) { - if (delta < 0) { - throw new RuntimeException("递减因子必须大于0"); - } - return redisTemplate.opsForValue().increment(key, -delta); - } - // ================================Map================================= - - /** - * HashGet - * - * @param key 键 不能为null - * @param item 项 不能为null - * @return 值 - */ - public Object hget(String key, String item) { - return redisTemplate.opsForHash().get(key, item); - } - - /** - * 获取hashKey对应的所有键值 - * - * @param key 键 - * @return 对应的多个键值 - */ - public Map hmget(String key) { - return redisTemplate.opsForHash().entries(key); - } - - /** - * HashSet - * - * @param key 键 - * @param map 对应多个键值 - * @return true 成功 false 失败 - */ - public boolean hmset(String key, Map map) { - try { - redisTemplate.opsForHash().putAll(key, map); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - /** - * HashSet 并设置时间 - * - * @param key 键 - * @param map 对应多个键值 - * @param time 时间(秒) - * @return true成功 false失败 - */ - public boolean hmset(String key, Map map, long time) { - try { - redisTemplate.opsForHash().putAll(key, map); - if (time > 0) { - expire(key, time); - } - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - /** - * 向一张hash表中放入数据,如果不存在将创建 - * - * @param key 键 - * @param item 项 - * @param value 值 - * @return true 成功 false失败 - */ - public boolean hset(String key, String item, Object value) { - try { - redisTemplate.opsForHash().put(key, item, value); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - /** - * 向一张hash表中放入数据,如果不存在将创建 - * - * @param key 键 - * @param item 项 - * @param value 值 - * @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间 - * @return true 成功 false失败 - */ - public boolean hset(String key, String item, Object value, long time) { - try { - redisTemplate.opsForHash().put(key, item, value); - if (time > 0) { - expire(key, time); - } - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - /** - * 删除hash表中的值 - * - * @param key 键 不能为null - * @param item 项 可以使多个 不能为null - */ - public void hdel(String key, Object... item) { - redisTemplate.opsForHash().delete(key, item); - } - - /** - * 判断hash表中是否有该项的值 - * - * @param key 键 不能为null - * @param item 项 不能为null - * @return true 存在 false不存在 - */ - public boolean hHasKey(String key, String item) { - return redisTemplate.opsForHash().hasKey(key, item); - } - - /** - * hash递增 如果不存在,就会创建一个 并把新增后的值返回 - * - * @param key 键 - * @param item 项 - * @param by 要增加几(大于0) - * @return - */ - public double hincr(String key, String item, double by) { - return redisTemplate.opsForHash().increment(key, item, by); - } - - /** - * hash递减 - * - * @param key 键 - * @param item 项 - * @param by 要减少记(小于0) - * @return - */ - public double hdecr(String key, String item, double by) { - return redisTemplate.opsForHash().increment(key, item, -by); - } - - // ============================set============================= - - /** - * 根据key获取Set中的所有值 - * - * @param key 键 - * @return - */ - public Set sGet(String key) { - try { - return redisTemplate.opsForSet().members(key); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - /** - * 根据value从一个set中查询,是否存在 - * - * @param key 键 - * @param value 值 - * @return true 存在 false不存在 - */ - public boolean sHasKey(String key, Object value) { - try { - return redisTemplate.opsForSet().isMember(key, value); - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - /** - * 将数据放入set缓存 - * - * @param key 键 - * @param values 值 可以是多个 - * @return 成功个数 - */ - public long sSet(String key, Object... values) { - try { - return redisTemplate.opsForSet().add(key, values); - } catch (Exception e) { - e.printStackTrace(); - return 0; - } - } - - /** - * 将set数据放入缓存 - * - * @param key 键 - * @param time 时间(秒) - * @param values 值 可以是多个 - * @return 成功个数 - */ - public long sSetAndTime(String key, long time, Object... values) { - try { - Long count = redisTemplate.opsForSet().add(key, values); - if (time > 0) - expire(key, time); - return count; - } catch (Exception e) { - e.printStackTrace(); - return 0; - } - } - - /** - * 获取set缓存的长度 - * - * @param key 键 - * @return - */ - public long sGetSetSize(String key) { - try { - return redisTemplate.opsForSet().size(key); - } catch (Exception e) { - e.printStackTrace(); - return 0; - } - } - - /** - * 移除值为value的 - * - * @param key 键 - * @param values 值 可以是多个 - * @return 移除的个数 - */ - public long setRemove(String key, Object... values) { - try { - Long count = redisTemplate.opsForSet().remove(key, values); - return count; - } catch (Exception e) { - e.printStackTrace(); - return 0; - } - } - // ===============================list================================= - - /** - * 获取list缓存的内容 - * - * @param key 键 - * @param start 开始 - * @param end 结束 0 到 -1代表所有值 - * @return - */ - public List lGet(String key, long start, long end) { - try { - return redisTemplate.opsForList().range(key, start, end); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - /** - * 获取list缓存的长度 - * - * @param key 键 - * @return - */ - public long lGetListSize(String key) { - try { - return redisTemplate.opsForList().size(key); - } catch (Exception e) { - e.printStackTrace(); - return 0; - } - } - - /** - * 通过索引 获取list中的值 - * - * @param key 键 - * @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推 - * @return - */ - public Object lGetIndex(String key, long index) { - try { - return redisTemplate.opsForList().index(key, index); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - /** - * 将list放入缓存 - * - * @param key 键 - * @param value 值 - * @return - */ - public boolean lSet(String key, Object value) { - try { - redisTemplate.opsForList().rightPush(key, value); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - /** - * 将list放入缓存 - * - * @param key 键 - * @param value 值 - * @param time 时间(秒) - * @return - */ - public boolean lSet(String key, Object value, long time) { - try { - redisTemplate.opsForList().rightPush(key, value); - if (time > 0) - expire(key, time); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - /** - * 将list放入缓存 - * - * @param key 键 - * @param value 值 - * @return - */ - public boolean lSet(String key, List value) { - try { - redisTemplate.opsForList().rightPushAll(key, value); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - /** - * 将list放入缓存 - * - * @param key 键 - * @param value 值 - * @param time 时间(秒) - * @return - */ - public boolean lSet(String key, List value, long time) { - try { - redisTemplate.opsForList().rightPushAll(key, value); - if (time > 0) - expire(key, time); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - /** - * 根据索引修改list中的某条数据 - * - * @param key 键 - * @param index 索引 - * @param value 值 - * @return - */ - public boolean lUpdateIndex(String key, long index, Object value) { - try { - redisTemplate.opsForList().set(key, index, value); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - /** - * 移除N个值为value - * - * @param key 键 - * @param count 移除多少个 - * @param value 值 - * @return 移除的个数 - */ - public long lRemove(String key, long count, Object value) { - try { - Long remove = redisTemplate.opsForList().remove(key, count, value); - return remove; - } catch (Exception e) { - e.printStackTrace(); - return 0; - } - } -} diff --git a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ThreadUtils.java b/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ThreadUtils.java deleted file mode 100644 index cbdb057..0000000 --- a/ty-common/src/main/java/top/kuanghua/khcomomon/utils/ThreadUtils.java +++ /dev/null @@ -1,13 +0,0 @@ -package top.kuanghua.khcomomon.utils; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -public class ThreadUtils { - - private static final ExecutorService es = Executors.newFixedThreadPool(10); - - public static void execute(Runnable runnable) { - es.submit(runnable); - } -} \ No newline at end of file diff --git a/ty-common/src/main/resources/application-dev.yml b/ty-common/src/main/resources/application-dev.yml deleted file mode 100644 index 0397283..0000000 --- a/ty-common/src/main/resources/application-dev.yml +++ /dev/null @@ -1,7 +0,0 @@ -spring: - main: - allow-bean-definition-overriding: true - #解决查询时间和返回的时间不一致问题 - jackson: - date-format: yyyy-MM-dd HH:mm:ss - time-zone: GMT+8 \ No newline at end of file diff --git a/ty-common/src/main/resources/application-prod.yml b/ty-common/src/main/resources/application-prod.yml deleted file mode 100644 index 0397283..0000000 --- a/ty-common/src/main/resources/application-prod.yml +++ /dev/null @@ -1,7 +0,0 @@ -spring: - main: - allow-bean-definition-overriding: true - #解决查询时间和返回的时间不一致问题 - jackson: - date-format: yyyy-MM-dd HH:mm:ss - time-zone: GMT+8 \ No newline at end of file diff --git a/ty-common/src/main/resources/application-test.yml b/ty-common/src/main/resources/application-test.yml deleted file mode 100644 index 0397283..0000000 --- a/ty-common/src/main/resources/application-test.yml +++ /dev/null @@ -1,7 +0,0 @@ -spring: - main: - allow-bean-definition-overriding: true - #解决查询时间和返回的时间不一致问题 - jackson: - date-format: yyyy-MM-dd HH:mm:ss - time-zone: GMT+8 \ No newline at end of file diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java b/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java deleted file mode 100644 index 4d0b9d6..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/ExampleApplication.java +++ /dev/null @@ -1,19 +0,0 @@ -package top.kuanghua.tyexample; - -import com.xpand.starter.canal.annotation.EnableCanalClient; -import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.scheduling.annotation.EnableAsync; -import org.springframework.scheduling.annotation.EnableScheduling; - -@SpringBootApplication -@EnableScheduling -@EnableAsync -@EnableCanalClient -@EnableAutoDataSourceProxy -public class ExampleApplication { - public static void main(String[] args) { - SpringApplication.run(ExampleApplication.class, args); - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java b/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java deleted file mode 100644 index bac5ac1..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/config/BaseConfig.java +++ /dev/null @@ -1,27 +0,0 @@ -package top.kuanghua.tyexample.config; - -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * @Title: BaseConfig - * @Description: - * @Auther: kuanghua - * @create 2020/8/23 21:52 - */ -/* - * 总结:1.@Configuration 下的@ComponentScan回将包下带有@Component扫描变成配置类, - * 而@SpringBootApplication扫描的只会变成普通类 - * */ -@Configuration -//扫描公用包的配置和自身的配置类 -@ComponentScan(basePackages = {"top.kuanghua.khcomomon"}) -//mapper scanning -@MapperScan(basePackages = {"top.kuanghua.tyexample.mapper"}) -//feign scanning -@EnableFeignClients(basePackages = {"top.kuanghua.feign.integrationfront", "top.kuanghua.feign.tyauth",}) -public class BaseConfig { - -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/config/RabbitDelayConfig.java b/ty-example/src/main/java/top/kuanghua/tyexample/config/RabbitDelayConfig.java deleted file mode 100644 index 1959f7f..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/config/RabbitDelayConfig.java +++ /dev/null @@ -1,67 +0,0 @@ -package top.kuanghua.tyexample.config; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.amqp.core.*; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.util.HashMap; -import java.util.Map; - -/** - * @Title: Configuration - * @Description: - * @Auther: kuanghua - * @create 2022/1/05 10:04 - */ -@Configuration -@Slf4j -public class RabbitDelayConfig { - - /*死信部分*/ - public static final String ORDER_DELAY_QUEUE = "queue.delay.user.order"; - public static final String ORDER_DELAY_EXCHANGE = "exchange.delay.user.order"; - public static final String ORDER_DELAY_ROUTING_KEY = "delay_order"; - /*普通交换机*/ - public static final String ORDER_QUEUE_NAME = "queue.user.order"; - public static final String ORDER_EXCHANGE_NAME = "exchange.user.order"; - public static final String ORDER_ROUTING_KEY = "order"; - - /* - * DELAY_EXCHANGE - * 死信交换机原理:发送到死信交换机(在有效期时间内接收信息不进行转发,超时则进行转发到其他队列) - * */ - @Bean - public Queue delayOrderQueue() { - Map params = new HashMap<>(); - // 转发的队列交换机的名称 - params.put("x-dead-letter-exchange", ORDER_EXCHANGE_NAME); - // 转发的队列队列的路由名称 - params.put("x-dead-letter-routing-key", ORDER_ROUTING_KEY); - return new Queue(ORDER_DELAY_QUEUE, true, false, false, params); - } - @Bean - public DirectExchange orderDelayExchange() { - return new DirectExchange(ORDER_DELAY_EXCHANGE); - } - - - @Bean - public Binding dlxBinding() { - return BindingBuilder.bind(delayOrderQueue()).to(orderDelayExchange()).with(ORDER_DELAY_ROUTING_KEY); - } - - /*普通交换机*/ - @Bean - public Queue orderQueue() { - return new Queue(ORDER_QUEUE_NAME, true); - } - @Bean - public TopicExchange orderTopicExchange() { - return new TopicExchange(ORDER_EXCHANGE_NAME); - } - @Bean - public Binding orderBinding() { - return BindingBuilder.bind(orderQueue()).to(orderTopicExchange()).with(ORDER_ROUTING_KEY); - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/config/SmsProperties.java b/ty-example/src/main/java/top/kuanghua/tyexample/config/SmsProperties.java deleted file mode 100644 index ab4ad5e..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/config/SmsProperties.java +++ /dev/null @@ -1,25 +0,0 @@ -package top.kuanghua.tyexample.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -/** - * @Title: SmsProperties - * @Description: - * @Auther:jzfai - * @Version: 1.0 - * @create 2020/3/13 18:19 - */ -@Component -@ConfigurationProperties(prefix = "kuanghua.sms") -@Data -public class SmsProperties { - String accessKeyId; - - String accessKeySecret; - - String signName; - - String verifyCodeTemplate; -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java b/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java deleted file mode 100644 index 85efbcf..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/config/Swagger2Config.java +++ /dev/null @@ -1,55 +0,0 @@ -package top.kuanghua.tyexample.config; - -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Component -@EnableSwagger2 //开启在线接口文档 -//配置包扫描 -public class Swagger2Config { - private boolean swagger_is_enable = true; - - @Value("${server.port}") - private String port; - - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .enable(swagger_is_enable) - //.host(this.ipAddr + ":" + this.port) - .apiInfo(apiInfo()) - .select() - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) - //.apis(basePackage("top.kuanghua.swagger.controller")) - .paths(PathSelectors.any()) - .build(); - } - - /** - * 构建 api文档的详细信息函数 - * - * @return - */ - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("micro-service-plus") - .description("描述:新一代的微服务架构") - .contact(new Contact("kuanghua", null, "869653722@qq.com")) - .version("版本号:2.9") - .build(); - } - - /** - * http://localhost:8080/swagger-ui.html - */ -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/GetTokenFromOtherService.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/GetTokenFromOtherService.java deleted file mode 100644 index 204e161..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/GetTokenFromOtherService.java +++ /dev/null @@ -1,35 +0,0 @@ -package top.kuanghua.tyexample.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import top.kuanghua.feign.tyauth.feign.TestGetTokenFeign; -import top.kuanghua.khcomomon.entity.ResResult; - -import javax.annotation.Resource; - -/** - * @Title: GetTokenFromOtherService - * @Description: - * @Auther: kuanghua - * @create 2022-01-14 17:31 - */ -@RestController -@Api(tags = "feign转发请求头测试") -@RequestMapping("testFeign") -@Slf4j -public class GetTokenFromOtherService { - @Resource - private TestGetTokenFeign testGetTokenFeign; - - @ApiOperation(value = "获取token信息(需要配置gateway拦截,然后用postman在头部添加token进行测试,token可以从vue3-admin-plus中获取)") - @PostMapping("getTokenFromService") - public ResResult getTokenFromService() { - ResResult tokenInfo = testGetTokenFeign.getTokenInfo(); - log.info(tokenInfo.getData().toString()); - return new ResResult<>().success(tokenInfo); - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/HystrixRibbonController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/HystrixRibbonController.java deleted file mode 100644 index ced9bb3..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/HystrixRibbonController.java +++ /dev/null @@ -1,31 +0,0 @@ -package top.kuanghua.tyexample.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import top.kuanghua.khcomomon.entity.ResResult; - -/** - * @Title: HystrixRibbonController - * @Description: - * @Auther: kuanghua - * @create 2022-01-08 17:20 - */ -@Api(tags = "HystrixRibbon和限流测试") -@RestController -@RequestMapping("hystrixRibbon") -public class HystrixRibbonController { - @ApiOperation(value = "测试Hystrix熔断和Ribbon") - @GetMapping("timeoutTest") - public ResResult timeoutTest() { - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - return new ResResult<>().success(); - - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/RabbitDelayController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/RabbitDelayController.java deleted file mode 100644 index a67d5f4..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/RabbitDelayController.java +++ /dev/null @@ -1,35 +0,0 @@ -package top.kuanghua.tyexample.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.tyexample.service.RabbitDelayService; - -import javax.annotation.Resource; - -/** - * @Title: RabbitDelayController - * @Description: - * @Auther: kuanghua - * @create 2022-01-06 17:23 - */ -@Api(tags = "延时队列") -@RestController -@RequestMapping("delayQueue") -public class RabbitDelayController { - - @Resource - private RabbitDelayService rabbitDelayService; - - @ApiOperation(value = "测试延时队列") - @GetMapping("convertAndSend") - public ResResult convertAndSend(@ApiParam("延时时间(s)") @RequestParam("time") Integer time) { - rabbitDelayService.convertAndSend(time); - return new ResResult().success(); - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java deleted file mode 100644 index ea895c9..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/RedisTestController.java +++ /dev/null @@ -1,131 +0,0 @@ -package top.kuanghua.tyexample.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.BoundHashOperations; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; -import top.kuanghua.khcomomon.utils.RedisClientUtils; -import top.kuanghua.tyexample.entity.ErrorCollection; -import top.kuanghua.tyexample.mapper.ErrorCollectionMapper; - -import javax.annotation.PostConstruct; -import javax.annotation.Resource; -import java.text.MessageFormat; -import java.util.List; -import java.util.concurrent.TimeUnit; - -/** - * @Title: CacheAvalancheController - * @Description: - * @Auther: kuanghua - * @create 2022-01-09 16:48 - */ -@Api(tags = "缓存击穿和雪崩,redis锁") -@RestController -@RequestMapping("redisCache") -public class RedisTestController { - - @Resource - private ErrorCollectionMapper errorCollectionMapper; - - @Autowired - private RedisTemplate redisTemplate; - - @Resource - private RedisClientUtils redisClient; - - - private Integer orderCount = 10; - private String redisCountKey = "orderCo"; - - - @PostConstruct - public void intParam() { - BoundHashOperations hashKey = redisTemplate.boundHashOps("hashKey"); - hashKey.increment(redisCountKey, orderCount); - } - - /* redis缓存击穿问题 - * 1. 当用户根据key 查询数据时,先查询缓存,如果缓存有命中,返回, - 2. 但是如果缓存没有命中直接穿过缓存层,访问数据层 如果有,则存储指缓存, - 3. 但是同样如果没有命中,(也就是数据库中也没有数据)直接返回用户,但是不缓存 - 这就是缓存的穿透。如果某一个key 请求量很大,但是存储层也没有数据,大量的请求都会达到存储层就会造成数据库压力巨大,有可能宕机的情况。 - - - 缓存雪崩 - 如果缓存集中在一段时间内失效,发生大量的缓存穿透,所有的查询都落在数据库上,造成了缓存雪崩。 - 这个没有完美解决办法,但可以分析用户行为,尽量让失效时间点均匀分布。 - + 限流 加锁排队 - - 在缓存失效后,通过对某一个key加锁或者是队列 来控制key的线程访问的数量。例如:某一个key 只允许一个线程进行 操作。 - - + 限流 - - 在缓存失效后,某一个key 做count统计限流,达到一定的阈值,直接丢弃,不再查询数据库。例如:令牌桶算法。等等。 - - + 数据预热 - - 在缓存失效应当尽量避免某一段时间,可以先进行数据预热,比如某些热门的商品。提前在上线之前,或者开放给用户使用之前,先进行loading 缓存中,这样用户使用的时候,直接从缓存中获取。要注意的是,要更加业务来进行过期时间的设置 ,尽量均匀。 - - + 做缓存降级(二级缓存策略) - - 当分布式缓存失效的时候,可以采用本地缓存,本地缓存没有再查询数据库。这种方式,可以避免很多数据分布式缓存没有,就直接打到数据库的情况。 - - * */ - - @ApiOperation(value = "查询错误日志") - @GetMapping("queryErrorLogList") - public ResResult queryErrorLogList() { - String key = "queryErrorLogList"; - /* - * 解决缓存穿透带来的问题 - * 1.查询值为空的时候也设置到redis的key上 - * 2.给空值的key设定过期时间(为了避免过多的KEY 存储在redis中) - * */ - if (redisTemplate.hasKey(key)) { - List redisList = redisTemplate.opsForList().range(key, 0, -1); - return new ResResult().success(redisList); - } else { - List ecList = errorCollectionMapper.selectList(null); - //无论ecList是否为空都设置到redis的key上,解决缓存穿透带来的雪崩问题 - //如果为空,一般情况下都需要设置一个过期时间,例如:5分钟失效。(为了避免过多的KEY 存储在redis中) - redisTemplate.opsForList().leftPushAll(key, ecList); - if (ObjectUtilsSelf.isEmpty(ecList)) { - //此处设置为20s,进行测试 - redisTemplate.expire(key, 20, TimeUnit.SECONDS); - } else { - //此处设置为20s,进行测试,不为空时可以不设置过期时间,根据业务需求进行设置 - redisTemplate.expire(key, 20, TimeUnit.SECONDS); - } - return new ResResult().success(ecList); - - } - } - - - @ApiOperation(value = "并发请求改接口测试redis锁") - @GetMapping("testRedisLock") - public void testRedisLock() throws InterruptedException { - //订单超卖问题 -// orderCount--; -// if (orderCount >= 0) { -// Thread.sleep(1000); -// System.out.println(MessageFormat.format("订单还剩{0}", orderCount)); -// } - - /*用redis锁*/ - BoundHashOperations hashKey = redisTemplate.boundHashOps("hashKey"); - Long decrement = hashKey.increment(redisCountKey, -1); - if (decrement >= 0) { - System.out.println(MessageFormat.format("redis订单还剩{0}", decrement)); - } - - } - -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/SeataTestController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/SeataTestController.java deleted file mode 100644 index 006e993..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/SeataTestController.java +++ /dev/null @@ -1,30 +0,0 @@ -package top.kuanghua.tyexample.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import top.kuanghua.tyexample.service.SeataTestService; - -/** - * @Title: SeataTestController - * @Description: - * @Auther: kuanghua - * @create 2022-01-10 15:05 - */ - -@Api(tags = "seata测试") -@RestController -@RequestMapping("seataTest") -public class SeataTestController { - @Autowired - private SeataTestService seataTestService; - - @ApiOperation(value = "测试seata回滚") - @GetMapping("test-seata-rollback") - public void testSeataRollback() { - seataTestService.testSeataRollback(); - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/controller/SendEmailController.java b/ty-example/src/main/java/top/kuanghua/tyexample/controller/SendEmailController.java deleted file mode 100644 index afbb0f0..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/controller/SendEmailController.java +++ /dev/null @@ -1,50 +0,0 @@ -package top.kuanghua.tyexample.controller; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; -import top.kuanghua.khcomomon.entity.ResResult; -import top.kuanghua.tyexample.service.SendEmailService; - -import javax.mail.MessagingException; -import java.io.IOException; - -/** - * @Title: SendEmailController - * @Description: - * @Auther: kuanghua - * @create 2020/8/20 22:41 - */ -@Api(tags = "发送邮件") -@RestController -@RequestMapping("email") -public class SendEmailController { - - @Autowired - private SendEmailService sendEmailService; - - @ApiOperation(value = "发送普通文本邮件") - @GetMapping("sendEmailText") - public ResResult sendEmailText(@RequestParam(name = "subject", defaultValue = "这是主题") String subject, - @RequestParam(name = "text", defaultValue = "发送的文本(这是测试文本)") String text, - @RequestParam(name = "sendTo", defaultValue = "1319404169@qq.com") String sendTo) { - sendEmailService.sendEmailText(subject, text, sendTo); - return new ResResult().success("发送邮件成功"); - } - - @ApiOperation(value = "发送文本邮件(可以带附件)", notes = "可以带附件 ") - @PostMapping("sendMimeMail") - public ResResult sendMimeMail(@RequestParam(name = "subject", defaultValue = "这是主题") String subject, - @RequestParam(name = "text", defaultValue = "发送的文本(这是测试文本)") String text, - @RequestParam(name = "sendTo", defaultValue = "1319404169@qq.com") String sendTo, - MultipartFile file) - throws IOException, MessagingException, InterruptedException { - if (file.getOriginalFilename().isEmpty()) { - return new ResResult().error("文件上传空"); - } - sendEmailService.sendMimeMail(subject, text, sendTo, file); - return new ResResult().success("发送邮件成功"); - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/entity/ErrorCollection.java b/ty-example/src/main/java/top/kuanghua/tyexample/entity/ErrorCollection.java deleted file mode 100644 index afe96e0..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/entity/ErrorCollection.java +++ /dev/null @@ -1,36 +0,0 @@ -package top.kuanghua.tyexample.entity; - -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.extension.activerecord.Model; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.util.Date; - -/** - * error_log_collection(ErrorCollection)表实体类 - * - * @author kuanghua - * @since 2021-10-08 11:37:25 - */ -@Data -@ApiModel("错误日志相关") -@TableName(value = "tb_error_collection") -public class ErrorCollection extends Model { - @ApiModelProperty(value = "id主键") - private Long id; - @ApiModelProperty(value = "错误日志") - private String errorLog; - @ApiModelProperty(value = "页面路径") - private String pageUrl; - @ApiModelProperty(value = "当前版本") - private String version; - @ApiModelProperty(value = "浏览器类型", hidden = true) - private String browserType; - @TableField(fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建时间", hidden = true) - private Date createTime; -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/listener/CanalDataEventListener.java b/ty-example/src/main/java/top/kuanghua/tyexample/listener/CanalDataEventListener.java deleted file mode 100644 index 5bef611..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/listener/CanalDataEventListener.java +++ /dev/null @@ -1,53 +0,0 @@ -package top.kuanghua.tyexample.listener; - -import com.alibaba.otter.canal.protocol.CanalEntry; -import com.xpand.starter.canal.annotation.*; - -/** - * @Title: CanalDataEventListener - * @Description: - * @Auther: kuanghua - * @create 2020/9/1 22:43 - */ -@CanalEventListener -public class CanalDataEventListener { -// @InsertListenPoint -// public void onEventInsert(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { -// for (CanalEntry.Column column : rowData.getAfterColumnsList()) { -// System.out.println("新增" + column.getName() + ":获取的数据" + column.getValue()); -// } -// } -// -// @UpdateListenPoint -// public void onEventUpdate(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { -// for (CanalEntry.Column column : rowData.getBeforeColumnsList()) { -// System.out.println("修改前" + column.getName() + ":获取的数据" + column.getValue()); -// } -// for (CanalEntry.Column column : rowData.getAfterColumnsList()) { -// System.out.println("修改后" + column.getName() + ":获取的数据" + column.getValue()); -// } -// } -// -// @DeleteListenPoint -// public void onEventDelete(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { -// for (CanalEntry.Column column : rowData.getBeforeColumnsList()) { -// System.out.println("删除前" + column.getName() + ":获取的数据" + column.getValue()); -// } -// } - - //自定义监听 - @ListenPoint( - eventType = {CanalEntry.EventType.DELETE, CanalEntry.EventType.UPDATE,CanalEntry.EventType.UPDATE}, //监听类型 - schema = {"micro-service-plus"},//Library - table = {"tb_error_collection"}, //table - destination = "example" //指定实例的地址 - ) - public void onEventCustomUpdate(CanalEntry.EventType eventType, CanalEntry.RowData rowData) { - for (CanalEntry.Column column : rowData.getBeforeColumnsList()) { - System.out.println("自定义前" + column.getName() + ":获取的数据" + column.getValue()); - } - for (CanalEntry.Column column : rowData.getAfterColumnsList()) { - System.out.println("自定义后" + column.getName() + ":获取的数据" + column.getValue()); - } - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/listener/RabbitDelayListener.java b/ty-example/src/main/java/top/kuanghua/tyexample/listener/RabbitDelayListener.java deleted file mode 100644 index de4130d..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/listener/RabbitDelayListener.java +++ /dev/null @@ -1,29 +0,0 @@ -package top.kuanghua.tyexample.listener; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.stereotype.Component; -import top.kuanghua.tyexample.config.RabbitDelayConfig; - -/** - * @Title: orderDelayQueue - * @Description: - * @Auther: kuanghua - * @create 2021/1/18 10:27 - */ -@Component -@Slf4j -public class RabbitDelayListener { - @RabbitListener(queues = {RabbitDelayConfig.ORDER_QUEUE_NAME}) - public void ORDER_QUEUE_NAME( String outTradeno) { - /* - * 微信服务器查询订单,并更新订单状态 - * */ - log.info("receive the Delay info "+outTradeno); - } - // note: not dill the msg will re to redirect ORDER_QUEUE_NAME - // @RabbitListener(queues = {RabbitDelayConfig.ORDER_DELAY_QUEUE}) - // public void ORDER_DELAY_QUEUE( String outTradeno) { - // log.info("ORDER_DELAY_QUEUE"+outTradeno); - // } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/listener/SmsListener.java b/ty-example/src/main/java/top/kuanghua/tyexample/listener/SmsListener.java deleted file mode 100644 index 317bb47..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/listener/SmsListener.java +++ /dev/null @@ -1,50 +0,0 @@ -package top.kuanghua.tyexample.listener; - - -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringUtils; -import org.springframework.amqp.rabbit.annotation.Exchange; -import org.springframework.amqp.rabbit.annotation.Queue; -import org.springframework.amqp.rabbit.annotation.QueueBinding; -import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.stereotype.Component; -import top.kuanghua.tyexample.config.SmsProperties; -import top.kuanghua.tyexample.utils.SendSmsUtils; - - -import java.util.Map; - -@Component -@EnableConfigurationProperties(SmsProperties.class) -@Slf4j -public class SmsListener { - - @Autowired - private SendSmsUtils smsUtils; - - @Autowired - private SmsProperties smsProperties; - - @RabbitListener( - bindings = @QueueBinding(value = @Queue(value = "kuanghua.sms.queue", durable = "true"), - exchange = @Exchange(value = "kuanghua.sms.exchange", ignoreDeclarationExceptions = "true",durable = "true"), - key = {"sms.verify.code"}) - ) - public void listenSms(Map msg) throws Exception { - if (msg == null || msg.size() <= 0) { - // 放弃处理 - return; - } - String phone = msg.get("phone"); - String code = msg.get("code"); - if (StringUtils.isBlank(phone) || StringUtils.isBlank(code)) { - // 放弃处理 - log.error("发送短信mq phone或code字段为空"); - return; - } - // 发送短信 - this.smsUtils.sendMsg(phone,code,smsProperties.getSignName(),smsProperties.getVerifyCodeTemplate()); - } -} \ No newline at end of file diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/mapper/ErrorCollectionMapper.java b/ty-example/src/main/java/top/kuanghua/tyexample/mapper/ErrorCollectionMapper.java deleted file mode 100644 index 49b5aba..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/mapper/ErrorCollectionMapper.java +++ /dev/null @@ -1,9 +0,0 @@ -package top.kuanghua.tyexample.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import top.kuanghua.tyexample.entity.ErrorCollection; - - -public interface ErrorCollectionMapper extends BaseMapper { - -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/RabbitDelayService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/RabbitDelayService.java deleted file mode 100644 index 084da36..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/service/RabbitDelayService.java +++ /dev/null @@ -1,33 +0,0 @@ -package top.kuanghua.tyexample.service; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import top.kuanghua.tyexample.config.RabbitDelayConfig; - -/** - * @Title: RabbitDelayService - * @Description: - * @Auther: kuanghua - * @create 2022-01-06 17:18 - */ -@Service -public class RabbitDelayService { - - @Autowired - private RabbitTemplate rabbitTemplate; - - /** - * @param time 延时的时间 - * 死信延时转发队列 - */ - public void convertAndSend(Integer time){ - rabbitTemplate.convertAndSend(RabbitDelayConfig.ORDER_DELAY_EXCHANGE, RabbitDelayConfig.ORDER_DELAY_ROUTING_KEY, "发送的数据", message -> { - // 如果配置了 params.put("x-message-ttl", 5 * 1000); 那么这一句也可以省略,具体根据业务需要是声明 Queue 的时候就指定好延迟时间还是在发送自己控制时间 - message.getMessageProperties().setExpiration(time * 1000 + ""); - return message; - }); - } -} - diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java deleted file mode 100644 index 5040928..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/service/SeataTestService.java +++ /dev/null @@ -1,26 +0,0 @@ -package top.kuanghua.tyexample.service; - -import io.seata.spring.annotation.GlobalTransactional; -import org.springframework.stereotype.Service; -import top.kuanghua.feign.integrationfront.feign.UserFeign; - -import javax.annotation.Resource; - -/** - * @Title: SeataTestService - * @Description: - * @Auther: kuanghua - * @create 2022-01-10 15:09 - */ -@Service -public class SeataTestService { - - @Resource - private UserFeign userFeign; - - @GlobalTransactional(rollbackFor = Exception.class) - public void testSeataRollback(){ - userFeign.insertUser("jzfai"); - int i=10/0; - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/SendEmailService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/SendEmailService.java deleted file mode 100644 index 2dc1f96..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/service/SendEmailService.java +++ /dev/null @@ -1,99 +0,0 @@ -package top.kuanghua.tyexample.service; - - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.mail.SimpleMailMessage; -import org.springframework.mail.javamail.JavaMailSenderImpl; -import org.springframework.mail.javamail.MimeMessageHelper; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; -import top.kuanghua.khcomomon.utils.ObjectUtilsSelf; - -import javax.annotation.Resource; -import javax.mail.MessagingException; -import javax.mail.internet.MimeMessage; -import java.io.File; -import java.io.IOException; - -/** - * @Title: SendEmailService - * @Description: - * @Auther: kuanghua - * @create 2020/8/20 22:09 - */ -@Service -public class SendEmailService { - - @Resource - private JavaMailSenderImpl javaMailSender; - - @Value("${spring.mail.username}") - private String sendForm; - - /** - * @Description: 发送文本邮件 - * @Param: subject 主题 - * @Param: text 发送的文本 - * @Param: sendForm 发送人 - * @Param: sendTo 发送给谁 - * @return: - * @Date: 2020-08-20 - */ - @Async - public void sendEmailText(String subject, String text, String sendTo) { - //封装简单的邮件内容 - SimpleMailMessage simpleMailMessage = new SimpleMailMessage(); - //邮件主题 - simpleMailMessage.setSubject(subject); - simpleMailMessage.setText(text); - //发件人和收件人 - simpleMailMessage.setFrom(sendForm); - simpleMailMessage.setTo(sendTo); - //发送 - javaMailSender.send(simpleMailMessage); - //demo - //sendEmailText("邮件主题测试setSubject","邮件主题测试setText","869653722@qq.com","1319404169@qq.com") - } - - /** - * @Description: 发送附件邮件 - * @Param: * @param null - * @return: - * @Date: 2020-08-20 - */ - @Async - public void sendMimeMail(String subject, String text, String sendTo, MultipartFile file) - throws MessagingException, IOException { - // String path = ResourceUtils.getURL("classpath:").getPath(); - // System.out.println(path + file.getOriginalFilename()); - //先将文件保存在本地 - //file.transferTo(filePath); - - File toFile = ObjectUtilsSelf.MultipartFileToFile(file); - //创建一个发送复杂消息对象 - MimeMessage mimeMessage = javaMailSender.createMimeMessage(); - //通过消息帮助对象,来设置发送的内容 - MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, "UTF-8"); - //邮件主题 - messageHelper.setSubject(subject); - //第2个参数为true表示是html - messageHelper.setText(text, true); - //上传文件 (文件名,File或IO对象) - String filename = file.getOriginalFilename(); - - messageHelper.addAttachment(filename, toFile); - //发件人和收件人 - messageHelper.setFrom(sendForm); - messageHelper.setTo(sendTo); - //发送 - javaMailSender.send(mimeMessage); - //发完后清空文件 - //filePath.delete(); - } - //@Scheduled(cron = "*/1 * * * * *") - //public void scheduled() { - //this.sendEmailText("邮件主题测试setSubject", "邮件主题测试setText", "869653722@qq.com", "1319404169@qq.com"); - //System.out.println("邮件发送了好烦啊"); - // } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/SendMsgService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/SendMsgService.java deleted file mode 100644 index 088f049..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/service/SendMsgService.java +++ /dev/null @@ -1,42 +0,0 @@ -package top.kuanghua.tyexample.service; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.amqp.core.AmqpTemplate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Service; -import top.kuanghua.khcomomon.utils.NumberUtilsSelf; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -/** - * @Title: SendMsgService - * @Description: - * @Auther: - * @create 2020/8/20 11:26 - */ -@Service -@Slf4j -public class SendMsgService { - - @Autowired - protected AmqpTemplate amqpTemplate; - - @Autowired - private StringRedisTemplate stringRedisTemplate; - - public void sendMsg(String phone) { - String code = NumberUtilsSelf.generateCode(6); - Map smsMap = new HashMap(); - smsMap.put("phone", phone); - smsMap.put("code", code); - amqpTemplate.convertAndSend("kuanghua.sms.exchange", "sms.verify.code", smsMap); - stringRedisTemplate.opsForValue().set("user:code:phone:" + phone, code, 60, TimeUnit.SECONDS); - log.info("发送短信的code" + code); - } -} - - - diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java b/ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java deleted file mode 100644 index 11ef1e9..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/service/UploadService.java +++ /dev/null @@ -1,92 +0,0 @@ -package top.kuanghua.tyexample.service; - - -import com.alibaba.fastjson.JSON; -import com.github.tobato.fastdfs.domain.fdfs.MetaData; -import com.github.tobato.fastdfs.domain.fdfs.StorePath; -import com.github.tobato.fastdfs.service.FastFileStorageClient; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; - -import javax.annotation.Resource; -import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.util.*; - -/** - * @Title: UploadService - * @Description: - * @Auther:jzfai - * @Version: 1.0 - * @create 2020/3/4 21:58 - */ -@Service -@Slf4j -public class UploadService { - - @Resource - private FastFileStorageClient storageClient; - - //private static final List CONTENT_TYPES = Arrays.asList("image/jpeg", "image/gif"); - - public String upload(MultipartFile file) throws IOException { - String originalFilename = file.getOriginalFilename(); - //检验文件类型 -// String contentType = file.getContentType(); -// if (!CONTENT_TYPES.contains(contentType)) { -// //文件类型不合法 -// log.info("文件类型不合法:{}", originalFilename); -// throw new RuntimeException("文件内容不合法"); -// } - //检验文件内容 - BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); - if (bufferedImage == null) { - log.info("文件不能为空:{}", originalFilename); - throw new RuntimeException("文件不能为空"); - } - //保存到服务器 - //file.transferTo(new File("D:\\java\\javaproject\\pinyou\\pinyou-upload\\src\\main\\resources\\static\\" + originalFilename)); - //上传到FastDfs - String ext = StringUtils.substringAfterLast(originalFilename, "."); - HashSet metaData = new HashSet<>(); - metaData.add(new MetaData("name", file.getOriginalFilename())); - metaData.add(new MetaData("createTime", JSON.toJSONString(new Date()))); - StorePath storePath = this.storageClient.uploadFile(file.getInputStream(), file.getSize(), ext, metaData); - return storePath.getFullPath(); - } - - public Map uploadGetMetaData(MultipartFile file) throws IOException { - String originalFilename = file.getOriginalFilename(); - //检验文件类型 - String contentType = file.getContentType(); -// if (!CONTENT_TYPES.contains(contentType)) { -// //文件类型不合法 -// log.info("文件类型不合法:{}", originalFilename); -// } - //检验文件内容 - BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); - if (bufferedImage == null) { - log.info("文件内容不合法:{}", originalFilename); - } - //保存到服务器 - //file.transferTo(new File("D:\\java\\javaproject\\pinyou\\pinyou-upload\\src\\main\\resources\\static\\" + originalFilename)); - //上传到FastDfs - String ext = StringUtils.substringAfterLast(originalFilename, "."); - HashSet metaData = new HashSet<>(); - metaData.add(new MetaData("name", file.getOriginalFilename())); - StorePath storePath = this.storageClient.uploadFile(file.getInputStream(), file.getSize(), ext, metaData); - //获取数据源信息 - Set metadata = this.storageClient.getMetadata(storePath.getGroup(), storePath.getPath()); - ArrayList metaDataArrayList = new ArrayList<>(metadata); - String name = metaDataArrayList.get(0).getValue(); - //拼接name和url返回 - Map hashMap = new HashMap<>(); - hashMap.put("name", name); - hashMap.put("url", storePath.getFullPath()); - hashMap.put("group", storePath.getGroup()); - return hashMap; - } -} diff --git a/ty-example/src/main/java/top/kuanghua/tyexample/utils/SendSmsUtils.java b/ty-example/src/main/java/top/kuanghua/tyexample/utils/SendSmsUtils.java deleted file mode 100644 index 876ab4f..0000000 --- a/ty-example/src/main/java/top/kuanghua/tyexample/utils/SendSmsUtils.java +++ /dev/null @@ -1,54 +0,0 @@ -package top.kuanghua.tyexample.utils; - -import com.alibaba.fastjson.JSON; -import com.aliyuncs.CommonRequest; -import com.aliyuncs.CommonResponse; -import com.aliyuncs.DefaultAcsClient; -import com.aliyuncs.IAcsClient; -import com.aliyuncs.http.MethodType; -import com.aliyuncs.profile.DefaultProfile; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import top.kuanghua.tyexample.config.SmsProperties; - -import java.util.Map; - - -@Component -@Slf4j -public class SendSmsUtils { - - @Autowired - private SmsProperties smsProperties; - - public void sendMsg(String phone, String code, String signName, String codeTemplate){ - DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", smsProperties.getAccessKeyId(), smsProperties.getAccessKeySecret()); - IAcsClient client = new DefaultAcsClient(profile); - CommonRequest request = new CommonRequest(); - request.setSysMethod(MethodType.POST); - request.setSysDomain("dysmsapi.aliyuncs.com"); - request.setSysVersion("2017-05-25"); - request.setSysAction("SendSms"); - request.putQueryParameter("RegionId", "cn-hangzhou"); - request.putQueryParameter("PhoneNumbers", phone); - request.putQueryParameter("SignName", signName); - request.putQueryParameter("TemplateCode", codeTemplate); - request.putQueryParameter("TemplateParam", "{\"code\":\""+code+"\"}"); - try { - CommonResponse response = client.getCommonResponse(request); - String data = response.getData(); - Map map = JSON.parseObject(data, Map.class); - if (map.get("Code").equals("OK")){ - log.warn("发送短信成功 "+data); - }else{ - // 记录失败日志 - log.error("发送短信失败 "+data); - } - } catch (Exception e) { - // 记录失败日志 - log.error("发送短信失败 "+e.getMessage()); - throw new RuntimeException("发送短信失败 "+e.getMessage()); - } - } -} diff --git a/ty-example/src/main/resources/bootstrap.yml b/ty-example/src/main/resources/bootstrap.yml deleted file mode 100644 index 191e96f..0000000 --- a/ty-example/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,46 +0,0 @@ -spring: - application: - name: @project.artifactId@ - profiles: - active: "" - cloud: - nacos: - config: - enabled: true - namespace: @nacosNamespace@ - group: @nacosGroup@ - username: @nacosUsername@ - password: @nacosPassword@ - server-addr: @nacosIpPort@ - prefix: @project.artifactId@ - file-extension: yml - # 用于共享的配置文件 - shared-configs: - - data-id: application-main.yml - group: @nacosGroup@ - refresh: true - # 额外的配置文件 - extension-configs: - #get mysql config - - data-id: application-db.yml - group: @nacosGroup@ - refresh: true - - data-id: application-rabbit.yml - group: @nacosGroup@ - refresh: true - #get redis config - - data-id: application-redis.yml - group: @nacosGroup@ - refresh: true - #get seata config need after db config - - data-id: application-seata.yml - group: @nacosGroup@ - refresh: true - discovery: - namespace: @nacosNamespace@ - group: @nacosGroup@ - username: @nacosUsername@ - password: @nacosPassword@ - server-addr: @nacosIpPort@ - weight: @nacosWeight@ - ip: @nacosDiscoveryIp@ \ No newline at end of file diff --git a/ty-example/src/test/java/top/kuanghua/tyexample/service/CacheAvalancheServiceTest.java b/ty-example/src/test/java/top/kuanghua/tyexample/service/CacheAvalancheServiceTest.java deleted file mode 100644 index 4f3b9c6..0000000 --- a/ty-example/src/test/java/top/kuanghua/tyexample/service/CacheAvalancheServiceTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package top.kuanghua.tyexample.service; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @Title: CacheAvalancheServiceTest - * @Description: - * @Auther: kuanghua - * @create 2022-01-09 16:35 - */ -@SpringBootTest -@RunWith(SpringRunner.class) -public class CacheAvalancheServiceTest { - - @Autowired - private RedisTemplate redisTemplate; - - @Test - public void test() throws InterruptedException { - redisTemplate.opsForValue().set("fai", "1"); - String fai = (String) redisTemplate.opsForValue().get("fai"); - System.out.println(fai); - //Thread.sleep(10000); - } - - -} \ No newline at end of file diff --git a/ty-gateway/pom.xml b/ty-gateway/pom.xml deleted file mode 100644 index 2d78d62..0000000 --- a/ty-gateway/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - micro-service-plus - top.kuanghua - 1.0-SNAPSHOT - - 4.0.0 - - ty-gateway - pom - - ty-gateway-one - - - - - top.kuanghua - ty-common - 1.0-SNAPSHOT - - - org.springframework.cloud - spring-cloud-starter-gateway - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework - spring-webmvc - - - org.apache.tomcat.embed - tomcat-embed-core - - - - - \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/pom.xml b/ty-gateway/ty-gateway-one/pom.xml deleted file mode 100644 index 4154a68..0000000 --- a/ty-gateway/ty-gateway-one/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - ty-gateway - top.kuanghua - 1.0-SNAPSHOT - - 4.0.0 - ty-gateway-one - - - ${project.artifactId} - - - - src/main/resources - - true - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.1 - - true - - - - - \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/BaseConfig.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/BaseConfig.java deleted file mode 100644 index 6effeec..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/BaseConfig.java +++ /dev/null @@ -1,23 +0,0 @@ -package top.kuanghua.gatewaytwo.config; - -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -/** - * @Title: BaseConfig - * @Description: - * @Auther: kuanghua - * @create 2020/8/23 21:52 - */ -/* - * 总结:1.@Configuration 下的@ComponentScan回将包下带有@Component扫描变成配置类, - * 而@SpringBootApplication扫描的只会变成普通类 - * */ -@Configuration -//dao包扫描 -@ComponentScan(basePackages = {"top.kuanghua.khcomomon"}) -@EnableFeignClients(basePackages = {"top.kuanghua.feign"}) -public class BaseConfig { - -} diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/JwtProperties.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/JwtProperties.java deleted file mode 100644 index 9bf7775..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/JwtProperties.java +++ /dev/null @@ -1,54 +0,0 @@ -package top.kuanghua.gatewaytwo.config; - - -import lombok.Data; -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.context.properties.ConfigurationProperties; -import top.kuanghua.gatewaytwo.utils.RsaUtils; - -import javax.annotation.PostConstruct; -import java.io.File; -import java.security.PrivateKey; -import java.security.PublicKey; - - -@Data -@Slf4j -@ConfigurationProperties(prefix = "jwt-properties") -public class JwtProperties { - private String secret; - private String pubKeyPath; - private String priKeyPath; - private PublicKey publicKey; - private PrivateKey privateKey; - private Integer expire; - private String cookieName; - private Integer cookieMaxAge; - - @PostConstruct - public void init() throws Exception { -// String classPath = ResourceUtils.getURL("classpath:").getPath(); -// String pubKeyPath=classPath+"\\rsafile\\rsa.pub"; -// String priKeyPath=classPath+"\\rsafile\\rsa.pri"; - File pubKeyFile = new File(pubKeyPath); - File priKeyFile = new File(priKeyPath); - if (!pubKeyFile.exists() || !priKeyFile.exists()) { - File fileParent = pubKeyFile.getParentFile(); - if (!fileParent.exists()) { - fileParent.mkdirs(); - } - throw new RuntimeException("秘钥文件不存在"); - // 获取公钥和私钥 - /*秘钥最好不要跟换*/ -// try { -// RsaUtils.generateKey(pubKeyPath, priKeyPath, secret); -// } catch (Exception e) { -// log.error("生成秘钥失败"); -// //e.printStackTrace(); -// }r - } - //读取公钥和私钥文件 - this.publicKey = RsaUtils.getPublicKey(pubKeyPath); - this.privateKey = RsaUtils.getPrivateKey(priKeyPath); - } -} \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SpecialHystrixGatewayFilterFactory.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SpecialHystrixGatewayFilterFactory.java deleted file mode 100644 index 440d247..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SpecialHystrixGatewayFilterFactory.java +++ /dev/null @@ -1,241 +0,0 @@ -package top.kuanghua.gatewaytwo.config; - -import com.netflix.hystrix.HystrixCommandGroupKey; -import com.netflix.hystrix.HystrixCommandKey; -import com.netflix.hystrix.HystrixCommandProperties; -import com.netflix.hystrix.HystrixObservableCommand; -import com.netflix.hystrix.exception.HystrixRuntimeException; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.cloud.gateway.filter.GatewayFilter; -import org.springframework.cloud.gateway.filter.GatewayFilterChain; -import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; -import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.reactive.DispatcherHandler; -import org.springframework.web.server.ResponseStatusException; -import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.util.UriComponentsBuilder; -import reactor.core.publisher.Mono; -import rx.Observable; -import rx.RxReactiveStreams; -import rx.Subscription; - -import java.math.BigDecimal; -import java.net.URI; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeoutException; -import java.util.function.Function; - -import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR; -import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.containsEncodedParts; - -@Component -public class SpecialHystrixGatewayFilterFactory extends AbstractGatewayFilterFactory { - - private static final String NAME = "SpecialHystrix"; - - private final ObjectProvider dispatcherHandler; - - public SpecialHystrixGatewayFilterFactory(ObjectProvider dispatcherHandler) { - super(Config.class); - this.dispatcherHandler = dispatcherHandler; - } - - @Override - public List shortcutFieldOrder() { - return Collections.singletonList(NAME_KEY); - } - - @Override - public GatewayFilter apply(Config config) { - return (exchange, chain) -> { - ServerHttpRequest request = exchange.getRequest(); - String path = request.getPath().pathWithinApplication().value(); - Map timeoutMap = config.getTimeout(); - Integer timeout = null; - if (timeoutMap != null) { - //对rest接口通配符url进行转换 暂只配置url 末尾为数字的的接口--- - path = config.wildCard(path); - timeout = timeoutMap.get(path); - } - - MyRouteHystrixCommand command; - if (timeout == null) { - //没有定义时间的接口将使用配置的default时间 - command = new MyRouteHystrixCommand(config.getFallbackUri(), exchange, chain, path); - } else { - //有配置时间的接口将使用配置的时间 - command = new MyRouteHystrixCommand(config.getFallbackUri(), exchange, chain, timeout, path); - } - - return Mono.create(s -> { - Subscription sub = command.toObservable().subscribe(s::success, s::error, s::success); - s.onCancel(sub::unsubscribe); - }).onErrorResume((Function>) throwable -> { - if (throwable instanceof HystrixRuntimeException) { - HystrixRuntimeException e = (HystrixRuntimeException) throwable; - HystrixRuntimeException.FailureType failureType = e.getFailureType(); - switch (failureType) { - case TIMEOUT: - return Mono.error(new TimeoutException("接口请求超时了")); - case COMMAND_EXCEPTION: { - Throwable cause = e.getCause(); - if (cause instanceof ResponseStatusException || AnnotatedElementUtils - .findMergedAnnotation(cause.getClass(), ResponseStatus.class) != null) { - return Mono.error(cause); - } - } - default: - break; - } - } - return Mono.error(throwable); - }).then(); - }; - } - - @Override - public String name() { - return NAME; - } - - private class MyRouteHystrixCommand extends HystrixObservableCommand { - - private final URI fallbackUri; - private final ServerWebExchange exchange; - private final GatewayFilterChain chain; - - public MyRouteHystrixCommand(URI fallbackUri, ServerWebExchange exchange, GatewayFilterChain chain, - String key) { - super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(key)) - .andCommandKey(HystrixCommandKey.Factory.asKey(key))); - this.fallbackUri = fallbackUri; - this.exchange = exchange; - this.chain = chain; - - } - - public MyRouteHystrixCommand(URI fallbackUri, ServerWebExchange exchange, GatewayFilterChain chain, - int timeout, - String key) { - //***出现通配符的情况**// - super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(key)) - .andCommandKey(HystrixCommandKey.Factory.asKey(key)) - .andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withExecutionTimeoutInMilliseconds(timeout))); - this.fallbackUri = fallbackUri; - this.exchange = exchange; - this.chain = chain; - - } - - @Override - protected Observable construct() { - return RxReactiveStreams.toObservable(this.chain.filter(exchange)); - } - - @Override - protected Observable resumeWithFallback() { - if (null == fallbackUri) { - return super.resumeWithFallback(); - } - URI uri = exchange.getRequest().getURI(); - boolean encoded = containsEncodedParts(uri); - URI requestUrl = UriComponentsBuilder.fromUri(uri) - .host(null) - .port(null) - .uri(this.fallbackUri) - .build(encoded) - .toUri(); - exchange.getAttributes().put(GATEWAY_REQUEST_URL_ATTR, requestUrl); - - ServerHttpRequest request = this.exchange.getRequest().mutate().uri(requestUrl).build(); - ServerWebExchange mutated = exchange.mutate().request(request).build(); - DispatcherHandler dispatcherHandler = SpecialHystrixGatewayFilterFactory.this.dispatcherHandler.getIfAvailable(); - return RxReactiveStreams.toObservable(dispatcherHandler.handle(mutated)); - } - } - - public static class Config { - - private String id; - private URI fallbackUri; - /** - * url -> timeout ms - */ - private Map timeout; - - public String getId() { - return id; - } - - public Config setId(String id) { - this.id = id; - return this; - } - - public URI getFallbackUri() { - return fallbackUri; - } - - public Config setFallbackUri(URI fallbackUri) { - if (fallbackUri != null && !"forward".equals(fallbackUri.getScheme())) { - throw new IllegalArgumentException("Hystrix Filter currently only supports 'forward' URIs, found " + fallbackUri); - } - this.fallbackUri = fallbackUri; - return this; - } - - public Map getTimeout() { - return timeout; - } - - public Config setTimeout(Map timeout) { - //YAML解析的时候MAP的KEY不支持'/',这里只能用'-'替代 - Map tempTimeout = new HashMap<>(timeout.size()); - for (String key : timeout.keySet()) { - Integer value = timeout.get(key); - - key = key.replace("-", "/"); - if (!key.startsWith("/")) { - key = "/" + key; - } - /** 末尾有动态传参 **/ - if (key.endsWith("/")) { - key = key + "**"; - } - tempTimeout.put(key, value); - } - this.timeout = tempTimeout; - return this; - } - - - public String wildCard(String path) { - String replace = path; - String[] split = path.split("/"); - if (split.length > 0) { - String wildcard = split[split.length - 1]; - boolean numeric = isNumeric(wildcard); - if (numeric) { - replace = path.replace(wildcard, "**"); - } - } - return replace; - } - - private boolean isNumeric(String str) { - String bigStr; - try { - bigStr = new BigDecimal(str).toString(); - } catch (Exception e) { - return false;//异常 说明包含非数字。 - } - return true; - } - } -} \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerDocConfig.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerDocConfig.java deleted file mode 100644 index 6a125b4..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerDocConfig.java +++ /dev/null @@ -1,21 +0,0 @@ -package top.kuanghua.gatewaytwo.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; -import org.springframework.stereotype.Component; - -import java.util.*; -/** - * @Title: SwaggerDocConfig - * @Description: - * @Auther: kuanghua - * @create 2021/9/14 13:36 - */ - -@Component -@ConfigurationProperties(prefix = "swagger-doc") -@Data -public class SwaggerDocConfig { - private Map serviceMap; -} diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHandler.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHandler.java deleted file mode 100644 index 8a630ff..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -package top.kuanghua.gatewaytwo.config; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import reactor.core.publisher.Mono; -import springfox.documentation.swagger.web.*; - -import java.util.Optional; - -/** - * @introduce: Swagger处理器 - * @author: kuanghua - * @date: 2020/6/4 - **/ -@RestController -@RequestMapping("/swagger-resources") -public class SwaggerHandler { - @Autowired(required = false) - private SecurityConfiguration securityConfiguration; - @Autowired(required = false) - private UiConfiguration uiConfiguration; - private final SwaggerResourcesProvider swaggerResources; - - @Autowired - public SwaggerHandler(SwaggerResourcesProvider swaggerResources) { - this.swaggerResources = swaggerResources; - } - - @GetMapping("/configuration/security") - public Mono> securityConfiguration() { - return Mono.just(new ResponseEntity<>( - Optional.ofNullable(securityConfiguration).orElse(SecurityConfigurationBuilder.builder().build()), HttpStatus.OK)); - } - - @GetMapping("/configuration/ui") - public Mono> uiConfiguration() { - return Mono.just(new ResponseEntity<>( - Optional.ofNullable(uiConfiguration).orElse(UiConfigurationBuilder.builder().build()), HttpStatus.OK)); - } - - @GetMapping("") - public Mono swaggerResources() { - return Mono.just((new ResponseEntity<>(swaggerResources.get(), HttpStatus.OK))); - } -} diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHeaderFilter.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHeaderFilter.java deleted file mode 100644 index a9df815..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerHeaderFilter.java +++ /dev/null @@ -1,34 +0,0 @@ -package top.kuanghua.gatewaytwo.config; - -import org.springframework.cloud.gateway.filter.GatewayFilter; -import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; -import org.springframework.web.server.ServerWebExchange; - -/** - * @introduce: swagger请求头过滤器 - * @author: kuanghua - * @date: 2020/6/4 - **/ -@Component -public class SwaggerHeaderFilter extends AbstractGatewayFilterFactory { - - private static final String HEADER_NAME = "X-Forwarded-Prefix"; - - @Override - public GatewayFilter apply(Object config) { - return (exchange, chain) -> { - ServerHttpRequest request = exchange.getRequest(); - String path = request.getURI().getPath(); - if (!StringUtils.endsWithIgnoreCase(path, SwaggerProvider.API_URI)) { - return chain.filter(exchange); - } - String basePath = path.substring(0, path.lastIndexOf(SwaggerProvider.API_URI)); - ServerHttpRequest newRequest = request.mutate().header(HEADER_NAME, basePath).build(); - ServerWebExchange newExchange = exchange.mutate().request(newRequest).build(); - return chain.filter(newExchange); - }; - } -} diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerProvider.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerProvider.java deleted file mode 100644 index 00de5e7..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/config/SwaggerProvider.java +++ /dev/null @@ -1,62 +0,0 @@ -package top.kuanghua.gatewaytwo.config; - -import lombok.AllArgsConstructor; -import org.springframework.context.annotation.Primary; -import org.springframework.stereotype.Component; -import springfox.documentation.swagger.web.SwaggerResource; -import springfox.documentation.swagger.web.SwaggerResourcesProvider; - -import java.util.ArrayList; -import java.util.List; - -/** - * @introduce: gateway集成各微服务swagger - * @author: kuanghua - * @date: 2020/6/4 - **/ -@Component -@Primary -@AllArgsConstructor -public class SwaggerProvider implements SwaggerResourcesProvider { - - static final String API_URI = "/v2/api-docs"; -// private final RouteLocator routeLocator; -// private final GatewayProperties gatewayProperties; - - - private SwaggerDocConfig swaggerDocConfig; - - /** - * @return - */ - @Override - public List get() { - List resources = new ArrayList<>(); - //List routes = new ArrayList<>(); - swaggerDocConfig.getServiceMap().entrySet().stream().forEach(mapEntry -> { - /*设置swagger服务路径*/ - resources.add(createResource(mapEntry.getValue().toString(), mapEntry.getKey(), "2.9")); - }); - -// routeLocator.getRoutes().subscribe(route -> { -// System.out.println("routeLocator"); -// System.out.println(route); -// route.getId(); -// }); -// gatewayProperties.getRoutes().stream().forEach(item -> { -// System.out.println("gatewayProperties"); -// item.getId(); -// System.out.println(item); -// }); - - return resources; - } - - private SwaggerResource createResource(String name, String location, String version) { - SwaggerResource swaggerResource = new SwaggerResource(); - swaggerResource.setName(name); - swaggerResource.setLocation("/api/" + location + "/v2/api-docs"); - swaggerResource.setSwaggerVersion(version); - return swaggerResource; - } -} diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/ChangeObjectUtils.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/ChangeObjectUtils.java deleted file mode 100644 index 05e3d69..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/ChangeObjectUtils.java +++ /dev/null @@ -1,38 +0,0 @@ -package top.kuanghua.gatewaytwo.utils; - -import org.apache.commons.lang3.StringUtils; - -/** - * 从jwt解析得到的数据是Object类型,转换为具体类型可能出现空指针, - * 这个工具类进行了一些转换 - */ -public class ChangeObjectUtils { - - public static String toString(Object obj) { - if (obj == null) { - return null; - } - return obj.toString(); - } - - public static Long toLong(Object obj) { - if (obj == null) { - return 0L; - } - if (obj instanceof Double || obj instanceof Float) { - return Long.valueOf(StringUtils.substringBefore(obj.toString(), ".")); - } - if (obj instanceof Number) { - return Long.valueOf(obj.toString()); - } - if (obj instanceof String) { - return Long.valueOf(obj.toString()); - } else { - return 0L; - } - } - - public static Integer toInt(Object obj) { - return toLong(obj).intValue(); - } -} \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/JwtUtilsKh.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/JwtUtilsKh.java deleted file mode 100644 index e7e51c3..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/JwtUtilsKh.java +++ /dev/null @@ -1,42 +0,0 @@ -package top.kuanghua.gatewaytwo.utils; - -import io.jsonwebtoken.*; -import org.joda.time.DateTime; - -import java.security.PrivateKey; -import java.security.PublicKey; -import java.util.Map; - -/** - * @Title: JwtUtilsKh - * @Description: - * @Auther: kuanghua - * @create 2020/9/11 12:08 - */ - -public class JwtUtilsKh { - public static String generateToken(Map hashMap, PrivateKey privateKey, int expireMinutes) throws Exception { - JwtBuilder jwtBuilder = Jwts.builder() - .setExpiration(DateTime.now().plusMinutes(expireMinutes).toDate()) - .signWith(SignatureAlgorithm.RS256, privateKey); - jwtBuilder.addClaims(hashMap); - //将jwt返回 - return jwtBuilder.compact(); - } - public static String updateToken(Map hashMap, PrivateKey privateKey, int expireMinutes) throws Exception { - hashMap.remove("exp"); - JwtBuilder jwtBuilder = Jwts.builder() - .setExpiration(DateTime.now().plusMinutes(expireMinutes).toDate()) - .signWith(SignatureAlgorithm.RS256, privateKey); - jwtBuilder.addClaims(hashMap); - //将jwt返回 - return jwtBuilder.compact(); - } - public static Jws parserToken(String token, PublicKey publicKey){ - return Jwts.parser().setSigningKey(publicKey).parseClaimsJws(token); - } - /*获取jwt的载荷*/ - public static Claims parserTokenGetBody(String token, PublicKey publicKey){ - return Jwts.parser().setSigningKey(publicKey).parseClaimsJws(token).getBody(); - } -} diff --git a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/RsaUtils.java b/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/RsaUtils.java deleted file mode 100644 index 42005d9..0000000 --- a/ty-gateway/ty-gateway-one/src/main/java/top/kuanghua/gatewaytwo/utils/RsaUtils.java +++ /dev/null @@ -1,92 +0,0 @@ -package top.kuanghua.gatewaytwo.utils; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.security.*; -import java.security.spec.PKCS8EncodedKeySpec; -import java.security.spec.X509EncodedKeySpec; - -public class RsaUtils { - /** - * 从文件中读取公钥 - * - * @param filename 公钥保存路径,相对于classpath - * @return 公钥对象 - * @throws Exception - */ - public static PublicKey getPublicKey(String filename) throws Exception { - byte[] bytes = readFile(filename); - return getPublicKey(bytes); - } - - /** - * 从文件中读取密钥 - * - * @param filename 私钥保存路径,相对于classpath - * @return 私钥对象 - * @throws Exception - */ - public static PrivateKey getPrivateKey(String filename) throws Exception { - byte[] bytes = readFile(filename); - return getPrivateKey(bytes); - } - /** - * 获取公钥 - * - * @param bytes 公钥的字节形式 - * @return - * @throws Exception - */ - public static PublicKey getPublicKey(byte[] bytes) throws Exception { - X509EncodedKeySpec spec = new X509EncodedKeySpec(bytes); - KeyFactory factory = KeyFactory.getInstance("RSA"); - return factory.generatePublic(spec); - } - /** - * 获取密钥 - * - * @param bytes 私钥的字节形式 - * @return - * @throws Exception - */ - public static PrivateKey getPrivateKey(byte[] bytes) throws Exception { - PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(bytes); - KeyFactory factory = KeyFactory.getInstance("RSA"); - return factory.generatePrivate(spec); - } - - /** - * 根据密文,生存rsa公钥和私钥,并写入指定文件 - * - * @param publicKeyFilename 公钥文件路径 - * @param privateKeyFilename 私钥文件路径 - * @param secret 生成密钥的密文 - * @throws IOException - * @throws NoSuchAlgorithmException - */ - public static void generateKey(String publicKeyFilename, String privateKeyFilename, String secret) throws Exception { - KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); - SecureRandom secureRandom = new SecureRandom(secret.getBytes()); - keyPairGenerator.initialize(1024, secureRandom); - KeyPair keyPair = keyPairGenerator.genKeyPair(); - // 获取公钥并写出 - byte[] publicKeyBytes = keyPair.getPublic().getEncoded(); - writeFile(publicKeyFilename, publicKeyBytes); - // 获取私钥并写出 - byte[] privateKeyBytes = keyPair.getPrivate().getEncoded(); - writeFile(privateKeyFilename, privateKeyBytes); - } - - private static byte[] readFile(String fileName) throws Exception { - return Files.readAllBytes(new File(fileName).toPath()); - } - - private static void writeFile(String destPath, byte[] bytes) throws IOException { - File dest = new File(destPath); - if (!dest.exists()) { - dest.createNewFile(); - } - Files.write(dest.toPath(), bytes); - } -} \ No newline at end of file diff --git a/ty-gateway/ty-gateway-one/src/main/resources/application.yml b/ty-gateway/ty-gateway-one/src/main/resources/application.yml deleted file mode 100644 index e69de29..0000000 diff --git a/ty-gateway/ty-gateway-one/src/main/resources/bootstrap.yml b/ty-gateway/ty-gateway-one/src/main/resources/bootstrap.yml deleted file mode 100644 index e6c3e43..0000000 --- a/ty-gateway/ty-gateway-one/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,38 +0,0 @@ -spring: - application: - name: @project.artifactId@ - profiles: - active: @activatedProperties@ - cloud: - nacos: - config: - enabled: true - namespace: @nacosNamespace@ - group: @nacosGroup@ - username: @nacosUsername@ - password: @nacosPassword@ - server-addr: @nacosIpPort@ - prefix: @project.artifactId@ - file-extension: yml - # 用于共享的配置文件 - shared-configs: - - data-id: application-main.yml - group: @nacosGroup@ - refresh: true - extension-configs: - - data-id: application-rabbit.yml - group: @nacosGroup@ - refresh: true - - data-id: application-redis.yml - group: @nacosGroup@ - refresh: true - discovery: - namespace: @nacosNamespace@ - group: @nacosGroup@ - username: @nacosUsername@ - password: @nacosPassword@ - server-addr: @nacosIpPort@ - weight: @nacosWeight@ - ip: @nacosDiscoveryIp@ - - diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/controllerMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multb/controllerMul.vm new file mode 100644 index 0000000..70e3008 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multb/controllerMul.vm @@ -0,0 +1,75 @@ +package ${projectOrAuthor.packageName}.controller; +import java.util.Map; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +/** +* ${dbTableConfig.multiTableDesc}Controller +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Api(tags = "维修信息") +@RestController +@RequestMapping("${dbTableConfig.multiTableName}") +public class ${dbTableConfig.multiTableNameCase}Controller { +@Resource +private ${dbTableConfig.multiTableNameCase}Service ${dbTableConfig.multiTableName}Service; + +@ApiOperation(value = "分页查询${dbTableConfig.multiTableDesc}") +@GetMapping("select${dbTableConfig.multiTableNameCase}") +public Page< Map > select${dbTableConfig.multiTableNameCase}(SelfCommonParams commonParams, ${dbTableConfig.multiTableNameCase}Vo ${dbTableConfig.multiTableName}Vo) { +Map ${dbTableConfig.multiTableName}Map = JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}Vo), Map.class); +return ${dbTableConfig.multiTableName}Service.select${dbTableConfig.multiTableNameCase}(commonParams, ${dbTableConfig.multiTableName}Map); +} + +/** +* 新增数据 +* +* @param ${dbTableConfig.multiTableName} 实体对象 +* @return 新增结果 +*/ +@ApiOperation(value = "新增${dbTableConfig.multiTableDesc}") +@PostMapping("insert") +public ResResult insert(@RequestBody ${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +this.${dbTableConfig.multiTableName}Service.insert(${dbTableConfig.multiTableName}); +return new ResResult().success(); +} + + +/** +* 通过主键查询单条数据 +* +* @param ${dbTableConfig.associationKey} 主键 +* @return 单条数据 +*/ +@GetMapping("selectByKey") +@ApiOperation(value = "通过联合key查询详情") +public ResResult selectByKey(@RequestParam("${dbTableConfig.associationKey}") ${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { +return new ResResult().success(${dbTableConfig.multiTableName}Service.selectByKey(${dbTableConfig.associationKey})); +} + +/** +* 修改数据 +* +* @param ${dbTableConfig.multiTableName} 实体对象 +* @return 修改结果 +*/ +@ApiOperation(value = "根据${dbTableConfig.associationKey}修改数据") +@PutMapping("updateByKey") +public ResResult updateByKey(@RequestBody ${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +this.${dbTableConfig.multiTableName}Service.updateByKey(${dbTableConfig.multiTableName}); +return new ResResult().success(); +} + + +/** +* 删除项根据主键key +* @param ${dbTableConfig.associationKey} +* @return +*/ +@ApiOperation(value = "根据联合key删除数据") +@DeleteMapping("deleteByKey") +public ResResult deleteByKey(@RequestParam("${dbTableConfig.associationKey}") ${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { +this.${dbTableConfig.multiTableName}Service.deleteByKey(${dbTableConfig.associationKey}); +return new ResResult().success(); +} +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/entity.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multb/entity.vm new file mode 100644 index 0000000..197fdbe --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multb/entity.vm @@ -0,0 +1,37 @@ +package ${projectOrAuthor.packageName}.entity; +import java.util.*; +/** +* ${currentTbConfig.tableDesc}实体类 +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Data +@ApiModel("${currentTbConfig.tableDesc}") +@TableName(value = "${currentTbConfig.originTableName}") +public class ${currentTbConfig.tableNameCase} extends Model< ${currentTbConfig.tableNameCase} > { +#foreach($item in $dbTableConfig.tableFieldArr) + #if($item.field=="createTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.INSERT) + private ${item.type} $item.field; + #elseif($item.field=="updateTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private ${item.type} $item.field; + #else + @ApiModelProperty(value = "$item.desc") + private ${item.type} $item.field; + #end +#end + +/** +* 获取主键值 +* +* @return 主键值 +*/ +@Override +protected Serializable pkVal() { +return this.${currentTbConfig.uniKey}; +} +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/entityMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multb/entityMul.vm new file mode 100644 index 0000000..ab3938e --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multb/entityMul.vm @@ -0,0 +1,29 @@ +package ${projectOrAuthor.packageName}.entity; +import java.util.*; +/** +* ${dbTableConfig.tableDesc}实体类 +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Data +@ApiModel("${dbTableConfig.tableDesc}") +@TableName(value = "${dbTableConfig.originTableName}") +public class ${dbTableConfig.multiTableNameCase}{ +#foreach($mtcItem in $multiTableConfig) + #foreach($item in $mtcItem.tableFieldArr) + #if($item.field=="createTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.INSERT) + private ${item.type} $item.field; + #elseif($item.field=="updateTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private ${item.type} $item.field; + #else + @ApiModelProperty(value = "$item.desc") + private ${item.type} $item.field; + #end + #end +#end +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/entityVo.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multb/entityVo.vm new file mode 100644 index 0000000..b1e98e1 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multb/entityVo.vm @@ -0,0 +1,19 @@ +package ${projectOrAuthor.packageName}.entity; +import java.util.*; +/** +* ${dbTableConfig.multiTableDesc}实体类 +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Data +@ApiModel("${dbTableConfig.multiTableDesc}") +public class ${dbTableConfig.multiTableNameCase}Vo { +#foreach($mtcItem in $multiTableConfig) + #foreach( $tfItem in $mtcItem.tableFormArr) + @ApiModelProperty(value = "$tfItem.desc") + private ${tfItem.type} $tfItem.field; + #end +#end + +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/mapper.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multb/mapper.vm new file mode 100644 index 0000000..b7b7f94 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multb/mapper.vm @@ -0,0 +1,10 @@ +package ${projectOrAuthor.packageName}.mapper; +/** +* ${currentTbConfig.tableDesc}Mapper +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +public interface ${currentTbConfig.tableNameCase}Mapper extends BaseMapper< ${currentTbConfig.tableNameCase} > { + +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/mapperMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multb/mapperMul.vm new file mode 100644 index 0000000..689cc2b --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multb/mapperMul.vm @@ -0,0 +1,16 @@ +#set($firstTbConfig=$multiTableConfig[0]) +package ${projectOrAuthor.packageName}.mapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import java.util.*; +/** +* ${dbTableConfig.multiTableDesc}Mapper +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +public interface ${dbTableConfig.multiTableNameCase}Mapper { +Page< Map > select${dbTableConfig.multiTableNameCase}(Page< Map > pagination,@Param("params") Map params); + +Map selectByKey(@Param("${firstTbConfig.associationKey}") String ${firstTbConfig.associationKey}); +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/serviceMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multb/serviceMul.vm new file mode 100644 index 0000000..71ccf12 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multb/serviceMul.vm @@ -0,0 +1,57 @@ +package ${projectOrAuthor.packageName}.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.util.*; +import com.alibaba.fastjson.JSON; +/** +* ${dbTableConfig.multiTableDesc}Service +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Service +public class ${dbTableConfig.multiTableNameCase}Service { + +@Resource +private ${dbTableConfig.multiTableNameCase}Mapper ${dbTableConfig.multiTableName}Mapper; + +#foreach( $mtcItem in $multiTableConfig) +@Resource +private ${mtcItem.tableNameCase}Mapper ${mtcItem.tableName}Mapper; +#end + +public Page< Map > select${dbTableConfig.multiTableNameCase}(SelfCommonParams commonParams, Map repairVo) { + return ${dbTableConfig.multiTableName}Mapper.select${dbTableConfig.multiTableNameCase}(new Page< Map >(commonParams.getPageNum(), commonParams.getPageSize()), repairVo); +} + +public Map selectByKey(String ${dbTableConfig.multiTableName}) { + return ${dbTableConfig.multiTableName}Mapper.selectByKey(${dbTableConfig.multiTableName}); +} + +@Transactional +public void insert(${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { + #foreach( $mtcItem in $multiTableConfig) + this.${mtcItem.tableName}Mapper.insert(JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}), ${mtcItem.tableNameCase}.class)); + #end +} + +@Transactional +public void updateByKey(${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +#foreach( $mtcItem in $multiTableConfig) + //${mtcItem.tableDesc} + ${mtcItem.tableNameCase} ${mtcItem.tableName} = JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}), ${mtcItem.tableNameCase}.class); + QueryWrapper<${mtcItem.tableNameCase}> ${mtcItem.tableName}Wrapper = new QueryWrapper<>(); + ${mtcItem.tableName}Wrapper.eq("sn", ${dbTableConfig.multiTableName}.getSn()); + this.${mtcItem.tableName}Mapper.update(${mtcItem.tableName}, ${mtcItem.tableName}Wrapper); +#end +} + +@Transactional +public void deleteByKey(${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { + #foreach( $mtcItem in $multiTableConfig) + //${mtcItem.tableName} + QueryWrapper<${mtcItem.tableNameCase}> ${mtcItem.tableName}Wrapper = new QueryWrapper<>(); + ${mtcItem.tableName}Wrapper.eq("${dbTableConfig.orgAssociationKey}", ${dbTableConfig.associationKey}); + this.${mtcItem.tableName}Mapper.delete(${mtcItem.tableName}Wrapper); + #end + } +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/utils.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multb/utils.vm new file mode 100644 index 0000000..758add7 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multb/utils.vm @@ -0,0 +1,8 @@ +#macro(getOriginField) + #foreach($fItem in $multiTableConfig) + #foreach($tableShowArrItem in ${fItem.tableShowArr})${fItem.tableName}.${tableShowArrItem.originField},#end + #end +#end +#set($originFieldString="#getOriginField()") +#set($lenth=$originFieldString.length() - 1) +#set($xmlSelectString=$originFieldString.substring(0,$lenth)) diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/xmlMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multb/xmlMul.vm new file mode 100644 index 0000000..c9c3353 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multb/xmlMul.vm @@ -0,0 +1,60 @@ +#parse("utils.vm") +#set($firstTbConfig=$multiTableConfig[0]) + + + + + #foreach($fItem in $multiTableConfig) + #foreach($tableShowArrItem in ${fItem.tableShowArr}) + + #end + #end + + + ${xmlSelectString} + + + + + \ No newline at end of file diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/controller.vm b/velocity-tmp-dir/back-vms/mybatis-plus/controller.vm new file mode 100644 index 0000000..5c4cbef --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus/controller.vm @@ -0,0 +1,112 @@ +#parse("utils.vm") +package ${projectOrAuthor.packageName}.controller; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +/** +* ${dbTableConfig.tableDesc}Controller +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Api(tags = "${dbTableConfig.tableDesc}(${dbTableConfig.tableNameCase})") +@RestController +@RequestMapping("${dbTableConfig.tableName}") +public class ${dbTableConfig.tableNameCase}Controller { + +@Resource +private ${dbTableConfig.tableNameCase}Service ${dbTableConfig.tableName}Service; + +/** +* 分页查询所有数据 +* +* @param ${dbTableConfig.tableName} 查询实体 +* @return ResResult +*/ +@GetMapping("selectPage") +@ApiOperation(value = "分页查询所有数据") +public ResResult selectPage(${dbTableConfig.tableNameCase} $dbTableConfig.tableName, SelfCommonParams commonParams) { +QueryWrapper <${dbTableConfig.tableNameCase}> queryWrapper = new QueryWrapper<>(); +#foreach($item in $queryConfig) + #if(${item.originField}=="create_time") + //${item.desc} + queryWrapper.orderByDesc("$item.originField"); + if (ObjSelfUtils.isNotEmpty(commonParams.getStartTime())) { + queryWrapper.between("create_time", commonParams.getStartTime(), commonParams.getEndTime()); + } + #else + //${item.desc} + if (ObjSelfUtils.isNotEmpty(${dbTableConfig.tableName}.get${item.fieldCase}())) { + queryWrapper.like("${item.originField}", ${dbTableConfig.tableName}.get${item.fieldCase}()); + } + #end +#end + +queryWrapper.select("$selectString"); + +Page <${dbTableConfig.tableNameCase}> ${dbTableConfig.tableName}Page = this.${dbTableConfig.tableName}Service.selectPage(commonParams.getPageNum(), commonParams.getPageSize(),queryWrapper); +return new ResResult().success(${dbTableConfig.tableName}Page); +} + +/** +* 通过主键查询单条数据 +* +* @param id 主键 +* @return 单条数据 +*/ +@GetMapping("selectById") +@ApiOperation(value = "通过id主键查询单条数据") +public ResResult selectById(@RequestParam("id") ${dbTableConfig.uniKeyType} id) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.selectById(id)); +} + +/** +* @Description: 根据id数组查询品牌列表 +* @Param: idList id数组 +* @return: ids列表数据 +*/ +@ApiOperation(value = "根据id数组查询品牌列表") +@PostMapping("selectBatchIds") +public ResResult selectBatchIds(@RequestParam("idList") List< ${dbTableConfig.uniKeyType} > idList) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.selectBatchIds(idList)); +} + +/** +* 新增数据 +* +* @param ${dbTableConfig.tableName} 实体对象 +* @return 新增结果 +*/ +@ApiOperation(value = "新增数据") +@PostMapping("insert") +public ResResult insert(@RequestBody ${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.insert(${dbTableConfig.tableName})); +} + +/** +* 修改数据 +* +* @param ${dbTableConfig.tableName} 实体对象 +* @return 修改结果 +*/ +@ApiOperation(value = "根据id修改数据") +@PutMapping("updateById") +public ResResult updateById(@RequestBody ${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.updateById(${dbTableConfig.tableName})); +} + +/** +* 删除数据 +* +* @param idList 主键结合 +* @return 删除结果 +*/ +@ApiOperation(value = "根据id数组删除数据") +@DeleteMapping("deleteBatchIds") +public ResResult deleteBatchIds(@RequestBody List< ${dbTableConfig.uniKeyType} > idList) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.deleteBatchIds(idList)); +} + +@DeleteMapping("deleteById") +public ResResult deleteById(@RequestParam("id") ${dbTableConfig.uniKeyType} id) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.deleteById(id)); +} +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/entity.vm b/velocity-tmp-dir/back-vms/mybatis-plus/entity.vm new file mode 100644 index 0000000..d1a16b5 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus/entity.vm @@ -0,0 +1,37 @@ +package ${projectOrAuthor.packageName}.entity; +import java.util.Date; +/** +* ${dbTableConfig.tableDesc}实体类 +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Data +@ApiModel("${dbTableConfig.tableDesc}") +@TableName(value = "${dbTableConfig.originTableName}") +public class ${dbTableConfig.tableNameCase} extends Model< ${dbTableConfig.tableNameCase} > { +#foreach($item in $dbTableConfig.tableFieldArr) + #if($item.field=="createTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.INSERT) + private ${item.type} $item.field; + #elseif($item.field=="updateTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private ${item.type} $item.field; + #else + @ApiModelProperty(value = "$item.desc") + private ${item.type} $item.field; + #end +#end + +/** +* 获取主键值 +* +* @return 主键值 +*/ +@Override +protected Serializable pkVal() { +return this.${dbTableConfig.uniKey}; +} +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/mapper.vm b/velocity-tmp-dir/back-vms/mybatis-plus/mapper.vm new file mode 100644 index 0000000..12cb2ad --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus/mapper.vm @@ -0,0 +1,10 @@ +package ${projectOrAuthor.packageName}.mapper; +/** +* ${dbTableConfig.tableDesc}Mapper +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +public interface ${dbTableConfig.tableNameCase}Mapper extends BaseMapper< ${dbTableConfig.tableNameCase} > { + +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/service.vm b/velocity-tmp-dir/back-vms/mybatis-plus/service.vm new file mode 100644 index 0000000..1ecde1e --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus/service.vm @@ -0,0 +1,42 @@ +package ${projectOrAuthor.packageName}.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +/** +* ${dbTableConfig.tableDesc}Service +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Service +public class ${dbTableConfig.tableNameCase}Service { + +@Resource +private ${dbTableConfig.tableNameCase}Mapper ${dbTableConfig.tableName}Mapper; + +public Page< ${dbTableConfig.tableNameCase} > selectPage(${dbTableConfig.uniKeyType} pageNum, ${dbTableConfig.uniKeyType} pageSize, QueryWrapper< ${dbTableConfig.tableNameCase} > queryWrapper) { +return this.${dbTableConfig.tableName}Mapper.selectPage(new Page< ${dbTableConfig.tableNameCase} >(pageNum, pageSize), queryWrapper); +} + +public ${dbTableConfig.tableNameCase} selectById(${dbTableConfig.uniKeyType} id) { +return this.${dbTableConfig.tableName}Mapper.selectById(id); +} + +public List< ${dbTableConfig.tableNameCase} > selectBatchIds(List< ${dbTableConfig.uniKeyType} > idList) { +return this.${dbTableConfig.tableName}Mapper.selectBatchIds(idList); +} + +public int insert(${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { +return this.${dbTableConfig.tableName}Mapper.insert(${dbTableConfig.tableName}); +} + +public int updateById(${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { +return this.${dbTableConfig.tableName}Mapper.updateById(${dbTableConfig.tableName}); +} + +public int deleteById(${dbTableConfig.uniKeyType} id) { +return this.${dbTableConfig.tableName}Mapper.deleteById(id); +} + +public int deleteBatchIds(List< ${dbTableConfig.uniKeyType} > idList) { +return this.${dbTableConfig.tableName}Mapper.deleteBatchIds(idList); +} +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm b/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm new file mode 100644 index 0000000..11faccf --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm @@ -0,0 +1,6 @@ +#macro(getOriginField) + #foreach($item in $formConfig)$item.originField,#end +#end +#set($originFieldString="#getOriginField()") +#set($lenth=$originFieldString.length() - 1) +#set($selectString=$originFieldString.substring(0,$lenth)) \ No newline at end of file diff --git a/ty-example/src/main/resources/application.yml b/velocity-tmp-dir/back-vms/mybatis-plus/xml.vm similarity index 100% rename from ty-example/src/main/resources/application.yml rename to velocity-tmp-dir/back-vms/mybatis-plus/xml.vm diff --git a/velocity-tmp-dir/front-vms/element-plus/CRUD.vm b/velocity-tmp-dir/front-vms/element-plus/CRUD.vm new file mode 100644 index 0000000..99e3d0d --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/CRUD.vm @@ -0,0 +1,96 @@ +#parse("queryUtils.vm") +#parse("tableUtils.vm") +#parse("utils.vm") + + + + \ No newline at end of file diff --git a/velocity-tmp-dir/front-vms/element-plus/CRUDForm.vm b/velocity-tmp-dir/front-vms/element-plus/CRUDForm.vm new file mode 100644 index 0000000..0d72de3 --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/CRUDForm.vm @@ -0,0 +1,87 @@ +#parse("formUtils.vm") + + + + + \ No newline at end of file diff --git a/velocity-tmp-dir/front-vms/element-plus/formUtils.vm b/velocity-tmp-dir/front-vms/element-plus/formUtils.vm new file mode 100644 index 0000000..0bc16a2 --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/formUtils.vm @@ -0,0 +1,268 @@ +##生成form item +#parse("utils.vm") +#macro(formTemp) +#foreach($item in $formConfig) + #if($item.componentType=="input") ##input + + + + #elseif($item.componentType=="textarea") ##textarea + + + + #elseif($item.componentType=="select") ##select + + + #foreach($enum in $item.optionDataArr) + + #end + + + #elseif($item.componentType=="selectApi") ##selectApi + + + + + + #elseif($item.componentType=="radio") ##radio + + + #foreach($enum in $item.optionDataArr) + ${enum.label} + #end + + + #elseif($item.componentType=="checkbox") ##checkbox + + + #foreach($enum in $item.optionDataArr) + + #end + + + #elseif($item.componentType=="switch") ##switch + + + + #elseif($item.componentType=="cascaderApi") ##cascader + + + + #elseif($item.componentType=="datetimerange") ##datetimerange + + + + #elseif($item.componentType=="datetime") ##datetime + + + + #elseif($item.componentType=="date") ##date + + + + #elseif($item.componentType=="uploadImage") ##uploadImage + +
+ +
+ + + 上传 + + +
{{ chooseFileName }}
+
+
+
+ #end +#end +#end +##rule校验 +#macro(rulesData) +#foreach($item in $formConfig) +#if($item.rule=="notNull")##必填 + $item.field:{required: true, message:"${item.desc}不能为空",trigger:["blur", "change"]}, + #elseif ($item.rule=="number")##只允许输入数字 + $item.field:[{required: true, message: "请输入${item.desc}", trigger: "blur"},{pattern: + /^[1-9]\d*$/,message: "${item.desc}为正整数",trigger: "blur",}], + #elseif ($item.rule=="positiveNumber")##只允许输入正数(允许带两位小数) + $item.field:[{required: true, message: "请输入${item.desc}", trigger: "blur"},{pattern: + /^[1-9]\d*$/,message: "${item.desc}为正整数",trigger: "blur",}], +#end +#end +#end +##保存请求接口 +#macro(insertReq) +const insertReq = () => { +const data = JSON.parse(JSON.stringify(subForm)) +delete data.id +axiosReq({ +url: '${apiConfig.insertApi}', +data: data, +method: '${apiConfig.insertApiType}', +bfLoading: true +}).then(() => { +elMessage('保存成功') +emit('selectPageReq') +emit('hideComp') +}) +} +#end +##保存请求接口 +#macro(updateReq) +const updateReq = () => { +return axiosReq({ +url: '${apiConfig.updateApi}', +data: subForm, +method: '${apiConfig.updateApiType}', +bfLoading: true +}).then(() => { +elMessage('更新成功') +emit('selectPageReq') +emit('hideComp') +}) +} +#end +##上传图片,一张图片 +#macro(fileUploadSave) +/*上传图片(单张))*/ +const refSettingFile = $ref(null) +const goUploadFile = () => { +refSettingFile.click() +} +const fileUploadSave = () => { +const formData = new FormData() +formData.append('file', refSettingFile.files[0]) +axiosReq({ +url: '${commonConfig.upFileApi}', +timeout: 30000, +data: formData, +method: 'post', +bfLoading: true, +isUploadFile: true +}) +.then((resData) => { +let { path } = resData.data +const filename = refSettingFile.value +chooseFileName = filename.slice(filename.lastIndexOf('\\') + 1) +subForm.image = `${import.meta.env.VITE_APP_IMAGE_URL}/${path}` +refSettingFile.value = '' +}) +.catch(() => { +chooseFileName = '' +subForm.image = '' +refSettingFile.value = '' +}) +} +#end +##生成form item +#macro(formScript) + #foreach($item in $formConfig) + #if($item.componentType=="uploadImage") + #fileUploadSave() + #elseif($item.componentType=="selectApi") ##selectApi + //下拉数据选择 + let select${item.fieldCase} = $ref([]) + const select${item.fieldCase}Req = () => { + let reqConfig = { + url: '${item.api}', + method: '${item.method}' + } + axiosReq(reqConfig).then((resData) => { + select${item.fieldCase} = resData.data + }) + } + #elseif($item.componentType=="cascaderApi") ##cascaderApi + //级联数据处理 + let cascade${item.fieldCase} = $ref([]) + const cascadeProps = { + multiple: false, + value: '${item}', + label: '${item.label}', + children: '${item.children}' + } + const cascade${item.fieldCase}Req = () => { + let reqConfig = { + url: '${item.api}', + method: '${item.method}' + } + axiosReq(reqConfig).then((resData) => { + cascade${item.fieldCase} = resData.data + }) + } + const handleCascade = (data) => { + console.log(data) + } + #elseif($item.componentType=="datetimerange") ##datetimerange + //时间packing + let startEndArr=$ref([]) + const dateTimePacking = (timeArr) => { + startEndArr= timeArr + if (timeArr && timeArr.length === 2) { + subForm.startTime = timeArr[0] + subForm.endTime = timeArr[1] + } else { + subForm.startTime = '' + subForm.endTime = '' + } + } + #end + #end +#end +##onMouted需要调用的请求 +#macro(onMountedScript) + #foreach($item in $formConfig) + #if($item.componentType=="selectApi")##selectApi + select${item.fieldCase}Req() + #elseif($item.componentType=="cascaderApi") ##cascader + cascade${item.fieldCase}Req() + #end + #end +#end \ No newline at end of file diff --git a/velocity-tmp-dir/front-vms/element-plus/queryUtils.vm b/velocity-tmp-dir/front-vms/element-plus/queryUtils.vm new file mode 100644 index 0000000..ad034f8 --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/queryUtils.vm @@ -0,0 +1,139 @@ +##生成查询表单数据 +#macro(queryItem) + #foreach($item in $queryConfig) + #if($item.componentType=="input") ##input + + + + #elseif($item.componentType=="select") ##select + + + #foreach($enum in $item.optionDataArr) + + #end + + + #elseif($item.componentType=="selectApi") ##selectApi + + + + + + #elseif($item.componentType=="cascaderApi") ##cascaderApi + + + + #elseif($item.componentType=="datetimerange") ##datetimerange + + + + #elseif($item.componentType=="datetime") ##datetime + + + + #elseif($item.componentType=="date") ##date + + + + #end + #end +#end +##生成queryScript +#macro(queryScript) + #foreach($item in $queryConfig) + #if($item.componentType=="selectApi")##selectApi + let select${item.fieldCase} = $ref([]) + const select${item.fieldCase}Req = () => { + let reqConfig = { + url: '${item.api}', + method: '${item.method}', + } + axiosReq(reqConfig).then((resData) => { + select${item.fieldCase} = resData.data + }) + } + #elseif($item.componentType=="cascaderApi") ##cascader + let cascade${item.fieldCase} = $ref([]) + const cascadeProps = { + multiple: false, + value: '${item}', + label: '${item.label}', + children: '${item.children}' + } + const cascade${item.fieldCase}Req = () => { + let reqConfig = { + url: '${item.api}', + method: '${item.method}' + } + axiosReq(reqConfig).then((resData) => { + cascade${item.fieldCase} = resData.data + }) + } + const handleCascade = (data) => { + console.log(data) + } + #elseif($item.componentType=="datetimerange") ##datetimerange + + let selectStartEndArr=$ref([]) + const dateTimePacking = (timeArr) => { + selectStartEndArr= timeArr + if (timeArr && timeArr.length === 2) { + searchForm.startTime = timeArr[0] + searchForm.endTime = timeArr[1] + } else { + searchForm.startTime = '' + searchForm.endTime = '' + } + } + #end + #end +#end +##onMouted需要调用的请求 +#macro(onMountedScript) +onMounted(()=>{ +selectPageReq() + #foreach($item in $queryConfig) + #if($item.componentType=="selectApi")##selectApi + select${item.fieldCase}Req() + #elseif($item.componentType=="cascaderApi") ##cascader + cascade${item.fieldCase}Req() + #end + #end +}) +#end \ No newline at end of file diff --git a/velocity-tmp-dir/front-vms/element-plus/tableUtils.vm b/velocity-tmp-dir/front-vms/element-plus/tableUtils.vm new file mode 100644 index 0000000..3d8cb94 --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/tableUtils.vm @@ -0,0 +1,214 @@ +##表格列项 +#macro(tableColumnItemTemp) + #if($commonConfig.isTableMulChoose) + + #end + #foreach($item in $tableConfig) + #if($item.componentType=="input") ##input + + #elseif($item.componentType=="select") ##select + + + + #elseif($item.componentType=="image") ##image + + + + #end + #end +#end + +##请求表格数据 +#macro(selectPageReq) +let selectPageReq = () => { +const data = Object.assign(searchForm, { +pageNum: pageNum, +pageSize: pageSize +}) +let reqConfig = { +url: '${apiConfig.queryApi}', +method: '${apiConfig.queryApiType}', +data, +isParams: true +} +axiosReq(reqConfig).then((resData) => { +usertableData = resData.data?.records +totalPage = resData.data?.total +}) +} +#end +##删除相关 +#macro(deleteByIdReq) + #if($commonConfig.isDelete) + let deleteByIdReq = (id) => { + return axiosReq({ + url: '${apiConfig.deleteApi}', + data: { id: id }, + isParams: true, + method: '${apiConfig.deleteApiType}', + bfLoading: true + }) + } + let tableDelClick = (row) => { + elConfirm('确定', `您确定要删除【${row.name}】吗?`) + .then(() => { + deleteByIdReq(row.id).then(() => { + selectPageReq() + elMessage(`【${row.name}】删除成功`) + }) + }) + .catch(() => {}) + } + #end +#end +##多个删除 +#macro(multiDelReq) + #if($commonConfig.isMulDelete) + const refuserTable = $ref(null) + const multiDelBtnClick = () => { + let rowDeleteIdArr = [] + let deleteNameTitle = '' + rowDeleteIdArr = multipleSelection.map((mItem) => { + deleteNameTitle = deleteNameTitle + mItem.name + ',' + return mItem.id + }) + if (rowDeleteIdArr.length === 0) { + elMessage('表格选项不能为空', 'warning') + return + } + let stringLength = deleteNameTitle.length - 1 + elConfirm('删除', `您确定要删除${deleteNameTitle}吗`) + .then(() => { + const data = rowDeleteIdArr + axiosReq({ + url: `${apiConfig.deleteMultiApi}`, + data, + method: '${apiConfig.deleteMultiApiType}', + bfLoading: true + }).then((res) => { + elMessage('删除成功') + selectPageReq() + }) + }) + .catch(() => {}) + } + #end +#end +##详情modal +#macro(detailScript) + #if($commonConfig.isDetail) + let detailData = $ref({}) + let dialogTitle =$ref("") + let detailDialog =$ref(false) + let tableDetailClick = (row) => { + dialogTitle = `详情【${row.name}】` + getDetailByIdReq(row.id).then((resData) => { + detailData = resData.data + detailDialog = true + }) + } + let getDetailByIdReq = (id) => { + return axiosReq({ + url: '${apiConfig.detailApi}', + data: { id }, + isParams: true, + method: '${apiConfig.detailApiType}' + }) + } + #end +#end +##table操作 +#macro(tableGlobalOperatorTemp) + #if($commonConfig.isAdd) + + + + + 增加 + + #end + #if($commonConfig.isMulDelete) + + + + + 删除 + + #end +#end +#macro(tableOperatorTemp) + #if($commonConfig.isEdit) + 编辑 + #end + #if($commonConfig.isDetail) + 详情 + #end + #if($commonConfig.isDelete) + 删除 + #end +#end +##分页 +#macro(tablePaginationTemp) + #if($commonConfig.isPagination) +
+ +
+ #end +#end +##详情 +#macro(tableDetailTemp) + #if($commonConfig.isDetail) + + #foreach($item in $formConfig) +
+
$item.desc:{{ detailData.$item.field }}
+
+ #end + +
+ #end +#end +##编辑和添加 +#macro(tableAddEditScript) + #if($commonConfig.isEdit) + let tableEditClick = (row) => { + getDetailByIdReq(row.id).then((resData) => { + showFrom = true + nextTick(() => { + refCRUDForm.showModal(true, resData.data) + }) + }) + } + #end + #if($commonConfig.isAdd) + let showFrom = $ref(false) + const refCRUDForm = $ref(null) + let addBtnClick = () => { + showFrom = true + nextTick(() => { + refCRUDForm.showModal() + }) + } + const hideComp = () => { + showFrom = false + } + #end +#end \ No newline at end of file diff --git a/velocity-tmp-dir/front-vms/element-plus/utils.vm b/velocity-tmp-dir/front-vms/element-plus/utils.vm new file mode 100644 index 0000000..dd49408 --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/utils.vm @@ -0,0 +1,30 @@ +##根据数组某个key分组 +#macro(groupArrByKey $arrs $group_key) + #set($gabkMap={}) + #foreach($ai in $arrs) + #if(!$!gabkMap[$ai[$group_key]]) + #set($gabkMap[$ai[$group_key]] = [$ai]) + #else + #set($gabkMap[$ai[$group_key]][-1] = [$ai]) + #end + #end +#end +##根据数组某个deep key分组 +#macro(groupArrByDeepKey $arrs $group_key $group_deep_key) + #set($gabkDeepMap={}) + #foreach($ai in $arrs) + #if(!$!gabkDeepMap[$ai[$group_key][$group_deep_key]]) + #set($gabkDeepMap[$ai[$group_key][$group_deep_key]] = [$ai]) + #else + #set($gabkDeepMap[$ai[$group_key][$group_deep_key]][-1] = [$ai]) + #end + #end +#end + + +##form key +#macro(fromDataProp) + #foreach($item in $formConfig) + $item.field:"", + #end +#end diff --git a/velocity-tmp-dir/json-data/brandData.json b/velocity-tmp-dir/json-data/brandData.json new file mode 100644 index 0000000..bca0430 --- /dev/null +++ b/velocity-tmp-dir/json-data/brandData.json @@ -0,0 +1,135 @@ +{ + "projectOrAuthor": { + "author": "熊猫哥", + "packageName": "top.kuanghua.vg", + "serviceName": "integration-front", + "dataTime": "2021-09-15 11:54:49" + }, + "commonConfig": { + "upFileApi": "/ty-example/upload/file", + "isAdd": true, + "isDelete": true, + "isMulDelete": true, + "isEdit": true, + "isPagination": true, + "isDetail": true, + "isTableMulChoose": true + }, + "dbTableConfig":[ + { + "tableName": "brand", + "originTableName": "tb_brand", + "tableDesc": "品牌表", + "tableNameCase": "Brand", + "uniKey": "id", + "associationKey": "sn" + } + ], + "apiConfig": { + "queryApi": "/integration-front/brand/selectPage", + "queryApiType": "get", + "insertApi": "/integration-front/brand/insert", + "insertApiType": "post", + "updateApi": "/integration-front/brand/updateById", + "updateApiType": "update", + "deleteApi": "/integration-front/brand/deleteById", + "deleteApiType": "delete", + "deleteMultiApi": "/integration-front/brand/deleteBatchIds", + "deleteMultiApiType": "delete", + "detailApi": "/integration-front/brand/selectById", + "detailApiType": "get" + }, + "queryConfig": [ + { + "field": "name", + "originField": "name", + "fieldCase": "Name", + "desc": "品牌名称", + "width": 100, + "componentType": "input" + } + ], + "tableConfig": [ + { + "field": "name", + "desc": "品牌名称", + "width": 100, + "componentType": "input" + }, + { + "field": "image", + "desc": "品牌图片地址", + "width": 140, + "componentType": "image" + }, + { + "field": "letter", + "desc": "首字母", + "width": 80, + "componentType": "input" + }, + { + "field": "seq", + "desc": "排序", + "width": 80, + "componentType": "input" + }, + { + "field": "createTime", + "desc": "创建时间", + "width": 140, + "componentType": "input" + }, + { + "field": "updateTime", + "desc": "更新时间", + "width": 140, + "componentType": "input" + } + ], + "formConfig": [ + { + "field": "id", + "type": "Integer", + "originField": "id", + "desc": "主键", + "width": 100 + }, + { + "field": "name", + "type": "String", + "desc": "品牌名称", + "originField": "name", + "componentType": "input", + "rule": "isNotNull", + "width": 200 + }, + { + "field": "image", + "type": "String", + "desc": "品牌图片地址", + "originField": "image", + "componentType": "uploadImage", + "width": 200, + "rule": "isNotNull" + }, + { + "field": "letter", + "type": "String", + "desc": "品牌的首字母", + "originField": "letter", + "componentType": "input", + "width": 200, + "rule": "isNotNull" + }, + { + "field": "seq", + "type": "Integer", + "desc": "排序", + "originField": "seq", + "componentType": "textarea", + "width": 200, + "rule": "isNotNull" + } + ] +} diff --git a/velocity-tmp-dir/json-data/cascadeData.json b/velocity-tmp-dir/json-data/cascadeData.json new file mode 100644 index 0000000..bbd8e21 --- /dev/null +++ b/velocity-tmp-dir/json-data/cascadeData.json @@ -0,0 +1,16 @@ +[ + { + "value": "guide", + "label": "Guide", + "children": [ + { + "value": "feedback", + "label": "Feedback" + }, + { + "value": "consistency", + "label": "Consistency" + } + ] + } +] \ No newline at end of file diff --git a/velocity-tmp-dir/json-data/data.json b/velocity-tmp-dir/json-data/data.json new file mode 100644 index 0000000..e81f60a --- /dev/null +++ b/velocity-tmp-dir/json-data/data.json @@ -0,0 +1,192 @@ +{ + "projectOrAuthor": { + "author": "熊猫哥", + "dataTime": "2021-09-15 11:54:49" + }, + "dbTableConfig": { + "tableName": "brand", + "originTableName": "tb_brand", + "tableDesc": "品牌表", + "tableNameCase": "Brand", + "uniKey": "id" + }, + "commonConfig": { + "upFileApi": "/ty-example/upload/file", + "isAdd": true, + "isDelete": true, + "isMulDelete": true, + "isEdit": true, + "isPagination": true, + "isDetail": true, + "isTableMulChoose": true + }, + "apiConfig": { + "queryApi": "/integration-front/brand/selectPage", + "queryApiType": "get", + "insertApi": "/integration-front/brand/insert", + "insertApiType": "post", + "updateApi": "/integration-front/brand/updateById", + "updateApiType": "update", + "deleteApi": "/integration-front/brand/deleteById", + "deleteApiType": "delete", + "deleteMultiApi": "/integration-front/brand/deleteBatchIds", + "deleteMultiApiType": "delete", + "detailApi": "/integration-front/brand/selectById", + "detailApiType": "get" + }, + "queryConfig": [ + { + "field": "name", + "originField": "name", + "fieldCase": "Name", + "desc": "品牌名字", + "width": 100, + "componentType": "input" + }, + { + "field": "select", + "desc": "select", + "width": 100, + "componentType": "select", + "selectKey": "id", + "selectLabel": "label", + "queryApi": "/integration-front/VmsTemplate/selectApiDemo", + "queryApiType": "get" + }, + { + "field": "selectApi", + "desc": "selectApi", + "width": 100, + "componentType": "selectApi", + "selectKey": "id", + "selectLabel": "label", + "queryApi": "/integration-front/VmsTemplate/selectApiDemo", + "queryApiType": "get" + }, + { + "field": "cascader", + "desc": "cascader", + "width": 100, + "componentType": "cascader", + "value": "value", + "label": "label", + "children": "children", + "queryApi": "/integration-front/VmsTemplate/cascadeApiDemo", + "queryApiType": "get" + }, + { + "field": "createTime", + "desc": "时间日期选择", + "width": 100, + "componentType": "datetimerange" + } + ], + "tableConfig": [ + { + "field": "name", + "desc": "品牌名称", + "width": 100, + "componentType": "input" + }, + { + "field": "image", + "desc": "品牌图片地址", + "width": 140, + "componentType": "image" + }, + { + "field": "letter", + "desc": "首字母", + "width": 80, + "componentType": "input" + }, + { + "field": "seq", + "desc": "排序", + "width": 80, + "componentType": "input" + }, + { + "field": "createTime", + "desc": "创建时间", + "width": 140, + "componentType": "input" + }, + { + "field": "updateTime", + "desc": "更新时间", + "width": 140, + "componentType": "input" + } + ], + "formConfig": [ + { + "field": "selectApi", + "desc": "selectApi", + "width": 100, + "componentType": "selectApi", + "selectKey": "id", + "selectLabel": "label", + "queryApi": "/integration-front/VmsTemplate/selectApiDemo", + "queryApiType": "get", + "rule": "isNotNull" + }, + { + "field": "cascader", + "desc": "cascader", + "width": 100, + "componentType": "cascader", + "value": "value", + "label": "label", + "children": "children", + "queryApi": "/integration-front/VmsTemplate/cascadeApiDemo", + "queryApiType": "get", + "rule": "isNotNull" + }, + { + "field": "name", + "desc": "品牌名称", + "componentType": "input", + "rule": "isNotNull", + "width": 200 + }, + { + "field": "image", + "desc": "品牌图片地址", + "componentType": "uploadImage", + "width": 200, + "rule": "isNotNull" + }, + { + "field": "carTypeList", + "desc": "可兼容车型", + "componentType": "select", + "optionDataArr": [ + { + "desc": "未出库", + "value": "0" + }, + { + "desc": "已出库", + "value": "1" + } + ], + "rule": "isNotNull", + "width": 200 + }, + { + "field": "letter", + "desc": "品牌的首字母", + "componentType": "input", + "width": 200, + "rule": "isNotNull" + }, + { + "field": "seq", + "desc": "排序", + "componentType": "textarea", + "width": 200, + "rule": "isNotNull" + } + ] +} diff --git a/velocity-tmp-dir/json-data/multiTableData.json b/velocity-tmp-dir/json-data/multiTableData.json new file mode 100644 index 0000000..cea2d48 --- /dev/null +++ b/velocity-tmp-dir/json-data/multiTableData.json @@ -0,0 +1,3076 @@ +{ + "projectOrAuthor": { + "author": "熊猫哥", + "packageName": "top.kuanghua.integrationfront", + "serviceName": "integration-front", + "dataTime": "2022-06-25 10:32:12", + "modalTitle": "我是modal的title", + "isMultiTable": true + }, + "commonConfig": { + "upFileApi": "/ty-example/upload/file", + "isAdd": "true", + "isDelete": "true", + "isMulDelete": "true", + "isEdit": "true", + "isPagination": "true", + "isDetail": "true", + "isTableMulChoose": "true" + }, + "multiTableConfig": [ + { + "tableName": "repair", + "originTableName": "tb_repair", + "tableDesc": "售后维修表", + "tableNameCase": "Repair", + "uniKey": "id", + "tableFieldArr": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "id", + "field": "id", + "desc": "ID", + "fieldCase": "", + "originField": "id", + "tbName": "id", + "type": "Integer" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "SN_ID", + "columnKey": "UNI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "sn", + "field": "sn", + "desc": "SN_ID", + "fieldCase": "", + "originField": "sn", + "tbName": "sn", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "换件_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "replacement_id", + "field": "replacementId", + "desc": "换件_ID", + "fieldCase": "ReplacementId", + "originField": "replacement_id", + "tbName": "replacement_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "快递信息ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "express_id", + "field": "expressId", + "desc": "快递信息ID", + "fieldCase": "ExpressId", + "originField": "express_id", + "tbName": "express_id", + "type": "String" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "问题归类id", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "problem_classification_id", + "field": "problemClassificationId", + "desc": "问题归类id", + "fieldCase": "ProblemClassificationId", + "originField": "problem_classification_id", + "tbName": "problem_classification_id", + "type": "String" + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "问题描述", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "problem_description", + "field": "problemDescription", + "desc": "问题描述", + "fieldCase": "ProblemDescription", + "originField": "problem_description", + "tbName": "problem_description", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "反馈时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "feedback_time", + "field": "feedbackTime", + "desc": "反馈时间", + "fieldCase": "FeedbackTime", + "originField": "feedback_time", + "tbName": "feedback_time", + "type": "Date" + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "提出人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "proposer", + "field": "proposer", + "desc": "提出人", + "fieldCase": "", + "originField": "proposer", + "tbName": "proposer", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "返回日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "return_date", + "field": "returnDate", + "desc": "返回日期", + "fieldCase": "ReturnDate", + "originField": "return_date", + "tbName": "return_date", + "type": "Date" + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "返修分析的问题", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "problems_analyzed", + "field": "problemsAnalyzed", + "desc": "返修分析的问题", + "fieldCase": "ProblemsAnalyzed", + "originField": "problems_analyzed", + "tbName": "problems_analyzed", + "type": "String" + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "返修分析的原因", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "reason", + "field": "reason", + "desc": "返修分析的原因", + "fieldCase": "", + "originField": "reason", + "tbName": "reason", + "type": "String" + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "处理方法", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "processing_method", + "field": "processingMethod", + "desc": "处理方法", + "fieldCase": "ProcessingMethod", + "originField": "processing_method", + "tbName": "processing_method", + "type": "String" + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "备注", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "remarks", + "field": "remarks", + "desc": "备注", + "fieldCase": "", + "originField": "remarks", + "tbName": "remarks", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "create_time", + "field": "createTime", + "desc": "创建时间", + "fieldCase": "CreateTime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "更新时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "update_time", + "field": "updateTime", + "desc": "更新时间", + "fieldCase": "UpdateTime", + "originField": "update_time", + "tbName": "update_time", + "type": "Date" + } + ], + "orgUniKey": "id", + "uniKeyType": "Integer", + "priKeyArr": [ + "id", + "sn", + "replacement_id", + "express_id", + "problem_classification_id" + ], + "priKeyItemArr": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "id", + "field": "id", + "desc": "ID", + "fieldCase": "", + "originField": "id", + "tbName": "id", + "type": "Integer" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "SN_ID", + "columnKey": "UNI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "sn", + "field": "sn", + "desc": "SN_ID", + "fieldCase": "", + "originField": "sn", + "tbName": "sn", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "换件_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "replacement_id", + "field": "replacementId", + "desc": "换件_ID", + "fieldCase": "ReplacementId", + "originField": "replacement_id", + "tbName": "replacement_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "快递信息ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "express_id", + "field": "expressId", + "desc": "快递信息ID", + "fieldCase": "ExpressId", + "originField": "express_id", + "tbName": "express_id", + "type": "String" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "问题归类id", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "problem_classification_id", + "field": "problemClassificationId", + "desc": "问题归类id", + "fieldCase": "ProblemClassificationId", + "originField": "problem_classification_id", + "tbName": "problem_classification_id", + "type": "String" + } + ], + "orgAssociationKey": "sn", + "associationKey": "sn", + "associationKeyCase": "ProblemClassificationId", + "associationKeyType": "String", + "multiTableNameCase": null, + "tableQueryArr": [ + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + } + ], + "tableShowArr": [ + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + } + ], + "tableFormArr": [ + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + } + ] + }, + { + "tableName": "replacement", + "originTableName": "tb_replacement", + "tableDesc": "换件表", + "tableNameCase": "Replacement", + "uniKey": "id", + "tableFieldArr": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "id", + "field": "id", + "desc": "ID", + "fieldCase": "", + "originField": "id", + "tbName": "id", + "type": "Integer" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "SN_ID", + "columnKey": "UNI", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "sn", + "field": "sn", + "desc": "SN_ID", + "fieldCase": "", + "originField": "sn", + "tbName": "sn", + "type": "String" + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型;0:T-BOX,1:VCI", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "新SN_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "new_sn_id", + "field": "newSnId", + "desc": "新SN_ID", + "fieldCase": "NewSnId", + "originField": "new_sn_id", + "tbName": "new_sn_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "深度;(换件次数)", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "depth", + "field": "depth", + "desc": "深度", + "fieldCase": "", + "originField": "depth", + "tbName": "depth", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "create_time", + "field": "createTime", + "desc": "创建时间", + "fieldCase": "CreateTime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "更新时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "update_time", + "field": "updateTime", + "desc": "更新时间", + "fieldCase": "UpdateTime", + "originField": "update_time", + "tbName": "update_time", + "type": "Date" + } + ], + "orgUniKey": "id", + "uniKeyType": "Integer", + "priKeyArr": [ + "id", + "sn", + "new_sn_id" + ], + "priKeyItemArr": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "id", + "field": "id", + "desc": "ID", + "fieldCase": "", + "originField": "id", + "tbName": "id", + "type": "Integer" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "SN_ID", + "columnKey": "UNI", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "sn", + "field": "sn", + "desc": "SN_ID", + "fieldCase": "", + "originField": "sn", + "tbName": "sn", + "type": "String" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "新SN_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "new_sn_id", + "field": "newSnId", + "desc": "新SN_ID", + "fieldCase": "NewSnId", + "originField": "new_sn_id", + "tbName": "new_sn_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "orgAssociationKey": "sn", + "associationKey": "sn", + "associationKeyCase": "NewSnId", + "associationKeyType": "String", + "multiTableNameCase": "Pair", + "tableQueryArr": [ + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "深度;(换件次数)", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "depth", + "field": "depth", + "desc": "深度", + "fieldCase": "", + "originField": "depth", + "tbName": "depth", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "tableShowArr": [ + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "深度;(换件次数)", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "depth", + "field": "depth", + "desc": "深度", + "fieldCase": "", + "originField": "depth", + "tbName": "depth", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "tableFormArr": [ + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "深度;(换件次数)", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "depth", + "field": "depth", + "desc": "深度", + "fieldCase": "", + "originField": "depth", + "tbName": "depth", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ] + } + ], + "dbTableConfig": { + "multiTableName": "pairment", + "multiTableDesc": "多表中实体类的注释", + "tableName": "repair", + "originTableName": "tb_repair", + "tableDesc": "售后维修表", + "tableNameCase": "Repair", + "uniKey": "id", + "tableFieldArr": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "id", + "field": "id", + "desc": "ID", + "fieldCase": "", + "originField": "id", + "tbName": "id", + "type": "Integer" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "SN_ID", + "columnKey": "UNI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "sn", + "field": "sn", + "desc": "SN_ID", + "fieldCase": "", + "originField": "sn", + "tbName": "sn", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "换件_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "replacement_id", + "field": "replacementId", + "desc": "换件_ID", + "fieldCase": "ReplacementId", + "originField": "replacement_id", + "tbName": "replacement_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "快递信息ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "express_id", + "field": "expressId", + "desc": "快递信息ID", + "fieldCase": "ExpressId", + "originField": "express_id", + "tbName": "express_id", + "type": "String" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "问题归类id", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "problem_classification_id", + "field": "problemClassificationId", + "desc": "问题归类id", + "fieldCase": "ProblemClassificationId", + "originField": "problem_classification_id", + "tbName": "problem_classification_id", + "type": "String" + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "问题描述", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "problem_description", + "field": "problemDescription", + "desc": "问题描述", + "fieldCase": "ProblemDescription", + "originField": "problem_description", + "tbName": "problem_description", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "反馈时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "feedback_time", + "field": "feedbackTime", + "desc": "反馈时间", + "fieldCase": "FeedbackTime", + "originField": "feedback_time", + "tbName": "feedback_time", + "type": "Date" + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "提出人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "proposer", + "field": "proposer", + "desc": "提出人", + "fieldCase": "", + "originField": "proposer", + "tbName": "proposer", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "返回日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "return_date", + "field": "returnDate", + "desc": "返回日期", + "fieldCase": "ReturnDate", + "originField": "return_date", + "tbName": "return_date", + "type": "Date" + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "返修分析的问题", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "problems_analyzed", + "field": "problemsAnalyzed", + "desc": "返修分析的问题", + "fieldCase": "ProblemsAnalyzed", + "originField": "problems_analyzed", + "tbName": "problems_analyzed", + "type": "String" + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "返修分析的原因", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "reason", + "field": "reason", + "desc": "返修分析的原因", + "fieldCase": "", + "originField": "reason", + "tbName": "reason", + "type": "String" + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "处理方法", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "processing_method", + "field": "processingMethod", + "desc": "处理方法", + "fieldCase": "ProcessingMethod", + "originField": "processing_method", + "tbName": "processing_method", + "type": "String" + }, + { + "columnType": "varchar(1024)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "备注", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "remarks", + "field": "remarks", + "desc": "备注", + "fieldCase": "", + "originField": "remarks", + "tbName": "remarks", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "create_time", + "field": "createTime", + "desc": "创建时间", + "fieldCase": "CreateTime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "更新时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "update_time", + "field": "updateTime", + "desc": "更新时间", + "fieldCase": "UpdateTime", + "originField": "update_time", + "tbName": "update_time", + "type": "Date" + } + ], + "orgUniKey": "id", + "uniKeyType": "Integer", + "priKeyArr": [ + "id", + "sn", + "replacement_id", + "express_id", + "problem_classification_id" + ], + "priKeyItemArr": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "id", + "field": "id", + "desc": "ID", + "fieldCase": "", + "originField": "id", + "tbName": "id", + "type": "Integer" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "SN_ID", + "columnKey": "UNI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "sn", + "field": "sn", + "desc": "SN_ID", + "fieldCase": "", + "originField": "sn", + "tbName": "sn", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "换件_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "replacement_id", + "field": "replacementId", + "desc": "换件_ID", + "fieldCase": "ReplacementId", + "originField": "replacement_id", + "tbName": "replacement_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "快递信息ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "express_id", + "field": "expressId", + "desc": "快递信息ID", + "fieldCase": "ExpressId", + "originField": "express_id", + "tbName": "express_id", + "type": "String" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "问题归类id", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "problem_classification_id", + "field": "problemClassificationId", + "desc": "问题归类id", + "fieldCase": "ProblemClassificationId", + "originField": "problem_classification_id", + "tbName": "problem_classification_id", + "type": "String" + } + ], + "orgAssociationKey": "sn", + "associationKey": "sn", + "associationKeyCase": "ProblemClassificationId", + "associationKeyType": "String", + "multiTableNameCase": "Pairment", + "tableQueryArr": [ + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + } + ], + "tableShowArr": [ + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + } + ], + "tableFormArr": [ + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + } + ] + }, + "apiConfig": { + "queryApi": "/integration-front/pairment/selectPage", + "queryApiType": "get", + "insertApi": "/insert", + "insertApiType": "post", + "updateApi": "/integration-front/pairment/updateById", + "updateApiType": "update", + "deleteApi": "/integration-front/pairment/deleteById", + "deleteApiType": "delete", + "deleteMultiApi": "/integration-front/pairment/deleteBatchIds", + "deleteMultiApiType": "delete", + "detailApi": "/integration-front/pairment/selectById", + "detailApiType": "get" + }, + "queryConfig": [ + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + }, + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "深度;(换件次数)", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "depth", + "field": "depth", + "desc": "深度", + "fieldCase": "", + "originField": "depth", + "tbName": "depth", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "tableConfig": [ + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "提出人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "proposer", + "field": "proposer", + "desc": "提出人", + "fieldCase": "", + "originField": "proposer", + "tbName": "proposer", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "SN_ID", + "columnKey": "UNI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "sn", + "field": "sn", + "desc": "SN_ID", + "fieldCase": "", + "originField": "sn", + "tbName": "sn", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "换件_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "replacement_id", + "field": "replacementId", + "desc": "换件_ID", + "fieldCase": "ReplacementId", + "originField": "replacement_id", + "tbName": "replacement_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "深度;(换件次数)", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "depth", + "field": "depth", + "desc": "深度", + "fieldCase": "", + "originField": "depth", + "tbName": "depth", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "新SN_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "new_sn_id", + "field": "newSnId", + "desc": "新SN_ID", + "fieldCase": "NewSnId", + "originField": "new_sn_id", + "tbName": "new_sn_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "formConfig": [ + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "目前状态;0:报废,1:在用,2:维修,3:更换,4:替换件", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "current_status", + "field": "currentStatus", + "desc": "目前状态", + "fieldCase": "CurrentStatus", + "originField": "current_status", + "tbName": "current_status", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:报废,1:在用,2:维修,3:更换,4:替换件", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:报废" + }, + { + "value": "1:在用" + }, + { + "value": "2:维修" + }, + { + "value": "3:更换" + }, + { + "value": "4:替换件" + } + ] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "提出人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "proposer", + "field": "proposer", + "desc": "提出人", + "fieldCase": "", + "originField": "proposer", + "tbName": "proposer", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "回收日期", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "recovery_date", + "field": "recoveryDate", + "desc": "回收日期", + "fieldCase": "RecoveryDate", + "originField": "recovery_date", + "tbName": "recovery_date", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(50)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "联系方式", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "contact_info", + "field": "contactInfo", + "desc": "联系方式", + "fieldCase": "ContactInfo", + "originField": "contact_info", + "tbName": "contact_info", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "SN_ID", + "columnKey": "UNI", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "sn", + "field": "sn", + "desc": "SN_ID", + "fieldCase": "", + "originField": "sn", + "tbName": "sn", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "换件_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "replacement_id", + "field": "replacementId", + "desc": "换件_ID", + "fieldCase": "ReplacementId", + "originField": "replacement_id", + "tbName": "replacement_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "深度;(换件次数)", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "depth", + "field": "depth", + "desc": "深度", + "fieldCase": "", + "originField": "depth", + "tbName": "depth", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "新SN_ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "tb_replacement", + "columnName": "new_sn_id", + "field": "newSnId", + "desc": "新SN_ID", + "fieldCase": "NewSnId", + "originField": "new_sn_id", + "tbName": "new_sn_id", + "type": "String", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(4)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "设备类型;0:T-BOX,1:VCI", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_repair", + "columnName": "equip_type", + "field": "equipType", + "desc": "设备类型", + "fieldCase": "EquipType", + "originField": "equip_type", + "tbName": "equip_type", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "optionData": "0:T-BOX,1:VCI", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0:T-BOX" + }, + { + "value": "1:VCI" + } + ] + } + ] +} \ No newline at end of file diff --git a/velocity-tmp-dir/json-data/tb_brand.json b/velocity-tmp-dir/json-data/tb_brand.json new file mode 100644 index 0000000..fbff052 --- /dev/null +++ b/velocity-tmp-dir/json-data/tb_brand.json @@ -0,0 +1,877 @@ +{ + "projectOrAuthor": { + "author": "熊猫哥", + "packageName": "top.kuanghua.integrationfront", + "serviceName": "integration-front", + "dataTime": "2022-06-22 10:02:51", + "modalTitle": "我是modal的title", + "isMultiTable": false + }, + "commonConfig": { + "upFileApi": "/ty-example/upload/file", + "isAdd": "true", + "isDelete": "true", + "isMulDelete": "true", + "isEdit": "true", + "isPagination": "true", + "isDetail": "true", + "isTableMulChoose": "true" + }, + "multiTableConfig": [ + { + "tableName": "brand", + "originTableName": "tb_brand", + "tableDesc": "品牌表", + "tableNameCase": "Brand", + "uniKey": "id", + "tableFieldArr": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "id", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Integer", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "id", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(100)", + "isNullable": "NO", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌名称", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(1000)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌图片地址", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "image", + "field": "image", + "fieldCase": "Image", + "originField": "image", + "tbName": "image", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌图片地址", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "char(1)", + "isNullable": "YES", + "dataType": "char", + "extra": "", + "columnComment": "品牌的首字母", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "letter", + "field": "letter", + "fieldCase": "Letter", + "originField": "letter", + "tbName": "letter", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌的首字母", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "排序", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "seq", + "field": "seq", + "fieldCase": "Seq", + "originField": "seq", + "tbName": "seq", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "排序", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "on update CURRENT_TIMESTAMP", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "create_time", + "field": "createTime", + "fieldCase": "Createtime", + "originField": "create_time", + "tbName": "create_time", + "type": "Long" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "on update CURRENT_TIMESTAMP", + "columnComment": "更新时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "update_time", + "field": "updateTime", + "fieldCase": "Updatetime", + "originField": "update_time", + "tbName": "update_time", + "type": "Long" + } + ], + "orgUniKey": "id", + "uniKeyType": "Integer", + "priKeyArr": [ + "id", + "name" + ], + "priKeyItemArr": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "id", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Integer", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "id", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(100)", + "isNullable": "NO", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌名称", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "orgAssociationKey": "name", + "associationKey": "name", + "associationKeyType": "String", + "tableQueryArr": [ + { + "columnType": "varchar(100)", + "isNullable": "NO", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌名称", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "tableShowArr": [ + { + "columnType": "varchar(100)", + "isNullable": "NO", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌名称", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "tableFormArr": [ + { + "columnType": "varchar(100)", + "isNullable": "NO", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌名称", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ] + } + ], + "dbTableConfig": { + "tableName": "brand", + "originTableName": "tb_brand", + "tableDesc": "品牌表", + "tableNameCase": "Brand", + "uniKey": "id", + "orgUniKey": "id", + "uniKeyType": "Integer", + "orgAssociationKey": "name", + "multiTableName": "rand", + "multiTableNameCase": "Rand", + "multiTableDesc": "多表中实体类的注释", + "associationKey": "name", + "associationKeyCase": "Name", + "associationKeyType": "String", + "tableFieldArr": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "id", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Integer", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "id", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(100)", + "isNullable": "NO", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌名称", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(1000)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌图片地址", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "image", + "field": "image", + "fieldCase": "Image", + "originField": "image", + "tbName": "image", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌图片地址", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "char(1)", + "isNullable": "YES", + "dataType": "char", + "extra": "", + "columnComment": "品牌的首字母", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "letter", + "field": "letter", + "fieldCase": "Letter", + "originField": "letter", + "tbName": "letter", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌的首字母", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "排序", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "seq", + "field": "seq", + "fieldCase": "Seq", + "originField": "seq", + "tbName": "seq", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "排序", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "desc": "创建时间", + "isNullable": "YES", + "dataType": "datetime", + "extra": "on update CURRENT_TIMESTAMP", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "create_time", + "field": "createTime", + "fieldCase": "Createtime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date" + }, + { + "columnType": "datetime", + "desc": "更新时间", + "isNullable": "YES", + "dataType": "datetime", + "extra": "on update CURRENT_TIMESTAMP", + "columnComment": "更新时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "update_time", + "field": "updateTime", + "fieldCase": "Updatetime", + "originField": "update_time", + "tbName": "update_time", + "type": "Date" + } + ] + }, + "apiConfig": { + "queryApi": "/integration-front/brand/selectPage", + "queryApiType": "get", + "insertApi": "/insert", + "insertApiType": "post", + "updateApi": "/integration-front/brand/updateById", + "updateApiType": "update", + "deleteApi": "/integration-front/brand/deleteById", + "deleteApiType": "delete", + "deleteMultiApi": "/integration-front/brand/deleteBatchIds", + "deleteMultiApiType": "delete", + "detailApi": "/integration-front/brand/selectById", + "detailApiType": "get" + }, + "queryConfig": [ + { + "columnType": "varchar(100)", + "isNullable": "NO", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌名称", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "tableConfig": [ + { + "columnType": "varchar(100)", + "isNullable": "NO", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌名称", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(1000)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌图片地址", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "image", + "field": "image", + "fieldCase": "Image", + "originField": "image", + "tbName": "image", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌图片地址", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "char(1)", + "isNullable": "YES", + "dataType": "char", + "extra": "", + "columnComment": "品牌的首字母", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "letter", + "field": "letter", + "fieldCase": "Letter", + "originField": "letter", + "tbName": "letter", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌的首字母", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "排序", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "seq", + "field": "seq", + "fieldCase": "Seq", + "originField": "seq", + "tbName": "seq", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "排序", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ], + "formConfig": [ + { + "columnType": "int(11)", + "isNullable": "NO", + "dataType": "int", + "extra": "auto_increment", + "columnComment": "id", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Integer", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "id", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(100)", + "isNullable": "NO", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌名称", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(1000)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "品牌图片地址", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "image", + "field": "image", + "fieldCase": "Image", + "originField": "image", + "tbName": "image", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌图片地址", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "char(1)", + "isNullable": "YES", + "dataType": "char", + "extra": "", + "columnComment": "品牌的首字母", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "letter", + "field": "letter", + "fieldCase": "Letter", + "originField": "letter", + "tbName": "letter", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "品牌的首字母", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "int(11)", + "isNullable": "YES", + "dataType": "int", + "extra": "", + "columnComment": "排序", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "tb_brand", + "columnName": "seq", + "field": "seq", + "fieldCase": "Seq", + "originField": "seq", + "tbName": "seq", + "type": "Integer", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "排序", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + } + ] +} \ No newline at end of file From 51b635d87ce6ee3fc0c665d4f375492a4b22c972 Mon Sep 17 00:00:00 2001 From: jzfai Date: Sun, 18 Sep 2022 17:39:43 +0800 Subject: [PATCH 26/36] replace tomcat to undertow --- pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pom.xml b/pom.xml index 9c2da85..0410fe4 100644 --- a/pom.xml +++ b/pom.xml @@ -53,6 +53,10 @@ org.springframework.cloud spring-cloud-starter-bootstrap + + org.springframework.boot + spring-boot-starter-undertow + com.alibaba From 91aa01623828f95866c146154919207acb6e775d Mon Sep 17 00:00:00 2001 From: jzfai Date: Mon, 3 Oct 2022 13:12:35 +0800 Subject: [PATCH 27/36] add element-plus code generator --- .../controller/ElementPlusController.java | 68 ++++ .../GeneratorConfigSaveController.java | 119 +++++++ .../basisfunc/entity/GeneratorConfigSave.java | 35 +++ .../mapper/GeneratorConfigSaveMapper.java | 14 + .../basisfunc/service/ElementPlusService.java | 166 ++++++++++ .../service/GeneratorConfigSaveService.java | 60 ++++ .../basisfunc/utils/GeneratorTempUtils.java | 2 +- .../src/main/resources/application-db.yml | 8 +- .../service/ElementPlusServiceTest.java | 45 +++ .../aulton-asset/base-model-add-model.vm | 96 ++++++ .../aulton-asset/base-model-index.vm | 141 +++++++++ front-template/aulton-asset/base-template.vm | 55 ++++ front-template/aulton-asset/formUtils.vm | 291 ++++++++++++++++++ front-template/aulton-asset/queryUtils.vm | 94 ++++++ front-template/aulton-asset/req-api.vm | 82 +++++ front-template/aulton-asset/tableUtils.vm | 88 ++++++ front-template/aulton-asset/utils.vm | 24 ++ front-template/settlement/add-edit-api.vm | 54 ++++ .../settlement/add-edit-table-api.vm | 18 ++ .../settlement/add-edit-table-utils.vm | 74 +++++ front-template/settlement/add-edit-table.vm | 78 +++++ front-template/settlement/add-edit.vm | 68 ++++ front-template/settlement/detail-api.vm | 8 + front-template/settlement/detail.vm | 51 +++ front-template/settlement/detailUtils.vm | 76 +++++ front-template/settlement/formUtils.vm | 156 ++++++++++ front-template/settlement/queryApi.vm | 39 +++ .../settlement/table-query-utils.vm | 127 ++++++++ front-template/settlement/table-query.vm | 158 ++++++++++ front-template/settlement/tableUtils.vm | 88 ++++++ front-template/settlement/utils.vm | 24 ++ gateway/src/main/resources/application.yml | 26 +- .../element-plus/add-edit-table-api.vm | 18 ++ .../element-plus/add-edit-table-utils.vm | 74 +++++ .../front-vms/element-plus/add-edit-table.vm | 78 +++++ .../front-vms/element-plus/addEdit.vm | 91 ++++++ .../front-vms/element-plus/addEditApi.vm | 39 +++ .../front-vms/element-plus/addEditUtils.vm | 170 ++++++++++ .../front-vms/element-plus/detail.vm | 46 +++ .../front-vms/element-plus/detailApi.vm | 8 + .../front-vms/element-plus/detailUtils.vm | 91 ++++++ .../front-vms/element-plus/queryApi.vm | 38 +++ .../front-vms/element-plus/queryUtils.vm | 2 - .../front-vms/element-plus/routerItem.vm | 28 ++ .../front-vms/element-plus/tableQuery.vm | 123 ++++++++ .../front-vms/element-plus/tableQueryIndex.vm | 2 + .../front-vms/element-plus/tableQueryUtils.vm | 179 +++++++++++ .../json-data/element-plus/add-edit.json | 89 ++++++ .../json-data/element-plus/detail.json | 156 ++++++++++ .../json-data/element-plus/table-query.json | 175 +++++++++++ 50 files changed, 3822 insertions(+), 18 deletions(-) create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/controller/ElementPlusController.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/controller/GeneratorConfigSaveController.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/entity/GeneratorConfigSave.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/mapper/GeneratorConfigSaveMapper.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/service/ElementPlusService.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorConfigSaveService.java create mode 100644 basis-func/src/test/java/top/kuanghua/basisfunc/service/ElementPlusServiceTest.java create mode 100644 front-template/aulton-asset/base-model-add-model.vm create mode 100644 front-template/aulton-asset/base-model-index.vm create mode 100644 front-template/aulton-asset/base-template.vm create mode 100644 front-template/aulton-asset/formUtils.vm create mode 100644 front-template/aulton-asset/queryUtils.vm create mode 100644 front-template/aulton-asset/req-api.vm create mode 100644 front-template/aulton-asset/tableUtils.vm create mode 100644 front-template/aulton-asset/utils.vm create mode 100644 front-template/settlement/add-edit-api.vm create mode 100644 front-template/settlement/add-edit-table-api.vm create mode 100644 front-template/settlement/add-edit-table-utils.vm create mode 100644 front-template/settlement/add-edit-table.vm create mode 100644 front-template/settlement/add-edit.vm create mode 100644 front-template/settlement/detail-api.vm create mode 100644 front-template/settlement/detail.vm create mode 100644 front-template/settlement/detailUtils.vm create mode 100644 front-template/settlement/formUtils.vm create mode 100644 front-template/settlement/queryApi.vm create mode 100644 front-template/settlement/table-query-utils.vm create mode 100644 front-template/settlement/table-query.vm create mode 100644 front-template/settlement/tableUtils.vm create mode 100644 front-template/settlement/utils.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/add-edit-table-api.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/add-edit-table-utils.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/add-edit-table.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/addEdit.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/addEditApi.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/addEditUtils.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/detail.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/detailApi.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/detailUtils.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/queryApi.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/routerItem.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/tableQuery.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/tableQueryIndex.vm create mode 100644 velocity-tmp-dir/front-vms/element-plus/tableQueryUtils.vm create mode 100644 velocity-tmp-dir/json-data/element-plus/add-edit.json create mode 100644 velocity-tmp-dir/json-data/element-plus/detail.json create mode 100644 velocity-tmp-dir/json-data/element-plus/table-query.json diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/controller/ElementPlusController.java b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/ElementPlusController.java new file mode 100644 index 0000000..7cb56b2 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/ElementPlusController.java @@ -0,0 +1,68 @@ +package top.kuanghua.basisfunc.controller; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; +import top.kuanghua.basisfunc.service.ElementPlusService; +import top.kuanghua.basisfunc.utils.GeneratorTempUtils; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +/** + * 生成代码控制层 + * @author 邝华 + * @email kuanghua@aulton.com + * @date 2022-06-06 13:39 + * @Copyright Copyright (c) aulton Inc. All Rights Reserved. + **/ +@Api(tags = "element-plus代码生成") +@RestController +@RequestMapping("element-plus") +public class ElementPlusController { + @Resource + private ElementPlusService elementPlusService; + + @PostMapping("querySearchTmp") + @ApiOperation(value = "查询模板生成") + public void querySearchTmp(HttpServletResponse response, @RequestBody Map generatorData) { + //生成模板 + String exportFilePath = this.elementPlusService.generatorTableQuery(generatorData); + response.setContentType("application/zip"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Access-Control-Expose-Headers", "exportFileName"); + response.setHeader("exportFileName", "querySearchTmp-"+ ObjSelfUtils.getCurrentDateTimeTrim()+".zip"); + //你压缩包路径 + GeneratorTempUtils.downloadZip(response, exportFilePath); + } + + + @PostMapping("addEdit") + @ApiOperation(value = "添加编辑生成") + public void addEditTmp(HttpServletResponse response, @RequestBody Map generatorData) { + //生成模板 + String exportFilePath = this.elementPlusService.generatorAddEdit(generatorData); + response.setContentType("application/zip"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Access-Control-Expose-Headers", "exportFileName"); + response.setHeader("exportFileName", "addEdit-"+ObjSelfUtils.getCurrentDateTimeTrim()+".zip"); + //你压缩包路径 + GeneratorTempUtils.downloadZip(response, exportFilePath); + } + + + @PostMapping("detail") + @ApiOperation(value = "详情模板生成") + public void detailTmp(HttpServletResponse response, @RequestBody Map generatorData) { + //生成模板 + String exportFilePath = this.elementPlusService.generatorDetail(generatorData); + response.setContentType("application/zip"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Access-Control-Expose-Headers", "exportFileName"); + response.setHeader("exportFileName", "detail-"+ObjSelfUtils.getCurrentDateTimeTrim()+".zip"); + //你压缩包路径 + GeneratorTempUtils.downloadZip(response, exportFilePath); + } +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/controller/GeneratorConfigSaveController.java b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/GeneratorConfigSaveController.java new file mode 100644 index 0000000..184fd20 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/GeneratorConfigSaveController.java @@ -0,0 +1,119 @@ +package top.kuanghua.basisfunc.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; +import top.kuanghua.basisfunc.entity.GeneratorConfigSave; +import top.kuanghua.basisfunc.service.GeneratorConfigSaveService; +import top.kuanghua.commonpom.entity.ResResult; +import top.kuanghua.commonpom.entity.SelfCommonParams; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 代码生成配置保存Controller + * + * @author 熊猫哥 + * @since 2022-07-20 10:10:28 + */ +@Api(tags = "配置信息") +@RestController +@CrossOrigin +@RequestMapping("generatorConfigSave") +public class GeneratorConfigSaveController { + + @Resource + private GeneratorConfigSaveService generatorConfigSaveService; + + /** + * 分页查询所有数据 + * + * @param generatorConfigSave 查询实体 + * @return ResResult + */ + @GetMapping("selectPage") + @ApiOperation(value = "分页查询所有数据") + + public ResResult selectPage(GeneratorConfigSave generatorConfigSave, SelfCommonParams commonParams) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + //选中的字段配置 + if (ObjSelfUtils.isNotEmpty(generatorConfigSave.getName())) { + queryWrapper.like("name", generatorConfigSave.getName()); + } + //生成的配置 + queryWrapper.orderByDesc("id"); + queryWrapper.select("id,name,generator_config"); + + Page generatorConfigSavePage = this.generatorConfigSaveService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); + return new ResResult().success(generatorConfigSavePage); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("selectById") + @ApiOperation(value = "通过id主键查询单条数据") + public ResResult selectById(@RequestParam("id") Integer id) { + return new ResResult().success(this.generatorConfigSaveService.selectById(id)); + } + + /** + * @Description: 根据id数组查询品牌列表 + * @Param: idList id数组 + * @return: ids列表数据 + */ + @ApiOperation(value = "根据id数组查询品牌列表") + @PostMapping("selectBatchIds") + public ResResult selectBatchIds(@RequestParam("idList") List idList) { + return new ResResult().success(this.generatorConfigSaveService.selectBatchIds(idList)); + } + + + /** + * 新增数据 + * + * @param generatorConfigSave 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping("insert") + public ResResult insert(@RequestBody GeneratorConfigSave generatorConfigSave) { + return new ResResult().success(this.generatorConfigSaveService.insert(generatorConfigSave)); + } + + /** + * 修改数据 + * + * @param generatorConfigSave 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "根据id修改数据") + @PutMapping("updateById") + public ResResult updateById(@RequestBody GeneratorConfigSave generatorConfigSave) { + return new ResResult().success(this.generatorConfigSaveService.updateById(generatorConfigSave)); + } + + /** + * 删除数据 + * + * @param idList 主键结合 + * @return 删除结果 + */ + @ApiOperation(value = "根据id数组删除数据") + @DeleteMapping("deleteBatchIds") + public ResResult deleteBatchIds(@RequestBody List idList) { + return new ResResult().success(this.generatorConfigSaveService.deleteBatchIds(idList)); + } + + @DeleteMapping("deleteById") + public ResResult deleteById(@RequestParam("id") Integer id) { + return new ResResult().success(this.generatorConfigSaveService.deleteById(id)); + } +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/entity/GeneratorConfigSave.java b/basis-func/src/main/java/top/kuanghua/basisfunc/entity/GeneratorConfigSave.java new file mode 100644 index 0000000..31dd20f --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/entity/GeneratorConfigSave.java @@ -0,0 +1,35 @@ +package top.kuanghua.basisfunc.entity; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** +* 代码生成配置保存实体类 +* +* @author 熊猫哥 +* @since 2022-07-20 10:10:28 +*/ +@Data +@ApiModel("代码生成配置保存") +@TableName(value = "t_config_save") +public class GeneratorConfigSave extends Model< GeneratorConfigSave > { + @ApiModelProperty(value = "") + private Integer id; + @ApiModelProperty(value = "选中的字段配置") + private String name; + @ApiModelProperty(value = "生成的配置") + private String generatorConfig; +/** +* 获取主键值 +* +* @return 主键值 +*/ +@Override +protected Serializable pkVal() { +return this.id; +} +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/mapper/GeneratorConfigSaveMapper.java b/basis-func/src/main/java/top/kuanghua/basisfunc/mapper/GeneratorConfigSaveMapper.java new file mode 100644 index 0000000..c4b31d8 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/mapper/GeneratorConfigSaveMapper.java @@ -0,0 +1,14 @@ +package top.kuanghua.basisfunc.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.basisfunc.entity.GeneratorConfigSave; + +/** +* 代码生成配置保存Mapper +* +* @author 熊猫哥 +* @since 2022-07-20 10:10:28 +*/ +public interface GeneratorConfigSaveMapper extends BaseMapper { + +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/service/ElementPlusService.java b/basis-func/src/main/java/top/kuanghua/basisfunc/service/ElementPlusService.java new file mode 100644 index 0000000..f784149 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/service/ElementPlusService.java @@ -0,0 +1,166 @@ +package top.kuanghua.basisfunc.service; + +import com.alibaba.fastjson.JSON; +import org.apache.velocity.Template; +import org.apache.velocity.context.Context; +import org.springframework.stereotype.Service; +import top.kuanghua.basisfunc.utils.GeneratorTempUtils; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Map; + +/** + * @author 猫哥 + * @date 2022-06-06 13:31 + **/ +@Service +public class ElementPlusService { + /** + * 生成查询表格和请求api模板 + * @param jsonData 前端传入的json数据 + * @return 导出zip的路径 + * @author 邝华 + * @email kuanghua@aulton.com + * @date 2022-06-10 9:59 + */ + public String generatorTableQuery(Map jsonData) { + try { + Context context = GeneratorTempUtils.getVelocityContext(); + context.put("configData", jsonData); + context.put("basicConfig", jsonData.get("basicConfig")); + context.put("apiConfig", jsonData.get("apiConfig")); + context.put("queryConfig", jsonData.get("queryConfig")); + context.put("tableConfig", jsonData.get("tableConfig")); + context.put("tableList", jsonData.get("tableList")); + Map basicConfig = ObjSelfUtils.changeToMap(jsonData.get("basicConfig")); + String pageName=basicConfig.get("apiFileNameFirstCase").toString(); + //table-query + Template template = GeneratorTempUtils.getElementPlusTemp("tableQuery.vm"); + FileWriter fileWriter = new FileWriter(GeneratorTempUtils.getExportFileDir() +pageName+"TableQuery.vue"); + template.merge(context, fileWriter); + fileWriter.close(); + //reqApi.vm + Template reqApiTemplateModal = GeneratorTempUtils.getElementPlusTemp("queryApi.vm"); + FileWriter reqApiTemplateWriter = new FileWriter(GeneratorTempUtils.getExportFileDir() +pageName+".js"); + reqApiTemplateModal.merge(context, reqApiTemplateWriter); + reqApiTemplateWriter.close(); + + + //tableQueryIndex.vm + Template tableQueryIndexModal = GeneratorTempUtils.getElementPlusTemp("tableQueryIndex.vm"); + FileWriter tableQueryIndexWriter = new FileWriter(GeneratorTempUtils.getExportFileDir() +"index.ts"); + tableQueryIndexModal.merge(context, tableQueryIndexWriter); + tableQueryIndexWriter.close(); + + //routerItem.vm + Template routerItemModal = GeneratorTempUtils.getElementPlusTemp("routerItem.vm"); + FileWriter routerItemWriter = new FileWriter(GeneratorTempUtils.getExportFileDir() +"routerItem.ts"); + routerItemModal.merge(context, routerItemWriter); + routerItemWriter.close(); + + //导出文件路径 + String exportFilePath=GeneratorTempUtils.getOutputZipPath() + pageName+ ObjSelfUtils.getCurrentDateTimeTrim()+".zip"; + + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + return exportFilePath; + } catch (IOException e) { + throw new RuntimeException("前端导出模板报错"+e); + } + } + + + + //生成新增和编辑模板 + public String generatorAddEdit(Map jsonData) { + try { + Context context = GeneratorTempUtils.getVelocityContext(); + context.put("configData", jsonData); + context.put("basicConfig", jsonData.get("basicConfig")); + context.put("apiConfig", jsonData.get("apiConfig")); + context.put("tableList", jsonData.get("tableList")); + Map basicConfig = ObjSelfUtils.changeToMap(jsonData.get("basicConfig")); + String pageName=basicConfig.get("apiFileNameFirstCase").toString(); + //add-edit + Template template = GeneratorTempUtils.getElementPlusTemp("addEdit.vm"); + FileWriter fileWriter = new FileWriter(GeneratorTempUtils.getExportFileDir() +pageName+"AddEdit.vue"); + template.merge(context, fileWriter); + fileWriter.close(); + //reqApi.vm + Template reqApiTemplateModal = GeneratorTempUtils.getElementPlusTemp("AddEditApi.vm"); + FileWriter reqApiTemplateWriter = new FileWriter(GeneratorTempUtils.getExportFileDir() +pageName+"AddEdit.js"); + reqApiTemplateModal.merge(context, reqApiTemplateWriter); + reqApiTemplateWriter.close(); + + //add-edit-table + ArrayList> mapArrayList = ObjSelfUtils.changeToArrayMap(jsonData.get("tableList")); + mapArrayList.forEach((listItem) -> { + if ("table".equals(listItem.get("componentType"))) { + context.put("tableListConfig",listItem.get("tableListConfig")); + try { + Template addTableTemplate= GeneratorTempUtils.getElementPlusTemp("add-edit-table.vm"); + FileWriter fileWriterAddTable = new FileWriter(GeneratorTempUtils.getExportFileDir() +listItem.get("columnName")+"-add-edit-table.vue"); + addTableTemplate.merge(context, fileWriterAddTable); + fileWriterAddTable.close(); + + //reqApi.vm + Template reqApiModal = GeneratorTempUtils.getElementPlusTemp("add-edit-table-api.vm"); + FileWriter reqApiWriter = new FileWriter(GeneratorTempUtils.getExportFileDir() +pageName+"-add-edit-table.js"); + reqApiModal.merge(context, reqApiWriter); + reqApiWriter.close(); + } catch (IOException e) { + throw new RuntimeException("生成模板报错"+e); + } + } + }); + String exportFilePath=GeneratorTempUtils.getOutputZipPath() + pageName+ ObjSelfUtils.getCurrentDateTimeTrim()+".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + return exportFilePath; + } catch (IOException e) { + throw new RuntimeException("前端导出模板报错"+e); + } + } + + /** + * 生成详情数据 + * @param jsonData 前端传入的json数据 + * @return 导出zip的路径 + * @author 邝华 + * @email kuanghua@aulton.com + * @date 2022-06-10 9:59 + */ + public String generatorDetail(Map jsonData) { + try { + Context context = GeneratorTempUtils.getVelocityContext(); + context.put("configData", jsonData); + context.put("basicConfig", jsonData.get("basicConfig")); + context.put("apiConfig", jsonData.get("apiConfig")); + context.put("tableConfigArr", jsonData.get("tableConfigArr")); + Map basicConfig = ObjSelfUtils.changeToMap(jsonData.get("basicConfig")); + String pageName=basicConfig.get("apiFileNameFirstCase").toString(); + //detail + Template template = GeneratorTempUtils.getElementPlusTemp("detail.vm"); + FileWriter fileWriter = new FileWriter(GeneratorTempUtils.getExportFileDir() +pageName+"Detail.vue"); + template.merge(context, fileWriter); + fileWriter.close(); + + //reqApi.vm + Template reqApiTemplateModal = GeneratorTempUtils.getElementPlusTemp("detailApi.vm"); + FileWriter reqApiTemplateWriter = new FileWriter(GeneratorTempUtils.getExportFileDir() +pageName+"Detail.js"); + reqApiTemplateModal.merge(context, reqApiTemplateWriter); + reqApiTemplateWriter.close(); + + String exportFilePath=GeneratorTempUtils.getOutputZipPath() + pageName+ ObjSelfUtils.getCurrentDateTimeTrim()+".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + return exportFilePath; + } catch (IOException e) { + throw new RuntimeException("前端导出模板报错"+e); + } + } + +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorConfigSaveService.java b/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorConfigSaveService.java new file mode 100644 index 0000000..61a2613 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorConfigSaveService.java @@ -0,0 +1,60 @@ +package top.kuanghua.basisfunc.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Service; +import top.kuanghua.basisfunc.entity.GeneratorConfigSave; +import top.kuanghua.basisfunc.mapper.GeneratorConfigSaveMapper; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 代码生成配置保存Service + * + * @author 熊猫哥 + * @since 2022-07-20 10:10:28 + */ +@Service +public class GeneratorConfigSaveService { + + @Resource + private GeneratorConfigSaveMapper generatorConfigSaveMapper; + + public Page selectPage(Integer pageNum, Integer pageSize, QueryWrapper queryWrapper) { + return this.generatorConfigSaveMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); + } + + public GeneratorConfigSave selectById(Integer id) { + return this.generatorConfigSaveMapper.selectById(id); + } + + public List selectBatchIds(List idList) { + return this.generatorConfigSaveMapper.selectBatchIds(idList); + } + + public int insert(GeneratorConfigSave generatorConfigSave) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + //选中的字段配置 + if (ObjSelfUtils.isNotEmpty(generatorConfigSave.getName())) { + queryWrapper.like("name", generatorConfigSave.getName()); + } + if(ObjSelfUtils.isNotEmpty(generatorConfigSaveMapper.selectOne(queryWrapper))){ + throw new RuntimeException(generatorConfigSave.getName()+"已存在"); + } + return this.generatorConfigSaveMapper.insert(generatorConfigSave); + } + + public int updateById(GeneratorConfigSave generatorConfigSave) { + return this.generatorConfigSaveMapper.updateById(generatorConfigSave); + } + + public int deleteById(Integer id) { + return this.generatorConfigSaveMapper.deleteById(id); + } + + public int deleteBatchIds(List idList) { + return this.generatorConfigSaveMapper.deleteBatchIds(idList); + } +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java b/basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java index 799bb7d..4329775 100644 --- a/basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java @@ -29,7 +29,7 @@ public class GeneratorTempUtils { //velocity tools配置文件路径 public static final String ToolManagerConfigPath = "velocity-tools.xml"; - public static final String VelocityTemplateDir = "D:\\github\\velocity-tmp-dir\\"; + public static final String VelocityTemplateDir = "D:\\github\\micro-service-plus\\velocity-tmp-dir\\"; public static final String VelocityTemplateDirMac = "/deploy/velocity-tmp-dir/"; public static final String ElementPlusDir = "front-vms" + File.separator + "element-plus"; public static final String MybatisPlusDir = "back-vms" + File.separator + "mybatis-plus"; diff --git a/basis-func/src/main/resources/application-db.yml b/basis-func/src/main/resources/application-db.yml index 842d8ed..6cf2856 100644 --- a/basis-func/src/main/resources/application-db.yml +++ b/basis-func/src/main/resources/application-db.yml @@ -5,8 +5,12 @@ spring: username: root password: root123 hikari: - max-lifetime: 28830000 # 一个连接的生命时长(毫秒),超时而且没被使用则被释放(retired),缺省:30分钟,建议设置比数据库超时时长少30秒,参考MySQL wait_timeout参数(show variables like '%timeout%';) - maximum-pool-size: 9 # 连接池中允许的最大连接数。缺省值:10;推荐的公式:((core_count * 2) + effective_spindle_count) + connection-timeout: 2000 #最大超时时间 + maximum-pool-size: 100 #连接数 + max-lifetime: 1800000 #控制池中连接的最大生存期 + minimum-idle: 10 #此属性控制 HikariCP尝试在池中维护的最小空闲连接数 + validation-timeout: 1000 #此属性控制测试连接是否活跃的最长时间。此值必须小于 connectionTimeout + idle-timeout: 60000 #此属性控制允许连接在池中处于空闲状态的最长时间 mybatis-plus: mapper-locations: classpath:/mapper/*Mapper.xml diff --git a/basis-func/src/test/java/top/kuanghua/basisfunc/service/ElementPlusServiceTest.java b/basis-func/src/test/java/top/kuanghua/basisfunc/service/ElementPlusServiceTest.java new file mode 100644 index 0000000..6bebd77 --- /dev/null +++ b/basis-func/src/test/java/top/kuanghua/basisfunc/service/ElementPlusServiceTest.java @@ -0,0 +1,45 @@ +package top.kuanghua.basisfunc.service; + +import com.alibaba.fastjson.JSON; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import top.kuanghua.basisfunc.utils.GeneratorTempUtils; + +import java.io.IOException; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * @Title: ElementPlusServiceTest + * @Description: + * @Auther: kuanghua + * @create 2022/10/1 15:59 + */ +public class ElementPlusServiceTest { + @Test + public void generatorTableQuery() throws IOException { + String string = GeneratorTempUtils.readFileToString("D:\\github\\micro-service-plus\\velocity-tmp-dir\\json-data\\element-plus\\" + "table-query.json"); + Map jsonData = JSON.parseObject(string, Map.class); + ElementPlusService elementPlusService = new ElementPlusService(); + elementPlusService.generatorTableQuery(jsonData); + } + @Test + public void generatorAddEdit() throws IOException { + String string = GeneratorTempUtils.readFileToString("D:\\github\\micro-service-plus\\velocity-tmp-dir\\json-data\\element-plus\\" + "add-edit.json"); + Map jsonData = JSON.parseObject(string, Map.class); + ElementPlusService elementPlusService = new ElementPlusService(); + elementPlusService.generatorAddEdit(jsonData); + } + @Test + public void generatorDetail() throws IOException { + String string = GeneratorTempUtils.readFileToString("D:\\github\\micro-service-plus\\velocity-tmp-dir\\json-data\\element-plus\\" + "detail.json"); + Map jsonData = JSON.parseObject(string, Map.class); + ElementPlusService elementPlusService = new ElementPlusService(); + elementPlusService.generatorDetail(jsonData); + } + + +} \ No newline at end of file diff --git a/front-template/aulton-asset/base-model-add-model.vm b/front-template/aulton-asset/base-model-add-model.vm new file mode 100644 index 0000000..197250d --- /dev/null +++ b/front-template/aulton-asset/base-model-add-model.vm @@ -0,0 +1,96 @@ +#parse("formUtils.vm") + + + + + \ No newline at end of file diff --git a/front-template/aulton-asset/base-model-index.vm b/front-template/aulton-asset/base-model-index.vm new file mode 100644 index 0000000..ef38896 --- /dev/null +++ b/front-template/aulton-asset/base-model-index.vm @@ -0,0 +1,141 @@ +#parse("queryUtils.vm") +#parse("tableUtils.vm") + + + + + diff --git a/front-template/aulton-asset/base-template.vm b/front-template/aulton-asset/base-template.vm new file mode 100644 index 0000000..862444d --- /dev/null +++ b/front-template/aulton-asset/base-template.vm @@ -0,0 +1,55 @@ +#parse("queryUtils.vm") +#parse("tableUtils.vm") +#parse("formUtils.vm") + + \ No newline at end of file diff --git a/front-template/aulton-asset/formUtils.vm b/front-template/aulton-asset/formUtils.vm new file mode 100644 index 0000000..dbd979f --- /dev/null +++ b/front-template/aulton-asset/formUtils.vm @@ -0,0 +1,291 @@ +##生成form item +#macro(formItemTemp) +#foreach($item in $formConfig) + #if($item.componentType=="input") ##输入框 input + + + + #elseif($item.componentType=="textarea") ##多行文本框 textarea + + + + #elseif($item.componentType=="radio") ##单选框 radio + + + #foreach($enum in $item.optionDataArr) + ${enum.label} + #end + + + #elseif($item.componentType=="select") ##select + + + #foreach($enum in $item.optionDataArr) + + #end + + + #elseif($item.componentType=="selectApi") ##selectApi + + + + + + + #elseif($item.componentType=="checkbox") ##多选框 checkbox + + + #foreach($enum in $item.optionDataArr) + + #end + + + #elseif($item.componentType=="switch") ##开关 switch + + + + #elseif($item.componentType=="date") ##日期选择 datePicker + + + + #elseif($item.componentType=="time") ##时间选择 timePicker + + + + #elseif($item.componentType=="datetime") ##日期选择 dateTime + + + + #elseif($item.componentType=="datetimerange") ##日期时间选择 dateTimePicker + + + + #elseif($item.componentType=="upload") ##上传组件 upload + + + + + + + + #elseif($item.componentType=="specialDict") ##specialDict + + + + #elseif($item.componentType=="specialMulti") ##specialMulti + + + + #end +#end +#end +##生成form key +#macro(fromKeyData) +#foreach($item in $formConfig) +$item.field:"", +#end +#end +##生成 rule校验 +#macro(rulesData) +#foreach($item in $formConfig) +#if($item.rule=="isNotNull")##必填 +$item.field:{required: true,message:"请输入${item.desc}",trigger:["blur", "change"]}, +#elseif ($item.rule=="positiveInteger")##整数 +$item.field:[{required: true, message: "请输入${item.desc}", trigger: "blur"},{pattern: +/^[0-9]\d*$/,message: "${item.desc}为整数",trigger: "blur",}], +#elseif ($item.rule=="positiveIntegerNotZero")##大于O的整数 +$item.field:[{required: true, message: "请输入${item.desc}", trigger: "blur"},{pattern: +/^\+?[1-9]\d*$/,message: "${item.desc}为正整数",trigger: "blur",}], +#elseif ($item.rule=="regEmail")##邮箱 +$item.field:[{required: true, message: "请输入${item.desc}", trigger: "blur"},{pattern: +/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/,message: "${item.desc}校验失败",trigger: "blur",}], +#elseif ($item.rule=="idCardNumber")##身份证 +$item.field:[{required: true, message: "请输入${item.desc}", trigger: "blur"},{pattern: +/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,message: "${item.desc}校验失败",trigger: "blur",}], +#elseif ($item.rule=="mobilePhone")##手机号 +$item.field:[{required: true, message: "请输入${item.desc}", trigger: "blur"},{pattern: +/^0?1[0-9]{10}$/,message: "${item.desc}校验失败",trigger: "blur",}], +#elseif ($item.rule=="bankCardNo")##银行卡号 +$item.field:[{required: true, message: "请输入${item.desc}", trigger: "blur"},{pattern: +/^\d{15,20}$/,message: "${item.desc}校验失败",trigger: "blur",}], + +#end +#end +#end +##生成data +#macro(formDataScript) +#foreach($item in $formConfig) +#if($item.componentType=="selectApi") ##输入框 input +${item.field}Data:[], +#elseif($item.componentType=="date") ##日期选择 datePicker +#elseif($item.componentType=="time") ##时间选择 timePicker +#elseif($item.componentType=="datetime") ##日期时间选择 dateTimePicker +#elseif($item.componentType=="upload") ##上传组件 upload +fileOptions: [ + { + type: 'upload', + label: '合同正文', + prop: 'pic', + uploadAttrs: { + action: 'https://jsonplaceholder.typicode.com/posts/', + multiple: true, + limit: 3 + }, + rules: [ + { + required: true, + message: '上传合同正文', + trigger: 'blur' + } + ] + }, + #end + #end +#end +##生成method +#macro(formMethodScript) + #foreach($item in $formConfig) + #if($item.compoentType=="selectApi") ##输入框 input + this.${item.field}Req(){ + this.$api.${frontConfig.apiFileName}.${item.field}FormReq().then((response) => { + this.${item.field}Data = response.data; + }) + } + }, + #elseif($item.componentType=="specialDict") ##specialDict + ${item.field}Change(code) { + const dictItem = getDictItemsFromCache('$!item.dictCode') + dictItem.map((item) => { + if (item.code === String(code)) { + this.form.${item.field} = item.name + } + }) + }, + #elseif($item.componentType=="specialMulti") ##specialMulti + ${item.field}Change(code) { + const dictItem = getDictItemsFromCache('$!item.dictCode') + dictItem.map((item) => { + if (item.code === String(code)) { + this.form.${item.field} = item.name + } + }) + }, + #elseif($item.componentType=="date") ##日期选择 datePicker + #elseif($item.componentType=="time") ##时间选择 timePicker + #elseif($item.componentType=="datetime") ##日期时间选择 dateTimePicker + #elseif($item.componentType=="upload") ##上传组件 upload + #end + #end +#end +##生成mounted +#macro(formMountedScript) + #foreach($item in $formConfig) + #if($item.componentType=="selectApi") ##输入框 selectApi + this.${item.field}Req() + #elseif($item.componentType=="date") ##日期选择 datePicker + #elseif($item.componentType=="time") ##时间选择 timePicker + #elseif($item.componentType=="dateTime") ##日期时间选择 dateTimePicker + #elseif($item.componentType=="upload") ##上传组件 upload + #end + #end +#end +##生成详情请求接口 +#macro(detailReq) +this.$api.${frontConfig.apiFileName}.${frontConfig.apiFileName}Detail(data).then((response) => { +this.formData = response.data; +this.status = true; +}).catch(() => { +}); +#end +##生成保存请求接口 +#macro(insertReq) +this.$api.${frontConfig.apiFileName}.${frontConfig.apiFileName}Insert(data).then((response) => { +if (response.code === "200") { +this.$message.success("保存成功"); +this.status = false; +this.successStatus = true; +} +}); +#end + +##生成更新请求接口 +#macro(updateReq) +this.$api.${frontConfig.apiFileName}.${frontConfig.apiFileName}Update(data).then((response) => { +if (response.code === "200") { +this.$message.success("更新成功"); +this.status = false; +this.successStatus = true; +} +}); +#end diff --git a/front-template/aulton-asset/queryUtils.vm b/front-template/aulton-asset/queryUtils.vm new file mode 100644 index 0000000..68e23db --- /dev/null +++ b/front-template/aulton-asset/queryUtils.vm @@ -0,0 +1,94 @@ +#parse("utils.vm") +#groupArrByKey($queryConfig,"controlType") +##queryItem +#macro(queryItemScript) +#foreach($entry in $gabkMap.entrySet()) + #if($entry.key=="elDataPicker") + #set($evItem=$entry.value[0]) + $entry.key:{ + label: "$evItem.desc", + dateRange: ['', ''], + type: 'daterange', + beginDate: '$evItem.field', + //endDate: 'stationOpenEndDate' + }, + #else + $entry.key:[ + #foreach($item in $entry.value) + #if($item.componentType=="input") + { + label: "$item.desc", + key: "$item.field", + placeholder: "请输入${item.desc}", + }, + #elseif($item.componentType=="select") + { + label: "$item.desc", + key: '$item.field', + option: [ + #foreach($odItem in $item.optionDataArr) + { + key: "$odItem.value", + value: "$odItem.label" + }, + #end + ] + }, + #elseif($item.componentType=="selectApi") + { + label: "$item.desc", + key: '$item.field', + option: this.${item.field}Data + }, + #elseif($item.componentType=="selectDict") + { + label: "$item.desc", + key: "$item.field", + componentType:"$item.componentType", + dictCode: "$!item.dictCode", + }, + #elseif($item.componentType=="specialDict") + { + label: "$item.desc", + key: "$item.field", + type: '$!item.type', + componentType:"$item.componentType", + dictCode: "$!item.dictCode", + selectProps: { + value: 'name', + label: 'code' + } + }, + #end + #end + ], + #end + #end +#end +##data +#macro(queryDataScript) + #foreach($qcItem in $queryConfig) + #if($qcItem.componentType=="selectApi") + ${qcItem.field}Data:[], + #end + #end +#end +##method +#macro(queryMethodScript) + #foreach($qcItem in $queryConfig) + #if($qcItem.componentType=="selectApi") + this.$api.${frontConfig.apiFileName}.${qcItem.fielnd}QueryReq().then((response) => { + this.${qcItem.field}Data = response.data; + }).catch(() => {}); + }, + #end + #end +#end +##mounted +#macro(queryMountedScript) + #foreach($qcItem in $queryConfig) + #if($qcItem.componentType=="selectApi") + this.${qcItem.field}Req() + #end + #end +#end \ No newline at end of file diff --git a/front-template/aulton-asset/req-api.vm b/front-template/aulton-asset/req-api.vm new file mode 100644 index 0000000..f137798 --- /dev/null +++ b/front-template/aulton-asset/req-api.vm @@ -0,0 +1,82 @@ +import request from '@/lib/axios' +/** +*${frontConfig.apiFileName}查询数据 +* @param {*} params +*/ +export const ${frontConfig.apiFileName}Query = (params) => { +return request('${apiConfig.queryApi}', { +params: params, +method: '${apiConfig.queryApiType}' +}) +} +/** +* +* @param {*} data +*/ +export const ${frontConfig.apiFileName}Insert = (data) => { +return request('${apiConfig.insertApi}', { +data: data, +method: '${apiConfig.insertApiType}' +}) +} + +/** +*${frontConfig.apiFileName}更新接口 +* @param {*} data json数据 +*/ +export const ${frontConfig.apiFileName}Update = (data) => { +return request('${apiConfig.updateApi}', { +data: data, +method: '${apiConfig.updateApiType}' +}) +} +/** +*${frontConfig.apiFileName}详情 +* @param {*} params +*/ +export const ${frontConfig.apiFileName}Detail = (params) => { +return request('${apiConfig.detailApi}', { +params: params, +method: '${apiConfig.detailApiType}' +}) +} +/** +* ${frontConfig.apiFileName}删除接口 +* @param {*} params +*/ +export const ${frontConfig.apiFileName}Delete = (params) => { +return request('${apiConfig.deleteApi}', { +params: params, +method: '${apiConfig.deleteApiType}' +}) +} +##生成queryItem里的api查询接口 +#foreach($item in $queryConfig) + #if($item.compoentType=="selectApi") ##输入框 input + /** + * ${item.desc}接口 + * @param {*} params + */ + export const ${item.fielnd}QueryReq = () => { + return request('${item.api}', { + //params: params, + method: '${item.method}' + }) + } + #end +#end +##生成formItem里的api查询接口 +#foreach($item in $formConfig) + #if($item.compoentType=="selectApi") ##输入框 input + /** + * ${item.desc}接口 + * @param {*} params + */ + export const ${item.fielnd}FormReq = () => { + return request('${item.api}', { + //params: params, + method: '${item.requestType}' + }) + } + #end +#end diff --git a/front-template/aulton-asset/tableUtils.vm b/front-template/aulton-asset/tableUtils.vm new file mode 100644 index 0000000..72b3f4f --- /dev/null +++ b/front-template/aulton-asset/tableUtils.vm @@ -0,0 +1,88 @@ +##column +#macro(tableColumnScript) +#foreach($item in $tableConfig) + #if($foreach.count==1) + { + label: '$item.desc', + prop: '$item.field', + 'min-width': "$!item.width", + align: 'left' + }, + #else + { + label: '$item.desc', + prop: '$item.field', + 'min-width': "$!item.width", + }, + #end + #end +#end +##tableDataReq +#macro(tableDataReq) +this.$api.${frontConfig.apiFileName}.${frontConfig.apiFileName}Query(data).then((response) => { +this.dataSource.data = response.data +this.dataSource.pageData.total = response.total +}) +.catch(() => { +}) +#end +##deleteReq +#macro(deleteReq) +this.$api.${frontConfig.apiFileName}.${frontConfig.apiFileName}Delete(data).then((response) => { +if (response.code === "200") { +this.$message.success("删除成功"); +this.status = false; +this.successStatus = true; +} +}); +#end +##dataSourceTool +#macro(tableDataSourceTool) +tool: [ + #if($frontConfig.tableNeedExport) + { + name: '导出', + handleClick: this.handleExport + }, + #end + #if($frontConfig.tableNeedImport) + { + btnName: '导入发货单', + modelExcelType: 'exportEquipmentSend', + importExcelType: 'importEquipmentSend', + component: 'Import' // 配置列表设置组件 + }, + #end +{ +component: 'Drag' // 配置列表设置组件 +} +], +#end +##tableScript +#macro(tableExportMethod) + #if($frontConfig.tableNeedExport) + handleExport() { + const params = JSON.parse(JSON.stringify(this.listQuery)) + params.pageIndex = 1 + params.pageSize = 1000 + // delete params.time + this.$request('$frontConfig.exportUrl', { + data: params + }).then((response) => { + this.$alert('请前往导出中心下载表格', '提交成功', { + confirmButtonText: '去下载表格', + callback: (action) => { + if (action === 'confirm') { + const rt=this.$router + rt.push({ + path: '/center/index', + query: { activeType: 2 } + }) + } + } + }) + }) + .catch(() => {}) + }, + #end +#end \ No newline at end of file diff --git a/front-template/aulton-asset/utils.vm b/front-template/aulton-asset/utils.vm new file mode 100644 index 0000000..9c6e786 --- /dev/null +++ b/front-template/aulton-asset/utils.vm @@ -0,0 +1,24 @@ +##根据数组某个key分组 +#macro(groupArrByKey $arrs $group_key) + #set($gabkMap={}) + #foreach($ai in $arrs) + #if(!$!gabkMap[$ai[$group_key]]) + #set($gabkMap[$ai[$group_key]] = [$ai]) + #else + #if($gabkMap[$ai[$group_key]].add($ai)) + #end + #end + #end +#end +##根据数组某个deep key分组 +#macro(groupArrByDeepKey $arrs $group_key $group_deep_key) + #set($gabkDeepMap={}) + #foreach($ai in $arrs) + #if(!$!gabkDeepMap[$ai[$group_key][$group_deep_key]]) + #set($gabkDeepMap[$ai[$group_key][$group_deep_key]] = [$ai]) + #else + #if($gabkDeepMap[$ai[$group_key][$group_deep_key]].add($ai)) + #end + #end + #end +#end \ No newline at end of file diff --git a/front-template/settlement/add-edit-api.vm b/front-template/settlement/add-edit-api.vm new file mode 100644 index 0000000..2491fe7 --- /dev/null +++ b/front-template/settlement/add-edit-api.vm @@ -0,0 +1,54 @@ +import request from '@/lib/axios' +/** +* +*${frontConfig.apiFileName}新增 +*/ +export const ${frontConfig.apiFileName}Insert = (data) => { + return request('${apiConfig.insertApi}', { + data: data, + method: '${apiConfig.insertMethod}' + }) +} + +/** +*${frontConfig.apiFileName}更新 +* @param {*} data json数据 +*/ +export const ${frontConfig.apiFileName}Update = (data) => { + return request('${apiConfig.updateApi}', { + data: data, + method: '${apiConfig.updateMethod}' + }) +} +##生成queryItem里的api查询接口 +#foreach($item in $queryConfig) + #if($item.componentType=="selectApi") ##输入框 input + /** + * ${item.desc}接口 + * @param {*} params + */ + export const ${item.field}Req = (data) => { + return request('${item.api}', { + data, + method: '${item.method}' + }) + } + #end +#end + + +##生成formItem里的api查询接口 +#foreach($item in $formConfig) + #if($item.compoentType=="selectApi") ##输入框 input + /** + * ${item.desc}接口 + * @param {*} data + */ + export const ${item.field}Req = (data) => { + return request('${item.api}', { + data, + method: '${item.method}' + }) + } + #end +#end diff --git a/front-template/settlement/add-edit-table-api.vm b/front-template/settlement/add-edit-table-api.vm new file mode 100644 index 0000000..e3417ca --- /dev/null +++ b/front-template/settlement/add-edit-table-api.vm @@ -0,0 +1,18 @@ +import request from '@/lib/axios' + + +##生成formItem里的api查询接口 +#foreach($item in $tableListConfig) + #if($item.compoentType=="selectApi") ##输入框 input + /** + * ${item.desc}接口 + * @param {*} data + */ + export const ${item.field}Req = (data) => { + return request('${item.api}', { + data, + method: '${item.method}' + }) + } + #end +#end diff --git a/front-template/settlement/add-edit-table-utils.vm b/front-template/settlement/add-edit-table-utils.vm new file mode 100644 index 0000000..5fb9ca9 --- /dev/null +++ b/front-template/settlement/add-edit-table-utils.vm @@ -0,0 +1,74 @@ +#macro(tableItemTemp) + #foreach($item in $tableListConfig) + #if($item.componentType=="input") ##输入框 input + + #if($item.isTemplate=="true") + + #end + + #elseif($item.componentType=="select") ##select + + #if($item.isTemplate=="true") + + #end + + #elseif($item.componentType=="selectApi") ##selectApi + + #if($item.isTemplate=="true") + + #end + + #end + #end +#end + + + +##生成data +#macro(formDataScript) + #foreach($item in $tableListConfig) + #if($item.componentType=="selectApi") ##输入框 input + ${item.field}Data:[], + ##elseif($item.componentType=="date") ##日期选择 datePicker + ##elseif($item.componentType=="time") ##时间选择 timePicker + #end + #end +#end + + +##生成method +#macro(formMethodScript) + #foreach($item in $tableListConfig) + #if($item.componentType=="selectApi") + ${item.field}Req(){ + this.globalApi.${frontConfig.apiFileName}.${item.field}Req().then(({data}) => { + this.${item.field}Data = data + }) + }, + #end + #end +#end +##生成mounted +#macro(formMountedScript) + #foreach($item in $tableListConfig) + #if($item.componentType=="selectApi") ##输入框 selectApi + this.${item.field}Req() + #end + #end +#end diff --git a/front-template/settlement/add-edit-table.vm b/front-template/settlement/add-edit-table.vm new file mode 100644 index 0000000..a5bbf83 --- /dev/null +++ b/front-template/settlement/add-edit-table.vm @@ -0,0 +1,78 @@ +#parse("add-edit-table-utils.vm") + + + + + + diff --git a/front-template/settlement/add-edit.vm b/front-template/settlement/add-edit.vm new file mode 100644 index 0000000..52db9bf --- /dev/null +++ b/front-template/settlement/add-edit.vm @@ -0,0 +1,68 @@ +#parse("formUtils.vm") + + + + + + diff --git a/front-template/settlement/detail-api.vm b/front-template/settlement/detail-api.vm new file mode 100644 index 0000000..2cca8cc --- /dev/null +++ b/front-template/settlement/detail-api.vm @@ -0,0 +1,8 @@ +/** +*${frontConfig.apiFileName}详情 +*/ +export const ${frontConfig.apiFileName}Detail = (id) => { + return request(`${apiConfig.detailApi}`, { + method: `${apiConfig.detailMethod}` + }) +} \ No newline at end of file diff --git a/front-template/settlement/detail.vm b/front-template/settlement/detail.vm new file mode 100644 index 0000000..fdabd7e --- /dev/null +++ b/front-template/settlement/detail.vm @@ -0,0 +1,51 @@ +#parse("detailUtils.vm") + + + + + diff --git a/front-template/settlement/detailUtils.vm b/front-template/settlement/detailUtils.vm new file mode 100644 index 0000000..eb3df17 --- /dev/null +++ b/front-template/settlement/detailUtils.vm @@ -0,0 +1,76 @@ +#macro(detailContainer) + #foreach($pItem in $tableConfigArr) + ## 横向 + #if($pItem.direction=="1") + +
+ #foreach($fItem in $pItem.dillColumnArr) +
+ #foreach($sItem in $fItem ) +
+
+ ${sItem.desc}: + #if($sItem.componentType=="input") ##input + {{detailData.$sItem.columnName}} + #elseif($sItem.componentType=="select") ##select + #foreach($enum in $sItem.optionDataArr) + ${enum.label} + #end + #end +
+
+ #end +
+ #end +
+
+ #end + ## 纵向 + #if($pItem.direction=="2") + + #foreach($fItem in $pItem.dillColumnArr) +
+ #foreach($sItem in $fItem ) +
+ ${sItem.desc}: + #if($sItem.componentType=="input") ##input + {{detailData.$sItem.columnName}} + #elseif($sItem.componentType=="select") ##select + #foreach($enum in $sItem.optionDataArr) + ${enum.label} + #end + #end +
+ #end +
+ #end +
+ #end + ## 表格 + #if($pItem.direction=="3") + + + #foreach($fItem in $pItem.dillColumnArr) + #if($fItem.isTemplate==true) + + + + #else + + #end + #end + + + #end + #end +#end diff --git a/front-template/settlement/formUtils.vm b/front-template/settlement/formUtils.vm new file mode 100644 index 0000000..282a602 --- /dev/null +++ b/front-template/settlement/formUtils.vm @@ -0,0 +1,156 @@ +##生成form item +#macro(formItemTemp) +#foreach($item in $tableList) + #if($item.componentType=="input") ##输入框 input + + + + #elseif($item.componentType=="textarea") ##多行文本框 textarea + + + + #elseif($item.componentType=="radio") ##单选框 radio + + + #foreach($enum in $item.optionDataArr) + ${enum.label} + #end + + + #elseif($item.componentType=="select") ##select + + + #foreach($enum in $item.optionDataArr) + + #end + + + #elseif($item.componentType=="selectApi") ##selectApi + + + + + + + #elseif($item.componentType=="checkbox") ##多选框 checkbox + + + #foreach($enum in $item.optionDataArr) + + #end + + + #elseif($item.componentType=="switch") ##开关 switch + + + + #elseif($item.componentType=="date") ##日期选择 datePicker + + + + #elseif($item.componentType=="daterange") ##日期时间选择 dateTimePicker + + + + #elseif($item.componentType=="uploadImage") ##上传组件 upload + + + + #elseif($item.componentType=="table") ##上传组件 upload + + + + #end +#end +#end +##生成form key +#macro(fromKeyData) + #foreach($item in $tableList) + $item.field:"", //$item.desc + #end +#end + +##生成import +#macro(subFormImport) + #foreach($item in $tableList) + #if($item.componentType=="table") ##输入框 input + import AddEditTable from './add-edit-table.vue' + #end + #end +#end + +##生成component +#macro(subFormComponent) + #foreach($item in $tableList) + #if($item.componentType=="table") ##输入框 input + AddEditTable, + #end + #end +#end + +##生成data +#macro(formDataScript) + #foreach($item in $tableList) + #if($item.componentType=="selectApi") ##输入框 input + ${item.field}Data:[], + ##elseif($item.componentType=="date") ##日期选择 datePicker + ##elseif($item.componentType=="time") ##时间选择 timePicker + #end + #end +#end + + +##生成method +#macro(formMethodScript) + #foreach($item in $tableList) + #if($item.componentType=="selectApi") + ${item.field}Req(){ + this.globalApi.${frontConfig.apiFileName}.${item.field}Req().then(({data}) => { + this.${item.field}Data = data + }) + }, + #end + #end +#end +##生成mounted +#macro(formMountedScript) + #foreach($item in $tableList) + #if($item.componentType=="selectApi") ##输入框 selectApi + this.${item.field}Req() + #end + #end +#end + diff --git a/front-template/settlement/queryApi.vm b/front-template/settlement/queryApi.vm new file mode 100644 index 0000000..a79ee3a --- /dev/null +++ b/front-template/settlement/queryApi.vm @@ -0,0 +1,39 @@ +import request from '@/lib/axios' +/** +* ${frontConfig.apiFileName}查询 +* @param {*} data +*/ +export const tableQuery = (data) => { + return request('${apiConfig.queryApi}', { + data:data||{}, + method: '${apiConfig.queryMethod}' + }) +} + + +/** +* ${frontConfig.apiFileName}作废 +* @param {*} params +*/ +export const splitfeeInvalid = id => { + return request(`/api/v1.0/feePolicy/${id}`, { + method: '${apiConfig.invalidMethod}' + }) +} + + +##生成queryItem里的api查询接口 +#foreach($item in $queryConfig) + #if($item.componentType=="selectApi") ##输入框 input + /** + * ${item.desc}接口 + * @param {*} data + */ + export const ${item.field}Req = (data) => { + return request('${item.api}', { + data: data||{}, + method: '${item.method}' + }) + } + #end +#end diff --git a/front-template/settlement/table-query-utils.vm b/front-template/settlement/table-query-utils.vm new file mode 100644 index 0000000..8340bf9 --- /dev/null +++ b/front-template/settlement/table-query-utils.vm @@ -0,0 +1,127 @@ +#*查询表单部分*# +##生成query from 的 item +#macro(queryFormItemTmp) + #foreach($item in $queryConfig) + #if($item.componentType=="input") ##input + + + + #elseif($item.componentType=="select") ##select + + + #foreach($enum in $item.optionDataArr) + + #end + + + #elseif($item.componentType=="selectApi") ##selectApi + + + + + + #elseif($item.componentType=="datetime") ##日期选择 dateTime + + + + #elseif($item.componentType=="datetimerange") ##日期时间选择 dateTimePicker + + + + #end + #end +#end + +##自定义表头后的数据 +#macro(customTableHead) + #foreach($item in $tableList) + #if($item.isTemplate=="true") + + + + #end + #end +#end + + +#macro(queryformKey) + #foreach($item in $queryConfig) + $item.field:"", + #end +#end + +#*表单selectApi请求*# +#macro(queryDataScript) + #foreach($qcItem in $queryConfig) + #if($qcItem.componentType=="selectApi") + ${qcItem.field}Data:[], + #end + #end +#end +##method +#macro(queryMethodScript) + #foreach($qcItem in $queryConfig) + #if($qcItem.componentType=="selectApi") + ${qcItem.field}Req(){ + this.globalApi.${frontConfig.apiFileName}.${qcItem.field}Req().then(({data}) => { + this.${qcItem.field}Data = data; + }) + }, + #end + #end +#end +##mounted +#macro(queryMountedScript) + #foreach($qcItem in $queryConfig) + #if($qcItem.componentType=="selectApi") + this.${qcItem.field}Req() + #end + #end +#end + +#*表格部分*# +#macro(tableOfHead) + #foreach($item in $tableList) + { prop: "$item.field", label: "$item.desc", minWidth: $item.width,isTemplate:${item.isTemplate} }, + #end +#end + diff --git a/front-template/settlement/table-query.vm b/front-template/settlement/table-query.vm new file mode 100644 index 0000000..a26c49f --- /dev/null +++ b/front-template/settlement/table-query.vm @@ -0,0 +1,158 @@ +#parse("table-query-utils.vm") + + + + + diff --git a/front-template/settlement/tableUtils.vm b/front-template/settlement/tableUtils.vm new file mode 100644 index 0000000..72b3f4f --- /dev/null +++ b/front-template/settlement/tableUtils.vm @@ -0,0 +1,88 @@ +##column +#macro(tableColumnScript) +#foreach($item in $tableConfig) + #if($foreach.count==1) + { + label: '$item.desc', + prop: '$item.field', + 'min-width': "$!item.width", + align: 'left' + }, + #else + { + label: '$item.desc', + prop: '$item.field', + 'min-width': "$!item.width", + }, + #end + #end +#end +##tableDataReq +#macro(tableDataReq) +this.$api.${frontConfig.apiFileName}.${frontConfig.apiFileName}Query(data).then((response) => { +this.dataSource.data = response.data +this.dataSource.pageData.total = response.total +}) +.catch(() => { +}) +#end +##deleteReq +#macro(deleteReq) +this.$api.${frontConfig.apiFileName}.${frontConfig.apiFileName}Delete(data).then((response) => { +if (response.code === "200") { +this.$message.success("删除成功"); +this.status = false; +this.successStatus = true; +} +}); +#end +##dataSourceTool +#macro(tableDataSourceTool) +tool: [ + #if($frontConfig.tableNeedExport) + { + name: '导出', + handleClick: this.handleExport + }, + #end + #if($frontConfig.tableNeedImport) + { + btnName: '导入发货单', + modelExcelType: 'exportEquipmentSend', + importExcelType: 'importEquipmentSend', + component: 'Import' // 配置列表设置组件 + }, + #end +{ +component: 'Drag' // 配置列表设置组件 +} +], +#end +##tableScript +#macro(tableExportMethod) + #if($frontConfig.tableNeedExport) + handleExport() { + const params = JSON.parse(JSON.stringify(this.listQuery)) + params.pageIndex = 1 + params.pageSize = 1000 + // delete params.time + this.$request('$frontConfig.exportUrl', { + data: params + }).then((response) => { + this.$alert('请前往导出中心下载表格', '提交成功', { + confirmButtonText: '去下载表格', + callback: (action) => { + if (action === 'confirm') { + const rt=this.$router + rt.push({ + path: '/center/index', + query: { activeType: 2 } + }) + } + } + }) + }) + .catch(() => {}) + }, + #end +#end \ No newline at end of file diff --git a/front-template/settlement/utils.vm b/front-template/settlement/utils.vm new file mode 100644 index 0000000..9c6e786 --- /dev/null +++ b/front-template/settlement/utils.vm @@ -0,0 +1,24 @@ +##根据数组某个key分组 +#macro(groupArrByKey $arrs $group_key) + #set($gabkMap={}) + #foreach($ai in $arrs) + #if(!$!gabkMap[$ai[$group_key]]) + #set($gabkMap[$ai[$group_key]] = [$ai]) + #else + #if($gabkMap[$ai[$group_key]].add($ai)) + #end + #end + #end +#end +##根据数组某个deep key分组 +#macro(groupArrByDeepKey $arrs $group_key $group_deep_key) + #set($gabkDeepMap={}) + #foreach($ai in $arrs) + #if(!$!gabkDeepMap[$ai[$group_key][$group_deep_key]]) + #set($gabkDeepMap[$ai[$group_key][$group_deep_key]] = [$ai]) + #else + #if($gabkDeepMap[$ai[$group_key][$group_deep_key]].add($ai)) + #end + #end + #end +#end \ No newline at end of file diff --git a/gateway/src/main/resources/application.yml b/gateway/src/main/resources/application.yml index ca61614..7c8d2ad 100644 --- a/gateway/src/main/resources/application.yml +++ b/gateway/src/main/resources/application.yml @@ -3,19 +3,19 @@ server: spring: cloud: gateway: - # globalcors: - # corsConfigurations: - # '[/**]': - # allow-credentials: true - # allowed-origin-patterns: "*" - # allowed-headers: "*" - # allowed-methods: - # - OPTIONS - # - GET - # - POST - # - PUT - # - DELETE - # #max-age: 3600 + globalcors: + corsConfigurations: + '[/**]': + allow-credentials: true + allowed-origin-patterns: "*" + allowed-headers: "*" + allowed-methods: + - OPTIONS + - GET + - POST + - PUT + - DELETE + #max-age: 3600 routes: - id: integration-front uri: lb://integration-front diff --git a/velocity-tmp-dir/front-vms/element-plus/add-edit-table-api.vm b/velocity-tmp-dir/front-vms/element-plus/add-edit-table-api.vm new file mode 100644 index 0000000..e3417ca --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/add-edit-table-api.vm @@ -0,0 +1,18 @@ +import request from '@/lib/axios' + + +##生成formItem里的api查询接口 +#foreach($item in $tableListConfig) + #if($item.compoentType=="selectApi") ##输入框 input + /** + * ${item.desc}接口 + * @param {*} data + */ + export const ${item.field}Req = (data) => { + return request('${item.api}', { + data, + method: '${item.method}' + }) + } + #end +#end diff --git a/velocity-tmp-dir/front-vms/element-plus/add-edit-table-utils.vm b/velocity-tmp-dir/front-vms/element-plus/add-edit-table-utils.vm new file mode 100644 index 0000000..5fb9ca9 --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/add-edit-table-utils.vm @@ -0,0 +1,74 @@ +#macro(tableItemTemp) + #foreach($item in $tableListConfig) + #if($item.componentType=="input") ##输入框 input + + #if($item.isTemplate=="true") + + #end + + #elseif($item.componentType=="select") ##select + + #if($item.isTemplate=="true") + + #end + + #elseif($item.componentType=="selectApi") ##selectApi + + #if($item.isTemplate=="true") + + #end + + #end + #end +#end + + + +##生成data +#macro(formDataScript) + #foreach($item in $tableListConfig) + #if($item.componentType=="selectApi") ##输入框 input + ${item.field}Data:[], + ##elseif($item.componentType=="date") ##日期选择 datePicker + ##elseif($item.componentType=="time") ##时间选择 timePicker + #end + #end +#end + + +##生成method +#macro(formMethodScript) + #foreach($item in $tableListConfig) + #if($item.componentType=="selectApi") + ${item.field}Req(){ + this.globalApi.${frontConfig.apiFileName}.${item.field}Req().then(({data}) => { + this.${item.field}Data = data + }) + }, + #end + #end +#end +##生成mounted +#macro(formMountedScript) + #foreach($item in $tableListConfig) + #if($item.componentType=="selectApi") ##输入框 selectApi + this.${item.field}Req() + #end + #end +#end diff --git a/velocity-tmp-dir/front-vms/element-plus/add-edit-table.vm b/velocity-tmp-dir/front-vms/element-plus/add-edit-table.vm new file mode 100644 index 0000000..a5bbf83 --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/add-edit-table.vm @@ -0,0 +1,78 @@ +#parse("add-edit-table-utils.vm") + + + + + + diff --git a/velocity-tmp-dir/front-vms/element-plus/addEdit.vm b/velocity-tmp-dir/front-vms/element-plus/addEdit.vm new file mode 100644 index 0000000..fb7958c --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/addEdit.vm @@ -0,0 +1,91 @@ +#parse("addEditUtils.vm") + + + + + diff --git a/velocity-tmp-dir/front-vms/element-plus/addEditApi.vm b/velocity-tmp-dir/front-vms/element-plus/addEditApi.vm new file mode 100644 index 0000000..a79ee3a --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/addEditApi.vm @@ -0,0 +1,39 @@ +import request from '@/lib/axios' +/** +* ${frontConfig.apiFileName}查询 +* @param {*} data +*/ +export const tableQuery = (data) => { + return request('${apiConfig.queryApi}', { + data:data||{}, + method: '${apiConfig.queryMethod}' + }) +} + + +/** +* ${frontConfig.apiFileName}作废 +* @param {*} params +*/ +export const splitfeeInvalid = id => { + return request(`/api/v1.0/feePolicy/${id}`, { + method: '${apiConfig.invalidMethod}' + }) +} + + +##生成queryItem里的api查询接口 +#foreach($item in $queryConfig) + #if($item.componentType=="selectApi") ##输入框 input + /** + * ${item.desc}接口 + * @param {*} data + */ + export const ${item.field}Req = (data) => { + return request('${item.api}', { + data: data||{}, + method: '${item.method}' + }) + } + #end +#end diff --git a/velocity-tmp-dir/front-vms/element-plus/addEditUtils.vm b/velocity-tmp-dir/front-vms/element-plus/addEditUtils.vm new file mode 100644 index 0000000..6151c10 --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/addEditUtils.vm @@ -0,0 +1,170 @@ +#macro(subFormItemTmp) + #foreach($item in $tableList) + #if($item.componentType=="input") ##input + + + + #elseif($item.componentType=="textarea") ##textarea + + + + #elseif($item.componentType=="select") ##select + + + #foreach($enum in $item.optionDataArr) + + #end + + + #elseif($item.componentType=="selectApi") ##selectApi + + + + + + #elseif($item.componentType=="radio") ##radio + + + #foreach($enum in $item.optionDataArr) + ${enum.label} + #end + + + #elseif($item.componentType=="checkbox") ##checkbox + + + #foreach($enum in $item.optionDataArr) + + #end + + + #elseif($item.componentType=="switch") ##switch + + + + #elseif($item.componentType=="cascaderApi") ##cascader + + + + #elseif($item.componentType=="daterange") ##datetime + + + + #elseif($item.componentType=="date") ##date + + + + #elseif($item.componentType=="uploadImage") + +
+ +
+ + + 上传 + + +
{{ chooseFileName }}
+
+
+
+ #end + #end +#end + + +#*script*# +#macro(onMountedScript) +onMounted(()=>{ + #foreach($item in $tableList) + #if($item.componentType=="selectApi")##selectApi + ${item.fieldCase}Req() + #end + #end +}) +#end + +##api data +#macro(apiDataScript) + #foreach($qcItem in $tableList) + #if($qcItem.componentType=="selectApi") + let ${qcItem.field}Data=$ref([]), + #end + #end +#end + +##api req +#macro(apiReqScript) + #foreach($qcItem in $tableList) + #if($qcItem.componentType=="selectApi") + ${qcItem.fieldCase}Req() + #end + #end +#end + + +##form key +#macro(formKeyScrpt) + #foreach($item in $tableList) + $item.field:"", + #if($qcItem.componentType=="daterange") + ${item.field}Arr:[], + #end + #end +#end + +##上传文件 +#macro(uploadImageScript) + #foreach($item in $tableList) + #if($item.componentType=="uploadImage") + const ${item.field}Ref = $ref(null) + const ${item.field}UploadFile = () => { + ${item.field}Ref.click() + } + const ${item.field}UploadSave = async () => { + let { fileUrl } = await fileUpload(${item.field}Ref) + subForm.${item.field} = fileUrl + } + #end + #end + +#end diff --git a/velocity-tmp-dir/front-vms/element-plus/detail.vm b/velocity-tmp-dir/front-vms/element-plus/detail.vm new file mode 100644 index 0000000..0ba7d7a --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/detail.vm @@ -0,0 +1,46 @@ +#parse("detailUtils.vm") + + + + + diff --git a/velocity-tmp-dir/front-vms/element-plus/detailApi.vm b/velocity-tmp-dir/front-vms/element-plus/detailApi.vm new file mode 100644 index 0000000..379947e --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/detailApi.vm @@ -0,0 +1,8 @@ +/** +*${frontConfig.apiFileName}详情 +*/ +export const ${frontConfig.apiFileName}Detail = (id) => { + return request(`${apiConfig.detailApi}`, { + method: `${apiConfig.detailMethod}` + }) +} \ No newline at end of file diff --git a/velocity-tmp-dir/front-vms/element-plus/detailUtils.vm b/velocity-tmp-dir/front-vms/element-plus/detailUtils.vm new file mode 100644 index 0000000..76a6ab6 --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/detailUtils.vm @@ -0,0 +1,91 @@ +#macro(detailContainer) + #foreach($pItem in $tableConfigArr) + ## 横向 + #if($pItem.direction=="1") + +
+ #foreach($fItem in $pItem.dillColumnArr) +
+ #foreach($sItem in $fItem ) +
+
+ ${sItem.desc}: + #if($sItem.componentType=="input") ##input + {{detailData.$sItem.columnName}} + #elseif($sItem.componentType=="select") ##select + #foreach($enum in $sItem.optionDataArr) + ${enum.label} + #end + #elseif($sItem.componentType=="image") ##select + + #end +
+
+ #end +
+ #end +
+
+ #end + ## 纵向 + #if($pItem.direction=="2") + + #foreach($fItem in $pItem.dillColumnArr) +
+ #foreach($sItem in $fItem ) +
+ ${sItem.desc}: + #if($sItem.componentType=="input") ##input + {{detailData.$sItem.columnName}} + #elseif($sItem.componentType=="select") ##select + #foreach($enum in $sItem.optionDataArr) + ${enum.label} + #end + #elseif($sItem.componentType=="image") ##select + + #end +
+ #end +
+ #end +
+ #end + ## 表格 + #if($pItem.direction=="3") + + + #foreach($fItem in $pItem.dillColumnArr) + #if($fItem.isTemplate==true) + + + + #else + + #end + #end + + + #end + #end +#end diff --git a/velocity-tmp-dir/front-vms/element-plus/queryApi.vm b/velocity-tmp-dir/front-vms/element-plus/queryApi.vm new file mode 100644 index 0000000..b0ae3f7 --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/queryApi.vm @@ -0,0 +1,38 @@ +import request from '@/lib/axios' +/** +* ${frontConfig.apiFileName}查询 +* @param {*} data +*/ +export const tableQuery = (data) => { + return request('${apiConfig.queryApi}', { + data:data||{}, + method: '${apiConfig.queryMethod}' + }) +} + +/** +* ${frontConfig.apiFileName}作废 +* @param {*} params +*/ +export const splitfeeInvalid = id => { + return request(`/api/v1.0/feePolicy/${id}`, { + method: '${apiConfig.invalidMethod}' + }) +} + + +##生成queryItem里的api查询接口 +#foreach($item in $queryConfig) + #if($item.componentType=="selectApi") ##输入框 input + /** + * ${item.desc}接口 + * @param {*} data + */ + export const ${item.field}Req = (data) => { + return request('${item.api}', { + data: data||{}, + method: '${item.method}' + }) + } + #end +#end diff --git a/velocity-tmp-dir/front-vms/element-plus/queryUtils.vm b/velocity-tmp-dir/front-vms/element-plus/queryUtils.vm index ad034f8..a957a48 100644 --- a/velocity-tmp-dir/front-vms/element-plus/queryUtils.vm +++ b/velocity-tmp-dir/front-vms/element-plus/queryUtils.vm @@ -131,8 +131,6 @@ selectPageReq() #foreach($item in $queryConfig) #if($item.componentType=="selectApi")##selectApi select${item.fieldCase}Req() - #elseif($item.componentType=="cascaderApi") ##cascader - cascade${item.fieldCase}Req() #end #end }) diff --git a/velocity-tmp-dir/front-vms/element-plus/routerItem.vm b/velocity-tmp-dir/front-vms/element-plus/routerItem.vm new file mode 100644 index 0000000..19fb90a --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/routerItem.vm @@ -0,0 +1,28 @@ +{ + path: '/${basicConfig.routerParentDir}', + component: Layout, + meta: { title: '${basicConfig.routerParentDir}', elSvgIcon: 'Fold' }, + alwaysShow: true, + children: [ + { + path: '${basicConfig.apiFileName}-table-query', + component: () => import('@/views/${basicConfig.routerParentDir}/${basicConfig.apiFileName}/${basicConfig.apiFileNameFirstCase}TableQuery.vue'), + name: '${basicConfig.apiFileNameFirstCase}TableQuery', + meta: { title: '${basicConfig.apiFileName}列表' } + }, + { + path: '${basicConfig.apiFileName}-add-edit', + component: () => import('@/views/${basicConfig.routerParentDir}/${basicConfig.apiFileName}/${basicConfig.apiFileNameFirstCase}AddEdit.vue'), + name: '${basicConfig.apiFileNameFirstCase}AddEdit', + hidden: true, + meta: { title: '新增编辑', activeMenu: '/${basicConfig.routerParentDir}/${basicConfig.apiFileName}-table-query' } + }, + { + path: '${basicConfig.apiFileName}-detail', + component: () => import('@/views/${basicConfig.routerParentDir}/${basicConfig.apiFileName}/${basicConfig.apiFileNameFirstCase}Detail.vue'), + name: '${basicConfig.apiFileNameFirstCase}Detail', + hidden: true, + meta: { title: '详情', activeMenu: '/${basicConfig.routerParentDir}/${basicConfig.apiFileName}-table-query' } + } + ] +} \ No newline at end of file diff --git a/velocity-tmp-dir/front-vms/element-plus/tableQuery.vm b/velocity-tmp-dir/front-vms/element-plus/tableQuery.vm new file mode 100644 index 0000000..3595b57 --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/tableQuery.vm @@ -0,0 +1,123 @@ +#parse("tableQueryUtils.vm") + + + + diff --git a/velocity-tmp-dir/front-vms/element-plus/tableQueryIndex.vm b/velocity-tmp-dir/front-vms/element-plus/tableQueryIndex.vm new file mode 100644 index 0000000..7e0547a --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/tableQueryIndex.vm @@ -0,0 +1,2 @@ +import component from './${basicConfig.apiFileNameFirstCase}TableQuery.vue' +export default component diff --git a/velocity-tmp-dir/front-vms/element-plus/tableQueryUtils.vm b/velocity-tmp-dir/front-vms/element-plus/tableQueryUtils.vm new file mode 100644 index 0000000..33a74de --- /dev/null +++ b/velocity-tmp-dir/front-vms/element-plus/tableQueryUtils.vm @@ -0,0 +1,179 @@ +#*查询form item*# +#macro(queryFormItemTmp) + #foreach($item in $queryConfig) + #if($item.componentType=="input") ##input + + + + #elseif($item.componentType=="select") ##select + + + #foreach($enum in $item.optionDataArr) + + #end + + + #elseif($item.componentType=="selectApi") ##selectApi + + + + + + #elseif($item.componentType=="daterange") ##datetimerange + + + + #elseif($item.componentType=="date") ##date + + + + #end + #end +#end + +#*表格列项*# +#macro(tableItemTmp) + #if($tableConfig.isTableMulChoose) + + #end + #foreach($item in $tableList) + #if($item.componentType=="input") ##input + + #elseif($item.componentType=="select") ##select + + + + #elseif($item.componentType=="image") ##image + + + + #end + #end +#end +##table 新增和删除 +#macro(tableGlobalOperatorTmp) + #if($tableConfig.isAdd) + + + + + 增加 + + #end + #if($tableConfig.isMulDelete) + + + + + 删除 + + #end +#end +##table 操作 +#macro(tableOperatorTmp) + #if($tableConfig.isEdit) + 编辑 + #end + + #if($tableConfig.isDelete) + 删除 + #end + #if($tableConfig.isDetail) + 详情 + #end +#end + +##分页 +#macro(tablePaginationTmp) + #if($tableConfig.isPagination) +
+ +
+ #end +#end + +#*script*# +#macro(onMountedScript) +onMounted(()=>{ + selectPageReq() + #foreach($item in $queryConfig) + #if($item.componentType=="selectApi")##selectApi + ${item.fieldCase}Req() + #end + #end +}) +#end + +##api data +#macro(apiDataScript) + #foreach($qcItem in $queryConfig) + #if($qcItem.componentType=="selectApi") + let ${qcItem.field}Data=$ref([]), + #end + #end +#end + +##api req +#macro(apiReqScript) + #foreach($qcItem in $queryConfig) + #if($qcItem.componentType=="selectApi") + ${qcItem.fieldCase}Req() + #end + #end +#end + + +##form key +#macro(formKeyScrpt) + #foreach($item in $queryConfig) + $item.field:"", +## #if($item.componentType=="daterange") +## ${item.field}Arr:[], +## #end + #end +#end \ No newline at end of file diff --git a/velocity-tmp-dir/json-data/element-plus/add-edit.json b/velocity-tmp-dir/json-data/element-plus/add-edit.json new file mode 100644 index 0000000..3cad1a4 --- /dev/null +++ b/velocity-tmp-dir/json-data/element-plus/add-edit.json @@ -0,0 +1,89 @@ +{ + "basicConfig": { + "author": "熊猫哥", + "apiFileName": "addEdit", + "dataTime": "2022-10-02 17:05:08" + }, + "apiConfig": { + "insertApi": "/integration-front/brand/insert", + "insertMethod": "post", + "updateApi": "/integration-front/brand/updateById", + "updateMethod": "put", + "detailApi": "/integration-front/brand/selectById", + "detailMethod": "get" + }, + "tableList": [ + { + "columnName": "name", + "desc": "品牌名称", + "uuid": "6ce2098a-12fd-4fac-96ae-179923db0d57", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "componentType": "input", + "rule": "isNotNull", + "children": "children", + "width": 300, + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "isTemplate": "false", + "controlType": "elInput" + }, + { + "columnName": "image", + "desc": "品牌图片地址", + "uuid": "78984e33-c530-4bd6-87c9-f2eabd6cc78c", + "field": "image", + "fieldCase": "Image", + "originField": "image", + "componentType": "uploadImage", + "rule": "isNotNull", + "children": "children", + "width": 300, + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "isTemplate": "false", + "controlType": "elInput" + }, + { + "columnName": "letter", + "desc": "品牌的首字母", + "uuid": "8dbcfb81-1d70-47b4-8535-651af2a0df06", + "field": "letter", + "fieldCase": "Letter", + "originField": "letter", + "componentType": "input", + "rule": "isNotNull", + "children": "children", + "width": 300, + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "isTemplate": "false", + "controlType": "elInput" + }, + { + "columnName": "seq", + "desc": "排序", + "uuid": "3880b8b5-296c-414b-b991-97b983842555", + "field": "seq", + "fieldCase": "Seq", + "originField": "seq", + "componentType": "input", + "rule": "isNotNull", + "children": "children", + "width": 300, + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "isTemplate": "false", + "controlType": "elInput" + } + ] +} \ No newline at end of file diff --git a/velocity-tmp-dir/json-data/element-plus/detail.json b/velocity-tmp-dir/json-data/element-plus/detail.json new file mode 100644 index 0000000..9e95be5 --- /dev/null +++ b/velocity-tmp-dir/json-data/element-plus/detail.json @@ -0,0 +1,156 @@ +{ + "basicConfig": { + "author": "熊猫哥", + "apiFileName": "detail", + "dataTime": "2022-10-02 17:57:59" + }, + "apiConfig": { + "detailApi": "/integration-front/brand/selectById", + "detailMethod": "get" + }, + "tableConfigArr": [ + { + "direction": "2", + "splitNum": 2, + "cartTitle": "品牌详情", + "columnArr": [ + { + "columnName": "name", + "desc": "品牌名称", + "uuid": "9ff5263a-10c1-4359-b9fa-8cc5bc1d7198", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "componentType": "input", + "rule": "isNotNull", + "children": "children", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "width": "150" + }, + { + "columnName": "image", + "desc": "品牌图片地址", + "uuid": "9da7427a-a096-4160-a952-0aeadbcfbe59", + "field": "image", + "fieldCase": "Image", + "originField": "image", + "componentType": "image", + "rule": "isNotNull", + "children": "children", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "width": "150" + }, + { + "columnName": "letter", + "desc": "品牌的首字母", + "uuid": "4bb9c154-d51c-4086-893d-fd4f09d297b5", + "field": "letter", + "fieldCase": "Letter", + "originField": "letter", + "componentType": "input", + "rule": "isNotNull", + "children": "children", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "width": "150" + }, + { + "columnName": "seq", + "desc": "排序", + "uuid": "3c3fa900-7140-43c3-94d2-d545b254b1ba", + "field": "seq", + "fieldCase": "Seq", + "originField": "seq", + "componentType": "input", + "rule": "isNotNull", + "children": "children", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "width": "150" + } + ], + "dillColumnArr": [ + [ + { + "columnName": "name", + "desc": "品牌名称", + "uuid": "9ff5263a-10c1-4359-b9fa-8cc5bc1d7198", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "componentType": "input", + "rule": "isNotNull", + "children": "children", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "width": "150" + }, + { + "columnName": "image", + "desc": "品牌图片地址", + "uuid": "9da7427a-a096-4160-a952-0aeadbcfbe59", + "field": "image", + "fieldCase": "Image", + "originField": "image", + "componentType": "image", + "rule": "isNotNull", + "children": "children", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "width": "150" + } + ], + [ + { + "columnName": "letter", + "desc": "品牌的首字母", + "uuid": "4bb9c154-d51c-4086-893d-fd4f09d297b5", + "field": "letter", + "fieldCase": "Letter", + "originField": "letter", + "componentType": "input", + "rule": "isNotNull", + "children": "children", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "width": "150" + }, + { + "columnName": "seq", + "desc": "排序", + "uuid": "3c3fa900-7140-43c3-94d2-d545b254b1ba", + "field": "seq", + "fieldCase": "Seq", + "originField": "seq", + "componentType": "input", + "rule": "isNotNull", + "children": "children", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "width": "150" + } + ], + [] + ], + "leftWidth": "150" + } + ] +} \ No newline at end of file diff --git a/velocity-tmp-dir/json-data/element-plus/table-query.json b/velocity-tmp-dir/json-data/element-plus/table-query.json new file mode 100644 index 0000000..2332c8e --- /dev/null +++ b/velocity-tmp-dir/json-data/element-plus/table-query.json @@ -0,0 +1,175 @@ +{ + "basicConfig": { + "author": "熊猫哥", + "apiFileName": "brand", + "apiFileNameFirstCase": "Brand", + "routerParentDir": "template-demo", + "addEditPath": "CRUDForm", + "detailPath": "CRUDDetail", + "dataTime": "2022-10-01 16:07:56" + }, + "apiConfig": { + "queryApi": "/integration-front/brand/selectPage", + "queryMethod": "get", + "deleteApi": "/integration-front/brand/deleteById", + "deleteMethod": "delete", + "multiDeleteApi": "/integration-front/brand/deleteBatchIds", + "multiDeleteMethod": "delete" + }, + "tableConfig": { + "isAdd": "true", + "isDelete": "true", + "isMulDelete": "true", + "isEdit": "true", + "isPagination": "true", + "isDetail": "true", + "isTableMulChoose": "true", + "isExport": "false" + }, + "queryConfig": [ + { + "columnName": "name", + "desc": "品牌名字", + "uuid": "093ada70-8c8e-4ee4-a6eb-a837207911c7", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "componentType": "input", + "rule": "isNotNull", + "children": "children", + "width": "100", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "controlType": "elInput" + }, + { + "columnName": "startEndArr", + "desc": "查询时间范围", + "uuid": "c14dd34f-5c55-48fd-bd8a-cb1ec3dc6898", + "field": "startEndArr", + "fieldCase": "Startendarr", + "originField": "startEndArr", + "componentType": "daterange", + "rule": "isNotNull", + "children": "children", + "width": 150, + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "controlType": "elInput" + } + ], + "tableList": [ + { + "columnName": "name", + "desc": "品牌名字", + "uuid": "2513f205-4e68-49eb-83d1-eb7a3a4c1754", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "componentType": "input", + "rule": "isNotNull", + "children": "children", + "width": 100, + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "isTemplate": "false", + "controlType": "elInput" + }, + { + "columnName": "image", + "desc": "图片地址", + "uuid": "ee801eb1-81dc-475e-b1b3-ad3522218b91", + "field": "image", + "fieldCase": "Image", + "originField": "image", + "componentType": "image", + "rule": "isNotNull", + "children": "children", + "width": 100, + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "isTemplate": "true", + "controlType": "elInput" + }, + { + "columnName": "letter", + "desc": "首字母", + "uuid": "3223c62b-c28f-4419-94ba-275afca97100", + "field": "letter", + "fieldCase": "Letter", + "originField": "letter", + "componentType": "input", + "rule": "isNotNull", + "children": "children", + "width": 100, + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "isTemplate": "false", + "controlType": "elInput" + }, + { + "columnName": "seq", + "desc": "排序", + "uuid": "501e9286-4cc6-41b0-9abe-28ae9412528f", + "field": "seq", + "fieldCase": "Seq", + "originField": "seq", + "componentType": "input", + "rule": "isNotNull", + "children": "children", + "width": 100, + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "isTemplate": "false", + "controlType": "elInput" + }, + { + "columnName": "createTime", + "desc": "创建时间", + "uuid": "4e311ffc-13c8-4217-89d6-29a2693e7fa7", + "field": "createTime", + "fieldCase": "Createtime", + "originField": "createTime", + "componentType": "daterange", + "rule": "isNotNull", + "children": "children", + "width": 100, + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "isTemplate": "false", + "controlType": "elInput" + }, + { + "columnName": "updateTime", + "desc": "更新时间", + "uuid": "2d84d57c-a181-4cdd-a824-c560987d2c7e", + "field": "updateTime", + "fieldCase": "Updatetime", + "originField": "updateTime", + "componentType": "daterange", + "rule": "isNotNull", + "children": "children", + "width": 100, + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "isTemplate": "false", + "controlType": "elInput" + } + ] +} \ No newline at end of file From 5fdf073bf3aa4e124ee553be924a1902493c2831 Mon Sep 17 00:00:00 2001 From: jzfai Date: Fri, 7 Oct 2022 19:30:46 +0800 Subject: [PATCH 28/36] add mybatisPlus code generator --- .../service/GeneratorCustromService.java | 60 +- .../basisfunc/service/GeneratorService.java | 62 +- .../service/MybatisPlusGeneratorService.java | 151 ++ .../basisfunc/utils/GeneratorTempUtils.java | 8 +- .../src/main/resources/application-db.yml | 6 +- .../service/GeneratorServiceTest.java | 136 +- .../MybatisPlusGeneratorServiceTest.java | 30 + .../aulton-asset/base-model-add-model.vm | 96 - .../aulton-asset/base-model-index.vm | 141 - front-template/aulton-asset/base-template.vm | 55 - front-template/aulton-asset/formUtils.vm | 291 -- front-template/aulton-asset/queryUtils.vm | 94 - front-template/aulton-asset/req-api.vm | 82 - front-template/aulton-asset/tableUtils.vm | 88 - front-template/aulton-asset/utils.vm | 24 - front-template/settlement/add-edit-api.vm | 54 - .../settlement/add-edit-table-api.vm | 18 - .../settlement/add-edit-table-utils.vm | 74 - front-template/settlement/add-edit-table.vm | 78 - front-template/settlement/add-edit.vm | 68 - front-template/settlement/detail-api.vm | 8 - front-template/settlement/detail.vm | 51 - front-template/settlement/detailUtils.vm | 76 - front-template/settlement/formUtils.vm | 156 -- front-template/settlement/queryApi.vm | 39 - .../settlement/table-query-utils.vm | 127 - front-template/settlement/table-query.vm | 158 -- front-template/settlement/tableUtils.vm | 88 - front-template/settlement/utils.vm | 24 - .../controller/RoleController.java | 145 + .../integrationfront/entity/Role.java | 43 +- .../integrationfront/mapper/RoleMapper.java | 17 +- .../integrationfront/service/RoleService.java | 39 +- .../src/main/resources/application-db.yml | 2 +- .../mybatis-plus-multi}/controllerMul.vm | 0 .../mybatis-plus-multi}/entity.vm | 0 .../mybatis-plus-multi}/entityMul.vm | 0 .../mybatis-plus-multi}/entityVo.vm | 0 .../mybatis-plus-multi}/mapper.vm | 0 .../mybatis-plus-multi}/mapperMul.vm | 0 .../mybatis-plus-multi}/serviceMul.vm | 0 .../mybatis-plus-multi}/utils.vm | 0 .../mybatis-plus-multi}/xmlMul.vm | 0 .../back-vms-bak/mybatis-plus/controller.vm | 112 + .../back-vms-bak/mybatis-plus/entity.vm | 37 + .../back-vms-bak/mybatis-plus/mapper.vm | 10 + .../back-vms-bak/mybatis-plus/service.vm | 42 + .../back-vms-bak/mybatis-plus/utils.vm | 6 + .../back-vms-bak/mybatis-plus/xml.vm | 0 .../mybatis-plus-multi/controllerMul.vm | 75 + .../back-vms/mybatis-plus-multi/entity.vm | 37 + .../back-vms/mybatis-plus-multi/entityMul.vm | 29 + .../back-vms/mybatis-plus-multi/entityVo.vm | 19 + .../back-vms/mybatis-plus-multi/mapper.vm | 10 + .../back-vms/mybatis-plus-multi/mapperMul.vm | 16 + .../back-vms/mybatis-plus-multi/serviceMul.vm | 57 + .../back-vms/mybatis-plus-multi/utils.vm | 8 + .../back-vms/mybatis-plus-multi/xmlMul.vm | 60 + .../back-vms/mybatis-plus/controller.vm | 184 +- .../back-vms/mybatis-plus/entity.vm | 50 +- .../back-vms/mybatis-plus/mapper.vm | 8 +- .../back-vms/mybatis-plus/service.vm | 53 +- .../back-vms/mybatis-plus/utils.vm | 27 +- .../front-vms/element-plus/tableQueryUtils.vm | 4 +- .../json-data/mybatis-plus/basicData.json | 2378 +++++++++++++++++ 65 files changed, 3598 insertions(+), 2213 deletions(-) create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorService.java create mode 100644 basis-func/src/test/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorServiceTest.java delete mode 100644 front-template/aulton-asset/base-model-add-model.vm delete mode 100644 front-template/aulton-asset/base-model-index.vm delete mode 100644 front-template/aulton-asset/base-template.vm delete mode 100644 front-template/aulton-asset/formUtils.vm delete mode 100644 front-template/aulton-asset/queryUtils.vm delete mode 100644 front-template/aulton-asset/req-api.vm delete mode 100644 front-template/aulton-asset/tableUtils.vm delete mode 100644 front-template/aulton-asset/utils.vm delete mode 100644 front-template/settlement/add-edit-api.vm delete mode 100644 front-template/settlement/add-edit-table-api.vm delete mode 100644 front-template/settlement/add-edit-table-utils.vm delete mode 100644 front-template/settlement/add-edit-table.vm delete mode 100644 front-template/settlement/add-edit.vm delete mode 100644 front-template/settlement/detail-api.vm delete mode 100644 front-template/settlement/detail.vm delete mode 100644 front-template/settlement/detailUtils.vm delete mode 100644 front-template/settlement/formUtils.vm delete mode 100644 front-template/settlement/queryApi.vm delete mode 100644 front-template/settlement/table-query-utils.vm delete mode 100644 front-template/settlement/table-query.vm delete mode 100644 front-template/settlement/tableUtils.vm delete mode 100644 front-template/settlement/utils.vm create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/controller/RoleController.java rename velocity-tmp-dir/{back-vms/mybatis-plus-multb => back-vms-bak/mybatis-plus-multi}/controllerMul.vm (100%) rename velocity-tmp-dir/{back-vms/mybatis-plus-multb => back-vms-bak/mybatis-plus-multi}/entity.vm (100%) rename velocity-tmp-dir/{back-vms/mybatis-plus-multb => back-vms-bak/mybatis-plus-multi}/entityMul.vm (100%) rename velocity-tmp-dir/{back-vms/mybatis-plus-multb => back-vms-bak/mybatis-plus-multi}/entityVo.vm (100%) rename velocity-tmp-dir/{back-vms/mybatis-plus-multb => back-vms-bak/mybatis-plus-multi}/mapper.vm (100%) rename velocity-tmp-dir/{back-vms/mybatis-plus-multb => back-vms-bak/mybatis-plus-multi}/mapperMul.vm (100%) rename velocity-tmp-dir/{back-vms/mybatis-plus-multb => back-vms-bak/mybatis-plus-multi}/serviceMul.vm (100%) rename velocity-tmp-dir/{back-vms/mybatis-plus-multb => back-vms-bak/mybatis-plus-multi}/utils.vm (100%) rename velocity-tmp-dir/{back-vms/mybatis-plus-multb => back-vms-bak/mybatis-plus-multi}/xmlMul.vm (100%) create mode 100644 velocity-tmp-dir/back-vms-bak/mybatis-plus/controller.vm create mode 100644 velocity-tmp-dir/back-vms-bak/mybatis-plus/entity.vm create mode 100644 velocity-tmp-dir/back-vms-bak/mybatis-plus/mapper.vm create mode 100644 velocity-tmp-dir/back-vms-bak/mybatis-plus/service.vm create mode 100644 velocity-tmp-dir/back-vms-bak/mybatis-plus/utils.vm create mode 100644 velocity-tmp-dir/back-vms-bak/mybatis-plus/xml.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi/controllerMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi/entity.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi/entityMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi/entityVo.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi/mapper.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi/mapperMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi/serviceMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi/utils.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi/xmlMul.vm create mode 100644 velocity-tmp-dir/json-data/mybatis-plus/basicData.json diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorCustromService.java b/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorCustromService.java index ce7496d..10537ec 100644 --- a/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorCustromService.java +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorCustromService.java @@ -111,35 +111,35 @@ private Context getContext(Map jsonData) { /** * Mybatis-plus单表生成模版 */ - public void generatorMybatisPlusTemp(Map jsonData, String tmpSaveDir) { - try { - Context context = getContext(jsonData); - Map dbTableConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("dbTableConfig")), Map.class); - String tbName = dbTableConfig.get("tableNameCase").toString(); - //entity - Template entityTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "entity.vm"); - FileWriter entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("entity") + tbName + ".java"); - entityTemp.merge(context, entityWriter); - entityWriter.close(); - //controller - Template controllerTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "controller.vm"); - FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("controller") + tbName + "Controller.java"); - controllerTemp.merge(context, controllerWriter); - controllerWriter.close(); - //service - Template serviceTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "service.vm"); - FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("service") + tbName + "Service.java"); - serviceTemp.merge(context, serviceWriter); - serviceWriter.close(); - //mapper - Template mapperTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "mapper.vm"); - FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("mapper") + tbName + "Mapper.java"); - mapperTemp.merge(context, mapperWriter); - mapperWriter.close(); - } catch (IOException e) { - throw new RuntimeException("Mybatis-plus单表生成模版报错" + e); - } - } +// public void generatorMybatisPlusTemp(Map jsonData, String tmpSaveDir) { +// try { +// Context context = getContext(jsonData); +// Map dbTableConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("dbTableConfig")), Map.class); +// String tbName = dbTableConfig.get("tableNameCase").toString(); +// //entity +// Template entityTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "entity.vm"); +// FileWriter entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("entity") + tbName + ".java"); +// entityTemp.merge(context, entityWriter); +// entityWriter.close(); +// //controller +// Template controllerTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "controller.vm"); +// FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("controller") + tbName + "Controller.java"); +// controllerTemp.merge(context, controllerWriter); +// controllerWriter.close(); +// //service +// Template serviceTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "service.vm"); +// FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("service") + tbName + "Service.java"); +// serviceTemp.merge(context, serviceWriter); +// serviceWriter.close(); +// //mapper +// Template mapperTemp = GeneratorTempUtils.getTmpSaveDirTemp(tmpSaveDir, "mapper.vm"); +// FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("mapper") + tbName + "Mapper.java"); +// mapperTemp.merge(context, mapperWriter); +// mapperWriter.close(); +// } catch (IOException e) { +// throw new RuntimeException("Mybatis-plus单表生成模版报错" + e); +// } +// } /** * element-plus多表生成模版 @@ -175,7 +175,7 @@ public String generatorBackTempZip(Map jsonData, String tmpSaveDir) { } else { /*单表*/ //生成前端模板 - generatorMybatisPlusTemp(jsonData, tmpSaveDir); +// generatorMybatisPlusTemp(jsonData, tmpSaveDir); } String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; //生成zip包 diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorService.java b/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorService.java index 1ae5b40..f51fefc 100644 --- a/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorService.java +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorService.java @@ -93,35 +93,35 @@ public void generatorMybatisPlusMulTemp(Map jsonData) { /** * Mybatis-plus单表生成模版 */ - public void generatorMybatisPlusTemp(Map jsonData) { - try { - Context context = getContext(jsonData); - Map dbTableConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("dbTableConfig")), Map.class); - String tbName = dbTableConfig.get("tableNameCase").toString(); - //entity - Template entityTemp = GeneratorTempUtils.getMybatisPlusTemp("entity.vm"); - FileWriter entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("entity") + tbName + ".java"); - entityTemp.merge(context, entityWriter); - entityWriter.close(); - //controller - Template controllerTemp = GeneratorTempUtils.getMybatisPlusTemp("controller.vm"); - FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("controller") + tbName + "Controller.java"); - controllerTemp.merge(context, controllerWriter); - controllerWriter.close(); - //service - Template serviceTemp = GeneratorTempUtils.getMybatisPlusTemp("service.vm"); - FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("service") + tbName + "Service.java"); - serviceTemp.merge(context, serviceWriter); - serviceWriter.close(); - //mapper - Template mapperTemp = GeneratorTempUtils.getMybatisPlusTemp("mapper.vm"); - FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("mapper") + tbName + "Mapper.java"); - mapperTemp.merge(context, mapperWriter); - mapperWriter.close(); - } catch (IOException e) { - throw new RuntimeException("Mybatis-plus单表生成模版报错" + e); - } - } +// public void generatorMybatisPlusTemp(Map jsonData) { +// try { +// Context context = getContext(jsonData); +// Map dbTableConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("dbTableConfig")), Map.class); +// String tbName = dbTableConfig.get("tableNameCase").toString(); +// //entity +// Template entityTemp = GeneratorTempUtils.getMybatisPlusTemp("entity.vm"); +// FileWriter entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("entity") + tbName + ".java"); +// entityTemp.merge(context, entityWriter); +// entityWriter.close(); +// //controller +// Template controllerTemp = GeneratorTempUtils.getMybatisPlusTemp("controller.vm"); +// FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("controller") + tbName + "Controller.java"); +// controllerTemp.merge(context, controllerWriter); +// controllerWriter.close(); +// //service +// Template serviceTemp = GeneratorTempUtils.getMybatisPlusTemp("service.vm"); +// FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("service") + tbName + "Service.java"); +// serviceTemp.merge(context, serviceWriter); +// serviceWriter.close(); +// //mapper +// Template mapperTemp = GeneratorTempUtils.getMybatisPlusTemp("mapper.vm"); +// FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("mapper") + tbName + "Mapper.java"); +// mapperTemp.merge(context, mapperWriter); +// mapperWriter.close(); +// } catch (IOException e) { +// throw new RuntimeException("Mybatis-plus单表生成模版报错" + e); +// } +// } /** * element-plus多表生成模版 @@ -156,7 +156,7 @@ public String generatorBackTempZip(Map jsonData) { generatorMybatisPlusMulTemp(jsonData); } else { /*单表*/ - generatorMybatisPlusTemp(jsonData); +// generatorMybatisPlusTemp(jsonData); } String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; //生成zip包 @@ -205,7 +205,7 @@ public String generatorFrontBackTempZip(Map jsonData) { //生成前端模板 generatorElementPlusTemp(jsonData); //生成后端模板 - generatorMybatisPlusTemp(jsonData); +// generatorMybatisPlusTemp(jsonData); } String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorService.java b/basis-func/src/main/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorService.java new file mode 100644 index 0000000..899ad0e --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorService.java @@ -0,0 +1,151 @@ +package top.kuanghua.basisfunc.service; + +import com.alibaba.fastjson.JSON; +import org.apache.velocity.Template; +import org.apache.velocity.context.Context; +import org.springframework.stereotype.Service; +import top.kuanghua.basisfunc.utils.GeneratorTempUtils; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Map; +import java.util.regex.Matcher; + +/** + * @author 猫哥 + * @date 2022-06-06 13:31 + **/ +@Service +public class MybatisPlusGeneratorService { + /** + * Mybatis-plus单表生成模版 + */ + public String generatorMybatisPlusBasicTmp(Map jsonData) { + try { + Context context = GeneratorTempUtils.getVelocityContext(); + context.put("totalData", jsonData); + context.put("basicConfig", jsonData.get("basicConfig")); + context.put("queryConfig", jsonData.get("queryConfig")); + context.put("dbTableConfig", jsonData.get("dbTableConfig")); + context.put("tableConfig", jsonData.get("tableConfig")); + context.put("formConfig", jsonData.get("formConfig")); + Map dbTableConfig = ObjSelfUtils.changeToMap(jsonData.get("dbTableConfig")); + String tbName = dbTableConfig.get("tableNameCase").toString(); + + Map basicConfig = ObjSelfUtils.changeToMap(jsonData.get("basicConfig")); + //包名转路径 + String packagePath = basicConfig.get("packageName").toString().replaceAll("\\.", Matcher.quoteReplacement(File.separator)); + + //entity + Template entityTemp = GeneratorTempUtils.getMybatisPlusTemp("entity.vm"); + FileWriter entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath,"entity") + tbName + ".java"); + entityTemp.merge(context, entityWriter); + entityWriter.close(); + //controller + Template controllerTemp = GeneratorTempUtils.getMybatisPlusTemp("controller.vm"); + FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath,"controller") + tbName + "Controller.java"); + controllerTemp.merge(context, controllerWriter); + controllerWriter.close(); + //service + Template serviceTemp = GeneratorTempUtils.getMybatisPlusTemp("service.vm"); + FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath,"service") + tbName + "Service.java"); + serviceTemp.merge(context, serviceWriter); + serviceWriter.close(); + //mapper + Template mapperTemp = GeneratorTempUtils.getMybatisPlusTemp("mapper.vm"); + FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath,"mapper") + tbName + "Mapper.java"); + mapperTemp.merge(context, mapperWriter); + mapperWriter.close(); + + + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + return exportFilePath; + } catch (IOException e) { + throw new RuntimeException("Mybatis-plus单表生成模版报错" + e); + } + } + + /** + * element-plus多表生成模版 + */ + public void generatorElementPlusTemp(Map jsonData) { + try { + Context context = getContext(jsonData); + Template template = GeneratorTempUtils.getElementPlusTemp("CRUD.vm"); + FileWriter fileWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUD.vue"); + template.merge(context, fileWriter); + fileWriter.close(); + //第二个模板 + Template addModal = GeneratorTempUtils.getElementPlusTemp("CRUDForm.vm"); + FileWriter addModalWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUDForm.vue"); + addModal.merge(context, addModalWriter); + addModalWriter.close(); + } catch (IOException e) { + throw new RuntimeException("element-plus多表生成模版报错" + e); + } + } + + /** + * 生成后端模版 + * + * @param jsonData + * @return + */ + public String generatorBackTempZip(Map jsonData) { + Map commonConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("commonConfig")), Map.class); + if ("true".equals(commonConfig.get("isTableMulChoose").toString())) { + //多表模版 +// generatorMybatisPlusMulTemp(jsonData); + } else { + /*单表*/ +// generatorMybatisPlusTemp(jsonData); + } + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + return exportFilePath; + } + + /** + * 生成前端模版 + * + * @param jsonData + * @return + */ + public String generatorFrontTempZip(Map jsonData) { + Map commonConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("commonConfig")), Map.class); + //多表 + if ("true".equals(commonConfig.get("isTableMulChoose").toString())) { + //生成前端模板 + generatorElementPlusTemp(jsonData); + } else { + /*单表*/ + //生成前端模板 + generatorElementPlusTemp(jsonData); + } + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + return exportFilePath; + } + + + private Context getContext(Map jsonData) { + Context context = GeneratorTempUtils.getVelocityContext(); + context.put("totalData", jsonData); + context.put("projectOrAuthor", jsonData.get("projectOrAuthor")); + context.put("commonConfig", jsonData.get("commonConfig")); + context.put("multiTableConfig", jsonData.get("multiTableConfig")); + context.put("dbTableConfig", jsonData.get("dbTableConfig")); + context.put("apiConfig", jsonData.get("apiConfig")); + context.put("queryConfig", jsonData.get("queryConfig")); + context.put("tableConfig", jsonData.get("tableConfig")); + context.put("formConfig", jsonData.get("formConfig")); + return context; + } + +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java b/basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java index 4329775..83e5cd9 100644 --- a/basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java @@ -33,7 +33,7 @@ public class GeneratorTempUtils { public static final String VelocityTemplateDirMac = "/deploy/velocity-tmp-dir/"; public static final String ElementPlusDir = "front-vms" + File.separator + "element-plus"; public static final String MybatisPlusDir = "back-vms" + File.separator + "mybatis-plus"; - public static final String MybatisPlusMulTbDir = "back-vms" + File.separator + "mybatis-plus-multb"; + public static final String MybatisPlusMulTbDir = "back-vms" + File.separator + "mybatis-plus-multi"; //win public static final String ExportFileDir = "D:\\temp-dir\\export-dir\\"; @@ -73,13 +73,13 @@ public static String getExportMybatisPlusMulDir(String dir) { return fileMkdir(path); } - public static String getExportMybatisPlusDir(String dir) { + public static String getExportMybatisPlusDir(String exportDir,String dir) { String os = System.getProperty("os.name"); String path = ""; if (os.toLowerCase().startsWith("win")) { - path = ExportFileDir + "mybatis-plus" + File.separator + dir + File.separator; + path = ExportFileDir + exportDir + File.separator + dir + File.separator; } else { - path = MacExportFileDir + "mybatis-plus" + File.separator + dir + File.separator; + path = MacExportFileDir + exportDir + File.separator + dir + File.separator; } return fileMkdir(path); } diff --git a/basis-func/src/main/resources/application-db.yml b/basis-func/src/main/resources/application-db.yml index 6cf2856..5eac081 100644 --- a/basis-func/src/main/resources/application-db.yml +++ b/basis-func/src/main/resources/application-db.yml @@ -5,11 +5,11 @@ spring: username: root password: root123 hikari: - connection-timeout: 2000 #最大超时时间 + connection-timeout: 6000 #最大超时时间 maximum-pool-size: 100 #连接数 - max-lifetime: 1800000 #控制池中连接的最大生存期 + max-lifetime: 18000 #控制池中连接的最大生存期 minimum-idle: 10 #此属性控制 HikariCP尝试在池中维护的最小空闲连接数 - validation-timeout: 1000 #此属性控制测试连接是否活跃的最长时间。此值必须小于 connectionTimeout + validation-timeout: 5500 #此属性控制测试连接是否活跃的最长时间。此值必须小于 connectionTimeout idle-timeout: 60000 #此属性控制允许连接在池中处于空闲状态的最长时间 mybatis-plus: diff --git a/basis-func/src/test/java/top/kuanghua/basisfunc/service/GeneratorServiceTest.java b/basis-func/src/test/java/top/kuanghua/basisfunc/service/GeneratorServiceTest.java index 4e5b939..8781260 100644 --- a/basis-func/src/test/java/top/kuanghua/basisfunc/service/GeneratorServiceTest.java +++ b/basis-func/src/test/java/top/kuanghua/basisfunc/service/GeneratorServiceTest.java @@ -108,73 +108,73 @@ public void generatorMybatisPlusMulTemp() throws IOException { /** * element-plus单表生成模版 */ - @Test - public void generatorMybatisPlusTemp() throws IOException { - String string = GeneratorTempUtils.readFileToString("D:\\github\\velocity-tmp-dir\\json-data\\" + "tb_brand.json"); - Map jsonData = JSON.parseObject(string, Map.class); - - Context context = GeneratorTempUtils.getVelocityContext(); - context.put("configData", jsonData); - context.put("projectOrAuthor", jsonData.get("projectOrAuthor")); - context.put("dbTableConfig", jsonData.get("dbTableConfig")); - context.put("apiConfig", jsonData.get("apiConfig")); - context.put("queryConfig", jsonData.get("queryConfig")); - context.put("tableConfig", jsonData.get("tableConfig")); - context.put("formConfig", jsonData.get("formConfig")); - context.put("commonConfig", jsonData.get("commonConfig")); - - - Map dbTableConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("dbTableConfig")), Map.class); - - String tbName = dbTableConfig.get("tableNameCase").toString(); - //entity - Template entityTemp = GeneratorTempUtils.getMybatisPlusTemp("entity.vm"); - FileWriter entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("entity") + tbName + ".java"); - entityTemp.merge(context, entityWriter); - entityWriter.close(); - //controller - Template controllerTemp = GeneratorTempUtils.getMybatisPlusTemp("controller.vm"); - FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("controller") + tbName + "Controller.java"); - controllerTemp.merge(context, controllerWriter); - controllerWriter.close(); - //service - Template serviceTemp = GeneratorTempUtils.getMybatisPlusTemp("service.vm"); - FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("service") + tbName + "Service.java"); - serviceTemp.merge(context, serviceWriter); - serviceWriter.close(); - //mapper - Template mapperTemp = GeneratorTempUtils.getMybatisPlusTemp("mapper.vm"); - FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("mapper") + tbName + "Mapper.java"); - mapperTemp.merge(context, mapperWriter); - mapperWriter.close(); - } - - - /** - * element-plus多表生成模版 - */ - @Test - public void generatorElementPlusTemp() throws IOException { - String string = GeneratorTempUtils.readFileToString("D:\\github\\velocity-tmp-dir\\json-data\\" + "tb_brand.json"); - Map jsonData = JSON.parseObject(string, Map.class); - Context context = GeneratorTempUtils.getVelocityContext(); - context.put("configData", jsonData); - context.put("companyOrAuthor", jsonData.get("companyOrAuthor")); - context.put("dbTableConfig", jsonData.get("dbTableConfig")); - context.put("apiConfig", jsonData.get("apiConfig")); - context.put("queryConfig", jsonData.get("queryConfig")); - context.put("tableConfig", jsonData.get("tableConfig")); - context.put("formConfig", jsonData.get("formConfig")); - context.put("commonConfig", jsonData.get("commonConfig")); - Template template = GeneratorTempUtils.getElementPlusTemp("CRUD.vm"); - FileWriter fileWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUD.vue"); - template.merge(context, fileWriter); - fileWriter.close(); - //第二个模板 - Template addModal = GeneratorTempUtils.getElementPlusTemp("CRUDForm.vm"); - FileWriter addModalWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUDForm.vue"); - addModal.merge(context, addModalWriter); - addModalWriter.close(); - } +// @Test +// public void generatorMybatisPlusTemp() throws IOException { +// String string = GeneratorTempUtils.readFileToString("D:\\github\\velocity-tmp-dir\\json-data\\" + "tb_brand.json"); +// Map jsonData = JSON.parseObject(string, Map.class); +// +// Context context = GeneratorTempUtils.getVelocityContext(); +// context.put("configData", jsonData); +// context.put("projectOrAuthor", jsonData.get("projectOrAuthor")); +// context.put("dbTableConfig", jsonData.get("dbTableConfig")); +// context.put("apiConfig", jsonData.get("apiConfig")); +// context.put("queryConfig", jsonData.get("queryConfig")); +// context.put("tableConfig", jsonData.get("tableConfig")); +// context.put("formConfig", jsonData.get("formConfig")); +// context.put("commonConfig", jsonData.get("commonConfig")); +// +// +// Map dbTableConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("dbTableConfig")), Map.class); +// +// String tbName = dbTableConfig.get("tableNameCase").toString(); +// //entity +// Template entityTemp = GeneratorTempUtils.getMybatisPlusTemp("entity.vm"); +// FileWriter entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("entity") + tbName + ".java"); +// entityTemp.merge(context, entityWriter); +// entityWriter.close(); +// //controller +// Template controllerTemp = GeneratorTempUtils.getMybatisPlusTemp("controller.vm"); +// FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("controller") + tbName + "Controller.java"); +// controllerTemp.merge(context, controllerWriter); +// controllerWriter.close(); +// //service +// Template serviceTemp = GeneratorTempUtils.getMybatisPlusTemp("service.vm"); +// FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("service") + tbName + "Service.java"); +// serviceTemp.merge(context, serviceWriter); +// serviceWriter.close(); +// //mapper +// Template mapperTemp = GeneratorTempUtils.getMybatisPlusTemp("mapper.vm"); +// FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir("mapper") + tbName + "Mapper.java"); +// mapperTemp.merge(context, mapperWriter); +// mapperWriter.close(); +// } +// +// +// /** +// * element-plus多表生成模版 +// */ +// @Test +// public void generatorElementPlusTemp() throws IOException { +// String string = GeneratorTempUtils.readFileToString("D:\\github\\velocity-tmp-dir\\json-data\\" + "tb_brand.json"); +// Map jsonData = JSON.parseObject(string, Map.class); +// Context context = GeneratorTempUtils.getVelocityContext(); +// context.put("configData", jsonData); +// context.put("companyOrAuthor", jsonData.get("companyOrAuthor")); +// context.put("dbTableConfig", jsonData.get("dbTableConfig")); +// context.put("apiConfig", jsonData.get("apiConfig")); +// context.put("queryConfig", jsonData.get("queryConfig")); +// context.put("tableConfig", jsonData.get("tableConfig")); +// context.put("formConfig", jsonData.get("formConfig")); +// context.put("commonConfig", jsonData.get("commonConfig")); +// Template template = GeneratorTempUtils.getElementPlusTemp("CRUD.vm"); +// FileWriter fileWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUD.vue"); +// template.merge(context, fileWriter); +// fileWriter.close(); +// //第二个模板 +// Template addModal = GeneratorTempUtils.getElementPlusTemp("CRUDForm.vm"); +// FileWriter addModalWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUDForm.vue"); +// addModal.merge(context, addModalWriter); +// addModalWriter.close(); +// } } \ No newline at end of file diff --git a/basis-func/src/test/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorServiceTest.java b/basis-func/src/test/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorServiceTest.java new file mode 100644 index 0000000..8a68132 --- /dev/null +++ b/basis-func/src/test/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorServiceTest.java @@ -0,0 +1,30 @@ +package top.kuanghua.basisfunc.service; + +import com.alibaba.fastjson.JSON; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import top.kuanghua.basisfunc.utils.GeneratorTempUtils; + +import java.io.IOException; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * @Title: MybatisPlusGeneratorServiceTest + * @Description: + * @Auther: kuanghua + * @create 2022/10/7 17:03 + */ + +public class MybatisPlusGeneratorServiceTest { + @Test + public void generatorMybatisPlusBasicTmp() throws IOException { + MybatisPlusGeneratorService generatorService = new MybatisPlusGeneratorService(); + String string = GeneratorTempUtils.readFileToString("D:\\github\\micro-service-plus\\velocity-tmp-dir\\json-data\\mybatis-plus\\" + "basicData.json"); + Map jsonData = JSON.parseObject(string, Map.class); + generatorService.generatorMybatisPlusBasicTmp(jsonData); + } +} \ No newline at end of file diff --git a/front-template/aulton-asset/base-model-add-model.vm b/front-template/aulton-asset/base-model-add-model.vm deleted file mode 100644 index 197250d..0000000 --- a/front-template/aulton-asset/base-model-add-model.vm +++ /dev/null @@ -1,96 +0,0 @@ -#parse("formUtils.vm") - - - - - \ No newline at end of file diff --git a/front-template/aulton-asset/base-model-index.vm b/front-template/aulton-asset/base-model-index.vm deleted file mode 100644 index ef38896..0000000 --- a/front-template/aulton-asset/base-model-index.vm +++ /dev/null @@ -1,141 +0,0 @@ -#parse("queryUtils.vm") -#parse("tableUtils.vm") - - - - - diff --git a/front-template/aulton-asset/base-template.vm b/front-template/aulton-asset/base-template.vm deleted file mode 100644 index 862444d..0000000 --- a/front-template/aulton-asset/base-template.vm +++ /dev/null @@ -1,55 +0,0 @@ -#parse("queryUtils.vm") -#parse("tableUtils.vm") -#parse("formUtils.vm") - - \ No newline at end of file diff --git a/front-template/aulton-asset/formUtils.vm b/front-template/aulton-asset/formUtils.vm deleted file mode 100644 index dbd979f..0000000 --- a/front-template/aulton-asset/formUtils.vm +++ /dev/null @@ -1,291 +0,0 @@ -##生成form item -#macro(formItemTemp) -#foreach($item in $formConfig) - #if($item.componentType=="input") ##输入框 input - - - - #elseif($item.componentType=="textarea") ##多行文本框 textarea - - - - #elseif($item.componentType=="radio") ##单选框 radio - - - #foreach($enum in $item.optionDataArr) - ${enum.label} - #end - - - #elseif($item.componentType=="select") ##select - - - #foreach($enum in $item.optionDataArr) - - #end - - - #elseif($item.componentType=="selectApi") ##selectApi - - - - - - - #elseif($item.componentType=="checkbox") ##多选框 checkbox - - - #foreach($enum in $item.optionDataArr) - - #end - - - #elseif($item.componentType=="switch") ##开关 switch - - - - #elseif($item.componentType=="date") ##日期选择 datePicker - - - - #elseif($item.componentType=="time") ##时间选择 timePicker - - - - #elseif($item.componentType=="datetime") ##日期选择 dateTime - - - - #elseif($item.componentType=="datetimerange") ##日期时间选择 dateTimePicker - - - - #elseif($item.componentType=="upload") ##上传组件 upload - - - - - - - - #elseif($item.componentType=="specialDict") ##specialDict - - - - #elseif($item.componentType=="specialMulti") ##specialMulti - - - - #end -#end -#end -##生成form key -#macro(fromKeyData) -#foreach($item in $formConfig) -$item.field:"", -#end -#end -##生成 rule校验 -#macro(rulesData) -#foreach($item in $formConfig) -#if($item.rule=="isNotNull")##必填 -$item.field:{required: true,message:"请输入${item.desc}",trigger:["blur", "change"]}, -#elseif ($item.rule=="positiveInteger")##整数 -$item.field:[{required: true, message: "请输入${item.desc}", trigger: "blur"},{pattern: -/^[0-9]\d*$/,message: "${item.desc}为整数",trigger: "blur",}], -#elseif ($item.rule=="positiveIntegerNotZero")##大于O的整数 -$item.field:[{required: true, message: "请输入${item.desc}", trigger: "blur"},{pattern: -/^\+?[1-9]\d*$/,message: "${item.desc}为正整数",trigger: "blur",}], -#elseif ($item.rule=="regEmail")##邮箱 -$item.field:[{required: true, message: "请输入${item.desc}", trigger: "blur"},{pattern: -/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/,message: "${item.desc}校验失败",trigger: "blur",}], -#elseif ($item.rule=="idCardNumber")##身份证 -$item.field:[{required: true, message: "请输入${item.desc}", trigger: "blur"},{pattern: -/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,message: "${item.desc}校验失败",trigger: "blur",}], -#elseif ($item.rule=="mobilePhone")##手机号 -$item.field:[{required: true, message: "请输入${item.desc}", trigger: "blur"},{pattern: -/^0?1[0-9]{10}$/,message: "${item.desc}校验失败",trigger: "blur",}], -#elseif ($item.rule=="bankCardNo")##银行卡号 -$item.field:[{required: true, message: "请输入${item.desc}", trigger: "blur"},{pattern: -/^\d{15,20}$/,message: "${item.desc}校验失败",trigger: "blur",}], - -#end -#end -#end -##生成data -#macro(formDataScript) -#foreach($item in $formConfig) -#if($item.componentType=="selectApi") ##输入框 input -${item.field}Data:[], -#elseif($item.componentType=="date") ##日期选择 datePicker -#elseif($item.componentType=="time") ##时间选择 timePicker -#elseif($item.componentType=="datetime") ##日期时间选择 dateTimePicker -#elseif($item.componentType=="upload") ##上传组件 upload -fileOptions: [ - { - type: 'upload', - label: '合同正文', - prop: 'pic', - uploadAttrs: { - action: 'https://jsonplaceholder.typicode.com/posts/', - multiple: true, - limit: 3 - }, - rules: [ - { - required: true, - message: '上传合同正文', - trigger: 'blur' - } - ] - }, - #end - #end -#end -##生成method -#macro(formMethodScript) - #foreach($item in $formConfig) - #if($item.compoentType=="selectApi") ##输入框 input - this.${item.field}Req(){ - this.$api.${frontConfig.apiFileName}.${item.field}FormReq().then((response) => { - this.${item.field}Data = response.data; - }) - } - }, - #elseif($item.componentType=="specialDict") ##specialDict - ${item.field}Change(code) { - const dictItem = getDictItemsFromCache('$!item.dictCode') - dictItem.map((item) => { - if (item.code === String(code)) { - this.form.${item.field} = item.name - } - }) - }, - #elseif($item.componentType=="specialMulti") ##specialMulti - ${item.field}Change(code) { - const dictItem = getDictItemsFromCache('$!item.dictCode') - dictItem.map((item) => { - if (item.code === String(code)) { - this.form.${item.field} = item.name - } - }) - }, - #elseif($item.componentType=="date") ##日期选择 datePicker - #elseif($item.componentType=="time") ##时间选择 timePicker - #elseif($item.componentType=="datetime") ##日期时间选择 dateTimePicker - #elseif($item.componentType=="upload") ##上传组件 upload - #end - #end -#end -##生成mounted -#macro(formMountedScript) - #foreach($item in $formConfig) - #if($item.componentType=="selectApi") ##输入框 selectApi - this.${item.field}Req() - #elseif($item.componentType=="date") ##日期选择 datePicker - #elseif($item.componentType=="time") ##时间选择 timePicker - #elseif($item.componentType=="dateTime") ##日期时间选择 dateTimePicker - #elseif($item.componentType=="upload") ##上传组件 upload - #end - #end -#end -##生成详情请求接口 -#macro(detailReq) -this.$api.${frontConfig.apiFileName}.${frontConfig.apiFileName}Detail(data).then((response) => { -this.formData = response.data; -this.status = true; -}).catch(() => { -}); -#end -##生成保存请求接口 -#macro(insertReq) -this.$api.${frontConfig.apiFileName}.${frontConfig.apiFileName}Insert(data).then((response) => { -if (response.code === "200") { -this.$message.success("保存成功"); -this.status = false; -this.successStatus = true; -} -}); -#end - -##生成更新请求接口 -#macro(updateReq) -this.$api.${frontConfig.apiFileName}.${frontConfig.apiFileName}Update(data).then((response) => { -if (response.code === "200") { -this.$message.success("更新成功"); -this.status = false; -this.successStatus = true; -} -}); -#end diff --git a/front-template/aulton-asset/queryUtils.vm b/front-template/aulton-asset/queryUtils.vm deleted file mode 100644 index 68e23db..0000000 --- a/front-template/aulton-asset/queryUtils.vm +++ /dev/null @@ -1,94 +0,0 @@ -#parse("utils.vm") -#groupArrByKey($queryConfig,"controlType") -##queryItem -#macro(queryItemScript) -#foreach($entry in $gabkMap.entrySet()) - #if($entry.key=="elDataPicker") - #set($evItem=$entry.value[0]) - $entry.key:{ - label: "$evItem.desc", - dateRange: ['', ''], - type: 'daterange', - beginDate: '$evItem.field', - //endDate: 'stationOpenEndDate' - }, - #else - $entry.key:[ - #foreach($item in $entry.value) - #if($item.componentType=="input") - { - label: "$item.desc", - key: "$item.field", - placeholder: "请输入${item.desc}", - }, - #elseif($item.componentType=="select") - { - label: "$item.desc", - key: '$item.field', - option: [ - #foreach($odItem in $item.optionDataArr) - { - key: "$odItem.value", - value: "$odItem.label" - }, - #end - ] - }, - #elseif($item.componentType=="selectApi") - { - label: "$item.desc", - key: '$item.field', - option: this.${item.field}Data - }, - #elseif($item.componentType=="selectDict") - { - label: "$item.desc", - key: "$item.field", - componentType:"$item.componentType", - dictCode: "$!item.dictCode", - }, - #elseif($item.componentType=="specialDict") - { - label: "$item.desc", - key: "$item.field", - type: '$!item.type', - componentType:"$item.componentType", - dictCode: "$!item.dictCode", - selectProps: { - value: 'name', - label: 'code' - } - }, - #end - #end - ], - #end - #end -#end -##data -#macro(queryDataScript) - #foreach($qcItem in $queryConfig) - #if($qcItem.componentType=="selectApi") - ${qcItem.field}Data:[], - #end - #end -#end -##method -#macro(queryMethodScript) - #foreach($qcItem in $queryConfig) - #if($qcItem.componentType=="selectApi") - this.$api.${frontConfig.apiFileName}.${qcItem.fielnd}QueryReq().then((response) => { - this.${qcItem.field}Data = response.data; - }).catch(() => {}); - }, - #end - #end -#end -##mounted -#macro(queryMountedScript) - #foreach($qcItem in $queryConfig) - #if($qcItem.componentType=="selectApi") - this.${qcItem.field}Req() - #end - #end -#end \ No newline at end of file diff --git a/front-template/aulton-asset/req-api.vm b/front-template/aulton-asset/req-api.vm deleted file mode 100644 index f137798..0000000 --- a/front-template/aulton-asset/req-api.vm +++ /dev/null @@ -1,82 +0,0 @@ -import request from '@/lib/axios' -/** -*${frontConfig.apiFileName}查询数据 -* @param {*} params -*/ -export const ${frontConfig.apiFileName}Query = (params) => { -return request('${apiConfig.queryApi}', { -params: params, -method: '${apiConfig.queryApiType}' -}) -} -/** -* -* @param {*} data -*/ -export const ${frontConfig.apiFileName}Insert = (data) => { -return request('${apiConfig.insertApi}', { -data: data, -method: '${apiConfig.insertApiType}' -}) -} - -/** -*${frontConfig.apiFileName}更新接口 -* @param {*} data json数据 -*/ -export const ${frontConfig.apiFileName}Update = (data) => { -return request('${apiConfig.updateApi}', { -data: data, -method: '${apiConfig.updateApiType}' -}) -} -/** -*${frontConfig.apiFileName}详情 -* @param {*} params -*/ -export const ${frontConfig.apiFileName}Detail = (params) => { -return request('${apiConfig.detailApi}', { -params: params, -method: '${apiConfig.detailApiType}' -}) -} -/** -* ${frontConfig.apiFileName}删除接口 -* @param {*} params -*/ -export const ${frontConfig.apiFileName}Delete = (params) => { -return request('${apiConfig.deleteApi}', { -params: params, -method: '${apiConfig.deleteApiType}' -}) -} -##生成queryItem里的api查询接口 -#foreach($item in $queryConfig) - #if($item.compoentType=="selectApi") ##输入框 input - /** - * ${item.desc}接口 - * @param {*} params - */ - export const ${item.fielnd}QueryReq = () => { - return request('${item.api}', { - //params: params, - method: '${item.method}' - }) - } - #end -#end -##生成formItem里的api查询接口 -#foreach($item in $formConfig) - #if($item.compoentType=="selectApi") ##输入框 input - /** - * ${item.desc}接口 - * @param {*} params - */ - export const ${item.fielnd}FormReq = () => { - return request('${item.api}', { - //params: params, - method: '${item.requestType}' - }) - } - #end -#end diff --git a/front-template/aulton-asset/tableUtils.vm b/front-template/aulton-asset/tableUtils.vm deleted file mode 100644 index 72b3f4f..0000000 --- a/front-template/aulton-asset/tableUtils.vm +++ /dev/null @@ -1,88 +0,0 @@ -##column -#macro(tableColumnScript) -#foreach($item in $tableConfig) - #if($foreach.count==1) - { - label: '$item.desc', - prop: '$item.field', - 'min-width': "$!item.width", - align: 'left' - }, - #else - { - label: '$item.desc', - prop: '$item.field', - 'min-width': "$!item.width", - }, - #end - #end -#end -##tableDataReq -#macro(tableDataReq) -this.$api.${frontConfig.apiFileName}.${frontConfig.apiFileName}Query(data).then((response) => { -this.dataSource.data = response.data -this.dataSource.pageData.total = response.total -}) -.catch(() => { -}) -#end -##deleteReq -#macro(deleteReq) -this.$api.${frontConfig.apiFileName}.${frontConfig.apiFileName}Delete(data).then((response) => { -if (response.code === "200") { -this.$message.success("删除成功"); -this.status = false; -this.successStatus = true; -} -}); -#end -##dataSourceTool -#macro(tableDataSourceTool) -tool: [ - #if($frontConfig.tableNeedExport) - { - name: '导出', - handleClick: this.handleExport - }, - #end - #if($frontConfig.tableNeedImport) - { - btnName: '导入发货单', - modelExcelType: 'exportEquipmentSend', - importExcelType: 'importEquipmentSend', - component: 'Import' // 配置列表设置组件 - }, - #end -{ -component: 'Drag' // 配置列表设置组件 -} -], -#end -##tableScript -#macro(tableExportMethod) - #if($frontConfig.tableNeedExport) - handleExport() { - const params = JSON.parse(JSON.stringify(this.listQuery)) - params.pageIndex = 1 - params.pageSize = 1000 - // delete params.time - this.$request('$frontConfig.exportUrl', { - data: params - }).then((response) => { - this.$alert('请前往导出中心下载表格', '提交成功', { - confirmButtonText: '去下载表格', - callback: (action) => { - if (action === 'confirm') { - const rt=this.$router - rt.push({ - path: '/center/index', - query: { activeType: 2 } - }) - } - } - }) - }) - .catch(() => {}) - }, - #end -#end \ No newline at end of file diff --git a/front-template/aulton-asset/utils.vm b/front-template/aulton-asset/utils.vm deleted file mode 100644 index 9c6e786..0000000 --- a/front-template/aulton-asset/utils.vm +++ /dev/null @@ -1,24 +0,0 @@ -##根据数组某个key分组 -#macro(groupArrByKey $arrs $group_key) - #set($gabkMap={}) - #foreach($ai in $arrs) - #if(!$!gabkMap[$ai[$group_key]]) - #set($gabkMap[$ai[$group_key]] = [$ai]) - #else - #if($gabkMap[$ai[$group_key]].add($ai)) - #end - #end - #end -#end -##根据数组某个deep key分组 -#macro(groupArrByDeepKey $arrs $group_key $group_deep_key) - #set($gabkDeepMap={}) - #foreach($ai in $arrs) - #if(!$!gabkDeepMap[$ai[$group_key][$group_deep_key]]) - #set($gabkDeepMap[$ai[$group_key][$group_deep_key]] = [$ai]) - #else - #if($gabkDeepMap[$ai[$group_key][$group_deep_key]].add($ai)) - #end - #end - #end -#end \ No newline at end of file diff --git a/front-template/settlement/add-edit-api.vm b/front-template/settlement/add-edit-api.vm deleted file mode 100644 index 2491fe7..0000000 --- a/front-template/settlement/add-edit-api.vm +++ /dev/null @@ -1,54 +0,0 @@ -import request from '@/lib/axios' -/** -* -*${frontConfig.apiFileName}新增 -*/ -export const ${frontConfig.apiFileName}Insert = (data) => { - return request('${apiConfig.insertApi}', { - data: data, - method: '${apiConfig.insertMethod}' - }) -} - -/** -*${frontConfig.apiFileName}更新 -* @param {*} data json数据 -*/ -export const ${frontConfig.apiFileName}Update = (data) => { - return request('${apiConfig.updateApi}', { - data: data, - method: '${apiConfig.updateMethod}' - }) -} -##生成queryItem里的api查询接口 -#foreach($item in $queryConfig) - #if($item.componentType=="selectApi") ##输入框 input - /** - * ${item.desc}接口 - * @param {*} params - */ - export const ${item.field}Req = (data) => { - return request('${item.api}', { - data, - method: '${item.method}' - }) - } - #end -#end - - -##生成formItem里的api查询接口 -#foreach($item in $formConfig) - #if($item.compoentType=="selectApi") ##输入框 input - /** - * ${item.desc}接口 - * @param {*} data - */ - export const ${item.field}Req = (data) => { - return request('${item.api}', { - data, - method: '${item.method}' - }) - } - #end -#end diff --git a/front-template/settlement/add-edit-table-api.vm b/front-template/settlement/add-edit-table-api.vm deleted file mode 100644 index e3417ca..0000000 --- a/front-template/settlement/add-edit-table-api.vm +++ /dev/null @@ -1,18 +0,0 @@ -import request from '@/lib/axios' - - -##生成formItem里的api查询接口 -#foreach($item in $tableListConfig) - #if($item.compoentType=="selectApi") ##输入框 input - /** - * ${item.desc}接口 - * @param {*} data - */ - export const ${item.field}Req = (data) => { - return request('${item.api}', { - data, - method: '${item.method}' - }) - } - #end -#end diff --git a/front-template/settlement/add-edit-table-utils.vm b/front-template/settlement/add-edit-table-utils.vm deleted file mode 100644 index 5fb9ca9..0000000 --- a/front-template/settlement/add-edit-table-utils.vm +++ /dev/null @@ -1,74 +0,0 @@ -#macro(tableItemTemp) - #foreach($item in $tableListConfig) - #if($item.componentType=="input") ##输入框 input - - #if($item.isTemplate=="true") - - #end - - #elseif($item.componentType=="select") ##select - - #if($item.isTemplate=="true") - - #end - - #elseif($item.componentType=="selectApi") ##selectApi - - #if($item.isTemplate=="true") - - #end - - #end - #end -#end - - - -##生成data -#macro(formDataScript) - #foreach($item in $tableListConfig) - #if($item.componentType=="selectApi") ##输入框 input - ${item.field}Data:[], - ##elseif($item.componentType=="date") ##日期选择 datePicker - ##elseif($item.componentType=="time") ##时间选择 timePicker - #end - #end -#end - - -##生成method -#macro(formMethodScript) - #foreach($item in $tableListConfig) - #if($item.componentType=="selectApi") - ${item.field}Req(){ - this.globalApi.${frontConfig.apiFileName}.${item.field}Req().then(({data}) => { - this.${item.field}Data = data - }) - }, - #end - #end -#end -##生成mounted -#macro(formMountedScript) - #foreach($item in $tableListConfig) - #if($item.componentType=="selectApi") ##输入框 selectApi - this.${item.field}Req() - #end - #end -#end diff --git a/front-template/settlement/add-edit-table.vm b/front-template/settlement/add-edit-table.vm deleted file mode 100644 index a5bbf83..0000000 --- a/front-template/settlement/add-edit-table.vm +++ /dev/null @@ -1,78 +0,0 @@ -#parse("add-edit-table-utils.vm") - - - - - - diff --git a/front-template/settlement/add-edit.vm b/front-template/settlement/add-edit.vm deleted file mode 100644 index 52db9bf..0000000 --- a/front-template/settlement/add-edit.vm +++ /dev/null @@ -1,68 +0,0 @@ -#parse("formUtils.vm") - - - - - - diff --git a/front-template/settlement/detail-api.vm b/front-template/settlement/detail-api.vm deleted file mode 100644 index 2cca8cc..0000000 --- a/front-template/settlement/detail-api.vm +++ /dev/null @@ -1,8 +0,0 @@ -/** -*${frontConfig.apiFileName}详情 -*/ -export const ${frontConfig.apiFileName}Detail = (id) => { - return request(`${apiConfig.detailApi}`, { - method: `${apiConfig.detailMethod}` - }) -} \ No newline at end of file diff --git a/front-template/settlement/detail.vm b/front-template/settlement/detail.vm deleted file mode 100644 index fdabd7e..0000000 --- a/front-template/settlement/detail.vm +++ /dev/null @@ -1,51 +0,0 @@ -#parse("detailUtils.vm") - - - - - diff --git a/front-template/settlement/detailUtils.vm b/front-template/settlement/detailUtils.vm deleted file mode 100644 index eb3df17..0000000 --- a/front-template/settlement/detailUtils.vm +++ /dev/null @@ -1,76 +0,0 @@ -#macro(detailContainer) - #foreach($pItem in $tableConfigArr) - ## 横向 - #if($pItem.direction=="1") - -
- #foreach($fItem in $pItem.dillColumnArr) -
- #foreach($sItem in $fItem ) -
-
- ${sItem.desc}: - #if($sItem.componentType=="input") ##input - {{detailData.$sItem.columnName}} - #elseif($sItem.componentType=="select") ##select - #foreach($enum in $sItem.optionDataArr) - ${enum.label} - #end - #end -
-
- #end -
- #end -
-
- #end - ## 纵向 - #if($pItem.direction=="2") - - #foreach($fItem in $pItem.dillColumnArr) -
- #foreach($sItem in $fItem ) -
- ${sItem.desc}: - #if($sItem.componentType=="input") ##input - {{detailData.$sItem.columnName}} - #elseif($sItem.componentType=="select") ##select - #foreach($enum in $sItem.optionDataArr) - ${enum.label} - #end - #end -
- #end -
- #end -
- #end - ## 表格 - #if($pItem.direction=="3") - - - #foreach($fItem in $pItem.dillColumnArr) - #if($fItem.isTemplate==true) - - - - #else - - #end - #end - - - #end - #end -#end diff --git a/front-template/settlement/formUtils.vm b/front-template/settlement/formUtils.vm deleted file mode 100644 index 282a602..0000000 --- a/front-template/settlement/formUtils.vm +++ /dev/null @@ -1,156 +0,0 @@ -##生成form item -#macro(formItemTemp) -#foreach($item in $tableList) - #if($item.componentType=="input") ##输入框 input - - - - #elseif($item.componentType=="textarea") ##多行文本框 textarea - - - - #elseif($item.componentType=="radio") ##单选框 radio - - - #foreach($enum in $item.optionDataArr) - ${enum.label} - #end - - - #elseif($item.componentType=="select") ##select - - - #foreach($enum in $item.optionDataArr) - - #end - - - #elseif($item.componentType=="selectApi") ##selectApi - - - - - - - #elseif($item.componentType=="checkbox") ##多选框 checkbox - - - #foreach($enum in $item.optionDataArr) - - #end - - - #elseif($item.componentType=="switch") ##开关 switch - - - - #elseif($item.componentType=="date") ##日期选择 datePicker - - - - #elseif($item.componentType=="daterange") ##日期时间选择 dateTimePicker - - - - #elseif($item.componentType=="uploadImage") ##上传组件 upload - - - - #elseif($item.componentType=="table") ##上传组件 upload - - - - #end -#end -#end -##生成form key -#macro(fromKeyData) - #foreach($item in $tableList) - $item.field:"", //$item.desc - #end -#end - -##生成import -#macro(subFormImport) - #foreach($item in $tableList) - #if($item.componentType=="table") ##输入框 input - import AddEditTable from './add-edit-table.vue' - #end - #end -#end - -##生成component -#macro(subFormComponent) - #foreach($item in $tableList) - #if($item.componentType=="table") ##输入框 input - AddEditTable, - #end - #end -#end - -##生成data -#macro(formDataScript) - #foreach($item in $tableList) - #if($item.componentType=="selectApi") ##输入框 input - ${item.field}Data:[], - ##elseif($item.componentType=="date") ##日期选择 datePicker - ##elseif($item.componentType=="time") ##时间选择 timePicker - #end - #end -#end - - -##生成method -#macro(formMethodScript) - #foreach($item in $tableList) - #if($item.componentType=="selectApi") - ${item.field}Req(){ - this.globalApi.${frontConfig.apiFileName}.${item.field}Req().then(({data}) => { - this.${item.field}Data = data - }) - }, - #end - #end -#end -##生成mounted -#macro(formMountedScript) - #foreach($item in $tableList) - #if($item.componentType=="selectApi") ##输入框 selectApi - this.${item.field}Req() - #end - #end -#end - diff --git a/front-template/settlement/queryApi.vm b/front-template/settlement/queryApi.vm deleted file mode 100644 index a79ee3a..0000000 --- a/front-template/settlement/queryApi.vm +++ /dev/null @@ -1,39 +0,0 @@ -import request from '@/lib/axios' -/** -* ${frontConfig.apiFileName}查询 -* @param {*} data -*/ -export const tableQuery = (data) => { - return request('${apiConfig.queryApi}', { - data:data||{}, - method: '${apiConfig.queryMethod}' - }) -} - - -/** -* ${frontConfig.apiFileName}作废 -* @param {*} params -*/ -export const splitfeeInvalid = id => { - return request(`/api/v1.0/feePolicy/${id}`, { - method: '${apiConfig.invalidMethod}' - }) -} - - -##生成queryItem里的api查询接口 -#foreach($item in $queryConfig) - #if($item.componentType=="selectApi") ##输入框 input - /** - * ${item.desc}接口 - * @param {*} data - */ - export const ${item.field}Req = (data) => { - return request('${item.api}', { - data: data||{}, - method: '${item.method}' - }) - } - #end -#end diff --git a/front-template/settlement/table-query-utils.vm b/front-template/settlement/table-query-utils.vm deleted file mode 100644 index 8340bf9..0000000 --- a/front-template/settlement/table-query-utils.vm +++ /dev/null @@ -1,127 +0,0 @@ -#*查询表单部分*# -##生成query from 的 item -#macro(queryFormItemTmp) - #foreach($item in $queryConfig) - #if($item.componentType=="input") ##input - - - - #elseif($item.componentType=="select") ##select - - - #foreach($enum in $item.optionDataArr) - - #end - - - #elseif($item.componentType=="selectApi") ##selectApi - - - - - - #elseif($item.componentType=="datetime") ##日期选择 dateTime - - - - #elseif($item.componentType=="datetimerange") ##日期时间选择 dateTimePicker - - - - #end - #end -#end - -##自定义表头后的数据 -#macro(customTableHead) - #foreach($item in $tableList) - #if($item.isTemplate=="true") - - - - #end - #end -#end - - -#macro(queryformKey) - #foreach($item in $queryConfig) - $item.field:"", - #end -#end - -#*表单selectApi请求*# -#macro(queryDataScript) - #foreach($qcItem in $queryConfig) - #if($qcItem.componentType=="selectApi") - ${qcItem.field}Data:[], - #end - #end -#end -##method -#macro(queryMethodScript) - #foreach($qcItem in $queryConfig) - #if($qcItem.componentType=="selectApi") - ${qcItem.field}Req(){ - this.globalApi.${frontConfig.apiFileName}.${qcItem.field}Req().then(({data}) => { - this.${qcItem.field}Data = data; - }) - }, - #end - #end -#end -##mounted -#macro(queryMountedScript) - #foreach($qcItem in $queryConfig) - #if($qcItem.componentType=="selectApi") - this.${qcItem.field}Req() - #end - #end -#end - -#*表格部分*# -#macro(tableOfHead) - #foreach($item in $tableList) - { prop: "$item.field", label: "$item.desc", minWidth: $item.width,isTemplate:${item.isTemplate} }, - #end -#end - diff --git a/front-template/settlement/table-query.vm b/front-template/settlement/table-query.vm deleted file mode 100644 index a26c49f..0000000 --- a/front-template/settlement/table-query.vm +++ /dev/null @@ -1,158 +0,0 @@ -#parse("table-query-utils.vm") - - - - - diff --git a/front-template/settlement/tableUtils.vm b/front-template/settlement/tableUtils.vm deleted file mode 100644 index 72b3f4f..0000000 --- a/front-template/settlement/tableUtils.vm +++ /dev/null @@ -1,88 +0,0 @@ -##column -#macro(tableColumnScript) -#foreach($item in $tableConfig) - #if($foreach.count==1) - { - label: '$item.desc', - prop: '$item.field', - 'min-width': "$!item.width", - align: 'left' - }, - #else - { - label: '$item.desc', - prop: '$item.field', - 'min-width': "$!item.width", - }, - #end - #end -#end -##tableDataReq -#macro(tableDataReq) -this.$api.${frontConfig.apiFileName}.${frontConfig.apiFileName}Query(data).then((response) => { -this.dataSource.data = response.data -this.dataSource.pageData.total = response.total -}) -.catch(() => { -}) -#end -##deleteReq -#macro(deleteReq) -this.$api.${frontConfig.apiFileName}.${frontConfig.apiFileName}Delete(data).then((response) => { -if (response.code === "200") { -this.$message.success("删除成功"); -this.status = false; -this.successStatus = true; -} -}); -#end -##dataSourceTool -#macro(tableDataSourceTool) -tool: [ - #if($frontConfig.tableNeedExport) - { - name: '导出', - handleClick: this.handleExport - }, - #end - #if($frontConfig.tableNeedImport) - { - btnName: '导入发货单', - modelExcelType: 'exportEquipmentSend', - importExcelType: 'importEquipmentSend', - component: 'Import' // 配置列表设置组件 - }, - #end -{ -component: 'Drag' // 配置列表设置组件 -} -], -#end -##tableScript -#macro(tableExportMethod) - #if($frontConfig.tableNeedExport) - handleExport() { - const params = JSON.parse(JSON.stringify(this.listQuery)) - params.pageIndex = 1 - params.pageSize = 1000 - // delete params.time - this.$request('$frontConfig.exportUrl', { - data: params - }).then((response) => { - this.$alert('请前往导出中心下载表格', '提交成功', { - confirmButtonText: '去下载表格', - callback: (action) => { - if (action === 'confirm') { - const rt=this.$router - rt.push({ - path: '/center/index', - query: { activeType: 2 } - }) - } - } - }) - }) - .catch(() => {}) - }, - #end -#end \ No newline at end of file diff --git a/front-template/settlement/utils.vm b/front-template/settlement/utils.vm deleted file mode 100644 index 9c6e786..0000000 --- a/front-template/settlement/utils.vm +++ /dev/null @@ -1,24 +0,0 @@ -##根据数组某个key分组 -#macro(groupArrByKey $arrs $group_key) - #set($gabkMap={}) - #foreach($ai in $arrs) - #if(!$!gabkMap[$ai[$group_key]]) - #set($gabkMap[$ai[$group_key]] = [$ai]) - #else - #if($gabkMap[$ai[$group_key]].add($ai)) - #end - #end - #end -#end -##根据数组某个deep key分组 -#macro(groupArrByDeepKey $arrs $group_key $group_deep_key) - #set($gabkDeepMap={}) - #foreach($ai in $arrs) - #if(!$!gabkDeepMap[$ai[$group_key][$group_deep_key]]) - #set($gabkDeepMap[$ai[$group_key][$group_deep_key]] = [$ai]) - #else - #if($gabkDeepMap[$ai[$group_key][$group_deep_key]].add($ai)) - #end - #end - #end -#end \ No newline at end of file diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/RoleController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/RoleController.java new file mode 100644 index 0000000..4786b2a --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/RoleController.java @@ -0,0 +1,145 @@ + + + +package top.kuanghua.integrationfront.controller; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; +import top.kuanghua.commonpom.entity.ResResult; +import top.kuanghua.commonpom.entity.SelfCommonParams; +import top.kuanghua.commonpom.utils.ObjSelfUtils; +import top.kuanghua.integrationfront.entity.Role; +import top.kuanghua.integrationfront.service.RoleService; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 角色Controller + * + * @author 熊猫哥 + * @since 2022-10-07 16:33:13 + */ +@Api(tags = "角色(Role)") +@RestController +@RequestMapping("role") +public class RoleController { + + @Resource + private RoleService roleService; + + /** + * 分页查询所有数据 + * @return ResResult + */ + @GetMapping("selectPage") + @ApiOperation(value = "分页查询所有数据") + + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "角色ID"), + @ApiImplicitParam(name = "name", value = "角色名称"), + }) + public ResResult selectPage( @RequestParam("id") String id, + @RequestParam("code") String code, + @RequestParam("editor") String editor, + @RequestParam("name") String name, + @RequestParam("createTime") String createTime, + SelfCommonParams commonParams) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + //角色ID + if (ObjSelfUtils.isNotEmpty( id)) { + queryWrapper.like("id", id); + } + //角色唯一CODE代码 + if (ObjSelfUtils.isNotEmpty( code)) { + queryWrapper.like("code", code); + } + //修改人 + if (ObjSelfUtils.isNotEmpty( editor)) { + queryWrapper.like("editor", editor); + } + //角色名称 + if (ObjSelfUtils.isNotEmpty( name)) { + queryWrapper.like("name", name); + } + //创建时间 + queryWrapper.orderByDesc("create_time"); + if (ObjSelfUtils.isNotEmpty(commonParams.getStartTime())) { + queryWrapper.between("create_time", commonParams.getStartTime(), commonParams.getEndTime()); + } + + queryWrapper.select("id,parent_id,code,intro,create_time,creator,update_time,editor,deleted"); + + Page rolePage = this.roleService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(),queryWrapper); + return new ResResult().success(rolePage); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("selectById") + @ApiOperation(value = "通过id主键查询单条数据") + public ResResult selectById(@RequestParam("id") Long id) { + return new ResResult().success(this.roleService.selectById(id)); + } + + /** + * @Description: 根据id数组查询品牌列表 + * @Param: idList id数组 + * @return: ids列表数据 + */ + @ApiOperation(value = "根据id数组查询品牌列表") + @PostMapping("selectBatchIds") + public ResResult selectBatchIds(@RequestParam("idList") List< Long > idList) { + return new ResResult().success(this.roleService.selectBatchIds(idList)); + } + + /** + * 新增数据 + * + * @param role 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping("insert") + public ResResult insert(@RequestBody Role role) { + return new ResResult().success(this.roleService.insert(role)); + } + + /** + * 修改数据 + * + * @param role 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "根据id修改数据") + @PutMapping("updateById") + public ResResult updateById(@RequestBody Role role) { + return new ResResult().success(this.roleService.updateById(role)); + } + + /** + * 删除数据 + * + * @param idList 主键结合 + * @return 删除结果 + */ + @ApiOperation(value = "根据id数组删除数据") + @DeleteMapping("deleteBatchIds") + public ResResult deleteBatchIds(@RequestBody List< Long > idList) { + return new ResResult().success(this.roleService.deleteBatchIds(idList)); + } + + @DeleteMapping("根据id删除数据") + public ResResult deleteById(@RequestParam("id") Long id) { + return new ResResult().success(this.roleService.deleteById(id)); + } +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java index a950502..3780d7d 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java @@ -1,5 +1,4 @@ package top.kuanghua.integrationfront.entity; - import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -10,27 +9,37 @@ import java.io.Serializable; import java.util.Date; - /** - * 角色表(Role)表实体类 + * 角色实体类 * - * @author kuanghua - * @since 2021-01-18 12:12:37 + * @author 熊猫哥 + * @since 2022-10-07 16:33:13 */ @Data -@ApiModel("角色表") -@TableName(value = "tb_role") -public class Role extends Model { - @ApiModelProperty(value = "角色id") - private Integer id; - @ApiModelProperty(value = "角色名称") - private String name; - @ApiModelProperty(value = "更新时间") +@ApiModel("角色") +@TableName(value = "t_role") +public class Role extends Model< Role > { + @ApiModelProperty(value = "角色ID(修改时需要传递)",hidden=false) + private Long id; + @ApiModelProperty(value = "所属父级角色ID(不传为顶级父id)",hidden=false) + private Long parentId; + @ApiModelProperty(value = "角色唯一CODE代码",hidden=false) + private String code; + @ApiModelProperty(value = "角色介绍",hidden=false) + private String intro; + @ApiModelProperty(value = "创建时间",hidden = true) + @TableField(fill = FieldFill.INSERT) + private Date createTime; + @ApiModelProperty(value = "创建人",hidden=true) + private String creator; + @ApiModelProperty(value = "修改时间",hidden = true) @TableField(fill = FieldFill.UPDATE) private Date updateTime; - @ApiModelProperty(value = "创建时间") - @TableField(fill = FieldFill.INSERT) - private Date createdTime; + @ApiModelProperty(value = "修改人",hidden=true) + private String editor; + @ApiModelProperty(value = "逻辑删除",hidden=true) + private Integer deleted; + /** * 获取主键值 * @@ -40,4 +49,4 @@ public class Role extends Model { protected Serializable pkVal() { return this.id; } -} \ No newline at end of file +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/RoleMapper.java b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/RoleMapper.java index 3e09425..eb02cb3 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/RoleMapper.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/RoleMapper.java @@ -1,14 +1,13 @@ package top.kuanghua.integrationfront.mapper; - import com.baomidou.mybatisplus.core.mapper.BaseMapper; import top.kuanghua.integrationfront.entity.Role; - /** - * 角色表(Role)表数据库访问层 - * - * @author kuanghua - * @since 2021-01-18 12:12:38 - */ -public interface RoleMapper extends BaseMapper { +* 角色Mapper +* +* @author 熊猫哥 +* @since 2022-10-07 16:33:13 +*/ + +public interface RoleMapper extends BaseMapper< Role > { -} \ No newline at end of file +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/service/RoleService.java b/integration-front/src/main/java/top/kuanghua/integrationfront/service/RoleService.java index 4bdf8e4..692121b 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/service/RoleService.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/service/RoleService.java @@ -1,5 +1,4 @@ package top.kuanghua.integrationfront.service; - import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.springframework.stereotype.Service; @@ -7,31 +6,45 @@ import top.kuanghua.integrationfront.mapper.RoleMapper; import javax.annotation.Resource; +import java.util.List; /** - * (Role) - * - * @author kuanghua - * @since 2020-10-27 20:54:24 - */ +* 角色Service +* +* @author 熊猫哥 +* @since 2022-10-07 16:33:13 +*/ @Service public class RoleService { @Resource private RoleMapper roleMapper; - public Page selectPage(Integer pageNum, Integer pageSize, - Role role) { - QueryWrapper queryWrapper = new QueryWrapper<>(role); - return this.roleMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); + public Page< Role > selectPage(Integer pageNum, Integer pageSize, QueryWrapper< Role > queryWrapper) { + return this.roleMapper.selectPage(new Page< Role >(pageNum, pageSize), queryWrapper); + } + + public Role selectById(Long id) { + return this.roleMapper.selectById(id); + } + + public List< Role > selectBatchIds(List< Long > idList) { + return this.roleMapper.selectBatchIds(idList); } public int insert(Role role) { - return this.roleMapper.insert(role); + return this.roleMapper.insert(role); } public int updateById(Role role) { - return this.roleMapper.updateById(role); + return this.roleMapper.updateById(role); + } + + public int deleteById(Long id) { + return this.roleMapper.deleteById(id); } -} \ No newline at end of file + public int deleteBatchIds(List< Long > idList) { + return this.roleMapper.deleteBatchIds(idList); + } +} diff --git a/integration-front/src/main/resources/application-db.yml b/integration-front/src/main/resources/application-db.yml index b1abd47..0049a6b 100644 --- a/integration-front/src/main/resources/application-db.yml +++ b/integration-front/src/main/resources/application-db.yml @@ -6,7 +6,7 @@ spring: password: root123 hikari: connection-timeout: 60000 - validation-timeout: 3000 + validation-timeout: 6000 idle-timeout: 60000 login-timeout: 5 max-lifetime: 60000 diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/controllerMul.vm b/velocity-tmp-dir/back-vms-bak/mybatis-plus-multi/controllerMul.vm similarity index 100% rename from velocity-tmp-dir/back-vms/mybatis-plus-multb/controllerMul.vm rename to velocity-tmp-dir/back-vms-bak/mybatis-plus-multi/controllerMul.vm diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/entity.vm b/velocity-tmp-dir/back-vms-bak/mybatis-plus-multi/entity.vm similarity index 100% rename from velocity-tmp-dir/back-vms/mybatis-plus-multb/entity.vm rename to velocity-tmp-dir/back-vms-bak/mybatis-plus-multi/entity.vm diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/entityMul.vm b/velocity-tmp-dir/back-vms-bak/mybatis-plus-multi/entityMul.vm similarity index 100% rename from velocity-tmp-dir/back-vms/mybatis-plus-multb/entityMul.vm rename to velocity-tmp-dir/back-vms-bak/mybatis-plus-multi/entityMul.vm diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/entityVo.vm b/velocity-tmp-dir/back-vms-bak/mybatis-plus-multi/entityVo.vm similarity index 100% rename from velocity-tmp-dir/back-vms/mybatis-plus-multb/entityVo.vm rename to velocity-tmp-dir/back-vms-bak/mybatis-plus-multi/entityVo.vm diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/mapper.vm b/velocity-tmp-dir/back-vms-bak/mybatis-plus-multi/mapper.vm similarity index 100% rename from velocity-tmp-dir/back-vms/mybatis-plus-multb/mapper.vm rename to velocity-tmp-dir/back-vms-bak/mybatis-plus-multi/mapper.vm diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/mapperMul.vm b/velocity-tmp-dir/back-vms-bak/mybatis-plus-multi/mapperMul.vm similarity index 100% rename from velocity-tmp-dir/back-vms/mybatis-plus-multb/mapperMul.vm rename to velocity-tmp-dir/back-vms-bak/mybatis-plus-multi/mapperMul.vm diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/serviceMul.vm b/velocity-tmp-dir/back-vms-bak/mybatis-plus-multi/serviceMul.vm similarity index 100% rename from velocity-tmp-dir/back-vms/mybatis-plus-multb/serviceMul.vm rename to velocity-tmp-dir/back-vms-bak/mybatis-plus-multi/serviceMul.vm diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/utils.vm b/velocity-tmp-dir/back-vms-bak/mybatis-plus-multi/utils.vm similarity index 100% rename from velocity-tmp-dir/back-vms/mybatis-plus-multb/utils.vm rename to velocity-tmp-dir/back-vms-bak/mybatis-plus-multi/utils.vm diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multb/xmlMul.vm b/velocity-tmp-dir/back-vms-bak/mybatis-plus-multi/xmlMul.vm similarity index 100% rename from velocity-tmp-dir/back-vms/mybatis-plus-multb/xmlMul.vm rename to velocity-tmp-dir/back-vms-bak/mybatis-plus-multi/xmlMul.vm diff --git a/velocity-tmp-dir/back-vms-bak/mybatis-plus/controller.vm b/velocity-tmp-dir/back-vms-bak/mybatis-plus/controller.vm new file mode 100644 index 0000000..5c4cbef --- /dev/null +++ b/velocity-tmp-dir/back-vms-bak/mybatis-plus/controller.vm @@ -0,0 +1,112 @@ +#parse("utils.vm") +package ${projectOrAuthor.packageName}.controller; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +/** +* ${dbTableConfig.tableDesc}Controller +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Api(tags = "${dbTableConfig.tableDesc}(${dbTableConfig.tableNameCase})") +@RestController +@RequestMapping("${dbTableConfig.tableName}") +public class ${dbTableConfig.tableNameCase}Controller { + +@Resource +private ${dbTableConfig.tableNameCase}Service ${dbTableConfig.tableName}Service; + +/** +* 分页查询所有数据 +* +* @param ${dbTableConfig.tableName} 查询实体 +* @return ResResult +*/ +@GetMapping("selectPage") +@ApiOperation(value = "分页查询所有数据") +public ResResult selectPage(${dbTableConfig.tableNameCase} $dbTableConfig.tableName, SelfCommonParams commonParams) { +QueryWrapper <${dbTableConfig.tableNameCase}> queryWrapper = new QueryWrapper<>(); +#foreach($item in $queryConfig) + #if(${item.originField}=="create_time") + //${item.desc} + queryWrapper.orderByDesc("$item.originField"); + if (ObjSelfUtils.isNotEmpty(commonParams.getStartTime())) { + queryWrapper.between("create_time", commonParams.getStartTime(), commonParams.getEndTime()); + } + #else + //${item.desc} + if (ObjSelfUtils.isNotEmpty(${dbTableConfig.tableName}.get${item.fieldCase}())) { + queryWrapper.like("${item.originField}", ${dbTableConfig.tableName}.get${item.fieldCase}()); + } + #end +#end + +queryWrapper.select("$selectString"); + +Page <${dbTableConfig.tableNameCase}> ${dbTableConfig.tableName}Page = this.${dbTableConfig.tableName}Service.selectPage(commonParams.getPageNum(), commonParams.getPageSize(),queryWrapper); +return new ResResult().success(${dbTableConfig.tableName}Page); +} + +/** +* 通过主键查询单条数据 +* +* @param id 主键 +* @return 单条数据 +*/ +@GetMapping("selectById") +@ApiOperation(value = "通过id主键查询单条数据") +public ResResult selectById(@RequestParam("id") ${dbTableConfig.uniKeyType} id) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.selectById(id)); +} + +/** +* @Description: 根据id数组查询品牌列表 +* @Param: idList id数组 +* @return: ids列表数据 +*/ +@ApiOperation(value = "根据id数组查询品牌列表") +@PostMapping("selectBatchIds") +public ResResult selectBatchIds(@RequestParam("idList") List< ${dbTableConfig.uniKeyType} > idList) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.selectBatchIds(idList)); +} + +/** +* 新增数据 +* +* @param ${dbTableConfig.tableName} 实体对象 +* @return 新增结果 +*/ +@ApiOperation(value = "新增数据") +@PostMapping("insert") +public ResResult insert(@RequestBody ${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.insert(${dbTableConfig.tableName})); +} + +/** +* 修改数据 +* +* @param ${dbTableConfig.tableName} 实体对象 +* @return 修改结果 +*/ +@ApiOperation(value = "根据id修改数据") +@PutMapping("updateById") +public ResResult updateById(@RequestBody ${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.updateById(${dbTableConfig.tableName})); +} + +/** +* 删除数据 +* +* @param idList 主键结合 +* @return 删除结果 +*/ +@ApiOperation(value = "根据id数组删除数据") +@DeleteMapping("deleteBatchIds") +public ResResult deleteBatchIds(@RequestBody List< ${dbTableConfig.uniKeyType} > idList) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.deleteBatchIds(idList)); +} + +@DeleteMapping("deleteById") +public ResResult deleteById(@RequestParam("id") ${dbTableConfig.uniKeyType} id) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.deleteById(id)); +} +} diff --git a/velocity-tmp-dir/back-vms-bak/mybatis-plus/entity.vm b/velocity-tmp-dir/back-vms-bak/mybatis-plus/entity.vm new file mode 100644 index 0000000..d1a16b5 --- /dev/null +++ b/velocity-tmp-dir/back-vms-bak/mybatis-plus/entity.vm @@ -0,0 +1,37 @@ +package ${projectOrAuthor.packageName}.entity; +import java.util.Date; +/** +* ${dbTableConfig.tableDesc}实体类 +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Data +@ApiModel("${dbTableConfig.tableDesc}") +@TableName(value = "${dbTableConfig.originTableName}") +public class ${dbTableConfig.tableNameCase} extends Model< ${dbTableConfig.tableNameCase} > { +#foreach($item in $dbTableConfig.tableFieldArr) + #if($item.field=="createTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.INSERT) + private ${item.type} $item.field; + #elseif($item.field=="updateTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private ${item.type} $item.field; + #else + @ApiModelProperty(value = "$item.desc") + private ${item.type} $item.field; + #end +#end + +/** +* 获取主键值 +* +* @return 主键值 +*/ +@Override +protected Serializable pkVal() { +return this.${dbTableConfig.uniKey}; +} +} diff --git a/velocity-tmp-dir/back-vms-bak/mybatis-plus/mapper.vm b/velocity-tmp-dir/back-vms-bak/mybatis-plus/mapper.vm new file mode 100644 index 0000000..12cb2ad --- /dev/null +++ b/velocity-tmp-dir/back-vms-bak/mybatis-plus/mapper.vm @@ -0,0 +1,10 @@ +package ${projectOrAuthor.packageName}.mapper; +/** +* ${dbTableConfig.tableDesc}Mapper +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +public interface ${dbTableConfig.tableNameCase}Mapper extends BaseMapper< ${dbTableConfig.tableNameCase} > { + +} diff --git a/velocity-tmp-dir/back-vms-bak/mybatis-plus/service.vm b/velocity-tmp-dir/back-vms-bak/mybatis-plus/service.vm new file mode 100644 index 0000000..1ecde1e --- /dev/null +++ b/velocity-tmp-dir/back-vms-bak/mybatis-plus/service.vm @@ -0,0 +1,42 @@ +package ${projectOrAuthor.packageName}.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +/** +* ${dbTableConfig.tableDesc}Service +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Service +public class ${dbTableConfig.tableNameCase}Service { + +@Resource +private ${dbTableConfig.tableNameCase}Mapper ${dbTableConfig.tableName}Mapper; + +public Page< ${dbTableConfig.tableNameCase} > selectPage(${dbTableConfig.uniKeyType} pageNum, ${dbTableConfig.uniKeyType} pageSize, QueryWrapper< ${dbTableConfig.tableNameCase} > queryWrapper) { +return this.${dbTableConfig.tableName}Mapper.selectPage(new Page< ${dbTableConfig.tableNameCase} >(pageNum, pageSize), queryWrapper); +} + +public ${dbTableConfig.tableNameCase} selectById(${dbTableConfig.uniKeyType} id) { +return this.${dbTableConfig.tableName}Mapper.selectById(id); +} + +public List< ${dbTableConfig.tableNameCase} > selectBatchIds(List< ${dbTableConfig.uniKeyType} > idList) { +return this.${dbTableConfig.tableName}Mapper.selectBatchIds(idList); +} + +public int insert(${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { +return this.${dbTableConfig.tableName}Mapper.insert(${dbTableConfig.tableName}); +} + +public int updateById(${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { +return this.${dbTableConfig.tableName}Mapper.updateById(${dbTableConfig.tableName}); +} + +public int deleteById(${dbTableConfig.uniKeyType} id) { +return this.${dbTableConfig.tableName}Mapper.deleteById(id); +} + +public int deleteBatchIds(List< ${dbTableConfig.uniKeyType} > idList) { +return this.${dbTableConfig.tableName}Mapper.deleteBatchIds(idList); +} +} diff --git a/velocity-tmp-dir/back-vms-bak/mybatis-plus/utils.vm b/velocity-tmp-dir/back-vms-bak/mybatis-plus/utils.vm new file mode 100644 index 0000000..11faccf --- /dev/null +++ b/velocity-tmp-dir/back-vms-bak/mybatis-plus/utils.vm @@ -0,0 +1,6 @@ +#macro(getOriginField) + #foreach($item in $formConfig)$item.originField,#end +#end +#set($originFieldString="#getOriginField()") +#set($lenth=$originFieldString.length() - 1) +#set($selectString=$originFieldString.substring(0,$lenth)) \ No newline at end of file diff --git a/velocity-tmp-dir/back-vms-bak/mybatis-plus/xml.vm b/velocity-tmp-dir/back-vms-bak/mybatis-plus/xml.vm new file mode 100644 index 0000000..e69de29 diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/controllerMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/controllerMul.vm new file mode 100644 index 0000000..70e3008 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/controllerMul.vm @@ -0,0 +1,75 @@ +package ${projectOrAuthor.packageName}.controller; +import java.util.Map; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +/** +* ${dbTableConfig.multiTableDesc}Controller +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Api(tags = "维修信息") +@RestController +@RequestMapping("${dbTableConfig.multiTableName}") +public class ${dbTableConfig.multiTableNameCase}Controller { +@Resource +private ${dbTableConfig.multiTableNameCase}Service ${dbTableConfig.multiTableName}Service; + +@ApiOperation(value = "分页查询${dbTableConfig.multiTableDesc}") +@GetMapping("select${dbTableConfig.multiTableNameCase}") +public Page< Map > select${dbTableConfig.multiTableNameCase}(SelfCommonParams commonParams, ${dbTableConfig.multiTableNameCase}Vo ${dbTableConfig.multiTableName}Vo) { +Map ${dbTableConfig.multiTableName}Map = JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}Vo), Map.class); +return ${dbTableConfig.multiTableName}Service.select${dbTableConfig.multiTableNameCase}(commonParams, ${dbTableConfig.multiTableName}Map); +} + +/** +* 新增数据 +* +* @param ${dbTableConfig.multiTableName} 实体对象 +* @return 新增结果 +*/ +@ApiOperation(value = "新增${dbTableConfig.multiTableDesc}") +@PostMapping("insert") +public ResResult insert(@RequestBody ${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +this.${dbTableConfig.multiTableName}Service.insert(${dbTableConfig.multiTableName}); +return new ResResult().success(); +} + + +/** +* 通过主键查询单条数据 +* +* @param ${dbTableConfig.associationKey} 主键 +* @return 单条数据 +*/ +@GetMapping("selectByKey") +@ApiOperation(value = "通过联合key查询详情") +public ResResult selectByKey(@RequestParam("${dbTableConfig.associationKey}") ${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { +return new ResResult().success(${dbTableConfig.multiTableName}Service.selectByKey(${dbTableConfig.associationKey})); +} + +/** +* 修改数据 +* +* @param ${dbTableConfig.multiTableName} 实体对象 +* @return 修改结果 +*/ +@ApiOperation(value = "根据${dbTableConfig.associationKey}修改数据") +@PutMapping("updateByKey") +public ResResult updateByKey(@RequestBody ${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +this.${dbTableConfig.multiTableName}Service.updateByKey(${dbTableConfig.multiTableName}); +return new ResResult().success(); +} + + +/** +* 删除项根据主键key +* @param ${dbTableConfig.associationKey} +* @return +*/ +@ApiOperation(value = "根据联合key删除数据") +@DeleteMapping("deleteByKey") +public ResResult deleteByKey(@RequestParam("${dbTableConfig.associationKey}") ${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { +this.${dbTableConfig.multiTableName}Service.deleteByKey(${dbTableConfig.associationKey}); +return new ResResult().success(); +} +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/entity.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/entity.vm new file mode 100644 index 0000000..197fdbe --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/entity.vm @@ -0,0 +1,37 @@ +package ${projectOrAuthor.packageName}.entity; +import java.util.*; +/** +* ${currentTbConfig.tableDesc}实体类 +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Data +@ApiModel("${currentTbConfig.tableDesc}") +@TableName(value = "${currentTbConfig.originTableName}") +public class ${currentTbConfig.tableNameCase} extends Model< ${currentTbConfig.tableNameCase} > { +#foreach($item in $dbTableConfig.tableFieldArr) + #if($item.field=="createTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.INSERT) + private ${item.type} $item.field; + #elseif($item.field=="updateTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private ${item.type} $item.field; + #else + @ApiModelProperty(value = "$item.desc") + private ${item.type} $item.field; + #end +#end + +/** +* 获取主键值 +* +* @return 主键值 +*/ +@Override +protected Serializable pkVal() { +return this.${currentTbConfig.uniKey}; +} +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/entityMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/entityMul.vm new file mode 100644 index 0000000..ab3938e --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/entityMul.vm @@ -0,0 +1,29 @@ +package ${projectOrAuthor.packageName}.entity; +import java.util.*; +/** +* ${dbTableConfig.tableDesc}实体类 +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Data +@ApiModel("${dbTableConfig.tableDesc}") +@TableName(value = "${dbTableConfig.originTableName}") +public class ${dbTableConfig.multiTableNameCase}{ +#foreach($mtcItem in $multiTableConfig) + #foreach($item in $mtcItem.tableFieldArr) + #if($item.field=="createTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.INSERT) + private ${item.type} $item.field; + #elseif($item.field=="updateTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private ${item.type} $item.field; + #else + @ApiModelProperty(value = "$item.desc") + private ${item.type} $item.field; + #end + #end +#end +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/entityVo.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/entityVo.vm new file mode 100644 index 0000000..b1e98e1 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/entityVo.vm @@ -0,0 +1,19 @@ +package ${projectOrAuthor.packageName}.entity; +import java.util.*; +/** +* ${dbTableConfig.multiTableDesc}实体类 +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Data +@ApiModel("${dbTableConfig.multiTableDesc}") +public class ${dbTableConfig.multiTableNameCase}Vo { +#foreach($mtcItem in $multiTableConfig) + #foreach( $tfItem in $mtcItem.tableFormArr) + @ApiModelProperty(value = "$tfItem.desc") + private ${tfItem.type} $tfItem.field; + #end +#end + +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/mapper.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/mapper.vm new file mode 100644 index 0000000..b7b7f94 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/mapper.vm @@ -0,0 +1,10 @@ +package ${projectOrAuthor.packageName}.mapper; +/** +* ${currentTbConfig.tableDesc}Mapper +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +public interface ${currentTbConfig.tableNameCase}Mapper extends BaseMapper< ${currentTbConfig.tableNameCase} > { + +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/mapperMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/mapperMul.vm new file mode 100644 index 0000000..689cc2b --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/mapperMul.vm @@ -0,0 +1,16 @@ +#set($firstTbConfig=$multiTableConfig[0]) +package ${projectOrAuthor.packageName}.mapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import java.util.*; +/** +* ${dbTableConfig.multiTableDesc}Mapper +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +public interface ${dbTableConfig.multiTableNameCase}Mapper { +Page< Map > select${dbTableConfig.multiTableNameCase}(Page< Map > pagination,@Param("params") Map params); + +Map selectByKey(@Param("${firstTbConfig.associationKey}") String ${firstTbConfig.associationKey}); +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/serviceMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/serviceMul.vm new file mode 100644 index 0000000..71ccf12 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/serviceMul.vm @@ -0,0 +1,57 @@ +package ${projectOrAuthor.packageName}.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.util.*; +import com.alibaba.fastjson.JSON; +/** +* ${dbTableConfig.multiTableDesc}Service +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Service +public class ${dbTableConfig.multiTableNameCase}Service { + +@Resource +private ${dbTableConfig.multiTableNameCase}Mapper ${dbTableConfig.multiTableName}Mapper; + +#foreach( $mtcItem in $multiTableConfig) +@Resource +private ${mtcItem.tableNameCase}Mapper ${mtcItem.tableName}Mapper; +#end + +public Page< Map > select${dbTableConfig.multiTableNameCase}(SelfCommonParams commonParams, Map repairVo) { + return ${dbTableConfig.multiTableName}Mapper.select${dbTableConfig.multiTableNameCase}(new Page< Map >(commonParams.getPageNum(), commonParams.getPageSize()), repairVo); +} + +public Map selectByKey(String ${dbTableConfig.multiTableName}) { + return ${dbTableConfig.multiTableName}Mapper.selectByKey(${dbTableConfig.multiTableName}); +} + +@Transactional +public void insert(${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { + #foreach( $mtcItem in $multiTableConfig) + this.${mtcItem.tableName}Mapper.insert(JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}), ${mtcItem.tableNameCase}.class)); + #end +} + +@Transactional +public void updateByKey(${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +#foreach( $mtcItem in $multiTableConfig) + //${mtcItem.tableDesc} + ${mtcItem.tableNameCase} ${mtcItem.tableName} = JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}), ${mtcItem.tableNameCase}.class); + QueryWrapper<${mtcItem.tableNameCase}> ${mtcItem.tableName}Wrapper = new QueryWrapper<>(); + ${mtcItem.tableName}Wrapper.eq("sn", ${dbTableConfig.multiTableName}.getSn()); + this.${mtcItem.tableName}Mapper.update(${mtcItem.tableName}, ${mtcItem.tableName}Wrapper); +#end +} + +@Transactional +public void deleteByKey(${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { + #foreach( $mtcItem in $multiTableConfig) + //${mtcItem.tableName} + QueryWrapper<${mtcItem.tableNameCase}> ${mtcItem.tableName}Wrapper = new QueryWrapper<>(); + ${mtcItem.tableName}Wrapper.eq("${dbTableConfig.orgAssociationKey}", ${dbTableConfig.associationKey}); + this.${mtcItem.tableName}Mapper.delete(${mtcItem.tableName}Wrapper); + #end + } +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/utils.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/utils.vm new file mode 100644 index 0000000..758add7 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/utils.vm @@ -0,0 +1,8 @@ +#macro(getOriginField) + #foreach($fItem in $multiTableConfig) + #foreach($tableShowArrItem in ${fItem.tableShowArr})${fItem.tableName}.${tableShowArrItem.originField},#end + #end +#end +#set($originFieldString="#getOriginField()") +#set($lenth=$originFieldString.length() - 1) +#set($xmlSelectString=$originFieldString.substring(0,$lenth)) diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/xmlMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/xmlMul.vm new file mode 100644 index 0000000..c9c3353 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/xmlMul.vm @@ -0,0 +1,60 @@ +#parse("utils.vm") +#set($firstTbConfig=$multiTableConfig[0]) + + + + + #foreach($fItem in $multiTableConfig) + #foreach($tableShowArrItem in ${fItem.tableShowArr}) + + #end + #end + + + ${xmlSelectString} + + + + + \ No newline at end of file diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/controller.vm b/velocity-tmp-dir/back-vms/mybatis-plus/controller.vm index 5c4cbef..171d767 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus/controller.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus/controller.vm @@ -1,112 +1,116 @@ #parse("utils.vm") -package ${projectOrAuthor.packageName}.controller; +package ${basicConfig.packageName}.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +import ${basicConfig.packageName}.entity.${dbTableConfig.tableNameCase}; /** * ${dbTableConfig.tableDesc}Controller * -* @author ${projectOrAuthor.author} -* @since ${projectOrAuthor.dataTime} +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} */ @Api(tags = "${dbTableConfig.tableDesc}(${dbTableConfig.tableNameCase})") @RestController @RequestMapping("${dbTableConfig.tableName}") public class ${dbTableConfig.tableNameCase}Controller { -@Resource -private ${dbTableConfig.tableNameCase}Service ${dbTableConfig.tableName}Service; + @Resource + private ${dbTableConfig.tableNameCase}Service ${dbTableConfig.tableName}Service; -/** -* 分页查询所有数据 -* -* @param ${dbTableConfig.tableName} 查询实体 -* @return ResResult -*/ -@GetMapping("selectPage") -@ApiOperation(value = "分页查询所有数据") -public ResResult selectPage(${dbTableConfig.tableNameCase} $dbTableConfig.tableName, SelfCommonParams commonParams) { -QueryWrapper <${dbTableConfig.tableNameCase}> queryWrapper = new QueryWrapper<>(); -#foreach($item in $queryConfig) - #if(${item.originField}=="create_time") - //${item.desc} - queryWrapper.orderByDesc("$item.originField"); - if (ObjSelfUtils.isNotEmpty(commonParams.getStartTime())) { - queryWrapper.between("create_time", commonParams.getStartTime(), commonParams.getEndTime()); - } - #else - //${item.desc} - if (ObjSelfUtils.isNotEmpty(${dbTableConfig.tableName}.get${item.fieldCase}())) { - queryWrapper.like("${item.originField}", ${dbTableConfig.tableName}.get${item.fieldCase}()); - } + /** + * 分页查询所有数据 + * +## * @param ${dbTableConfig.tableName} 查询实体 + * @return ResResult + */ + @GetMapping("selectPage") + @ApiOperation(value = "分页查询所有数据") + + #getSwaggerParam() + public ResResult selectPage(#getQueryField() SelfCommonParams commonParams) { + QueryWrapper <${dbTableConfig.tableNameCase}> queryWrapper = new QueryWrapper<>(); + #foreach($item in $queryConfig) + #if(${item.originField}=="create_time") + //${item.desc} + queryWrapper.orderByDesc("$item.originField"); + if (ObjSelfUtils.isNotEmpty(commonParams.getStartTime())) { + queryWrapper.between("create_time", commonParams.getStartTime(), commonParams.getEndTime()); + } + #else + //${item.desc} + if (ObjSelfUtils.isNotEmpty( ${item.field})) { + queryWrapper.like("${item.originField}", ${item.field}); + } + #end #end -#end -queryWrapper.select("$selectString"); + queryWrapper.select("$selectString"); -Page <${dbTableConfig.tableNameCase}> ${dbTableConfig.tableName}Page = this.${dbTableConfig.tableName}Service.selectPage(commonParams.getPageNum(), commonParams.getPageSize(),queryWrapper); -return new ResResult().success(${dbTableConfig.tableName}Page); -} + Page <${dbTableConfig.tableNameCase}> ${dbTableConfig.tableName}Page = this.${dbTableConfig.tableName}Service.selectPage(commonParams.getPageNum(), commonParams.getPageSize(),queryWrapper); + return new ResResult().success(${dbTableConfig.tableName}Page); + } -/** -* 通过主键查询单条数据 -* -* @param id 主键 -* @return 单条数据 -*/ -@GetMapping("selectById") -@ApiOperation(value = "通过id主键查询单条数据") -public ResResult selectById(@RequestParam("id") ${dbTableConfig.uniKeyType} id) { -return new ResResult().success(this.${dbTableConfig.tableName}Service.selectById(id)); -} + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("selectById") + @ApiOperation(value = "通过id主键查询单条数据") + public ResResult selectById(@RequestParam("id") ${dbTableConfig.uniKeyType} id) { + return new ResResult().success(this.${dbTableConfig.tableName}Service.selectById(id)); + } -/** -* @Description: 根据id数组查询品牌列表 -* @Param: idList id数组 -* @return: ids列表数据 -*/ -@ApiOperation(value = "根据id数组查询品牌列表") -@PostMapping("selectBatchIds") -public ResResult selectBatchIds(@RequestParam("idList") List< ${dbTableConfig.uniKeyType} > idList) { -return new ResResult().success(this.${dbTableConfig.tableName}Service.selectBatchIds(idList)); -} + /** + * @Description: 根据id数组查询品牌列表 + * @Param: idList id数组 + * @return: ids列表数据 + */ + @ApiOperation(value = "根据id数组查询品牌列表") + @PostMapping("selectBatchIds") + public ResResult selectBatchIds(@RequestParam("idList") List< ${dbTableConfig.uniKeyType} > idList) { + return new ResResult().success(this.${dbTableConfig.tableName}Service.selectBatchIds(idList)); + } -/** -* 新增数据 -* -* @param ${dbTableConfig.tableName} 实体对象 -* @return 新增结果 -*/ -@ApiOperation(value = "新增数据") -@PostMapping("insert") -public ResResult insert(@RequestBody ${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { -return new ResResult().success(this.${dbTableConfig.tableName}Service.insert(${dbTableConfig.tableName})); -} + /** + * 新增数据 + * + * @param ${dbTableConfig.tableName} 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping("insert") + public ResResult insert(@RequestBody ${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { + return new ResResult().success(this.${dbTableConfig.tableName}Service.insert(${dbTableConfig.tableName})); + } -/** -* 修改数据 -* -* @param ${dbTableConfig.tableName} 实体对象 -* @return 修改结果 -*/ -@ApiOperation(value = "根据id修改数据") -@PutMapping("updateById") -public ResResult updateById(@RequestBody ${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { -return new ResResult().success(this.${dbTableConfig.tableName}Service.updateById(${dbTableConfig.tableName})); -} + /** + * 修改数据 + * + * @param ${dbTableConfig.tableName} 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "根据id修改数据") + @PutMapping("updateById") + public ResResult updateById(@RequestBody ${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { + return new ResResult().success(this.${dbTableConfig.tableName}Service.updateById(${dbTableConfig.tableName})); + } -/** -* 删除数据 -* -* @param idList 主键结合 -* @return 删除结果 -*/ -@ApiOperation(value = "根据id数组删除数据") -@DeleteMapping("deleteBatchIds") -public ResResult deleteBatchIds(@RequestBody List< ${dbTableConfig.uniKeyType} > idList) { -return new ResResult().success(this.${dbTableConfig.tableName}Service.deleteBatchIds(idList)); -} + /** + * 删除数据 + * + * @param idList 主键结合 + * @return 删除结果 + */ + @ApiOperation(value = "根据id数组删除数据") + @DeleteMapping("deleteBatchIds") + public ResResult deleteBatchIds(@RequestBody List< ${dbTableConfig.uniKeyType} > idList) { + return new ResResult().success(this.${dbTableConfig.tableName}Service.deleteBatchIds(idList)); + } -@DeleteMapping("deleteById") -public ResResult deleteById(@RequestParam("id") ${dbTableConfig.uniKeyType} id) { -return new ResResult().success(this.${dbTableConfig.tableName}Service.deleteById(id)); -} + @DeleteMapping("根据id删除数据") + public ResResult deleteById(@RequestParam("id") ${dbTableConfig.uniKeyType} id) { + return new ResResult().success(this.${dbTableConfig.tableName}Service.deleteById(id)); + } } diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/entity.vm b/velocity-tmp-dir/back-vms/mybatis-plus/entity.vm index d1a16b5..6c5dc52 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus/entity.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus/entity.vm @@ -1,37 +1,37 @@ -package ${projectOrAuthor.packageName}.entity; +package ${basicConfig.packageName}.entity; import java.util.Date; /** * ${dbTableConfig.tableDesc}实体类 * -* @author ${projectOrAuthor.author} -* @since ${projectOrAuthor.dataTime} +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} */ @Data @ApiModel("${dbTableConfig.tableDesc}") @TableName(value = "${dbTableConfig.originTableName}") public class ${dbTableConfig.tableNameCase} extends Model< ${dbTableConfig.tableNameCase} > { -#foreach($item in $dbTableConfig.tableFieldArr) - #if($item.field=="createTime") - @ApiModelProperty(value = "$item.desc",hidden = true) - @TableField(fill = FieldFill.INSERT) - private ${item.type} $item.field; - #elseif($item.field=="updateTime") - @ApiModelProperty(value = "$item.desc",hidden = true) - @TableField(fill = FieldFill.UPDATE) - private ${item.type} $item.field; - #else - @ApiModelProperty(value = "$item.desc") - private ${item.type} $item.field; + #foreach($item in $formConfig) + #if($item.field=="createTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.INSERT) + private ${item.type} $item.field; + #elseif($item.field=="updateTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private ${item.type} $item.field; + #else + @ApiModelProperty(value = "$item.desc",hidden=$item.isNotShowSwagger) + private ${item.type} $item.field; + #end #end -#end -/** -* 获取主键值 -* -* @return 主键值 -*/ -@Override -protected Serializable pkVal() { -return this.${dbTableConfig.uniKey}; -} + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.${dbTableConfig.uniKey}; + } } diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/mapper.vm b/velocity-tmp-dir/back-vms/mybatis-plus/mapper.vm index 12cb2ad..e0d7a14 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus/mapper.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus/mapper.vm @@ -1,10 +1,12 @@ -package ${projectOrAuthor.packageName}.mapper; +package ${basicConfig.packageName}.mapper; +import ${basicConfig.packageName}.entity.${dbTableConfig.tableNameCase}; /** * ${dbTableConfig.tableDesc}Mapper * -* @author ${projectOrAuthor.author} -* @since ${projectOrAuthor.dataTime} +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} */ + public interface ${dbTableConfig.tableNameCase}Mapper extends BaseMapper< ${dbTableConfig.tableNameCase} > { } diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/service.vm b/velocity-tmp-dir/back-vms/mybatis-plus/service.vm index 1ecde1e..3356a51 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus/service.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus/service.vm @@ -1,42 +1,43 @@ -package ${projectOrAuthor.packageName}.service; +package ${basicConfig.packageName}.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import ${basicConfig.packageName}.entity.${dbTableConfig.tableNameCase}; /** * ${dbTableConfig.tableDesc}Service * -* @author ${projectOrAuthor.author} -* @since ${projectOrAuthor.dataTime} +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} */ @Service public class ${dbTableConfig.tableNameCase}Service { -@Resource -private ${dbTableConfig.tableNameCase}Mapper ${dbTableConfig.tableName}Mapper; + @Resource + private ${dbTableConfig.tableNameCase}Mapper ${dbTableConfig.tableName}Mapper; -public Page< ${dbTableConfig.tableNameCase} > selectPage(${dbTableConfig.uniKeyType} pageNum, ${dbTableConfig.uniKeyType} pageSize, QueryWrapper< ${dbTableConfig.tableNameCase} > queryWrapper) { -return this.${dbTableConfig.tableName}Mapper.selectPage(new Page< ${dbTableConfig.tableNameCase} >(pageNum, pageSize), queryWrapper); -} + public Page< ${dbTableConfig.tableNameCase} > selectPage(Integer pageNum, Integer pageSize, QueryWrapper< ${dbTableConfig.tableNameCase} > queryWrapper) { + return this.${dbTableConfig.tableName}Mapper.selectPage(new Page< ${dbTableConfig.tableNameCase} >(pageNum, pageSize), queryWrapper); + } -public ${dbTableConfig.tableNameCase} selectById(${dbTableConfig.uniKeyType} id) { -return this.${dbTableConfig.tableName}Mapper.selectById(id); -} + public ${dbTableConfig.tableNameCase} selectById(${dbTableConfig.uniKeyType} id) { + return this.${dbTableConfig.tableName}Mapper.selectById(id); + } -public List< ${dbTableConfig.tableNameCase} > selectBatchIds(List< ${dbTableConfig.uniKeyType} > idList) { -return this.${dbTableConfig.tableName}Mapper.selectBatchIds(idList); -} + public List< ${dbTableConfig.tableNameCase} > selectBatchIds(List< ${dbTableConfig.uniKeyType} > idList) { + return this.${dbTableConfig.tableName}Mapper.selectBatchIds(idList); + } -public int insert(${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { -return this.${dbTableConfig.tableName}Mapper.insert(${dbTableConfig.tableName}); -} + public int insert(${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { + return this.${dbTableConfig.tableName}Mapper.insert(${dbTableConfig.tableName}); + } -public int updateById(${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { -return this.${dbTableConfig.tableName}Mapper.updateById(${dbTableConfig.tableName}); -} + public int updateById(${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { + return this.${dbTableConfig.tableName}Mapper.updateById(${dbTableConfig.tableName}); + } -public int deleteById(${dbTableConfig.uniKeyType} id) { -return this.${dbTableConfig.tableName}Mapper.deleteById(id); -} + public int deleteById(${dbTableConfig.uniKeyType} id) { + return this.${dbTableConfig.tableName}Mapper.deleteById(id); + } -public int deleteBatchIds(List< ${dbTableConfig.uniKeyType} > idList) { -return this.${dbTableConfig.tableName}Mapper.deleteBatchIds(idList); -} + public int deleteBatchIds(List< ${dbTableConfig.uniKeyType} > idList) { + return this.${dbTableConfig.tableName}Mapper.deleteBatchIds(idList); + } } diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm b/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm index 11faccf..e515fd5 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm @@ -3,4 +3,29 @@ #end #set($originFieldString="#getOriginField()") #set($lenth=$originFieldString.length() - 1) -#set($selectString=$originFieldString.substring(0,$lenth)) \ No newline at end of file +#set($selectString=$originFieldString.substring(0,$lenth)) + +#macro(getQueryField) + #foreach($item in $queryConfig) + #if($item.isNeedInput=="true") + @ApiIgnore @RequestParam("$item.field") String $item.field, + #else + @RequestParam("$item.field") String $item.field, + #end + #end +#end + + +#macro(getSwaggerParam) +@ApiImplicitParams({ + #foreach($item in $queryConfig) + #if($item.isNotShowSwagger=="false") + #if($item.isNeedInput=="true") + @ApiImplicitParam(name = "$item.field", value = "$item.desc", required = true), + #else + @ApiImplicitParam(name = "$item.field", value = "$item.desc"), + #end + #end + #end +}) +#end diff --git a/velocity-tmp-dir/front-vms/element-plus/tableQueryUtils.vm b/velocity-tmp-dir/front-vms/element-plus/tableQueryUtils.vm index 33a74de..162c2f0 100644 --- a/velocity-tmp-dir/front-vms/element-plus/tableQueryUtils.vm +++ b/velocity-tmp-dir/front-vms/element-plus/tableQueryUtils.vm @@ -12,7 +12,7 @@ #foreach($enum in $item.optionDataArr) @@ -24,7 +24,7 @@ Date: Sun, 9 Oct 2022 19:01:20 +0800 Subject: [PATCH 29/36] add multi func --- .../src/main/resources/application-db.yml | 13 +- .../controller/RoleController.java | 50 +- .../controller/UserController.java | 1 - .../integrationfront/entity/Role.java | 29 +- .../src/main/resources/application-db.yml | 14 +- .../back-vms/mybatis-plus/controller.vm | 179 +- .../back-vms/mybatis-plus/entity.vm | 48 +- .../back-vms/mybatis-plus/utils.vm | 33 +- .../json-data/mybatis-plus/basicData.json | 220 +- .../json-data/mybatis-plus/mutiQueryData.json | 2098 +++++++++++++++++ 10 files changed, 2430 insertions(+), 255 deletions(-) create mode 100644 velocity-tmp-dir/json-data/mybatis-plus/mutiQueryData.json diff --git a/basis-func/src/main/resources/application-db.yml b/basis-func/src/main/resources/application-db.yml index 5eac081..49a0e3f 100644 --- a/basis-func/src/main/resources/application-db.yml +++ b/basis-func/src/main/resources/application-db.yml @@ -4,13 +4,12 @@ spring: url: jdbc:p6spy:mysql://${envpt.mysqlIp}:${envpt.mysqlPort}/micro-service-plus?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&useSSL=false username: root password: root123 - hikari: - connection-timeout: 6000 #最大超时时间 - maximum-pool-size: 100 #连接数 - max-lifetime: 18000 #控制池中连接的最大生存期 - minimum-idle: 10 #此属性控制 HikariCP尝试在池中维护的最小空闲连接数 - validation-timeout: 5500 #此属性控制测试连接是否活跃的最长时间。此值必须小于 connectionTimeout - idle-timeout: 60000 #此属性控制允许连接在池中处于空闲状态的最长时间 + #hikari: + #最大连接数 + #maximum-pool-size: 50 + #最大超时时间 + #connection-timeout: 600000 + mybatis-plus: mapper-locations: classpath:/mapper/*Mapper.xml diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/RoleController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/RoleController.java index 4786b2a..0fc610f 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/RoleController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/RoleController.java @@ -1,15 +1,14 @@ - - - package top.kuanghua.integrationfront.controller; + import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; import top.kuanghua.commonpom.entity.ResResult; import top.kuanghua.commonpom.entity.SelfCommonParams; import top.kuanghua.commonpom.utils.ObjSelfUtils; @@ -17,10 +16,12 @@ import top.kuanghua.integrationfront.service.RoleService; import javax.annotation.Resource; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; import java.util.List; /** - * 角色Controller + * 角色Controller * * @author 熊猫哥 * @since 2022-10-07 16:33:13 @@ -28,6 +29,7 @@ @Api(tags = "角色(Role)") @RestController @RequestMapping("role") +@Validated public class RoleController { @Resource @@ -35,36 +37,40 @@ public class RoleController { /** * 分页查询所有数据 + * * @return ResResult */ @GetMapping("selectPage") @ApiOperation(value = "分页查询所有数据") @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "角色ID"), - @ApiImplicitParam(name = "name", value = "角色名称"), + @ApiImplicitParam(name = "id", value = "角色ID", paramType = "query", required = true), + @ApiImplicitParam(name = "name", value = "角色名称", paramType = "query", required = true), }) - public ResResult selectPage( @RequestParam("id") String id, - @RequestParam("code") String code, - @RequestParam("editor") String editor, - @RequestParam("name") String name, - @RequestParam("createTime") String createTime, - SelfCommonParams commonParams) { + public ResResult selectPage(@NotEmpty(message = "id不能为空}") + String id, + @ApiIgnore() String code, + @ApiIgnore() String editor, + @NotEmpty(message = "name不能为空}") + @Pattern(regexp = "^0?1[0-9]{10}$", message = "name输入有误-手机号}") + String name, + @ApiIgnore() String createTime, + SelfCommonParams commonParams) { QueryWrapper queryWrapper = new QueryWrapper<>(); //角色ID - if (ObjSelfUtils.isNotEmpty( id)) { + if (ObjSelfUtils.isNotEmpty(id)) { queryWrapper.like("id", id); } //角色唯一CODE代码 - if (ObjSelfUtils.isNotEmpty( code)) { + if (ObjSelfUtils.isNotEmpty(code)) { queryWrapper.like("code", code); } //修改人 - if (ObjSelfUtils.isNotEmpty( editor)) { + if (ObjSelfUtils.isNotEmpty(editor)) { queryWrapper.like("editor", editor); } //角色名称 - if (ObjSelfUtils.isNotEmpty( name)) { + if (ObjSelfUtils.isNotEmpty(name)) { queryWrapper.like("name", name); } //创建时间 @@ -75,7 +81,7 @@ public ResResult selectPage( @RequestParam("id") String id, queryWrapper.select("id,parent_id,code,intro,create_time,creator,update_time,editor,deleted"); - Page rolePage = this.roleService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(),queryWrapper); + Page rolePage = this.roleService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); return new ResResult().success(rolePage); } @@ -98,7 +104,7 @@ public ResResult selectById(@RequestParam("id") Long id) { */ @ApiOperation(value = "根据id数组查询品牌列表") @PostMapping("selectBatchIds") - public ResResult selectBatchIds(@RequestParam("idList") List< Long > idList) { + public ResResult selectBatchIds(@RequestParam("idList") List idList) { return new ResResult().success(this.roleService.selectBatchIds(idList)); } @@ -110,7 +116,7 @@ public ResResult selectBatchIds(@RequestParam("idList") List< Long > idList) { */ @ApiOperation(value = "新增数据") @PostMapping("insert") - public ResResult insert(@RequestBody Role role) { + public ResResult insert(@Validated @RequestBody Role role) { return new ResResult().success(this.roleService.insert(role)); } @@ -122,7 +128,7 @@ public ResResult insert(@RequestBody Role role) { */ @ApiOperation(value = "根据id修改数据") @PutMapping("updateById") - public ResResult updateById(@RequestBody Role role) { + public ResResult updateById(@Validated @RequestBody Role role) { return new ResResult().success(this.roleService.updateById(role)); } @@ -134,7 +140,7 @@ public ResResult updateById(@RequestBody Role role) { */ @ApiOperation(value = "根据id数组删除数据") @DeleteMapping("deleteBatchIds") - public ResResult deleteBatchIds(@RequestBody List< Long > idList) { + public ResResult deleteBatchIds(@RequestBody List idList) { return new ResResult().success(this.roleService.deleteBatchIds(idList)); } diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java index 673c3aa..c792e8a 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java @@ -94,7 +94,6 @@ public ResResult selectById(@RequestParam("id") Integer id) { */ @ApiOperation(value = "新增数据") @PostMapping("insert") - public ResResult insert(@Valid @RequestBody User user) { //List userInfos = userInfoMapper.selectList(new EntityWrapper<>(userInfo).like("firstname", name) // .like("lastname", name));52 diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java index 3780d7d..339dc06 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java @@ -1,4 +1,5 @@ package top.kuanghua.integrationfront.entity; + import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -7,10 +8,13 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; import java.io.Serializable; import java.util.Date; + /** - * 角色实体类 + * 角色实体类 * * @author 熊猫哥 * @since 2022-10-07 16:33:13 @@ -18,26 +22,29 @@ @Data @ApiModel("角色") @TableName(value = "t_role") -public class Role extends Model< Role > { - @ApiModelProperty(value = "角色ID(修改时需要传递)",hidden=false) +public class Role extends Model { + @ApiModelProperty(value = "角色ID(修改时需要传递)", hidden = false) + @NotEmpty(message = "id不能为空}") private Long id; - @ApiModelProperty(value = "所属父级角色ID(不传为顶级父id)",hidden=false) + @ApiModelProperty(value = "所属父级角色ID(不传为顶级父id)", hidden = false) + @NotEmpty(message = "parentId不能为空}") + @Pattern(regexp = "(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)", message = "parentId输入有误-身份证") private Long parentId; - @ApiModelProperty(value = "角色唯一CODE代码",hidden=false) + @ApiModelProperty(value = "角色唯一CODE代码", hidden = false) private String code; - @ApiModelProperty(value = "角色介绍",hidden=false) + @ApiModelProperty(value = "角色介绍", hidden = false) private String intro; - @ApiModelProperty(value = "创建时间",hidden = true) + @ApiModelProperty(value = "创建时间", hidden = true) @TableField(fill = FieldFill.INSERT) private Date createTime; - @ApiModelProperty(value = "创建人",hidden=true) + @ApiModelProperty(value = "创建人", hidden = true) private String creator; - @ApiModelProperty(value = "修改时间",hidden = true) + @ApiModelProperty(value = "修改时间", hidden = true) @TableField(fill = FieldFill.UPDATE) private Date updateTime; - @ApiModelProperty(value = "修改人",hidden=true) + @ApiModelProperty(value = "修改人", hidden = true) private String editor; - @ApiModelProperty(value = "逻辑删除",hidden=true) + @ApiModelProperty(value = "逻辑删除", hidden = true) private Integer deleted; /** diff --git a/integration-front/src/main/resources/application-db.yml b/integration-front/src/main/resources/application-db.yml index 0049a6b..9a56e95 100644 --- a/integration-front/src/main/resources/application-db.yml +++ b/integration-front/src/main/resources/application-db.yml @@ -4,15 +4,11 @@ spring: url: jdbc:p6spy:mysql://${envpt.mysqlIp}:${envpt.mysqlPort}/micro-service-plus?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&useSSL=false username: root password: root123 - hikari: - connection-timeout: 60000 - validation-timeout: 6000 - idle-timeout: 60000 - login-timeout: 5 - max-lifetime: 60000 - maximum-pool-size: 10 - minimum-idle: 10 - read-only: false + #hikari: + #最大连接数 + #maximum-pool-size: 50 + #最大超时时间 + #connection-timeout: 600000 mybatis-plus: mapper-locations: classpath:/mapper/*Mapper.xml diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/controller.vm b/velocity-tmp-dir/back-vms/mybatis-plus/controller.vm index 171d767..4c4876c 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus/controller.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus/controller.vm @@ -1,7 +1,8 @@ #parse("utils.vm") package ${basicConfig.packageName}.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; - +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; import ${basicConfig.packageName}.entity.${dbTableConfig.tableNameCase}; /** * ${dbTableConfig.tableDesc}Controller @@ -12,105 +13,107 @@ import ${basicConfig.packageName}.entity.${dbTableConfig.tableNameCase}; @Api(tags = "${dbTableConfig.tableDesc}(${dbTableConfig.tableNameCase})") @RestController @RequestMapping("${dbTableConfig.tableName}") +@Validated public class ${dbTableConfig.tableNameCase}Controller { - @Resource - private ${dbTableConfig.tableNameCase}Service ${dbTableConfig.tableName}Service; +@Resource +private ${dbTableConfig.tableNameCase}Service ${dbTableConfig.tableName}Service; - /** - * 分页查询所有数据 - * +/** +* 分页查询所有数据 +* ## * @param ${dbTableConfig.tableName} 查询实体 - * @return ResResult - */ - @GetMapping("selectPage") - @ApiOperation(value = "分页查询所有数据") +* @return ResResult +*/ +@GetMapping("selectPage") +@ApiOperation(value = "分页查询所有数据") - #getSwaggerParam() - public ResResult selectPage(#getQueryField() SelfCommonParams commonParams) { - QueryWrapper <${dbTableConfig.tableNameCase}> queryWrapper = new QueryWrapper<>(); - #foreach($item in $queryConfig) - #if(${item.originField}=="create_time") - //${item.desc} - queryWrapper.orderByDesc("$item.originField"); - if (ObjSelfUtils.isNotEmpty(commonParams.getStartTime())) { - queryWrapper.between("create_time", commonParams.getStartTime(), commonParams.getEndTime()); - } - #else - //${item.desc} - if (ObjSelfUtils.isNotEmpty( ${item.field})) { - queryWrapper.like("${item.originField}", ${item.field}); - } - #end +#getSwaggerParam() +public ResResult selectPage(#getQueryField() SelfCommonParams commonParams) { +QueryWrapper <${dbTableConfig.tableNameCase}> queryWrapper = new QueryWrapper<>(); +#foreach($item in $queryConfig) + #if(${item.originField}=="create_time") + //${item.desc} + queryWrapper.orderByDesc("$item.originField"); + if (ObjSelfUtils.isNotEmpty(commonParams.getStartTime())) { + queryWrapper.between("create_time", commonParams.getStartTime(), commonParams.getEndTime()); + } + #else + //${item.desc} + if (ObjSelfUtils.isNotEmpty( ${item.field})) { + queryWrapper.like("${item.originField}", ${item.field}); + } #end +#end - queryWrapper.select("$selectString"); +queryWrapper.select("$selectString"); - Page <${dbTableConfig.tableNameCase}> ${dbTableConfig.tableName}Page = this.${dbTableConfig.tableName}Service.selectPage(commonParams.getPageNum(), commonParams.getPageSize(),queryWrapper); - return new ResResult().success(${dbTableConfig.tableName}Page); - } +Page <${dbTableConfig.tableNameCase}> ${dbTableConfig.tableName}Page = this.${dbTableConfig.tableName}Service.selectPage(commonParams.getPageNum(), commonParams.getPageSize(),queryWrapper); +return new ResResult().success(${dbTableConfig.tableName}Page); +} - /** - * 通过主键查询单条数据 - * - * @param id 主键 - * @return 单条数据 - */ - @GetMapping("selectById") - @ApiOperation(value = "通过id主键查询单条数据") - public ResResult selectById(@RequestParam("id") ${dbTableConfig.uniKeyType} id) { - return new ResResult().success(this.${dbTableConfig.tableName}Service.selectById(id)); - } +/** +* 通过主键查询单条数据 +* +* @param id 主键 +* @return 单条数据 +*/ +@GetMapping("selectById") +@ApiOperation(value = "通过id主键查询单条数据") +public ResResult selectById(@RequestParam("id") ${dbTableConfig.uniKeyType} id) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.selectById(id)); +} - /** - * @Description: 根据id数组查询品牌列表 - * @Param: idList id数组 - * @return: ids列表数据 - */ - @ApiOperation(value = "根据id数组查询品牌列表") - @PostMapping("selectBatchIds") - public ResResult selectBatchIds(@RequestParam("idList") List< ${dbTableConfig.uniKeyType} > idList) { - return new ResResult().success(this.${dbTableConfig.tableName}Service.selectBatchIds(idList)); - } +/** +* @Description: 根据id数组查询列表 +* @Param: idList id数组 +* @return: ids列表数据 +*/ +@ApiOperation(value = "根据id数组查询列表") +@PostMapping("selectBatchIds") +public ResResult selectBatchIds(@RequestParam("idList") List< ${dbTableConfig.uniKeyType} > idList) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.selectBatchIds(idList)); +} - /** - * 新增数据 - * - * @param ${dbTableConfig.tableName} 实体对象 - * @return 新增结果 - */ - @ApiOperation(value = "新增数据") - @PostMapping("insert") - public ResResult insert(@RequestBody ${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { - return new ResResult().success(this.${dbTableConfig.tableName}Service.insert(${dbTableConfig.tableName})); - } +/** +* 新增数据 +* +* @param ${dbTableConfig.tableName} 实体对象 +* @return 新增结果 +*/ +@ApiOperation(value = "新增数据") +@PostMapping("insert") +public ResResult insert(@Validated @RequestBody ${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.insert(${dbTableConfig.tableName})); +} - /** - * 修改数据 - * - * @param ${dbTableConfig.tableName} 实体对象 - * @return 修改结果 - */ - @ApiOperation(value = "根据id修改数据") - @PutMapping("updateById") - public ResResult updateById(@RequestBody ${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { - return new ResResult().success(this.${dbTableConfig.tableName}Service.updateById(${dbTableConfig.tableName})); - } +/** +* 修改数据 +* +* @param ${dbTableConfig.tableName} 实体对象 +* @return 修改结果 +*/ +@ApiOperation(value = "根据id修改数据") +@PutMapping("updateById") +public ResResult updateById(@Validated @RequestBody ${dbTableConfig.tableNameCase} ${dbTableConfig.tableName}) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.updateById(${dbTableConfig.tableName})); +} - /** - * 删除数据 - * - * @param idList 主键结合 - * @return 删除结果 - */ - @ApiOperation(value = "根据id数组删除数据") - @DeleteMapping("deleteBatchIds") - public ResResult deleteBatchIds(@RequestBody List< ${dbTableConfig.uniKeyType} > idList) { - return new ResResult().success(this.${dbTableConfig.tableName}Service.deleteBatchIds(idList)); - } +/** +* 删除数据 +* +* @param idList 主键结合 +* @return 删除结果 +*/ +@ApiOperation(value = "根据id数组删除数据") +@DeleteMapping("deleteBatchIds") +public ResResult deleteBatchIds(@RequestBody List< ${dbTableConfig.uniKeyType} > idList) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.deleteBatchIds(idList)); +} - @DeleteMapping("根据id删除数据") - public ResResult deleteById(@RequestParam("id") ${dbTableConfig.uniKeyType} id) { - return new ResResult().success(this.${dbTableConfig.tableName}Service.deleteById(id)); - } +@ApiOperation("根据id删除数据") +@DeleteMapping("deleteById") +public ResResult deleteById(@RequestParam("id") ${dbTableConfig.uniKeyType} id) { +return new ResResult().success(this.${dbTableConfig.tableName}Service.deleteById(id)); +} } diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/entity.vm b/velocity-tmp-dir/back-vms/mybatis-plus/entity.vm index 6c5dc52..2654837 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus/entity.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus/entity.vm @@ -1,5 +1,8 @@ +#parse("utils.vm") package ${basicConfig.packageName}.entity; import java.util.Date; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; /** * ${dbTableConfig.tableDesc}实体类 * @@ -10,28 +13,29 @@ import java.util.Date; @ApiModel("${dbTableConfig.tableDesc}") @TableName(value = "${dbTableConfig.originTableName}") public class ${dbTableConfig.tableNameCase} extends Model< ${dbTableConfig.tableNameCase} > { - #foreach($item in $formConfig) - #if($item.field=="createTime") - @ApiModelProperty(value = "$item.desc",hidden = true) - @TableField(fill = FieldFill.INSERT) - private ${item.type} $item.field; - #elseif($item.field=="updateTime") - @ApiModelProperty(value = "$item.desc",hidden = true) - @TableField(fill = FieldFill.UPDATE) - private ${item.type} $item.field; - #else - @ApiModelProperty(value = "$item.desc",hidden=$item.isNotShowSwagger) - private ${item.type} $item.field; - #end +#foreach($item in $formConfig) + #if($item.field=="createTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.INSERT) + private ${item.type} $item.field; + #elseif($item.field=="updateTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private ${item.type} $item.field; + #else + @ApiModelProperty(value = "$item.desc",hidden=$item.isNotShowSwagger) + #getValid($item) + private ${item.type} $item.field; #end +#end - /** - * 获取主键值 - * - * @return 主键值 - */ - @Override - protected Serializable pkVal() { - return this.${dbTableConfig.uniKey}; - } +/** +* 获取主键值 +* +* @return 主键值 +*/ +@Override +protected Serializable pkVal() { +return this.${dbTableConfig.uniKey}; +} } diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm b/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm index e515fd5..fca7b65 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm @@ -5,25 +5,44 @@ #set($lenth=$originFieldString.length() - 1) #set($selectString=$originFieldString.substring(0,$lenth)) + +#macro(getValid $item) + #if($item.isNeedInput=="true") + @NotEmpty(message = "${item.field}不能为空") + #end + #if($item.rule=="upZeroInt") + @Pattern(regexp = "^\+?[1-9]\d*$",message = "${item.field}输入有误-正整数") + #elseif($item.rule=="zeroInt") + @Pattern(regexp = "^\+?[0-9]\d*$",message = "${item.field}输入有误-正整数包括0") + #elseif($item.rule=="phone") + @Pattern(regexp = "^0?1[0-9]{10}$",message = "${item.field}输入有误-手机号}") + #elseif($item.rule=="money") + @Pattern(regexp = "((^[1-9]\d*)|^0)(\.\d{0,2}){0,1}$",message = "${item.field}输入有误-金额") + #elseif($item.rule=="email") + @Pattern(regexp = "(^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4}))$",message = "${item.field}输入有误-邮箱") + #elseif($item.rule=="idCard") + @Pattern(regexp = "(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)",message = "${item.field}输入有误-身份证") + #end +#end + + #macro(getQueryField) #foreach($item in $queryConfig) - #if($item.isNeedInput=="true") - @ApiIgnore @RequestParam("$item.field") String $item.field, - #else - @RequestParam("$item.field") String $item.field, - #end + #if($item.isNotShowSwagger=="true")@ApiIgnore()#end #getValid($item) String $item.field, #end #end + + #macro(getSwaggerParam) @ApiImplicitParams({ #foreach($item in $queryConfig) #if($item.isNotShowSwagger=="false") #if($item.isNeedInput=="true") - @ApiImplicitParam(name = "$item.field", value = "$item.desc", required = true), + @ApiImplicitParam(name = "$item.field", value = "$item.desc",paramType = "query", required = true), #else - @ApiImplicitParam(name = "$item.field", value = "$item.desc"), + @ApiImplicitParam(name = "$item.field", value = "$item.desc",paramType = "query"), #end #end #end diff --git a/velocity-tmp-dir/json-data/mybatis-plus/basicData.json b/velocity-tmp-dir/json-data/mybatis-plus/basicData.json index 1cf99fa..75a3c2b 100644 --- a/velocity-tmp-dir/json-data/mybatis-plus/basicData.json +++ b/velocity-tmp-dir/json-data/mybatis-plus/basicData.json @@ -267,7 +267,7 @@ "tbName": "id", "type": "Long", "componentType": "", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -279,7 +279,8 @@ "valueKey": "value", "optionDataArr": [], "isShowSwagger": true, - "isNotShowSwagger": "false" + "isNotShowSwagger": "false", + "isNeedInput": "true" }, { "columnType": "varchar(255)", @@ -298,7 +299,7 @@ "tbName": "code", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -309,7 +310,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" }, { "columnType": "varchar(36)", @@ -328,7 +330,7 @@ "tbName": "editor", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -339,7 +341,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" }, { "columnType": "varchar(255)", @@ -358,7 +361,7 @@ "tbName": "name", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "phone", "value": "value", "label": "label", "children": "children", @@ -369,7 +372,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "false" + "isNotShowSwagger": "false", + "isNeedInput": "true" }, { "columnType": "datetime", @@ -388,7 +392,7 @@ "tbName": "create_time", "type": "Date", "componentType": "datetime", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -399,7 +403,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" } ], "tableShowArr": [ @@ -420,7 +425,7 @@ "tbName": "id", "type": "Long", "componentType": "", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -432,7 +437,8 @@ "valueKey": "value", "optionDataArr": [], "isShowSwagger": true, - "isNotShowSwagger": "false" + "isNotShowSwagger": "false", + "isNeedInput": "true" }, { "columnType": "varchar(255)", @@ -451,7 +457,7 @@ "tbName": "code", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -462,7 +468,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" }, { "columnType": "varchar(36)", @@ -481,7 +488,7 @@ "tbName": "editor", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -492,7 +499,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" }, { "columnType": "varchar(255)", @@ -511,7 +519,7 @@ "tbName": "name", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "phone", "value": "value", "label": "label", "children": "children", @@ -522,7 +530,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "false" + "isNotShowSwagger": "false", + "isNeedInput": "true" }, { "columnType": "datetime", @@ -541,7 +550,7 @@ "tbName": "create_time", "type": "Date", "componentType": "datetime", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -552,7 +561,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" } ], "tableFormArr": [ @@ -573,7 +583,7 @@ "tbName": "id", "type": "Long", "componentType": "", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -585,7 +595,8 @@ "valueKey": "value", "optionDataArr": [], "isShowSwagger": true, - "isNotShowSwagger": "false" + "isNotShowSwagger": "false", + "isNeedInput": "true" }, { "columnType": "varchar(255)", @@ -604,7 +615,7 @@ "tbName": "code", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -615,7 +626,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" }, { "columnType": "varchar(36)", @@ -634,7 +646,7 @@ "tbName": "editor", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -645,7 +657,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" }, { "columnType": "varchar(255)", @@ -664,7 +677,7 @@ "tbName": "name", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "phone", "value": "value", "label": "label", "children": "children", @@ -675,7 +688,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "false" + "isNotShowSwagger": "false", + "isNeedInput": "true" }, { "columnType": "datetime", @@ -694,7 +708,7 @@ "tbName": "create_time", "type": "Date", "componentType": "datetime", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -705,7 +719,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" } ] } @@ -973,7 +988,7 @@ "tbName": "id", "type": "Long", "componentType": "", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -985,7 +1000,8 @@ "valueKey": "value", "optionDataArr": [], "isShowSwagger": true, - "isNotShowSwagger": "false" + "isNotShowSwagger": "false", + "isNeedInput": "true" }, { "columnType": "varchar(255)", @@ -1004,7 +1020,7 @@ "tbName": "code", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1015,7 +1031,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" }, { "columnType": "varchar(36)", @@ -1034,7 +1051,7 @@ "tbName": "editor", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1045,7 +1062,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" }, { "columnType": "varchar(255)", @@ -1064,7 +1082,7 @@ "tbName": "name", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "phone", "value": "value", "label": "label", "children": "children", @@ -1075,7 +1093,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "false" + "isNotShowSwagger": "false", + "isNeedInput": "true" }, { "columnType": "datetime", @@ -1094,7 +1113,7 @@ "tbName": "create_time", "type": "Date", "componentType": "datetime", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1105,7 +1124,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" } ], "tableShowArr": [ @@ -1126,7 +1146,7 @@ "tbName": "id", "type": "Long", "componentType": "", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1138,7 +1158,8 @@ "valueKey": "value", "optionDataArr": [], "isShowSwagger": true, - "isNotShowSwagger": "false" + "isNotShowSwagger": "false", + "isNeedInput": "true" }, { "columnType": "varchar(255)", @@ -1157,7 +1178,7 @@ "tbName": "code", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1168,7 +1189,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" }, { "columnType": "varchar(36)", @@ -1187,7 +1209,7 @@ "tbName": "editor", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1198,7 +1220,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" }, { "columnType": "varchar(255)", @@ -1217,7 +1240,7 @@ "tbName": "name", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "phone", "value": "value", "label": "label", "children": "children", @@ -1228,7 +1251,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "false" + "isNotShowSwagger": "false", + "isNeedInput": "true" }, { "columnType": "datetime", @@ -1247,7 +1271,7 @@ "tbName": "create_time", "type": "Date", "componentType": "datetime", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1258,7 +1282,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" } ], "tableFormArr": [ @@ -1279,7 +1304,7 @@ "tbName": "id", "type": "Long", "componentType": "", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1291,7 +1316,8 @@ "valueKey": "value", "optionDataArr": [], "isShowSwagger": true, - "isNotShowSwagger": "false" + "isNotShowSwagger": "false", + "isNeedInput": "true" }, { "columnType": "varchar(255)", @@ -1310,7 +1336,7 @@ "tbName": "code", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1321,7 +1347,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" }, { "columnType": "varchar(36)", @@ -1340,7 +1367,7 @@ "tbName": "editor", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1351,7 +1378,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" }, { "columnType": "varchar(255)", @@ -1370,7 +1398,7 @@ "tbName": "name", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "phone", "value": "value", "label": "label", "children": "children", @@ -1381,7 +1409,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "false" + "isNotShowSwagger": "false", + "isNeedInput": "true" }, { "columnType": "datetime", @@ -1400,7 +1429,7 @@ "tbName": "create_time", "type": "Date", "componentType": "datetime", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1411,7 +1440,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" } ] }, @@ -1433,7 +1463,7 @@ "tbName": "id", "type": "Long", "componentType": "", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1445,7 +1475,8 @@ "valueKey": "value", "optionDataArr": [], "isShowSwagger": true, - "isNotShowSwagger": "false" + "isNotShowSwagger": "false", + "isNeedInput": "true" }, { "columnType": "varchar(255)", @@ -1464,7 +1495,7 @@ "tbName": "code", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1475,7 +1506,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" }, { "columnType": "varchar(36)", @@ -1494,7 +1526,7 @@ "tbName": "editor", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1505,7 +1537,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" }, { "columnType": "varchar(255)", @@ -1524,7 +1557,7 @@ "tbName": "name", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "phone", "value": "value", "label": "label", "children": "children", @@ -1535,7 +1568,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "false" + "isNotShowSwagger": "false", + "isNeedInput": "true" }, { "columnType": "datetime", @@ -1554,7 +1588,7 @@ "tbName": "create_time", "type": "Date", "componentType": "datetime", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1565,7 +1599,8 @@ "labelKey": "label", "valueKey": "value", "optionDataArr": [], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" } ], "tableConfig": [ @@ -1798,7 +1833,7 @@ "tbName": "id", "type": "Long", "componentType": "", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1810,7 +1845,8 @@ "valueKey": "code", "optionDataArr": [], "isShowSwagger": true, - "isNotShowSwagger": "false" + "isNotShowSwagger": "false", + "isNeedInput": "true" }, { "columnType": "bigint(20)", @@ -1829,7 +1865,7 @@ "tbName": "parent_id", "type": "Long", "componentType": "", - "rule": "isNotNull", + "rule": "idCard", "value": "value", "label": "label", "children": "children", @@ -1841,7 +1877,8 @@ "valueKey": "code", "optionDataArr": [], "isShowSwagger": true, - "isNotShowSwagger": "false" + "isNotShowSwagger": "false", + "isNeedInput": "true" }, { "columnType": "varchar(255)", @@ -1860,7 +1897,7 @@ "tbName": "code", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1872,7 +1909,8 @@ "valueKey": "code", "optionDataArr": [], "isShowSwagger": true, - "isNotShowSwagger": "false" + "isNotShowSwagger": "false", + "isNeedInput": "false" }, { "columnType": "varchar(255)", @@ -1891,7 +1929,7 @@ "tbName": "intro", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1903,7 +1941,8 @@ "valueKey": "code", "optionDataArr": [], "isShowSwagger": true, - "isNotShowSwagger": "false" + "isNotShowSwagger": "false", + "isNeedInput": "false" }, { "columnType": "datetime", @@ -1922,7 +1961,7 @@ "tbName": "create_time", "type": "Date", "componentType": "datetime", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1934,7 +1973,8 @@ "valueKey": "code", "optionDataArr": [], "isShowSwagger": false, - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" }, { "columnType": "varchar(36)", @@ -1953,7 +1993,7 @@ "tbName": "creator", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1965,7 +2005,8 @@ "valueKey": "code", "optionDataArr": [], "isShowSwagger": false, - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" }, { "columnType": "datetime", @@ -1984,7 +2025,7 @@ "tbName": "update_time", "type": "Date", "componentType": "datetime", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -1996,7 +2037,8 @@ "valueKey": "code", "optionDataArr": [], "isShowSwagger": false, - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" }, { "columnType": "varchar(36)", @@ -2015,7 +2057,7 @@ "tbName": "editor", "type": "String", "componentType": "input", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -2027,7 +2069,8 @@ "valueKey": "code", "optionDataArr": [], "isShowSwagger": false, - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" }, { "columnType": "tinyint(1) unsigned", @@ -2046,7 +2089,7 @@ "tbName": "deleted", "type": "Integer", "componentType": "select", - "rule": "isNotNull", + "rule": "notValid", "value": "value", "label": "label", "children": "children", @@ -2066,7 +2109,8 @@ "label": "已删除" } ], - "isNotShowSwagger": "true" + "isNotShowSwagger": "true", + "isNeedInput": "false" } ], "dataBaseUrl": "https://github.jzfai.top/micro-service-api/basis-func/dataBase/getAllDatabaseOrTable/micro-service-plus", diff --git a/velocity-tmp-dir/json-data/mybatis-plus/mutiQueryData.json b/velocity-tmp-dir/json-data/mybatis-plus/mutiQueryData.json new file mode 100644 index 0000000..8590bfc --- /dev/null +++ b/velocity-tmp-dir/json-data/mybatis-plus/mutiQueryData.json @@ -0,0 +1,2098 @@ +{ + "basicConfig": { + "author": "熊猫哥", + "packageName": "top.kuanghua.integrationfront", + "basicClassName": "role", + "basicClassDesc": "角色相关", + "dataTime": "2022-10-07 16:33:13", + "isMultiTable": true + }, + "multiTableConfig": [ + { + "tableName": "user", + "originTableName": "t_user", + "tableDesc": "用户", + "tableNameCase": "User", + "uniKey": "id", + "tableFieldArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "desc": "用户ID", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "frontField": "id", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + }, + { + "columnType": "tinyint(1)", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "用户状态:0=正常,1=禁用", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "state", + "field": "state", + "desc": "用户状态:0=正常,1=禁用", + "fieldCase": "State", + "originField": "state", + "tbName": "state", + "type": "Integer" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "desc": "姓名", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "frontField": "name", + "componentType": "input", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "头像图片地址", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "head_img_url", + "field": "headImgUrl", + "desc": "头像图片地址", + "fieldCase": "HeadImgUrl", + "originField": "head_img_url", + "tbName": "head_img_url", + "type": "String" + }, + { + "columnType": "varchar(11)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "手机号码", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "phone", + "field": "phone", + "desc": "手机号码", + "fieldCase": "Phone", + "originField": "phone", + "tbName": "phone", + "type": "String" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "密码加盐", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "salt", + "field": "salt", + "desc": "密码加盐", + "fieldCase": "Salt", + "originField": "salt", + "tbName": "salt", + "type": "String" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "登录密码", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "password", + "field": "password", + "desc": "登录密码", + "fieldCase": "Password", + "originField": "password", + "tbName": "password", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "create_time", + "field": "createTime", + "desc": "创建时间", + "fieldCase": "CreateTime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "创建人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "creator", + "field": "creator", + "desc": "创建人", + "fieldCase": "Creator", + "originField": "creator", + "tbName": "creator", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "修改时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "update_time", + "field": "updateTime", + "desc": "修改时间", + "fieldCase": "UpdateTime", + "originField": "update_time", + "tbName": "update_time", + "type": "Date" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "修改人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "editor", + "field": "editor", + "desc": "修改人", + "fieldCase": "Editor", + "originField": "editor", + "tbName": "editor", + "type": "String" + }, + { + "columnType": "tinyint(1) unsigned", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "逻辑删除:0=未删除,1=已删除", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "deleted", + "field": "deleted", + "desc": "逻辑删除:0=未删除,1=已删除", + "fieldCase": "Deleted", + "originField": "deleted", + "tbName": "deleted", + "type": "Integer" + } + ], + "orgUniKey": "id", + "uniKeyType": "Long", + "priKeyArr": [ + "id" + ], + "priKeyItemArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "desc": "用户ID", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "frontField": "id", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + } + ], + "orgAssociationKey": "id", + "associationKey": "id", + "associationKeyCase": "Id", + "associationKeyType": "Long", + "tableQueryArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "frontField": "userId", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "frontField": "userName", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "姓名", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + } + ], + "tableShowArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "frontField": "userId", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "frontField": "userName", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "姓名", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + } + ], + "tableFormArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "frontField": "userId", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "frontField": "userName", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "姓名", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + } + ] + }, + { + "tableName": "role", + "originTableName": "t_role", + "tableDesc": "角色", + "tableNameCase": "Role", + "uniKey": "id", + "tableFieldArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "角色ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "id", + "field": "id", + "desc": "角色ID", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long" + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "所属父级角色ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "parent_id", + "field": "parentId", + "desc": "所属父级角色ID", + "fieldCase": "ParentId", + "originField": "parent_id", + "tbName": "parent_id", + "type": "Long" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色唯一CODE代码", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "code", + "field": "code", + "desc": "角色唯一CODE代码", + "fieldCase": "Code", + "originField": "code", + "tbName": "code", + "type": "String" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色名称", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "name", + "field": "name", + "desc": "角色名称", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色介绍", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "intro", + "field": "intro", + "desc": "角色介绍", + "fieldCase": "Intro", + "originField": "intro", + "tbName": "intro", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "create_time", + "field": "createTime", + "desc": "创建时间", + "fieldCase": "CreateTime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date" + }, + { + "columnType": "varchar(36)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "创建人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "creator", + "field": "creator", + "desc": "创建人", + "fieldCase": "Creator", + "originField": "creator", + "tbName": "creator", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "修改时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "update_time", + "field": "updateTime", + "desc": "修改时间", + "fieldCase": "UpdateTime", + "originField": "update_time", + "tbName": "update_time", + "type": "Date" + }, + { + "columnType": "varchar(36)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "修改人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "editor", + "field": "editor", + "desc": "修改人", + "fieldCase": "Editor", + "originField": "editor", + "tbName": "editor", + "type": "String" + }, + { + "columnType": "tinyint(1) unsigned", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "逻辑删除:0=未删除,1=已删除", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "deleted", + "field": "deleted", + "desc": "逻辑删除:0=未删除,1=已删除", + "fieldCase": "Deleted", + "originField": "deleted", + "tbName": "deleted", + "type": "Integer" + } + ], + "orgUniKey": "id", + "uniKeyType": "Long", + "priKeyArr": [ + "id", + "parent_id", + "code" + ], + "priKeyItemArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "角色ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "id", + "field": "id", + "desc": "角色ID", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long" + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "所属父级角色ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "parent_id", + "field": "parentId", + "desc": "所属父级角色ID", + "fieldCase": "ParentId", + "originField": "parent_id", + "tbName": "parent_id", + "type": "Long" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色唯一CODE代码", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "code", + "field": "code", + "desc": "角色唯一CODE代码", + "fieldCase": "Code", + "originField": "code", + "tbName": "code", + "type": "String" + } + ], + "orgAssociationKey": "code", + "associationKey": "code", + "associationKeyCase": "Code", + "associationKeyType": "String", + "tableQueryArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "角色ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "id", + "field": "id", + "desc": "角色ID", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "frontField": "roleId", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色名称", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "name", + "field": "name", + "desc": "角色名称", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "frontField": "roleName", + "componentType": "input", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + } + ], + "tableShowArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "角色ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "id", + "field": "id", + "desc": "角色ID", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "frontField": "roleId", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色名称", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "name", + "field": "name", + "desc": "角色名称", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "frontField": "roleName", + "componentType": "input", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + } + ], + "tableFormArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "角色ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "id", + "field": "id", + "desc": "角色ID", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "frontField": "roleId", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色名称", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "name", + "field": "name", + "desc": "角色名称", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "frontField": "roleName", + "componentType": "input", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + } + ] + } + ], + "dbTableConfig": { + "multiTableName": null, + "multiTableNameCase": null, + "multiTableDesc": "", + "tableName": "user", + "originTableName": "t_user", + "tableDesc": "用户", + "tableNameCase": "User", + "uniKey": "id", + "tableFieldArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "desc": "用户ID", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "frontField": "id", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + }, + { + "columnType": "tinyint(1)", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "用户状态:0=正常,1=禁用", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "state", + "field": "state", + "desc": "用户状态:0=正常,1=禁用", + "fieldCase": "State", + "originField": "state", + "tbName": "state", + "type": "Integer" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "desc": "姓名", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "frontField": "name", + "componentType": "input", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "头像图片地址", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "head_img_url", + "field": "headImgUrl", + "desc": "头像图片地址", + "fieldCase": "HeadImgUrl", + "originField": "head_img_url", + "tbName": "head_img_url", + "type": "String" + }, + { + "columnType": "varchar(11)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "手机号码", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "phone", + "field": "phone", + "desc": "手机号码", + "fieldCase": "Phone", + "originField": "phone", + "tbName": "phone", + "type": "String" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "密码加盐", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "salt", + "field": "salt", + "desc": "密码加盐", + "fieldCase": "Salt", + "originField": "salt", + "tbName": "salt", + "type": "String" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "登录密码", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "password", + "field": "password", + "desc": "登录密码", + "fieldCase": "Password", + "originField": "password", + "tbName": "password", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "create_time", + "field": "createTime", + "desc": "创建时间", + "fieldCase": "CreateTime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "创建人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "creator", + "field": "creator", + "desc": "创建人", + "fieldCase": "Creator", + "originField": "creator", + "tbName": "creator", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "修改时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "update_time", + "field": "updateTime", + "desc": "修改时间", + "fieldCase": "UpdateTime", + "originField": "update_time", + "tbName": "update_time", + "type": "Date" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "修改人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "editor", + "field": "editor", + "desc": "修改人", + "fieldCase": "Editor", + "originField": "editor", + "tbName": "editor", + "type": "String" + }, + { + "columnType": "tinyint(1) unsigned", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "逻辑删除:0=未删除,1=已删除", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "deleted", + "field": "deleted", + "desc": "逻辑删除:0=未删除,1=已删除", + "fieldCase": "Deleted", + "originField": "deleted", + "tbName": "deleted", + "type": "Integer" + } + ], + "orgUniKey": "id", + "uniKeyType": "Long", + "priKeyArr": [ + "id" + ], + "priKeyItemArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "desc": "用户ID", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "frontField": "id", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + } + ], + "orgAssociationKey": "id", + "associationKey": "id", + "associationKeyCase": "Id", + "associationKeyType": "Long", + "tableQueryArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "frontField": "userId", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "frontField": "userName", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "姓名", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + } + ], + "tableShowArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "frontField": "userId", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "frontField": "userName", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "姓名", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + } + ], + "tableFormArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "frontField": "userId", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "frontField": "userName", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "姓名", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + } + ] + }, + "queryConfig": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "角色ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "id", + "field": "id", + "desc": "角色ID", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "frontField": "roleId", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色名称", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "name", + "field": "name", + "desc": "角色名称", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "frontField": "roleName", + "componentType": "input", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + }, + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "frontField": "userId", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "frontField": "userName", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "姓名", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + } + ], + "tableConfig": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "角色ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "id", + "field": "id", + "frontField": "id", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "角色ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "所属父级角色ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "parent_id", + "field": "parentId", + "frontField": "parentId", + "fieldCase": "ParentId", + "originField": "parent_id", + "tbName": "parent_id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "所属父级角色ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色唯一CODE代码", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "code", + "field": "code", + "frontField": "code", + "fieldCase": "Code", + "originField": "code", + "tbName": "code", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "角色唯一CODE代码", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色名称", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "name", + "field": "name", + "frontField": "roleName", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "角色名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色介绍", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "intro", + "field": "intro", + "frontField": "intro", + "fieldCase": "Intro", + "originField": "intro", + "tbName": "intro", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "角色介绍", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "frontField": "userId", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "tinyint(1)", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "用户状态:0=正常,1=禁用", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "state", + "field": "state", + "frontField": "state", + "fieldCase": "State", + "originField": "state", + "tbName": "state", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "用户状态", + "optionData": "0=正常,1=禁用", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0", + "label": "正常" + }, + { + "value": "1", + "label": "禁用" + } + ] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "frontField": "userName", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "姓名", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "头像图片地址", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "head_img_url", + "field": "headImgUrl", + "frontField": "headImgUrl", + "fieldCase": "HeadImgUrl", + "originField": "head_img_url", + "tbName": "head_img_url", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "头像图片地址", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(11)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "手机号码", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "phone", + "field": "phone", + "frontField": "phone", + "fieldCase": "Phone", + "originField": "phone", + "tbName": "phone", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "手机号码", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "create_time", + "field": "createTime", + "frontField": "userCreateTime", + "fieldCase": "CreateTime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "用户创建时间", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "create_time", + "field": "createTime", + "fieldCase": "CreateTime", + "originField": "create_time", + "frontField": "roleCreateTime", + "tbName": "create_time", + "type": "Date", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "角色创建时间", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "width": 120, + "optionDataArr": [] + } + ], + "dataBaseUrl": "https://github.jzfai.top/micro-service-api/basis-func/dataBase/getAllDatabaseOrTable/micro-service-plus", + "dbRadio": [ + "t_role", + "t_user_role", + "t_user" + ], + "chooseDbRadio": "t_role", + "dbTableUrl": "https://github.jzfai.top/micro-service-api/basis-func/dataBase/getAllDatabaseOrTable/micro-service-plus", + "tbName": "t_role", + "checkColumnArr": [ + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "create_time", + "field": "createTime", + "fieldCase": "CreateTime", + "originField": "create_time", + "frontField": "roleCreateTime", + "tbName": "create_time", + "type": "Date", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "角色创建时间", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "width": 120, + "optionDataArr": [] + } + ], + "chooseDbArr": [ + { + "createTime": "2022-09-16T06:46:07", + "tableComment": "角色", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "id": "f239e1a4-ef6b-4b56-b4bc-dd3bce4bd4e1" + }, + { + "createTime": "2022-09-16T06:46:07", + "tableComment": "用户角色", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "id": "5e47ce1b-1502-421d-acb3-899afc6b56cc" + }, + { + "createTime": "2022-09-16T06:46:07", + "tableComment": "用户", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "id": "e7b294e9-2ab9-467a-8b95-e49f96153868" + } + ], + "tbData": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "角色ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "id" + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "所属父级角色ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "parent_id" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色唯一CODE代码", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "code" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色名称", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "name" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色介绍", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "intro" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "create_time", + "field": "createTime", + "fieldCase": "CreateTime", + "originField": "create_time", + "frontField": "roleCreateTime", + "tbName": "create_time", + "type": "Date", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "角色创建时间", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "width": 120, + "optionDataArr": [] + }, + { + "columnType": "varchar(36)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "创建人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "creator" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "修改时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "update_time" + }, + { + "columnType": "varchar(36)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "修改人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "editor" + }, + { + "columnType": "tinyint(1) unsigned", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "逻辑删除:0=未删除,1=已删除", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "deleted" + } + ] +} \ No newline at end of file From 2aff7500552a489377c97887dab44005cf927014 Mon Sep 17 00:00:00 2001 From: kuanghua <869653722qq.com> Date: Tue, 11 Oct 2022 11:44:07 +0800 Subject: [PATCH 30/36] finish mybatis-plus-multi tmp func --- .../basisfunc/service/GeneratorService.java | 40 +- .../service/MybatisPlusGeneratorService.java | 217 +- .../basisfunc/utils/GeneratorTempUtils.java | 14 +- .../MybatisPlusGeneratorServiceTest.java | 27 +- .../controller/RoleController.java | 50 +- .../controller/UserController.java | 1 + .../integrationfront/entity/Role.java | 29 +- .../src/main/resources/mapper/UrMulMapper.xml | 54 + .../mybatis-plus-bak/controllerMul.vm | 75 + .../back-vms/mybatis-plus-bak/entity.vm | 37 + .../back-vms/mybatis-plus-bak/entityMul.vm | 29 + .../back-vms/mybatis-plus-bak/entityVo.vm | 19 + .../back-vms/mybatis-plus-bak/mapper.vm | 10 + .../back-vms/mybatis-plus-bak/mapperMul.vm | 16 + .../back-vms/mybatis-plus-bak/serviceMul.vm | 57 + .../back-vms/mybatis-plus-bak/utils.vm | 8 + .../back-vms/mybatis-plus-bak/xmlMul.vm | 60 + .../mybatis-plus-multi-bak/controllerMul.vm | 75 + .../back-vms/mybatis-plus-multi-bak/entity.vm | 37 + .../mybatis-plus-multi-bak/entityMul.vm | 29 + .../mybatis-plus-multi-bak/entityVo.vm | 19 + .../back-vms/mybatis-plus-multi-bak/mapper.vm | 10 + .../mybatis-plus-multi-bak/mapperMul.vm | 16 + .../mybatis-plus-multi-bak/serviceMul.vm | 57 + .../back-vms/mybatis-plus-multi-bak/utils.vm | 8 + .../back-vms/mybatis-plus-multi-bak/xmlMul.vm | 60 + .../mybatis-plus-multi-query/controllerMul.vm | 75 + .../mybatis-plus-multi-query/entity.vm | 37 + .../mybatis-plus-multi-query/entityMul.vm | 29 + .../mybatis-plus-multi-query/entityVo.vm | 19 + .../mybatis-plus-multi-query/mapper.vm | 10 + .../mybatis-plus-multi-query/mapperMul.vm | 16 + .../mybatis-plus-multi-query/serviceMul.vm | 57 + .../mybatis-plus-multi-query/utils.vm | 8 + .../mybatis-plus-multi-query/xmlMul.vm | 60 + .../mybatis-plus-multi/controllerMul.vm | 21 +- .../back-vms/mybatis-plus-multi/entity.vm | 12 +- .../back-vms/mybatis-plus-multi/entityMul.vm | 40 +- .../back-vms/mybatis-plus-multi/entityVo.vm | 18 +- .../back-vms/mybatis-plus-multi/mapper.vm | 6 +- .../back-vms/mybatis-plus-multi/mapperMul.vm | 10 +- .../back-vms/mybatis-plus-multi/serviceMul.vm | 84 +- .../back-vms/mybatis-plus-multi/utils.vm | 55 +- .../back-vms/mybatis-plus-multi/xmlMul.vm | 88 +- .../back-vms/mybatis-plus/utils.vm | 12 +- .../json-data/mybatis-plus/basicData.json | 2308 ++++++----- .../json-data/mybatis-plus/multiData.json | 3416 +++++++++++++++++ 47 files changed, 5970 insertions(+), 1465 deletions(-) create mode 100644 integration-front/src/main/resources/mapper/UrMulMapper.xml create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-bak/controllerMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-bak/entity.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-bak/entityMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-bak/entityVo.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-bak/mapper.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-bak/mapperMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-bak/serviceMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-bak/utils.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-bak/xmlMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/controllerMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/entity.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/entityMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/entityVo.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/mapper.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/mapperMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/serviceMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/utils.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/xmlMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi-query/controllerMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi-query/entity.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi-query/entityMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi-query/entityVo.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi-query/mapper.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi-query/mapperMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi-query/serviceMul.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi-query/utils.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi-query/xmlMul.vm create mode 100644 velocity-tmp-dir/json-data/mybatis-plus/multiData.json diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorService.java b/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorService.java index f51fefc..15be946 100644 --- a/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorService.java +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/service/GeneratorService.java @@ -26,26 +26,26 @@ public void generatorMybatisPlusMulTemp(Map jsonData) { Context context = getContext(jsonData); Map dbTableConfig = ObjSelfUtils.changeToMap(jsonData.get("dbTableConfig")); ArrayList> multiTableConfig = ObjSelfUtils.changeToArrayMap(jsonData.get("multiTableConfig")); - multiTableConfig.forEach((fItem) -> { - //entity - FileWriter entityWriter = null; - try { - Template entityTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entity.vm"); - context.put("currentTbConfig", fItem); - context.put("tableFieldArr", fItem.get("tableFieldArr")); - entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("entity") + fItem.get("tableNameCase") + ".java"); - entityTemp.merge(context, entityWriter); - entityWriter.close(); - - //single-mapper - Template mapperTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("mapper.vm"); - FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("mapper") + fItem.get("tableNameCase") + "Mapper.java"); - mapperTemp.merge(context, mapperWriter); - mapperWriter.close(); - } catch (IOException e) { - throw new RuntimeException(" mybatis-plus多表生成模版报错" + e); - } - }); +// multiTableConfig.forEach((fItem) -> { +// //entity +// FileWriter entityWriter = null; +// try { +// Template entityTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entity.vm"); +// context.put("currentTbConfig", fItem); +// context.put("tableFieldArr", fItem.get("tableFieldArr")); +// entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("entity") + fItem.get("tableNameCase") + ".java"); +// entityTemp.merge(context, entityWriter); +// entityWriter.close(); +// +// //single-mapper +// Template mapperTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("mapper.vm"); +// FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulDir("mapper") + fItem.get("tableNameCase") + "Mapper.java"); +// mapperTemp.merge(context, mapperWriter); +// mapperWriter.close(); +// } catch (IOException e) { +// throw new RuntimeException(" mybatis-plus多表生成模版报错" + e); +// } +// }); String tbName = dbTableConfig.get("multiTableNameCase").toString(); try { //controller diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorService.java b/basis-func/src/main/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorService.java index 899ad0e..a5bb46e 100644 --- a/basis-func/src/main/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorService.java +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorService.java @@ -1,6 +1,5 @@ package top.kuanghua.basisfunc.service; -import com.alibaba.fastjson.JSON; import org.apache.velocity.Template; import org.apache.velocity.context.Context; import org.springframework.stereotype.Service; @@ -37,26 +36,26 @@ public String generatorMybatisPlusBasicTmp(Map jsonData) { Map basicConfig = ObjSelfUtils.changeToMap(jsonData.get("basicConfig")); //包名转路径 - String packagePath = basicConfig.get("packageName").toString().replaceAll("\\.", Matcher.quoteReplacement(File.separator)); + String packagePath = basicConfig.get("packageName").toString().replaceAll("\\.", Matcher.quoteReplacement(File.separator)); //entity Template entityTemp = GeneratorTempUtils.getMybatisPlusTemp("entity.vm"); - FileWriter entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath,"entity") + tbName + ".java"); + FileWriter entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "entity") + tbName + ".java"); entityTemp.merge(context, entityWriter); entityWriter.close(); //controller Template controllerTemp = GeneratorTempUtils.getMybatisPlusTemp("controller.vm"); - FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath,"controller") + tbName + "Controller.java"); + FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "controller") + tbName + "Controller.java"); controllerTemp.merge(context, controllerWriter); controllerWriter.close(); //service Template serviceTemp = GeneratorTempUtils.getMybatisPlusTemp("service.vm"); - FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath,"service") + tbName + "Service.java"); + FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "service") + tbName + "Service.java"); serviceTemp.merge(context, serviceWriter); serviceWriter.close(); //mapper Template mapperTemp = GeneratorTempUtils.getMybatisPlusTemp("mapper.vm"); - FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath,"mapper") + tbName + "Mapper.java"); + FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "mapper") + tbName + "Mapper.java"); mapperTemp.merge(context, mapperWriter); mapperWriter.close(); @@ -70,82 +69,170 @@ public String generatorMybatisPlusBasicTmp(Map jsonData) { } } + /** - * element-plus多表生成模版 + * Mybatis-plus 多表生成 */ - public void generatorElementPlusTemp(Map jsonData) { + public void generatorMybatisPlusMulTemp(Map jsonData) { + Context context = GeneratorTempUtils.getVelocityContext(); + context.put("totalData", jsonData); + context.put("basicConfig", jsonData.get("basicConfig")); + context.put("multiTableConfig", jsonData.get("multiTableConfig")); + context.put("dbTableConfig", jsonData.get("dbTableConfig")); + context.put("apiConfig", jsonData.get("apiConfig")); + context.put("queryConfig", jsonData.get("queryConfig")); + context.put("tableConfig", jsonData.get("tableConfig")); + context.put("formConfig", jsonData.get("formConfig")); + Map dbTableConfig = ObjSelfUtils.changeToMap(jsonData.get("dbTableConfig")); + ArrayList> multiTableConfig = ObjSelfUtils.changeToArrayMap(jsonData.get("multiTableConfig")); + Map basicConfig = ObjSelfUtils.changeToMap(jsonData.get("basicConfig")); + String packagePath = basicConfig.get("packageName").toString().replaceAll("\\.", Matcher.quoteReplacement(File.separator)); + multiTableConfig.forEach((fItem) -> { + //entity + FileWriter entityWriter = null; + try { + Template entityTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entity.vm"); + context.put("currentTbConfig", fItem); +// if (multiTableConfig.get(multiTableConfig.size() - 1).get("originTableName").equals(fItem.get("originTableName"))) { +// context.put("tableFormArr", fItem.get("tableFieldArr")); +// } else { +// context.put("tableFormArr", fItem.get("tableFormArr")); +// } + context.put("tableFormArr", fItem.get("tableFieldArr")); + entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "entity") + fItem.get("tableNameCase") + ".java"); + entityTemp.merge(context, entityWriter); + entityWriter.close(); + + //single-mapper + Template mapperTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("mapper.vm"); + FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "mapper") + fItem.get("tableNameCase") + "Mapper.java"); + mapperTemp.merge(context, mapperWriter); + mapperWriter.close(); + } catch (IOException e) { + throw new RuntimeException(" mybatis-plus多表生成模版报错" + e); + } + }); + String tbName = dbTableConfig.get("multiTableNameCase").toString(); try { - Context context = getContext(jsonData); - Template template = GeneratorTempUtils.getElementPlusTemp("CRUD.vm"); - FileWriter fileWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUD.vue"); - template.merge(context, fileWriter); - fileWriter.close(); - //第二个模板 - Template addModal = GeneratorTempUtils.getElementPlusTemp("CRUDForm.vm"); - FileWriter addModalWriter = new FileWriter(GeneratorTempUtils.getExportElementPlusDir("") + "CRUDForm.vue"); - addModal.merge(context, addModalWriter); - addModalWriter.close(); - } catch (IOException e) { - throw new RuntimeException("element-plus多表生成模版报错" + e); - } - } + //controller + Template controllerTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("controllerMul.vm"); + FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "controller") + tbName + "Controller.java"); + controllerTemp.merge(context, controllerWriter); + controllerWriter.close(); + //service + Template serviceTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("serviceMul.vm"); + FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "service") + tbName + "Service.java"); + serviceTemp.merge(context, serviceWriter); + serviceWriter.close(); - /** - * 生成后端模版 - * - * @param jsonData - * @return - */ - public String generatorBackTempZip(Map jsonData) { - Map commonConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("commonConfig")), Map.class); - if ("true".equals(commonConfig.get("isTableMulChoose").toString())) { - //多表模版 -// generatorMybatisPlusMulTemp(jsonData); - } else { - /*单表*/ -// generatorMybatisPlusTemp(jsonData); + //mul-entity + Template mapperMulTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("mapperMul.vm"); + FileWriter mapperMulWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "mapper") + tbName + "Mapper.java"); + mapperMulTemp.merge(context, mapperMulWriter); + mapperMulWriter.close(); + + //entity-vo + Template entityVoTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entityVo.vm"); + FileWriter entityVoWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "vo") + tbName + "Vo.java"); + entityVoTemp.merge(context, entityVoWriter); + entityVoWriter.close(); + + //entity-mul + Template entityMulTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entityMul.vm"); + FileWriter entityMulWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "entity") + tbName + ".java"); + entityMulTemp.merge(context, entityMulWriter); + entityMulWriter.close(); + //xml + Template xmlTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("xmlMul.vm"); + FileWriter xmlWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "xml") + tbName + "Mapper.xml"); + xmlTemp.merge(context, xmlWriter); + xmlWriter.close(); + + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + } catch (IOException e) { + throw new RuntimeException("生成实体类报错" + e); } - String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; - //生成zip包 - GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); - return exportFilePath; } /** - * 生成前端模版 - * - * @param jsonData - * @return + * mybatis-plus多表生成模版-查询 */ - public String generatorFrontTempZip(Map jsonData) { - Map commonConfig = JSON.parseObject(JSON.toJSONString(jsonData.get("commonConfig")), Map.class); - //多表 - if ("true".equals(commonConfig.get("isTableMulChoose").toString())) { - //生成前端模板 - generatorElementPlusTemp(jsonData); - } else { - /*单表*/ - //生成前端模板 - generatorElementPlusTemp(jsonData); - } - String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; - GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); - return exportFilePath; - } - - - private Context getContext(Map jsonData) { + public void generatorMybatisPlusMulQueryTmp(Map jsonData) { Context context = GeneratorTempUtils.getVelocityContext(); context.put("totalData", jsonData); - context.put("projectOrAuthor", jsonData.get("projectOrAuthor")); - context.put("commonConfig", jsonData.get("commonConfig")); + context.put("basicConfig", jsonData.get("basicConfig")); context.put("multiTableConfig", jsonData.get("multiTableConfig")); context.put("dbTableConfig", jsonData.get("dbTableConfig")); context.put("apiConfig", jsonData.get("apiConfig")); context.put("queryConfig", jsonData.get("queryConfig")); context.put("tableConfig", jsonData.get("tableConfig")); context.put("formConfig", jsonData.get("formConfig")); - return context; + Map dbTableConfig = ObjSelfUtils.changeToMap(jsonData.get("dbTableConfig")); +// ArrayList> multiTableConfig = ObjSelfUtils.changeToArrayMap(jsonData.get("multiTableConfig")); +// multiTableConfig.forEach((fItem) -> { +// //entity +// FileWriter entityWriter = null; +// try { +// Template entityTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entity.vm"); +// context.put("currentTbConfig", fItem); +// context.put("tableFieldArr", fItem.get("tableFieldArr")); +// entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulQueryDir("entity") + fItem.get("tableNameCase") + ".java"); +// entityTemp.merge(context, entityWriter); +// entityWriter.close(); +// +// //single-mapper +// Template mapperTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("mapper.vm"); +// FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulQueryDir("mapper") + fItem.get("tableNameCase") + "Mapper.java"); +// mapperTemp.merge(context, mapperWriter); +// mapperWriter.close(); +// } catch (IOException e) { +// throw new RuntimeException(" mybatis-plus多表生成模版报错" + e); +// } +// }); + String tbName = dbTableConfig.get("multiTableNameCase").toString(); + try { + //controller + Template controllerTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("controllerMul.vm"); + FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulQueryDir("controller") + tbName + "Controller.java"); + controllerTemp.merge(context, controllerWriter); + controllerWriter.close(); + //service + Template serviceTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("serviceMul.vm"); + FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulQueryDir("service") + tbName + "Service.java"); + serviceTemp.merge(context, serviceWriter); + serviceWriter.close(); + + //mul-entity + Template mapperMulTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("mapperMul.vm"); + FileWriter mapperMulWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulQueryDir("mapper") + tbName + "Mapper.java"); + mapperMulTemp.merge(context, mapperMulWriter); + mapperMulWriter.close(); + + //entity-vo + Template entityVoTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entityVo.vm"); + FileWriter entityVoWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulQueryDir("vo") + tbName + "Vo.java"); + entityVoTemp.merge(context, entityVoWriter); + entityVoWriter.close(); + + //entity-mul + Template entityMulTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entityMul.vm"); + FileWriter entityMulWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulQueryDir("entity") + tbName + ".java"); + entityMulTemp.merge(context, entityMulWriter); + entityMulWriter.close(); + //xml + Template xmlTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("xmlMul.vm"); + FileWriter xmlWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusMulQueryDir("xml") + tbName + "Mapper.xml"); + xmlTemp.merge(context, xmlWriter); + xmlWriter.close(); + String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; + //生成zip包 + GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + } catch (IOException e) { + throw new RuntimeException("生成实体类报错" + e); + } } + } diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java b/basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java index 83e5cd9..efef81b 100644 --- a/basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/utils/GeneratorTempUtils.java @@ -73,7 +73,19 @@ public static String getExportMybatisPlusMulDir(String dir) { return fileMkdir(path); } - public static String getExportMybatisPlusDir(String exportDir,String dir) { + public static String getExportMybatisPlusMulQueryDir(String dir) { + String os = System.getProperty("os.name"); + String path = ""; + if (os.toLowerCase().startsWith("win")) { + path = ExportFileDir + "mybatis-plus-multi-query" + File.separator + dir + File.separator; + } else { + path = MacExportFileDir + "mybatis-plus-multi-query" + File.separator + dir + File.separator; + } + return fileMkdir(path); + } + + + public static String getExportMybatisPlusDir(String exportDir, String dir) { String os = System.getProperty("os.name"); String path = ""; if (os.toLowerCase().startsWith("win")) { diff --git a/basis-func/src/test/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorServiceTest.java b/basis-func/src/test/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorServiceTest.java index 8a68132..3cebc6a 100644 --- a/basis-func/src/test/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorServiceTest.java +++ b/basis-func/src/test/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorServiceTest.java @@ -2,16 +2,11 @@ import com.alibaba.fastjson.JSON; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; import top.kuanghua.basisfunc.utils.GeneratorTempUtils; import java.io.IOException; import java.util.Map; -import static org.junit.jupiter.api.Assertions.*; - /** * @Title: MybatisPlusGeneratorServiceTest * @Description: @@ -21,10 +16,30 @@ public class MybatisPlusGeneratorServiceTest { @Test - public void generatorMybatisPlusBasicTmp() throws IOException { + public void generatorMybatisPlusBasicTmp() throws IOException { MybatisPlusGeneratorService generatorService = new MybatisPlusGeneratorService(); String string = GeneratorTempUtils.readFileToString("D:\\github\\micro-service-plus\\velocity-tmp-dir\\json-data\\mybatis-plus\\" + "basicData.json"); Map jsonData = JSON.parseObject(string, Map.class); generatorService.generatorMybatisPlusBasicTmp(jsonData); } + + /* + * 多表生成 + * */ + @Test + public void generatorMybatisPlusMulTemp() throws IOException { + MybatisPlusGeneratorService generatorService = new MybatisPlusGeneratorService(); + String string = GeneratorTempUtils.readFileToString("D:\\github\\micro-service-plus\\velocity-tmp-dir\\json-data\\mybatis-plus\\" + "multiData.json"); + Map jsonData = JSON.parseObject(string, Map.class); + generatorService.generatorMybatisPlusMulTemp(jsonData); + } + + /*查询*/ + @Test + public void generatorMybatisPlusMulQueryTmp() throws IOException { + MybatisPlusGeneratorService generatorService = new MybatisPlusGeneratorService(); + String string = GeneratorTempUtils.readFileToString("D:\\github\\micro-service-plus\\velocity-tmp-dir\\json-data\\mybatis-plus\\" + "basicData.json"); + Map jsonData = JSON.parseObject(string, Map.class); + generatorService.generatorMybatisPlusMulQueryTmp(jsonData); + } } \ No newline at end of file diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/RoleController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/RoleController.java index 0fc610f..4786b2a 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/RoleController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/RoleController.java @@ -1,14 +1,15 @@ -package top.kuanghua.integrationfront.controller; + + +package top.kuanghua.integrationfront.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; -import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import springfox.documentation.annotations.ApiIgnore; import top.kuanghua.commonpom.entity.ResResult; import top.kuanghua.commonpom.entity.SelfCommonParams; import top.kuanghua.commonpom.utils.ObjSelfUtils; @@ -16,12 +17,10 @@ import top.kuanghua.integrationfront.service.RoleService; import javax.annotation.Resource; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Pattern; import java.util.List; /** - * 角色Controller + * 角色Controller * * @author 熊猫哥 * @since 2022-10-07 16:33:13 @@ -29,7 +28,6 @@ @Api(tags = "角色(Role)") @RestController @RequestMapping("role") -@Validated public class RoleController { @Resource @@ -37,40 +35,36 @@ public class RoleController { /** * 分页查询所有数据 - * * @return ResResult */ @GetMapping("selectPage") @ApiOperation(value = "分页查询所有数据") @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "角色ID", paramType = "query", required = true), - @ApiImplicitParam(name = "name", value = "角色名称", paramType = "query", required = true), + @ApiImplicitParam(name = "id", value = "角色ID"), + @ApiImplicitParam(name = "name", value = "角色名称"), }) - public ResResult selectPage(@NotEmpty(message = "id不能为空}") - String id, - @ApiIgnore() String code, - @ApiIgnore() String editor, - @NotEmpty(message = "name不能为空}") - @Pattern(regexp = "^0?1[0-9]{10}$", message = "name输入有误-手机号}") - String name, - @ApiIgnore() String createTime, - SelfCommonParams commonParams) { + public ResResult selectPage( @RequestParam("id") String id, + @RequestParam("code") String code, + @RequestParam("editor") String editor, + @RequestParam("name") String name, + @RequestParam("createTime") String createTime, + SelfCommonParams commonParams) { QueryWrapper queryWrapper = new QueryWrapper<>(); //角色ID - if (ObjSelfUtils.isNotEmpty(id)) { + if (ObjSelfUtils.isNotEmpty( id)) { queryWrapper.like("id", id); } //角色唯一CODE代码 - if (ObjSelfUtils.isNotEmpty(code)) { + if (ObjSelfUtils.isNotEmpty( code)) { queryWrapper.like("code", code); } //修改人 - if (ObjSelfUtils.isNotEmpty(editor)) { + if (ObjSelfUtils.isNotEmpty( editor)) { queryWrapper.like("editor", editor); } //角色名称 - if (ObjSelfUtils.isNotEmpty(name)) { + if (ObjSelfUtils.isNotEmpty( name)) { queryWrapper.like("name", name); } //创建时间 @@ -81,7 +75,7 @@ public ResResult selectPage(@NotEmpty(message = "id不能为空}") queryWrapper.select("id,parent_id,code,intro,create_time,creator,update_time,editor,deleted"); - Page rolePage = this.roleService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); + Page rolePage = this.roleService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(),queryWrapper); return new ResResult().success(rolePage); } @@ -104,7 +98,7 @@ public ResResult selectById(@RequestParam("id") Long id) { */ @ApiOperation(value = "根据id数组查询品牌列表") @PostMapping("selectBatchIds") - public ResResult selectBatchIds(@RequestParam("idList") List idList) { + public ResResult selectBatchIds(@RequestParam("idList") List< Long > idList) { return new ResResult().success(this.roleService.selectBatchIds(idList)); } @@ -116,7 +110,7 @@ public ResResult selectBatchIds(@RequestParam("idList") List idList) { */ @ApiOperation(value = "新增数据") @PostMapping("insert") - public ResResult insert(@Validated @RequestBody Role role) { + public ResResult insert(@RequestBody Role role) { return new ResResult().success(this.roleService.insert(role)); } @@ -128,7 +122,7 @@ public ResResult insert(@Validated @RequestBody Role role) { */ @ApiOperation(value = "根据id修改数据") @PutMapping("updateById") - public ResResult updateById(@Validated @RequestBody Role role) { + public ResResult updateById(@RequestBody Role role) { return new ResResult().success(this.roleService.updateById(role)); } @@ -140,7 +134,7 @@ public ResResult updateById(@Validated @RequestBody Role role) { */ @ApiOperation(value = "根据id数组删除数据") @DeleteMapping("deleteBatchIds") - public ResResult deleteBatchIds(@RequestBody List idList) { + public ResResult deleteBatchIds(@RequestBody List< Long > idList) { return new ResResult().success(this.roleService.deleteBatchIds(idList)); } diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java index c792e8a..673c3aa 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/UserController.java @@ -94,6 +94,7 @@ public ResResult selectById(@RequestParam("id") Integer id) { */ @ApiOperation(value = "新增数据") @PostMapping("insert") + public ResResult insert(@Valid @RequestBody User user) { //List userInfos = userInfoMapper.selectList(new EntityWrapper<>(userInfo).like("firstname", name) // .like("lastname", name));52 diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java index 339dc06..3780d7d 100644 --- a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/Role.java @@ -1,5 +1,4 @@ package top.kuanghua.integrationfront.entity; - import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -8,13 +7,10 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Pattern; import java.io.Serializable; import java.util.Date; - /** - * 角色实体类 + * 角色实体类 * * @author 熊猫哥 * @since 2022-10-07 16:33:13 @@ -22,29 +18,26 @@ @Data @ApiModel("角色") @TableName(value = "t_role") -public class Role extends Model { - @ApiModelProperty(value = "角色ID(修改时需要传递)", hidden = false) - @NotEmpty(message = "id不能为空}") +public class Role extends Model< Role > { + @ApiModelProperty(value = "角色ID(修改时需要传递)",hidden=false) private Long id; - @ApiModelProperty(value = "所属父级角色ID(不传为顶级父id)", hidden = false) - @NotEmpty(message = "parentId不能为空}") - @Pattern(regexp = "(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)", message = "parentId输入有误-身份证") + @ApiModelProperty(value = "所属父级角色ID(不传为顶级父id)",hidden=false) private Long parentId; - @ApiModelProperty(value = "角色唯一CODE代码", hidden = false) + @ApiModelProperty(value = "角色唯一CODE代码",hidden=false) private String code; - @ApiModelProperty(value = "角色介绍", hidden = false) + @ApiModelProperty(value = "角色介绍",hidden=false) private String intro; - @ApiModelProperty(value = "创建时间", hidden = true) + @ApiModelProperty(value = "创建时间",hidden = true) @TableField(fill = FieldFill.INSERT) private Date createTime; - @ApiModelProperty(value = "创建人", hidden = true) + @ApiModelProperty(value = "创建人",hidden=true) private String creator; - @ApiModelProperty(value = "修改时间", hidden = true) + @ApiModelProperty(value = "修改时间",hidden = true) @TableField(fill = FieldFill.UPDATE) private Date updateTime; - @ApiModelProperty(value = "修改人", hidden = true) + @ApiModelProperty(value = "修改人",hidden=true) private String editor; - @ApiModelProperty(value = "逻辑删除", hidden = true) + @ApiModelProperty(value = "逻辑删除",hidden=true) private Integer deleted; /** diff --git a/integration-front/src/main/resources/mapper/UrMulMapper.xml b/integration-front/src/main/resources/mapper/UrMulMapper.xml new file mode 100644 index 0000000..62a6533 --- /dev/null +++ b/integration-front/src/main/resources/mapper/UrMulMapper.xml @@ -0,0 +1,54 @@ + + + + + + + t_role + . + id + as id,t_role.parent_id as parentId,t_role.code as code,t_role.name as roleName,t_role.intro as intro,t_user.id as userId,t_user.state as state,t_user.name as userName,t_user.head_img_url as headImgUrl,t_user.phone as phone,t_user.create_time as userCreateTime,t_role.create_time as roleCreateTime + + + + + \ No newline at end of file diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-bak/controllerMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-bak/controllerMul.vm new file mode 100644 index 0000000..70e3008 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-bak/controllerMul.vm @@ -0,0 +1,75 @@ +package ${projectOrAuthor.packageName}.controller; +import java.util.Map; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +/** +* ${dbTableConfig.multiTableDesc}Controller +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Api(tags = "维修信息") +@RestController +@RequestMapping("${dbTableConfig.multiTableName}") +public class ${dbTableConfig.multiTableNameCase}Controller { +@Resource +private ${dbTableConfig.multiTableNameCase}Service ${dbTableConfig.multiTableName}Service; + +@ApiOperation(value = "分页查询${dbTableConfig.multiTableDesc}") +@GetMapping("select${dbTableConfig.multiTableNameCase}") +public Page< Map > select${dbTableConfig.multiTableNameCase}(SelfCommonParams commonParams, ${dbTableConfig.multiTableNameCase}Vo ${dbTableConfig.multiTableName}Vo) { +Map ${dbTableConfig.multiTableName}Map = JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}Vo), Map.class); +return ${dbTableConfig.multiTableName}Service.select${dbTableConfig.multiTableNameCase}(commonParams, ${dbTableConfig.multiTableName}Map); +} + +/** +* 新增数据 +* +* @param ${dbTableConfig.multiTableName} 实体对象 +* @return 新增结果 +*/ +@ApiOperation(value = "新增${dbTableConfig.multiTableDesc}") +@PostMapping("insert") +public ResResult insert(@RequestBody ${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +this.${dbTableConfig.multiTableName}Service.insert(${dbTableConfig.multiTableName}); +return new ResResult().success(); +} + + +/** +* 通过主键查询单条数据 +* +* @param ${dbTableConfig.associationKey} 主键 +* @return 单条数据 +*/ +@GetMapping("selectByKey") +@ApiOperation(value = "通过联合key查询详情") +public ResResult selectByKey(@RequestParam("${dbTableConfig.associationKey}") ${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { +return new ResResult().success(${dbTableConfig.multiTableName}Service.selectByKey(${dbTableConfig.associationKey})); +} + +/** +* 修改数据 +* +* @param ${dbTableConfig.multiTableName} 实体对象 +* @return 修改结果 +*/ +@ApiOperation(value = "根据${dbTableConfig.associationKey}修改数据") +@PutMapping("updateByKey") +public ResResult updateByKey(@RequestBody ${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +this.${dbTableConfig.multiTableName}Service.updateByKey(${dbTableConfig.multiTableName}); +return new ResResult().success(); +} + + +/** +* 删除项根据主键key +* @param ${dbTableConfig.associationKey} +* @return +*/ +@ApiOperation(value = "根据联合key删除数据") +@DeleteMapping("deleteByKey") +public ResResult deleteByKey(@RequestParam("${dbTableConfig.associationKey}") ${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { +this.${dbTableConfig.multiTableName}Service.deleteByKey(${dbTableConfig.associationKey}); +return new ResResult().success(); +} +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-bak/entity.vm b/velocity-tmp-dir/back-vms/mybatis-plus-bak/entity.vm new file mode 100644 index 0000000..197fdbe --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-bak/entity.vm @@ -0,0 +1,37 @@ +package ${projectOrAuthor.packageName}.entity; +import java.util.*; +/** +* ${currentTbConfig.tableDesc}实体类 +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Data +@ApiModel("${currentTbConfig.tableDesc}") +@TableName(value = "${currentTbConfig.originTableName}") +public class ${currentTbConfig.tableNameCase} extends Model< ${currentTbConfig.tableNameCase} > { +#foreach($item in $dbTableConfig.tableFieldArr) + #if($item.field=="createTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.INSERT) + private ${item.type} $item.field; + #elseif($item.field=="updateTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private ${item.type} $item.field; + #else + @ApiModelProperty(value = "$item.desc") + private ${item.type} $item.field; + #end +#end + +/** +* 获取主键值 +* +* @return 主键值 +*/ +@Override +protected Serializable pkVal() { +return this.${currentTbConfig.uniKey}; +} +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-bak/entityMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-bak/entityMul.vm new file mode 100644 index 0000000..ab3938e --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-bak/entityMul.vm @@ -0,0 +1,29 @@ +package ${projectOrAuthor.packageName}.entity; +import java.util.*; +/** +* ${dbTableConfig.tableDesc}实体类 +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Data +@ApiModel("${dbTableConfig.tableDesc}") +@TableName(value = "${dbTableConfig.originTableName}") +public class ${dbTableConfig.multiTableNameCase}{ +#foreach($mtcItem in $multiTableConfig) + #foreach($item in $mtcItem.tableFieldArr) + #if($item.field=="createTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.INSERT) + private ${item.type} $item.field; + #elseif($item.field=="updateTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private ${item.type} $item.field; + #else + @ApiModelProperty(value = "$item.desc") + private ${item.type} $item.field; + #end + #end +#end +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-bak/entityVo.vm b/velocity-tmp-dir/back-vms/mybatis-plus-bak/entityVo.vm new file mode 100644 index 0000000..b1e98e1 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-bak/entityVo.vm @@ -0,0 +1,19 @@ +package ${projectOrAuthor.packageName}.entity; +import java.util.*; +/** +* ${dbTableConfig.multiTableDesc}实体类 +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Data +@ApiModel("${dbTableConfig.multiTableDesc}") +public class ${dbTableConfig.multiTableNameCase}Vo { +#foreach($mtcItem in $multiTableConfig) + #foreach( $tfItem in $mtcItem.tableFormArr) + @ApiModelProperty(value = "$tfItem.desc") + private ${tfItem.type} $tfItem.field; + #end +#end + +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-bak/mapper.vm b/velocity-tmp-dir/back-vms/mybatis-plus-bak/mapper.vm new file mode 100644 index 0000000..b7b7f94 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-bak/mapper.vm @@ -0,0 +1,10 @@ +package ${projectOrAuthor.packageName}.mapper; +/** +* ${currentTbConfig.tableDesc}Mapper +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +public interface ${currentTbConfig.tableNameCase}Mapper extends BaseMapper< ${currentTbConfig.tableNameCase} > { + +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-bak/mapperMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-bak/mapperMul.vm new file mode 100644 index 0000000..689cc2b --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-bak/mapperMul.vm @@ -0,0 +1,16 @@ +#set($firstTbConfig=$multiTableConfig[0]) +package ${projectOrAuthor.packageName}.mapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import java.util.*; +/** +* ${dbTableConfig.multiTableDesc}Mapper +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +public interface ${dbTableConfig.multiTableNameCase}Mapper { +Page< Map > select${dbTableConfig.multiTableNameCase}(Page< Map > pagination,@Param("params") Map params); + +Map selectByKey(@Param("${firstTbConfig.associationKey}") String ${firstTbConfig.associationKey}); +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-bak/serviceMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-bak/serviceMul.vm new file mode 100644 index 0000000..71ccf12 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-bak/serviceMul.vm @@ -0,0 +1,57 @@ +package ${projectOrAuthor.packageName}.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.util.*; +import com.alibaba.fastjson.JSON; +/** +* ${dbTableConfig.multiTableDesc}Service +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Service +public class ${dbTableConfig.multiTableNameCase}Service { + +@Resource +private ${dbTableConfig.multiTableNameCase}Mapper ${dbTableConfig.multiTableName}Mapper; + +#foreach( $mtcItem in $multiTableConfig) +@Resource +private ${mtcItem.tableNameCase}Mapper ${mtcItem.tableName}Mapper; +#end + +public Page< Map > select${dbTableConfig.multiTableNameCase}(SelfCommonParams commonParams, Map repairVo) { + return ${dbTableConfig.multiTableName}Mapper.select${dbTableConfig.multiTableNameCase}(new Page< Map >(commonParams.getPageNum(), commonParams.getPageSize()), repairVo); +} + +public Map selectByKey(String ${dbTableConfig.multiTableName}) { + return ${dbTableConfig.multiTableName}Mapper.selectByKey(${dbTableConfig.multiTableName}); +} + +@Transactional +public void insert(${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { + #foreach( $mtcItem in $multiTableConfig) + this.${mtcItem.tableName}Mapper.insert(JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}), ${mtcItem.tableNameCase}.class)); + #end +} + +@Transactional +public void updateByKey(${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +#foreach( $mtcItem in $multiTableConfig) + //${mtcItem.tableDesc} + ${mtcItem.tableNameCase} ${mtcItem.tableName} = JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}), ${mtcItem.tableNameCase}.class); + QueryWrapper<${mtcItem.tableNameCase}> ${mtcItem.tableName}Wrapper = new QueryWrapper<>(); + ${mtcItem.tableName}Wrapper.eq("sn", ${dbTableConfig.multiTableName}.getSn()); + this.${mtcItem.tableName}Mapper.update(${mtcItem.tableName}, ${mtcItem.tableName}Wrapper); +#end +} + +@Transactional +public void deleteByKey(${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { + #foreach( $mtcItem in $multiTableConfig) + //${mtcItem.tableName} + QueryWrapper<${mtcItem.tableNameCase}> ${mtcItem.tableName}Wrapper = new QueryWrapper<>(); + ${mtcItem.tableName}Wrapper.eq("${dbTableConfig.orgAssociationKey}", ${dbTableConfig.associationKey}); + this.${mtcItem.tableName}Mapper.delete(${mtcItem.tableName}Wrapper); + #end + } +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-bak/utils.vm b/velocity-tmp-dir/back-vms/mybatis-plus-bak/utils.vm new file mode 100644 index 0000000..758add7 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-bak/utils.vm @@ -0,0 +1,8 @@ +#macro(getOriginField) + #foreach($fItem in $multiTableConfig) + #foreach($tableShowArrItem in ${fItem.tableShowArr})${fItem.tableName}.${tableShowArrItem.originField},#end + #end +#end +#set($originFieldString="#getOriginField()") +#set($lenth=$originFieldString.length() - 1) +#set($xmlSelectString=$originFieldString.substring(0,$lenth)) diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-bak/xmlMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-bak/xmlMul.vm new file mode 100644 index 0000000..c9c3353 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-bak/xmlMul.vm @@ -0,0 +1,60 @@ +#parse("utils.vm") +#set($firstTbConfig=$multiTableConfig[0]) + + + + + #foreach($fItem in $multiTableConfig) + #foreach($tableShowArrItem in ${fItem.tableShowArr}) + + #end + #end + + + ${xmlSelectString} + + + + + \ No newline at end of file diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/controllerMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/controllerMul.vm new file mode 100644 index 0000000..70e3008 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/controllerMul.vm @@ -0,0 +1,75 @@ +package ${projectOrAuthor.packageName}.controller; +import java.util.Map; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +/** +* ${dbTableConfig.multiTableDesc}Controller +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Api(tags = "维修信息") +@RestController +@RequestMapping("${dbTableConfig.multiTableName}") +public class ${dbTableConfig.multiTableNameCase}Controller { +@Resource +private ${dbTableConfig.multiTableNameCase}Service ${dbTableConfig.multiTableName}Service; + +@ApiOperation(value = "分页查询${dbTableConfig.multiTableDesc}") +@GetMapping("select${dbTableConfig.multiTableNameCase}") +public Page< Map > select${dbTableConfig.multiTableNameCase}(SelfCommonParams commonParams, ${dbTableConfig.multiTableNameCase}Vo ${dbTableConfig.multiTableName}Vo) { +Map ${dbTableConfig.multiTableName}Map = JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}Vo), Map.class); +return ${dbTableConfig.multiTableName}Service.select${dbTableConfig.multiTableNameCase}(commonParams, ${dbTableConfig.multiTableName}Map); +} + +/** +* 新增数据 +* +* @param ${dbTableConfig.multiTableName} 实体对象 +* @return 新增结果 +*/ +@ApiOperation(value = "新增${dbTableConfig.multiTableDesc}") +@PostMapping("insert") +public ResResult insert(@RequestBody ${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +this.${dbTableConfig.multiTableName}Service.insert(${dbTableConfig.multiTableName}); +return new ResResult().success(); +} + + +/** +* 通过主键查询单条数据 +* +* @param ${dbTableConfig.associationKey} 主键 +* @return 单条数据 +*/ +@GetMapping("selectByKey") +@ApiOperation(value = "通过联合key查询详情") +public ResResult selectByKey(@RequestParam("${dbTableConfig.associationKey}") ${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { +return new ResResult().success(${dbTableConfig.multiTableName}Service.selectByKey(${dbTableConfig.associationKey})); +} + +/** +* 修改数据 +* +* @param ${dbTableConfig.multiTableName} 实体对象 +* @return 修改结果 +*/ +@ApiOperation(value = "根据${dbTableConfig.associationKey}修改数据") +@PutMapping("updateByKey") +public ResResult updateByKey(@RequestBody ${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +this.${dbTableConfig.multiTableName}Service.updateByKey(${dbTableConfig.multiTableName}); +return new ResResult().success(); +} + + +/** +* 删除项根据主键key +* @param ${dbTableConfig.associationKey} +* @return +*/ +@ApiOperation(value = "根据联合key删除数据") +@DeleteMapping("deleteByKey") +public ResResult deleteByKey(@RequestParam("${dbTableConfig.associationKey}") ${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { +this.${dbTableConfig.multiTableName}Service.deleteByKey(${dbTableConfig.associationKey}); +return new ResResult().success(); +} +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/entity.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/entity.vm new file mode 100644 index 0000000..197fdbe --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/entity.vm @@ -0,0 +1,37 @@ +package ${projectOrAuthor.packageName}.entity; +import java.util.*; +/** +* ${currentTbConfig.tableDesc}实体类 +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Data +@ApiModel("${currentTbConfig.tableDesc}") +@TableName(value = "${currentTbConfig.originTableName}") +public class ${currentTbConfig.tableNameCase} extends Model< ${currentTbConfig.tableNameCase} > { +#foreach($item in $dbTableConfig.tableFieldArr) + #if($item.field=="createTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.INSERT) + private ${item.type} $item.field; + #elseif($item.field=="updateTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private ${item.type} $item.field; + #else + @ApiModelProperty(value = "$item.desc") + private ${item.type} $item.field; + #end +#end + +/** +* 获取主键值 +* +* @return 主键值 +*/ +@Override +protected Serializable pkVal() { +return this.${currentTbConfig.uniKey}; +} +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/entityMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/entityMul.vm new file mode 100644 index 0000000..ab3938e --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/entityMul.vm @@ -0,0 +1,29 @@ +package ${projectOrAuthor.packageName}.entity; +import java.util.*; +/** +* ${dbTableConfig.tableDesc}实体类 +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Data +@ApiModel("${dbTableConfig.tableDesc}") +@TableName(value = "${dbTableConfig.originTableName}") +public class ${dbTableConfig.multiTableNameCase}{ +#foreach($mtcItem in $multiTableConfig) + #foreach($item in $mtcItem.tableFieldArr) + #if($item.field=="createTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.INSERT) + private ${item.type} $item.field; + #elseif($item.field=="updateTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private ${item.type} $item.field; + #else + @ApiModelProperty(value = "$item.desc") + private ${item.type} $item.field; + #end + #end +#end +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/entityVo.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/entityVo.vm new file mode 100644 index 0000000..b1e98e1 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/entityVo.vm @@ -0,0 +1,19 @@ +package ${projectOrAuthor.packageName}.entity; +import java.util.*; +/** +* ${dbTableConfig.multiTableDesc}实体类 +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Data +@ApiModel("${dbTableConfig.multiTableDesc}") +public class ${dbTableConfig.multiTableNameCase}Vo { +#foreach($mtcItem in $multiTableConfig) + #foreach( $tfItem in $mtcItem.tableFormArr) + @ApiModelProperty(value = "$tfItem.desc") + private ${tfItem.type} $tfItem.field; + #end +#end + +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/mapper.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/mapper.vm new file mode 100644 index 0000000..b7b7f94 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/mapper.vm @@ -0,0 +1,10 @@ +package ${projectOrAuthor.packageName}.mapper; +/** +* ${currentTbConfig.tableDesc}Mapper +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +public interface ${currentTbConfig.tableNameCase}Mapper extends BaseMapper< ${currentTbConfig.tableNameCase} > { + +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/mapperMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/mapperMul.vm new file mode 100644 index 0000000..689cc2b --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/mapperMul.vm @@ -0,0 +1,16 @@ +#set($firstTbConfig=$multiTableConfig[0]) +package ${projectOrAuthor.packageName}.mapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import java.util.*; +/** +* ${dbTableConfig.multiTableDesc}Mapper +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +public interface ${dbTableConfig.multiTableNameCase}Mapper { +Page< Map > select${dbTableConfig.multiTableNameCase}(Page< Map > pagination,@Param("params") Map params); + +Map selectByKey(@Param("${firstTbConfig.associationKey}") String ${firstTbConfig.associationKey}); +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/serviceMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/serviceMul.vm new file mode 100644 index 0000000..71ccf12 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/serviceMul.vm @@ -0,0 +1,57 @@ +package ${projectOrAuthor.packageName}.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.util.*; +import com.alibaba.fastjson.JSON; +/** +* ${dbTableConfig.multiTableDesc}Service +* +* @author ${projectOrAuthor.author} +* @since ${projectOrAuthor.dataTime} +*/ +@Service +public class ${dbTableConfig.multiTableNameCase}Service { + +@Resource +private ${dbTableConfig.multiTableNameCase}Mapper ${dbTableConfig.multiTableName}Mapper; + +#foreach( $mtcItem in $multiTableConfig) +@Resource +private ${mtcItem.tableNameCase}Mapper ${mtcItem.tableName}Mapper; +#end + +public Page< Map > select${dbTableConfig.multiTableNameCase}(SelfCommonParams commonParams, Map repairVo) { + return ${dbTableConfig.multiTableName}Mapper.select${dbTableConfig.multiTableNameCase}(new Page< Map >(commonParams.getPageNum(), commonParams.getPageSize()), repairVo); +} + +public Map selectByKey(String ${dbTableConfig.multiTableName}) { + return ${dbTableConfig.multiTableName}Mapper.selectByKey(${dbTableConfig.multiTableName}); +} + +@Transactional +public void insert(${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { + #foreach( $mtcItem in $multiTableConfig) + this.${mtcItem.tableName}Mapper.insert(JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}), ${mtcItem.tableNameCase}.class)); + #end +} + +@Transactional +public void updateByKey(${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +#foreach( $mtcItem in $multiTableConfig) + //${mtcItem.tableDesc} + ${mtcItem.tableNameCase} ${mtcItem.tableName} = JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}), ${mtcItem.tableNameCase}.class); + QueryWrapper<${mtcItem.tableNameCase}> ${mtcItem.tableName}Wrapper = new QueryWrapper<>(); + ${mtcItem.tableName}Wrapper.eq("sn", ${dbTableConfig.multiTableName}.getSn()); + this.${mtcItem.tableName}Mapper.update(${mtcItem.tableName}, ${mtcItem.tableName}Wrapper); +#end +} + +@Transactional +public void deleteByKey(${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { + #foreach( $mtcItem in $multiTableConfig) + //${mtcItem.tableName} + QueryWrapper<${mtcItem.tableNameCase}> ${mtcItem.tableName}Wrapper = new QueryWrapper<>(); + ${mtcItem.tableName}Wrapper.eq("${dbTableConfig.orgAssociationKey}", ${dbTableConfig.associationKey}); + this.${mtcItem.tableName}Mapper.delete(${mtcItem.tableName}Wrapper); + #end + } +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/utils.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/utils.vm new file mode 100644 index 0000000..758add7 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/utils.vm @@ -0,0 +1,8 @@ +#macro(getOriginField) + #foreach($fItem in $multiTableConfig) + #foreach($tableShowArrItem in ${fItem.tableShowArr})${fItem.tableName}.${tableShowArrItem.originField},#end + #end +#end +#set($originFieldString="#getOriginField()") +#set($lenth=$originFieldString.length() - 1) +#set($xmlSelectString=$originFieldString.substring(0,$lenth)) diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/xmlMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/xmlMul.vm new file mode 100644 index 0000000..c9c3353 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi-bak/xmlMul.vm @@ -0,0 +1,60 @@ +#parse("utils.vm") +#set($firstTbConfig=$multiTableConfig[0]) + + + + + #foreach($fItem in $multiTableConfig) + #foreach($tableShowArrItem in ${fItem.tableShowArr}) + + #end + #end + + + ${xmlSelectString} + + + + + \ No newline at end of file diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/controllerMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/controllerMul.vm new file mode 100644 index 0000000..204c312 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/controllerMul.vm @@ -0,0 +1,75 @@ +package ${basicConfig.packageName}.controller; +import java.util.Map; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +/** +* ${dbTableConfig.multiTableDesc}Controller +* +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} +*/ +@Api(tags = "维修信息") +@RestController +@RequestMapping("${dbTableConfig.multiTableName}") +public class ${dbTableConfig.multiTableNameCase}Controller { +@Resource +private ${dbTableConfig.multiTableNameCase}Service ${dbTableConfig.multiTableName}Service; + +@ApiOperation(value = "分页查询${dbTableConfig.multiTableDesc}") +@GetMapping("select${dbTableConfig.multiTableNameCase}") +public Page< Map > select${dbTableConfig.multiTableNameCase}(SelfCommonParams commonParams, ${dbTableConfig.multiTableNameCase}Vo ${dbTableConfig.multiTableName}Vo) { +Map ${dbTableConfig.multiTableName}Map = JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}Vo), Map.class); +return ${dbTableConfig.multiTableName}Service.select${dbTableConfig.multiTableNameCase}(commonParams, ${dbTableConfig.multiTableName}Map); +} + +/** +* 新增数据 +* +* @param ${dbTableConfig.multiTableName} 实体对象 +* @return 新增结果 +*/ +@ApiOperation(value = "新增${dbTableConfig.multiTableDesc}") +@PostMapping("insert") +public ResResult insert(@RequestBody ${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +this.${dbTableConfig.multiTableName}Service.insert(${dbTableConfig.multiTableName}); +return new ResResult().success(); +} + + +/** +* 通过主键查询单条数据 +* +* @param ${dbTableConfig.associationKey} 主键 +* @return 单条数据 +*/ +@GetMapping("selectByKey") +@ApiOperation(value = "通过联合key查询详情") +public ResResult selectByKey(@RequestParam("${dbTableConfig.associationKey}") ${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { +return new ResResult().success(${dbTableConfig.multiTableName}Service.selectByKey(${dbTableConfig.associationKey})); +} + +/** +* 修改数据 +* +* @param ${dbTableConfig.multiTableName} 实体对象 +* @return 修改结果 +*/ +@ApiOperation(value = "根据${dbTableConfig.associationKey}修改数据") +@PutMapping("updateByKey") +public ResResult updateByKey(@RequestBody ${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +this.${dbTableConfig.multiTableName}Service.updateByKey(${dbTableConfig.multiTableName}); +return new ResResult().success(); +} + + +/** +* 删除项根据主键key +* @param ${dbTableConfig.associationKey} +* @return +*/ +@ApiOperation(value = "根据联合key删除数据") +@DeleteMapping("deleteByKey") +public ResResult deleteByKey(@RequestParam("${dbTableConfig.associationKey}") ${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { +this.${dbTableConfig.multiTableName}Service.deleteByKey(${dbTableConfig.associationKey}); +return new ResResult().success(); +} +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/entity.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/entity.vm new file mode 100644 index 0000000..d869718 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/entity.vm @@ -0,0 +1,37 @@ +package ${basicConfig.packageName}.entity; +import java.util.*; +/** +* ${currentTbConfig.tableDesc}实体类 +* +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} +*/ +@Data +@ApiModel("${currentTbConfig.tableDesc}") +@TableName(value = "${currentTbConfig.originTableName}") +public class ${currentTbConfig.tableNameCase} extends Model< ${currentTbConfig.tableNameCase} > { +#foreach($item in $dbTableConfig.tableFieldArr) + #if($item.field=="createTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.INSERT) + private ${item.type} $item.field; + #elseif($item.field=="updateTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private ${item.type} $item.field; + #else + @ApiModelProperty(value = "$item.desc") + private ${item.type} $item.field; + #end +#end + +/** +* 获取主键值 +* +* @return 主键值 +*/ +@Override +protected Serializable pkVal() { +return this.${currentTbConfig.uniKey}; +} +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/entityMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/entityMul.vm new file mode 100644 index 0000000..5928416 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/entityMul.vm @@ -0,0 +1,29 @@ +package ${basicConfig.packageName}.entity; +import java.util.*; +/** +* ${dbTableConfig.tableDesc}实体类 +* +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} +*/ +@Data +@ApiModel("${dbTableConfig.tableDesc}") +@TableName(value = "${dbTableConfig.originTableName}") +public class ${dbTableConfig.multiTableNameCase}{ +#foreach($mtcItem in $multiTableConfig) + #foreach($item in $mtcItem.tableFieldArr) + #if($item.field=="createTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.INSERT) + private ${item.type} $item.field; + #elseif($item.field=="updateTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private ${item.type} $item.field; + #else + @ApiModelProperty(value = "$item.desc") + private ${item.type} $item.field; + #end + #end +#end +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/entityVo.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/entityVo.vm new file mode 100644 index 0000000..4c7ac6f --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/entityVo.vm @@ -0,0 +1,19 @@ +package ${basicConfig.packageName}.entity; +import java.util.*; +/** +* ${dbTableConfig.multiTableDesc}实体类 +* +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} +*/ +@Data +@ApiModel("${dbTableConfig.multiTableDesc}") +public class ${dbTableConfig.multiTableNameCase}Vo { +#foreach($mtcItem in $multiTableConfig) + #foreach( $tfItem in $mtcItem.tableFormArr) + @ApiModelProperty(value = "$tfItem.desc") + private ${tfItem.type} $tfItem.field; + #end +#end + +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/mapper.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/mapper.vm new file mode 100644 index 0000000..8ff2500 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/mapper.vm @@ -0,0 +1,10 @@ +package ${basicConfig.packageName}.mapper; +/** +* ${currentTbConfig.tableDesc}Mapper +* +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} +*/ +public interface ${currentTbConfig.tableNameCase}Mapper extends BaseMapper< ${currentTbConfig.tableNameCase} > { + +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/mapperMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/mapperMul.vm new file mode 100644 index 0000000..35d5a16 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/mapperMul.vm @@ -0,0 +1,16 @@ +#set($firstTbConfig=$multiTableConfig[0]) +package ${basicConfig.packageName}.mapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import java.util.*; +/** +* ${dbTableConfig.multiTableDesc}Mapper +* +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} +*/ +public interface ${dbTableConfig.multiTableNameCase}Mapper { +Page< Map > select${dbTableConfig.multiTableNameCase}(Page< Map > pagination,@Param("params") Map params); + +Map selectByKey(@Param("${firstTbConfig.associationKey}") String ${firstTbConfig.associationKey}); +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/serviceMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/serviceMul.vm new file mode 100644 index 0000000..919c0a7 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/serviceMul.vm @@ -0,0 +1,57 @@ +package ${basicConfig.packageName}.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.util.*; +import com.alibaba.fastjson.JSON; +/** +* ${dbTableConfig.multiTableDesc}Service +* +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} +*/ +@Service +public class ${dbTableConfig.multiTableNameCase}Service { + +@Resource +private ${dbTableConfig.multiTableNameCase}Mapper ${dbTableConfig.multiTableName}Mapper; + +#foreach( $mtcItem in $multiTableConfig) +@Resource +private ${mtcItem.tableNameCase}Mapper ${mtcItem.tableName}Mapper; +#end + +public Page< Map > select${dbTableConfig.multiTableNameCase}(SelfCommonParams commonParams, Map repairVo) { +return ${dbTableConfig.multiTableName}Mapper.select${dbTableConfig.multiTableNameCase}(new Page< Map >(commonParams.getPageNum(), commonParams.getPageSize()), repairVo); +} + +public Map selectByKey(String ${dbTableConfig.multiTableName}) { +return ${dbTableConfig.multiTableName}Mapper.selectByKey(${dbTableConfig.multiTableName}); +} + +@Transactional +public void insert(${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +#foreach( $mtcItem in $multiTableConfig) +this.${mtcItem.tableName}Mapper.insert(JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}), ${mtcItem.tableNameCase}.class)); +#end +} + +@Transactional +public void updateByKey(${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +#foreach( $mtcItem in $multiTableConfig) +//${mtcItem.tableDesc} + ${mtcItem.tableNameCase} ${mtcItem.tableName} = JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}), ${mtcItem.tableNameCase}.class); +QueryWrapper<${mtcItem.tableNameCase}> ${mtcItem.tableName}Wrapper = new QueryWrapper<>(); + ${mtcItem.tableName}Wrapper.eq("sn", ${dbTableConfig.multiTableName}.getSn()); +this.${mtcItem.tableName}Mapper.update(${mtcItem.tableName}, ${mtcItem.tableName}Wrapper); +#end +} + +@Transactional +public void deleteByKey(${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { +#foreach( $mtcItem in $multiTableConfig) +//${mtcItem.tableName} +QueryWrapper<${mtcItem.tableNameCase}> ${mtcItem.tableName}Wrapper = new QueryWrapper<>(); + ${mtcItem.tableName}Wrapper.eq("${dbTableConfig.orgAssociationKey}", ${dbTableConfig.associationKey}); +this.${mtcItem.tableName}Mapper.delete(${mtcItem.tableName}Wrapper); +#end +} +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/utils.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/utils.vm new file mode 100644 index 0000000..758add7 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/utils.vm @@ -0,0 +1,8 @@ +#macro(getOriginField) + #foreach($fItem in $multiTableConfig) + #foreach($tableShowArrItem in ${fItem.tableShowArr})${fItem.tableName}.${tableShowArrItem.originField},#end + #end +#end +#set($originFieldString="#getOriginField()") +#set($lenth=$originFieldString.length() - 1) +#set($xmlSelectString=$originFieldString.substring(0,$lenth)) diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/xmlMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/xmlMul.vm new file mode 100644 index 0000000..3f35db2 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi-query/xmlMul.vm @@ -0,0 +1,60 @@ +#parse("utils.vm") +#set($firstTbConfig=$multiTableConfig[0]) + + + + + #foreach($fItem in $multiTableConfig) + #foreach($tableShowArrItem in ${fItem.tableShowArr}) + + #end + #end + + + ${xmlSelectString} + + + + + \ No newline at end of file diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/controllerMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/controllerMul.vm index 70e3008..9d136dc 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus-multi/controllerMul.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/controllerMul.vm @@ -1,13 +1,16 @@ -package ${projectOrAuthor.packageName}.controller; +#parse("utils.vm") +package ${basicConfig.packageName}.controller; import java.util.Map; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; /** * ${dbTableConfig.multiTableDesc}Controller * -* @author ${projectOrAuthor.author} -* @since ${projectOrAuthor.dataTime} +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} */ -@Api(tags = "维修信息") +@Api(tags = "${dbTableConfig.multiTableDesc}") @RestController @RequestMapping("${dbTableConfig.multiTableName}") public class ${dbTableConfig.multiTableNameCase}Controller { @@ -15,10 +18,10 @@ public class ${dbTableConfig.multiTableNameCase}Controller { private ${dbTableConfig.multiTableNameCase}Service ${dbTableConfig.multiTableName}Service; @ApiOperation(value = "分页查询${dbTableConfig.multiTableDesc}") + @GetMapping("select${dbTableConfig.multiTableNameCase}") -public Page< Map > select${dbTableConfig.multiTableNameCase}(SelfCommonParams commonParams, ${dbTableConfig.multiTableNameCase}Vo ${dbTableConfig.multiTableName}Vo) { -Map ${dbTableConfig.multiTableName}Map = JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}Vo), Map.class); -return ${dbTableConfig.multiTableName}Service.select${dbTableConfig.multiTableNameCase}(commonParams, ${dbTableConfig.multiTableName}Map); +public Page< Map > select${dbTableConfig.multiTableNameCase}(@Validated ${dbTableConfig.multiTableNameCase}Vo ${dbTableConfig.multiTableName}Vo,SelfCommonParams commonParams) { +return ${dbTableConfig.multiTableName}Service.select${dbTableConfig.multiTableNameCase}(commonParams, ${dbTableConfig.multiTableName}Vo); } /** @@ -29,7 +32,7 @@ return ${dbTableConfig.multiTableName}Service.select${dbTableConfig.multiTableNa */ @ApiOperation(value = "新增${dbTableConfig.multiTableDesc}") @PostMapping("insert") -public ResResult insert(@RequestBody ${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +public ResResult insert(@Validated @RequestBody ${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { this.${dbTableConfig.multiTableName}Service.insert(${dbTableConfig.multiTableName}); return new ResResult().success(); } @@ -55,7 +58,7 @@ return new ResResult().success(${dbTableConfig.multiTableName}Service.selectByKe */ @ApiOperation(value = "根据${dbTableConfig.associationKey}修改数据") @PutMapping("updateByKey") -public ResResult updateByKey(@RequestBody ${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { +public ResResult updateByKey(@Validated @RequestBody ${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { this.${dbTableConfig.multiTableName}Service.updateByKey(${dbTableConfig.multiTableName}); return new ResResult().success(); } diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/entity.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/entity.vm index 197fdbe..879385a 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus-multi/entity.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/entity.vm @@ -1,16 +1,19 @@ -package ${projectOrAuthor.packageName}.entity; +#parse("utils.vm") +package ${basicConfig.packageName}.entity; import java.util.*; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; /** * ${currentTbConfig.tableDesc}实体类 * -* @author ${projectOrAuthor.author} -* @since ${projectOrAuthor.dataTime} +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} */ @Data @ApiModel("${currentTbConfig.tableDesc}") @TableName(value = "${currentTbConfig.originTableName}") public class ${currentTbConfig.tableNameCase} extends Model< ${currentTbConfig.tableNameCase} > { -#foreach($item in $dbTableConfig.tableFieldArr) +#foreach($item in $tableFormArr) #if($item.field=="createTime") @ApiModelProperty(value = "$item.desc",hidden = true) @TableField(fill = FieldFill.INSERT) @@ -21,6 +24,7 @@ public class ${currentTbConfig.tableNameCase} extends Model< ${currentTbConfig.t private ${item.type} $item.field; #else @ApiModelProperty(value = "$item.desc") + #getValid($item) private ${item.type} $item.field; #end #end diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/entityMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/entityMul.vm index ab3938e..bff9245 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus-multi/entityMul.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/entityMul.vm @@ -1,29 +1,31 @@ -package ${projectOrAuthor.packageName}.entity; +#parse("utils.vm") +package ${basicConfig.packageName}.entity; import java.util.*; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; + /** * ${dbTableConfig.tableDesc}实体类 * -* @author ${projectOrAuthor.author} -* @since ${projectOrAuthor.dataTime} +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} */ @Data -@ApiModel("${dbTableConfig.tableDesc}") -@TableName(value = "${dbTableConfig.originTableName}") +@ApiModel("${dbTableConfig.multiTableDesc}") public class ${dbTableConfig.multiTableNameCase}{ -#foreach($mtcItem in $multiTableConfig) - #foreach($item in $mtcItem.tableFieldArr) - #if($item.field=="createTime") - @ApiModelProperty(value = "$item.desc",hidden = true) - @TableField(fill = FieldFill.INSERT) - private ${item.type} $item.field; - #elseif($item.field=="updateTime") - @ApiModelProperty(value = "$item.desc",hidden = true) - @TableField(fill = FieldFill.UPDATE) - private ${item.type} $item.field; - #else - @ApiModelProperty(value = "$item.desc") - private ${item.type} $item.field; - #end +#foreach($item in $formConfig) + #if($item.field=="createTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.INSERT) + private ${item.type} $item.field; + #elseif($item.field=="updateTime") + @ApiModelProperty(value = "$item.desc",hidden = true) + @TableField(fill = FieldFill.UPDATE) + private ${item.type} $item.field; + #else + @ApiModelProperty(value = "$item.desc") + #getValid($item) + private ${item.type} $item.frontField; #end #end } diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/entityVo.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/entityVo.vm index b1e98e1..114e298 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus-multi/entityVo.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/entityVo.vm @@ -1,19 +1,21 @@ -package ${projectOrAuthor.packageName}.entity; +#parse("utils.vm") +package ${basicConfig.packageName}.vo; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; import java.util.*; /** * ${dbTableConfig.multiTableDesc}实体类 * -* @author ${projectOrAuthor.author} -* @since ${projectOrAuthor.dataTime} +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} */ @Data @ApiModel("${dbTableConfig.multiTableDesc}") public class ${dbTableConfig.multiTableNameCase}Vo { -#foreach($mtcItem in $multiTableConfig) - #foreach( $tfItem in $mtcItem.tableFormArr) - @ApiModelProperty(value = "$tfItem.desc") - private ${tfItem.type} $tfItem.field; - #end +#foreach( $qItem in $queryConfig) +@ApiModelProperty(value = "$qItem.desc") + #getValid($qItem) +private ${qItem.type} $qItem.frontField; #end } diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/mapper.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/mapper.vm index b7b7f94..8ff2500 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus-multi/mapper.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/mapper.vm @@ -1,9 +1,9 @@ -package ${projectOrAuthor.packageName}.mapper; +package ${basicConfig.packageName}.mapper; /** * ${currentTbConfig.tableDesc}Mapper * -* @author ${projectOrAuthor.author} -* @since ${projectOrAuthor.dataTime} +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} */ public interface ${currentTbConfig.tableNameCase}Mapper extends BaseMapper< ${currentTbConfig.tableNameCase} > { diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/mapperMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/mapperMul.vm index 689cc2b..05ee442 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus-multi/mapperMul.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/mapperMul.vm @@ -1,16 +1,16 @@ #set($firstTbConfig=$multiTableConfig[0]) -package ${projectOrAuthor.packageName}.mapper; +package ${basicConfig.packageName}.mapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Param; import java.util.*; /** * ${dbTableConfig.multiTableDesc}Mapper * -* @author ${projectOrAuthor.author} -* @since ${projectOrAuthor.dataTime} +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} */ public interface ${dbTableConfig.multiTableNameCase}Mapper { -Page< Map > select${dbTableConfig.multiTableNameCase}(Page< Map > pagination,@Param("params") Map params); +Page< Map > select${dbTableConfig.multiTableNameCase}(Page< Map > pagination,@Param("params") ${dbTableConfig.multiTableNameCase}Vo params); -Map selectByKey(@Param("${firstTbConfig.associationKey}") String ${firstTbConfig.associationKey}); +Map selectByKey(@Param("${firstTbConfig.associationKey}") ${firstTbConfig.associationKeyType} ${firstTbConfig.associationKey}); } diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/serviceMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/serviceMul.vm index 71ccf12..28b9e8e 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus-multi/serviceMul.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/serviceMul.vm @@ -1,57 +1,93 @@ -package ${projectOrAuthor.packageName}.service; +package ${basicConfig.packageName}.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import java.util.*; import com.alibaba.fastjson.JSON; + +#if($multiTableConfig.size()==2) + #set($fTbCfg=$multiTableConfig[0]) + #set($sTbCfg=$multiTableConfig[1]) +#end + +#if($multiTableConfig.size()==3) + #set($fTbCfg=$multiTableConfig[0]) + #set($sTbCfg=$multiTableConfig[1]) + #set($tTbCfg=$multiTableConfig[2]) +#end + + /** * ${dbTableConfig.multiTableDesc}Service * -* @author ${projectOrAuthor.author} -* @since ${projectOrAuthor.dataTime} +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} */ @Service public class ${dbTableConfig.multiTableNameCase}Service { - @Resource private ${dbTableConfig.multiTableNameCase}Mapper ${dbTableConfig.multiTableName}Mapper; -#foreach( $mtcItem in $multiTableConfig) +#foreach($mtcItem in $multiTableConfig) @Resource private ${mtcItem.tableNameCase}Mapper ${mtcItem.tableName}Mapper; #end -public Page< Map > select${dbTableConfig.multiTableNameCase}(SelfCommonParams commonParams, Map repairVo) { - return ${dbTableConfig.multiTableName}Mapper.select${dbTableConfig.multiTableNameCase}(new Page< Map >(commonParams.getPageNum(), commonParams.getPageSize()), repairVo); +public Page< Map > select${dbTableConfig.multiTableNameCase}(SelfCommonParams commonParams, ${dbTableConfig.multiTableNameCase}Vo ${dbTableConfig.multiTableName}Vo) { +return ${dbTableConfig.multiTableName}Mapper.select${dbTableConfig.multiTableNameCase}(new Page< Map >(commonParams.getPageNum(), commonParams.getPageSize()), ${dbTableConfig.multiTableName}Vo); } -public Map selectByKey(String ${dbTableConfig.multiTableName}) { - return ${dbTableConfig.multiTableName}Mapper.selectByKey(${dbTableConfig.multiTableName}); +public Map selectByKey(${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { +return ${dbTableConfig.multiTableName}Mapper.selectByKey(${dbTableConfig.associationKey}); } @Transactional public void insert(${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { - #foreach( $mtcItem in $multiTableConfig) - this.${mtcItem.tableName}Mapper.insert(JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}), ${mtcItem.tableNameCase}.class)); +//${fTbCfg.tableDesc} +${fTbCfg.tableNameCase} ${fTbCfg.tableName} = new ${fTbCfg.tableNameCase}(); +#foreach( $lItem in ${fTbCfg.tableFormArr}) + #if($lItem.isNotShowSwagger=="false") + ${fTbCfg.tableName}.set${lItem.fieldCase}(${dbTableConfig.multiTableName}.get${lItem.frontFieldCase}()); #end +#end +this.${fTbCfg.tableName}Mapper.insert(${fTbCfg.tableName}); + +//${sTbCfg.tableDesc} +${sTbCfg.tableNameCase} ${sTbCfg.tableName} = new ${sTbCfg.tableNameCase}(); +#foreach( $lItem in ${sTbCfg.tableFormArr}) + ${sTbCfg.tableName}.set${lItem.fieldCase}(${dbTableConfig.multiTableName}.get${lItem.frontFieldCase}()); +#end +this.${sTbCfg.tableName}Mapper.insert(${sTbCfg.tableName}); } @Transactional public void updateByKey(${dbTableConfig.multiTableNameCase} ${dbTableConfig.multiTableName}) { -#foreach( $mtcItem in $multiTableConfig) - //${mtcItem.tableDesc} - ${mtcItem.tableNameCase} ${mtcItem.tableName} = JSON.parseObject(JSON.toJSONString(${dbTableConfig.multiTableName}), ${mtcItem.tableNameCase}.class); - QueryWrapper<${mtcItem.tableNameCase}> ${mtcItem.tableName}Wrapper = new QueryWrapper<>(); - ${mtcItem.tableName}Wrapper.eq("sn", ${dbTableConfig.multiTableName}.getSn()); - this.${mtcItem.tableName}Mapper.update(${mtcItem.tableName}, ${mtcItem.tableName}Wrapper); +//${fTbCfg.tableDesc} +${fTbCfg.tableNameCase} ${fTbCfg.tableName} = new ${fTbCfg.tableNameCase}(); +#foreach( $lItem in ${fTbCfg.tableFormArr}) + #if($lItem.isNotShowSwagger=="false") + ${fTbCfg.tableName}.set${lItem.fieldCase}(${dbTableConfig.multiTableName}.get${lItem.frontFieldCase}()); + #end +#end +this.${fTbCfg.tableName}Mapper.updateById(${fTbCfg.tableName}); + +//${sTbCfg.tableDesc} +${sTbCfg.tableNameCase} ${sTbCfg.tableName} = new ${sTbCfg.tableNameCase}(); +#foreach( $lItem in ${sTbCfg.tableFormArr}) + ${sTbCfg.tableName}.set${lItem.fieldCase}(${dbTableConfig.multiTableName}.get${lItem.frontFieldCase}()); #end +this.${sTbCfg.tableName}Mapper.updateById(${sTbCfg.tableName}); } @Transactional public void deleteByKey(${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { - #foreach( $mtcItem in $multiTableConfig) - //${mtcItem.tableName} - QueryWrapper<${mtcItem.tableNameCase}> ${mtcItem.tableName}Wrapper = new QueryWrapper<>(); - ${mtcItem.tableName}Wrapper.eq("${dbTableConfig.orgAssociationKey}", ${dbTableConfig.associationKey}); - this.${mtcItem.tableName}Mapper.delete(${mtcItem.tableName}Wrapper); - #end - } +//${fTbCfg.tableName} +QueryWrapper<${fTbCfg.tableNameCase}> ${fTbCfg.tableName}Wrapper = new QueryWrapper<>(); +${fTbCfg.tableName}Wrapper.eq("${dbTableConfig.orgAssociationKey[0]}", ${dbTableConfig.associationKey}); +this.${fTbCfg.tableName}Mapper.delete(${fTbCfg.tableName}Wrapper); + + +//${sTbCfg.tableName} +QueryWrapper<${sTbCfg.tableNameCase}> ${sTbCfg.tableName}Wrapper = new QueryWrapper<>(); +${sTbCfg.tableName}Wrapper.eq("${dbTableConfig.orgAssociationKey[0]}", ${dbTableConfig.associationKey}); +this.${sTbCfg.tableName}Mapper.delete(${sTbCfg.tableName}Wrapper); +} } diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/utils.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/utils.vm index 758add7..e580bbb 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus-multi/utils.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/utils.vm @@ -1,8 +1,57 @@ #macro(getOriginField) - #foreach($fItem in $multiTableConfig) - #foreach($tableShowArrItem in ${fItem.tableShowArr})${fItem.tableName}.${tableShowArrItem.originField},#end - #end + #foreach($fItem in ${tableConfig})${fItem.tableName}.${fItem.originField} as ${fItem.frontField},#end #end #set($originFieldString="#getOriginField()") #set($lenth=$originFieldString.length() - 1) #set($xmlSelectString=$originFieldString.substring(0,$lenth)) + +#macro(getValid $item) + #if($item.isNeedInput=="true") + #if(${item.type}=="Long") + @NotNull(message = "userId不能为空") + #elseif(${item.type}=="Integer") + @NotNull(message = "userId不能为空") + #elseif(${item.type}=="String") + @NotBlank(message = "userId不能为空") + #elseif(${item.type}=="List") + @NotEmpty(message = "${item.field}不能为空") + #end + #end + #if($item.rule=="upZeroInt") + @Pattern(regexp = "^\+?[1-9]\d*$",message = "${item.field}输入有误-正整数") + #elseif($item.rule=="zeroInt") + @Pattern(regexp = "^\+?[0-9]\d*$",message = "${item.field}输入有误-正整数包括0") + #elseif($item.rule=="phone") + @Pattern(regexp = "^0?1[0-9]{10}$",message = "${item.field}输入有误-手机号") + #elseif($item.rule=="money") + @Pattern(regexp = "((^[1-9]\d*)|^0)(\.\d{0,2}){0,1}$",message = "${item.field}输入有误-金额") + #elseif($item.rule=="email") + @Pattern(regexp = "(^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4}))$",message = "${item.field}输入有误-邮箱") + #elseif($item.rule=="idCard") + @Pattern(regexp = "(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)",message = "${item.field}输入有误-身份证") + #end +#end + + +#macro(getQueryField) + #foreach($item in $queryConfig) + #if($item.isNotShowSwagger=="true")@ApiIgnore()#end #getValid($item) String $item.field, + #end +#end + + + + +#macro(getSwaggerParam) +@ApiImplicitParams({ + #foreach($item in $queryConfig) + #if($item.isNotShowSwagger=="false") + #if($item.isNeedInput=="true") + @ApiImplicitParam(name = "$item.field", value = "$item.desc",paramType = "query", required = true), + #else + @ApiImplicitParam(name = "$item.field", value = "$item.desc",paramType = "query"), + #end + #end + #end +}) +#end diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/xmlMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/xmlMul.vm index c9c3353..9d8db98 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus-multi/xmlMul.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/xmlMul.vm @@ -1,14 +1,22 @@ #parse("utils.vm") -#set($firstTbConfig=$multiTableConfig[0]) +#if($multiTableConfig.size()==2) + #set($fTbCfg=$multiTableConfig[0]) + #set($sTbCfg=$multiTableConfig[1]) +#end + +#if($multiTableConfig.size()==3) + #set($fTbCfg=$multiTableConfig[0]) + #set($sTbCfg=$multiTableConfig[1]) + #set($tTbCfg=$multiTableConfig[2]) +#end + - + - #foreach($fItem in $multiTableConfig) - #foreach($tableShowArrItem in ${fItem.tableShowArr}) - - #end - #end + ## #foreach($tableShowArrItem in ${fItem.tableShowArr}) + ## + ## #end ${xmlSelectString} @@ -16,26 +24,33 @@ select - FROM ${firstTbConfig.originTableName} ${firstTbConfig.tableName} - #foreach($fItem in $multiTableConfig.subList(1,$multiTableConfig.size())) - LEFT JOIN ${fItem.originTableName} ${fItem.tableName} - ON ${firstTbConfig.tableName}.${firstTbConfig.orgAssociationKey}=${fItem.tableName}.${fItem.associationKey} + FROM ${fTbCfg.originTableName} ${fTbCfg.originTableName} + #if($multiTableConfig.size()==2) + LEFT JOIN ${sTbCfg.originTableName} ${sTbCfg.originTableName} + ON ${fTbCfg.originTableName}.${fTbCfg.orgAssociationKey[0]}= + ${sTbCfg.originTableName}.${sTbCfg.orgAssociationKey[0]} + #end + #if($multiTableConfig.size()==3) + LEFT JOIN ${sTbCfg.originTableName} ${sTbCfg.originTableName} + ON ${fTbCfg.originTableName}.${fTbCfg.orgAssociationKey[0]}= + ${sTbCfg.originTableName}.${sTbCfg.orgAssociationKey[0]} + LEFT JOIN ${tTbCfg.originTableName} ${tTbCfg.originTableName} + ON ${sTbCfg.originTableName}.${sTbCfg.orgAssociationKey[1]}= + ${tTbCfg.originTableName}.${tTbCfg.orgAssociationKey[0]} #end - + #set($likePre='%${') - #set($likeParam="$likePre${firstTbConfig.associationKey}}%") - ${firstTbConfig.tableName}.${firstTbConfig.orgAssociationKey} LIKE '$likeParam' + #set($likeParam="$likePre${fTbCfg.associationKey}}%") + ${fTbCfg.originTableName}.${fTbCfg.associationKey} LIKE '$likeParam' diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm b/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm index fca7b65..924db85 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm @@ -8,14 +8,22 @@ #macro(getValid $item) #if($item.isNeedInput=="true") - @NotEmpty(message = "${item.field}不能为空") + #if(${item.type}=="Long") + @NotNull(message = "userId不能为空") + #elseif(${item.type}=="Integer") + @NotNull(message = "userId不能为空") + #elseif(${item.type}=="String") + @NotBlank(message = "userId不能为空") + #elseif(${item.type}=="List") + @NotEmpty(message = "${item.field}不能为空") + #end #end #if($item.rule=="upZeroInt") @Pattern(regexp = "^\+?[1-9]\d*$",message = "${item.field}输入有误-正整数") #elseif($item.rule=="zeroInt") @Pattern(regexp = "^\+?[0-9]\d*$",message = "${item.field}输入有误-正整数包括0") #elseif($item.rule=="phone") - @Pattern(regexp = "^0?1[0-9]{10}$",message = "${item.field}输入有误-手机号}") + @Pattern(regexp = "^0?1[0-9]{10}$",message = "${item.field}输入有误-手机号") #elseif($item.rule=="money") @Pattern(regexp = "((^[1-9]\d*)|^0)(\.\d{0,2}){0,1}$",message = "${item.field}输入有误-金额") #elseif($item.rule=="email") diff --git a/velocity-tmp-dir/json-data/mybatis-plus/basicData.json b/velocity-tmp-dir/json-data/mybatis-plus/basicData.json index 75a3c2b..59c33c5 100644 --- a/velocity-tmp-dir/json-data/mybatis-plus/basicData.json +++ b/velocity-tmp-dir/json-data/mybatis-plus/basicData.json @@ -4,14 +4,15 @@ "packageName": "top.kuanghua.integrationfront", "basicClassName": "role", "basicClassDesc": "角色相关", - "dataTime": "2022-10-07 16:33:13" + "dataTime": "2022-10-07 16:33:13", + "isMultiTable": true }, "multiTableConfig": [ { - "tableName": "role", - "originTableName": "t_role", - "tableDesc": "角色", - "tableNameCase": "Role", + "tableName": "user", + "originTableName": "t_user", + "tableDesc": "用户", + "tableNameCase": "User", "uniKey": "id", "tableFieldArr": [ { @@ -19,50 +20,50 @@ "isNullable": "NO", "dataType": "bigint", "extra": "auto_increment", - "columnComment": "角色ID", + "columnComment": "用户ID", "columnKey": "PRI", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "id", "field": "id", - "desc": "角色ID", + "desc": "用户ID", "fieldCase": "Id", "originField": "id", "tbName": "id", "type": "Long" }, { - "columnType": "bigint(20)", + "columnType": "tinyint(1)", "isNullable": "YES", - "dataType": "bigint", + "dataType": "tinyint", "extra": "", - "columnComment": "所属父级角色ID", - "columnKey": "MUL", + "columnComment": "用户状态:0=正常,1=禁用", + "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "parent_id", - "field": "parentId", - "desc": "所属父级角色ID", - "fieldCase": "ParentId", - "originField": "parent_id", - "tbName": "parent_id", - "type": "Long" + "tableName": "t_user", + "columnName": "state", + "field": "state", + "desc": "用户状态:0=正常,1=禁用", + "fieldCase": "State", + "originField": "state", + "tbName": "state", + "type": "Integer" }, { "columnType": "varchar(255)", "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "角色唯一CODE代码", - "columnKey": "MUL", + "columnComment": "姓名", + "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "code", - "field": "code", - "desc": "角色唯一CODE代码", - "fieldCase": "Code", - "originField": "code", - "tbName": "code", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "desc": "姓名", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", "type": "String" }, { @@ -70,33 +71,67 @@ "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "角色名称", + "columnComment": "头像图片地址", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "name", - "field": "name", - "desc": "角色名称", - "fieldCase": "Name", - "originField": "name", - "tbName": "name", + "tableName": "t_user", + "columnName": "head_img_url", + "field": "headImgUrl", + "desc": "头像图片地址", + "fieldCase": "HeadImgUrl", + "originField": "head_img_url", + "tbName": "head_img_url", "type": "String" }, { - "columnType": "varchar(255)", + "columnType": "varchar(11)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "手机号码", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "phone", + "field": "phone", + "desc": "手机号码", + "fieldCase": "Phone", + "originField": "phone", + "tbName": "phone", + "type": "String" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "密码加盐", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "salt", + "field": "salt", + "desc": "密码加盐", + "fieldCase": "Salt", + "originField": "salt", + "tbName": "salt", + "type": "String" + }, + { + "columnType": "varchar(64)", "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "角色介绍", + "columnComment": "登录密码", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "intro", - "field": "intro", - "desc": "角色介绍", - "fieldCase": "Intro", - "originField": "intro", - "tbName": "intro", + "tableName": "t_user", + "columnName": "password", + "field": "password", + "desc": "登录密码", + "fieldCase": "Password", + "originField": "password", + "tbName": "password", "type": "String" }, { @@ -107,7 +142,7 @@ "columnComment": "创建时间", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "create_time", "field": "createTime", "desc": "创建时间", @@ -117,14 +152,14 @@ "type": "Date" }, { - "columnType": "varchar(36)", + "columnType": "varchar(64)", "isNullable": "YES", "dataType": "varchar", "extra": "", "columnComment": "创建人", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "creator", "field": "creator", "desc": "创建人", @@ -141,7 +176,7 @@ "columnComment": "修改时间", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "update_time", "field": "updateTime", "desc": "修改时间", @@ -151,14 +186,14 @@ "type": "Date" }, { - "columnType": "varchar(36)", + "columnType": "varchar(64)", "isNullable": "YES", "dataType": "varchar", "extra": "", "columnComment": "修改人", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "editor", "field": "editor", "desc": "修改人", @@ -175,7 +210,7 @@ "columnComment": "逻辑删除:0=未删除,1=已删除", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "deleted", "field": "deleted", "desc": "逻辑删除:0=未删除,1=已删除", @@ -188,9 +223,7 @@ "orgUniKey": "id", "uniKeyType": "Long", "priKeyArr": [ - "id", - "parent_id", - "code" + "id" ], "priKeyItemArr": [ { @@ -198,72 +231,40 @@ "isNullable": "NO", "dataType": "bigint", "extra": "auto_increment", - "columnComment": "角色ID", + "columnComment": "用户ID", "columnKey": "PRI", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "id", "field": "id", - "desc": "角色ID", + "desc": "用户ID", "fieldCase": "Id", "originField": "id", "tbName": "id", "type": "Long" - }, - { - "columnType": "bigint(20)", - "isNullable": "YES", - "dataType": "bigint", - "extra": "", - "columnComment": "所属父级角色ID", - "columnKey": "MUL", - "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "parent_id", - "field": "parentId", - "desc": "所属父级角色ID", - "fieldCase": "ParentId", - "originField": "parent_id", - "tbName": "parent_id", - "type": "Long" - }, - { - "columnType": "varchar(255)", - "isNullable": "YES", - "dataType": "varchar", - "extra": "", - "columnComment": "角色唯一CODE代码", - "columnKey": "MUL", - "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "code", - "field": "code", - "desc": "角色唯一CODE代码", - "fieldCase": "Code", - "originField": "code", - "tbName": "code", - "type": "String" } ], - "orgAssociationKey": "id", + "orgAssociationKey": [ + "id" + ], "associationKey": "id", - "associationKeyCase": "Code", - "associationKeyType": "String", + "associationKeyCase": "Id", + "associationKeyType": "Long", "tableQueryArr": [ { "columnType": "bigint(20)", "isNullable": "NO", "dataType": "bigint", "extra": "auto_increment", - "columnComment": "角色ID", + "columnComment": "用户ID", "columnKey": "PRI", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "id", "field": "id", - "desc": "角色ID", "fieldCase": "Id", "originField": "id", + "frontField": "userId", "tbName": "id", "type": "Long", "componentType": "", @@ -271,140 +272,46 @@ "value": "value", "label": "label", "children": "children", - "width": 120, - "optionData": "", - "api": "", - "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isShowSwagger": true, "isNotShowSwagger": "false", - "isNeedInput": "true" - }, - { - "columnType": "varchar(255)", - "isNullable": "YES", - "dataType": "varchar", - "extra": "", - "columnComment": "角色唯一CODE代码", - "columnKey": "MUL", - "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "code", - "field": "code", - "desc": "角色唯一CODE代码", - "fieldCase": "Code", - "originField": "code", - "tbName": "code", - "type": "String", - "componentType": "input", - "rule": "notValid", - "value": "value", - "label": "label", - "children": "children", - "isShowSwagger": false, - "optionData": "", - "api": "", - "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" - }, - { - "columnType": "varchar(36)", - "isNullable": "YES", - "dataType": "varchar", - "extra": "", - "columnComment": "修改人", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "editor", - "field": "editor", - "desc": "修改人", - "fieldCase": "Editor", - "originField": "editor", - "tbName": "editor", - "type": "String", - "componentType": "input", - "rule": "notValid", - "value": "value", - "label": "label", - "children": "children", - "isShowSwagger": false, + "isNeedInput": "false", + "desc": "用户ID", "optionData": "", "api": "", "method": "get", "labelKey": "label", "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" + "optionDataArr": [] }, { "columnType": "varchar(255)", "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "角色名称", + "columnComment": "姓名", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "name", "field": "name", - "desc": "角色名称", "fieldCase": "Name", "originField": "name", + "frontField": "userName", "tbName": "name", "type": "String", "componentType": "input", - "rule": "phone", - "value": "value", - "label": "label", - "children": "children", - "isShowSwagger": false, - "optionData": "", - "api": "", - "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "false", - "isNeedInput": "true" - }, - { - "columnType": "datetime", - "isNullable": "YES", - "dataType": "datetime", - "extra": "", - "columnComment": "创建时间", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "create_time", - "field": "createTime", - "desc": "创建时间", - "fieldCase": "CreateTime", - "originField": "create_time", - "tbName": "create_time", - "type": "Date", - "componentType": "datetime", "rule": "notValid", "value": "value", "label": "label", "children": "children", - "isShowSwagger": false, + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "姓名", "optionData": "", "api": "", "method": "get", "labelKey": "label", "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" + "optionDataArr": [] } ], "tableShowArr": [ @@ -413,15 +320,15 @@ "isNullable": "NO", "dataType": "bigint", "extra": "auto_increment", - "columnComment": "角色ID", + "columnComment": "用户ID", "columnKey": "PRI", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "id", "field": "id", - "desc": "角色ID", "fieldCase": "Id", "originField": "id", + "frontField": "userId", "tbName": "id", "type": "Long", "componentType": "", @@ -429,267 +336,170 @@ "value": "value", "label": "label", "children": "children", - "width": 120, + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "用户ID", "optionData": "", "api": "", "method": "get", "labelKey": "label", "valueKey": "value", - "optionDataArr": [], - "isShowSwagger": true, - "isNotShowSwagger": "false", - "isNeedInput": "true" + "optionDataArr": [] }, { "columnType": "varchar(255)", "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "角色唯一CODE代码", - "columnKey": "MUL", + "columnComment": "姓名", + "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "code", - "field": "code", - "desc": "角色唯一CODE代码", - "fieldCase": "Code", - "originField": "code", - "tbName": "code", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "frontField": "userName", + "tbName": "name", "type": "String", "componentType": "input", "rule": "notValid", "value": "value", "label": "label", "children": "children", - "isShowSwagger": false, + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "姓名", "optionData": "", "api": "", "method": "get", "labelKey": "label", "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" - }, + "optionDataArr": [] + } + ], + "tableFormArr": [ { - "columnType": "varchar(36)", - "isNullable": "YES", - "dataType": "varchar", - "extra": "", - "columnComment": "修改人", - "columnKey": "", + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "editor", - "field": "editor", - "desc": "修改人", - "fieldCase": "Editor", - "originField": "editor", - "tbName": "editor", - "type": "String", - "componentType": "input", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "frontField": "userId", + "tbName": "id", + "type": "Long", + "componentType": "", "rule": "notValid", "value": "value", "label": "label", "children": "children", - "isShowSwagger": false, + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "用户ID", "optionData": "", "api": "", "method": "get", "labelKey": "label", "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" + "optionDataArr": [] }, { "columnType": "varchar(255)", "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "角色名称", + "columnComment": "姓名", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "name", "field": "name", - "desc": "角色名称", "fieldCase": "Name", "originField": "name", + "frontField": "userName", "tbName": "name", "type": "String", "componentType": "input", - "rule": "phone", - "value": "value", - "label": "label", - "children": "children", - "isShowSwagger": false, - "optionData": "", - "api": "", - "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "false", - "isNeedInput": "true" - }, - { - "columnType": "datetime", - "isNullable": "YES", - "dataType": "datetime", - "extra": "", - "columnComment": "创建时间", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "create_time", - "field": "createTime", - "desc": "创建时间", - "fieldCase": "CreateTime", - "originField": "create_time", - "tbName": "create_time", - "type": "Date", - "componentType": "datetime", "rule": "notValid", "value": "value", "label": "label", "children": "children", - "isShowSwagger": false, + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "姓名", "optionData": "", "api": "", "method": "get", "labelKey": "label", "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" + "optionDataArr": [] } - ], - "tableFormArr": [ + ] + }, + { + "tableName": "userRole", + "originTableName": "t_user_role", + "tableDesc": "用户角色", + "tableNameCase": "UserRole", + "uniKey": "id", + "tableFieldArr": [ { "columnType": "bigint(20)", "isNullable": "NO", "dataType": "bigint", "extra": "auto_increment", - "columnComment": "角色ID", + "columnComment": "ID", "columnKey": "PRI", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user_role", "columnName": "id", "field": "id", - "desc": "角色ID", + "desc": "ID", "fieldCase": "Id", "originField": "id", "tbName": "id", - "type": "Long", - "componentType": "", - "rule": "notValid", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "optionData": "", - "api": "", - "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isShowSwagger": true, - "isNotShowSwagger": "false", - "isNeedInput": "true" + "type": "Long" }, { - "columnType": "varchar(255)", + "columnType": "bigint(20)", "isNullable": "YES", - "dataType": "varchar", + "dataType": "bigint", "extra": "", - "columnComment": "角色唯一CODE代码", + "columnComment": "用户ID", "columnKey": "MUL", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "code", - "field": "code", - "desc": "角色唯一CODE代码", - "fieldCase": "Code", - "originField": "code", - "tbName": "code", - "type": "String", - "componentType": "input", - "rule": "notValid", - "value": "value", - "label": "label", - "children": "children", - "isShowSwagger": false, - "optionData": "", - "api": "", - "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" + "tableName": "t_user_role", + "columnName": "user_id", + "field": "userId", + "desc": "用户ID", + "fieldCase": "UserId", + "originField": "user_id", + "tbName": "user_id", + "type": "Long" }, { - "columnType": "varchar(36)", + "columnType": "bigint(20)", "isNullable": "YES", - "dataType": "varchar", + "dataType": "bigint", "extra": "", - "columnComment": "修改人", - "columnKey": "", + "columnComment": "角色ID", + "columnKey": "MUL", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "editor", - "field": "editor", - "desc": "修改人", - "fieldCase": "Editor", - "originField": "editor", - "tbName": "editor", - "type": "String", - "componentType": "input", - "rule": "notValid", - "value": "value", - "label": "label", - "children": "children", - "isShowSwagger": false, - "optionData": "", - "api": "", - "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" - }, - { - "columnType": "varchar(255)", - "isNullable": "YES", - "dataType": "varchar", - "extra": "", - "columnComment": "角色名称", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "name", - "field": "name", - "desc": "角色名称", - "fieldCase": "Name", - "originField": "name", - "tbName": "name", - "type": "String", - "componentType": "input", - "rule": "phone", - "value": "value", - "label": "label", - "children": "children", - "isShowSwagger": false, - "optionData": "", - "api": "", - "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "false", - "isNeedInput": "true" + "tableName": "t_user_role", + "columnName": "role_id", + "field": "roleId", + "desc": "角色ID", + "fieldCase": "RoleId", + "originField": "role_id", + "tbName": "role_id", + "type": "Long" }, { "columnType": "datetime", @@ -699,40 +509,162 @@ "columnComment": "创建时间", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user_role", "columnName": "create_time", "field": "createTime", "desc": "创建时间", "fieldCase": "CreateTime", "originField": "create_time", "tbName": "create_time", - "type": "Date", - "componentType": "datetime", - "rule": "notValid", - "value": "value", - "label": "label", - "children": "children", - "isShowSwagger": false, - "optionData": "", - "api": "", - "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" + "type": "Date" + }, + { + "columnType": "varchar(36)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "创建人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "creator", + "field": "creator", + "desc": "创建人", + "fieldCase": "Creator", + "originField": "creator", + "tbName": "creator", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "修改时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "update_time", + "field": "updateTime", + "desc": "修改时间", + "fieldCase": "UpdateTime", + "originField": "update_time", + "tbName": "update_time", + "type": "Date" + }, + { + "columnType": "varchar(36)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "修改人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "editor", + "field": "editor", + "desc": "修改人", + "fieldCase": "Editor", + "originField": "editor", + "tbName": "editor", + "type": "String" + }, + { + "columnType": "tinyint(1) unsigned", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "逻辑删除:0=未删除,1=已删除", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "deleted", + "field": "deleted", + "desc": "逻辑删除:0=未删除,1=已删除", + "fieldCase": "Deleted", + "originField": "deleted", + "tbName": "deleted", + "type": "Integer" } - ] + ], + "orgUniKey": "id", + "uniKeyType": "Long", + "priKeyArr": [ + "id", + "user_id", + "role_id" + ], + "priKeyItemArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "id", + "field": "id", + "desc": "ID", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long" + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "用户ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "user_id", + "field": "userId", + "desc": "用户ID", + "fieldCase": "UserId", + "originField": "user_id", + "tbName": "user_id", + "type": "Long" + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "角色ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "role_id", + "field": "roleId", + "desc": "角色ID", + "fieldCase": "RoleId", + "originField": "role_id", + "tbName": "role_id", + "type": "Long" + } + ], + "orgAssociationKey": [ + "user_id", + "role_id" + ], + "associationKey": "roleId", + "associationKeyCase": "RoleId", + "associationKeyType": "Long" } ], "dbTableConfig": { - "multiTableName": null, - "multiTableNameCase": null, - "multiTableDesc": "", - "tableName": "role", - "originTableName": "t_role", - "tableDesc": "角色", - "tableNameCase": "Role", + "multiTableName": "UserRole", + "multiTableNameCase": "UserRole", + "multiTableDesc": "用户角色", + "associationType": "多对多", + "tableName": "user", + "originTableName": "t_user", + "tableDesc": "用户", + "tableNameCase": "User", "uniKey": "id", "tableFieldArr": [ { @@ -740,50 +672,50 @@ "isNullable": "NO", "dataType": "bigint", "extra": "auto_increment", - "columnComment": "角色ID", + "columnComment": "用户ID", "columnKey": "PRI", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "id", "field": "id", - "desc": "角色ID", + "desc": "用户ID", "fieldCase": "Id", "originField": "id", "tbName": "id", "type": "Long" }, { - "columnType": "bigint(20)", + "columnType": "tinyint(1)", "isNullable": "YES", - "dataType": "bigint", + "dataType": "tinyint", "extra": "", - "columnComment": "所属父级角色ID", - "columnKey": "MUL", + "columnComment": "用户状态:0=正常,1=禁用", + "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "parent_id", - "field": "parentId", - "desc": "所属父级角色ID", - "fieldCase": "ParentId", - "originField": "parent_id", - "tbName": "parent_id", - "type": "Long" + "tableName": "t_user", + "columnName": "state", + "field": "state", + "desc": "用户状态:0=正常,1=禁用", + "fieldCase": "State", + "originField": "state", + "tbName": "state", + "type": "Integer" }, { "columnType": "varchar(255)", "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "角色唯一CODE代码", - "columnKey": "MUL", + "columnComment": "姓名", + "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "code", - "field": "code", - "desc": "角色唯一CODE代码", - "fieldCase": "Code", - "originField": "code", - "tbName": "code", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "desc": "姓名", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", "type": "String" }, { @@ -791,33 +723,67 @@ "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "角色名称", + "columnComment": "头像图片地址", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "name", - "field": "name", - "desc": "角色名称", - "fieldCase": "Name", - "originField": "name", - "tbName": "name", + "tableName": "t_user", + "columnName": "head_img_url", + "field": "headImgUrl", + "desc": "头像图片地址", + "fieldCase": "HeadImgUrl", + "originField": "head_img_url", + "tbName": "head_img_url", "type": "String" }, { - "columnType": "varchar(255)", + "columnType": "varchar(11)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "手机号码", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "phone", + "field": "phone", + "desc": "手机号码", + "fieldCase": "Phone", + "originField": "phone", + "tbName": "phone", + "type": "String" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "密码加盐", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "salt", + "field": "salt", + "desc": "密码加盐", + "fieldCase": "Salt", + "originField": "salt", + "tbName": "salt", + "type": "String" + }, + { + "columnType": "varchar(64)", "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "角色介绍", + "columnComment": "登录密码", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "intro", - "field": "intro", - "desc": "角色介绍", - "fieldCase": "Intro", - "originField": "intro", - "tbName": "intro", + "tableName": "t_user", + "columnName": "password", + "field": "password", + "desc": "登录密码", + "fieldCase": "Password", + "originField": "password", + "tbName": "password", "type": "String" }, { @@ -828,7 +794,7 @@ "columnComment": "创建时间", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "create_time", "field": "createTime", "desc": "创建时间", @@ -838,14 +804,14 @@ "type": "Date" }, { - "columnType": "varchar(36)", + "columnType": "varchar(64)", "isNullable": "YES", "dataType": "varchar", "extra": "", "columnComment": "创建人", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "creator", "field": "creator", "desc": "创建人", @@ -862,7 +828,7 @@ "columnComment": "修改时间", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "update_time", "field": "updateTime", "desc": "修改时间", @@ -872,14 +838,14 @@ "type": "Date" }, { - "columnType": "varchar(36)", + "columnType": "varchar(64)", "isNullable": "YES", "dataType": "varchar", "extra": "", "columnComment": "修改人", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "editor", "field": "editor", "desc": "修改人", @@ -896,7 +862,7 @@ "columnComment": "逻辑删除:0=未删除,1=已删除", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "deleted", "field": "deleted", "desc": "逻辑删除:0=未删除,1=已删除", @@ -909,9 +875,7 @@ "orgUniKey": "id", "uniKeyType": "Long", "priKeyArr": [ - "id", - "parent_id", - "code" + "id" ], "priKeyItemArr": [ { @@ -919,72 +883,40 @@ "isNullable": "NO", "dataType": "bigint", "extra": "auto_increment", - "columnComment": "角色ID", + "columnComment": "用户ID", "columnKey": "PRI", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "id", "field": "id", - "desc": "角色ID", + "desc": "用户ID", "fieldCase": "Id", "originField": "id", "tbName": "id", "type": "Long" - }, - { - "columnType": "bigint(20)", - "isNullable": "YES", - "dataType": "bigint", - "extra": "", - "columnComment": "所属父级角色ID", - "columnKey": "MUL", - "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "parent_id", - "field": "parentId", - "desc": "所属父级角色ID", - "fieldCase": "ParentId", - "originField": "parent_id", - "tbName": "parent_id", - "type": "Long" - }, - { - "columnType": "varchar(255)", - "isNullable": "YES", - "dataType": "varchar", - "extra": "", - "columnComment": "角色唯一CODE代码", - "columnKey": "MUL", - "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "code", - "field": "code", - "desc": "角色唯一CODE代码", - "fieldCase": "Code", - "originField": "code", - "tbName": "code", - "type": "String" } ], - "orgAssociationKey": "id", + "orgAssociationKey": [ + "id" + ], "associationKey": "id", - "associationKeyCase": "Code", - "associationKeyType": "String", + "associationKeyCase": "Id", + "associationKeyType": "Long", "tableQueryArr": [ { "columnType": "bigint(20)", "isNullable": "NO", "dataType": "bigint", "extra": "auto_increment", - "columnComment": "角色ID", + "columnComment": "用户ID", "columnKey": "PRI", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "id", "field": "id", - "desc": "角色ID", "fieldCase": "Id", "originField": "id", + "frontField": "userId", "tbName": "id", "type": "Long", "componentType": "", @@ -992,157 +924,127 @@ "value": "value", "label": "label", "children": "children", - "width": 120, + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "用户ID", "optionData": "", "api": "", "method": "get", "labelKey": "label", "valueKey": "value", - "optionDataArr": [], - "isShowSwagger": true, - "isNotShowSwagger": "false", - "isNeedInput": "true" + "optionDataArr": [] }, { "columnType": "varchar(255)", "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "角色唯一CODE代码", - "columnKey": "MUL", + "columnComment": "姓名", + "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "code", - "field": "code", - "desc": "角色唯一CODE代码", - "fieldCase": "Code", - "originField": "code", - "tbName": "code", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "frontField": "userName", + "tbName": "name", "type": "String", "componentType": "input", "rule": "notValid", "value": "value", "label": "label", "children": "children", - "isShowSwagger": false, + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "姓名", "optionData": "", "api": "", "method": "get", "labelKey": "label", "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" - }, + "optionDataArr": [] + } + ], + "tableShowArr": [ { - "columnType": "varchar(36)", - "isNullable": "YES", - "dataType": "varchar", - "extra": "", - "columnComment": "修改人", - "columnKey": "", + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "editor", - "field": "editor", - "desc": "修改人", - "fieldCase": "Editor", - "originField": "editor", - "tbName": "editor", - "type": "String", - "componentType": "input", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "frontField": "userId", + "tbName": "id", + "type": "Long", + "componentType": "", "rule": "notValid", "value": "value", "label": "label", "children": "children", - "isShowSwagger": false, + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "用户ID", "optionData": "", "api": "", "method": "get", "labelKey": "label", "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" + "optionDataArr": [] }, { "columnType": "varchar(255)", "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "角色名称", + "columnComment": "姓名", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "name", "field": "name", - "desc": "角色名称", "fieldCase": "Name", "originField": "name", + "frontField": "userName", "tbName": "name", "type": "String", "componentType": "input", - "rule": "phone", + "rule": "notValid", "value": "value", "label": "label", "children": "children", - "isShowSwagger": false, + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "姓名", "optionData": "", "api": "", "method": "get", "labelKey": "label", "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "false", - "isNeedInput": "true" - }, - { - "columnType": "datetime", - "isNullable": "YES", - "dataType": "datetime", - "extra": "", - "columnComment": "创建时间", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "create_time", - "field": "createTime", - "desc": "创建时间", - "fieldCase": "CreateTime", - "originField": "create_time", - "tbName": "create_time", - "type": "Date", - "componentType": "datetime", - "rule": "notValid", - "value": "value", - "label": "label", - "children": "children", - "isShowSwagger": false, - "optionData": "", - "api": "", - "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" - } - ], - "tableShowArr": [ + "optionDataArr": [] + } + ], + "tableFormArr": [ { "columnType": "bigint(20)", "isNullable": "NO", "dataType": "bigint", "extra": "auto_increment", - "columnComment": "角色ID", + "columnComment": "用户ID", "columnKey": "PRI", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "id", "field": "id", - "desc": "角色ID", "fieldCase": "Id", "originField": "id", + "frontField": "userId", "tbName": "id", "type": "Long", "componentType": "", @@ -1150,298 +1052,46 @@ "value": "value", "label": "label", "children": "children", - "width": 120, - "optionData": "", - "api": "", - "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isShowSwagger": true, "isNotShowSwagger": "false", - "isNeedInput": "true" - }, - { - "columnType": "varchar(255)", - "isNullable": "YES", - "dataType": "varchar", - "extra": "", - "columnComment": "角色唯一CODE代码", - "columnKey": "MUL", - "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "code", - "field": "code", - "desc": "角色唯一CODE代码", - "fieldCase": "Code", - "originField": "code", - "tbName": "code", - "type": "String", - "componentType": "input", - "rule": "notValid", - "value": "value", - "label": "label", - "children": "children", - "isShowSwagger": false, - "optionData": "", - "api": "", - "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" - }, - { - "columnType": "varchar(36)", - "isNullable": "YES", - "dataType": "varchar", - "extra": "", - "columnComment": "修改人", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "editor", - "field": "editor", - "desc": "修改人", - "fieldCase": "Editor", - "originField": "editor", - "tbName": "editor", - "type": "String", - "componentType": "input", - "rule": "notValid", - "value": "value", - "label": "label", - "children": "children", - "isShowSwagger": false, + "isNeedInput": "false", + "desc": "用户ID", "optionData": "", "api": "", "method": "get", "labelKey": "label", "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" + "optionDataArr": [] }, { "columnType": "varchar(255)", "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "角色名称", + "columnComment": "姓名", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "name", "field": "name", - "desc": "角色名称", "fieldCase": "Name", "originField": "name", + "frontField": "userName", "tbName": "name", "type": "String", "componentType": "input", - "rule": "phone", - "value": "value", - "label": "label", - "children": "children", - "isShowSwagger": false, - "optionData": "", - "api": "", - "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "false", - "isNeedInput": "true" - }, - { - "columnType": "datetime", - "isNullable": "YES", - "dataType": "datetime", - "extra": "", - "columnComment": "创建时间", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "create_time", - "field": "createTime", - "desc": "创建时间", - "fieldCase": "CreateTime", - "originField": "create_time", - "tbName": "create_time", - "type": "Date", - "componentType": "datetime", "rule": "notValid", "value": "value", "label": "label", "children": "children", - "isShowSwagger": false, - "optionData": "", - "api": "", - "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" - } - ], - "tableFormArr": [ - { - "columnType": "bigint(20)", - "isNullable": "NO", - "dataType": "bigint", - "extra": "auto_increment", - "columnComment": "角色ID", - "columnKey": "PRI", - "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "id", - "field": "id", - "desc": "角色ID", - "fieldCase": "Id", - "originField": "id", - "tbName": "id", - "type": "Long", - "componentType": "", - "rule": "notValid", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "optionData": "", - "api": "", - "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isShowSwagger": true, "isNotShowSwagger": "false", - "isNeedInput": "true" - }, - { - "columnType": "varchar(255)", - "isNullable": "YES", - "dataType": "varchar", - "extra": "", - "columnComment": "角色唯一CODE代码", - "columnKey": "MUL", - "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "code", - "field": "code", - "desc": "角色唯一CODE代码", - "fieldCase": "Code", - "originField": "code", - "tbName": "code", - "type": "String", - "componentType": "input", - "rule": "notValid", - "value": "value", - "label": "label", - "children": "children", - "isShowSwagger": false, - "optionData": "", - "api": "", - "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" - }, - { - "columnType": "varchar(36)", - "isNullable": "YES", - "dataType": "varchar", - "extra": "", - "columnComment": "修改人", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "editor", - "field": "editor", - "desc": "修改人", - "fieldCase": "Editor", - "originField": "editor", - "tbName": "editor", - "type": "String", - "componentType": "input", - "rule": "notValid", - "value": "value", - "label": "label", - "children": "children", - "isShowSwagger": false, + "isNeedInput": "false", + "desc": "姓名", "optionData": "", "api": "", "method": "get", "labelKey": "label", "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" - }, - { - "columnType": "varchar(255)", - "isNullable": "YES", - "dataType": "varchar", - "extra": "", - "columnComment": "角色名称", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "name", - "field": "name", - "desc": "角色名称", - "fieldCase": "Name", - "originField": "name", - "tbName": "name", - "type": "String", - "componentType": "input", - "rule": "phone", - "value": "value", - "label": "label", - "children": "children", - "isShowSwagger": false, - "optionData": "", - "api": "", - "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "false", - "isNeedInput": "true" - }, - { - "columnType": "datetime", - "isNullable": "YES", - "dataType": "datetime", - "extra": "", - "columnComment": "创建时间", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "create_time", - "field": "createTime", - "desc": "创建时间", - "fieldCase": "CreateTime", - "originField": "create_time", - "tbName": "create_time", - "type": "Date", - "componentType": "datetime", - "rule": "notValid", - "value": "value", - "label": "label", - "children": "children", - "isShowSwagger": false, - "optionData": "", - "api": "", - "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" + "optionDataArr": [] } ] }, @@ -1462,83 +1112,205 @@ "originField": "id", "tbName": "id", "type": "Long", + "frontField": "roleId", "componentType": "", "rule": "notValid", "value": "value", "label": "label", "children": "children", - "width": 120, + "isNotShowSwagger": "false", + "isNeedInput": "false", "optionData": "", "api": "", "method": "get", "labelKey": "label", "valueKey": "value", - "optionDataArr": [], - "isShowSwagger": true, - "isNotShowSwagger": "false", - "isNeedInput": "true" + "optionDataArr": [] }, { "columnType": "varchar(255)", "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "角色唯一CODE代码", - "columnKey": "MUL", + "columnComment": "角色名称", + "columnKey": "", "tableSchema": "micro-service-plus", "tableName": "t_role", - "columnName": "code", - "field": "code", - "desc": "角色唯一CODE代码", - "fieldCase": "Code", - "originField": "code", - "tbName": "code", + "columnName": "name", + "field": "name", + "desc": "角色名称", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", "type": "String", + "frontField": "roleName", "componentType": "input", "rule": "notValid", "value": "value", "label": "label", "children": "children", - "isShowSwagger": false, + "isNotShowSwagger": "false", + "isNeedInput": "false", "optionData": "", "api": "", "method": "get", "labelKey": "label", "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" + "optionDataArr": [] }, { - "columnType": "varchar(36)", + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "frontField": "userId", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "修改人", + "columnComment": "姓名", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "editor", - "field": "editor", - "desc": "修改人", - "fieldCase": "Editor", - "originField": "editor", - "tbName": "editor", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "frontField": "userName", + "tbName": "name", "type": "String", "componentType": "input", "rule": "notValid", "value": "value", "label": "label", "children": "children", - "isShowSwagger": false, + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "姓名", "optionData": "", "api": "", "method": "get", "labelKey": "label", "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" + "optionDataArr": [] + } + ], + "tableConfig": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "角色ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "id", + "field": "id", + "frontField": "id", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "角色ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "所属父级角色ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "parent_id", + "field": "parentId", + "frontField": "parentId", + "fieldCase": "ParentId", + "originField": "parent_id", + "tbName": "parent_id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "所属父级角色ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色唯一CODE代码", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "code", + "field": "code", + "frontField": "code", + "fieldCase": "Code", + "originField": "code", + "tbName": "code", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "角色唯一CODE代码", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] }, { "columnType": "varchar(255)", @@ -1551,82 +1323,78 @@ "tableName": "t_role", "columnName": "name", "field": "name", - "desc": "角色名称", + "frontField": "roleName", "fieldCase": "Name", "originField": "name", "tbName": "name", "type": "String", "componentType": "input", - "rule": "phone", + "rule": "isNotNull", "value": "value", "label": "label", "children": "children", - "isShowSwagger": false, + "width": 120, + "desc": "角色名称", "optionData": "", "api": "", "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "false", - "isNeedInput": "true" + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] }, { - "columnType": "datetime", + "columnType": "varchar(255)", "isNullable": "YES", - "dataType": "datetime", + "dataType": "varchar", "extra": "", - "columnComment": "创建时间", + "columnComment": "角色介绍", "columnKey": "", "tableSchema": "micro-service-plus", "tableName": "t_role", - "columnName": "create_time", - "field": "createTime", - "desc": "创建时间", - "fieldCase": "CreateTime", - "originField": "create_time", - "tbName": "create_time", - "type": "Date", - "componentType": "datetime", - "rule": "notValid", + "columnName": "intro", + "field": "intro", + "frontField": "intro", + "fieldCase": "Intro", + "originField": "intro", + "tbName": "intro", + "type": "String", + "componentType": "input", + "rule": "isNotNull", "value": "value", "label": "label", "children": "children", - "isShowSwagger": false, + "width": 120, + "desc": "角色介绍", "optionData": "", "api": "", "method": "get", - "labelKey": "label", - "valueKey": "value", - "optionDataArr": [], - "isNotShowSwagger": "true", - "isNeedInput": "false" - } - ], - "tableConfig": [ + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, { "columnType": "bigint(20)", "isNullable": "NO", "dataType": "bigint", "extra": "auto_increment", - "columnComment": "角色ID", + "columnComment": "用户ID", "columnKey": "PRI", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "id", "field": "id", - "desc": "角色ID", + "frontField": "userId", "fieldCase": "Id", "originField": "id", "tbName": "id", "type": "Long", - "frontField": "id", "componentType": "", "rule": "isNotNull", "value": "value", "label": "label", "children": "children", "width": 120, + "desc": "用户ID", "optionData": "", "api": "", "method": "get", @@ -1635,58 +1403,67 @@ "optionDataArr": [] }, { - "columnType": "bigint(20)", + "columnType": "tinyint(1)", "isNullable": "YES", - "dataType": "bigint", + "dataType": "tinyint", "extra": "", - "columnComment": "所属父级角色ID", - "columnKey": "MUL", + "columnComment": "用户状态:0=正常,1=禁用", + "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "parent_id", - "field": "parentId", - "desc": "所属父级角色ID", - "fieldCase": "ParentId", - "originField": "parent_id", - "tbName": "parent_id", - "type": "Long", - "frontField": "parentId", - "componentType": "", + "tableName": "t_user", + "columnName": "state", + "field": "state", + "frontField": "state", + "fieldCase": "State", + "originField": "state", + "tbName": "state", + "type": "Integer", + "componentType": "select", "rule": "isNotNull", "value": "value", "label": "label", "children": "children", "width": 120, - "optionData": "", + "desc": "用户状态", + "optionData": "0=正常,1=禁用", "api": "", "method": "get", "labelKey": "name", "valueKey": "code", - "optionDataArr": [] + "optionDataArr": [ + { + "value": "0", + "label": "正常" + }, + { + "value": "1", + "label": "禁用" + } + ] }, { "columnType": "varchar(255)", "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "角色唯一CODE代码", - "columnKey": "MUL", + "columnComment": "姓名", + "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "code", - "field": "code", - "desc": "角色唯一CODE代码", - "fieldCase": "Code", - "originField": "code", - "tbName": "code", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "frontField": "userName", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", "type": "String", - "frontField": "code", "componentType": "input", "rule": "isNotNull", "value": "value", "label": "label", "children": "children", "width": 120, + "desc": "姓名", "optionData": "", "api": "", "method": "get", @@ -1699,24 +1476,24 @@ "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "角色名称", + "columnComment": "头像图片地址", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "name", - "field": "name", - "desc": "角色名称", - "fieldCase": "Name", - "originField": "name", - "tbName": "name", + "tableName": "t_user", + "columnName": "head_img_url", + "field": "headImgUrl", + "frontField": "headImgUrl", + "fieldCase": "HeadImgUrl", + "originField": "head_img_url", + "tbName": "head_img_url", "type": "String", - "frontField": "name", "componentType": "input", "rule": "isNotNull", "value": "value", "label": "label", "children": "children", "width": 120, + "desc": "头像图片地址", "optionData": "", "api": "", "method": "get", @@ -1725,28 +1502,28 @@ "optionDataArr": [] }, { - "columnType": "varchar(255)", + "columnType": "varchar(11)", "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "角色介绍", + "columnComment": "手机号码", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "intro", - "field": "intro", - "desc": "角色介绍", - "fieldCase": "Intro", - "originField": "intro", - "tbName": "intro", + "tableName": "t_user", + "columnName": "phone", + "field": "phone", + "frontField": "phone", + "fieldCase": "Phone", + "originField": "phone", + "tbName": "phone", "type": "String", - "frontField": "intro", "componentType": "input", "rule": "isNotNull", "value": "value", "label": "label", "children": "children", "width": 120, + "desc": "手机号码", "optionData": "", "api": "", "method": "get", @@ -1762,21 +1539,21 @@ "columnComment": "创建时间", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "create_time", "field": "createTime", - "desc": "创建时间", + "frontField": "userCreateTime", "fieldCase": "CreateTime", "originField": "create_time", "tbName": "create_time", "type": "Date", - "frontField": "createTime", "componentType": "input", "rule": "isNotNull", "value": "value", "label": "label", "children": "children", "width": 120, + "desc": "用户创建时间", "optionData": "", "api": "", "method": "get", @@ -1785,33 +1562,35 @@ "optionDataArr": [] }, { - "columnType": "varchar(36)", + "columnType": "datetime", "isNullable": "YES", - "dataType": "varchar", + "dataType": "datetime", "extra": "", - "columnComment": "创建人", + "columnComment": "创建时间", "columnKey": "", "tableSchema": "micro-service-plus", "tableName": "t_role", - "columnName": "creator", - "field": "creator", - "desc": "创建人", - "fieldCase": "Creator", - "originField": "creator", - "tbName": "creator", - "type": "String", - "frontField": "creator", + "columnName": "create_time", + "field": "createTime", + "fieldCase": "CreateTime", + "originField": "create_time", + "frontField": "roleCreateTime", + "tbName": "create_time", + "type": "Date", "componentType": "input", "rule": "isNotNull", "value": "value", "label": "label", "children": "children", - "width": 120, + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "角色创建时间", "optionData": "", "api": "", "method": "get", "labelKey": "name", "valueKey": "code", + "width": 120, "optionDataArr": [] } ], @@ -1821,128 +1600,159 @@ "isNullable": "NO", "dataType": "bigint", "extra": "auto_increment", - "columnComment": "角色ID", + "columnComment": "用户ID", "columnKey": "PRI", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "id", - "field": "id", - "desc": "角色ID(修改时需要传递)", + "field": "userId", "fieldCase": "Id", "originField": "id", "tbName": "id", "type": "Long", "componentType": "", - "rule": "notValid", + "rule": "isNotNull", "value": "value", "label": "label", "children": "children", - "width": 120, + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "用户ID", "optionData": "", "api": "", "method": "get", "labelKey": "name", "valueKey": "code", - "optionDataArr": [], - "isShowSwagger": true, - "isNotShowSwagger": "false", - "isNeedInput": "true" + "optionDataArr": [] }, { - "columnType": "bigint(20)", + "columnType": "tinyint(1)", "isNullable": "YES", - "dataType": "bigint", + "dataType": "tinyint", "extra": "", - "columnComment": "所属父级角色ID", - "columnKey": "MUL", + "columnComment": "用户状态:0=正常,1=禁用", + "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "parent_id", - "field": "parentId", - "desc": "所属父级角色ID(不传为顶级父id)", - "fieldCase": "ParentId", - "originField": "parent_id", - "tbName": "parent_id", - "type": "Long", - "componentType": "", - "rule": "idCard", + "tableName": "t_user", + "columnName": "state", + "field": "state", + "fieldCase": "State", + "originField": "state", + "tbName": "state", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", "value": "value", "label": "label", "children": "children", - "width": 120, - "optionData": "", + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "用户状态", + "optionData": "0=正常,1=禁用", "api": "", "method": "get", "labelKey": "name", "valueKey": "code", - "optionDataArr": [], - "isShowSwagger": true, - "isNotShowSwagger": "false", - "isNeedInput": "true" + "optionDataArr": [ + { + "value": "0", + "label": "正常" + }, + { + "value": "1", + "label": "禁用" + } + ] }, { "columnType": "varchar(255)", "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "角色唯一CODE代码", - "columnKey": "MUL", + "columnComment": "姓名", + "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "code", - "field": "code", - "desc": "角色唯一CODE代码", - "fieldCase": "Code", - "originField": "code", - "tbName": "code", + "tableName": "t_user", + "columnName": "name", + "field": "userName", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", "type": "String", "componentType": "input", - "rule": "notValid", + "rule": "isNotNull", "value": "value", "label": "label", "children": "children", - "width": 120, + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "姓名", "optionData": "", "api": "", "method": "get", "labelKey": "name", "valueKey": "code", - "optionDataArr": [], - "isShowSwagger": true, - "isNotShowSwagger": "false", - "isNeedInput": "false" + "optionDataArr": [] }, { "columnType": "varchar(255)", "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "角色介绍", + "columnComment": "头像图片地址", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", - "columnName": "intro", - "field": "intro", - "desc": "角色介绍", - "fieldCase": "Intro", - "originField": "intro", - "tbName": "intro", + "tableName": "t_user", + "columnName": "head_img_url", + "field": "headImgUrl", + "fieldCase": "HeadImgUrl", + "originField": "head_img_url", + "tbName": "head_img_url", "type": "String", "componentType": "input", - "rule": "notValid", + "rule": "isNotNull", "value": "value", "label": "label", "children": "children", - "width": 120, + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "头像图片地址", "optionData": "", "api": "", "method": "get", "labelKey": "name", "valueKey": "code", - "optionDataArr": [], - "isShowSwagger": true, + "optionDataArr": [] + }, + { + "columnType": "varchar(11)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "手机号码", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "phone", + "field": "phone", + "fieldCase": "Phone", + "originField": "phone", + "tbName": "phone", + "type": "String", + "componentType": "input", + "rule": "phone", + "value": "value", + "label": "label", + "children": "children", "isNotShowSwagger": "false", - "isNeedInput": "false" + "isNeedInput": "true", + "desc": "手机号码", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] }, { "columnType": "datetime", @@ -1952,231 +1762,337 @@ "columnComment": "创建时间", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "create_time", "field": "createTime", - "desc": "创建时间", "fieldCase": "CreateTime", "originField": "create_time", "tbName": "create_time", "type": "Date", "componentType": "datetime", - "rule": "notValid", + "rule": "isNotNull", "value": "value", "label": "label", "children": "children", - "width": 120, + "isNotShowSwagger": "true", + "isNeedInput": "false", + "desc": "创建时间", "optionData": "", "api": "", "method": "get", "labelKey": "name", "valueKey": "code", - "optionDataArr": [], - "isShowSwagger": false, - "isNotShowSwagger": "true", - "isNeedInput": "false" + "optionDataArr": [] }, { - "columnType": "varchar(36)", + "columnType": "varchar(64)", "isNullable": "YES", "dataType": "varchar", "extra": "", "columnComment": "创建人", "columnKey": "", "tableSchema": "micro-service-plus", - "tableName": "t_role", + "tableName": "t_user", "columnName": "creator", "field": "creator", - "desc": "创建人", "fieldCase": "Creator", "originField": "creator", "tbName": "creator", "type": "String", "componentType": "input", - "rule": "notValid", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "true", + "isNeedInput": "false", + "desc": "创建人", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "修改时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "update_time", + "field": "updateTime", + "fieldCase": "UpdateTime", + "originField": "update_time", + "tbName": "update_time", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "true", + "isNeedInput": "false", + "desc": "修改时间", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "角色ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "id", + "field": "roleId", + "fieldCase": "Id", + "originField": "rolid", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "角色ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "所属父级角色ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "parent_id", + "field": "parentId", + "fieldCase": "ParentId", + "originField": "parent_id", + "tbName": "parent_id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", "value": "value", "label": "label", "children": "children", - "width": 120, + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "所属父级角色ID", "optionData": "", "api": "", "method": "get", "labelKey": "name", "valueKey": "code", - "optionDataArr": [], - "isShowSwagger": false, - "isNotShowSwagger": "true", - "isNeedInput": "false" + "optionDataArr": [] }, { - "columnType": "datetime", + "columnType": "varchar(255)", "isNullable": "YES", - "dataType": "datetime", + "dataType": "varchar", "extra": "", - "columnComment": "修改时间", - "columnKey": "", + "columnComment": "角色唯一CODE代码", + "columnKey": "MUL", "tableSchema": "micro-service-plus", "tableName": "t_role", - "columnName": "update_time", - "field": "updateTime", - "desc": "修改时间", - "fieldCase": "UpdateTime", - "originField": "update_time", - "tbName": "update_time", - "type": "Date", - "componentType": "datetime", - "rule": "notValid", + "columnName": "code", + "field": "code", + "fieldCase": "Code", + "originField": "code", + "tbName": "code", + "type": "String", + "componentType": "input", + "rule": "isNotNull", "value": "value", "label": "label", "children": "children", - "width": 120, + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "角色唯一CODE代码", "optionData": "", "api": "", "method": "get", "labelKey": "name", "valueKey": "code", - "optionDataArr": [], - "isShowSwagger": false, - "isNotShowSwagger": "true", - "isNeedInput": "false" + "optionDataArr": [] }, { - "columnType": "varchar(36)", + "columnType": "varchar(255)", "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "修改人", + "columnComment": "角色名称", "columnKey": "", "tableSchema": "micro-service-plus", "tableName": "t_role", - "columnName": "editor", - "field": "editor", - "desc": "修改人", - "fieldCase": "Editor", - "originField": "editor", - "tbName": "editor", + "columnName": "name", + "field": "roleName", + "fieldCase": "Name", + "originField": "roleName", + "tbName": "name", "type": "String", "componentType": "input", - "rule": "notValid", + "rule": "isNotNull", "value": "value", "label": "label", "children": "children", - "width": 120, + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "角色名称", "optionData": "", "api": "", "method": "get", "labelKey": "name", "valueKey": "code", - "optionDataArr": [], - "isShowSwagger": false, - "isNotShowSwagger": "true", - "isNeedInput": "false" + "optionDataArr": [] }, { - "columnType": "tinyint(1) unsigned", + "columnType": "varchar(255)", "isNullable": "YES", - "dataType": "tinyint", + "dataType": "varchar", "extra": "", - "columnComment": "逻辑删除:0=未删除,1=已删除", + "columnComment": "角色介绍", "columnKey": "", "tableSchema": "micro-service-plus", "tableName": "t_role", - "columnName": "deleted", - "field": "deleted", - "desc": "逻辑删除", - "fieldCase": "Deleted", - "originField": "deleted", - "tbName": "deleted", - "type": "Integer", - "componentType": "select", - "rule": "notValid", + "columnName": "intro", + "field": "intro", + "fieldCase": "Intro", + "originField": "intro", + "tbName": "intro", + "type": "String", + "componentType": "input", + "rule": "isNotNull", "value": "value", "label": "label", "children": "children", - "width": 120, - "optionData": "0=未删除,1=已删除", + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "角色介绍", + "optionData": "", "api": "", "method": "get", "labelKey": "name", "valueKey": "code", - "optionDataArr": [ - { - "value": "0", - "label": "未删除" - }, - { - "value": "1", - "label": "已删除" - } - ], - "isNotShowSwagger": "true", - "isNeedInput": "false" + "optionDataArr": [] } ], "dataBaseUrl": "https://github.jzfai.top/micro-service-api/basis-func/dataBase/getAllDatabaseOrTable/micro-service-plus", "dbRadio": [ - "t_role" + "t_role", + "t_user_role", + "t_user" ], "chooseDbRadio": "t_role", "dbTableUrl": "https://github.jzfai.top/micro-service-api/basis-func/dataBase/getAllDatabaseOrTable/micro-service-plus", "tbName": "t_role", "checkColumnArr": [ { - "columnType": "varchar(255)", + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "角色ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "true", + "isNeedInput": "false", + "desc": "角色ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [] + }, + { + "columnType": "bigint(20)", "isNullable": "YES", - "dataType": "varchar", + "dataType": "bigint", "extra": "", - "columnComment": "角色唯一CODE代码", + "columnComment": "所属父级角色ID", "columnKey": "MUL", "tableSchema": "micro-service-plus", "tableName": "t_role", - "columnName": "code", - "field": "code", - "desc": "角色唯一CODE代码", - "fieldCase": "Code", - "originField": "code", - "tbName": "code", - "type": "String", - "componentType": "input", + "columnName": "parent_id", + "field": "parentId", + "fieldCase": "ParentId", + "originField": "parent_id", + "tbName": "parent_id", + "type": "Long", + "componentType": "", "rule": "isNotNull", "value": "value", "label": "label", "children": "children", - "isShowSwagger": false, + "isNotShowSwagger": "true", + "isNeedInput": "false", + "desc": "所属父级角色ID", "optionData": "", "api": "", "method": "get", - "labelKey": "label", - "valueKey": "value", + "labelKey": "name", + "valueKey": "code", "optionDataArr": [] }, { - "columnType": "varchar(36)", + "columnType": "varchar(255)", "isNullable": "YES", "dataType": "varchar", "extra": "", - "columnComment": "修改人", - "columnKey": "", + "columnComment": "角色唯一CODE代码", + "columnKey": "MUL", "tableSchema": "micro-service-plus", "tableName": "t_role", - "columnName": "editor", - "field": "editor", - "desc": "修改人", - "fieldCase": "Editor", - "originField": "editor", - "tbName": "editor", + "columnName": "code", + "field": "code", + "fieldCase": "Code", + "originField": "code", + "tbName": "code", "type": "String", "componentType": "input", "rule": "isNotNull", "value": "value", "label": "label", "children": "children", - "isShowSwagger": false, + "isNotShowSwagger": "true", + "isNeedInput": "false", + "desc": "角色唯一CODE代码", "optionData": "", "api": "", "method": "get", - "labelKey": "label", - "valueKey": "value", + "labelKey": "name", + "valueKey": "code", "optionDataArr": [] }, { @@ -2190,7 +2106,6 @@ "tableName": "t_role", "columnName": "name", "field": "name", - "desc": "角色名称", "fieldCase": "Name", "originField": "name", "tbName": "name", @@ -2200,41 +2115,44 @@ "value": "value", "label": "label", "children": "children", - "isShowSwagger": false, + "isNotShowSwagger": "true", + "isNeedInput": "false", + "desc": "角色名称", "optionData": "", "api": "", "method": "get", - "labelKey": "label", - "valueKey": "value", + "labelKey": "name", + "valueKey": "code", "optionDataArr": [] }, { - "columnType": "datetime", + "columnType": "varchar(255)", "isNullable": "YES", - "dataType": "datetime", + "dataType": "varchar", "extra": "", - "columnComment": "创建时间", + "columnComment": "角色介绍", "columnKey": "", "tableSchema": "micro-service-plus", "tableName": "t_role", - "columnName": "create_time", - "field": "createTime", - "desc": "创建时间", - "fieldCase": "CreateTime", - "originField": "create_time", - "tbName": "create_time", - "type": "Date", - "componentType": "datetime", + "columnName": "intro", + "field": "intro", + "fieldCase": "Intro", + "originField": "intro", + "tbName": "intro", + "type": "String", + "componentType": "input", "rule": "isNotNull", "value": "value", "label": "label", "children": "children", - "isShowSwagger": false, + "isNotShowSwagger": "true", + "isNeedInput": "false", + "desc": "角色介绍", "optionData": "", "api": "", "method": "get", - "labelKey": "label", - "valueKey": "value", + "labelKey": "name", + "valueKey": "code", "optionDataArr": [] } ], @@ -2245,6 +2163,20 @@ "tableSchema": "micro-service-plus", "tableName": "t_role", "id": "f239e1a4-ef6b-4b56-b4bc-dd3bce4bd4e1" + }, + { + "createTime": "2022-09-16T06:46:07", + "tableComment": "用户角色", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "id": "5e47ce1b-1502-421d-acb3-899afc6b56cc" + }, + { + "createTime": "2022-09-16T06:46:07", + "tableComment": "用户", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "id": "e7b294e9-2ab9-467a-8b95-e49f96153868" } ], "tbData": [ @@ -2257,13 +2189,7 @@ "columnKey": "PRI", "tableSchema": "micro-service-plus", "tableName": "t_role", - "columnName": "id", - "field": "id", - "desc": "角色ID", - "fieldCase": "Id", - "originField": "id", - "tbName": "id", - "type": "Long" + "columnName": "id" }, { "columnType": "bigint(20)", @@ -2274,13 +2200,7 @@ "columnKey": "MUL", "tableSchema": "micro-service-plus", "tableName": "t_role", - "columnName": "parent_id", - "field": "parentId", - "desc": "所属父级角色ID", - "fieldCase": "ParentId", - "originField": "parent_id", - "tbName": "parent_id", - "type": "Long" + "columnName": "parent_id" }, { "columnType": "varchar(255)", @@ -2291,13 +2211,7 @@ "columnKey": "MUL", "tableSchema": "micro-service-plus", "tableName": "t_role", - "columnName": "code", - "field": "code", - "desc": "角色唯一CODE代码", - "fieldCase": "Code", - "originField": "code", - "tbName": "code", - "type": "String" + "columnName": "code" }, { "columnType": "varchar(255)", @@ -2308,13 +2222,7 @@ "columnKey": "", "tableSchema": "micro-service-plus", "tableName": "t_role", - "columnName": "name", - "field": "name", - "desc": "角色名称", - "fieldCase": "Name", - "originField": "name", - "tbName": "name", - "type": "String" + "columnName": "name" }, { "columnType": "varchar(255)", @@ -2325,13 +2233,7 @@ "columnKey": "", "tableSchema": "micro-service-plus", "tableName": "t_role", - "columnName": "intro", - "field": "intro", - "desc": "角色介绍", - "fieldCase": "Intro", - "originField": "intro", - "tbName": "intro", - "type": "String" + "columnName": "intro" }, { "columnType": "datetime", @@ -2342,13 +2244,7 @@ "columnKey": "", "tableSchema": "micro-service-plus", "tableName": "t_role", - "columnName": "create_time", - "field": "createTime", - "desc": "创建时间", - "fieldCase": "CreateTime", - "originField": "create_time", - "tbName": "create_time", - "type": "Date" + "columnName": "create_time" }, { "columnType": "varchar(36)", @@ -2359,13 +2255,7 @@ "columnKey": "", "tableSchema": "micro-service-plus", "tableName": "t_role", - "columnName": "creator", - "field": "creator", - "desc": "创建人", - "fieldCase": "Creator", - "originField": "creator", - "tbName": "creator", - "type": "String" + "columnName": "creator" }, { "columnType": "datetime", @@ -2376,13 +2266,7 @@ "columnKey": "", "tableSchema": "micro-service-plus", "tableName": "t_role", - "columnName": "update_time", - "field": "updateTime", - "desc": "修改时间", - "fieldCase": "UpdateTime", - "originField": "update_time", - "tbName": "update_time", - "type": "Date" + "columnName": "update_time" }, { "columnType": "varchar(36)", @@ -2393,13 +2277,7 @@ "columnKey": "", "tableSchema": "micro-service-plus", "tableName": "t_role", - "columnName": "editor", - "field": "editor", - "desc": "修改人", - "fieldCase": "Editor", - "originField": "editor", - "tbName": "editor", - "type": "String" + "columnName": "editor" }, { "columnType": "tinyint(1) unsigned", @@ -2410,13 +2288,7 @@ "columnKey": "", "tableSchema": "micro-service-plus", "tableName": "t_role", - "columnName": "deleted", - "field": "deleted", - "desc": "逻辑删除:0=未删除,1=已删除", - "fieldCase": "Deleted", - "originField": "deleted", - "tbName": "deleted", - "type": "Integer" + "columnName": "deleted" } ] } \ No newline at end of file diff --git a/velocity-tmp-dir/json-data/mybatis-plus/multiData.json b/velocity-tmp-dir/json-data/mybatis-plus/multiData.json new file mode 100644 index 0000000..8def4b6 --- /dev/null +++ b/velocity-tmp-dir/json-data/mybatis-plus/multiData.json @@ -0,0 +1,3416 @@ +{ + "basicConfig": { + "author": "熊猫哥", + "packageName": "top.kuanghua.integrationfront", + "basicClassName": "role", + "basicClassDesc": "角色相关", + "dataTime": "2022-10-07 16:33:13", + "isMultiTable": true + }, + "multiTableConfig": [ + { + "tableName": "user", + "originTableName": "t_user", + "tableDesc": "用户", + "tableNameCase": "User", + "uniKey": "id", + "tableFieldArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "desc": "用户ID", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long" + }, + { + "columnType": "tinyint(1)", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "用户状态:0=正常,1=禁用", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "state", + "field": "state", + "desc": "用户状态:0=正常,1=禁用", + "fieldCase": "State", + "originField": "state", + "tbName": "state", + "type": "Integer" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "desc": "姓名", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "头像图片地址", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "head_img_url", + "field": "headImgUrl", + "desc": "头像图片地址", + "fieldCase": "HeadImgUrl", + "originField": "head_img_url", + "tbName": "head_img_url", + "type": "String" + }, + { + "columnType": "varchar(11)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "手机号码", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "phone", + "field": "phone", + "desc": "手机号码", + "fieldCase": "Phone", + "originField": "phone", + "tbName": "phone", + "type": "String" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "密码加盐", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "salt", + "field": "salt", + "desc": "密码加盐", + "fieldCase": "Salt", + "originField": "salt", + "tbName": "salt", + "type": "String" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "登录密码", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "password", + "field": "password", + "desc": "登录密码", + "fieldCase": "Password", + "originField": "password", + "tbName": "password", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "create_time", + "field": "createTime", + "desc": "创建时间", + "fieldCase": "CreateTime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "创建人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "creator", + "field": "creator", + "desc": "创建人", + "fieldCase": "Creator", + "originField": "creator", + "tbName": "creator", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "修改时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "update_time", + "field": "updateTime", + "desc": "修改时间", + "fieldCase": "UpdateTime", + "originField": "update_time", + "tbName": "update_time", + "type": "Date" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "修改人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "editor", + "field": "editor", + "desc": "修改人", + "fieldCase": "Editor", + "originField": "editor", + "tbName": "editor", + "type": "String" + }, + { + "columnType": "tinyint(1) unsigned", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "逻辑删除:0=未删除,1=已删除", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "deleted", + "field": "deleted", + "desc": "逻辑删除:0=未删除,1=已删除", + "fieldCase": "Deleted", + "originField": "deleted", + "tbName": "deleted", + "type": "Integer" + } + ], + "orgUniKey": "id", + "uniKeyType": "Long", + "priKeyArr": [ + "id" + ], + "priKeyItemArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "desc": "用户ID", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long" + } + ], + "orgAssociationKey": [ + "id" + ], + "associationKey": "id", + "associationKeyCase": "Id", + "associationKeyType": "Long", + "tableQueryArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "frontField": "userId", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [], + "frontFieldCase": "UserId" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "frontField": "userName", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "姓名", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [], + "frontFieldCase": "UserName" + } + ], + "tableShowArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "frontField": "userId", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "UserId" + }, + { + "columnType": "tinyint(1)", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "用户状态:0=正常,1=禁用", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "state", + "field": "state", + "frontField": "state", + "fieldCase": "State", + "originField": "state", + "tbName": "state", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "用户状态", + "optionData": "0=正常,1=禁用", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0", + "label": "正常" + }, + { + "value": "1", + "label": "禁用" + } + ], + "frontFieldCase": "State" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "frontField": "userName", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "姓名", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "UserName" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "头像图片地址", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "head_img_url", + "field": "headImgUrl", + "frontField": "headImgUrl", + "fieldCase": "HeadImgUrl", + "originField": "head_img_url", + "tbName": "head_img_url", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "头像图片地址", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "HeadImgUrl" + }, + { + "columnType": "varchar(11)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "手机号码", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "phone", + "field": "phone", + "frontField": "phone", + "fieldCase": "Phone", + "originField": "phone", + "tbName": "phone", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "手机号码", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "Phone" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "create_time", + "field": "createTime", + "frontField": "userCreateTime", + "fieldCase": "CreateTime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "用户创建时间", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "UserCreateTime" + } + ], + "tableFormArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "userId", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "userId", + "frontFieldCase": "UserId" + }, + { + "columnType": "tinyint(1)", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "用户状态:0=正常,1=禁用", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "state", + "field": "state", + "fieldCase": "State", + "originField": "state", + "tbName": "state", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "用户状态", + "optionData": "0=正常,1=禁用", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0", + "label": "正常" + }, + { + "value": "1", + "label": "禁用" + } + ], + "frontField": "state", + "frontFieldCase": "State" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "userName", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "姓名", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "userName", + "frontFieldCase": "UserName" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "头像图片地址", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "head_img_url", + "field": "headImgUrl", + "fieldCase": "HeadImgUrl", + "originField": "head_img_url", + "tbName": "head_img_url", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "头像图片地址", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "headImgUrl", + "frontFieldCase": "HeadImgUrl" + }, + { + "columnType": "varchar(11)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "手机号码", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "phone", + "field": "phone", + "fieldCase": "Phone", + "originField": "phone", + "tbName": "phone", + "type": "String", + "componentType": "input", + "rule": "phone", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "手机号码", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "userPhone", + "frontFieldCase": "UserPhone" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "create_time", + "field": "createTime", + "fieldCase": "CreateTime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "true", + "isNeedInput": "false", + "desc": "创建时间", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "createTime", + "frontFieldCase": "CreateTime" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "创建人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "creator", + "field": "creator", + "fieldCase": "Creator", + "originField": "creator", + "tbName": "creator", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "true", + "isNeedInput": "false", + "desc": "创建人", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "userCreator", + "frontFieldCase": "UserCreator" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "修改时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "update_time", + "field": "updateTime", + "fieldCase": "UpdateTime", + "originField": "update_time", + "tbName": "update_time", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "true", + "isNeedInput": "false", + "desc": "修改时间", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "updateTime", + "frontFieldCase": "UpdateTime" + } + ] + }, + { + "tableName": "userRole", + "originTableName": "t_user_role", + "tableDesc": "用户角色", + "tableNameCase": "UserRole", + "uniKey": "id", + "tableFieldArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "id", + "field": "id", + "desc": "ID", + "fieldCase": "Id", + "originField": "id", + "type": "Long" + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "用户ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "user_id", + "field": "userId", + "desc": "用户ID", + "fieldCase": "UserId", + "originField": "user_id", + "type": "Long" + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "角色ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "role_id", + "field": "roleId", + "desc": "角色ID", + "fieldCase": "RoleId", + "originField": "role_id", + "type": "Long" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "create_time", + "field": "createTime", + "desc": "创建时间", + "fieldCase": "CreateTime", + "originField": "create_time", + "type": "Date" + }, + { + "columnType": "varchar(36)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "创建人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "creator", + "field": "creator", + "desc": "创建人", + "fieldCase": "Creator", + "originField": "creator", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "修改时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "update_time", + "field": "updateTime", + "desc": "修改时间", + "fieldCase": "UpdateTime", + "originField": "update_time", + "type": "Date" + }, + { + "columnType": "varchar(36)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "修改人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "editor", + "field": "editor", + "desc": "修改人", + "fieldCase": "Editor", + "originField": "editor", + "type": "String" + }, + { + "columnType": "tinyint(1) unsigned", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "逻辑删除:0=未删除,1=已删除", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "deleted", + "field": "deleted", + "desc": "逻辑删除:0=未删除,1=已删除", + "fieldCase": "Deleted", + "originField": "deleted", + "type": "Integer" + } + ], + "orgUniKey": "id", + "uniKeyType": "Long", + "priKeyArr": [ + "user_id", + "role_id" + ], + "priKeyItemArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "id", + "field": "id", + "desc": "ID", + "fieldCase": "Id", + "originField": "id", + "type": "Long" + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "用户ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "user_id", + "field": "userId", + "desc": "用户ID", + "fieldCase": "UserId", + "originField": "user_id", + "type": "Long" + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "角色ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "role_id", + "field": "roleId", + "desc": "角色ID", + "fieldCase": "RoleId", + "originField": "role_id", + "type": "Long" + } + ], + "orgAssociationKey": [ + "user_id", + "role_id" + ], + "associationKey": "userId", + "associationKeyCase": "RoleId", + "associationKeyType": "Long", + "tableFormArr": [ + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "用户ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "user_id", + "field": "userId", + "frontField": "urUserId", + "fieldCase": "UserId", + "originField": "user_id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "frontFieldCase": "UrUserId", + "optionDataArr": [] + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "角色ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "role_id", + "field": "roleId", + "frontField": "roleId", + "fieldCase": "RoleId", + "originField": "role_id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "角色ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "frontFieldCase": "RoleId", + "optionDataArr": [] + } + ] + }, + { + "tableName": "role", + "originTableName": "t_role", + "tableDesc": "角色", + "tableNameCase": "Role", + "uniKey": "id", + "tableFieldArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "角色ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "id", + "field": "id", + "desc": "角色ID", + "fieldCase": "Id", + "originField": "id", + "type": "Long" + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "所属父级角色ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "parent_id", + "field": "parentId", + "desc": "所属父级角色ID", + "fieldCase": "ParentId", + "originField": "parent_id", + "type": "Long" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色唯一CODE代码", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "code", + "field": "code", + "desc": "角色唯一CODE代码", + "fieldCase": "Code", + "originField": "code", + "type": "String" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色名称", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "name", + "field": "name", + "desc": "角色名称", + "fieldCase": "Name", + "originField": "name", + "type": "String" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色介绍", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "intro", + "field": "intro", + "desc": "角色介绍", + "fieldCase": "Intro", + "originField": "intro", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "create_time", + "field": "createTime", + "desc": "创建时间", + "fieldCase": "CreateTime", + "originField": "create_time", + "type": "Date" + }, + { + "columnType": "varchar(36)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "创建人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "creator", + "field": "creator", + "desc": "创建人", + "fieldCase": "Creator", + "originField": "creator", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "修改时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "update_time", + "field": "updateTime", + "desc": "修改时间", + "fieldCase": "UpdateTime", + "originField": "update_time", + "type": "Date" + }, + { + "columnType": "varchar(36)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "修改人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "editor", + "field": "editor", + "desc": "修改人", + "fieldCase": "Editor", + "originField": "editor", + "type": "String" + }, + { + "columnType": "tinyint(1) unsigned", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "逻辑删除:0=未删除,1=已删除", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "deleted", + "field": "deleted", + "desc": "逻辑删除:0=未删除,1=已删除", + "fieldCase": "Deleted", + "originField": "deleted", + "type": "Integer" + } + ], + "orgUniKey": "id", + "uniKeyType": "Long", + "priKeyArr": [ + "id", + "parent_id", + "code" + ], + "priKeyItemArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "角色ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "id", + "field": "id", + "desc": "角色ID", + "fieldCase": "Id", + "originField": "id", + "type": "Long" + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "所属父级角色ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "parent_id", + "field": "parentId", + "desc": "所属父级角色ID", + "fieldCase": "ParentId", + "originField": "parent_id", + "type": "Long" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色唯一CODE代码", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "code", + "field": "code", + "desc": "角色唯一CODE代码", + "fieldCase": "Code", + "originField": "code", + "type": "String" + } + ], + "orgAssociationKey": [ + "id" + ], + "associationKey": "code", + "associationKeyCase": "Code", + "associationKeyType": "String", + "tableQueryArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "角色ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "id", + "field": "id", + "desc": "角色ID", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "frontField": "roleId", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [], + "frontFieldCase": "RoleId" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色名称", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "name", + "field": "name", + "desc": "角色名称", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "frontField": "roleName", + "componentType": "input", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [], + "frontFieldCase": "RoleName" + } + ], + "tableShowArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "角色ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "id", + "field": "id", + "frontField": "id", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "角色ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "Id" + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "所属父级角色ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "parent_id", + "field": "parentId", + "frontField": "parentId", + "fieldCase": "ParentId", + "originField": "parent_id", + "tbName": "parent_id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "所属父级角色ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "ParentId" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色唯一CODE代码", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "code", + "field": "code", + "frontField": "code", + "fieldCase": "Code", + "originField": "code", + "tbName": "code", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "角色唯一CODE代码", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "Code" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色名称", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "name", + "field": "name", + "frontField": "roleName", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "角色名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "RoleName" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色介绍", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "intro", + "field": "intro", + "frontField": "intro", + "fieldCase": "Intro", + "originField": "intro", + "tbName": "intro", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "角色介绍", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "Intro" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "create_time", + "field": "createTime", + "fieldCase": "CreateTime", + "originField": "create_time", + "frontField": "roleCreateTime", + "tbName": "create_time", + "type": "Date", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "角色创建时间", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "width": 120, + "optionDataArr": [], + "frontFieldCase": "RoleCreateTime" + } + ] + } + ], + "dbTableConfig": { + "multiTableName": "urMul", + "multiTableNameCase": "UrMul", + "multiTableDesc": "用户角色", + "associationType": "多对多", + "tableName": "user", + "originTableName": "t_user", + "tableDesc": "用户", + "tableNameCase": "User", + "uniKey": "id", + "tableFieldArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "desc": "用户ID", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long" + }, + { + "columnType": "tinyint(1)", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "用户状态:0=正常,1=禁用", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "state", + "field": "state", + "desc": "用户状态:0=正常,1=禁用", + "fieldCase": "State", + "originField": "state", + "tbName": "state", + "type": "Integer" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "desc": "姓名", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "头像图片地址", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "head_img_url", + "field": "headImgUrl", + "desc": "头像图片地址", + "fieldCase": "HeadImgUrl", + "originField": "head_img_url", + "tbName": "head_img_url", + "type": "String" + }, + { + "columnType": "varchar(11)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "手机号码", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "phone", + "field": "phone", + "desc": "手机号码", + "fieldCase": "Phone", + "originField": "phone", + "tbName": "phone", + "type": "String" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "密码加盐", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "salt", + "field": "salt", + "desc": "密码加盐", + "fieldCase": "Salt", + "originField": "salt", + "tbName": "salt", + "type": "String" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "登录密码", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "password", + "field": "password", + "desc": "登录密码", + "fieldCase": "Password", + "originField": "password", + "tbName": "password", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "create_time", + "field": "createTime", + "desc": "创建时间", + "fieldCase": "CreateTime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "创建人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "creator", + "field": "creator", + "desc": "创建人", + "fieldCase": "Creator", + "originField": "creator", + "tbName": "creator", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "修改时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "update_time", + "field": "updateTime", + "desc": "修改时间", + "fieldCase": "UpdateTime", + "originField": "update_time", + "tbName": "update_time", + "type": "Date" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "修改人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "editor", + "field": "editor", + "desc": "修改人", + "fieldCase": "Editor", + "originField": "editor", + "tbName": "editor", + "type": "String" + }, + { + "columnType": "tinyint(1) unsigned", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "逻辑删除:0=未删除,1=已删除", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "deleted", + "field": "deleted", + "desc": "逻辑删除:0=未删除,1=已删除", + "fieldCase": "Deleted", + "originField": "deleted", + "tbName": "deleted", + "type": "Integer" + } + ], + "orgUniKey": "id", + "uniKeyType": "Long", + "priKeyArr": [ + "id" + ], + "priKeyItemArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "desc": "用户ID", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long" + } + ], + "orgAssociationKey": [ + "id" + ], + "associationKey": "id", + "associationKeyCase": "Id", + "associationKeyType": "Long", + "tableQueryArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "frontField": "userId", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [], + "frontFieldCase": "UserId" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "frontField": "userName", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "姓名", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [], + "frontFieldCase": "UserName" + } + ], + "tableShowArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "frontField": "userId", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "UserId" + }, + { + "columnType": "tinyint(1)", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "用户状态:0=正常,1=禁用", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "state", + "field": "state", + "frontField": "state", + "fieldCase": "State", + "originField": "state", + "tbName": "state", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "用户状态", + "optionData": "0=正常,1=禁用", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0", + "label": "正常" + }, + { + "value": "1", + "label": "禁用" + } + ], + "frontFieldCase": "State" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "frontField": "userName", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "姓名", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "UserName" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "头像图片地址", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "head_img_url", + "field": "headImgUrl", + "frontField": "headImgUrl", + "fieldCase": "HeadImgUrl", + "originField": "head_img_url", + "tbName": "head_img_url", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "头像图片地址", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "HeadImgUrl" + }, + { + "columnType": "varchar(11)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "手机号码", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "phone", + "field": "phone", + "frontField": "phone", + "fieldCase": "Phone", + "originField": "phone", + "tbName": "phone", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "手机号码", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "Phone" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "create_time", + "field": "createTime", + "frontField": "userCreateTime", + "fieldCase": "CreateTime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "用户创建时间", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "UserCreateTime" + } + ], + "tableFormArr": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "userId", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "userId", + "frontFieldCase": "UserId" + }, + { + "columnType": "tinyint(1)", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "用户状态:0=正常,1=禁用", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "state", + "field": "state", + "fieldCase": "State", + "originField": "state", + "tbName": "state", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "用户状态", + "optionData": "0=正常,1=禁用", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0", + "label": "正常" + }, + { + "value": "1", + "label": "禁用" + } + ], + "frontField": "state", + "frontFieldCase": "State" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "userName", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "姓名", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "userName", + "frontFieldCase": "UserName" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "头像图片地址", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "head_img_url", + "field": "headImgUrl", + "fieldCase": "HeadImgUrl", + "originField": "head_img_url", + "tbName": "head_img_url", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "头像图片地址", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "headImgUrl", + "frontFieldCase": "HeadImgUrl" + }, + { + "columnType": "varchar(11)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "手机号码", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "phone", + "field": "phone", + "fieldCase": "Phone", + "originField": "phone", + "tbName": "phone", + "type": "String", + "componentType": "input", + "rule": "phone", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "手机号码", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "userPhone", + "frontFieldCase": "UserPhone" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "create_time", + "field": "createTime", + "fieldCase": "CreateTime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "true", + "isNeedInput": "false", + "desc": "创建时间", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "createTime", + "frontFieldCase": "CreateTime" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "创建人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "creator", + "field": "creator", + "fieldCase": "Creator", + "originField": "creator", + "tbName": "creator", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "true", + "isNeedInput": "false", + "desc": "创建人", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "userCreator", + "frontFieldCase": "UserCreator" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "修改时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "update_time", + "field": "updateTime", + "fieldCase": "UpdateTime", + "originField": "update_time", + "tbName": "update_time", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "true", + "isNeedInput": "false", + "desc": "修改时间", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "updateTime", + "frontFieldCase": "UpdateTime" + } + ] + }, + "queryConfig": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "角色ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "id", + "field": "id", + "desc": "角色ID", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "frontField": "roleId", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [], + "frontFieldCase": "RoleId" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色名称", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "name", + "field": "name", + "desc": "角色名称", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "frontField": "roleName", + "componentType": "input", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [], + "frontFieldCase": "RoleName" + }, + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "fieldCase": "Id", + "originField": "id", + "frontField": "userId", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [], + "frontFieldCase": "UserId" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "fieldCase": "Name", + "originField": "name", + "frontField": "userName", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "notValid", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "姓名", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "label", + "valueKey": "value", + "optionDataArr": [], + "frontFieldCase": "UserName" + } + ], + "tableConfig": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "角色ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "id", + "field": "id", + "frontField": "id", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "角色ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "Id" + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "所属父级角色ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "parent_id", + "field": "parentId", + "frontField": "parentId", + "fieldCase": "ParentId", + "originField": "parent_id", + "tbName": "parent_id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "所属父级角色ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "ParentId" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色唯一CODE代码", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "code", + "field": "code", + "frontField": "code", + "fieldCase": "Code", + "originField": "code", + "tbName": "code", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "角色唯一CODE代码", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "Code" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色名称", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "name", + "field": "name", + "frontField": "roleName", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "角色名称", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "RoleName" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色介绍", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "intro", + "field": "intro", + "frontField": "intro", + "fieldCase": "Intro", + "originField": "intro", + "tbName": "intro", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "角色介绍", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "Intro" + }, + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "id", + "frontField": "userId", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "UserId" + }, + { + "columnType": "tinyint(1)", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "用户状态:0=正常,1=禁用", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "state", + "field": "state", + "frontField": "state", + "fieldCase": "State", + "originField": "state", + "tbName": "state", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "用户状态", + "optionData": "0=正常,1=禁用", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0", + "label": "正常" + }, + { + "value": "1", + "label": "禁用" + } + ], + "frontFieldCase": "State" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "name", + "frontField": "userName", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "姓名", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "UserName" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "头像图片地址", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "head_img_url", + "field": "headImgUrl", + "frontField": "headImgUrl", + "fieldCase": "HeadImgUrl", + "originField": "head_img_url", + "tbName": "head_img_url", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "头像图片地址", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "HeadImgUrl" + }, + { + "columnType": "varchar(11)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "手机号码", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "phone", + "field": "phone", + "frontField": "phone", + "fieldCase": "Phone", + "originField": "phone", + "tbName": "phone", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "手机号码", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "Phone" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "create_time", + "field": "createTime", + "frontField": "userCreateTime", + "fieldCase": "CreateTime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "width": 120, + "desc": "用户创建时间", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontFieldCase": "UserCreateTime" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "create_time", + "field": "createTime", + "fieldCase": "CreateTime", + "originField": "create_time", + "frontField": "roleCreateTime", + "tbName": "create_time", + "type": "Date", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "角色创建时间", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "width": 120, + "optionDataArr": [], + "frontFieldCase": "RoleCreateTime" + } + ], + "formConfig": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "用户ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "id", + "field": "userId", + "fieldCase": "Id", + "originField": "id", + "tbName": "id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "userId", + "frontFieldCase": "UserId" + }, + { + "columnType": "tinyint(1)", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "用户状态:0=正常,1=禁用", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "state", + "field": "state", + "fieldCase": "State", + "originField": "state", + "tbName": "state", + "type": "Integer", + "componentType": "select", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "用户状态", + "optionData": "0=正常,1=禁用", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [ + { + "value": "0", + "label": "正常" + }, + { + "value": "1", + "label": "禁用" + } + ], + "frontField": "state", + "frontFieldCase": "State" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "姓名", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "name", + "field": "userName", + "fieldCase": "Name", + "originField": "name", + "tbName": "name", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "姓名", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "userName", + "frontFieldCase": "UserName" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "头像图片地址", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "head_img_url", + "field": "headImgUrl", + "fieldCase": "HeadImgUrl", + "originField": "head_img_url", + "tbName": "head_img_url", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "false", + "desc": "头像图片地址", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "headImgUrl", + "frontFieldCase": "HeadImgUrl" + }, + { + "columnType": "varchar(11)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "手机号码", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "phone", + "field": "phone", + "fieldCase": "Phone", + "originField": "phone", + "tbName": "phone", + "type": "String", + "componentType": "input", + "rule": "phone", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "手机号码", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "userPhone", + "frontFieldCase": "UserPhone" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "create_time", + "field": "createTime", + "fieldCase": "CreateTime", + "originField": "create_time", + "tbName": "create_time", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "true", + "isNeedInput": "false", + "desc": "创建时间", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "createTime", + "frontFieldCase": "CreateTime" + }, + { + "columnType": "varchar(64)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "创建人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "creator", + "field": "creator", + "fieldCase": "Creator", + "originField": "creator", + "tbName": "creator", + "type": "String", + "componentType": "input", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "true", + "isNeedInput": "false", + "desc": "创建人", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "userCreator", + "frontFieldCase": "UserCreator" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "修改时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "columnName": "update_time", + "field": "updateTime", + "fieldCase": "UpdateTime", + "originField": "update_time", + "tbName": "update_time", + "type": "Date", + "componentType": "datetime", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "true", + "isNeedInput": "false", + "desc": "修改时间", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "optionDataArr": [], + "frontField": "updateTime", + "frontFieldCase": "UpdateTime" + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "用户ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "user_id", + "field": "userId", + "frontField": "urUserId", + "fieldCase": "UserId", + "originField": "user_id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "frontFieldCase": "UrUserId", + "optionDataArr": [] + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "角色ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "role_id", + "field": "roleId", + "frontField": "roleId", + "fieldCase": "RoleId", + "originField": "role_id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "角色ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "frontFieldCase": "RoleId", + "optionDataArr": [] + } + ], + "dataBaseUrl": "https://github.jzfai.top/micro-service-api/basis-func/dataBase/getAllDatabaseOrTable/micro-service-plus", + "dbRadio": [ + "t_role", + "t_user_role", + "t_user" + ], + "chooseDbRadio": "t_role", + "dbTableUrl": "https://github.jzfai.top/micro-service-api/basis-func/dataBase/getAllDatabaseOrTable/micro-service-plus", + "tbName": "t_role", + "checkColumnArr": [ + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "用户ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "user_id", + "field": "userId", + "frontField": "userId", + "fieldCase": "UserId", + "originField": "user_id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "用户ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "frontFieldCase": "UserId", + "optionDataArr": [] + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "角色ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "columnName": "role_id", + "field": "roleId", + "frontField": "roleId", + "fieldCase": "RoleId", + "originField": "role_id", + "type": "Long", + "componentType": "", + "rule": "isNotNull", + "value": "value", + "label": "label", + "children": "children", + "isNotShowSwagger": "false", + "isNeedInput": "true", + "desc": "角色ID", + "optionData": "", + "api": "", + "method": "get", + "labelKey": "name", + "valueKey": "code", + "frontFieldCase": "RoleId", + "optionDataArr": [] + } + ], + "chooseDbArr": [ + { + "createTime": "2022-09-16T06:46:07", + "tableComment": "角色", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "id": "f239e1a4-ef6b-4b56-b4bc-dd3bce4bd4e1" + }, + { + "createTime": "2022-09-16T06:46:07", + "tableComment": "用户角色", + "tableSchema": "micro-service-plus", + "tableName": "t_user_role", + "id": "5e47ce1b-1502-421d-acb3-899afc6b56cc" + }, + { + "createTime": "2022-09-16T06:46:07", + "tableComment": "用户", + "tableSchema": "micro-service-plus", + "tableName": "t_user", + "id": "e7b294e9-2ab9-467a-8b95-e49f96153868" + } + ], + "tbData": [ + { + "columnType": "bigint(20)", + "isNullable": "NO", + "dataType": "bigint", + "extra": "auto_increment", + "columnComment": "角色ID", + "columnKey": "PRI", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "id", + "field": "id", + "desc": "角色ID", + "fieldCase": "Id", + "originField": "id", + "type": "Long" + }, + { + "columnType": "bigint(20)", + "isNullable": "YES", + "dataType": "bigint", + "extra": "", + "columnComment": "所属父级角色ID", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "parent_id", + "field": "parentId", + "desc": "所属父级角色ID", + "fieldCase": "ParentId", + "originField": "parent_id", + "type": "Long" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色唯一CODE代码", + "columnKey": "MUL", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "code", + "field": "code", + "desc": "角色唯一CODE代码", + "fieldCase": "Code", + "originField": "code", + "type": "String" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色名称", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "name", + "field": "name", + "desc": "角色名称", + "fieldCase": "Name", + "originField": "name", + "type": "String" + }, + { + "columnType": "varchar(255)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "角色介绍", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "intro", + "field": "intro", + "desc": "角色介绍", + "fieldCase": "Intro", + "originField": "intro", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "创建时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "create_time", + "field": "createTime", + "desc": "创建时间", + "fieldCase": "CreateTime", + "originField": "create_time", + "type": "Date" + }, + { + "columnType": "varchar(36)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "创建人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "creator", + "field": "creator", + "desc": "创建人", + "fieldCase": "Creator", + "originField": "creator", + "type": "String" + }, + { + "columnType": "datetime", + "isNullable": "YES", + "dataType": "datetime", + "extra": "", + "columnComment": "修改时间", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "update_time", + "field": "updateTime", + "desc": "修改时间", + "fieldCase": "UpdateTime", + "originField": "update_time", + "type": "Date" + }, + { + "columnType": "varchar(36)", + "isNullable": "YES", + "dataType": "varchar", + "extra": "", + "columnComment": "修改人", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "editor", + "field": "editor", + "desc": "修改人", + "fieldCase": "Editor", + "originField": "editor", + "type": "String" + }, + { + "columnType": "tinyint(1) unsigned", + "isNullable": "YES", + "dataType": "tinyint", + "extra": "", + "columnComment": "逻辑删除:0=未删除,1=已删除", + "columnKey": "", + "tableSchema": "micro-service-plus", + "tableName": "t_role", + "columnName": "deleted", + "field": "deleted", + "desc": "逻辑删除:0=未删除,1=已删除", + "fieldCase": "Deleted", + "originField": "deleted", + "type": "Integer" + } + ] +} \ No newline at end of file From a4b0d83bf6ce6d5dab0cd8cb5a62571f2258e16f Mon Sep 17 00:00:00 2001 From: kuanghua <869653722qq.com> Date: Wed, 12 Oct 2022 19:44:44 +0800 Subject: [PATCH 31/36] add role --- .../controller/MybatisPlusController.java | 59 ++ .../basisfunc/controller/RoleController.java | 137 +++ .../top/kuanghua/basisfunc/entity/Role.java | 55 ++ .../kuanghua/basisfunc/mapper/RoleMapper.java | 15 + .../service/MybatisPlusGeneratorService.java | 32 +- .../basisfunc/service/RoleService.java | 51 + .../src/main/resources/application-db.yml | 6 +- .../controller/ConfigSaveController.java | 134 +++ .../integrationfront/entity/ConfigSave.java | 42 + .../mapper/ConfigSaveMapper.java | 15 + .../service/ConfigSaveService.java | 51 + .../integrationfront/vo/ConfigSaveVo.java | 36 + .../mybatis-plus-multi/controllerMul.vm | 8 +- .../back-vms/mybatis-plus-multi/mapperMul.vm | 2 +- .../{entityVo.vm => query.vm} | 3 +- .../back-vms/mybatis-plus-multi/serviceMul.vm | 4 +- .../back-vms/mybatis-plus-multi/utils.vm | 10 +- .../back-vms/mybatis-plus-multi/vo.vm | 19 + .../back-vms/mybatis-plus/controller.vm | 6 +- .../back-vms/mybatis-plus/utils.vm | 11 +- velocity-tmp-dir/back-vms/mybatis-plus/vo.vm | 19 + .../front-vms/element-plus/routerItem.vm | 58 +- velocity-tmp-dir/json-data/tb_brand.json | 877 ------------------ 23 files changed, 712 insertions(+), 938 deletions(-) create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/controller/MybatisPlusController.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/controller/RoleController.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/entity/Role.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/mapper/RoleMapper.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/service/RoleService.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/controller/ConfigSaveController.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/entity/ConfigSave.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/mapper/ConfigSaveMapper.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/service/ConfigSaveService.java create mode 100644 integration-front/src/main/java/top/kuanghua/integrationfront/vo/ConfigSaveVo.java rename velocity-tmp-dir/back-vms/mybatis-plus-multi/{entityVo.vm => query.vm} (89%) create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus-multi/vo.vm create mode 100644 velocity-tmp-dir/back-vms/mybatis-plus/vo.vm delete mode 100644 velocity-tmp-dir/json-data/tb_brand.json diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/controller/MybatisPlusController.java b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/MybatisPlusController.java new file mode 100644 index 0000000..55768a0 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/MybatisPlusController.java @@ -0,0 +1,59 @@ +package top.kuanghua.basisfunc.controller; + +import com.alibaba.fastjson.JSON; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import top.kuanghua.basisfunc.service.GeneratorCustromService; +import top.kuanghua.basisfunc.service.GeneratorService; +import top.kuanghua.basisfunc.service.MybatisPlusGeneratorService; +import top.kuanghua.basisfunc.utils.GeneratorTempUtils; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + +/** + * @author 猫哥 + * @email kuanghua@aulton.com + * @date 2022-06-06 13:39 + * @Copyright Copyright (c) aulton Inc. All Rights Reserved. + **/ +@Api(tags = "模板生成") +@RestController +@RequestMapping("mybatis-plus") +public class MybatisPlusController { + @Resource + private MybatisPlusGeneratorService mybatisPlusGeneratorService; + + + @ApiOperation(value = "基础模板生成") + @PostMapping("generatorMybatisPlusBasicTmp") + public void generatorMybatisPlusBasicTmp(HttpServletResponse response, @RequestBody Map generatorData) { + //生成模板 + String exportFilePath = this.mybatisPlusGeneratorService.generatorMybatisPlusBasicTmp(generatorData); + response.setContentType("application/zip"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Access-Control-Expose-Headers", "exportFileName"); + response.setHeader("exportFileName", "MybatisPlusBasic" + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"); + //你压缩包路径 + GeneratorTempUtils.downloadZip(response, exportFilePath); + } + + @ApiOperation(value = "多表生成") + @PostMapping("generatorMybatisPlusMulTemp") + public void generatorMybatisPlusMulTemp(HttpServletResponse response, @RequestBody Map generatorData) { + //生成模板 + String exportFilePath = this.mybatisPlusGeneratorService.generatorMybatisPlusMulTemp(generatorData); + response.setContentType("application/zip"); + response.setCharacterEncoding("utf-8"); + response.setHeader("Access-Control-Expose-Headers", "exportFileName"); + response.setHeader("exportFileName", "generatorMybatisPlusMulTemp-" + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"); + //你压缩包路径 + GeneratorTempUtils.downloadZip(response, exportFilePath); + } + +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/controller/RoleController.java b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/RoleController.java new file mode 100644 index 0000000..9a5853a --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/RoleController.java @@ -0,0 +1,137 @@ + + + +package top.kuanghua.basisfunc.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +import javax.annotation.Resource; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import top.kuanghua.basisfunc.entity.Role; +import top.kuanghua.basisfunc.service.RoleService; +import top.kuanghua.commonpom.entity.ResResult; +import top.kuanghua.commonpom.entity.SelfCommonParams; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import java.util.List; + +/** + * 角色Controller + * + * @author 熊猫哥 + * @since 2022-10-07 16:33:13 + */ +@Api(tags = "角色(Role)") +@RestController +@RequestMapping("role") +@Validated +public class RoleController { + + @Resource + private RoleService roleService; + + /** + * 分页查询所有数据 + * + * @return ResResult + */ + @GetMapping("selectPage") + @ApiOperation(value = "分页查询所有数据") + + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "角色ID", paramType = "query"), + @ApiImplicitParam(name = "name", value = "角色名称", paramType = "query"), + }) + public ResResult> selectPage(String id, + String name, + SelfCommonParams commonParams) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + //角色ID + if (ObjSelfUtils.isNotEmpty(id)) { + queryWrapper.like("id", id); + } + //角色名称 + if (ObjSelfUtils.isNotEmpty(name)) { + queryWrapper.like("name", name); + } + + queryWrapper.select("id,parent_id,code,name,intro,permission_id,deleted"); + + Page rolePage = this.roleService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); + return new ResResult().success(rolePage); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("selectById") + @ApiOperation(value = "通过id主键查询单条数据") + public ResResult selectById(@RequestParam("id") Long id) { + return new ResResult().success(this.roleService.selectById(id)); + } + + /** + * @Description: 根据id数组查询列表 + * @Param: idList id数组 + * @return: ids列表数据 + */ + @ApiOperation(value = "根据id数组查询列表") + @PostMapping("selectBatchIds") + public ResResult> selectBatchIds(@RequestParam("idList") List idList) { + return new ResResult().success(this.roleService.selectBatchIds(idList)); + } + + /** + * 新增数据 + * + * @param role 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping("insert") + public ResResult insert(@Validated @RequestBody Role role) { + return new ResResult().success(this.roleService.insert(role)); + } + + /** + * 修改数据 + * + * @param role 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "根据id修改数据") + @PutMapping("updateById") + public ResResult updateById(@Validated @RequestBody Role role) { + return new ResResult().success(this.roleService.updateById(role)); + } + + /** + * 删除数据 + * + * @param idList 主键结合 + * @return 删除结果 + */ + @ApiOperation(value = "根据id数组删除数据") + @DeleteMapping("deleteBatchIds") + public ResResult deleteBatchIds(@RequestBody List idList) { + return new ResResult().success(this.roleService.deleteBatchIds(idList)); + } + + @ApiOperation("根据id删除数据") + @DeleteMapping("deleteById") + public ResResult deleteById(@RequestParam("id") Long id) { + return new ResResult().success(this.roleService.deleteById(id)); + } +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/entity/Role.java b/basis-func/src/main/java/top/kuanghua/basisfunc/entity/Role.java new file mode 100644 index 0000000..910ffde --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/entity/Role.java @@ -0,0 +1,55 @@ + + + +package top.kuanghua.basisfunc.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; + +/** + * 角色实体类 + * + * @author 熊猫哥 + * @since 2022-10-07 16:33:13 + */ +@Data +@ApiModel("角色") +@TableName(value = "t_role") +public class Role extends Model { + @ApiModelProperty(value = "角色ID", hidden = false) + private Long id; + @ApiModelProperty(value = "所属父级角色ID", hidden = false) + private Long parentId; + @ApiModelProperty(value = "角色唯一CODE代码", hidden = false) + private String code; + @ApiModelProperty(value = "角色名称", hidden = false) + @NotBlank(message = "userId不能为空") + private String name; + @ApiModelProperty(value = "角色介绍", hidden = false) + @NotBlank(message = "userId不能为空") + private String intro; + @ApiModelProperty(value = "权限id(字符数组)", hidden = false) + @NotBlank(message = "userId不能为空") + private String permissionId; + @ApiModelProperty(value = "逻辑删除", hidden = false) + private Integer deleted; + + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/mapper/RoleMapper.java b/basis-func/src/main/java/top/kuanghua/basisfunc/mapper/RoleMapper.java new file mode 100644 index 0000000..fb388cb --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/mapper/RoleMapper.java @@ -0,0 +1,15 @@ +package top.kuanghua.basisfunc.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.basisfunc.entity.Role; + +/** + * 角色Mapper + * + * @author 熊猫哥 + * @since 2022-10-07 16:33:13 + */ + +public interface RoleMapper extends BaseMapper { + +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorService.java b/basis-func/src/main/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorService.java index a5bb46e..f804ae0 100644 --- a/basis-func/src/main/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorService.java +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/service/MybatisPlusGeneratorService.java @@ -43,16 +43,25 @@ public String generatorMybatisPlusBasicTmp(Map jsonData) { FileWriter entityWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "entity") + tbName + ".java"); entityTemp.merge(context, entityWriter); entityWriter.close(); + + //vo + Template voTemp = GeneratorTempUtils.getMybatisPlusTemp("vo.vm"); + FileWriter voWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "vo") + tbName + "Vo.java"); + voTemp.merge(context, voWriter); + voWriter.close(); + //controller Template controllerTemp = GeneratorTempUtils.getMybatisPlusTemp("controller.vm"); FileWriter controllerWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "controller") + tbName + "Controller.java"); controllerTemp.merge(context, controllerWriter); controllerWriter.close(); + //service Template serviceTemp = GeneratorTempUtils.getMybatisPlusTemp("service.vm"); FileWriter serviceWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "service") + tbName + "Service.java"); serviceTemp.merge(context, serviceWriter); serviceWriter.close(); + //mapper Template mapperTemp = GeneratorTempUtils.getMybatisPlusTemp("mapper.vm"); FileWriter mapperWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "mapper") + tbName + "Mapper.java"); @@ -72,8 +81,10 @@ public String generatorMybatisPlusBasicTmp(Map jsonData) { /** * Mybatis-plus 多表生成 + * + * @return */ - public void generatorMybatisPlusMulTemp(Map jsonData) { + public String generatorMybatisPlusMulTemp(Map jsonData) { Context context = GeneratorTempUtils.getVelocityContext(); context.put("totalData", jsonData); context.put("basicConfig", jsonData.get("basicConfig")); @@ -131,11 +142,17 @@ public void generatorMybatisPlusMulTemp(Map jsonData) { mapperMulTemp.merge(context, mapperMulWriter); mapperMulWriter.close(); - //entity-vo - Template entityVoTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entityVo.vm"); - FileWriter entityVoWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "vo") + tbName + "Vo.java"); - entityVoTemp.merge(context, entityVoWriter); - entityVoWriter.close(); + //query + Template queryTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("query.vm"); + FileWriter queryWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "query") + tbName + "Query.java"); + queryTemp.merge(context, queryWriter); + queryWriter.close(); + + //vo + Template voTemp = GeneratorTempUtils.getMybatisPlusTemp("vo.vm"); + FileWriter voWriter = new FileWriter(GeneratorTempUtils.getExportMybatisPlusDir(packagePath, "vo") + tbName + "Vo.java"); + voTemp.merge(context, voWriter); + voWriter.close(); //entity-mul Template entityMulTemp = GeneratorTempUtils.getMybatisPlusMulTbTemp("entityMul.vm"); @@ -151,6 +168,9 @@ public void generatorMybatisPlusMulTemp(Map jsonData) { String exportFilePath = GeneratorTempUtils.getOutputZipPath() + ObjSelfUtils.getCurrentDateTimeTrim() + ".zip"; //生成zip包 GeneratorTempUtils.createZipFile(exportFilePath, GeneratorTempUtils.getNeedZipDir()); + + + return exportFilePath; } catch (IOException e) { throw new RuntimeException("生成实体类报错" + e); } diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/service/RoleService.java b/basis-func/src/main/java/top/kuanghua/basisfunc/service/RoleService.java new file mode 100644 index 0000000..02fce09 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/service/RoleService.java @@ -0,0 +1,51 @@ +package top.kuanghua.basisfunc.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Service; +import top.kuanghua.basisfunc.entity.Role; +import top.kuanghua.basisfunc.mapper.RoleMapper; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 角色Service + * + * @author 熊猫哥 + * @since 2022-10-07 16:33:13 + */ +@Service +public class RoleService { + + @Resource + private RoleMapper roleMapper; + + public Page selectPage(Integer pageNum, Integer pageSize, QueryWrapper queryWrapper) { + return this.roleMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); + } + + public Role selectById(Long id) { + return this.roleMapper.selectById(id); + } + + public List selectBatchIds(List idList) { + return this.roleMapper.selectBatchIds(idList); + } + + public int insert(Role role) { + return this.roleMapper.insert(role); + } + + public int updateById(Role role) { + return this.roleMapper.updateById(role); + } + + public int deleteById(Long id) { + return this.roleMapper.deleteById(id); + } + + public int deleteBatchIds(List idList) { + return this.roleMapper.deleteBatchIds(idList); + } +} diff --git a/basis-func/src/main/resources/application-db.yml b/basis-func/src/main/resources/application-db.yml index 49a0e3f..a5f08cf 100644 --- a/basis-func/src/main/resources/application-db.yml +++ b/basis-func/src/main/resources/application-db.yml @@ -4,13 +4,11 @@ spring: url: jdbc:p6spy:mysql://${envpt.mysqlIp}:${envpt.mysqlPort}/micro-service-plus?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&useSSL=false username: root password: root123 - #hikari: + #hikari: #最大连接数 #maximum-pool-size: 50 #最大超时时间 - #connection-timeout: 600000 - - + #connection-timeout: 600000 mybatis-plus: mapper-locations: classpath:/mapper/*Mapper.xml #实体扫描,多个package用逗号或者分号分隔 diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/controller/ConfigSaveController.java b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/ConfigSaveController.java new file mode 100644 index 0000000..f44d6b5 --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/controller/ConfigSaveController.java @@ -0,0 +1,134 @@ + + + +package top.kuanghua.integrationfront.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +import javax.annotation.Resource; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import top.kuanghua.commonpom.entity.ResResult; +import top.kuanghua.commonpom.entity.SelfCommonParams; +import top.kuanghua.commonpom.utils.ObjSelfUtils; +import top.kuanghua.integrationfront.entity.ConfigSave; +import top.kuanghua.integrationfront.service.ConfigSaveService; +import top.kuanghua.integrationfront.vo.ConfigSaveVo; + +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.List; + +/** + * 代码生成配置保存Controller + * + * @author 熊猫哥 + * @since 2022-10-07 16:33:13 + */ +@Api(tags = "代码生成配置保存(ConfigSave)") +@RestController +@RequestMapping("configSave") +@Validated +public class ConfigSaveController { + + @Resource + private ConfigSaveService configSaveService; + + /** + * 分页查询所有数据 + * + * @return ResResult + */ + @GetMapping("selectPage") + @ApiOperation(value = "分页查询所有数据") + + @ApiImplicitParams({ + @ApiImplicitParam(name = "name", value = "选中的字段配置", paramType = "query"), + }) + public ResResult> selectPage(String name, + SelfCommonParams commonParams) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + //选中的字段配置 + if (ObjSelfUtils.isNotEmpty(name)) { + queryWrapper.like("name", name); + } + + queryWrapper.select("name,generator_config,id"); + queryWrapper.orderByDesc("id"); + Page configSavePage = this.configSaveService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); + return new ResResult().success(configSavePage); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("selectById") + @ApiOperation(value = "通过id主键查询单条数据") + public ResResult selectById(@RequestParam("id") Integer id) { + return new ResResult().success(this.configSaveService.selectById(id)); + } + + /** + * @Description: 根据id数组查询列表 + * @Param: idList id数组 + * @return: ids列表数据 + */ + @ApiOperation(value = "根据id数组查询列表") + @PostMapping("selectBatchIds") + public ResResult> selectBatchIds(@RequestParam("idList") List idList) { + return new ResResult().success(this.configSaveService.selectBatchIds(idList)); + } + + /** + * 新增数据 + * + * @param configSave 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping("insert") + public ResResult insert(@Validated @RequestBody ConfigSave configSave) { + return new ResResult().success(this.configSaveService.insert(configSave)); + } + + /** + * 修改数据 + * + * @param configSave 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "根据id修改数据") + @PutMapping("updateById") + public ResResult updateById(@Validated @RequestBody ConfigSave configSave) { + return new ResResult().success(this.configSaveService.updateById(configSave)); + } + + /** + * 删除数据 + * + * @param idList 主键结合 + * @return 删除结果 + */ + @ApiOperation(value = "根据id数组删除数据") + @DeleteMapping("deleteBatchIds") + public ResResult deleteBatchIds(@RequestBody List idList) { + return new ResResult().success(this.configSaveService.deleteBatchIds(idList)); + } + + @ApiOperation("根据id删除数据") + @DeleteMapping("deleteById") + public ResResult deleteById(@RequestParam("id") Integer id) { + return new ResResult().success(this.configSaveService.deleteById(id)); + } +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/entity/ConfigSave.java b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/ConfigSave.java new file mode 100644 index 0000000..afee0f1 --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/entity/ConfigSave.java @@ -0,0 +1,42 @@ + + +package top.kuanghua.integrationfront.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; + +/** + * 代码生成配置保存实体类 + * + * @author 熊猫哥 + * @since 2022-10-07 16:33:13 + */ +@Data +@ApiModel("代码生成配置保存") +@TableName(value = "t_config_save") +public class ConfigSave extends Model { + @ApiModelProperty(value = "选中的字段配置", hidden = false) + private String name; + @ApiModelProperty(value = "生成的配置", hidden = false) + private String generatorConfig; + @ApiModelProperty(value = "主键id", hidden = false) + private Integer id; + + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/ConfigSaveMapper.java b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/ConfigSaveMapper.java new file mode 100644 index 0000000..1f8cd38 --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/mapper/ConfigSaveMapper.java @@ -0,0 +1,15 @@ +package top.kuanghua.integrationfront.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.integrationfront.entity.ConfigSave; + +/** + * 代码生成配置保存Mapper + * + * @author 熊猫哥 + * @since 2022-10-07 16:33:13 + */ + +public interface ConfigSaveMapper extends BaseMapper { + +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/service/ConfigSaveService.java b/integration-front/src/main/java/top/kuanghua/integrationfront/service/ConfigSaveService.java new file mode 100644 index 0000000..b6abe89 --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/service/ConfigSaveService.java @@ -0,0 +1,51 @@ +package top.kuanghua.integrationfront.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Service; +import top.kuanghua.integrationfront.entity.ConfigSave; +import top.kuanghua.integrationfront.mapper.ConfigSaveMapper; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 代码生成配置保存Service + * + * @author 熊猫哥 + * @since 2022-10-07 16:33:13 + */ +@Service +public class ConfigSaveService { + + @Resource + private ConfigSaveMapper configSaveMapper; + + public Page selectPage(Integer pageNum, Integer pageSize, QueryWrapper queryWrapper) { + return this.configSaveMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); + } + + public ConfigSave selectById(Integer id) { + return this.configSaveMapper.selectById(id); + } + + public List selectBatchIds(List idList) { + return this.configSaveMapper.selectBatchIds(idList); + } + + public int insert(ConfigSave configSave) { + return this.configSaveMapper.insert(configSave); + } + + public int updateById(ConfigSave configSave) { + return this.configSaveMapper.updateById(configSave); + } + + public int deleteById(Integer id) { + return this.configSaveMapper.deleteById(id); + } + + public int deleteBatchIds(List idList) { + return this.configSaveMapper.deleteBatchIds(idList); + } +} diff --git a/integration-front/src/main/java/top/kuanghua/integrationfront/vo/ConfigSaveVo.java b/integration-front/src/main/java/top/kuanghua/integrationfront/vo/ConfigSaveVo.java new file mode 100644 index 0000000..a8dc1ed --- /dev/null +++ b/integration-front/src/main/java/top/kuanghua/integrationfront/vo/ConfigSaveVo.java @@ -0,0 +1,36 @@ + + +package top.kuanghua.integrationfront.vo; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * 代码生成配置保存实体类 + * + * @author 熊猫哥 + * @since 2022-10-07 16:33:13 + */ +@Data +@ApiModel("代码生成配置保存") +public class ConfigSaveVo extends Model { + @ApiModelProperty(value = "主键id", hidden = false) + private Integer id; + @ApiModelProperty(value = "选中的字段配置", hidden = false) + private String name; + + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/controllerMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/controllerMul.vm index 9d136dc..ef9dde1 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus-multi/controllerMul.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/controllerMul.vm @@ -20,8 +20,8 @@ private ${dbTableConfig.multiTableNameCase}Service ${dbTableConfig.multiTableNam @ApiOperation(value = "分页查询${dbTableConfig.multiTableDesc}") @GetMapping("select${dbTableConfig.multiTableNameCase}") -public Page< Map > select${dbTableConfig.multiTableNameCase}(@Validated ${dbTableConfig.multiTableNameCase}Vo ${dbTableConfig.multiTableName}Vo,SelfCommonParams commonParams) { -return ${dbTableConfig.multiTableName}Service.select${dbTableConfig.multiTableNameCase}(commonParams, ${dbTableConfig.multiTableName}Vo); +public Page< ${dbTableConfig.multiTableNameCase}Query > select${dbTableConfig.multiTableNameCase}(@Validated ${dbTableConfig.multiTableNameCase}Query ${dbTableConfig.multiTableName}Query,SelfCommonParams commonParams) { +return ${dbTableConfig.multiTableName}Service.select${dbTableConfig.multiTableNameCase}(commonParams, ${dbTableConfig.multiTableName}Query); } /** @@ -46,7 +46,7 @@ return new ResResult().success(); */ @GetMapping("selectByKey") @ApiOperation(value = "通过联合key查询详情") -public ResResult selectByKey(@RequestParam("${dbTableConfig.associationKey}") ${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { +public ResResult< ${dbTableConfig.multiTableNameCase}Query > selectByKey(@RequestParam("${dbTableConfig.associationKey}") ${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { return new ResResult().success(${dbTableConfig.multiTableName}Service.selectByKey(${dbTableConfig.associationKey})); } @@ -75,4 +75,4 @@ public ResResult deleteByKey(@RequestParam("${dbTableConfig.associationKey}") ${ this.${dbTableConfig.multiTableName}Service.deleteByKey(${dbTableConfig.associationKey}); return new ResResult().success(); } -} +} \ No newline at end of file diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/mapperMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/mapperMul.vm index 05ee442..e5fdfe1 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus-multi/mapperMul.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/mapperMul.vm @@ -10,7 +10,7 @@ import java.util.*; * @since ${basicConfig.dataTime} */ public interface ${dbTableConfig.multiTableNameCase}Mapper { -Page< Map > select${dbTableConfig.multiTableNameCase}(Page< Map > pagination,@Param("params") ${dbTableConfig.multiTableNameCase}Vo params); +Page< Map > select${dbTableConfig.multiTableNameCase}(Page< Map > pagination,@Param("params") ${dbTableConfig.multiTableNameCase}Query params); Map selectByKey(@Param("${firstTbConfig.associationKey}") ${firstTbConfig.associationKeyType} ${firstTbConfig.associationKey}); } diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/entityVo.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/query.vm similarity index 89% rename from velocity-tmp-dir/back-vms/mybatis-plus-multi/entityVo.vm rename to velocity-tmp-dir/back-vms/mybatis-plus-multi/query.vm index 114e298..10c8974 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus-multi/entityVo.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/query.vm @@ -11,11 +11,10 @@ import java.util.*; */ @Data @ApiModel("${dbTableConfig.multiTableDesc}") -public class ${dbTableConfig.multiTableNameCase}Vo { +public class ${dbTableConfig.multiTableNameCase}Query { #foreach( $qItem in $queryConfig) @ApiModelProperty(value = "$qItem.desc") #getValid($qItem) private ${qItem.type} $qItem.frontField; #end - } diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/serviceMul.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/serviceMul.vm index 28b9e8e..1a5ad21 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus-multi/serviceMul.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/serviceMul.vm @@ -31,8 +31,8 @@ private ${dbTableConfig.multiTableNameCase}Mapper ${dbTableConfig.multiTableName private ${mtcItem.tableNameCase}Mapper ${mtcItem.tableName}Mapper; #end -public Page< Map > select${dbTableConfig.multiTableNameCase}(SelfCommonParams commonParams, ${dbTableConfig.multiTableNameCase}Vo ${dbTableConfig.multiTableName}Vo) { -return ${dbTableConfig.multiTableName}Mapper.select${dbTableConfig.multiTableNameCase}(new Page< Map >(commonParams.getPageNum(), commonParams.getPageSize()), ${dbTableConfig.multiTableName}Vo); +public Page< Map > select${dbTableConfig.multiTableNameCase}(SelfCommonParams commonParams, ${dbTableConfig.multiTableNameCase}Query ${dbTableConfig.multiTableName}Query) { +return ${dbTableConfig.multiTableName}Mapper.select${dbTableConfig.multiTableNameCase}(new Page< Map >(commonParams.getPageNum(), commonParams.getPageSize()), ${dbTableConfig.multiTableName}Query); } public Map selectByKey(${dbTableConfig.associationKeyType} ${dbTableConfig.associationKey}) { diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/utils.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/utils.vm index e580bbb..0efdcde 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus-multi/utils.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/utils.vm @@ -8,11 +8,11 @@ #macro(getValid $item) #if($item.isNeedInput=="true") #if(${item.type}=="Long") - @NotNull(message = "userId不能为空") + @NotNull(message = "${item.field}不能为空") #elseif(${item.type}=="Integer") - @NotNull(message = "userId不能为空") + @NotNull(message = "${item.field}不能为空") #elseif(${item.type}=="String") - @NotBlank(message = "userId不能为空") + @NotBlank(message = "${item.field}不能为空") #elseif(${item.type}=="List") @NotEmpty(message = "${item.field}不能为空") #end @@ -32,16 +32,12 @@ #end #end - #macro(getQueryField) #foreach($item in $queryConfig) #if($item.isNotShowSwagger=="true")@ApiIgnore()#end #getValid($item) String $item.field, #end #end - - - #macro(getSwaggerParam) @ApiImplicitParams({ #foreach($item in $queryConfig) diff --git a/velocity-tmp-dir/back-vms/mybatis-plus-multi/vo.vm b/velocity-tmp-dir/back-vms/mybatis-plus-multi/vo.vm new file mode 100644 index 0000000..cf1b2f7 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus-multi/vo.vm @@ -0,0 +1,19 @@ +#parse("utils.vm") +package ${basicConfig.packageName}.entity; +import java.util.Date; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; +/** +* ${dbTableConfig.tableDesc}实体类 +* +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} +*/ +@Data +@ApiModel("${dbTableConfig.tableDesc}") +public class ${dbTableConfig.tableNameCase}Vo { +#foreach($item in $tableConfig) +@ApiModelProperty(value = "$item.desc") +private ${item.type} $item.field; +#end +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/controller.vm b/velocity-tmp-dir/back-vms/mybatis-plus/controller.vm index 4c4876c..bc5559d 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus/controller.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus/controller.vm @@ -29,7 +29,7 @@ private ${dbTableConfig.tableNameCase}Service ${dbTableConfig.tableName}Service; @ApiOperation(value = "分页查询所有数据") #getSwaggerParam() -public ResResult selectPage(#getQueryField() SelfCommonParams commonParams) { +public ResResult< List<${dbTableConfig.tableNameCase}> > selectPage(#getQueryField() SelfCommonParams commonParams) { QueryWrapper <${dbTableConfig.tableNameCase}> queryWrapper = new QueryWrapper<>(); #foreach($item in $queryConfig) #if(${item.originField}=="create_time") @@ -60,7 +60,7 @@ return new ResResult().success(${dbTableConfig.tableName}Page); */ @GetMapping("selectById") @ApiOperation(value = "通过id主键查询单条数据") -public ResResult selectById(@RequestParam("id") ${dbTableConfig.uniKeyType} id) { +public ResResult<${dbTableConfig.tableNameCase}> selectById(@RequestParam("id") ${dbTableConfig.uniKeyType} id) { return new ResResult().success(this.${dbTableConfig.tableName}Service.selectById(id)); } @@ -71,7 +71,7 @@ return new ResResult().success(this.${dbTableConfig.tableName}Service.selectById */ @ApiOperation(value = "根据id数组查询列表") @PostMapping("selectBatchIds") -public ResResult selectBatchIds(@RequestParam("idList") List< ${dbTableConfig.uniKeyType} > idList) { +public ResResult< List<${dbTableConfig.tableNameCase}> > selectBatchIds(@RequestParam("idList") List< ${dbTableConfig.uniKeyType} > idList) { return new ResResult().success(this.${dbTableConfig.tableName}Service.selectBatchIds(idList)); } diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm b/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm index 924db85..512c4e3 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus/utils.vm @@ -3,17 +3,18 @@ #end #set($originFieldString="#getOriginField()") #set($lenth=$originFieldString.length() - 1) -#set($selectString=$originFieldString.substring(0,$lenth)) - +#if($lenth>0) + #set($selectString=$originFieldString.substring(0,$lenth)) +#end #macro(getValid $item) #if($item.isNeedInput=="true") #if(${item.type}=="Long") - @NotNull(message = "userId不能为空") + @NotNull(message = "${item.field}不能为空") #elseif(${item.type}=="Integer") - @NotNull(message = "userId不能为空") + @NotNull(message = "${item.field}不能为空") #elseif(${item.type}=="String") - @NotBlank(message = "userId不能为空") + @NotBlank(message = "${item.field}不能为空") #elseif(${item.type}=="List") @NotEmpty(message = "${item.field}不能为空") #end diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/vo.vm b/velocity-tmp-dir/back-vms/mybatis-plus/vo.vm new file mode 100644 index 0000000..cf1b2f7 --- /dev/null +++ b/velocity-tmp-dir/back-vms/mybatis-plus/vo.vm @@ -0,0 +1,19 @@ +#parse("utils.vm") +package ${basicConfig.packageName}.entity; +import java.util.Date; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; +/** +* ${dbTableConfig.tableDesc}实体类 +* +* @author ${basicConfig.author} +* @since ${basicConfig.dataTime} +*/ +@Data +@ApiModel("${dbTableConfig.tableDesc}") +public class ${dbTableConfig.tableNameCase}Vo { +#foreach($item in $tableConfig) +@ApiModelProperty(value = "$item.desc") +private ${item.type} $item.field; +#end +} diff --git a/velocity-tmp-dir/front-vms/element-plus/routerItem.vm b/velocity-tmp-dir/front-vms/element-plus/routerItem.vm index 19fb90a..4abec7c 100644 --- a/velocity-tmp-dir/front-vms/element-plus/routerItem.vm +++ b/velocity-tmp-dir/front-vms/element-plus/routerItem.vm @@ -1,28 +1,32 @@ { - path: '/${basicConfig.routerParentDir}', - component: Layout, - meta: { title: '${basicConfig.routerParentDir}', elSvgIcon: 'Fold' }, - alwaysShow: true, - children: [ - { - path: '${basicConfig.apiFileName}-table-query', - component: () => import('@/views/${basicConfig.routerParentDir}/${basicConfig.apiFileName}/${basicConfig.apiFileNameFirstCase}TableQuery.vue'), - name: '${basicConfig.apiFileNameFirstCase}TableQuery', - meta: { title: '${basicConfig.apiFileName}列表' } - }, - { - path: '${basicConfig.apiFileName}-add-edit', - component: () => import('@/views/${basicConfig.routerParentDir}/${basicConfig.apiFileName}/${basicConfig.apiFileNameFirstCase}AddEdit.vue'), - name: '${basicConfig.apiFileNameFirstCase}AddEdit', - hidden: true, - meta: { title: '新增编辑', activeMenu: '/${basicConfig.routerParentDir}/${basicConfig.apiFileName}-table-query' } - }, - { - path: '${basicConfig.apiFileName}-detail', - component: () => import('@/views/${basicConfig.routerParentDir}/${basicConfig.apiFileName}/${basicConfig.apiFileNameFirstCase}Detail.vue'), - name: '${basicConfig.apiFileNameFirstCase}Detail', - hidden: true, - meta: { title: '详情', activeMenu: '/${basicConfig.routerParentDir}/${basicConfig.apiFileName}-table-query' } - } - ] -} \ No newline at end of file +path: '/${basicConfig.routerParentDir}', +component: Layout, +meta: { title: '${basicConfig.routerParentDir}', elSvgIcon: 'Fold' }, +alwaysShow: true, +children: [ +{ +path: '${basicConfig.apiFileName}-table-query', +component: () => import('@/views/${basicConfig.routerParentDir}/${basicConfig.apiFileName}/${basicConfig.apiFileNameFirstCase}TableQuery.vue'), +name: '${basicConfig.apiFileNameFirstCase}TableQuery', +meta: { title: '${basicConfig.apiFileName}列表' } +}, +#if($commonConfig.isAdd||$commonConfig.isEdit) +{ +path: '${basicConfig.apiFileName}-add-edit', +component: () => import('@/views/${basicConfig.routerParentDir}/${basicConfig.apiFileName}/${basicConfig.apiFileNameFirstCase}AddEdit.vue'), +name: '${basicConfig.apiFileNameFirstCase}AddEdit', +hidden: true, +meta: { title: '新增编辑', activeMenu: '/${basicConfig.routerParentDir}/${basicConfig.apiFileName}-table-query' } +}, +#end +#if($commonConfig.isDetail) +{ +path: '${basicConfig.apiFileName}-detail', +component: () => import('@/views/${basicConfig.routerParentDir}/${basicConfig.apiFileName}/${basicConfig.apiFileNameFirstCase}Detail.vue'), +name: '${basicConfig.apiFileNameFirstCase}Detail', +hidden: true, +meta: { title: '详情', activeMenu: '/${basicConfig.routerParentDir}/${basicConfig.apiFileName}-table-query' } +} +] +} +#end diff --git a/velocity-tmp-dir/json-data/tb_brand.json b/velocity-tmp-dir/json-data/tb_brand.json deleted file mode 100644 index fbff052..0000000 --- a/velocity-tmp-dir/json-data/tb_brand.json +++ /dev/null @@ -1,877 +0,0 @@ -{ - "projectOrAuthor": { - "author": "熊猫哥", - "packageName": "top.kuanghua.integrationfront", - "serviceName": "integration-front", - "dataTime": "2022-06-22 10:02:51", - "modalTitle": "我是modal的title", - "isMultiTable": false - }, - "commonConfig": { - "upFileApi": "/ty-example/upload/file", - "isAdd": "true", - "isDelete": "true", - "isMulDelete": "true", - "isEdit": "true", - "isPagination": "true", - "isDetail": "true", - "isTableMulChoose": "true" - }, - "multiTableConfig": [ - { - "tableName": "brand", - "originTableName": "tb_brand", - "tableDesc": "品牌表", - "tableNameCase": "Brand", - "uniKey": "id", - "tableFieldArr": [ - { - "columnType": "int(11)", - "isNullable": "NO", - "dataType": "int", - "extra": "auto_increment", - "columnComment": "id", - "columnKey": "PRI", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "id", - "field": "id", - "fieldCase": "Id", - "originField": "id", - "tbName": "id", - "type": "Integer", - "componentType": "", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "id", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - }, - { - "columnType": "varchar(100)", - "isNullable": "NO", - "dataType": "varchar", - "extra": "", - "columnComment": "品牌名称", - "columnKey": "PRI", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "name", - "field": "name", - "fieldCase": "Name", - "originField": "name", - "tbName": "name", - "type": "String", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "品牌名称", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - }, - { - "columnType": "varchar(1000)", - "isNullable": "YES", - "dataType": "varchar", - "extra": "", - "columnComment": "品牌图片地址", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "image", - "field": "image", - "fieldCase": "Image", - "originField": "image", - "tbName": "image", - "type": "String", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "品牌图片地址", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - }, - { - "columnType": "char(1)", - "isNullable": "YES", - "dataType": "char", - "extra": "", - "columnComment": "品牌的首字母", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "letter", - "field": "letter", - "fieldCase": "Letter", - "originField": "letter", - "tbName": "letter", - "type": "String", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "品牌的首字母", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - }, - { - "columnType": "int(11)", - "isNullable": "YES", - "dataType": "int", - "extra": "", - "columnComment": "排序", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "seq", - "field": "seq", - "fieldCase": "Seq", - "originField": "seq", - "tbName": "seq", - "type": "Integer", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "排序", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - }, - { - "columnType": "datetime", - "isNullable": "YES", - "dataType": "datetime", - "extra": "on update CURRENT_TIMESTAMP", - "columnComment": "创建时间", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "create_time", - "field": "createTime", - "fieldCase": "Createtime", - "originField": "create_time", - "tbName": "create_time", - "type": "Long" - }, - { - "columnType": "datetime", - "isNullable": "YES", - "dataType": "datetime", - "extra": "on update CURRENT_TIMESTAMP", - "columnComment": "更新时间", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "update_time", - "field": "updateTime", - "fieldCase": "Updatetime", - "originField": "update_time", - "tbName": "update_time", - "type": "Long" - } - ], - "orgUniKey": "id", - "uniKeyType": "Integer", - "priKeyArr": [ - "id", - "name" - ], - "priKeyItemArr": [ - { - "columnType": "int(11)", - "isNullable": "NO", - "dataType": "int", - "extra": "auto_increment", - "columnComment": "id", - "columnKey": "PRI", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "id", - "field": "id", - "fieldCase": "Id", - "originField": "id", - "tbName": "id", - "type": "Integer", - "componentType": "", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "id", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - }, - { - "columnType": "varchar(100)", - "isNullable": "NO", - "dataType": "varchar", - "extra": "", - "columnComment": "品牌名称", - "columnKey": "PRI", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "name", - "field": "name", - "fieldCase": "Name", - "originField": "name", - "tbName": "name", - "type": "String", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "品牌名称", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - } - ], - "orgAssociationKey": "name", - "associationKey": "name", - "associationKeyType": "String", - "tableQueryArr": [ - { - "columnType": "varchar(100)", - "isNullable": "NO", - "dataType": "varchar", - "extra": "", - "columnComment": "品牌名称", - "columnKey": "PRI", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "name", - "field": "name", - "fieldCase": "Name", - "originField": "name", - "tbName": "name", - "type": "String", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "品牌名称", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - } - ], - "tableShowArr": [ - { - "columnType": "varchar(100)", - "isNullable": "NO", - "dataType": "varchar", - "extra": "", - "columnComment": "品牌名称", - "columnKey": "PRI", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "name", - "field": "name", - "fieldCase": "Name", - "originField": "name", - "tbName": "name", - "type": "String", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "品牌名称", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - } - ], - "tableFormArr": [ - { - "columnType": "varchar(100)", - "isNullable": "NO", - "dataType": "varchar", - "extra": "", - "columnComment": "品牌名称", - "columnKey": "PRI", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "name", - "field": "name", - "fieldCase": "Name", - "originField": "name", - "tbName": "name", - "type": "String", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "品牌名称", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - } - ] - } - ], - "dbTableConfig": { - "tableName": "brand", - "originTableName": "tb_brand", - "tableDesc": "品牌表", - "tableNameCase": "Brand", - "uniKey": "id", - "orgUniKey": "id", - "uniKeyType": "Integer", - "orgAssociationKey": "name", - "multiTableName": "rand", - "multiTableNameCase": "Rand", - "multiTableDesc": "多表中实体类的注释", - "associationKey": "name", - "associationKeyCase": "Name", - "associationKeyType": "String", - "tableFieldArr": [ - { - "columnType": "int(11)", - "isNullable": "NO", - "dataType": "int", - "extra": "auto_increment", - "columnComment": "id", - "columnKey": "PRI", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "id", - "field": "id", - "fieldCase": "Id", - "originField": "id", - "tbName": "id", - "type": "Integer", - "componentType": "", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "id", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - }, - { - "columnType": "varchar(100)", - "isNullable": "NO", - "dataType": "varchar", - "extra": "", - "columnComment": "品牌名称", - "columnKey": "PRI", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "name", - "field": "name", - "fieldCase": "Name", - "originField": "name", - "tbName": "name", - "type": "String", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "品牌名称", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - }, - { - "columnType": "varchar(1000)", - "isNullable": "YES", - "dataType": "varchar", - "extra": "", - "columnComment": "品牌图片地址", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "image", - "field": "image", - "fieldCase": "Image", - "originField": "image", - "tbName": "image", - "type": "String", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "品牌图片地址", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - }, - { - "columnType": "char(1)", - "isNullable": "YES", - "dataType": "char", - "extra": "", - "columnComment": "品牌的首字母", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "letter", - "field": "letter", - "fieldCase": "Letter", - "originField": "letter", - "tbName": "letter", - "type": "String", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "品牌的首字母", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - }, - { - "columnType": "int(11)", - "isNullable": "YES", - "dataType": "int", - "extra": "", - "columnComment": "排序", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "seq", - "field": "seq", - "fieldCase": "Seq", - "originField": "seq", - "tbName": "seq", - "type": "Integer", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "排序", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - }, - { - "columnType": "datetime", - "desc": "创建时间", - "isNullable": "YES", - "dataType": "datetime", - "extra": "on update CURRENT_TIMESTAMP", - "columnComment": "创建时间", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "create_time", - "field": "createTime", - "fieldCase": "Createtime", - "originField": "create_time", - "tbName": "create_time", - "type": "Date" - }, - { - "columnType": "datetime", - "desc": "更新时间", - "isNullable": "YES", - "dataType": "datetime", - "extra": "on update CURRENT_TIMESTAMP", - "columnComment": "更新时间", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "update_time", - "field": "updateTime", - "fieldCase": "Updatetime", - "originField": "update_time", - "tbName": "update_time", - "type": "Date" - } - ] - }, - "apiConfig": { - "queryApi": "/integration-front/brand/selectPage", - "queryApiType": "get", - "insertApi": "/insert", - "insertApiType": "post", - "updateApi": "/integration-front/brand/updateById", - "updateApiType": "update", - "deleteApi": "/integration-front/brand/deleteById", - "deleteApiType": "delete", - "deleteMultiApi": "/integration-front/brand/deleteBatchIds", - "deleteMultiApiType": "delete", - "detailApi": "/integration-front/brand/selectById", - "detailApiType": "get" - }, - "queryConfig": [ - { - "columnType": "varchar(100)", - "isNullable": "NO", - "dataType": "varchar", - "extra": "", - "columnComment": "品牌名称", - "columnKey": "PRI", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "name", - "field": "name", - "fieldCase": "Name", - "originField": "name", - "tbName": "name", - "type": "String", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "品牌名称", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - } - ], - "tableConfig": [ - { - "columnType": "varchar(100)", - "isNullable": "NO", - "dataType": "varchar", - "extra": "", - "columnComment": "品牌名称", - "columnKey": "PRI", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "name", - "field": "name", - "fieldCase": "Name", - "originField": "name", - "tbName": "name", - "type": "String", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "品牌名称", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - }, - { - "columnType": "varchar(1000)", - "isNullable": "YES", - "dataType": "varchar", - "extra": "", - "columnComment": "品牌图片地址", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "image", - "field": "image", - "fieldCase": "Image", - "originField": "image", - "tbName": "image", - "type": "String", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "品牌图片地址", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - }, - { - "columnType": "char(1)", - "isNullable": "YES", - "dataType": "char", - "extra": "", - "columnComment": "品牌的首字母", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "letter", - "field": "letter", - "fieldCase": "Letter", - "originField": "letter", - "tbName": "letter", - "type": "String", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "品牌的首字母", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - }, - { - "columnType": "int(11)", - "isNullable": "YES", - "dataType": "int", - "extra": "", - "columnComment": "排序", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "seq", - "field": "seq", - "fieldCase": "Seq", - "originField": "seq", - "tbName": "seq", - "type": "Integer", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "排序", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - } - ], - "formConfig": [ - { - "columnType": "int(11)", - "isNullable": "NO", - "dataType": "int", - "extra": "auto_increment", - "columnComment": "id", - "columnKey": "PRI", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "id", - "field": "id", - "fieldCase": "Id", - "originField": "id", - "tbName": "id", - "type": "Integer", - "componentType": "", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "id", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - }, - { - "columnType": "varchar(100)", - "isNullable": "NO", - "dataType": "varchar", - "extra": "", - "columnComment": "品牌名称", - "columnKey": "PRI", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "name", - "field": "name", - "fieldCase": "Name", - "originField": "name", - "tbName": "name", - "type": "String", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "品牌名称", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - }, - { - "columnType": "varchar(1000)", - "isNullable": "YES", - "dataType": "varchar", - "extra": "", - "columnComment": "品牌图片地址", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "image", - "field": "image", - "fieldCase": "Image", - "originField": "image", - "tbName": "image", - "type": "String", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "品牌图片地址", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - }, - { - "columnType": "char(1)", - "isNullable": "YES", - "dataType": "char", - "extra": "", - "columnComment": "品牌的首字母", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "letter", - "field": "letter", - "fieldCase": "Letter", - "originField": "letter", - "tbName": "letter", - "type": "String", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "品牌的首字母", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - }, - { - "columnType": "int(11)", - "isNullable": "YES", - "dataType": "int", - "extra": "", - "columnComment": "排序", - "columnKey": "", - "tableSchema": "micro-service-plus", - "tableName": "tb_brand", - "columnName": "seq", - "field": "seq", - "fieldCase": "Seq", - "originField": "seq", - "tbName": "seq", - "type": "Integer", - "componentType": "input", - "rule": "isNotNull", - "value": "value", - "label": "label", - "children": "children", - "width": 120, - "desc": "排序", - "optionData": "", - "api": "", - "method": "get", - "labelKey": "name", - "valueKey": "code", - "optionDataArr": [] - } - ] -} \ No newline at end of file From 2b4cf1792e7bf66e887efa5a15ee8a0da0bcf439 Mon Sep 17 00:00:00 2001 From: jzfai Date: Sun, 16 Oct 2022 20:27:07 +0800 Subject: [PATCH 32/36] finish permission func --- .../controller/PermissionController.java | 189 ++++++++++++ .../controller/PlateFormController.java | 137 +++++++++ .../kuanghua/basisfunc/entity/Permission.java | 84 ++++++ .../kuanghua/basisfunc/entity/PlateForm.java | 44 +++ .../basisfunc/mapper/PermissionMapper.java | 21 ++ .../basisfunc/mapper/PlateFormMapper.java | 13 + .../basisfunc/service/PermissionService.java | 86 ++++++ .../basisfunc/service/PlateFormService.java | 49 ++++ .../kuanghua/basisfunc/vo/PermissionVo.java | 29 ++ .../kuanghua/basisfunc/vo/PlateFormVo.java | 29 ++ .../back-vms/mybatis-plus/entity.vm | 2 + .../front-vms/element-plus/CRUD.vm | 96 ------- .../front-vms/element-plus/CRUDForm.vm | 87 ------ .../front-vms/element-plus/addEditUtils.vm | 48 ++-- .../front-vms/element-plus/formUtils.vm | 268 ------------------ .../front-vms/element-plus/queryUtils.vm | 56 +--- .../front-vms/element-plus/routerItem.vm | 8 +- .../front-vms/element-plus/tableQuery.vm | 36 +-- .../front-vms/element-plus/tableQueryUtils.vm | 33 ++- 19 files changed, 757 insertions(+), 558 deletions(-) create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/controller/PermissionController.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/controller/PlateFormController.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/entity/Permission.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/entity/PlateForm.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/mapper/PermissionMapper.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/mapper/PlateFormMapper.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/service/PermissionService.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/service/PlateFormService.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/vo/PermissionVo.java create mode 100644 basis-func/src/main/java/top/kuanghua/basisfunc/vo/PlateFormVo.java delete mode 100644 velocity-tmp-dir/front-vms/element-plus/CRUD.vm delete mode 100644 velocity-tmp-dir/front-vms/element-plus/CRUDForm.vm delete mode 100644 velocity-tmp-dir/front-vms/element-plus/formUtils.vm diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/controller/PermissionController.java b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/PermissionController.java new file mode 100644 index 0000000..32bf052 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/PermissionController.java @@ -0,0 +1,189 @@ + + + +package top.kuanghua.basisfunc.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +import javax.annotation.Resource; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import io.swagger.models.auth.In; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; +import top.kuanghua.basisfunc.entity.Permission; +import top.kuanghua.basisfunc.service.PermissionService; +import top.kuanghua.basisfunc.vo.PermissionVo; +import top.kuanghua.commonpom.entity.ResResult; +import top.kuanghua.commonpom.entity.SelfCommonParams; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import java.util.List; +import java.util.Map; + +/** + * 权限Controller + * + * @author 熊猫哥 + * @since 2022-10-07 16:33:13 + */ +@Api(tags = "权限(Permission)") +@RestController +@RequestMapping("permission") +@Validated +public class PermissionController { + + @Resource + private PermissionService permissionService; + + /** + * 分页查询所有数据 + * + * @return ResResult + */ + @GetMapping("selectPage") + @ApiOperation(value = "分页查询所有数据") + + @ApiImplicitParams({ + @ApiImplicitParam(name = "code", value = "权限唯一CODE代码", paramType = "query"), + @ApiImplicitParam(name = "name", value = "权限名称", paramType = "query"), + @ApiImplicitParam(name = "plateFormId", value = "平台id", paramType = "quebn" + + "ry"), + @ApiImplicitParam(name = "title", value = "页面标题", paramType = "query"), + @ApiImplicitParam(name = "createTime", value = "创建时间", paramType = "query"), + }) + public ResResult> selectPage(@ApiIgnore() String id, @ApiIgnore() String parentId, String code, + @ApiIgnore() String creator, @ApiIgnore() String editor, String name, + @ApiIgnore() String category,Integer plateFormId, String title, String createTime, SelfCommonParams commonParams) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + //权限ID + if (ObjSelfUtils.isNotEmpty(id)) { + queryWrapper.like("id", id); + } + //所属父级权限ID + if (ObjSelfUtils.isNotEmpty(parentId)) { + queryWrapper.like("parent_id", parentId); + } + //权限唯一CODE代码 + if (ObjSelfUtils.isNotEmpty(code)) { + queryWrapper.like("code", code); + } + //创建人 + if (ObjSelfUtils.isNotEmpty(creator)) { + queryWrapper.like("creator", creator); + } + //修改人 + if (ObjSelfUtils.isNotEmpty(editor)) { + queryWrapper.like("editor", editor); + } + //权限名称 + if (ObjSelfUtils.isNotEmpty(name)) { + queryWrapper.like("name", name); + } + //权限类别;1:路由,2:内页,3:按钮 + if (ObjSelfUtils.isNotEmpty(category)) { + queryWrapper.like("category", category); + } + //页面标题 + if (ObjSelfUtils.isNotEmpty(title)) { + queryWrapper.like("title", title); + } + //页面标题 + if (ObjSelfUtils.isNotEmpty(plateFormId)) { + queryWrapper.like("plate_form_id", plateFormId); + } + //创建时间 + queryWrapper.orderByDesc("create_time"); + if (ObjSelfUtils.isNotEmpty(commonParams.getStartTime())) { + queryWrapper.between("create_time", commonParams.getStartTime(), commonParams.getEndTime()); + } + + queryWrapper.select("id,parent_id,code,intro,creator,editor,path,name,category,component,title,el_svg_icon,icon,redirect,update_time,create_time,plate_form_id,deleted"); + + Page permissionPage = this.permissionService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); + return new ResResult().success(permissionPage); + } + + /** + * 通过主键查询单条数据 + * + * @param parentId 父元素id + * @return List + */ + @GetMapping("getPermissionList") + @ApiOperation(value = "递归查询children数据") + public ResResult> getPermissionList(@RequestParam("parentId") Long parentId) { + return new ResResult().success(this.permissionService.getPermissionList(parentId)); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("selectById") + @ApiOperation(value = "通过id主键查询单条数据") + public ResResult selectById(@RequestParam("id") Long id) { + return new ResResult().success(this.permissionService.selectById(id)); + } + /** + * @Description: 根据id数组查询列表 + * @Param: idList id数组 + * @return: ids列表数据 + */ + @ApiOperation(value = "根据id数组查询列表") + @PostMapping("selectBatchIds") + public ResResult> selectBatchIds(@RequestParam("idList") List idList) { + return new ResResult().success(this.permissionService.selectBatchIds(idList)); + } + + /** + * 新增数据 + * + * @param permission 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping("insert") + public ResResult insert(@Validated @RequestBody Permission permission) { + return new ResResult().success(this.permissionService.insert(permission)); + } + + /** + * 修改数据 + * + * @param permission 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "根据id修改数据") + @PutMapping("updateById") + public ResResult updateById(@Validated @RequestBody Permission permission) { + return new ResResult().success(this.permissionService.updateById(permission)); + } + + /** + * 删除数据 + * + * @param idList 主键结合 + * @return 删除结果 + */ + @ApiOperation(value = "根据id数组删除数据") + @DeleteMapping("deleteBatchIds") + public ResResult deleteBatchIds(@RequestBody List idList) { + return new ResResult().success(this.permissionService.deleteBatchIds(idList)); + } + + @ApiOperation("根据id删除数据") + @DeleteMapping("deleteById") + public ResResult deleteById(@RequestParam("id") Long id) { + return new ResResult().success(this.permissionService.deleteById(id)); + } +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/controller/PlateFormController.java b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/PlateFormController.java new file mode 100644 index 0000000..50b5c88 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/controller/PlateFormController.java @@ -0,0 +1,137 @@ + + + +package top.kuanghua.basisfunc.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +import javax.annotation.Resource; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import top.kuanghua.basisfunc.entity.PlateForm; +import top.kuanghua.basisfunc.service.PlateFormService; +import top.kuanghua.commonpom.entity.ResResult; +import top.kuanghua.commonpom.entity.SelfCommonParams; +import top.kuanghua.commonpom.utils.ObjSelfUtils; + +import java.util.List; + +/** + * 平台Controller + * + * @author 熊猫哥 + * @since 2022-10-07 16:33:13 + */ +@Api(tags = "平台(PlateForm)") +@RestController +@RequestMapping("plateForm") +@Validated +public class PlateFormController { + + @Resource + private PlateFormService plateFormService; + + /** + * 分页查询所有数据 + * + * @return ResResult + */ + @GetMapping("selectPage") + @ApiOperation(value = "分页查询所有数据") + + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "主键", paramType = "query"), + @ApiImplicitParam(name = "name", value = "平台名字", paramType = "query"), + }) + public ResResult> selectPage(String id, + String name, + SelfCommonParams commonParams) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + //主键 + if (ObjSelfUtils.isNotEmpty(id)) { + queryWrapper.like("id", id); + } + //平台名字 + if (ObjSelfUtils.isNotEmpty(name)) { + queryWrapper.like("name", name); + } + + queryWrapper.select("id,name"); + + Page plateFormPage = this.plateFormService.selectPage(commonParams.getPageNum(), commonParams.getPageSize(), queryWrapper); + return new ResResult().success(plateFormPage); + } + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @GetMapping("selectById") + @ApiOperation(value = "通过id主键查询单条数据") + public ResResult selectById(@RequestParam("id") Integer id) { + return new ResResult().success(this.plateFormService.selectById(id)); + } + + /** + * @Description: 根据id数组查询列表 + * @Param: idList id数组 + * @return: ids列表数据 + */ + @ApiOperation(value = "根据id数组查询列表") + @PostMapping("selectBatchIds") + public ResResult> selectBatchIds(@RequestParam("idList") List idList) { + return new ResResult().success(this.plateFormService.selectBatchIds(idList)); + } + + /** + * 新增数据 + * + * @param plateForm 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping("insert") + public ResResult insert(@Validated @RequestBody PlateForm plateForm) { + return new ResResult().success(this.plateFormService.insert(plateForm)); + } + + /** + * 修改数据 + * + * @param plateForm 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "根据id修改数据") + @PutMapping("updateById") + public ResResult updateById(@Validated @RequestBody PlateForm plateForm) { + return new ResResult().success(this.plateFormService.updateById(plateForm)); + } + + /** + * 删除数据 + * + * @param idList 主键结合 + * @return 删除结果 + */ + @ApiOperation(value = "根据id数组删除数据") + @DeleteMapping("deleteBatchIds") + public ResResult deleteBatchIds(@RequestBody List idList) { + return new ResResult().success(this.plateFormService.deleteBatchIds(idList)); + } + + @ApiOperation("根据id删除数据") + @DeleteMapping("deleteById") + public ResResult deleteById(@RequestParam("id") Integer id) { + return new ResResult().success(this.plateFormService.deleteById(id)); + } +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/entity/Permission.java b/basis-func/src/main/java/top/kuanghua/basisfunc/entity/Permission.java new file mode 100644 index 0000000..3536482 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/entity/Permission.java @@ -0,0 +1,84 @@ + + + +package top.kuanghua.basisfunc.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +/** + * 权限实体类 + * + * @author 熊猫哥 + * @since 2022-10-07 16:33:13 + */ +@Data +@ApiModel("权限") +@TableName(value = "t_permission") +public class Permission extends Model { + @ApiModelProperty(value = "权限ID", hidden = false) + private Long id; + @ApiModelProperty(value = "所属父级权限ID", hidden = false) + private Long parentId; + @ApiModelProperty(value = "平台id", hidden = false) + private Integer plateFormId; + @ApiModelProperty(value = "是否时父元素;0:不是,1:是", hidden = false) + private Long parentNode; + @ApiModelProperty(value = "权限唯一CODE代码", hidden = false) + @NotBlank(message = "code不能为空") + private String code; + @ApiModelProperty(value = "权限介绍", hidden = false) + private String intro; + @ApiModelProperty(value = "创建人", hidden = true) + private String creator; + @ApiModelProperty(value = "修改人", hidden = true) + private String editor; + @ApiModelProperty(value = "路由路径", hidden = false) + private String path; + @ApiModelProperty(value = "权限名称", hidden = false) + @NotBlank(message = "name不能为空") + private String name; + @ApiModelProperty(value = "权限类别;1:路由,2:内页,3:按钮", hidden = false) + @NotNull(message = "category不能为空") + private Integer category; + @ApiModelProperty(value = "组件", hidden = false) + private String component; + @ApiModelProperty(value = "页面标题", hidden = false) + private String title; + @ApiModelProperty(value = "element的icon图标", hidden = false) + private String elSvgIcon; + @ApiModelProperty(value = "自定义的svg图标", hidden = false) + private String icon; + @ApiModelProperty(value = "重定向路径", hidden = false) + private String redirect; + @ApiModelProperty(value = "修改时间", hidden = true) + @TableField(fill = FieldFill.UPDATE) + private Date updateTime; + @ApiModelProperty(value = "创建时间", hidden = true) + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + @ApiModelProperty(value = "是否激活", hidden = true) + private Integer deleted; + + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/entity/PlateForm.java b/basis-func/src/main/java/top/kuanghua/basisfunc/entity/PlateForm.java new file mode 100644 index 0000000..d17da00 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/entity/PlateForm.java @@ -0,0 +1,44 @@ + + + +package top.kuanghua.basisfunc.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; + +/** + * 平台实体类 + * + * @author 熊猫哥 + * @since 2022-10-07 16:33:13 + */ +@Data +@ApiModel("平台") +@TableName(value = "t_plate_form") +public class PlateForm extends Model { + @ApiModelProperty(value = "主键", hidden = false) + private Integer id; + @ApiModelProperty(value = "平台名字", hidden = false) + @NotBlank(message = "name不能为空") + private String name; + + /** + * 获取主键值 + * + * @return 主键值 + */ + @Override + protected Serializable pkVal() { + return this.id; + } +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/mapper/PermissionMapper.java b/basis-func/src/main/java/top/kuanghua/basisfunc/mapper/PermissionMapper.java new file mode 100644 index 0000000..aa2d7cd --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/mapper/PermissionMapper.java @@ -0,0 +1,21 @@ +package top.kuanghua.basisfunc.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import top.kuanghua.basisfunc.entity.Permission; +import top.kuanghua.basisfunc.vo.PermissionVo; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** +* 权限Mapper +* +* @author 熊猫哥 +* @since 2022-10-07 16:33:13 +*/ + +public interface PermissionMapper extends BaseMapper< Permission > { + +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/mapper/PlateFormMapper.java b/basis-func/src/main/java/top/kuanghua/basisfunc/mapper/PlateFormMapper.java new file mode 100644 index 0000000..af08904 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/mapper/PlateFormMapper.java @@ -0,0 +1,13 @@ +package top.kuanghua.basisfunc.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import top.kuanghua.basisfunc.entity.PlateForm; +/** +* 平台Mapper +* +* @author 熊猫哥 +* @since 2022-10-07 16:33:13 +*/ + +public interface PlateFormMapper extends BaseMapper< PlateForm > { + +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/service/PermissionService.java b/basis-func/src/main/java/top/kuanghua/basisfunc/service/PermissionService.java new file mode 100644 index 0000000..2fc833e --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/service/PermissionService.java @@ -0,0 +1,86 @@ +package top.kuanghua.basisfunc.service; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Service; +import top.kuanghua.basisfunc.entity.Permission; +import top.kuanghua.basisfunc.mapper.PermissionMapper; +import top.kuanghua.basisfunc.vo.PermissionVo; +import top.kuanghua.commonpom.utils.ObjSelfUtils; +import top.kuanghua.commonpom.utils.SelfObjUtils; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** +* 权限Service +* +* @author 熊猫哥 +* @since 2022-10-07 16:33:13 +*/ +@Service +public class PermissionService { + + @Resource + private PermissionMapper permissionMapper; + + public Page selectPage(Integer pageNum, Integer pageSize, QueryWrapper< Permission > queryWrapper) { + Page permissionPage = this.permissionMapper.selectPage(new Page(pageNum, pageSize), queryWrapper); + List arrayList = JSON.parseArray(JSON.toJSONString(permissionPage.getRecords()), PermissionVo.class); + arrayList.forEach((listItem) -> { + List childrenArr =getPermissionList(listItem.getId()); + listItem.setChildren(childrenArr); + }); + Page newPage = new Page<>(); + newPage.setSize(permissionPage.getSize()); + newPage.setCurrent(permissionPage.getCurrent()); + newPage.setTotal(permissionPage.getTotal()); + newPage.setRecords(arrayList); + return newPage; + } + + /*递归查询children数据*/ + public List getPermissionList(Long parentId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + //权限ID + queryWrapper.eq("parent_id",parentId); + List parentList = this.permissionMapper.selectList(queryWrapper); + List permissionVoList = parentList.stream().map(mItem -> { + PermissionVo permissionVo = JSON.parseObject(JSON.toJSONString(mItem), PermissionVo.class); + if (ObjSelfUtils.isNotEmpty(permissionVo.getParentNode())&&permissionVo.getParentNode()==1) { + permissionVo.setChildren(getPermissionList(permissionVo.getId())); + } + return permissionVo; + }).collect(Collectors.toList()); + return permissionVoList; + } + + + public Permission selectById(Long id) { + return this.permissionMapper.selectById(id); + } + + public List< Permission > selectBatchIds(List< Long > idList) { + return this.permissionMapper.selectBatchIds(idList); + } + + public int insert(Permission permission) { + return this.permissionMapper.insert(permission); + } + + public int updateById(Permission permission) { + return this.permissionMapper.updateById(permission); + } + + public int deleteById(Long id) { + return this.permissionMapper.deleteById(id); + } + + public int deleteBatchIds(List< Long > idList) { + return this.permissionMapper.deleteBatchIds(idList); + } +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/service/PlateFormService.java b/basis-func/src/main/java/top/kuanghua/basisfunc/service/PlateFormService.java new file mode 100644 index 0000000..6d2e87e --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/service/PlateFormService.java @@ -0,0 +1,49 @@ +package top.kuanghua.basisfunc.service; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.stereotype.Service; +import top.kuanghua.basisfunc.entity.PlateForm; +import top.kuanghua.basisfunc.mapper.PlateFormMapper; + +import javax.annotation.Resource; +import java.util.List; + +/** +* 平台Service +* +* @author 熊猫哥 +* @since 2022-10-07 16:33:13 +*/ +@Service +public class PlateFormService { + @Resource + private PlateFormMapper plateFormMapper; + + public Page< PlateForm > selectPage(Integer pageNum, Integer pageSize, QueryWrapper< PlateForm > queryWrapper) { + return this.plateFormMapper.selectPage(new Page< PlateForm >(pageNum, pageSize), queryWrapper); + } + + public PlateForm selectById(Integer id) { + return this.plateFormMapper.selectById(id); + } + + public List< PlateForm > selectBatchIds(List< Integer > idList) { + return this.plateFormMapper.selectBatchIds(idList); + } + + public int insert(PlateForm plateForm) { + return this.plateFormMapper.insert(plateForm); + } + + public int updateById(PlateForm plateForm) { + return this.plateFormMapper.updateById(plateForm); + } + + public int deleteById(Integer id) { + return this.plateFormMapper.deleteById(id); + } + + public int deleteBatchIds(List< Integer > idList) { + return this.plateFormMapper.deleteBatchIds(idList); + } +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/vo/PermissionVo.java b/basis-func/src/main/java/top/kuanghua/basisfunc/vo/PermissionVo.java new file mode 100644 index 0000000..0a1fa2a --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/vo/PermissionVo.java @@ -0,0 +1,29 @@ + + + + + + + +package top.kuanghua.basisfunc.vo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import top.kuanghua.basisfunc.entity.Permission; + +import java.util.Date; +import java.util.List; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; +/** +* 权限实体类 +* +* @author 熊猫哥 +* @since 2022-10-07 16:33:13 +*/ +@Data +@ApiModel("权限") +public class PermissionVo extends Permission { + @ApiModelProperty(value = "子元素", hidden = false) + private List Children; +} diff --git a/basis-func/src/main/java/top/kuanghua/basisfunc/vo/PlateFormVo.java b/basis-func/src/main/java/top/kuanghua/basisfunc/vo/PlateFormVo.java new file mode 100644 index 0000000..94bb462 --- /dev/null +++ b/basis-func/src/main/java/top/kuanghua/basisfunc/vo/PlateFormVo.java @@ -0,0 +1,29 @@ + + + + + + + +package top.kuanghua.basisfunc.vo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; +/** +* 平台实体类 +* +* @author 熊猫哥 +* @since 2022-10-07 16:33:13 +*/ +@Data +@ApiModel("平台") +public class PlateFormVo { +@ApiModelProperty(value = "主键") +private Integer id; +@ApiModelProperty(value = "平台名字") +private String name; +} diff --git a/velocity-tmp-dir/back-vms/mybatis-plus/entity.vm b/velocity-tmp-dir/back-vms/mybatis-plus/entity.vm index 2654837..f078dd3 100644 --- a/velocity-tmp-dir/back-vms/mybatis-plus/entity.vm +++ b/velocity-tmp-dir/back-vms/mybatis-plus/entity.vm @@ -1,6 +1,8 @@ #parse("utils.vm") package ${basicConfig.packageName}.entity; import java.util.Date; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.Pattern; /** diff --git a/velocity-tmp-dir/front-vms/element-plus/CRUD.vm b/velocity-tmp-dir/front-vms/element-plus/CRUD.vm deleted file mode 100644 index 99e3d0d..0000000 --- a/velocity-tmp-dir/front-vms/element-plus/CRUD.vm +++ /dev/null @@ -1,96 +0,0 @@ -#parse("queryUtils.vm") -#parse("tableUtils.vm") -#parse("utils.vm") - - - - \ No newline at end of file diff --git a/velocity-tmp-dir/front-vms/element-plus/CRUDForm.vm b/velocity-tmp-dir/front-vms/element-plus/CRUDForm.vm deleted file mode 100644 index 0d72de3..0000000 --- a/velocity-tmp-dir/front-vms/element-plus/CRUDForm.vm +++ /dev/null @@ -1,87 +0,0 @@ -#parse("formUtils.vm") - - - - - \ No newline at end of file diff --git a/velocity-tmp-dir/front-vms/element-plus/addEditUtils.vm b/velocity-tmp-dir/front-vms/element-plus/addEditUtils.vm index 6151c10..b407c89 100644 --- a/velocity-tmp-dir/front-vms/element-plus/addEditUtils.vm +++ b/velocity-tmp-dir/front-vms/element-plus/addEditUtils.vm @@ -1,11 +1,11 @@ #macro(subFormItemTmp) #foreach($item in $tableList) #if($item.componentType=="input") ##input - + #elseif($item.componentType=="textarea") ##textarea - + #elseif($item.componentType=="select") ##select - + #foreach($enum in $item.optionDataArr) @@ -26,25 +26,25 @@ #elseif($item.componentType=="selectApi") ##selectApi - + + :value="item.${item.valueKey}"/> #elseif($item.componentType=="radio") ##radio - + #foreach($enum in $item.optionDataArr) - ${enum.label} + ${enum.label} #end #elseif($item.componentType=="checkbox") ##checkbox - + #foreach($enum in $item.optionDataArr) @@ -52,7 +52,7 @@ #elseif($item.componentType=="switch") ##switch - + #elseif($item.componentType=="cascaderApi") ##cascader - + #elseif($item.componentType=="daterange") ##datetime - + #elseif($item.componentType=="date") ##date - + #elseif($item.componentType=="uploadImage") - +
@@ -117,7 +117,7 @@ onMounted(()=>{ #foreach($item in $tableList) #if($item.componentType=="selectApi")##selectApi - ${item.fieldCase}Req() + ${item.field}Req() #end #end }) @@ -134,9 +134,17 @@ onMounted(()=>{ ##api req #macro(apiReqScript) - #foreach($qcItem in $tableList) - #if($qcItem.componentType=="selectApi") - ${qcItem.fieldCase}Req() + #foreach($item in $tableList) + #if($item.componentType=="selectApi")##selectApi + let ${item.field}Data = $ref([]) + const ${item.field}Req = () => { + let reqConfig = { + url: '${item.api}', + method: '${item.method}', + } + axiosReq(reqConfig).then(({data}) => { + ${item.field}Data = data.records + })} #end #end #end @@ -144,6 +152,7 @@ onMounted(()=>{ ##form key #macro(formKeyScrpt) +id: '', #foreach($item in $tableList) $item.field:"", #if($qcItem.componentType=="daterange") @@ -166,5 +175,4 @@ onMounted(()=>{ } #end #end - #end diff --git a/velocity-tmp-dir/front-vms/element-plus/formUtils.vm b/velocity-tmp-dir/front-vms/element-plus/formUtils.vm deleted file mode 100644 index 0bc16a2..0000000 --- a/velocity-tmp-dir/front-vms/element-plus/formUtils.vm +++ /dev/null @@ -1,268 +0,0 @@ -##生成form item -#parse("utils.vm") -#macro(formTemp) -#foreach($item in $formConfig) - #if($item.componentType=="input") ##input - - - - #elseif($item.componentType=="textarea") ##textarea - - - - #elseif($item.componentType=="select") ##select - - - #foreach($enum in $item.optionDataArr) - - #end - - - #elseif($item.componentType=="selectApi") ##selectApi - - - - - - #elseif($item.componentType=="radio") ##radio - - - #foreach($enum in $item.optionDataArr) - ${enum.label} - #end - - - #elseif($item.componentType=="checkbox") ##checkbox - - - #foreach($enum in $item.optionDataArr) - - #end - - - #elseif($item.componentType=="switch") ##switch - - - - #elseif($item.componentType=="cascaderApi") ##cascader - - - - #elseif($item.componentType=="datetimerange") ##datetimerange - - - - #elseif($item.componentType=="datetime") ##datetime - - - - #elseif($item.componentType=="date") ##date - - - - #elseif($item.componentType=="uploadImage") ##uploadImage - -
- -
- - - 上传 - - -
{{ chooseFileName }}
-
-
-
- #end -#end -#end -##rule校验 -#macro(rulesData) -#foreach($item in $formConfig) -#if($item.rule=="notNull")##必填 - $item.field:{required: true, message:"${item.desc}不能为空",trigger:["blur", "change"]}, - #elseif ($item.rule=="number")##只允许输入数字 - $item.field:[{required: true, message: "请输入${item.desc}", trigger: "blur"},{pattern: - /^[1-9]\d*$/,message: "${item.desc}为正整数",trigger: "blur",}], - #elseif ($item.rule=="positiveNumber")##只允许输入正数(允许带两位小数) - $item.field:[{required: true, message: "请输入${item.desc}", trigger: "blur"},{pattern: - /^[1-9]\d*$/,message: "${item.desc}为正整数",trigger: "blur",}], -#end -#end -#end -##保存请求接口 -#macro(insertReq) -const insertReq = () => { -const data = JSON.parse(JSON.stringify(subForm)) -delete data.id -axiosReq({ -url: '${apiConfig.insertApi}', -data: data, -method: '${apiConfig.insertApiType}', -bfLoading: true -}).then(() => { -elMessage('保存成功') -emit('selectPageReq') -emit('hideComp') -}) -} -#end -##保存请求接口 -#macro(updateReq) -const updateReq = () => { -return axiosReq({ -url: '${apiConfig.updateApi}', -data: subForm, -method: '${apiConfig.updateApiType}', -bfLoading: true -}).then(() => { -elMessage('更新成功') -emit('selectPageReq') -emit('hideComp') -}) -} -#end -##上传图片,一张图片 -#macro(fileUploadSave) -/*上传图片(单张))*/ -const refSettingFile = $ref(null) -const goUploadFile = () => { -refSettingFile.click() -} -const fileUploadSave = () => { -const formData = new FormData() -formData.append('file', refSettingFile.files[0]) -axiosReq({ -url: '${commonConfig.upFileApi}', -timeout: 30000, -data: formData, -method: 'post', -bfLoading: true, -isUploadFile: true -}) -.then((resData) => { -let { path } = resData.data -const filename = refSettingFile.value -chooseFileName = filename.slice(filename.lastIndexOf('\\') + 1) -subForm.image = `${import.meta.env.VITE_APP_IMAGE_URL}/${path}` -refSettingFile.value = '' -}) -.catch(() => { -chooseFileName = '' -subForm.image = '' -refSettingFile.value = '' -}) -} -#end -##生成form item -#macro(formScript) - #foreach($item in $formConfig) - #if($item.componentType=="uploadImage") - #fileUploadSave() - #elseif($item.componentType=="selectApi") ##selectApi - //下拉数据选择 - let select${item.fieldCase} = $ref([]) - const select${item.fieldCase}Req = () => { - let reqConfig = { - url: '${item.api}', - method: '${item.method}' - } - axiosReq(reqConfig).then((resData) => { - select${item.fieldCase} = resData.data - }) - } - #elseif($item.componentType=="cascaderApi") ##cascaderApi - //级联数据处理 - let cascade${item.fieldCase} = $ref([]) - const cascadeProps = { - multiple: false, - value: '${item}', - label: '${item.label}', - children: '${item.children}' - } - const cascade${item.fieldCase}Req = () => { - let reqConfig = { - url: '${item.api}', - method: '${item.method}' - } - axiosReq(reqConfig).then((resData) => { - cascade${item.fieldCase} = resData.data - }) - } - const handleCascade = (data) => { - console.log(data) - } - #elseif($item.componentType=="datetimerange") ##datetimerange - //时间packing - let startEndArr=$ref([]) - const dateTimePacking = (timeArr) => { - startEndArr= timeArr - if (timeArr && timeArr.length === 2) { - subForm.startTime = timeArr[0] - subForm.endTime = timeArr[1] - } else { - subForm.startTime = '' - subForm.endTime = '' - } - } - #end - #end -#end -##onMouted需要调用的请求 -#macro(onMountedScript) - #foreach($item in $formConfig) - #if($item.componentType=="selectApi")##selectApi - select${item.fieldCase}Req() - #elseif($item.componentType=="cascaderApi") ##cascader - cascade${item.fieldCase}Req() - #end - #end -#end \ No newline at end of file diff --git a/velocity-tmp-dir/front-vms/element-plus/queryUtils.vm b/velocity-tmp-dir/front-vms/element-plus/queryUtils.vm index a957a48..25a619e 100644 --- a/velocity-tmp-dir/front-vms/element-plus/queryUtils.vm +++ b/velocity-tmp-dir/front-vms/element-plus/queryUtils.vm @@ -28,10 +28,10 @@ placeholder="${item.desc}" style="width:${item.width}px"> + :value="item.${item.valueKey}"/> #elseif($item.componentType=="cascaderApi") ##cascaderApi @@ -78,49 +78,15 @@ #macro(queryScript) #foreach($item in $queryConfig) #if($item.componentType=="selectApi")##selectApi - let select${item.fieldCase} = $ref([]) - const select${item.fieldCase}Req = () => { + let ${item.field}Data = $ref([]) + const ${item.field}Req = () => { let reqConfig = { - url: '${item.api}', - method: '${item.method}', - } - axiosReq(reqConfig).then((resData) => { - select${item.fieldCase} = resData.data - }) - } - #elseif($item.componentType=="cascaderApi") ##cascader - let cascade${item.fieldCase} = $ref([]) - const cascadeProps = { - multiple: false, - value: '${item}', - label: '${item.label}', - children: '${item.children}' - } - const cascade${item.fieldCase}Req = () => { - let reqConfig = { - url: '${item.api}', - method: '${item.method}' - } - axiosReq(reqConfig).then((resData) => { - cascade${item.fieldCase} = resData.data - }) - } - const handleCascade = (data) => { - console.log(data) - } - #elseif($item.componentType=="datetimerange") ##datetimerange - - let selectStartEndArr=$ref([]) - const dateTimePacking = (timeArr) => { - selectStartEndArr= timeArr - if (timeArr && timeArr.length === 2) { - searchForm.startTime = timeArr[0] - searchForm.endTime = timeArr[1] - } else { - searchForm.startTime = '' - searchForm.endTime = '' - } + url: '${item.api}', + method: '${item.method}', } + axiosReq(reqConfig).then(({records}) => { + ${item.field}Data = records + })} #end #end #end @@ -130,7 +96,7 @@ onMounted(()=>{ selectPageReq() #foreach($item in $queryConfig) #if($item.componentType=="selectApi")##selectApi - select${item.fieldCase}Req() + ${item.field}Req() #end #end }) diff --git a/velocity-tmp-dir/front-vms/element-plus/routerItem.vm b/velocity-tmp-dir/front-vms/element-plus/routerItem.vm index 4abec7c..234c329 100644 --- a/velocity-tmp-dir/front-vms/element-plus/routerItem.vm +++ b/velocity-tmp-dir/front-vms/element-plus/routerItem.vm @@ -10,7 +10,7 @@ component: () => import('@/views/${basicConfig.routerParentDir}/${basicConfig.ap name: '${basicConfig.apiFileNameFirstCase}TableQuery', meta: { title: '${basicConfig.apiFileName}列表' } }, -#if($commonConfig.isAdd||$commonConfig.isEdit) +#if($tableConfig.isAdd||$tableConfig.isEdit) { path: '${basicConfig.apiFileName}-add-edit', component: () => import('@/views/${basicConfig.routerParentDir}/${basicConfig.apiFileName}/${basicConfig.apiFileNameFirstCase}AddEdit.vue'), @@ -19,7 +19,7 @@ hidden: true, meta: { title: '新增编辑', activeMenu: '/${basicConfig.routerParentDir}/${basicConfig.apiFileName}-table-query' } }, #end -#if($commonConfig.isDetail) +#if($tableConfig.isDetail) { path: '${basicConfig.apiFileName}-detail', component: () => import('@/views/${basicConfig.routerParentDir}/${basicConfig.apiFileName}/${basicConfig.apiFileNameFirstCase}Detail.vue'), @@ -27,6 +27,6 @@ name: '${basicConfig.apiFileNameFirstCase}Detail', hidden: true, meta: { title: '详情', activeMenu: '/${basicConfig.routerParentDir}/${basicConfig.apiFileName}-table-query' } } -] -} #end +] +} \ No newline at end of file diff --git a/velocity-tmp-dir/front-vms/element-plus/tableQuery.vm b/velocity-tmp-dir/front-vms/element-plus/tableQuery.vm index 3595b57..93896e5 100644 --- a/velocity-tmp-dir/front-vms/element-plus/tableQuery.vm +++ b/velocity-tmp-dir/front-vms/element-plus/tableQuery.vm @@ -1,20 +1,17 @@ #parse("tableQueryUtils.vm")