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-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..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 @@ -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.deleteByPattern(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 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..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.customer_id=#{customerId} + and a.grid_id=#{gridId} and a.NEIGHBOR_HOOD_NAME=#{neighborHoodName} and a.id !=#{neighborId} 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); + } }