[新增]获取用户信息的接口中增加更新时间
CI / Docker-Build (push) Successful in 2m12s Details

This commit is contained in:
thesai 2024-09-25 13:27:39 +08:00
parent 436a07bcf4
commit 1e2ed4d305
1 changed files with 277 additions and 269 deletions

View File

@ -7,18 +7,17 @@ import club.joylink.rtss.vo.client.org.OrgVO;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.validation.constraints.NotBlank;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import javax.validation.constraints.NotBlank;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
/** /**
* 账户对象 * 账户对象
@ -28,307 +27,316 @@ import java.util.List;
@Setter @Setter
@EqualsAndHashCode @EqualsAndHashCode
public class AccountVO implements Serializable { public class AccountVO implements Serializable {
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
/** @JsonSerialize(using = ToStringSerializer.class)
* 登录账户名线下登录账户名 private Long id;
*/
private String account;
/**
* 父账户
*/
private String parentAccount;
/**
* 账户类型
*/
private String type;
public static final String Type_1 = "1"; // 个人账户
public static final String Type_2 = "2"; // 第三方企业账户
public static final String Type_3 = "3"; // 第三方企业子账户
/** /**
* 账号所属的组织是账号表里的字段 * 登录账户名线下登录账户名
*/ */
private Long orgId; private String account;
/**
* 父账户
*/
private String parentAccount;
/**
* 账户类型
*/
private String type;
public static final String Type_1 = "1"; // 个人账户
public static final String Type_2 = "2"; // 第三方企业账户
public static final String Type_3 = "3"; // 第三方企业子账户
/** /**
* 真实姓名 * 账号所属的组织是账号表里的字段
*/ */
@NotBlank(message = "姓名不能为空") private Long orgId;
private String name;
/** /**
* 昵称 * 真实姓名
*/ */
@NotBlank(message = "昵称不能为空") @NotBlank(message = "姓名不能为空")
private String nickname; private String name;
/** /**
* 头像资源地址 * 昵称
*/ */
private String avatarPath; @NotBlank(message = "昵称不能为空")
private String nickname;
/** /**
* 手机号 * 头像资源地址
*/ */
@NotBlank(message = "手机号码不能为空") private String avatarPath;
private String mobile;
/** /**
* 国家码 * 手机号
*/ */
private String nationcode; @NotBlank(message = "手机号码不能为空")
private String mobile;
private String password; /**
* 国家码
*/
private String nationcode;
/** private String password;
* 微信openId
*/
@NotBlank(message = "微信OPENID不能为空")
private String wxId;
/** /**
* 微信unionId * 微信openId
*/ */
private String wxUnionId; @NotBlank(message = "微信OPENID不能为空")
private String wxId;
/** /**
* 微信小程序openId * 微信unionId
*/ */
private String wmOpenId; private String wxUnionId;
/** /**
* 数据库的roles字段 * 微信小程序openId
*/ */
@JsonIgnore private String wmOpenId;
private String dbRoles;
/** /**
* 角色 * 数据库的roles字段
*/ */
private List<String> roles; @JsonIgnore
private String dbRoles;
/** /**
* 账号来源最初的目的是给cgy做注册人数变化曲线 * 角色
*/ */
private String source; private List<String> roles;
/** /**
* email邮箱 * 账号来源最初的目的是给cgy做注册人数变化曲线
*/ */
private String email; private String source;
/** /**
* 状态1-可用 * email邮箱
*/ */
private String status; private String email;
/** /**
* 创建时间 * 状态1-可用
*/ */
private LocalDateTime createTime; private String status;
//单位信息 /**
private Long companyId; * 创建时间
*/
private LocalDateTime createTime;
private String companyName; /**
private Boolean companyAdmin; * 更新时间
/** */
* 用户所属组织关联的项目 private LocalDateTime updateTime;
*/
private List<String> projectCodes; //单位信息
private Long companyId;
private String companyName;
private Boolean companyAdmin;
/**
* 用户所属组织关联的项目
*/
private List<String> projectCodes;
public AccountVO() { public AccountVO() {
}
public AccountVO(SysAccount account) {
this.id = account.getId();
this.account = account.getAccount();
this.parentAccount = account.getParentAccount();
this.type = account.getType();
this.orgId = account.getOrgId();
this.name = account.getName();
this.nickname = account.getNickname();
this.avatarPath = account.getAvatarPath();
this.mobile = account.getMobile();
this.nationcode = account.getNationcode();
this.password = account.getPassword();
this.wxId = account.getWxId();
this.wxUnionId = account.getWxUnionId();
this.wmOpenId = account.getWmOpenId();
this.setRolesByString(account.getRoles());
this.source = account.getSource();
this.email = account.getEmail();
this.status = account.getStatus();
this.createTime = account.getCreateTime();
this.updateTime = account.getUpdateTime();
}
public static AccountVO system() {
AccountVO accountVO = new AccountVO();
accountVO.setId(0L);
accountVO.setName("系统");
return accountVO;
}
public static SysAccount fromVO(AccountVO accountVo) {
SysAccount account = new SysAccount();
account.setId(accountVo.getId());
account.setName(accountVo.getName());
account.setNickname(accountVo.getNickname());
account.setNationcode(accountVo.getNationcode());
account.setMobile(accountVo.getMobile());
account.setWxId(accountVo.getWxId());
account.setWxUnionId(accountVo.getWxUnionId());
account.setRoles(accountVo.getRolesStr());
account.setEmail(accountVo.getEmail());
account.setStatus(accountVo.getStatus());
account.setCreateTime(accountVo.getCreateTime());
return account;
}
@JsonIgnore
public String getIdStr() {
return String.valueOf(this.id);
}
@JsonIgnore
public String getRolesStr() {
if (!CollectionUtils.isEmpty(this.roles)) {
return String.join(",", this.roles.toArray(new String[]{}));
} }
return null;
}
public AccountVO(SysAccount account) { public void setRolesByString(String roles) {
this.id = account.getId(); if (StringUtils.hasText(roles)) {
this.account = account.getAccount(); String[] splits = roles.split(",");
this.parentAccount = account.getParentAccount(); this.roles = new ArrayList<>();
this.type = account.getType(); Collections.addAll(this.roles, splits);
this.orgId = account.getOrgId();
this.name = account.getName();
this.nickname = account.getNickname();
this.avatarPath = account.getAvatarPath();
this.mobile = account.getMobile();
this.nationcode = account.getNationcode();
this.password = account.getPassword();
this.wxId = account.getWxId();
this.wxUnionId = account.getWxUnionId();
this.wmOpenId = account.getWmOpenId();
this.setRolesByString(account.getRoles());
this.source = account.getSource();
this.email = account.getEmail();
this.status = account.getStatus();
this.createTime = account.getCreateTime();
} }
}
public static AccountVO system() { public void setRolesByString() {
if (StringUtils.hasText(dbRoles)) {
String[] splits = dbRoles.split(",");
this.roles = new ArrayList<>();
Collections.addAll(this.roles, splits);
}
}
@Override
public String toString() {
return "UserVO [id=" + id + ", name=" + name + ", nickname=" + nickname + ", mobile=" + mobile
+ ", email=" + email + ", nationcode="
+ nationcode + ", wxId=" + wxId + "]";
}
public static List<AccountVO> convertFromDB(List<SysAccount> list) {
List<AccountVO> voList = new ArrayList<>();
if (!CollectionUtils.isEmpty(list)) {
list.forEach(account -> voList.add(new AccountVO(account)));
}
return voList;
}
public static List<AccountVO> convert2BaseInfoVO(List<SysAccount> list) {
List<AccountVO> voList = new ArrayList<>();
if (!CollectionUtils.isEmpty(list)) {
list.forEach(account -> {
AccountVO accountVO = new AccountVO(); AccountVO accountVO = new AccountVO();
accountVO.setId(0L); accountVO.setId(account.getId());
accountVO.setName("系统"); accountVO.setName(account.getName());
return accountVO; accountVO.setNickname(account.getNickname());
accountVO.setMobile(account.getMobile());
voList.add(accountVO);
});
} }
return voList;
}
public static SysAccount fromVO(AccountVO accountVo) { public static List<SysAccount> convert2UnionIdInfoVOs(List<AccountVO> voList) {
SysAccount account = new SysAccount(); List<SysAccount> list = new ArrayList<>();
account.setId(accountVo.getId()); if (!CollectionUtils.isEmpty(voList)) {
account.setName(accountVo.getName()); voList.forEach(userVO -> {
account.setNickname(accountVo.getNickname()); if (StringUtils.hasText(userVO.getWxUnionId())) {
account.setNationcode(accountVo.getNationcode()); SysAccount account = new SysAccount();
account.setMobile(accountVo.getMobile()); account.setId(userVO.getId());
account.setWxId(accountVo.getWxId()); account.setWxUnionId(userVO.getWxUnionId());
account.setWxUnionId(accountVo.getWxUnionId()); list.add(account);
account.setRoles(accountVo.getRolesStr());
account.setEmail(accountVo.getEmail());
account.setStatus(accountVo.getStatus());
account.setCreateTime(accountVo.getCreateTime());
return account;
}
@JsonIgnore
public String getIdStr() {
return String.valueOf(this.id);
}
@JsonIgnore
public String getRolesStr() {
if (!CollectionUtils.isEmpty(this.roles)) {
return String.join(",", this.roles.toArray(new String[]{}));
} }
return null; });
} }
return list;
}
public void setRolesByString(String roles) { /**
if (StringUtils.hasText(roles)) { * 是否管理员
String[] splits = roles.split(","); *
this.roles = new ArrayList<>(); * @return
Collections.addAll(this.roles, splits); */
} @JsonIgnore
} public boolean isAdmin() {
return !CollectionUtils.isEmpty(this.roles)
&& (this.roles.contains(BusinessConsts.ROLE_04) || this.roles.contains(
BusinessConsts.ROLE_05));
}
public void setRolesByString() { /**
if (StringUtils.hasText(dbRoles)) { * 是否超级管理员
String[] splits = dbRoles.split(","); *
this.roles = new ArrayList<>(); * @return
Collections.addAll(this.roles, splits); */
} @JsonIgnore
} public boolean isSuperAdmin() {
return !CollectionUtils.isEmpty(this.roles)
&& (this.roles.contains(BusinessConsts.ROLE_05));
}
@Override public void filter4Client() {
public String toString() { this.password = null;
return "UserVO [id=" + id + ", name=" + name + ", nickname=" + nickname + ", mobile=" + mobile + ", email=" + email + ", nationcode=" this.wxUnionId = null;
+ nationcode + ", wxId=" + wxId + "]"; this.wxId = null;
} this.wmOpenId = null;
this.createTime = null;
}
public static List<AccountVO> convertFromDB(List<SysAccount> list) { public void forClient() {
List<AccountVO> voList = new ArrayList<>(); if (StringUtils.hasText(dbRoles)) {
if (!CollectionUtils.isEmpty(list)) { this.roles = List.of(dbRoles.split(","));
list.forEach(account -> voList.add(new AccountVO(account)));
}
return voList;
} }
}
public static List<AccountVO> convert2BaseInfoVO(List<SysAccount> list) { public void setOrgInfo(Org org, Boolean companyAdmin, List<String> projectCodes) {
List<AccountVO> voList = new ArrayList<>(); this.companyId = org.getId();
if (!CollectionUtils.isEmpty(list)) { this.companyName = org.getName();
list.forEach(account -> { this.companyAdmin = companyAdmin;
AccountVO accountVO = new AccountVO(); this.projectCodes = projectCodes;
accountVO.setId(account.getId()); }
accountVO.setName(account.getName());
accountVO.setNickname(account.getNickname());
accountVO.setMobile(account.getMobile());
voList.add(accountVO);
});
}
return voList;
}
public static List<SysAccount> convert2UnionIdInfoVOs(List<AccountVO> voList) { public void copyOrgInfo(AccountVO accountVO) {
List<SysAccount> list = new ArrayList<>(); if (accountVO != null) {
if (!CollectionUtils.isEmpty(voList)) { this.companyId = accountVO.getCompanyId();
voList.forEach(userVO -> { this.companyName = accountVO.getCompanyName();
if (StringUtils.hasText(userVO.getWxUnionId())) { this.companyAdmin = accountVO.getCompanyAdmin();
SysAccount account = new SysAccount(); this.projectCodes = accountVO.getProjectCodes();
account.setId(userVO.getId());
account.setWxUnionId(userVO.getWxUnionId());
list.add(account);
}
});
}
return list;
} }
}
/** @JsonIgnore
* 是否管理员 public boolean isThirdChildAccount() {
* return Type_3.equalsIgnoreCase(this.type) && StringUtils.hasText(this.parentAccount);
* @return }
*/
@JsonIgnore
public boolean isAdmin() {
return !CollectionUtils.isEmpty(this.roles)
&& (this.roles.contains(BusinessConsts.ROLE_04) || this.roles.contains(BusinessConsts.ROLE_05));
}
/** public void setOrgProjectVO(OrgVO orgVO, boolean orgAdmin) {
* 是否超级管理员 if (orgVO != null) {
* this.companyId = orgVO.getId();
* @return this.companyName = orgVO.getName();
*/ this.companyAdmin = orgAdmin;
@JsonIgnore this.projectCodes = orgVO.getProjectCodes();
public boolean isSuperAdmin() { } else {
return !CollectionUtils.isEmpty(this.roles) this.companyId = null;
&& (this.roles.contains(BusinessConsts.ROLE_05)); this.companyName = null;
} this.companyAdmin = false;
this.projectCodes = List.of();
public void filter4Client() {
this.password = null;
this.wxUnionId = null;
this.wxId = null;
this.wmOpenId = null;
this.createTime = null;
}
public void forClient() {
if (StringUtils.hasText(dbRoles)) {
this.roles = List.of(dbRoles.split(","));
}
}
public void setOrgInfo(Org org, Boolean companyAdmin, List<String> projectCodes) {
this.companyId = org.getId();
this.companyName = org.getName();
this.companyAdmin = companyAdmin;
this.projectCodes = projectCodes;
}
public void copyOrgInfo(AccountVO accountVO) {
if (accountVO != null) {
this.companyId = accountVO.getCompanyId();
this.companyName = accountVO.getCompanyName();
this.companyAdmin = accountVO.getCompanyAdmin();
this.projectCodes = accountVO.getProjectCodes();
}
}
@JsonIgnore
public boolean isThirdChildAccount() {
return Type_3.equalsIgnoreCase(this.type) && StringUtils.hasText(this.parentAccount);
}
public void setOrgProjectVO(OrgVO orgVO, boolean orgAdmin) {
if (orgVO != null) {
this.companyId = orgVO.getId();
this.companyName = orgVO.getName();
this.companyAdmin = orgAdmin;
this.projectCodes = orgVO.getProjectCodes();
} else {
this.companyId = null;
this.companyName = null;
this.companyAdmin = false;
this.projectCodes = List.of();
}
} }
}
} }