Commit 132a9741c17be371362433c58421c28e7b8a5b7d

Authored by guzijian
1 parent 0cd0c7a2

feat: 多角色选择

trash-garbage/src/main/java/com/trash/garbage/pojo/vo/LoginVo.java
... ... @@ -3,13 +3,13 @@ package com.trash.garbage.pojo.vo;
3 3 import lombok.EqualsAndHashCode;
4 4 import lombok.ToString;
5 5  
  6 +import java.util.List;
  7 +
6 8 @ToString
7 9 @EqualsAndHashCode
8 10 public class LoginVo {
9 11 private String token;
10   - private String userType;
11   - private String parentCompanyName;
12   - private String transportCompanyName;
  12 + private List<RuleVo> ruleVos;
13 13  
14 14 public String getToken() {
15 15 return token;
... ... @@ -19,27 +19,36 @@ public class LoginVo {
19 19 this.token = token;
20 20 }
21 21  
22   - public String getUserType() {
23   - return userType;
  22 + public List<RuleVo> getRuleVos() {
  23 + return ruleVos;
24 24 }
25 25  
26   - public void setUserType(String userType) {
27   - this.userType = userType;
  26 + public void setRuleVos(List<RuleVo> ruleVos) {
  27 + this.ruleVos = ruleVos;
28 28 }
29 29  
30   - public String getParentCompanyName() {
31   - return parentCompanyName;
32   - }
  30 + @ToString
  31 + @EqualsAndHashCode
  32 + public static class RuleVo {
  33 + private String userType;
  34 + private String transportCompanyName;
33 35  
34   - public void setParentCompanyName(String parentCompanyName) {
35   - this.parentCompanyName = parentCompanyName;
36   - }
  36 + public String getUserType() {
  37 + return userType;
  38 + }
37 39  
38   - public String getTransportCompanyName() {
39   - return transportCompanyName;
40   - }
  40 + public void setUserType(String userType) {
  41 + this.userType = userType;
  42 + }
41 43  
42   - public void setTransportCompanyName(String transportCompanyName) {
43   - this.transportCompanyName = transportCompanyName;
  44 +
  45 + public String getTransportCompanyName() {
  46 + return transportCompanyName;
  47 + }
  48 +
  49 + public void setTransportCompanyName(String transportCompanyName) {
  50 + this.transportCompanyName = transportCompanyName;
  51 + }
44 52 }
  53 +
45 54 }
... ...
trash-garbage/src/main/java/com/trash/garbage/service/impl/GarUserServiceImpl.java
... ... @@ -86,6 +86,7 @@ public class GarUserServiceImpl extends ServiceImpl&lt;GarUserMapper, GarUser&gt;
86 86 if (Objects.isNull(loginDto)) {
87 87 throw new UsernameNotFoundException("当前用户不存在!");
88 88 }
  89 + // 微信登录
89 90 if (loginDto.getLoginType().equals(GlobalStatus.GarUserStatusEnum.WX_LOGIN.getStatus())) {
90 91 String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.getAppId() + "&secret=" + wxConfig.getSecret() + "&js_code=" + loginDto.getWxCode() + "&grant_type=authorization_code";
91 92 String body = HttpUtil.createGet(url).header("cache-control", "no-cache").execute().body();
... ... @@ -137,17 +138,17 @@ public class GarUserServiceImpl extends ServiceImpl&lt;GarUserMapper, GarUser&gt;
137 138 DriverVo driver = new DriverVo();
138 139 driver.setPhoneNo(loginDto.getTel());
139 140 List<DriverVo> driverList = driverService.selectDriverList(driver);
140   -
  141 + LoginVo.RuleVo ruleVo = new LoginVo.RuleVo();
  142 + ruleVo.setUserType(GlobalStatus.GarUserStatusEnum.NORMAL_USER.getDescription());
  143 + vo.setRuleVos(new ArrayList<>(Arrays.asList(ruleVo)));
141 144 // 运输驾驶员
142 145 if (CollectionUtil.isNotEmpty(driverList)) {
143   - vo.setUserType(GlobalStatus.GarUserStatusEnum.DRIVER_USER.getDescription());
144 146 DriverVo driverVo = driverList.get(0);
145 147 TransportationEnterprise enterprise = enterpriseService.selectTransportationEnterpriseById(driverVo.getCompanyId());
146   - TransportationEnterprise parentEnterprise = enterpriseService.selectTransportationEnterpriseById(enterprise.getParentId());
147   - vo.setTransportCompanyName(enterprise.getName());
148   - vo.setParentCompanyName(parentEnterprise.getName());
149   - vo.setUserType(GlobalStatus.GarUserStatusEnum.DRIVER_USER.getDescription());
150   - return vo;
  148 + ruleVo = new LoginVo.RuleVo();
  149 + ruleVo.setTransportCompanyName(enterprise.getName());
  150 + ruleVo.setUserType(GlobalStatus.GarUserStatusEnum.DRIVER_USER.getDescription());
  151 + vo.getRuleVos().add(ruleVo);
151 152 }
152 153  
153 154 // 企业负责人 TODO
... ... @@ -156,14 +157,11 @@ public class GarUserServiceImpl extends ServiceImpl&lt;GarUserMapper, GarUser&gt;
156 157 List<TransportationEnterprise> enterpriseList = enterpriseService.selectTransportationEnterpriseList(transportationEnterprise);
157 158 if (CollectionUtil.isNotEmpty(enterpriseList)) {
158 159 TransportationEnterprise enterprise = enterpriseList.get(0);
159   - String companyName = enterprise.getName();
160   - vo.setUserType(GlobalStatus.GarUserStatusEnum.RESPONSIBLE_USER.getDescription());
161   - vo.setTransportCompanyName(companyName);
162   - return vo;
  160 + ruleVo = new LoginVo.RuleVo();
  161 + ruleVo.setTransportCompanyName(enterprise.getName());
  162 + ruleVo.setUserType(GlobalStatus.GarUserStatusEnum.RESPONSIBLE_USER.getDescription());
  163 + vo.getRuleVos().add(ruleVo);
163 164 }
164   -
165   - // 普通用户 TODO
166   - vo.setUserType(GlobalStatus.GarUserStatusEnum.NORMAL_USER.getDescription());
167 165 return vo;
168 166 }
169 167  
... ...