| | |
| | | package kr.wisestone.owl.service.impl; |
| | | |
| | | import com.google.common.collect.Lists; |
| | | import kr.wisestone.owl.domain.Issue; |
| | | import kr.wisestone.owl.domain.IssueDepartment; |
| | | import kr.wisestone.owl.domain.IssueUser; |
| | | import kr.wisestone.owl.domain.Workspace; |
| | | import kr.wisestone.owl.domain.*; |
| | | import kr.wisestone.owl.mapper.IssueDepartmentMapper; |
| | | import kr.wisestone.owl.mapper.IssueUserMapper; |
| | | import kr.wisestone.owl.repository.IssueDepartmentRepository; |
| | | import kr.wisestone.owl.service.DepartmentService; |
| | | import kr.wisestone.owl.service.IssueDepartmentService; |
| | | import kr.wisestone.owl.util.CommonUtil; |
| | | import kr.wisestone.owl.util.MapUtil; |
| | | import kr.wisestone.owl.vo.DepartmentVo; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private static final Logger log = LoggerFactory.getLogger(IssueDepartmentServiceImpl.class); |
| | | |
| | | @Autowired |
| | | private DepartmentService departmentService; |
| | | |
| | | @Autowired |
| | | private IssueDepartmentRepository issueDepartmentRepository; |
| | | |
| | | @Autowired |
| | |
| | | return this.issueDepartmentRepository; |
| | | } |
| | | |
| | | /** |
| | | * 이슈의 담당부서 추가 |
| | | * @param departmentsIds List<Long> |
| | | * @param workspace Workspace |
| | | * @param issue Issue |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public void add(List<Long> departmentsIds, Workspace workspace, Issue issue) { |
| | | List<IssueDepartment> issueDepartments = Lists.newArrayList(); |
| | | |
| | | for (Long departmentId : departmentsIds) { |
| | | Department department = this.departmentService.getDepartment(departmentId); |
| | | issueDepartments.add(new IssueDepartment(workspace, issue, department)); |
| | | } |
| | | this.issueDepartmentRepository.saveAll(issueDepartments); |
| | | |
| | | } |
| | | |
| | | // 이슈 담당부서를 변경한다. |
| | | @Override |
| | | @Transactional |
| | | public void modifyIssueDepartment(Issue issue, Workspace workspace, List<Long> departmentIds) { |
| | | User user = this.webAppUtil.getLoginUserObject(); |
| | | modifyIssueDepartment(issue, user, workspace, departmentIds); |
| | | } |
| | | |
| | | // 이슈 담당부서를 변경한다. |
| | | @Override |
| | | @Transactional |
| | | public void modifyIssueDepartment(Issue issue, User user, Workspace workspace, List<Long> departmentIds) { |
| | | List<Long> oldDepartmentIds = Lists.newArrayList(); |
| | | |
| | | // 이전 담당 부서 |
| | |
| | | issueAssigneeMap.put("departmentId", departmentId); //담당부서 |
| | | issueAssigneeMap.put("issueId", issue.getId()); |
| | | issueAssigneeMap.put("workspaceId", workspace.getId()); |
| | | issueAssigneeMap.put("registerId", this.webAppUtil.getLoginId()); |
| | | issueAssigneeMap.put("modifyId", this.webAppUtil.getLoginId()); |
| | | issueAssigneeMap.put("registerId", user.getId()); |
| | | issueAssigneeMap.put("modifyId", user.getId()); |
| | | addIssueAssigneeMaps.add(issueAssigneeMap); |
| | | } |
| | | |
| | |
| | | return this.issueDepartmentRepository.findByIssueId(issue.getId()); |
| | | } |
| | | |
| | | // 이슈 담당부서 찾기 |
| | | @Override |
| | | @Transactional |
| | | public List<IssueDepartment> findByDepartmentId(Long departmentId) { |
| | | return this.issueDepartmentRepository.findByDepartmentId(departmentId); |
| | | } |
| | | |
| | | /** |
| | | * 이슈의 담당부서에 속해있는지 조회 |
| | | * @param departmentId Long |
| | | * @return useYn |
| | | */ |
| | | @Override |
| | | public boolean usingDepartment(Long departmentId) { |
| | | boolean useYn = false; |
| | | List<IssueDepartment> issueDepartments = this.issueDepartmentRepository.findByDepartmentId(departmentId); |
| | | if (issueDepartments != null && issueDepartments.size() > 0) { |
| | | useYn = true; |
| | | } |
| | | return useYn; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void insertIssueDepartment(List<Map<String, Long>> issueAssigneeMaps) { |