Browse Source

Merge remote-tracking branch 'remotes/origin/dev_bugfix_ljj' into dev_abandon_grid

dev
jianjun 3 years ago
parent
commit
6db2fee24c
  1. 6
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/config/MybatisPlusConfig.java
  2. 4
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dao/BaseDao.java
  3. 23
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/interceptor/MybatisPlusSqlInjector.java
  4. 21
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/mapper/MyBaseMapper.java
  5. 10
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  6. 12
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java
  7. 5
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovCustomerMenuServiceImpl.java
  8. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java
  9. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java
  10. 2
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml
  11. 12
      epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/UserControllerTest.java

6
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.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.epmet.commons.mybatis.interceptor.DataFilterInterceptor; 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.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
@ -44,5 +45,10 @@ public class MybatisPlusConfig {
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor; return interceptor;
} }
@Bean
@Order(2)
public MybatisPlusSqlInjector mybatisPlusSqlInjector(){
return new MybatisPlusSqlInjector();
}
} }

4
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; package com.epmet.commons.mybatis.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.epmet.commons.mybatis.mapper.MyBaseMapper;
/** /**
* 基础Dao * 基础Dao
@ -16,6 +16,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author Mark sunlightcs@gmail.com * @author Mark sunlightcs@gmail.com
* @since 1.0.0 * @since 1.0.0
*/ */
public interface BaseDao<T> extends BaseMapper<T> { public interface BaseDao<T> extends MyBaseMapper<T> {
} }

23
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<AbstractMethod> getMethodList(Class<?> mapperClass) {
final List<AbstractMethod> methods = super.getMethodList(mapperClass);
methods.add(new LogicDeleteByIdWithFill());
return methods;
}
}

21
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<Entity> extends BaseMapper<Entity> {
/**
* 根据Id逻辑删除 填充其他字段的值 id必填
*
* @param entity 要删除的实体对象
* @return 受影响记录数量
*/
int deleteByIdWithFill(Entity entity);
}

10
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) { 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:");
} }
} }

12
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java

@ -17,6 +17,7 @@
package com.epmet.redis; package com.epmet.redis;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.dto.GovMenuDTO; import com.epmet.dto.GovMenuDTO;
@ -66,16 +67,11 @@ public class GovCustomerMenuRedis {
/** /**
* desc:删除客户菜单缓存 * desc:删除客户菜单缓存
* @param customerId
* @param type
* @see com.epmet.enums.MenuTypeEnum * @see com.epmet.enums.MenuTypeEnum
*/ */
public void delCustomerMenu(String customerId, Integer type) { public void delAllCustomerMenu() {
if (checkParam(customerId, type)) { String key = RedisKeys.getCustomerMenuListPrefix().concat(StrConstant.STAR);
String key = RedisKeys.getCustomerMenuList(customerId, type); redisUtils.deleteByPattern(key);
redisUtils.delete(key);
}
} }
private boolean checkParam(String customerId, Integer type) { private boolean checkParam(String customerId, Integer type) {

5
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.GovCustomerMenuDTO;
import com.epmet.dto.form.MenuConfigFormDTO; import com.epmet.dto.form.MenuConfigFormDTO;
import com.epmet.entity.GovCustomerMenuEntity; import com.epmet.entity.GovCustomerMenuEntity;
import com.epmet.enums.MenuTypeEnum;
import com.epmet.redis.GovCustomerMenuRedis; import com.epmet.redis.GovCustomerMenuRedis;
import com.epmet.service.GovCustomerMenuService; import com.epmet.service.GovCustomerMenuService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -119,8 +118,8 @@ public class GovCustomerMenuServiceImpl extends BaseServiceImpl<GovCustomerMenuD
} }
insertBatch(entities); insertBatch(entities);
} }
//删除缓存 //删除全部客户缓存
formDTO.getCustomerIds().forEach(customerId-> govCustomerMenuRedis.delCustomerMenu(customerId, MenuTypeEnum.MENU.value())); govCustomerMenuRedis.delAllCustomerMenu();
} }
@Override @Override

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java

@ -48,7 +48,7 @@ public interface IcNeighborHoodDao extends BaseDao<IcNeighborHoodEntity> {
@Param("agencyNameList") List<String> agencyNameList, @Param("agencyNameList") List<String> agencyNameList,
@Param("gridNameList") List<String> gridNameList); @Param("gridNameList") List<String> gridNameList);
Integer checkNameUq(@Param("customerId") String customerId, Integer checkNameUq(@Param("gridId") String gridId,
@Param("neighborHoodName")String neighborHoodName, @Param("neighborHoodName")String neighborHoodName,
@Param("neighborId")String neighborId); @Param("neighborId")String neighborId);

6
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 @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void AddNeighborhood(String customerId, IcNeighborHoodFormDTO formDTO) { 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) { if (null != count && count > 0) {
throw new RenException(EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getCode(), EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getMsg()); 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) @Transactional(rollbackFor = Exception.class)
public void UpdateNeighborhood(String customerId, IcNeighborHoodFormDTO formDTO) { 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) { if (null != count && count > 0) {
throw new RenException(EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getCode(), EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getMsg()); throw new RenException(EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getCode(), EpmetErrorCode.NEIGHBOOR_NAME_EXITED.getMsg());
} }

2
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml

@ -208,7 +208,7 @@
count(*) count(*)
from ic_neighbor_hood a from ic_neighbor_hood a
where a.del_flag='0' where a.del_flag='0'
and a.customer_id=#{customerId} and a.grid_id=#{gridId}
and a.NEIGHBOR_HOOD_NAME=#{neighborHoodName} and a.NEIGHBOR_HOOD_NAME=#{neighborHoodName}
<if test=" null != neighborId and neighborId.trim() != ''"> <if test=" null != neighborId and neighborId.trim() != ''">
and a.id !=#{neighborId} and a.id !=#{neighborId}

12
epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/UserControllerTest.java

@ -1,7 +1,9 @@
package com.epmet.epmetuser.test; package com.epmet.epmetuser.test;
import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.dao.CustomerStaffDao;
import com.epmet.dto.result.LoginUserDetailsResultDTO; import com.epmet.dto.result.LoginUserDetailsResultDTO;
import com.epmet.entity.CustomerStaffEntity;
import com.epmet.service.UserService; import com.epmet.service.UserService;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -16,10 +18,20 @@ public class UserControllerTest {
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired
private CustomerStaffDao customerStaffDao;
@Test @Test
public void getLoginUserDetails() { public void getLoginUserDetails() {
LoginUserDetailsResultDTO loginUserDetails = userService.getLoginUserDetails(AppClientConstant.APP_GOV, AppClientConstant.CLIENT_WXMP, "4aaab913d9f11d90a2cb4dd21b075259"); LoginUserDetailsResultDTO loginUserDetails = userService.getLoginUserDetails(AppClientConstant.APP_GOV, AppClientConstant.CLIENT_WXMP, "4aaab913d9f11d90a2cb4dd21b075259");
System.out.println(loginUserDetails); System.out.println(loginUserDetails);
} }
@Test
public void del() {
CustomerStaffEntity entity = new CustomerStaffEntity();
//entity.setId("1476792429129445378");
entity.setRealName("刘建军3");
customerStaffDao.deleteByIdWithFill(entity);
}
} }

Loading…
Cancel
Save