[新增]获取用户信息的接口中增加更新时间
CI / Docker-Build (push) Successful in 2m12s
Details
CI / Docker-Build (push) Successful in 2m12s
Details
This commit is contained in:
parent
436a07bcf4
commit
1e2ed4d305
|
@ -7,18 +7,17 @@ import club.joylink.rtss.vo.client.org.OrgVO;
|
|||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
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.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
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
|
||||
@EqualsAndHashCode
|
||||
public class AccountVO implements Serializable {
|
||||
@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"; // 第三方企业子账户
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 账号所属的组织(是账号表里的字段)
|
||||
*/
|
||||
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 String name;
|
||||
/**
|
||||
* 账号所属的组织(是账号表里的字段)
|
||||
*/
|
||||
private Long orgId;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
@NotBlank(message = "昵称不能为空")
|
||||
private String nickname;
|
||||
/**
|
||||
* 真实姓名
|
||||
*/
|
||||
@NotBlank(message = "姓名不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 头像资源地址
|
||||
*/
|
||||
private String avatarPath;
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
@NotBlank(message = "昵称不能为空")
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@NotBlank(message = "手机号码不能为空")
|
||||
private String mobile;
|
||||
/**
|
||||
* 头像资源地址
|
||||
*/
|
||||
private String avatarPath;
|
||||
|
||||
/**
|
||||
* 国家码
|
||||
*/
|
||||
private String nationcode;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@NotBlank(message = "手机号码不能为空")
|
||||
private String mobile;
|
||||
|
||||
private String password;
|
||||
/**
|
||||
* 国家码
|
||||
*/
|
||||
private String nationcode;
|
||||
|
||||
/**
|
||||
* 微信openId
|
||||
*/
|
||||
@NotBlank(message = "微信OPENID不能为空")
|
||||
private String wxId;
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 微信unionId
|
||||
*/
|
||||
private String wxUnionId;
|
||||
/**
|
||||
* 微信openId
|
||||
*/
|
||||
@NotBlank(message = "微信OPENID不能为空")
|
||||
private String wxId;
|
||||
|
||||
/**
|
||||
* 微信小程序openId
|
||||
*/
|
||||
private String wmOpenId;
|
||||
/**
|
||||
* 微信unionId
|
||||
*/
|
||||
private String wxUnionId;
|
||||
|
||||
/**
|
||||
* 数据库的roles字段
|
||||
*/
|
||||
@JsonIgnore
|
||||
private String dbRoles;
|
||||
/**
|
||||
* 微信小程序openId
|
||||
*/
|
||||
private String wmOpenId;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
*/
|
||||
private List<String> roles;
|
||||
/**
|
||||
* 数据库的roles字段
|
||||
*/
|
||||
@JsonIgnore
|
||||
private String dbRoles;
|
||||
|
||||
/**
|
||||
* 账号来源(最初的目的是给cgy做注册人数变化曲线)
|
||||
*/
|
||||
private String source;
|
||||
/**
|
||||
* 角色
|
||||
*/
|
||||
private List<String> roles;
|
||||
|
||||
/**
|
||||
* email邮箱
|
||||
*/
|
||||
private String email;
|
||||
/**
|
||||
* 账号来源(最初的目的是给cgy做注册人数变化曲线)
|
||||
*/
|
||||
private String source;
|
||||
|
||||
/**
|
||||
* 状态:1-可用
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* email邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
/**
|
||||
* 状态:1-可用
|
||||
*/
|
||||
private String status;
|
||||
|
||||
//单位信息
|
||||
private Long companyId;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
private String companyName;
|
||||
private Boolean companyAdmin;
|
||||
/**
|
||||
* 用户所属组织关联的项目
|
||||
*/
|
||||
private List<String> projectCodes;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
//单位信息
|
||||
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) {
|
||||
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();
|
||||
public void setRolesByString(String roles) {
|
||||
if (StringUtils.hasText(roles)) {
|
||||
String[] splits = roles.split(",");
|
||||
this.roles = new ArrayList<>();
|
||||
Collections.addAll(this.roles, splits);
|
||||
}
|
||||
}
|
||||
|
||||
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.setId(0L);
|
||||
accountVO.setName("系统");
|
||||
return accountVO;
|
||||
accountVO.setId(account.getId());
|
||||
accountVO.setName(account.getName());
|
||||
accountVO.setNickname(account.getNickname());
|
||||
accountVO.setMobile(account.getMobile());
|
||||
voList.add(accountVO);
|
||||
});
|
||||
}
|
||||
return voList;
|
||||
}
|
||||
|
||||
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[]{}));
|
||||
public static List<SysAccount> convert2UnionIdInfoVOs(List<AccountVO> voList) {
|
||||
List<SysAccount> list = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(voList)) {
|
||||
voList.forEach(userVO -> {
|
||||
if (StringUtils.hasText(userVO.getWxUnionId())) {
|
||||
SysAccount account = new SysAccount();
|
||||
account.setId(userVO.getId());
|
||||
account.setWxUnionId(userVO.getWxUnionId());
|
||||
list.add(account);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setRolesByString(String roles) {
|
||||
if (StringUtils.hasText(roles)) {
|
||||
String[] splits = roles.split(",");
|
||||
this.roles = new ArrayList<>();
|
||||
Collections.addAll(this.roles, splits);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 是否管理员
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@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<>();
|
||||
Collections.addAll(this.roles, splits);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 是否超级管理员
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@JsonIgnore
|
||||
public boolean isSuperAdmin() {
|
||||
return !CollectionUtils.isEmpty(this.roles)
|
||||
&& (this.roles.contains(BusinessConsts.ROLE_05));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserVO [id=" + id + ", name=" + name + ", nickname=" + nickname + ", mobile=" + mobile + ", email=" + email + ", nationcode="
|
||||
+ nationcode + ", wxId=" + wxId + "]";
|
||||
}
|
||||
public void filter4Client() {
|
||||
this.password = null;
|
||||
this.wxUnionId = null;
|
||||
this.wxId = null;
|
||||
this.wmOpenId = null;
|
||||
this.createTime = null;
|
||||
}
|
||||
|
||||
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 void forClient() {
|
||||
if (StringUtils.hasText(dbRoles)) {
|
||||
this.roles = List.of(dbRoles.split(","));
|
||||
}
|
||||
}
|
||||
|
||||
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.setId(account.getId());
|
||||
accountVO.setName(account.getName());
|
||||
accountVO.setNickname(account.getNickname());
|
||||
accountVO.setMobile(account.getMobile());
|
||||
voList.add(accountVO);
|
||||
});
|
||||
}
|
||||
return voList;
|
||||
}
|
||||
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 static List<SysAccount> convert2UnionIdInfoVOs(List<AccountVO> voList) {
|
||||
List<SysAccount> list = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(voList)) {
|
||||
voList.forEach(userVO -> {
|
||||
if (StringUtils.hasText(userVO.getWxUnionId())) {
|
||||
SysAccount account = new SysAccount();
|
||||
account.setId(userVO.getId());
|
||||
account.setWxUnionId(userVO.getWxUnionId());
|
||||
list.add(account);
|
||||
}
|
||||
});
|
||||
}
|
||||
return list;
|
||||
public void copyOrgInfo(AccountVO accountVO) {
|
||||
if (accountVO != null) {
|
||||
this.companyId = accountVO.getCompanyId();
|
||||
this.companyName = accountVO.getCompanyName();
|
||||
this.companyAdmin = accountVO.getCompanyAdmin();
|
||||
this.projectCodes = accountVO.getProjectCodes();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否管理员
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@JsonIgnore
|
||||
public boolean isAdmin() {
|
||||
return !CollectionUtils.isEmpty(this.roles)
|
||||
&& (this.roles.contains(BusinessConsts.ROLE_04) || this.roles.contains(BusinessConsts.ROLE_05));
|
||||
}
|
||||
@JsonIgnore
|
||||
public boolean isThirdChildAccount() {
|
||||
return Type_3.equalsIgnoreCase(this.type) && StringUtils.hasText(this.parentAccount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否超级管理员
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@JsonIgnore
|
||||
public boolean isSuperAdmin() {
|
||||
return !CollectionUtils.isEmpty(this.roles)
|
||||
&& (this.roles.contains(BusinessConsts.ROLE_05));
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue