From 9cdaf85171ecc701b91280357e80c9546ccfbfec Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 09:11:59 +0800 Subject: [PATCH 01/20] =?UTF-8?q?=E4=BF=AE=E6=94=B9redis=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ym-gateway/src/main/resources/application.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ym-gateway/src/main/resources/application.yml b/ym-gateway/src/main/resources/application.yml index 84fb44c..b7b57ce 100644 --- a/ym-gateway/src/main/resources/application.yml +++ b/ym-gateway/src/main/resources/application.yml @@ -30,10 +30,10 @@ spring: max-request-size: 100MB enabled: true redis: - database: 0 - host: 124.221.241.144 - port: 6379 - password: why123456 # 密码(默认为空) + database: 5 + host: redis.picaiba.com + port: 6380 + password: # 密码(默认为空) timeout: 6000ms # 连接超时时长(毫秒) jedis: pool: From 37a7f6ae13391db00726b0c67051771e08d7e89c Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 09:14:53 +0800 Subject: [PATCH 02/20] =?UTF-8?q?=E4=BF=AE=E6=94=B9redis=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ym-gateway/src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ym-gateway/src/main/resources/application.yml b/ym-gateway/src/main/resources/application.yml index b7b57ce..769bdc4 100644 --- a/ym-gateway/src/main/resources/application.yml +++ b/ym-gateway/src/main/resources/application.yml @@ -30,7 +30,7 @@ spring: max-request-size: 100MB enabled: true redis: - database: 5 + database: 2 host: redis.picaiba.com port: 6380 password: # 密码(默认为空) From 266ce0c6a7dd39b610f64a8d7c187de6ea1c19d7 Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 09:44:15 +0800 Subject: [PATCH 03/20] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=89=AB?= =?UTF-8?q?=E7=A0=81=E6=9E=AA=E7=9B=91=E5=90=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../barcode/listener/GlobalKeyListenerExample.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ym-barcode/src/main/java/com/cnbm/barcode/listener/GlobalKeyListenerExample.java b/ym-barcode/src/main/java/com/cnbm/barcode/listener/GlobalKeyListenerExample.java index 1bc1d10..98586d9 100644 --- a/ym-barcode/src/main/java/com/cnbm/barcode/listener/GlobalKeyListenerExample.java +++ b/ym-barcode/src/main/java/com/cnbm/barcode/listener/GlobalKeyListenerExample.java @@ -48,14 +48,17 @@ public class GlobalKeyListenerExample implements NativeKeyListener { return NativeKeyEvent.getKeyText(n); }).collect(Collectors.toList()); - for (String s : collect) { - result = result + s; - } if (queue.size() == 5) { - log.info("符合标准的扫码是:"+ result.replace("Enter","")); + for (String s : collect) { + result = result + s; + } }else { - log.info("符合标准的扫码是:"+ result.substring(1).replace("Enter","")); + for (int i = 1; i < collect.size(); i++) { + result = result + collect.get(i); + } } + + log.info("符合标准的扫码是:"+ result.replace("Enter","")); queue.clear(); } if (queue.size() == 6){ From 2902a959f364191821965fa6af5a08cad106ed0d Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 13:39:20 +0800 Subject: [PATCH 04/20] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E6=8E=A5=E5=8F=A3=E7=9A=84swagger=E6=B3=A8=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cnbm/admin/config/SecurityConfig.java | 5 ++++- .../admin/controller/SysDictDataController.java | 12 ++++++------ .../admin/controller/SysDictTypeController.java | 12 ++++++------ .../admin/controller/SysLogErrorController.java | 8 ++++---- .../controller/SysLogOperationController.java | 10 +++++----- .../cnbm/admin/controller/SysMenuController.java | 2 +- .../admin/controller/SysParamsController.java | 12 ++++++------ .../cnbm/admin/controller/SysRoleController.java | 10 +++++----- .../cnbm/admin/controller/SysUserController.java | 16 ++++++++-------- .../src/main/java/com/cnbm/AdminApplication.java | 3 ++- 10 files changed, 47 insertions(+), 43 deletions(-) diff --git a/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java b/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java index 3c66bed..01bb30f 100644 --- a/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java +++ b/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java @@ -48,7 +48,10 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { .and() .authorizeRequests() // 对于登录接口 允许匿名访问 - .antMatchers("/login").anonymous() + .antMatchers("/login","/swagger/**","/v2/api-docs", + "/doc.html", + "/swagger-resources/**", + "/swagger-ui/**").anonymous() // .antMatchers("/testCors").hasAuthority("system:dept:list222") // 除上面外的所有请求全部需要鉴权认证 .anyRequest().authenticated(); diff --git a/ym-admin/src/main/java/com/cnbm/admin/controller/SysDictDataController.java b/ym-admin/src/main/java/com/cnbm/admin/controller/SysDictDataController.java index 3f799cd..982d63d 100644 --- a/ym-admin/src/main/java/com/cnbm/admin/controller/SysDictDataController.java +++ b/ym-admin/src/main/java/com/cnbm/admin/controller/SysDictDataController.java @@ -36,12 +36,12 @@ public class SysDictDataController { @GetMapping("page") @ApiOperation("字典数据") @ApiImplicitParams({ - @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , - @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , - @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , - @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") , - @ApiImplicitParam(name = "dictLabel", value = "字典标签", paramType = "query", dataType="String"), - @ApiImplicitParam(name = "dictValue", value = "字典值", paramType = "query", dataType="String") + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) , + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class) , + @ApiImplicitParam(name = "dictLabel", value = "字典标签", paramType = "query", dataTypeClass=String.class), + @ApiImplicitParam(name = "dictValue", value = "字典值", paramType = "query", dataTypeClass=String.class) }) @PreAuthorize("@ex.hasAuthority('sys:dept:page')") public Result> page(@ApiIgnore @RequestParam Map params){ diff --git a/ym-admin/src/main/java/com/cnbm/admin/controller/SysDictTypeController.java b/ym-admin/src/main/java/com/cnbm/admin/controller/SysDictTypeController.java index 222fcff..0a547ea 100644 --- a/ym-admin/src/main/java/com/cnbm/admin/controller/SysDictTypeController.java +++ b/ym-admin/src/main/java/com/cnbm/admin/controller/SysDictTypeController.java @@ -38,12 +38,12 @@ public class SysDictTypeController { @GetMapping("page") @ApiOperation("字典类型") @ApiImplicitParams({ - @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , - @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , - @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , - @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") , - @ApiImplicitParam(name = "dictType", value = "字典类型", paramType = "query", dataType="String"), - @ApiImplicitParam(name = "dictName", value = "字典名称", paramType = "query", dataType="String") + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) , + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class) , + @ApiImplicitParam(name = "dictType", value = "字典类型", paramType = "query", dataTypeClass=String.class), + @ApiImplicitParam(name = "dictName", value = "字典名称", paramType = "query", dataTypeClass=String.class) }) @PreAuthorize("@ex.hasAuthority('sys:dict:page')") public Result> page(@ApiIgnore @RequestParam Map params){ diff --git a/ym-admin/src/main/java/com/cnbm/admin/controller/SysLogErrorController.java b/ym-admin/src/main/java/com/cnbm/admin/controller/SysLogErrorController.java index 6aef1ec..21c7e7e 100644 --- a/ym-admin/src/main/java/com/cnbm/admin/controller/SysLogErrorController.java +++ b/ym-admin/src/main/java/com/cnbm/admin/controller/SysLogErrorController.java @@ -38,10 +38,10 @@ public class SysLogErrorController { @GetMapping("page") @ApiOperation("分页") @ApiImplicitParams({ - @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , - @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , - @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , - @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) , + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class) }) public Result> page(@ApiIgnore @RequestParam Map params){ PageData page = sysLogErrorService.page(params); diff --git a/ym-admin/src/main/java/com/cnbm/admin/controller/SysLogOperationController.java b/ym-admin/src/main/java/com/cnbm/admin/controller/SysLogOperationController.java index 6034d18..f571fee 100644 --- a/ym-admin/src/main/java/com/cnbm/admin/controller/SysLogOperationController.java +++ b/ym-admin/src/main/java/com/cnbm/admin/controller/SysLogOperationController.java @@ -38,11 +38,11 @@ public class SysLogOperationController { @GetMapping("page") @ApiOperation("分页") @ApiImplicitParams({ - @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , - @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , - @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , - @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") , - @ApiImplicitParam(name = "status", value = "状态 0:失败 1:成功", paramType = "query", dataType="int") + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) , + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class) , + @ApiImplicitParam(name = "status", value = "状态 0:失败 1:成功", paramType = "query", dataTypeClass=String.class) }) public Result> page(@ApiIgnore @RequestParam Map params){ PageData page = sysLogOperationService.page(params); diff --git a/ym-admin/src/main/java/com/cnbm/admin/controller/SysMenuController.java b/ym-admin/src/main/java/com/cnbm/admin/controller/SysMenuController.java index dcea161..61f88b3 100644 --- a/ym-admin/src/main/java/com/cnbm/admin/controller/SysMenuController.java +++ b/ym-admin/src/main/java/com/cnbm/admin/controller/SysMenuController.java @@ -60,7 +60,7 @@ public class SysMenuController { @GetMapping("list") @ApiOperation("列表") - @ApiImplicitParam(name = "type", value = "菜单类型 0:菜单 1:按钮 null:全部", paramType = "query", dataType="int") + @ApiImplicitParam(name = "type", value = "菜单类型 0:菜单 1:按钮 null:全部", paramType = "query", dataTypeClass=Integer.class) @PreAuthorize("@ex.hasAuthority('sys:menu:list')") public Result> list(Integer type){ List list = sysMenuService.getAllMenuList(type); diff --git a/ym-admin/src/main/java/com/cnbm/admin/controller/SysParamsController.java b/ym-admin/src/main/java/com/cnbm/admin/controller/SysParamsController.java index cfa9adb..68af592 100644 --- a/ym-admin/src/main/java/com/cnbm/admin/controller/SysParamsController.java +++ b/ym-admin/src/main/java/com/cnbm/admin/controller/SysParamsController.java @@ -41,11 +41,11 @@ public class SysParamsController { @GetMapping("page") @ApiOperation("分页") @ApiImplicitParams({ - @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , - @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , - @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , - @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") , - @ApiImplicitParam(name = "paramCode", value = "参数编码", paramType = "query", dataType="String") + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) , + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class) , + @ApiImplicitParam(name = "paramCode", value = "参数编码", paramType = "query", dataTypeClass=String.class) }) @PreAuthorize("@ex.hasAuthority('sys:params:page')") public Result> page(@ApiIgnore @RequestParam Map params){ @@ -105,7 +105,7 @@ public class SysParamsController { @GetMapping("export") @ApiOperation("导出") @LogOperation("导出") - @ApiImplicitParam(name = "paramCode", value = "参数编码", paramType = "query", dataType="String") + @ApiImplicitParam(name = "paramCode", value = "参数编码", paramType = "query", dataTypeClass=String.class) @PreAuthorize("@ex.hasAuthority('sys:params:export')") public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { List list = sysParamsService.list(params); diff --git a/ym-admin/src/main/java/com/cnbm/admin/controller/SysRoleController.java b/ym-admin/src/main/java/com/cnbm/admin/controller/SysRoleController.java index 5e87715..1ac3763 100644 --- a/ym-admin/src/main/java/com/cnbm/admin/controller/SysRoleController.java +++ b/ym-admin/src/main/java/com/cnbm/admin/controller/SysRoleController.java @@ -45,11 +45,11 @@ public class SysRoleController { @GetMapping("page") @ApiOperation("分页") @ApiImplicitParams({ - @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , - @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , - @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , - @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") , - @ApiImplicitParam(name = "name", value = "角色名", paramType = "query", dataType="String") + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) , + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class) , + @ApiImplicitParam(name = "name", value = "角色名", paramType = "query", dataTypeClass=String.class) }) @PreAuthorize("@ex.hasAuthority('sys:role:page')") public Result> page(@ApiIgnore @RequestParam Map params){ diff --git a/ym-admin/src/main/java/com/cnbm/admin/controller/SysUserController.java b/ym-admin/src/main/java/com/cnbm/admin/controller/SysUserController.java index 8bf9bc1..7e93314 100644 --- a/ym-admin/src/main/java/com/cnbm/admin/controller/SysUserController.java +++ b/ym-admin/src/main/java/com/cnbm/admin/controller/SysUserController.java @@ -53,13 +53,13 @@ public class SysUserController { @GetMapping("page") @ApiOperation("分页") @ApiImplicitParams({ - @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , - @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , - @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , - @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") , - @ApiImplicitParam(name = "username", value = "用户名", paramType = "query", dataType="String"), - @ApiImplicitParam(name = "gender", value = "性别", paramType = "query", dataType="String"), - @ApiImplicitParam(name = "deptId", value = "部门ID", paramType = "query", dataType="String") + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) , + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class) , + @ApiImplicitParam(name = "username", value = "用户名", paramType = "query", dataTypeClass=String.class), + @ApiImplicitParam(name = "gender", value = "性别", paramType = "query", dataTypeClass=String.class), + @ApiImplicitParam(name = "deptId", value = "部门ID", paramType = "query", dataTypeClass=String.class) }) @PreAuthorize("@ex.hasAuthority('sys:user:page')") public Result> page(@ApiIgnore @RequestParam Map params){ @@ -153,7 +153,7 @@ public class SysUserController { @GetMapping("export") @ApiOperation("导出") @LogOperation("导出") - @ApiImplicitParam(name = "username", value = "用户名", paramType = "query", dataType="String") + @ApiImplicitParam(name = "username", value = "用户名", paramType = "query", dataTypeClass=String.class) @PreAuthorize("@ex.hasAuthority('sys:user:export')") public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { List list = sysUserService.list(params); diff --git a/ym-gateway/src/main/java/com/cnbm/AdminApplication.java b/ym-gateway/src/main/java/com/cnbm/AdminApplication.java index afa4a80..5c142b6 100644 --- a/ym-gateway/src/main/java/com/cnbm/AdminApplication.java +++ b/ym-gateway/src/main/java/com/cnbm/AdminApplication.java @@ -2,6 +2,7 @@ package com.cnbm; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import springfox.documentation.oas.annotations.EnableOpenApi; /** * @Author weihongyang @@ -9,7 +10,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; * @Version 1.0 */ @SpringBootApplication - +@EnableOpenApi public class AdminApplication { public static void main(String[] args) { SpringApplication.run(AdminApplication.class,args); From 990cb5fd0c7d9813e417c6b674c1c15c48c912ce Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 13:39:44 +0800 Subject: [PATCH 05/20] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9yml=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9A=84redis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ym-gateway/src/main/resources/application.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ym-gateway/src/main/resources/application.yml b/ym-gateway/src/main/resources/application.yml index 769bdc4..22828bf 100644 --- a/ym-gateway/src/main/resources/application.yml +++ b/ym-gateway/src/main/resources/application.yml @@ -30,10 +30,10 @@ spring: max-request-size: 100MB enabled: true redis: - database: 2 + database: 0 host: redis.picaiba.com port: 6380 - password: # 密码(默认为空) + password: '@WSXcde3' # 密码(默认为空) timeout: 6000ms # 连接超时时长(毫秒) jedis: pool: From 891cc99c5494f4ccf59bc05ec3fd552ebbdf3e8d Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 13:40:35 +0800 Subject: [PATCH 06/20] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9Eswagger?= =?UTF-8?q?=E7=9A=84maven=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ym-gateway/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ym-gateway/pom.xml b/ym-gateway/pom.xml index 2d44c76..adbc612 100644 --- a/ym-gateway/pom.xml +++ b/ym-gateway/pom.xml @@ -37,6 +37,11 @@ ym-basic 1.0-SNAPSHOT + + io.springfox + springfox-boot-starter + 3.0.0 + \ No newline at end of file From 22c90cf6bcebdfb5b65e5374f669e0c401b05231 Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 13:40:59 +0800 Subject: [PATCH 07/20] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9Eswagger?= =?UTF-8?q?=E7=9A=84config=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/cnbm/config/SwaggerConfig.java | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 ym-gateway/src/main/java/com/cnbm/config/SwaggerConfig.java diff --git a/ym-gateway/src/main/java/com/cnbm/config/SwaggerConfig.java b/ym-gateway/src/main/java/com/cnbm/config/SwaggerConfig.java new file mode 100644 index 0000000..6aeac5a --- /dev/null +++ b/ym-gateway/src/main/java/com/cnbm/config/SwaggerConfig.java @@ -0,0 +1,85 @@ +package com.cnbm.config; + +import com.cnbm.common.constant.Constant; +import com.google.common.collect.Lists; +import io.swagger.annotations.ApiOperation; +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.oas.annotations.EnableOpenApi; +import springfox.documentation.service.*; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spi.service.contexts.SecurityContext; +import springfox.documentation.spring.web.plugins.Docket; + +import java.util.Arrays; +import java.util.List; + +import static com.google.common.collect.Lists.newArrayList; + +/** + * @Author weihongyang + * @Date 2022/6/21 10:56 AM + * @Version 1.0 + */ +@Configuration +@EnableOpenApi +public class SwaggerConfig { + + /** + * 创建API应用 + * apiInfo() 增加API相关信息 + * 通过select()函数返回一个ApiSelectorBuilder实例,用来控制哪些接口暴露给Swagger来展现, + * 本例采用指定扫描的包路径来定义指定要建立API的目录。 + * + * @return + */ + @Bean + public Docket restApi() { + return new Docket(DocumentationType.SWAGGER_2) + .groupName("标准接口") + .apiInfo(apiInfo("Spring Boot中使用Swagger2构建RESTful APIs", "1.0")) + .useDefaultResponseMessages(true) + .forCodeGeneration(false) + .select() + .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) + .paths(PathSelectors.any()) + .build() + .securityContexts(Arrays.asList(securityContext())) + // ApiKey的name需与SecurityReference的reference保持一致 + .securitySchemes(Arrays.asList(new ApiKey("token", "token", "header"))); + } + + /** + * 创建该API的基本信息(这些基本信息会展现在文档页面中) + * 访问地址:http://ip:port/swagger-ui.html + * + * @return + */ + private ApiInfo apiInfo(String title, String version) { + return new ApiInfoBuilder() + .title(title) + .description("ym-pass文档") + .termsOfServiceUrl("https://www.baidu.com/") + .version(version) + .build(); + } + + private SecurityContext securityContext() { + return SecurityContext.builder() + .securityReferences(defaultAuth()) + .build(); + } + + List defaultAuth() { + AuthorizationScope authorizationScope + = new AuthorizationScope("global", "accessEverything"); + AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; + authorizationScopes[0] = authorizationScope; + return Lists.newArrayList( + new SecurityReference(Constant.TOKEN_HEADER, authorizationScopes)); + } + +} From 8ae19c6c0bdb04238b7752fa32c6d46424d25476 Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 13:41:39 +0800 Subject: [PATCH 08/20] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9cors=E7=9A=84con?= =?UTF-8?q?fig=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cnbm/admin/config/CorsConfig.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/ym-admin/src/main/java/com/cnbm/admin/config/CorsConfig.java b/ym-admin/src/main/java/com/cnbm/admin/config/CorsConfig.java index 55e40e5..5999022 100644 --- a/ym-admin/src/main/java/com/cnbm/admin/config/CorsConfig.java +++ b/ym-admin/src/main/java/com/cnbm/admin/config/CorsConfig.java @@ -1,9 +1,25 @@ package com.cnbm.admin.config; +import com.cnbm.common.utils.DateUtils; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.converter.ByteArrayHttpMessageConverter; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.ResourceHttpMessageConverter; +import org.springframework.http.converter.StringHttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import java.text.SimpleDateFormat; +import java.util.List; +import java.util.TimeZone; + /** * @Author weihongyang * @Date 2022/6/8 10:47 AM @@ -27,4 +43,35 @@ public class CorsConfig implements WebMvcConfigurer { // 跨域允许时间 .maxAge(3600); } + + @Override + public void configureMessageConverters(List> converters) { + converters.add(new ByteArrayHttpMessageConverter()); + converters.add(new StringHttpMessageConverter()); + converters.add(new ResourceHttpMessageConverter()); + converters.add(new AllEncompassingFormHttpMessageConverter()); + converters.add(new StringHttpMessageConverter()); + converters.add(jackson2HttpMessageConverter()); + } + + @Bean + public MappingJackson2HttpMessageConverter jackson2HttpMessageConverter() { + MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); + ObjectMapper mapper = new ObjectMapper(); + + //日期格式转换 + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.setDateFormat(new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN)); + mapper.setTimeZone(TimeZone.getTimeZone("GMT+8")); + + //Long类型转String类型 + SimpleModule simpleModule = new SimpleModule(); + simpleModule.addSerializer(Long.class, ToStringSerializer.instance); + simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); + mapper.registerModule(simpleModule); + + converter.setObjectMapper(mapper); + return converter; + } + } From 8e06463f129ea0ed1517a6587023a48eec31c28a Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 13:44:10 +0800 Subject: [PATCH 09/20] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9VelocityTemplate?= =?UTF-8?q?=E7=9A=84=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/templates/controller.java.vm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ym-generator/src/main/resources/templates/controller.java.vm b/ym-generator/src/main/resources/templates/controller.java.vm index f4e622c..fc2f2b1 100644 --- a/ym-generator/src/main/resources/templates/controller.java.vm +++ b/ym-generator/src/main/resources/templates/controller.java.vm @@ -43,10 +43,10 @@ public class ${table.controllerName} { @GetMapping("page") @ApiOperation("分页") @ApiImplicitParams({ - @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , - @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , - @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , - @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) , + @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) , + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class) }) @PreAuthorize("@ex.hasAuthority('${package.ModuleName}:${table.entityPath}:page')") public Result> page(@ApiIgnore @RequestParam Map params){ From b98c015abce316baef29ec83135ae2d7efe9b73c Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 14:34:34 +0800 Subject: [PATCH 10/20] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9sercurity?= =?UTF-8?q?=E7=9A=84=E6=94=BE=E8=A1=8C=E7=AD=96=E7=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/cnbm/admin/config/SecurityConfig.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java b/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java index 01bb30f..8a6b5c8 100644 --- a/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java +++ b/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java @@ -48,10 +48,11 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { .and() .authorizeRequests() // 对于登录接口 允许匿名访问 - .antMatchers("/login","/swagger/**","/v2/api-docs", + .antMatchers("/login","/swagger/**","/v2/**", "/doc.html", "/swagger-resources/**", - "/swagger-ui/**").anonymous() + "/swagger-ui/**", + "/webjars/**").anonymous() // .antMatchers("/testCors").hasAuthority("system:dept:list222") // 除上面外的所有请求全部需要鉴权认证 .anyRequest().authenticated(); From a3802411d92b5236b3f17d06d7b654eb0189d4c0 Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 14:35:50 +0800 Subject: [PATCH 11/20] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9swagger=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ym-gateway/pom.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ym-gateway/pom.xml b/ym-gateway/pom.xml index adbc612..9a4f017 100644 --- a/ym-gateway/pom.xml +++ b/ym-gateway/pom.xml @@ -41,6 +41,17 @@ io.springfox springfox-boot-starter 3.0.0 + + + io.swagger + swagger-models + + + + + io.swagger + swagger-models + 1.5.21 From 696e15f43620f6e87b87859564425957678b7ac7 Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 14:36:11 +0800 Subject: [PATCH 12/20] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ym-gateway/src/main/resources/application.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ym-gateway/src/main/resources/application.yml b/ym-gateway/src/main/resources/application.yml index 22828bf..7fd704b 100644 --- a/ym-gateway/src/main/resources/application.yml +++ b/ym-gateway/src/main/resources/application.yml @@ -7,14 +7,14 @@ server: min-spare: 30 port: 8080 servlet: - context-path: /ym-admin + context-path: /ym-pass session: cookie: http-only: true spring: application: - name: ym-admin + name: ym-pass # 环境 dev|test|prod profiles: active: dev From 3b7e92447812586ae2085702d3687215aa5fa945 Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 14:46:03 +0800 Subject: [PATCH 13/20] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=94=9F?= =?UTF-8?q?=E4=BA=A7yml=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-prod.yml | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 ym-gateway/src/main/resources/application-prod.yml diff --git a/ym-gateway/src/main/resources/application-prod.yml b/ym-gateway/src/main/resources/application-prod.yml new file mode 100644 index 0000000..b443abc --- /dev/null +++ b/ym-gateway/src/main/resources/application-prod.yml @@ -0,0 +1,40 @@ +spring: + datasource: + #MySQL + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://mysql.picaiba.com:30307/ym_pass?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true + username: root + password: 1qaz@WSX3edc$RFV + # #Oracle + # driver-class-name: oracle.jdbc.OracleDriver + # url: jdbc:oracle:thin:@192.168.10.10:1521:xe + # username: renren_security + # password: 123456 + # #SQLServer + # driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + # url: jdbc:sqlserver://localhost:1433;DatabaseName=renren_security + # username: sa + # password: 123456 + # #postgresql + # driver-class-name: org.postgresql.Driver + # url: jdbc:postgresql://192.168.10.10:5432/postgres + # username: postgres + # password: 123456 + hikari: + pool-name: GrowUpHikariCP + minimum-idle: 1 + maximum-pool-size: 10 + +##多数据源的配置,需要引用renren-dynamic-datasource +#dynamic: +# datasource: +# slave1: +# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver +# url: jdbc:sqlserver://123456:1433;DatabaseName=renren_security +# username: sa +# password: 123456 +# slave2: +# driver-class-name: org.postgresql.Driver +# url: jdbc:postgresql://123456:5432/renren_security +# username: postgres +# password: 123456 \ No newline at end of file From 0218a7548abf5024450b945f5f716e05c16132eb Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 14:46:50 +0800 Subject: [PATCH 14/20] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=89=AB?= =?UTF-8?q?=E7=A0=81=E6=9E=AA=E7=9B=91=E5=90=AC=E5=8F=AA=E5=9C=A8=E7=94=9F?= =?UTF-8?q?=E4=BA=A7=E7=8E=AF=E5=A2=83=E4=B8=AD=E5=90=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cnbm/barcode/listener/GlobalKeyListenerExample.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ym-barcode/src/main/java/com/cnbm/barcode/listener/GlobalKeyListenerExample.java b/ym-barcode/src/main/java/com/cnbm/barcode/listener/GlobalKeyListenerExample.java index 98586d9..e031e4b 100644 --- a/ym-barcode/src/main/java/com/cnbm/barcode/listener/GlobalKeyListenerExample.java +++ b/ym-barcode/src/main/java/com/cnbm/barcode/listener/GlobalKeyListenerExample.java @@ -5,6 +5,7 @@ import com.github.kwhat.jnativehook.NativeHookException; import com.github.kwhat.jnativehook.keyboard.NativeKeyEvent; import com.github.kwhat.jnativehook.keyboard.NativeKeyListener; import lombok.extern.log4j.Log4j2; +import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; import java.util.List; @@ -19,6 +20,7 @@ import java.util.stream.Collectors; */ @Log4j2 @Component +@Profile("prod") public class GlobalKeyListenerExample implements NativeKeyListener { static { From 111473f057388fff2f6408119cd124496321f1da Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 14:47:27 +0800 Subject: [PATCH 15/20] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9swagger=E5=8F=AA?= =?UTF-8?q?=E5=9C=A8=E5=BC=80=E5=8F=91=E7=8E=AF=E5=A2=83=E4=B8=AD=E5=90=AF?= =?UTF-8?q?=E7=94=A8=EF=BC=8C=E5=9C=A8=E7=94=9F=E4=BA=A7=E5=B9=BB=E5=A2=83?= =?UTF-8?q?=E4=B8=AD=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ym-gateway/src/main/java/com/cnbm/config/SwaggerConfig.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ym-gateway/src/main/java/com/cnbm/config/SwaggerConfig.java b/ym-gateway/src/main/java/com/cnbm/config/SwaggerConfig.java index 6aeac5a..5ddb652 100644 --- a/ym-gateway/src/main/java/com/cnbm/config/SwaggerConfig.java +++ b/ym-gateway/src/main/java/com/cnbm/config/SwaggerConfig.java @@ -5,6 +5,7 @@ import com.google.common.collect.Lists; import io.swagger.annotations.ApiOperation; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; @@ -26,6 +27,7 @@ import static com.google.common.collect.Lists.newArrayList; */ @Configuration @EnableOpenApi +@Profile("dev") public class SwaggerConfig { /** From 7b1365b5cdcd35fefa84a8b60b9a6785c241356f Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 15:52:06 +0800 Subject: [PATCH 16/20] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E7=94=9F=E6=88=90=E4=BB=A3=E7=A0=81=E7=9A=84=E5=AD=98?= =?UTF-8?q?=E6=94=BE=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/cnbm/generator/build/CodeGenerator.java | 4 ++-- .../cnbm/generator/engine/EnhanceVelocityTemplateEngine.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java b/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java index c4d11fc..747018b 100644 --- a/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java +++ b/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java @@ -48,8 +48,8 @@ public class CodeGenerator { }) .packageConfig(builder -> { //设置父包名 - builder.parent("com.cnbm") - .moduleName("generator") + builder.parent("com.cnbm.generator") + .moduleName("code") .service("service") .serviceImpl("service.impl") .entity("entity") diff --git a/ym-generator/src/main/java/com/cnbm/generator/engine/EnhanceVelocityTemplateEngine.java b/ym-generator/src/main/java/com/cnbm/generator/engine/EnhanceVelocityTemplateEngine.java index 5dc7229..7d79c0f 100644 --- a/ym-generator/src/main/java/com/cnbm/generator/engine/EnhanceVelocityTemplateEngine.java +++ b/ym-generator/src/main/java/com/cnbm/generator/engine/EnhanceVelocityTemplateEngine.java @@ -24,10 +24,10 @@ public class EnhanceVelocityTemplateEngine extends VelocityTemplateEngine { customFile.forEach((key, value) -> { String fileName = ""; if ("DTO".equals(key)) { - fileName = String.format((path+ File.separator +"src/main/java/com/cnbm/generator"+ File.separator + "dto" + File.separator + entityName + "%s" + ".java"), key); + fileName = String.format((path+ File.separator +"src/main/java/com/cnbm/generator/code"+ File.separator + "dto" + File.separator + entityName + "%s" + ".java"), key); } if ("Excel".equals(key)) { - fileName = String.format((path+ File.separator +"src/main/java/com/cnbm/generator"+ File.separator + "excel" + File.separator + entityName + "%s" + ".java"), key); + fileName = String.format((path+ File.separator +"src/main/java/com/cnbm/generator/code"+ File.separator + "excel" + File.separator + entityName + "%s" + ".java"), key); } this.outputFile(new File(fileName), objectMap, value); }); From 3f8bb4f60707b6d22a87b6be559a39bfcc91193c Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 17:00:02 +0800 Subject: [PATCH 17/20] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cnbm/{AdminApplication.java => YmApplication.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename ym-gateway/src/main/java/com/cnbm/{AdminApplication.java => YmApplication.java} (79%) diff --git a/ym-gateway/src/main/java/com/cnbm/AdminApplication.java b/ym-gateway/src/main/java/com/cnbm/YmApplication.java similarity index 79% rename from ym-gateway/src/main/java/com/cnbm/AdminApplication.java rename to ym-gateway/src/main/java/com/cnbm/YmApplication.java index 5c142b6..120e277 100644 --- a/ym-gateway/src/main/java/com/cnbm/AdminApplication.java +++ b/ym-gateway/src/main/java/com/cnbm/YmApplication.java @@ -11,8 +11,8 @@ import springfox.documentation.oas.annotations.EnableOpenApi; */ @SpringBootApplication @EnableOpenApi -public class AdminApplication { +public class YmApplication { public static void main(String[] args) { - SpringApplication.run(AdminApplication.class,args); + SpringApplication.run(YmApplication.class,args); } } From 7a4b82a94cbd3f7106c3bcc2c76284162331a8e1 Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 17:00:22 +0800 Subject: [PATCH 18/20] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E5=BC=82=E5=B8=B8=E6=8D=95=E8=8E=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/exception/RenExceptionHandler.java | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/ym-admin/src/main/java/com/cnbm/admin/exception/RenExceptionHandler.java b/ym-admin/src/main/java/com/cnbm/admin/exception/RenExceptionHandler.java index 3c2b5d8..9d5f48b 100644 --- a/ym-admin/src/main/java/com/cnbm/admin/exception/RenExceptionHandler.java +++ b/ym-admin/src/main/java/com/cnbm/admin/exception/RenExceptionHandler.java @@ -26,40 +26,40 @@ import java.util.Map; * @Date 2022/6/10 2:05 PM * @Version 1.0 */ -//@RestControllerAdvice -//public class RenExceptionHandler { -// private static final Logger logger = LoggerFactory.getLogger(RenExceptionHandler.class); -// -// @Autowired -// private SysLogErrorService sysLogErrorService; -// -// /** -// * 处理自定义异常 -// */ -// @ExceptionHandler(RenException.class) -// public Result handleRenException(RenException ex){ -// Result result = new Result(); -// result.error(ex.getCode(), ex.getMsg()); -// -// return result; -// } -// -// @ExceptionHandler(DuplicateKeyException.class) -// public Result handleDuplicateKeyException(DuplicateKeyException ex){ -// Result result = new Result(); -// result.error(ErrorCode.DB_RECORD_EXISTS); -// -// return result; -// } -// -// @ExceptionHandler(Exception.class) -// public Result handleException(Exception ex){ -// logger.error(ex.getMessage(), ex); -// +@RestControllerAdvice +public class RenExceptionHandler { + private static final Logger logger = LoggerFactory.getLogger(RenExceptionHandler.class); + + @Autowired + private SysLogErrorService sysLogErrorService; + + /** + * 处理自定义异常 + */ + @ExceptionHandler(RenException.class) + public Result handleRenException(RenException ex){ + Result result = new Result(); + result.error(ex.getCode(), ex.getMsg()); + + return result; + } + + @ExceptionHandler(DuplicateKeyException.class) + public Result handleDuplicateKeyException(DuplicateKeyException ex){ + Result result = new Result(); + result.error(ErrorCode.DB_RECORD_EXISTS); + + return result; + } + + @ExceptionHandler(Exception.class) + public Result handleException(Exception ex){ + logger.error(ex.getMessage(), ex); + // saveLog(ex); -// -// return new Result().error(); -// } + + return new Result().error(); + } // // /** // * 保存异常日志 @@ -84,4 +84,4 @@ import java.util.Map; // //保存 // sysLogErrorService.save(log); // } -//} +} From 62d1a761ccb20a5fd4d008767fb4951e46ef43f5 Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 17:00:45 +0800 Subject: [PATCH 19/20] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9sercurity?= =?UTF-8?q?=E7=9A=84config=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cnbm/admin/config/SecurityConfig.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java b/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java index 8a6b5c8..d6fb33b 100644 --- a/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java +++ b/ym-admin/src/main/java/com/cnbm/admin/config/SecurityConfig.java @@ -1,10 +1,14 @@ package com.cnbm.admin.config; import com.cnbm.admin.filter.JwtAuthenticationTokenFilter; +import com.cnbm.admin.service.impl.UserDetailsServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.AuthenticationProvider; +import org.springframework.security.authentication.dao.DaoAuthenticationProvider; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; @@ -38,6 +42,10 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired private AccessDeniedHandler accessDeniedHandler; + @Autowired + private UserDetailsServiceImpl userDetailsService; + + @Override protected void configure(HttpSecurity http) throws Exception { http @@ -75,4 +83,22 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { public AuthenticationManager authenticationManagerBean() throws Exception { return super.authenticationManagerBean(); } + + + @Bean + public AuthenticationProvider daoAuthenticationProvider() { + DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider(); + daoAuthenticationProvider.setUserDetailsService(userDetailsService); + daoAuthenticationProvider.setPasswordEncoder(passwordEncoder()); + daoAuthenticationProvider.setHideUserNotFoundExceptions(false); + return daoAuthenticationProvider; + } + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + // 加入自定义认证, 无需配置userDetailsService,否则会执行默认的provider + // auth.authenticationProvider(myAuthenticationProvider()); + /* auth.userDetailsService(userService) + .passwordEncoder(passwordEncoder());*/ + auth.authenticationProvider(daoAuthenticationProvider()); + } } From 2bf099ee6d488f02e37dce0a8618580ccc97573b Mon Sep 17 00:00:00 2001 From: weihongyang <1075331873@qq.com> Date: Tue, 21 Jun 2022 17:01:28 +0800 Subject: [PATCH 20/20] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9sercurity?= =?UTF-8?q?=E7=9A=84UserDetailsService=E7=9A=84=E5=AE=9E=E7=8E=B0=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cnbm/admin/service/impl/UserDetailsServiceImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ym-admin/src/main/java/com/cnbm/admin/service/impl/UserDetailsServiceImpl.java b/ym-admin/src/main/java/com/cnbm/admin/service/impl/UserDetailsServiceImpl.java index a71bb7c..dcee45d 100644 --- a/ym-admin/src/main/java/com/cnbm/admin/service/impl/UserDetailsServiceImpl.java +++ b/ym-admin/src/main/java/com/cnbm/admin/service/impl/UserDetailsServiceImpl.java @@ -11,6 +11,7 @@ import com.cnbm.admin.service.SysMenuService; import com.cnbm.common.utils.ConvertUtils; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.authentication.DisabledException; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; @@ -46,6 +47,9 @@ public class UserDetailsServiceImpl implements UserDetailsService { if (Objects.isNull(sysUserEntity)) { throw new UsernameNotFoundException("用户名不存在"); } + if (sysUserEntity.getStatus() == 0) { + throw new DisabledException("该账户已被禁用,请联系管理员"); + } log.info("sysUserEntity的值是"+sysUserEntity.toString()); log.info("sysUserEntity.getSuperAdmin()=="+sysUserEntity.getSuperAdmin()); Set userPermissions = sysMenuService.getUserPermissions(sysUserEntity);