feat(department): 更新领域部门类型检查逻辑
parent
05c27803c5
commit
4c8123b84a
|
|
@ -3,7 +3,6 @@ package com.zcloud.domain.command;
|
|||
import com.alibaba.cola.exception.BizException;
|
||||
import com.zcloud.domain.command.convertor.DomainDepartmentUserCoConvertor;
|
||||
import com.zcloud.domain.domain.gateway.DomainDepartmentGateway;
|
||||
import com.zcloud.domain.domain.gateway.DomainDepartmentUserGateway;
|
||||
import com.zcloud.domain.domain.model.DomainDepartmentE;
|
||||
import com.zcloud.domain.dto.DomainDepartmentAddCmd;
|
||||
import com.zcloud.domain.dto.DomainDepartmentUserAddCmd;
|
||||
|
|
@ -36,7 +35,7 @@ public class DomainDepartmentAddExe {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean execute(DomainDepartmentAddCmd cmd) {
|
||||
//查询领域类型是否存在
|
||||
domainDepartmentRepository.checkDomainType(cmd.getDomainType());
|
||||
domainDepartmentRepository.checkDomainType(cmd.getDomainType(), null);
|
||||
DomainDepartmentE domainDepartmentE = new DomainDepartmentE();
|
||||
BeanUtils.copyProperties(cmd, domainDepartmentE);
|
||||
boolean res = false;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@ public class DomainDepartmentUpdateExe {
|
|||
if (info == null) {
|
||||
throw new BizException("领域管理部门不存在");
|
||||
}
|
||||
//查询领域类型是否存在
|
||||
domainDepartmentRepository.checkDomainType(domainDepartmentUpdateCmd.getDomainType(),domainDepartmentUpdateCmd.getId());
|
||||
|
||||
DomainDepartmentE domainDepartmentE = new DomainDepartmentE();
|
||||
BeanUtils.copyProperties(domainDepartmentUpdateCmd, domainDepartmentE);
|
||||
boolean res = domainDepartmentGateway.update(domainDepartmentE);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.jjb.saas.framework.repository.repo.BaseRepository;
|
|||
import com.zcloud.domain.persistence.dataobject.DomainDepartmentDO;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -17,7 +18,7 @@ import java.util.Map;
|
|||
public interface DomainDepartmentRepository extends BaseRepository<DomainDepartmentDO> {
|
||||
PageResponse<DomainDepartmentDO> listPage(Map<String, Object> params);
|
||||
|
||||
void checkDomainType(@NotEmpty(message = "领域类型不能为空") String domainType);
|
||||
void checkDomainType(@NotEmpty(message = "领域类型不能为空") String domainType, Long id);
|
||||
|
||||
DomainDepartmentDO getInfoById(Long id);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,12 +10,11 @@ import com.zcloud.domain.domain.enums.MenuEnum;
|
|||
import com.zcloud.domain.persistence.dataobject.DomainDepartmentDO;
|
||||
import com.zcloud.domain.persistence.mapper.DomainDepartmentMapper;
|
||||
import com.zcloud.domain.persistence.repository.DomainDepartmentRepository;
|
||||
import com.zcloud.gbscommon.utils.PageQueryHelper;
|
||||
import com.zcloud.gbscommon.utils.Query;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -42,9 +41,12 @@ public class DomainDepartmentRepositoryImpl extends BaseRepositoryImpl<DomainDep
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkDomainType(String domainType) {
|
||||
public void checkDomainType(String domainType, Long id) {
|
||||
QueryWrapper<DomainDepartmentDO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("domain_type", domainType);
|
||||
if(id != null){
|
||||
queryWrapper.ne("id", id);
|
||||
}
|
||||
List<DomainDepartmentDO> list = list(queryWrapper);
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
throw new RuntimeException("该领域类型已存在");
|
||||
|
|
|
|||
Loading…
Reference in New Issue