| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.api.BasePageDTO; |
| | | import com.ycl.api.CommonResult; |
| | | import com.ycl.dto.user.AdminDepartDTO; |
| | | import com.ycl.entity.depart.SccgDepart; |
| | | import com.ycl.entity.user.UmsAdminDepart; |
| | | import com.ycl.entity.user.UmsDepartManage; |
| | | import com.ycl.enums.common.ResultCode; |
| | | import com.ycl.exception.ApiException; |
| | | import com.ycl.mapper.depart.SccgDepartMapper; |
| | | import com.ycl.mapper.user.UmsAdminDepartMapper; |
| | | import com.ycl.service.depart.SccgDepartService; |
| | | import com.ycl.service.user.UmsAdminDepartService; |
| | | import com.ycl.service.user.UmsDepartManageService; |
| | | import com.ycl.service.user.UmsAdminService; |
| | | import com.ycl.utils.common.PojoUtils; |
| | | import com.ycl.vo.depart.DepartVO; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.xml.transform.Result; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | @Resource |
| | | private SccgDepartMapper sccgDepartMapper; |
| | | @Resource |
| | | private UmsAdminDepartService umsAdminDepartService; |
| | | private UmsDepartManageService umsAdminDepartService; |
| | | @Resource |
| | | private UmsAdminService umsAdminService; |
| | | |
| | |
| | | if (null != sccgDepart && sccgDepart.getId() != updateDepartVO.getId()) { |
| | | throw new ApiException(ResultCode.RECORD_ALREADY_EXISTS); |
| | | } |
| | | BeanUtils.copyProperties(updateDepartVO, sccgDepart); |
| | | SccgDepart depart = this.getById(updateDepartVO.getId()); |
| | | BeanUtils.copyProperties(updateDepartVO, depart); |
| | | List<Long> userIds = updateDepartVO.getUserIds(); |
| | | if (CollUtil.isNotEmpty(userIds)) { |
| | | Long departId = updateDepartVO.getId(); |
| | | List<UmsDepartManage> departList = umsAdminDepartService.queryByDepartId(departId); |
| | | if (CollUtil.isNotEmpty(departList)) { |
| | | umsAdminDepartService.deletedByDepartId(departId); |
| | | } |
| | | userIds.forEach(e -> { |
| | | UmsAdminDepart adminDepart = new UmsAdminDepart(); |
| | | UmsDepartManage adminDepart = new UmsDepartManage(); |
| | | adminDepart.setDepartId(departId); |
| | | adminDepart.setUserId(e); |
| | | umsAdminDepartService.save(adminDepart); |
| | | }); |
| | | } |
| | | if (sccgDepartMapper.updateById(sccgDepart) <= 0) { |
| | | if (sccgDepartMapper.updateById(depart) <= 0) { |
| | | throw new ApiException(ResultCode.RECORD_UPDATE_FAIL); |
| | | } |
| | | } |
| | |
| | | //负责人 |
| | | if (CollUtil.isNotEmpty(records)) { |
| | | for (SccgDepart record : records) { |
| | | List<UmsAdminDepart> umsAdminDeparts = umsAdminDepartService.queryByDepartId(record.getId()); |
| | | List<UmsDepartManage> umsAdminDeparts = umsAdminDepartService.queryByDepartId(record.getId()); |
| | | if (CollUtil.isNotEmpty(umsAdminDeparts)) { |
| | | List<AdminDepartDTO.UserInfoDTO> userInfoDTOS = umsAdminDeparts.stream().map(a -> { |
| | | AdminDepartDTO.UserInfoDTO userInfoDTO = new AdminDepartDTO.UserInfoDTO(); |