|
|
|
@ -0,0 +1,101 @@
|
|
|
|
|
package com.supervision.police.dto.user;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
|
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
|
|
import lombok.Data;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用于与UserInfoReqVo进行转换
|
|
|
|
|
* 系统规定用户与角色的关系为一对一,前端期望传入的数据类型为一个字符串,
|
|
|
|
|
* 后端设置用户与角色的关系是一对多,故需要转换
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
@Data
|
|
|
|
|
public class UserInfoVoDTO {
|
|
|
|
|
|
|
|
|
|
@Schema(description = "用户id")
|
|
|
|
|
private String id;
|
|
|
|
|
|
|
|
|
|
@Schema(description = "头像ID")
|
|
|
|
|
private String headPicId;
|
|
|
|
|
|
|
|
|
|
@Schema(description = "账号")
|
|
|
|
|
private String account;
|
|
|
|
|
|
|
|
|
|
@Schema(description = "用户名")
|
|
|
|
|
private String userName;
|
|
|
|
|
|
|
|
|
|
@Schema(description = "密码")
|
|
|
|
|
private String password;
|
|
|
|
|
|
|
|
|
|
@Schema(description = "手机号")
|
|
|
|
|
private String phoneNum;
|
|
|
|
|
|
|
|
|
|
@Schema(description = "账号状态 0正常 1停用")
|
|
|
|
|
private Integer status;
|
|
|
|
|
|
|
|
|
|
@Schema(description = "角色ID")
|
|
|
|
|
private String roleId;
|
|
|
|
|
|
|
|
|
|
@Schema(description = "角色名")
|
|
|
|
|
private String roleName;
|
|
|
|
|
|
|
|
|
|
@Schema(description = "备注")
|
|
|
|
|
private String remark;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Schema(description = "用户角色列表")
|
|
|
|
|
private List<UserRoleDTO> userRoleList;
|
|
|
|
|
|
|
|
|
|
@Schema(description = "最近登录时间")
|
|
|
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
|
|
|
|
private LocalDateTime recentLoginTime;
|
|
|
|
|
|
|
|
|
|
@Schema(description = "注册时间")
|
|
|
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
|
|
|
|
private LocalDateTime registerTime;
|
|
|
|
|
|
|
|
|
|
public UserInfoVoDTO() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UserInfoVoDTO(UserInfoDTO userInfoDTO) {
|
|
|
|
|
if (userInfoDTO == null){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.id = userInfoDTO.getId();
|
|
|
|
|
this.headPicId = userInfoDTO.getHeadPicId();
|
|
|
|
|
this.account = userInfoDTO.getAccount();
|
|
|
|
|
this.userName = userInfoDTO.getUserName();
|
|
|
|
|
this.phoneNum = userInfoDTO.getPhoneNum();
|
|
|
|
|
this.status = userInfoDTO.getStatus();
|
|
|
|
|
if (CollUtil.isNotEmpty(userInfoDTO.getUserRoleList())){
|
|
|
|
|
UserRoleDTO userRole = CollUtil.getFirst(userInfoDTO.getUserRoleList());
|
|
|
|
|
this.roleId = userRole.getRoleId();
|
|
|
|
|
this.roleName = userRole.getRoleName();
|
|
|
|
|
}
|
|
|
|
|
this.recentLoginTime = userInfoDTO.getRecentLoginTime();
|
|
|
|
|
this.registerTime = userInfoDTO.getRegisterTime();
|
|
|
|
|
this.userRoleList = userInfoDTO.getUserRoleList();
|
|
|
|
|
this.remark = userInfoDTO.getRemark();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UserInfoReqVo toUserInfoReqVo() {
|
|
|
|
|
UserInfoReqVo userInfoReqVo = new UserInfoReqVo();
|
|
|
|
|
userInfoReqVo.setId(this.id);
|
|
|
|
|
userInfoReqVo.setHeadPicId(this.headPicId);
|
|
|
|
|
userInfoReqVo.setAccount(this.account);
|
|
|
|
|
userInfoReqVo.setUserName(this.userName);
|
|
|
|
|
userInfoReqVo.setPassword(this.password);
|
|
|
|
|
userInfoReqVo.setPhoneNum(this.phoneNum);
|
|
|
|
|
userInfoReqVo.setStatus(this.status);
|
|
|
|
|
userInfoReqVo.setRoleIdList(List.of(this.roleId));
|
|
|
|
|
userInfoReqVo.setRemark(this.remark);
|
|
|
|
|
return userInfoReqVo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|