ソースを参照

用户管理相关接口调整

tags/24080901
liuxinxin 1年前
コミット
2d0bd54412
11個のファイルの変更162行の追加62行の削除
  1. +18
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/user/constant/UserAvailableEnum.java
  2. +6
    -6
      pmapi/src/main/java/com/ningdatech/pmapi/user/controller/UserInfoController.java
  3. +6
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/user/entity/UserInfo.java
  4. +80
    -6
      pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java
  5. +0
    -33
      pmapi/src/main/java/com/ningdatech/pmapi/user/model/base/UserRoleInfo.java
  6. +12
    -5
      pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserDetailEditPO.java
  7. +6
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserDetailPO.java
  8. +5
    -4
      pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserDisableOrEnablePO.java
  9. +5
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserInfoListPO.java
  10. +3
    -4
      pmapi/src/main/java/com/ningdatech/pmapi/user/model/vo/ResUserDetailVO.java
  11. +21
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/user/model/vo/UserRoleVO.java

+ 18
- 0
pmapi/src/main/java/com/ningdatech/pmapi/user/constant/UserAvailableEnum.java ファイルの表示

@@ -0,0 +1,18 @@
package com.ningdatech.pmapi.user.constant;

/**
* @author liuxinxin
* @date 2023/2/15 下午5:13
*/

public enum UserAvailableEnum {
/**
* 启用
*/
ENABLE,

/**
* 禁用
*/
DISABLE
}

+ 6
- 6
pmapi/src/main/java/com/ningdatech/pmapi/user/controller/UserInfoController.java ファイルの表示

@@ -4,7 +4,8 @@ package com.ningdatech.pmapi.user.controller;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.user.manage.UserInfoManage;
import com.ningdatech.pmapi.user.model.po.ReqUserDetailEditPO;
import com.ningdatech.pmapi.user.model.po.ReqUserDisablePO;
import com.ningdatech.pmapi.user.model.po.ReqUserDetailPO;
import com.ningdatech.pmapi.user.model.po.ReqUserDisableOrEnablePO;
import com.ningdatech.pmapi.user.model.po.ReqUserInfoListPO;
import com.ningdatech.pmapi.user.model.vo.ResUserDetailVO;
import com.ningdatech.pmapi.user.model.vo.ResUserInfoListVO;
@@ -38,14 +39,14 @@ public class UserInfoController {

@ApiOperation(value = "用户禁用/启用", notes = "用户禁用/启用")
@PostMapping("/disable-enable")
public void disableOrEnable(@Valid @RequestBody ReqUserDisablePO reqUserDisablePO) {
userInfoManage.disableOrEnable(reqUserDisablePO);
public void disableOrEnable(@Valid @RequestBody ReqUserDisableOrEnablePO reqUserDisableOrEnablePO) {
userInfoManage.disableOrEnable(reqUserDisableOrEnablePO);
}

@ApiOperation(value = "用户详情", notes = "用户详情")
@PostMapping("/detail")
public ResUserDetailVO userInfoDetail(@Valid @RequestBody ReqUserInfoListPO reqUserInfoListPO) {
return userInfoManage.userInfoDetail(reqUserInfoListPO);
public ResUserDetailVO userInfoDetail(@Valid @RequestBody ReqUserDetailPO reqUserDetailPO) {
return userInfoManage.userInfoDetail(reqUserDetailPO);
}

@ApiOperation(value = "用户详情编辑", notes = "用户详情编辑")
@@ -54,5 +55,4 @@ public class UserInfoController {
userInfoManage.userInfoDetailEdit(reqUserDetailEditPO);
}


}

+ 6
- 0
pmapi/src/main/java/com/ningdatech/pmapi/user/entity/UserInfo.java ファイルの表示

@@ -2,8 +2,10 @@ package com.ningdatech.pmapi.user.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;
@@ -19,6 +21,8 @@ import java.time.LocalDateTime;
@TableName("nd_user_info")
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "NdUserInfo对象", description = "")
public class UserInfo implements Serializable {

@@ -44,4 +48,6 @@ public class UserInfo implements Serializable {

private String available;

private String employeeCode;

}

+ 80
- 6
pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java ファイルの表示

@@ -1,23 +1,34 @@
package com.ningdatech.pmapi.user.manage;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo;
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService;
import com.ningdatech.pmapi.organization.service.IDingOrganizationService;
import com.ningdatech.pmapi.sys.model.entity.UserRole;
import com.ningdatech.pmapi.sys.service.IUserRoleService;
import com.ningdatech.pmapi.user.constant.UserAvailableEnum;
import com.ningdatech.pmapi.user.entity.UserInfo;
import com.ningdatech.pmapi.user.model.po.ReqUserDetailEditPO;
import com.ningdatech.pmapi.user.model.po.ReqUserDisablePO;
import com.ningdatech.pmapi.user.model.po.ReqUserDetailPO;
import com.ningdatech.pmapi.user.model.po.ReqUserDisableOrEnablePO;
import com.ningdatech.pmapi.user.model.po.ReqUserInfoListPO;
import com.ningdatech.pmapi.user.model.vo.ResUserDetailVO;
import com.ningdatech.pmapi.user.model.vo.ResUserInfoListVO;
import com.ningdatech.pmapi.user.model.vo.UserRoleVO;
import com.ningdatech.pmapi.user.service.IUserInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
@@ -31,6 +42,7 @@ public class UserInfoManage {
private final IDingOrganizationService iDingOrganizationService;
private final IDingEmployeeInfoService iDingEmployeeInfoService;
private final IUserInfoService iUserInfoService;
private final IUserRoleService iUserRoleService;

public PageVo<ResUserInfoListVO> list(ReqUserInfoListPO reqUserInfoListPO) {
LambdaQueryWrapper<DingEmployeeInfo> wrapper = Wrappers.lambdaQuery(DingEmployeeInfo.class)
@@ -67,16 +79,78 @@ public class UserInfoManage {
return pageVo;
}

public void disableOrEnable(ReqUserDisablePO reqUserDisablePO) {


public void disableOrEnable(ReqUserDisableOrEnablePO reqUserDisableOrEnablePO) {
Long userId = generateUserId(reqUserDisableOrEnablePO.getEmployeeCode());
UserInfo userInfo = iUserInfoService.getById(userId);
userInfo.setAvailable(reqUserDisableOrEnablePO.getOperation());
iUserInfoService.updateById(userInfo);
}

public ResUserDetailVO userInfoDetail(ReqUserInfoListPO reqUserInfoListPO) {
return null;
public ResUserDetailVO userInfoDetail(ReqUserDetailPO reqUserDetailPO) {
Long userId = generateUserId(reqUserDetailPO.getEmployeeCode());
UserInfo userInfo = iUserInfoService.getById(userId);
if (Objects.isNull(userInfo)) {
return null;
}
ResUserDetailVO resUserDetailVO = new ResUserDetailVO();

resUserDetailVO.setUserId(userInfo.getId());
resUserDetailVO.setPhoneNo(userInfo.getMobile());
resUserDetailVO.setStatus(userInfo.getAvailable());
resUserDetailVO.setUserRoleInfoList(new ArrayList<>());
return resUserDetailVO;
}

@Transactional(rollbackFor = Exception.class)
public void userInfoDetailEdit(ReqUserDetailEditPO reqUserDetailEditPO) {
Long userId = generateUserId(reqUserDetailEditPO.getEmployeeCode());

UserInfo userInfo = iUserInfoService.getById(userId);
if (Objects.isNull(userInfo)) {
return;
}
userInfo.setMobile(reqUserDetailEditPO.getPhoneNo());
userInfo.setAvailable(reqUserDetailEditPO.getStatus());
iUserInfoService.updateById(userInfo);

List<UserRoleVO> userRoleInfoList = reqUserDetailEditPO.getUserRoleInfoList();
iUserRoleService.remove(Wrappers.lambdaQuery(UserRole.class).eq(UserRole::getUserId, userId));
if (CollUtil.isNotEmpty(userRoleInfoList)) {
List<UserRole> userRoleList = userRoleInfoList.stream().map(r -> {
UserRole saveRecord = new UserRole();
saveRecord.setRoleId(r.getId());
saveRecord.setUserId(userId);
return saveRecord;
}).collect(Collectors.toList());
iUserRoleService.saveBatch(userRoleList);
}

}

private Long generateUserId(String employeeCode) {
UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class)
.eq(UserInfo::getEmployeeCode, employeeCode));
if (Objects.isNull(userInfo)) {
List<DingEmployeeInfo> dingEmployeeInfoList = iDingEmployeeInfoService.list(Wrappers.lambdaQuery(DingEmployeeInfo.class)
.eq(DingEmployeeInfo::getMainJob, "true"));
if (CollUtil.isEmpty(dingEmployeeInfoList)) {
throw new BizException("员工账号不存在");
}
DingEmployeeInfo dingEmployeeInfo = dingEmployeeInfoList.get(0);
userInfo = UserInfo.builder()
.accountId(dingEmployeeInfo.getAccountId())
.username(dingEmployeeInfo.getEmployeeName())
.realName(dingEmployeeInfo.getEmployeeName())
.available(UserAvailableEnum.DISABLE.name())
.createBy(-1L)
.updateBy(-1L)
.createOn(LocalDateTime.now())
.updateOn(LocalDateTime.now())
.build();
iUserInfoService.save(userInfo);
}
return userInfo.getId();
}


}

+ 0
- 33
pmapi/src/main/java/com/ningdatech/pmapi/user/model/base/UserRoleInfo.java ファイルの表示

@@ -1,33 +0,0 @@
package com.ningdatech.pmapi.user.model.base;

import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Size;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
* @author liuxinxin
* @date 2022/8/22 下午4:12
*/
@Data
@ApiModel("用户角色信息")
public class UserRoleInfo {

@ApiModelProperty(value = "名称")
private String name;

@ApiModelProperty(value = "枚举code")
private String code;

@ApiModelProperty(value = "描述")
@Size(max = 100, message = "描述长度不能超过100")
@TableField(value = "describe", condition = LIKE)
private String describe;

@ApiModelProperty(value = "排序")
private Integer roleSort;
}

+ 12
- 5
pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserDetailEditPO.java ファイルの表示

@@ -1,10 +1,11 @@
package com.ningdatech.pmapi.user.model.po;

import com.ningdatech.pmapi.user.model.base.UserRoleInfo;
import com.ningdatech.pmapi.user.model.vo.UserRoleVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.util.List;

/**
@@ -12,18 +13,24 @@ import java.util.List;
* @date 2023/2/15 上午8:43
*/
@Data
@ApiModel("获取用户详情编辑请求")
@ApiModel("用户详情编辑请求")
public class ReqUserDetailEditPO {

@ApiModelProperty("userId")
private Long userId;

@NotBlank(message = "浙政钉 用户编码 不能为空")
@ApiModelProperty("浙政钉 用户编码")
private String employeeCode;

@NotBlank(message = "用户手机号不能为空")
@ApiModelProperty("手机号")
private String phoneNo;

@ApiModelProperty("状态 启用/禁用")
private Boolean status;
@NotBlank(message = "状态不能为空")
@ApiModelProperty("状态 启用 ENABLE/禁用 DISABLE")
private String status;

@ApiModelProperty("用户角色信息列表")
private List<UserRoleInfo> userRoleInfoList;
private List<UserRoleVO> userRoleInfoList;
}

+ 6
- 2
pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserDetailPO.java ファイルの表示

@@ -4,7 +4,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.NotBlank;

/**
* @author liuxinxin
@@ -14,7 +14,11 @@ import javax.validation.constraints.NotNull;
@ApiModel("获取用户详情请求")
public class ReqUserDetailPO {

@NotNull(message = "用户id 不能为空")
@ApiModelProperty("用户id")
private Long userId;

@NotBlank(message = "浙政钉 用户编码 不能为空")
@ApiModelProperty("浙政钉 用户编码")
private String employeeCode;

}

pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserDisablePO.java → pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserDisableOrEnablePO.java ファイルの表示

@@ -13,7 +13,7 @@ import javax.validation.constraints.NotBlank;

@Data
@ApiModel("用户禁用/启用 PO")
public class ReqUserDisablePO {
public class ReqUserDisableOrEnablePO {

@ApiModelProperty("用户id")
private Long userId;
@@ -22,8 +22,9 @@ public class ReqUserDisablePO {
@ApiModelProperty("浙政钉 用户编码")
private String employeeCode;

@NotBlank(message = "浙政钉 用户编码 不能为空")
@ApiModelProperty("操作 true: 启用 / false 禁用")
private Boolean operation;
@NotBlank(message = "操作 不能为空")
@ApiModelProperty("操作 启用 ENABLE/禁用 DISABLE")
private String operation;


}

+ 5
- 2
pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqUserInfoListPO.java ファイルの表示

@@ -1,7 +1,7 @@
package com.ningdatech.pmapi.user.model.po;

import com.ningdatech.basic.model.PagePo;
import com.ningdatech.pmapi.sys.model.entity.Role;
import com.ningdatech.pmapi.user.model.vo.UserRoleVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -28,8 +28,11 @@ public class ReqUserInfoListPO extends PagePo {
@ApiModelProperty("所属区域")
private Long regionId;

@ApiModelProperty("所属区域名称")
private Long regionName;

@ApiModelProperty("用户角色")
private List<Role> userRoleList;
private List<UserRoleVO> userRoleList;

@ApiModelProperty("状态")
private String status;


+ 3
- 4
pmapi/src/main/java/com/ningdatech/pmapi/user/model/vo/ResUserDetailVO.java ファイルの表示

@@ -1,6 +1,5 @@
package com.ningdatech.pmapi.user.model.vo;

import com.ningdatech.pmapi.user.model.base.UserRoleInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -21,9 +20,9 @@ public class ResUserDetailVO {
@ApiModelProperty("手机号")
private String phoneNo;

@ApiModelProperty("状态 启用/禁用")
private Boolean status;
@ApiModelProperty("状态 启用 ENABLE/禁用 DISABLE")
private String status;

@ApiModelProperty("用户角色信息列表")
private List<UserRoleInfo> userRoleInfoList;
private List<UserRoleVO> userRoleInfoList;
}

+ 21
- 0
pmapi/src/main/java/com/ningdatech/pmapi/user/model/vo/UserRoleVO.java ファイルの表示

@@ -0,0 +1,21 @@
package com.ningdatech.pmapi.user.model.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
* @author liuxinxin
* @date 2023/2/15 下午5:47
*/

@Data
@ApiModel("用户角色VO")
public class UserRoleVO {

@ApiModelProperty(value = "角色id")
private Long id;

@ApiModelProperty(value = "名称")
private String name;
}

読み込み中…
キャンセル
保存