| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public TaskDaliyDto create(TaskDaliy resources) { |
| | | // 新增修改删除验证 |
| | | checkAddOrUpdateOrDelete(resources); |
| | | // 新增修改验证 |
| | | checkAddOrUpdate(resources); |
| | | return taskDaliyMapper.toDto(taskDaliyRepository.save(resources)); |
| | |
| | | public void update(TaskDaliy resources) { |
| | | TaskDaliy taskDaliy = taskDaliyRepository.findById(resources.getId()).orElseGet(TaskDaliy::new); |
| | | ValidationUtil.isNull( taskDaliy.getId(),"TaskDaliy","id",resources.getId()); |
| | | // 新增修改删除验证 |
| | | checkAddOrUpdateOrDelete(taskDaliy); |
| | | // 修改删除验证 |
| | | checkUpdateOrDelete(taskDaliy); |
| | | // 新增修改验证 |
| | |
| | | for (Long id : ids) { |
| | | TaskDaliy taskDaliy = taskDaliyRepository.findById(id).orElseGet(TaskDaliy::new); |
| | | ValidationUtil.isNull( taskDaliy.getId(),"TaskDaliy","id",id); |
| | | // 新增修改删除验证 |
| | | checkAddOrUpdateOrDelete(taskDaliy); |
| | | // 修改删除验证 |
| | | checkUpdateOrDelete(taskDaliy); |
| | | taskDaliyRepository.deleteById(id); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 新增修改删除验证 |
| | | * @param resources |
| | | */ |
| | | private void checkAddOrUpdateOrDelete(TaskDaliy resources) { |
| | | // 获取登录用户角色等级 |
| | | List<Integer> levels = roleService.findByUsersId(SecurityUtils.getCurrentUserId()).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList()); |
| | | // 登录用户最大角色等级 |
| | | int min = Collections.min(levels); |
| | | // 判断角色等级 |
| | | if (min == Constant.ROLE_LEVEL_MANAGER || min == Constant.ROLE_LEVEL_LEADER || min == Constant.ROLE_LEVEL_ORDINARY) { |
| | | // 判断是否是自己的日报 |
| | | if (SecurityUtils.getCurrentUserId().longValue() != resources.getUserId().longValue()) { |
| | | throw new BadRequestException("只能新增修改自己的任务日报!"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void download(List<TaskDaliyDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |