Commit 7a8de886 by 陶光胜

Merge branch 'developer' into 'master'

加日志

See merge request !44
parents d051950e f63f53aa
......@@ -73,7 +73,7 @@ public class LoginController {
}
});
RedisUtil.setCache(key, userVo, 5l, TimeUnit.MINUTES);
RedisUtil.setCache("userEnterpriseList:"+userVo.getUserId(), enterpriseDTOList);
//RedisUtil.setCache("userEnterpriseList:"+userVo.getUserId(), enterpriseDTOList);
return RestResponse.success(enterpriseId);
}else {
return RestResponse.failure(ErrorCode.SYSTEMERROR.getCode(), smsSendResult.getMessage());
......@@ -101,28 +101,35 @@ public class LoginController {
@RequestMapping("all-enterprise")
public RestResponse allEnterprise(Integer userId){
Object cache = RedisUtil.getCache("userEnterpriseList:" + userId);
UserDTO userDTO = this.userApiService.getUser(userId).getResult();
if(userDTO == null){
return RestResponse.success();
}
List<UserDTO> userDTOList = this.userApiService.listUserByPhone(userDTO.getNationCode(), userDTO.getPhone()).getResult();
List<EnterpriseDTO> enterpriseDTOList = (List<EnterpriseDTO>) cache;
List<EnterpriseVo> result = new ArrayList<>();
if(CollectionUtils.isNotEmpty(enterpriseDTOList)){
result = enterpriseDTOList.stream().map(enterpriseDTO -> {
EnterpriseVo vo = EntityUtil.changeEntityByJSON(EnterpriseVo.class, enterpriseDTO);
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;
}).collect(Collectors.toList());
log.info("userDTOList:{}", JSON.toJSONString(userDTOList));
if(CollectionUtils.isNotEmpty(userDTOList)){
List<Integer> enterpriseIdList = userDTOList.stream().map(user -> user.getEnterpriseId()).collect(Collectors.toList());
List<EnterpriseDTO> enterpriseDTOList = this.enterpriseApiService.listEnterpriseByIds(enterpriseIdList).getResult();
List<EnterpriseVo> result = new ArrayList<>();
if(CollectionUtils.isNotEmpty(enterpriseDTOList)){
result = enterpriseDTOList.stream().map(enterpriseDTO -> {
EnterpriseVo vo = EntityUtil.changeEntityByJSON(EnterpriseVo.class, enterpriseDTO);
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;
}).collect(Collectors.toList());
}
return RestResponse.success(result);
}
return RestResponse.success(result);
return RestResponse.success();
}
@RequestMapping("nation-code")
......
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