|
|
@@ -270,6 +270,8 @@ public class KwmAddressService {
|
|
|
throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ADDRESS_NOT_EXISTS);
|
|
|
}
|
|
|
|
|
|
+ checkAddressRepeat(reqVo.getName(), reqVo.getDetailAddress(), kwmAddress.getId());
|
|
|
+
|
|
|
BeanUtils.copyProperties(reqVo, kwmAddress);
|
|
|
if (kwmAddressMapper.updateById(kwmAddress) <= 0) {
|
|
|
throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
@@ -286,15 +288,7 @@ public class KwmAddressService {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = {})
|
|
|
public void add(AddressAddReqVo reqVo) {
|
|
|
- LambdaQueryWrapper<KwmAddress> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(KwmAddress::getName, reqVo.getName()).
|
|
|
- eq(KwmAddress::getDelFlag, Global.NO).
|
|
|
- eq(KwmAddress::getStatus, Global.NO).
|
|
|
- eq(KwmAddress::getEntId, LoginUserHolder.getEntId());
|
|
|
- if (kwmAddressMapper.selectCount(wrapper).compareTo((long) Global.NUMERICAL_ZERO) > 0) {
|
|
|
- throw new SystemException(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.ADDRESS_EXISTS);
|
|
|
- }
|
|
|
-
|
|
|
+ checkAddressRepeat(reqVo.getName(), reqVo.getDetailAddress(), null);
|
|
|
KwmAddress kwmAddress = new KwmAddress();
|
|
|
BeanUtils.copyProperties(reqVo, kwmAddress);
|
|
|
Long userId = LoginUserHolder.getUserId();
|
|
|
@@ -313,6 +307,26 @@ public class KwmAddressService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void checkAddressRepeat(String name, String detailAddress, Long id) {
|
|
|
+ LambdaQueryWrapper<KwmAddress> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(KwmAddress::getDelFlag, Global.NO).
|
|
|
+ eq(KwmAddress::getStatus, Global.NO).
|
|
|
+ eq(KwmAddress::getEntId, LoginUserHolder.getEntId()).and(
|
|
|
+ wp -> wp.eq(KwmAddress::getName, name).or().eq(KwmAddress::getDetailAddress, detailAddress)
|
|
|
+ );
|
|
|
+ List<KwmAddress> kwmAddressList = kwmAddressMapper.selectList(wrapper);
|
|
|
+ if (CollectionUtils.isNotEmpty(kwmAddressList) && Objects.isNull(id)) {
|
|
|
+ throw new SystemException(HttpStatus.CODE_10301, HttpStatus.MSG_035);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(kwmAddressList) && Objects.nonNull(id)) {
|
|
|
+ List<KwmAddress> kwmAddressList1 = kwmAddressList.stream().filter(item -> !item.getId().equals(id)).toList();
|
|
|
+ if (CollectionUtils.isNotEmpty(kwmAddressList1)) {
|
|
|
+ throw new SystemException(HttpStatus.CODE_10301, HttpStatus.MSG_035);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @param ids 主键
|