fix:修改商家重复判断
This commit is contained in:
1 parent
2fffce5db5
commit
be22a0a722
3 files changed
+12
-10
No files matched your search
+2
-2
@@ -219,9 +219,9 @@
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="dto.setUserDeptIds != null and dto.setUserDeptIds.size() != 0">
|
||||
<if test="dto.getUserDeptIds != null and dto.getUserDeptIds.size() != 0">
|
||||
and a.user_dept_id in
|
||||
<foreach collection="dto.setUserDeptIds" item="v" open="(" close=")" separator=",">
|
||||
<foreach collection="dto.getUserDeptIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
+2
-2
@@ -59,8 +59,8 @@ public interface MchManageMapper extends PjcloudBaseMapper<MchManageEntity> {
|
||||
.like(ObjectUtil.isNotEmpty(dto.getName()), MchManageEntity::getName, dto.getName())
|
||||
.in(ObjectUtil.isNotEmpty(dto.getDeptIds()), MchManageEntity::getDeptId, dto.getDeptIds())
|
||||
.in(ObjectUtil.isNotEmpty(dto.getIds()), MchManageEntity::getId, dto.getIds())
|
||||
.orderByDesc(MchManageEntity::getCreateTime)
|
||||
.orderByDesc(MchManageEntity::getId);
|
||||
.orderByDesc(MchManageEntity::getDeptId)
|
||||
.orderByDesc(MchManageEntity::getCreateTime);
|
||||
Page list = selectPageByScope(page, wrapper, DataScope.of());
|
||||
list.setRecords(BeanUtils.toBean(list.getRecords(), MchManageVo.class));
|
||||
return list;
|
||||
|
||||
+8
-6
@@ -78,10 +78,10 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long create(MchManageEntity dto) {
|
||||
if (existName(dto.getName(), null)) {
|
||||
if (existName(dto.getName(), dto.getTypes(), null)) {
|
||||
throw new RuntimeException("商户名不能重复");
|
||||
}
|
||||
if (existDeptId(dto.getDeptId(), null)) {
|
||||
if (existDeptId(dto.getDeptId(), dto.getTypes(), null)) {
|
||||
throw new RuntimeException("该部门已经绑定过商户");
|
||||
}
|
||||
baseMapper.insert(dto);
|
||||
@@ -109,10 +109,10 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
@Override
|
||||
// @CacheEvict(value = CacheConstants.WALLET_MCH, key = "#dto.getId()", condition = "#dto.getId() != null")
|
||||
public void edit(MchManageEntity dto) {
|
||||
if (existName(dto.getName(), dto.getId())) {
|
||||
if (existName(dto.getName(), dto.getTypes(), dto.getId())) {
|
||||
throw new RuntimeException("商户名不能重复");
|
||||
}
|
||||
if (existDeptId(dto.getDeptId(), dto.getId())) {
|
||||
if (existDeptId(dto.getDeptId(), dto.getTypes(), dto.getId())) {
|
||||
throw new RuntimeException("该部门已经绑定过商户");
|
||||
}
|
||||
MchManageEntity mchManage = getSelf().getById(dto.getId());
|
||||
@@ -266,9 +266,10 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
}
|
||||
}
|
||||
|
||||
private boolean existName(String name, Long id) {
|
||||
private boolean existName(String name, String types, Long id) {
|
||||
Long count = baseMapper.selectCount(new LambdaQueryWrapper<MchManageEntity>()
|
||||
.eq(ObjectUtil.isNotEmpty(name), MchManageEntity::getName, name)
|
||||
.eq(ObjectUtil.isNotEmpty(types), MchManageEntity::getTypes, types)
|
||||
.ne(ObjectUtil.isNotEmpty(id), MchManageEntity::getId, id)
|
||||
);
|
||||
if (ObjectUtil.isNotEmpty(id)) {
|
||||
@@ -277,9 +278,10 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
private boolean existDeptId(Long deptId, Long id) {
|
||||
private boolean existDeptId(Long deptId, String types, Long id) {
|
||||
Long count = baseMapper.selectCount(new LambdaQueryWrapper<MchManageEntity>()
|
||||
.eq(ObjectUtil.isNotEmpty(deptId), MchManageEntity::getDeptId, deptId)
|
||||
.eq(ObjectUtil.isNotEmpty(types), MchManageEntity::getTypes, types)
|
||||
.ne(ObjectUtil.isNotEmpty(id), MchManageEntity::getId, id)
|
||||
);
|
||||
if (ObjectUtil.isNotEmpty(id)) {
|
||||
|
||||
Reference in new issue
Block a user