package com.gk.hotwork.Service.ServiceImpl;
|
|
import com.gk.hotwork.Domain.DepartmentInfo;
|
import com.gk.hotwork.Domain.Enum.ResultCodes;
|
import com.gk.hotwork.Domain.Exception.BusinessException;
|
import com.gk.hotwork.Domain.Vo.DepartmentVo;
|
import com.gk.hotwork.Domain.Vo.ResultVO;
|
import com.gk.hotwork.Domain.dto.DepInfoRPCRespDTO;
|
import com.gk.hotwork.Service.DepartmentService;
|
import com.gk.hotwork.Service.Middle.AccountDepartmentService;
|
import com.gk.hotwork.specialWork.model.dto.resp.DepRPCRespDTO;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.util.ArrayList;
|
import java.util.Collections;
|
import java.util.List;
|
|
@Service("accountDepartmentService")
|
public class AccountDepartmentServiceImpl implements AccountDepartmentService {
|
|
@Autowired
|
private DepartmentService departmentService;
|
|
@Override
|
public ResultVO<DepInfoRPCRespDTO> getDepInfoByDepId(Long uid,Long depId) {
|
|
if (depId == null) {
|
throw new BusinessException("部门id为空");
|
}
|
DepInfoRPCRespDTO depInfoDep = null;
|
DepartmentInfo department = departmentService.getById(depId);
|
if (department != null) {
|
depInfoDep = new DepInfoRPCRespDTO();
|
depInfoDep.setDepId(department.getId());
|
depInfoDep.setDepName(department.getDepartment());
|
}
|
|
return new ResultVO<>(ResultCodes.OK,depInfoDep);
|
}
|
|
@Override
|
public ResultVO<List<DepInfoRPCRespDTO>> listDepByDepIds(List<Long> depIds) {
|
List<DepInfoRPCRespDTO> result;
|
if (depIds != null && depIds.size() > 0) {
|
List<DepartmentInfo> deps = departmentService.listDepByDepIds(depIds);
|
result = new ArrayList<>(depIds.size());
|
for (DepartmentInfo dep : deps) {
|
DepInfoRPCRespDTO respDTO = new DepInfoRPCRespDTO();
|
respDTO.setDepId(dep.getId());
|
respDTO.setDepName(dep.getDepartment());
|
respDTO.setStatus(dep.getIsdel());
|
result.add(respDTO);
|
}
|
}else{
|
result = Collections.emptyList();
|
}
|
|
return new ResultVO<>(ResultCodes.OK,result);
|
}
|
|
@Override
|
public ResultVO<List<DepRPCRespDTO>> depList() {
|
List<DepartmentVo> depDos = departmentService.selectByAll();
|
List<DepRPCRespDTO> result = new ArrayList<>(depDos.size());
|
if (depDos.size() > 0) {
|
for (DepartmentVo depDo : depDos) {
|
DepRPCRespDTO respDTO = new DepRPCRespDTO();
|
respDTO.setDepId(depDo.getId());
|
respDTO.setDepName(depDo.getDepartment());
|
respDTO.setStatus(depDo.getIsdel());
|
respDTO.setChildren(Collections.emptyList());
|
result.add(respDTO);
|
}
|
}
|
return new ResultVO<>(ResultCodes.OK,result);
|
}
|
}
|