6 changed files with 74 additions and 75 deletions
@ -0,0 +1,54 @@ |
|||
package com.elink.esua.epdc.utils; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.enums.YesOrNoEnum; |
|||
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|||
import com.elink.esua.epdc.commons.tools.redis.RedisKeys; |
|||
import com.elink.esua.epdc.commons.tools.redis.RedisUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.DeptLevelAndLeaderDTO; |
|||
import com.elink.esua.epdc.feign.AdminFeignClient; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @author work@yujt.net.cn |
|||
* @date 2019/12/18 14:52 |
|||
*/ |
|||
@Component |
|||
public class DeptUtils { |
|||
|
|||
@Autowired |
|||
private AdminFeignClient adminFeignClient; |
|||
|
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
/** |
|||
* 获取部门信息 |
|||
* |
|||
* @param deptId 部门id |
|||
* @param yesOrNo 是否需要获取网格长姓名 |
|||
* @return com.elink.esua.epdc.dto.DeptLevelAndLeaderDTO |
|||
* @author work@yujt.net.cn |
|||
* @date 2019/12/18 15:02 |
|||
*/ |
|||
public DeptLevelAndLeaderDTO getDeptLevelInfo(Long deptId, YesOrNoEnum yesOrNo) { |
|||
DeptLevelAndLeaderDTO dto = (DeptLevelAndLeaderDTO) redisUtils.get(RedisKeys.getDeptOptionKey(deptId)); |
|||
|
|||
if (null != dto) { |
|||
if (YesOrNoEnum.NO.value().equals(yesOrNo.value())) { |
|||
return dto; |
|||
} else { |
|||
if (StringUtils.isNotBlank(dto.getLeaderName())) { |
|||
return dto; |
|||
} |
|||
} |
|||
} |
|||
Result<DeptLevelAndLeaderDTO> result = adminFeignClient.getDeptInfoById(deptId, yesOrNo.value()); |
|||
if (!result.success() || result.getData() == null) { |
|||
throw new RenException("获取机构信息失败"); |
|||
} |
|||
return result.getData(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue