dev:岗位管理-接口联调
parent
36bc4041fa
commit
9093b3f3a7
|
|
@ -1,6 +1,7 @@
|
|||
package com.zcloud.basic.info.web;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.cola.exception.BizException;
|
||||
import com.zcloud.basic.info.api.PostServiceI;
|
||||
import com.zcloud.basic.info.dto.*;
|
||||
|
|
@ -16,6 +17,8 @@ import lombok.AllArgsConstructor;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
/**
|
||||
* web-adapter
|
||||
|
|
@ -49,6 +52,11 @@ public class PostController {
|
|||
if(qry.getCorpFlag() == 2){
|
||||
qry.setEqCorpinfoId(AuthContext.getTenantId());
|
||||
}
|
||||
|
||||
// 数据类型转换
|
||||
if(StrUtil.isNotBlank(qry.getDepartmentIdString())){
|
||||
qry.setEqDepartmentId(Long.parseLong(qry.getDepartmentIdString()));
|
||||
}
|
||||
return postService.listPage(qry);
|
||||
}
|
||||
|
||||
|
|
@ -58,6 +66,15 @@ public class PostController {
|
|||
if(qry.getCorpFlag() == 2){
|
||||
qry.setCorpinfoId(AuthContext.getTenantId());
|
||||
}
|
||||
// 数据类型转换
|
||||
if(StrUtil.isNotBlank(qry.getDepartmentIdString())){
|
||||
qry.setDepartmentId(Long.parseLong(qry.getDepartmentIdString()));
|
||||
}
|
||||
if(qry.getPostIdsString() != null && qry.getPostIdsString().length > 0){
|
||||
qry.setPostIds(Arrays.stream(qry.getPostIdsString())
|
||||
.map(Long::valueOf)
|
||||
.toArray(Long[]::new));
|
||||
}
|
||||
return postService.list(qry);
|
||||
}
|
||||
|
||||
|
|
@ -79,6 +96,18 @@ public class PostController {
|
|||
@ApiOperation("删除多个")
|
||||
@PutMapping("/removeBatch")
|
||||
public Response removeBatch(@Validated @RequestBody PostRemoveCmd cmd) {
|
||||
|
||||
if(cmd.getIdsString()== null || cmd.getIdsString().length == 0){
|
||||
throw new BizException("请选择要删除的项。");
|
||||
}
|
||||
|
||||
// 数据类型转换
|
||||
if(cmd.getIdsString() != null && cmd.getIdsString().length > 0){
|
||||
cmd.setIds(Arrays.stream(cmd.getIdsString())
|
||||
.map(Long::valueOf)
|
||||
.toArray(Long[]::new));
|
||||
}
|
||||
|
||||
postService.removeBatch(cmd.getIds());
|
||||
return SingleResponse.buildSuccess();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.zcloud.basic.info.command;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.zcloud.basic.info.domain.gateway.PostDepartmentGateway;
|
||||
import com.zcloud.basic.info.domain.gateway.PostGateway;
|
||||
import com.zcloud.basic.info.domain.model.PostDepartmentE;
|
||||
|
|
@ -12,6 +13,7 @@ import org.springframework.beans.BeanUtils;
|
|||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
|
@ -30,6 +32,17 @@ public class PostAddExe {
|
|||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean execute(PostAddCmd cmd) {
|
||||
|
||||
// 数据类型转换
|
||||
if(StrUtil.isNotBlank(cmd.getDepartmentIdString())){
|
||||
cmd.setDepartmentId(Long.parseLong(cmd.getDepartmentIdString()));
|
||||
}
|
||||
if(cmd.getDepartmentIdsString() != null && cmd.getDepartmentIdsString().length > 0){
|
||||
cmd.setDepartmentIds(Arrays.stream(cmd.getDepartmentIdsString())
|
||||
.map(Long::valueOf)
|
||||
.toArray(Long[]::new));
|
||||
}
|
||||
|
||||
PostE postE = new PostE();
|
||||
BeanUtils.copyProperties(cmd, postE);
|
||||
boolean res = false;
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@ public class PostRemoveExe {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean execute(Long id) {
|
||||
// 这段代码后续放到user的方法中, 校验是否有人员使用该岗位
|
||||
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("岗位有相应人员,请解除相关岗位信息后删除。");
|
||||
}
|
||||
// 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);
|
||||
|
|
@ -53,13 +53,13 @@ public class PostRemoveExe {
|
|||
}
|
||||
|
||||
// 这段代码后续放到user的方法中, 校验是否有人员使用该岗位
|
||||
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("岗位有相应人员,请解除相关岗位信息后删除。");
|
||||
}
|
||||
// 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);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.zcloud.basic.info.command;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.cola.exception.BizException;
|
||||
import com.zcloud.basic.info.domain.gateway.PostDepartmentGateway;
|
||||
import com.zcloud.basic.info.domain.gateway.PostGateway;
|
||||
|
|
@ -12,6 +13,7 @@ import org.springframework.beans.BeanUtils;
|
|||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
|
@ -29,6 +31,20 @@ public class PostUpdateExe {
|
|||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void execute(PostUpdateCmd postUpdateCmd) {
|
||||
|
||||
// 数据类型转换
|
||||
if(StrUtil.isNotBlank(postUpdateCmd.getIdString())){
|
||||
postUpdateCmd.setId(Long.parseLong(postUpdateCmd.getIdString()));
|
||||
}
|
||||
if(StrUtil.isNotBlank(postUpdateCmd.getDepartmentIdString())){
|
||||
postUpdateCmd.setDepartmentId(Long.parseLong(postUpdateCmd.getDepartmentIdString()));
|
||||
}
|
||||
if(postUpdateCmd.getDepartmentIdsString() != null && postUpdateCmd.getDepartmentIdsString().length > 0){
|
||||
postUpdateCmd.setDepartmentIds(Arrays.stream(postUpdateCmd.getDepartmentIdsString())
|
||||
.map(Long::valueOf)
|
||||
.toArray(Long[]::new));
|
||||
}
|
||||
|
||||
PostE postE = new PostE();
|
||||
BeanUtils.copyProperties(postUpdateCmd, postE);
|
||||
boolean res = postGateway.update(postE);
|
||||
|
|
|
|||
|
|
@ -24,10 +24,7 @@ import lombok.AllArgsConstructor;
|
|||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
|
|
@ -57,6 +54,11 @@ public class PostQueryExe {
|
|||
Map<String, Object> params = PageQueryHelper.toHashMap(postPageQry);
|
||||
PageResponse<PostDO> pageResponse = postRepository.listPage(params);
|
||||
|
||||
if(CollUtil.isEmpty(pageResponse.getData())){
|
||||
List<PostCO> postCOList = new ArrayList<>();
|
||||
return PageResponse.of(postCOList, pageResponse.getTotalCount(), pageResponse.getPageSize(), pageResponse.getPageIndex());
|
||||
}
|
||||
|
||||
Long[] departmentIds = pageResponse.getData().stream().map(PostDO::getDepartmentId).toArray(Long[]::new);
|
||||
List<DepartmentDO> departmentDOList = departmentRepository.listByIds(Arrays.asList(departmentIds));
|
||||
|
||||
|
|
|
|||
|
|
@ -20,15 +20,17 @@ import javax.validation.constraints.*;
|
|||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PostAddCmd extends Command {
|
||||
@ApiModelProperty(value = "部门id", name = "departmentId", required = true)
|
||||
@NotNull(message = "部门id不能为空")
|
||||
@ApiModelProperty(value = "部门id", name = "departmentIdString", required = true)
|
||||
@NotEmpty(message = "部门id不能为空")
|
||||
private String departmentIdString;
|
||||
private Long departmentId;
|
||||
|
||||
@ApiModelProperty(value = "岗位名称", name = "postName", required = true)
|
||||
@NotEmpty(message = "岗位名称不能为空")
|
||||
private String postName;
|
||||
|
||||
@ApiModelProperty(value = "岗位职责", name = "remarks")
|
||||
@ApiModelProperty(value = "岗位职责", name = "remarks", required = true)
|
||||
@NotEmpty(message = "岗位职责不能为空")
|
||||
private String remarks;
|
||||
|
||||
// @ApiModelProperty(value = "状态 1-启用, 2-禁用", name = "status", required = true)
|
||||
|
|
@ -46,10 +48,11 @@ public class PostAddCmd extends Command {
|
|||
@ApiModelProperty(value = "是否监管岗位 0-否, 1-是", name = "supervisionFlag")
|
||||
private Integer supervisionFlag;
|
||||
|
||||
@ApiModelProperty(value = "岗位-部门权限", name = "departmentIds")
|
||||
@ApiModelProperty(value = "岗位-部门权限", name = "departmentIdsString")
|
||||
private String[] departmentIdsString;
|
||||
private Long[] departmentIds;
|
||||
|
||||
@ApiModelProperty(value = "监管端/企业端标识,1-监管端, 2-企业端", name = "corpFlag")
|
||||
@ApiModelProperty(value = "监管端/企业端标识,1-监管端, 2-企业端", name = "corpFlag", required = true)
|
||||
@NotNull(message = "监管端/企业端标识不能为空")
|
||||
private Integer corpFlag;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.zcloud.basic.info.dto;
|
|||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
|
||||
|
|
@ -31,13 +32,15 @@ public class PostListQry {
|
|||
// 监管端/企业端标识,1-监管端, 2-企业端
|
||||
private Integer corpFlag;
|
||||
|
||||
@ApiModelProperty(value = "主键id集合", name = "postIds", required = true)
|
||||
@ApiModelProperty(value = "主键id集合", name = "postIdsString")
|
||||
// 主键id集合
|
||||
private String[] postIdsString;
|
||||
private Long[] postIds;
|
||||
|
||||
@ApiModelProperty(value = "部门id", name = "departmentId", required = true)
|
||||
@NotNull(message = "部门id不能为空")
|
||||
@ApiModelProperty(value = "部门id", name = "departmentIdString", required = true)
|
||||
@NotEmpty(message = "部门id不能为空")
|
||||
// 部门id
|
||||
private String departmentIdString;
|
||||
private Long departmentId;
|
||||
|
||||
@ApiModelProperty(value = "企业id", name = "corpinfoId", required = true)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.alibaba.cola.dto.PageQuery;
|
|||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
|
||||
|
|
@ -32,9 +33,10 @@ public class PostPageQry extends PageQuery {
|
|||
// 监管端/企业端标识,1-监管端, 2-企业端
|
||||
private Integer corpFlag;
|
||||
|
||||
@ApiModelProperty(value = "部门id", name = "eqDepartmentId", required = true)
|
||||
@NotNull(message = "部门id不能为空")
|
||||
@ApiModelProperty(value = "部门id", name = "departmentIdString", required = true)
|
||||
@NotEmpty(message = "部门id不能为空")
|
||||
// 部门id
|
||||
private String departmentIdString;
|
||||
private Long eqDepartmentId;
|
||||
|
||||
@ApiModelProperty(value = "企业id", name = "eqCorpinfoId")
|
||||
|
|
|
|||
|
|
@ -21,8 +21,9 @@ import javax.validation.constraints.*;
|
|||
@AllArgsConstructor
|
||||
public class PostRemoveCmd extends Command {
|
||||
|
||||
@ApiModelProperty(value = "主键", name = "ids", required = true)
|
||||
@NotNull(message = "主键不能为空")
|
||||
@ApiModelProperty(value = "主键", name = "idsString", required = true)
|
||||
@NotEmpty(message = "主键不能为空")
|
||||
private String[] idsString;
|
||||
private Long[] ids;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,19 +20,22 @@ import javax.validation.constraints.*;
|
|||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PostUpdateCmd extends Command {
|
||||
@ApiModelProperty(value = "主键", name = "id", required = true)
|
||||
@NotNull(message = "主键不能为空")
|
||||
@ApiModelProperty(value = "主键", name = "idString", required = true)
|
||||
@NotEmpty(message = "主键不能为空")
|
||||
private String idString;
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "部门id", name = "departmentId", required = true)
|
||||
@NotNull(message = "部门id不能为空")
|
||||
@ApiModelProperty(value = "部门id", name = "departmentIdString", required = true)
|
||||
@NotEmpty(message = "部门id不能为空")
|
||||
private String departmentIdString;
|
||||
private Long departmentId;
|
||||
|
||||
@ApiModelProperty(value = "岗位名称", name = "postName", required = true)
|
||||
@NotEmpty(message = "岗位名称不能为空")
|
||||
private String postName;
|
||||
|
||||
@ApiModelProperty(value = "岗位职责", name = "remarks")
|
||||
@ApiModelProperty(value = "岗位职责", name = "remarks", required = true)
|
||||
@NotEmpty(message = "岗位职责不能为空")
|
||||
private String remarks;
|
||||
|
||||
// @ApiModelProperty(value = "状态 1-启用, 2-禁用", name = "status", required = true)
|
||||
|
|
@ -50,7 +53,8 @@ public class PostUpdateCmd extends Command {
|
|||
@ApiModelProperty(value = "是否监管岗位 0-否, 1-是", name = "supervisionFlag")
|
||||
private Integer supervisionFlag;
|
||||
|
||||
@ApiModelProperty(value = "岗位 部门权限", name = "departmentIds")
|
||||
@ApiModelProperty(value = "岗位 部门权限", name = "departmentIdsString")
|
||||
private String[] departmentIdsString;
|
||||
private Long[] departmentIds;
|
||||
|
||||
@ApiModelProperty(value = "监管端/企业端标识,1-监管端, 2-企业端", name = "corpFlag", required = true)
|
||||
|
|
|
|||
Loading…
Reference in New Issue