From a21c3790c7278974c306ed2aa7c41603a869516d Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Tue, 15 Mar 2022 14:39:31 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E9=87=8D=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/dao/IcNeighborHoodDao.java | 2 +- .../com/epmet/service/impl/NeighborHoodServiceImpl.java | 6 +++--- .../src/main/resources/mapper/IcNeighborHoodDao.xml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java index 3203e96854..43b6aedaf5 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java @@ -48,7 +48,7 @@ public interface IcNeighborHoodDao extends BaseDao { @Param("agencyNameList") List agencyNameList, @Param("gridNameList") List gridNameList); - Integer checkNameUq(@Param("customerId") String customerId, + Integer checkNameUq(@Param("gridId") String gridId, @Param("neighborHoodName")String neighborHoodName, @Param("neighborId")String neighborId); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java index 5c68f83dba..0aeca0d13b 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java @@ -73,8 +73,8 @@ public class NeighborHoodServiceImpl implements NeighborHoodService { @Override @Transactional(rollbackFor = Exception.class) public void AddNeighborhood(String customerId, IcNeighborHoodFormDTO formDTO) { - //同一客户下,小区名称唯一 - Integer count = icNeighborHoodDao.checkNameUq(customerId,formDTO.getNeighborHoodName(),null); + //同一网格下,小区名称唯一 + Integer count = icNeighborHoodDao.checkNameUq(formDTO.getGridId(),formDTO.getNeighborHoodName(),null); if (null != count && count > 0) { throw new RenException(EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getCode(), EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getMsg()); } @@ -155,7 +155,7 @@ public class NeighborHoodServiceImpl implements NeighborHoodService { @Transactional(rollbackFor = Exception.class) public void UpdateNeighborhood(String customerId, IcNeighborHoodFormDTO formDTO) { //同一客户下,小区名称唯一 - Integer count = icNeighborHoodDao.checkNameUq(customerId,formDTO.getNeighborHoodName(),formDTO.getNeighborHoodId()); + Integer count = icNeighborHoodDao.checkNameUq(formDTO.getGridId(),formDTO.getNeighborHoodName(),formDTO.getNeighborHoodId()); if (null != count && count > 0) { throw new RenException(EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getCode(), EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getMsg()); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml index 36daaf0d27..4b4576bb6b 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml @@ -208,7 +208,7 @@ count(*) from ic_neighbor_hood a where a.del_flag='0' - and a.customer_id=#{customerId} + and a.grid_id=#{customerId} and a.NEIGHBOR_HOOD_NAME=#{neighborHoodName} and a.id !=#{neighborId} From 30f35c723c6935c381871ad5d6e3d8fa65a265c6 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Tue, 15 Mar 2022 14:49:52 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E9=87=8D=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/IcNeighborHoodDao.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml index 4b4576bb6b..acc02135cf 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml @@ -208,7 +208,7 @@ count(*) from ic_neighbor_hood a where a.del_flag='0' - and a.grid_id=#{customerId} + and a.grid_id=#{gridId} and a.NEIGHBOR_HOOD_NAME=#{neighborHoodName} and a.id !=#{neighborId} From d46e8e11545409a288616322038239026429984a Mon Sep 17 00:00:00 2001 From: jianjun Date: Wed, 16 Mar 2022 17:20:52 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E5=BF=85=E9=A1=BB=E5=85=A8=E5=B9=B2=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/commons/tools/redis/RedisKeys.java | 10 +++++++++- .../java/com/epmet/redis/GovCustomerMenuRedis.java | 12 ++++-------- .../service/impl/GovCustomerMenuServiceImpl.java | 5 ++--- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index 0798627046..e09d7c1615 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -734,6 +734,14 @@ public class RedisKeys { } public static String getCustomerMenuList(String customerId, Integer type) { - return rootPrefix.concat("oper:access:nav:customerId:").concat(customerId).concat(":type:")+type; + return getCustomerMenuListPrefix().concat(customerId).concat(":type:")+type; + } + + /** + * desc:菜单缓存前缀 + * @return + */ + public static String getCustomerMenuListPrefix() { + return rootPrefix.concat("oper:access:nav:customerId:"); } } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java index 3cc19b8ae2..6d2ec60e64 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java @@ -17,6 +17,7 @@ package com.epmet.redis; +import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.dto.GovMenuDTO; @@ -66,16 +67,11 @@ public class GovCustomerMenuRedis { /** * desc:删除客户菜单缓存 - * @param customerId - * @param type * @see com.epmet.enums.MenuTypeEnum */ - public void delCustomerMenu(String customerId, Integer type) { - if (checkParam(customerId, type)) { - String key = RedisKeys.getCustomerMenuList(customerId, type); - redisUtils.delete(key); - } - + public void delAllCustomerMenu() { + String key = RedisKeys.getCustomerMenuListPrefix().concat(StrConstant.STAR); + redisUtils.delete(key); } private boolean checkParam(String customerId, Integer type) { diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovCustomerMenuServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovCustomerMenuServiceImpl.java index 95e4f2f8d2..a5933f8e58 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovCustomerMenuServiceImpl.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovCustomerMenuServiceImpl.java @@ -28,7 +28,6 @@ import com.epmet.dao.GovCustomerMenuDao; import com.epmet.dto.GovCustomerMenuDTO; import com.epmet.dto.form.MenuConfigFormDTO; import com.epmet.entity.GovCustomerMenuEntity; -import com.epmet.enums.MenuTypeEnum; import com.epmet.redis.GovCustomerMenuRedis; import com.epmet.service.GovCustomerMenuService; import org.apache.commons.lang3.StringUtils; @@ -119,8 +118,8 @@ public class GovCustomerMenuServiceImpl extends BaseServiceImpl govCustomerMenuRedis.delCustomerMenu(customerId, MenuTypeEnum.MENU.value())); + //删除全部客户缓存 + govCustomerMenuRedis.delAllCustomerMenu(); } @Override From 303703a316f6a93b497c7e4875c364bf11e22bd9 Mon Sep 17 00:00:00 2001 From: jianjun Date: Wed, 16 Mar 2022 17:45:08 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E5=BF=85=E9=A1=BB=E5=85=A8=E5=B9=B2=E6=8E=89=20*?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/redis/GovCustomerMenuRedis.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java index 6d2ec60e64..6190a7c4c0 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java @@ -71,7 +71,7 @@ public class GovCustomerMenuRedis { */ public void delAllCustomerMenu() { String key = RedisKeys.getCustomerMenuListPrefix().concat(StrConstant.STAR); - redisUtils.delete(key); + redisUtils.deleteByPattern(key); } private boolean checkParam(String customerId, Integer type) { From 3a27ac452f02eb3b0ac3e102242d411d93cf23cc Mon Sep 17 00:00:00 2001 From: jianjun Date: Wed, 16 Mar 2022 19:21:14 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=A0=B9=E6=8D=AEid=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=B9=E6=B3=95=20=E5=B9=B6=E5=A1=AB?= =?UTF-8?q?=E5=85=85=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/config/MybatisPlusConfig.java | 6 +++++ .../epmet/commons/mybatis/dao/BaseDao.java | 4 ++-- .../interceptor/MybatisPlusSqlInjector.java | 23 +++++++++++++++++++ .../commons/mybatis/mapper/MyBaseMapper.java | 21 +++++++++++++++++ .../epmetuser/test/UserControllerTest.java | 12 ++++++++++ 5 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/MybatisPlusSqlInjector.java create mode 100644 epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/mapper/MyBaseMapper.java diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/config/MybatisPlusConfig.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/config/MybatisPlusConfig.java index 8ef978f3c3..d5537bb17d 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/config/MybatisPlusConfig.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/config/MybatisPlusConfig.java @@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; import com.epmet.commons.mybatis.interceptor.DataFilterInterceptor; +import com.epmet.commons.mybatis.interceptor.MybatisPlusSqlInjector; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.Order; @@ -44,5 +45,10 @@ public class MybatisPlusConfig { interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); return interceptor; } + @Bean + @Order(2) + public MybatisPlusSqlInjector mybatisPlusSqlInjector(){ + return new MybatisPlusSqlInjector(); + } } diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dao/BaseDao.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dao/BaseDao.java index f23017b6f7..30b95eaa4c 100644 --- a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dao/BaseDao.java +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dao/BaseDao.java @@ -8,7 +8,7 @@ package com.epmet.commons.mybatis.dao; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.epmet.commons.mybatis.mapper.MyBaseMapper; /** * 基础Dao @@ -16,6 +16,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; * @author Mark sunlightcs@gmail.com * @since 1.0.0 */ -public interface BaseDao extends BaseMapper { +public interface BaseDao extends MyBaseMapper { } diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/MybatisPlusSqlInjector.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/MybatisPlusSqlInjector.java new file mode 100644 index 0000000000..21cc58edd8 --- /dev/null +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/MybatisPlusSqlInjector.java @@ -0,0 +1,23 @@ +package com.epmet.commons.mybatis.interceptor; + +import com.baomidou.mybatisplus.core.injector.AbstractMethod; +import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector; +import com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteByIdWithFill; + +import java.util.List; + +/** + * desc:mybatisPlus拦截器 + * + * @author: LiuJanJun + * @date: 2022/3/16 6:33 下午 + * @version: 1.0 + */ +public class MybatisPlusSqlInjector extends DefaultSqlInjector { + @Override + public List getMethodList(Class mapperClass) { + final List methods = super.getMethodList(mapperClass); + methods.add(new LogicDeleteByIdWithFill()); + return methods; + } +} diff --git a/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/mapper/MyBaseMapper.java b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/mapper/MyBaseMapper.java new file mode 100644 index 0000000000..13d589e918 --- /dev/null +++ b/epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/mapper/MyBaseMapper.java @@ -0,0 +1,21 @@ +package com.epmet.commons.mybatis.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * desc:自定义mapper方法 + * + * @author: LiuJanJun + * @date: 2022/3/16 6:42 下午 + * @version: 1.0 + */ +public interface MyBaseMapper extends BaseMapper { + /** + * 根据Id逻辑删除 并 填充其他字段的值 id必填 + * + * @param entity 要删除的实体对象 + * @return 受影响记录数量 + */ + int deleteByIdWithFill(Entity entity); + +} diff --git a/epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/UserControllerTest.java b/epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/UserControllerTest.java index 06d674a4e3..a777c0c4da 100644 --- a/epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/UserControllerTest.java +++ b/epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/UserControllerTest.java @@ -1,7 +1,9 @@ package com.epmet.epmetuser.test; import com.epmet.commons.tools.constant.AppClientConstant; +import com.epmet.dao.CustomerStaffDao; import com.epmet.dto.result.LoginUserDetailsResultDTO; +import com.epmet.entity.CustomerStaffEntity; import com.epmet.service.UserService; import org.junit.Test; import org.junit.runner.RunWith; @@ -16,10 +18,20 @@ public class UserControllerTest { @Autowired private UserService userService; + @Autowired + private CustomerStaffDao customerStaffDao; + @Test public void getLoginUserDetails() { LoginUserDetailsResultDTO loginUserDetails = userService.getLoginUserDetails(AppClientConstant.APP_GOV, AppClientConstant.CLIENT_WXMP, "4aaab913d9f11d90a2cb4dd21b075259"); System.out.println(loginUserDetails); } + @Test + public void del() { + CustomerStaffEntity entity = new CustomerStaffEntity(); + //entity.setId("1476792429129445378"); + entity.setRealName("刘建军3"); + customerStaffDao.deleteByIdWithFill(entity); + } }