diff --git a/src/main/java/club/joylink/rtss/entity/org/OrgProject.java b/src/main/java/club/joylink/rtss/entity/org/OrgProject.java new file mode 100644 index 000000000..120e468f1 --- /dev/null +++ b/src/main/java/club/joylink/rtss/entity/org/OrgProject.java @@ -0,0 +1,18 @@ +package club.joylink.rtss.entity.org; + +import lombok.Data; + +import java.time.LocalDateTime; + +@Data +public class OrgProject { + private Long id; + + private Long orgId; + + private String projectCode; + + private Long creatorId; + + private LocalDateTime createTime; +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/vo/AccountVO.java b/src/main/java/club/joylink/rtss/vo/AccountVO.java index dccd95175..bad7b4c16 100644 --- a/src/main/java/club/joylink/rtss/vo/AccountVO.java +++ b/src/main/java/club/joylink/rtss/vo/AccountVO.java @@ -55,13 +55,13 @@ public class AccountVO implements Serializable { /** * 真实姓名 */ - @NotBlank(message="姓名不能为空") + @NotBlank(message = "姓名不能为空") private String name; /** * 昵称 */ - @NotBlank(message="昵称不能为空") + @NotBlank(message = "昵称不能为空") private String nickname; /** @@ -72,7 +72,7 @@ public class AccountVO implements Serializable { /** * 手机号 */ - @NotBlank(message="手机号码不能为空") + @NotBlank(message = "手机号码不能为空") private String mobile; /** @@ -85,7 +85,7 @@ public class AccountVO implements Serializable { /** * 微信openId */ - @NotBlank(message="微信OPENID不能为空") + @NotBlank(message = "微信OPENID不能为空") private String wxId; /** @@ -140,7 +140,8 @@ public class AccountVO implements Serializable { private List projectCodes; - public AccountVO() {} + public AccountVO() { + } public AccountVO(SysAccount account) { this.id = account.getId(); @@ -194,14 +195,14 @@ public class AccountVO implements Serializable { @JsonIgnore public String getRolesStr() { - if(!CollectionUtils.isEmpty(this.roles)) { - return String.join(",", this.roles.toArray(new String[] {})); + if (!CollectionUtils.isEmpty(this.roles)) { + return String.join(",", this.roles.toArray(new String[]{})); } return null; } public void setRolesByString(String roles) { - if(StringUtils.hasText(roles)) { + if (StringUtils.hasText(roles)) { String[] splits = roles.split(","); this.roles = new ArrayList<>(); Collections.addAll(this.roles, splits); @@ -209,7 +210,7 @@ public class AccountVO implements Serializable { } public void setRolesByString() { - if(StringUtils.hasText(dbRoles)) { + if (StringUtils.hasText(dbRoles)) { String[] splits = dbRoles.split(","); this.roles = new ArrayList<>(); Collections.addAll(this.roles, splits); @@ -218,13 +219,13 @@ public class AccountVO implements Serializable { @Override public String toString() { - return "UserVO [id=" + id + ", name=" + name + ", nickname=" + nickname + ", mobile=" + mobile + ", email=" + email +", nationcode=" + return "UserVO [id=" + id + ", name=" + name + ", nickname=" + nickname + ", mobile=" + mobile + ", email=" + email + ", nationcode=" + nationcode + ", wxId=" + wxId + "]"; } public static List convertFromDB(List list) { List voList = new ArrayList<>(); - if(!CollectionUtils.isEmpty(list)) { + if (!CollectionUtils.isEmpty(list)) { list.forEach(account -> voList.add(new AccountVO(account))); } return voList; @@ -232,7 +233,7 @@ public class AccountVO implements Serializable { public static List convert2BaseInfoVO(List list) { List voList = new ArrayList<>(); - if(!CollectionUtils.isEmpty(list)) { + if (!CollectionUtils.isEmpty(list)) { list.forEach(account -> { AccountVO accountVO = new AccountVO(); accountVO.setId(account.getId()); @@ -247,9 +248,9 @@ public class AccountVO implements Serializable { public static List convert2UnionIdInfoVOs(List voList) { List list = new ArrayList<>(); - if(!CollectionUtils.isEmpty(voList)) { + if (!CollectionUtils.isEmpty(voList)) { voList.forEach(userVO -> { - if(StringUtils.hasText(userVO.getWxUnionId())) { + if (StringUtils.hasText(userVO.getWxUnionId())) { SysAccount account = new SysAccount(); account.setId(userVO.getId()); account.setWxUnionId(userVO.getWxUnionId()); @@ -262,6 +263,7 @@ public class AccountVO implements Serializable { /** * 是否管理员 + * * @return */ @JsonIgnore @@ -272,6 +274,7 @@ public class AccountVO implements Serializable { /** * 是否超级管理员 + * * @return */ @JsonIgnore diff --git a/src/main/java/club/joylink/rtss/vo/LoginUserInfoVO.java b/src/main/java/club/joylink/rtss/vo/LoginUserInfoVO.java index f4f323fe9..d1031ef52 100644 --- a/src/main/java/club/joylink/rtss/vo/LoginUserInfoVO.java +++ b/src/main/java/club/joylink/rtss/vo/LoginUserInfoVO.java @@ -4,6 +4,7 @@ import club.joylink.rtss.constants.Client; import club.joylink.rtss.entity.SysAccountLogin; import club.joylink.rtss.entity.project.Project; import club.joylink.rtss.util.EncryptUtil; +import club.joylink.rtss.vo.client.org.OrgProjectVO; import club.joylink.rtss.vo.client.project.ProjectDeviceVO; import club.joylink.rtss.vo.project.ProjectVO; import lombok.Getter; @@ -49,6 +50,9 @@ public class LoginUserInfoVO { private LocalDateTime preLogoutTime; private LocalDateTime lastQueryTime; // 最后使用时间 + // 20220929 增加 + private OrgProjectVO orgProjectVO; + public LoginUserInfoVO(AccountVO accountVO, Client client, String project, ProjectDeviceVO deviceVO) { this.accountVO = accountVO; this.client = client; @@ -139,4 +143,14 @@ public class LoginUserInfoVO { public boolean isWechatLogin() { return Client.Assistant.equals(this.getClient()); } + + /** + * 获取顶级组织Id + */ + public Long getTopOrgId() { + if (orgProjectVO == null) { + return null; + } + return orgProjectVO.getTopOrgId(); + } } diff --git a/src/main/java/club/joylink/rtss/vo/client/org/OrgProjectVO.java b/src/main/java/club/joylink/rtss/vo/client/org/OrgProjectVO.java new file mode 100644 index 000000000..6bf1b97a5 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/org/OrgProjectVO.java @@ -0,0 +1,19 @@ +package club.joylink.rtss.vo.client.org; + +import club.joylink.rtss.entity.org.OrgProject; +import lombok.Data; + +@Data +public class OrgProjectVO { + private Long topOrgId; + + private Long orgId; + + + private String projectCode; + + public OrgProjectVO(OrgProject orgProject) { + this.orgId = orgProject.getOrgId(); + this.projectCode = orgProject.getProjectCode(); + } +}