Compare commits
No commits in common. "69aac79a943a75994798318e668474eb4d67997b" and "48ebcce75d877b67841e5743ac5d7f11fecfaf55" have entirely different histories.
69aac79a94
...
48ebcce75d
|
|
@ -1,18 +1,12 @@
|
|||
package com.zcloud.basic.info.command;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.zcloud.basic.info.domain.gateway.PostDepartmentGateway;
|
||||
import com.zcloud.basic.info.domain.gateway.PostGateway;
|
||||
import com.alibaba.cola.exception.BizException;
|
||||
import com.zcloud.basic.info.domain.gateway.UserGateway;
|
||||
import com.zcloud.basic.info.persistence.dataobject.UserDO;
|
||||
import com.zcloud.basic.info.persistence.repository.UserRepository;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* web-app
|
||||
|
|
@ -25,19 +19,9 @@ import java.util.List;
|
|||
public class PostRemoveExe {
|
||||
private final PostGateway postGateway;
|
||||
private final PostDepartmentGateway postDepartmentGateway;
|
||||
private final UserRepository userRepository;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean execute(Long id) {
|
||||
// todo 校验是否有人员使用该岗位
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq("post_id", id);
|
||||
queryWrapper.eq("delete_enum", "FALSE");
|
||||
List userPostList = userRepository.list(queryWrapper);
|
||||
if (userPostList != null && userPostList.size() > 0) {
|
||||
throw new BizException("删除失败,该岗位正在被使用");
|
||||
}
|
||||
|
||||
boolean res = postGateway.deletedPostById(id);
|
||||
postDepartmentGateway.deletedPostDepartment(id);
|
||||
if (!res) {
|
||||
|
|
@ -48,20 +32,6 @@ public class PostRemoveExe {
|
|||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean execute(Long[] ids) {
|
||||
|
||||
if (ids == null || ids.length == 0) {
|
||||
throw new BizException("岗位ID不能为空");
|
||||
}
|
||||
|
||||
// todo 校验是否有人员使用该岗位
|
||||
QueryWrapper<UserDO> queryWrapper = new QueryWrapper();
|
||||
queryWrapper.in("post_id", ids);
|
||||
queryWrapper.eq("delete_enum", "FALSE");
|
||||
List<UserDO> userPostList = userRepository.list(queryWrapper);
|
||||
if (userPostList != null && userPostList.size() > 0) {
|
||||
throw new BizException("删除失败,有岗位正在被使用");
|
||||
}
|
||||
|
||||
boolean res = postGateway.deletedPostByIds(ids);
|
||||
postDepartmentGateway.deletedPostDepartment(ids);
|
||||
if (!res) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package com.zcloud.basic.info.gatewayimpl;
|
||||
|
||||
import com.alibaba.cola.exception.BizException;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.zcloud.basic.info.domain.gateway.PostGateway;
|
||||
import com.zcloud.basic.info.domain.model.PostE;
|
||||
import com.zcloud.basic.info.persistence.dataobject.PostDO;
|
||||
|
|
@ -14,7 +12,6 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* web-infrastructure
|
||||
|
|
@ -29,16 +26,6 @@ public class PostGatewayImpl implements PostGateway {
|
|||
|
||||
@Override
|
||||
public Long add(PostE postE) {
|
||||
|
||||
QueryWrapper<PostDO> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("department_id", postE.getDepartmentId());
|
||||
wrapper.eq("post_name", postE.getPostName());
|
||||
wrapper.eq("delete_enum", "FALSE");
|
||||
List<PostDO> postDOList = postRepository.list(wrapper);
|
||||
if(postDOList != null && postDOList.size() > 0) {
|
||||
throw new BizException("保存失败,该岗位名称已存在");
|
||||
}
|
||||
|
||||
PostDO d = new PostDO();
|
||||
BeanUtils.copyProperties(postE, d);
|
||||
if(StringUtils.isEmpty(d.getPostId())){
|
||||
|
|
@ -50,17 +37,6 @@ public class PostGatewayImpl implements PostGateway {
|
|||
|
||||
@Override
|
||||
public Boolean update(PostE postE) {
|
||||
|
||||
QueryWrapper<PostDO> wrapper = new QueryWrapper<>();
|
||||
wrapper.ne("id", postE.getId());
|
||||
wrapper.eq("department_id", postE.getDepartmentId());
|
||||
wrapper.eq("post_name", postE.getPostName());
|
||||
wrapper.eq("delete_enum", "FALSE");
|
||||
List<PostDO> postDOList = postRepository.list(wrapper);
|
||||
if(postDOList != null && postDOList.size() > 0) {
|
||||
throw new BizException("修改失败,该岗位名称已存在");
|
||||
}
|
||||
|
||||
PostDO d = new PostDO();
|
||||
BeanUtils.copyProperties(postE, d);
|
||||
postRepository.updateById(d);
|
||||
|
|
|
|||
Loading…
Reference in New Issue