Commit 5e19a8ed by 陶光胜

Merge branch 'developer' into 'master'

Developer

See merge request !26
parents 3a9df88c 6e83d7c0
...@@ -103,13 +103,22 @@ public class LoginController { ...@@ -103,13 +103,22 @@ public class LoginController {
public RestResponse allEnterprise(Integer userId){ public RestResponse allEnterprise(Integer userId){
Object cache = RedisUtil.getCache("userEnterpriseList:" + userId); Object cache = RedisUtil.getCache("userEnterpriseList:" + userId);
UserDTO userDTO = this.userApiService.getUser(userId).getResult(); UserDTO userDTO = this.userApiService.getUser(userId).getResult();
List<UserDTO> userDTOList = this.userApiService.listUserByPhone(userDTO.getNationCode(), userDTO.getPhone()).getResult();
List<EnterpriseDTO> enterpriseDTOList = (List<EnterpriseDTO>) cache; List<EnterpriseDTO> enterpriseDTOList = (List<EnterpriseDTO>) cache;
List<EnterpriseVo> result = new ArrayList<>(); List<EnterpriseVo> result = new ArrayList<>();
if(CollectionUtils.isNotEmpty(enterpriseDTOList)){ if(CollectionUtils.isNotEmpty(enterpriseDTOList)){
result = enterpriseDTOList.stream().map(enterpriseDTO -> { result = enterpriseDTOList.stream().map(enterpriseDTO -> {
EnterpriseVo vo = EntityUtil.changeEntityByJSON(EnterpriseVo.class, enterpriseDTO); EnterpriseVo vo = EntityUtil.changeEntityByJSON(EnterpriseVo.class, enterpriseDTO);
vo.setIsAdmin((userDTO != null && userDTO.getPhone().equals(enterpriseDTO.getPhoneNumber())) ? 1 : 0);
vo.setIsSingle("basic".equals(enterpriseDTO.getVersionCode()) ? 1 : 0); vo.setIsSingle("basic".equals(enterpriseDTO.getVersionCode()) ? 1 : 0);
if(CollectionUtils.isNotEmpty(userDTOList)){
userDTOList.stream().forEach(user -> {
if(user.getEnterpriseId().intValue() == enterpriseDTO.getEnterpriseId().intValue()){
vo.setIsAdmin((user.getPhone().equals(enterpriseDTO.getPhoneNumber())) ? 1 : 0);
vo.setUserName(user.getUserName());
vo.setUserId(user.getUserId());
}
});
}
return vo; return vo;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
......
...@@ -7,6 +7,7 @@ public class EnterpriseVo { ...@@ -7,6 +7,7 @@ public class EnterpriseVo {
private String companyName; private String companyName;
private String logo; private String logo;
private String address; private String address;
private Integer userId;
private String userName; private String userName;
private String phoneNumber; private String phoneNumber;
private String phoneAreaCode; private String phoneAreaCode;
...@@ -93,4 +94,12 @@ public class EnterpriseVo { ...@@ -93,4 +94,12 @@ public class EnterpriseVo {
public void setIsSingle(Integer isSingle) { public void setIsSingle(Integer isSingle) {
this.isSingle = isSingle; this.isSingle = isSingle;
} }
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment