mirror of https://gitee.com/stylefeng/roses
【7.6.0】【sys】【org approver】更新审批人绑定接口
parent
7b475d4fa2
commit
44f420f1c3
|
@ -5,10 +5,12 @@ import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
|||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.org.entity.HrOrgApprover;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.org.pojo.request.HrOrgApproverRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.org.service.HrOrgApproverService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
@ -49,4 +51,16 @@ public class HrOrgApproverController {
|
|||
return new SuccessResponseData<>(hrOrgApproverService.getOrgApproverList(hrOrgApproverRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新组织机构绑定审批人
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2022/09/13 23:15
|
||||
*/
|
||||
@PostResource(name = "更新组织机构绑定审批人", path = "/hrOrgApprover/bindUserList")
|
||||
public ResponseData<HrOrgApprover> bindUserList(@RequestBody @Validated(HrOrgApproverRequest.add.class) HrOrgApproverRequest hrOrgApproverRequest) {
|
||||
hrOrgApproverService.bindUserList(hrOrgApproverRequest);
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,9 @@ import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 组织机构审批人封装类
|
||||
|
@ -27,13 +29,14 @@ public class HrOrgApproverRequest extends BaseRequest {
|
|||
* 组织审批类型:1-负责人,2-部长,3-体系负责人,4-部门助理,5-资产助理(专员),6-考勤专员,7-HRBP,8-门禁员,9-办公账号员,10-转岗须知员
|
||||
*/
|
||||
@ChineseDescription("组织审批类型:1-负责人,2-部长,3-体系负责人,4-部门助理,5-资产助理(专员),6-考勤专员,7-HRBP,8-门禁员,9-办公账号员,10-转岗须知员")
|
||||
@NotNull(message = "组织审批类型不能为空", groups = {add.class})
|
||||
private Integer orgApproverType;
|
||||
|
||||
/**
|
||||
* 组织机构id
|
||||
*/
|
||||
@ChineseDescription("组织机构id")
|
||||
@NotNull(message = "组织机构id不能为空", groups = {list.class})
|
||||
@NotNull(message = "组织机构id不能为空", groups = {list.class, add.class})
|
||||
private Long orgId;
|
||||
|
||||
/**
|
||||
|
@ -48,4 +51,11 @@ public class HrOrgApproverRequest extends BaseRequest {
|
|||
@ChineseDescription("租户id")
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 用户id集合,一般用在绑定多个用户
|
||||
*/
|
||||
@ChineseDescription("用户id集合")
|
||||
@NotEmpty(message = "用户id集合不能为空", groups = {add.class})
|
||||
private List<Long> userIdList;
|
||||
|
||||
}
|
||||
|
|
|
@ -89,4 +89,12 @@ public interface HrOrgApproverService extends IService<HrOrgApprover> {
|
|||
*/
|
||||
List<HrOrgApprover> getOrgApproverList(HrOrgApproverRequest hrOrgApproverRequest);
|
||||
|
||||
/**
|
||||
* 组织机构审批人,绑定用户(可以绑定多个)
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/6/11 15:51
|
||||
*/
|
||||
void bindUserList(HrOrgApproverRequest hrOrgApproverRequest);
|
||||
|
||||
}
|
|
@ -23,6 +23,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
|
@ -118,6 +119,50 @@ public class HrOrgApproverServiceImpl extends ServiceImpl<HrOrgApproverMapper, H
|
|||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void bindUserList(HrOrgApproverRequest hrOrgApproverRequest) {
|
||||
|
||||
// 获取改组织下,该种类型已经绑定的人
|
||||
LambdaQueryWrapper<HrOrgApprover> wrapper = this.createWrapper(hrOrgApproverRequest);
|
||||
List<HrOrgApprover> alreadyBindUsers = this.list(wrapper);
|
||||
|
||||
// 如果已经绑定的人是空的,则直接绑定
|
||||
if (ObjectUtil.isEmpty(alreadyBindUsers)) {
|
||||
ArrayList<HrOrgApprover> tempApproverList = new ArrayList<>();
|
||||
for (Long userId : hrOrgApproverRequest.getUserIdList()) {
|
||||
HrOrgApprover hrOrgApprover = new HrOrgApprover();
|
||||
hrOrgApprover.setOrgId(hrOrgApproverRequest.getOrgId());
|
||||
hrOrgApprover.setOrgApproverType(hrOrgApproverRequest.getOrgApproverType());
|
||||
hrOrgApprover.setUserId(userId);
|
||||
tempApproverList.add(hrOrgApprover);
|
||||
}
|
||||
this.saveBatch(tempApproverList);
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果有已经绑定的人,则需要判断请求参数中的人是否已经包含在内,包含在内则不用从新绑定
|
||||
List<Long> alreadyBindUserIdList = alreadyBindUsers.stream().map(HrOrgApprover::getUserId).collect(Collectors.toList());
|
||||
ArrayList<HrOrgApprover> tempApprovers = new ArrayList<>();
|
||||
for (Long needToBindUserId : hrOrgApproverRequest.getUserIdList()) {
|
||||
boolean needToAdd = true;
|
||||
for (Long tempUserId : alreadyBindUserIdList) {
|
||||
if (tempUserId.equals(needToBindUserId)) {
|
||||
needToAdd = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (needToAdd) {
|
||||
HrOrgApprover hrOrgApprover = new HrOrgApprover();
|
||||
hrOrgApprover.setOrgId(hrOrgApproverRequest.getOrgId());
|
||||
hrOrgApprover.setOrgApproverType(hrOrgApproverRequest.getOrgApproverType());
|
||||
hrOrgApprover.setUserId(needToBindUserId);
|
||||
tempApprovers.add(hrOrgApprover);
|
||||
}
|
||||
this.saveBatch(tempApprovers);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HrOrgApprover> findList(HrOrgApproverRequest hrOrgApproverRequest) {
|
||||
LambdaQueryWrapper<HrOrgApprover> wrapper = this.createWrapper(hrOrgApproverRequest);
|
||||
|
|
Loading…
Reference in New Issue