| | |
| | | import com.mzl.flower.dto.request.system.UserInfoDTO; |
| | | import com.mzl.flower.dto.response.customer.CustomerDTO; |
| | | import com.mzl.flower.dto.response.film.FilmWorksVO; |
| | | import com.mzl.flower.dto.response.system.MenuTreeDTO; |
| | | import com.mzl.flower.entity.film.FilmWorks; |
| | | import com.mzl.flower.entity.system.Role; |
| | | import com.mzl.flower.mapper.customer.CustomerMapper; |
| | | import com.mzl.flower.mapper.film.FilmWorksMapper; |
| | | import com.mzl.flower.service.film.FilmWorksService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mzl.flower.service.system.RoleService; |
| | | import com.mzl.flower.utils.DateUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | private final FilmWorksMapper filmWorksMapper; |
| | | private final CustomerMapper customerMapper; |
| | | private final RoleService roleService; |
| | | |
| | | @Override |
| | | public void saveFilmWorks(FilmWorksDTO filmWorksDTO) { |
| | | //获取当前人员角色,判断是不是编辑角色 |
| | | List<String> roleIds = new ArrayList<>(); |
| | | List<Role> roleList = roleService.getUserRoleList(SecurityUtils.getUserId()); |
| | | for (Role role : roleList) { |
| | | roleIds.add(role.getId()); |
| | | } |
| | | if (!roleIds.contains("8f9ef89f6b2d4d8e9ea1fc8d2f25ce69")) { |
| | | throw new ValidationException("非编辑角色不能新增"); |
| | | } |
| | | // 转换 |
| | | FilmWorks filmWorks = new FilmWorks(); |
| | | BeanUtils.copyProperties(filmWorksDTO, filmWorks); |
| | | filmWorks.create(); |
| | | filmWorks.setStatus(Constants.COMMON_PUBLISH_STATUS.unpublished.name()); |
| | | filmWorks.setStatus(Constants.COMMON_PUBLISH_STATUS.pending_review.name()); |
| | | filmWorksMapper.insert(filmWorks); |
| | | } |
| | | |
| | | @Override |
| | | public void updateFilmWorks(FilmWorksDTO filmWorksDTO) { |
| | | FilmWorks filmWork = filmWorksMapper.selectById(filmWorksDTO.getId()); |
| | | FilmWorks filmWorks = new FilmWorks(); |
| | | BeanUtils.copyProperties(filmWorksDTO,filmWorks); |
| | | //系统生成的内容无需管理 |
| | | if ("sys".equals(filmWorksDTO.getType())) { |
| | | filmWorks = filmWorksMapper.selectById(filmWorksDTO.getId()); |
| | | filmWorks.setFilmContent(filmWorksDTO.getFilmContent()); |
| | | //生成之后变成待审核 |
| | | if(StringUtils.isNotBlank(filmWorks.getFilmContent())){ |
| | | filmWorks.setStatus(Constants.COMMON_PUBLISH_STATUS.pending_review.name()); |
| | | }else{ |
| | | filmWorks.setStatus(Constants.COMMON_PUBLISH_STATUS.create_failed.name()); |
| | | } |
| | | |
| | | if (filmWork != null) { |
| | | filmWorks.setClassify(filmWork.getClassify()); |
| | | filmWorks.setCreateBy(filmWork.getCreateBy()); |
| | | filmWorks.setCreateTime(filmWork.getCreateTime()); |
| | | filmWorks.setStatus(filmWork.getStatus()); |
| | | } else { |
| | | List<String> roleIds = new ArrayList<>(); |
| | | List<Role> roleList = roleService.getUserRoleList(SecurityUtils.getUserId()); |
| | | for (Role role : roleList) { |
| | | roleIds.add(role.getId()); |
| | | } |
| | | if (!roleIds.contains("8f9ef89f6b2d4d8e9ea1fc8d2f25ce69")) { |
| | | throw new ValidationException("非编辑角色不能修改"); |
| | | } |
| | | filmWorks = filmWorksMapper.selectById(filmWorksDTO.getId()); |
| | | //判断影视作品状态 |
| | | if(Constants.COMMON_PUBLISH_STATUS.published.name().equals(filmWorks.getStatus()) ){ |
| | | throw new ValidationException("发布作品不能编辑"); |
| | | } |
| | | |
| | | if(Constants.COMMON_PUBLISH_STATUS.approved.name().equals(filmWorks.getStatus()) ){ |
| | | throw new ValidationException("审核作品不能编辑"); |
| | | } |
| | | BeanUtils.copyProperties(filmWorksDTO, filmWorks); |
| | | filmWorks.update(SecurityUtils.getUserId()); |
| | | filmWorks.setStatus(Constants.COMMON_PUBLISH_STATUS.pending_review.name()); |
| | | } |
| | | |
| | | filmWorks.update(SecurityUtils.getUserId()); |
| | | filmWorksMapper.updateById(filmWorks); |
| | | } |
| | | |
| | |
| | | if(StringUtils.isNotBlank(dto.getCreateDateEndStr())){ |
| | | dto.setCreateDateEnd(DateUtils.dateToLocalDateTime(dto.getCreateDateEndStr(),false)); |
| | | } |
| | | if (!StringUtils.isEmpty(dto.getCategory()) && Constants.FILM_CATEGORY.all.getDesc().equals(dto.getCategory())) { |
| | | //当时全部的时时候值设置为空,表示查询全部 |
| | | dto.setCategory(null); |
| | | } |
| | | |
| | | //todo 这里的用户ID可能为空,用户存在不登录的情况下访问,传null |
| | | try { |
| | |
| | | } catch (Exception e) { |
| | | dto.setUserId(null); |
| | | } |
| | | |
| | | List<FilmWorksVO> list = filmWorksMapper.queryPage(dto,page); |
| | | page.setRecords(list); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<FilmWorksVO> pendingCreate() { |
| | | return filmWorksMapper.pendingCreate(); |
| | | } |
| | | |
| | | @Override |
| | | public void changeStatus(Long id) { |
| | | //获取当前人员角色,判断是不是审核角色 |
| | | List<String> roleIds = new ArrayList<>(); |
| | | List<Role> roleList = roleService.getUserRoleList(SecurityUtils.getUserId()); |
| | | for (Role role : roleList) { |
| | | roleIds.add(role.getId()); |
| | | } |
| | | if (!roleIds.contains("77462b362bad4c88a7a5c64cbdd25d91")) { |
| | | throw new ValidationException("非运营角色不能发布"); |
| | | } |
| | | FilmWorks filmWork = filmWorksMapper.selectById(id); |
| | | if (filmWork == null) { |
| | | throw new ValidationException("找不到id为" + id + "的公告"); |
| | | } |
| | | if (Constants.COMMON_PUBLISH_STATUS.published.name().equals(filmWork.getStatus())) { |
| | | filmWork.setStatus(Constants.COMMON_PUBLISH_STATUS.unpublished.name()); |
| | | } else { |
| | | filmWork.setStatus(Constants.COMMON_PUBLISH_STATUS.published.name()); |
| | | filmWork.setPublishDate(LocalDate.now()); |
| | | if (Constants.COMMON_PUBLISH_STATUS.approved.name().equals(filmWork.getStatus()) || Constants.COMMON_PUBLISH_STATUS.published.name().equals(filmWork.getStatus()) || Constants.COMMON_PUBLISH_STATUS.unpublished.name().equals(filmWork.getStatus())) { |
| | | if (Constants.COMMON_PUBLISH_STATUS.published.name().equals(filmWork.getStatus())) { |
| | | filmWork.setStatus(Constants.COMMON_PUBLISH_STATUS.unpublished.name()); |
| | | } else { |
| | | filmWork.setStatus(Constants.COMMON_PUBLISH_STATUS.published.name()); |
| | | filmWork.setPublishDate(LocalDate.now()); |
| | | } |
| | | filmWorksMapper.updateById(filmWork); |
| | | }else{ |
| | | throw new ValidationException("非审核通过或者发布状态,不能操作"); |
| | | } |
| | | filmWorksMapper.updateById(filmWork); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void changeTopState(Long id) { |
| | | //获取当前人员角色,判断是不是审核角色 |
| | | List<String> roleIds = new ArrayList<>(); |
| | | List<Role> roleList = roleService.getUserRoleList(SecurityUtils.getUserId()); |
| | | for (Role role : roleList) { |
| | | roleIds.add(role.getId()); |
| | | } |
| | | if (!roleIds.contains("77462b362bad4c88a7a5c64cbdd25d91")) { |
| | | throw new ValidationException("非运营角色不能置顶"); |
| | | } |
| | | FilmWorks filmWork = filmWorksMapper.selectById(id); |
| | | if (filmWork == null) { |
| | | throw new ValidationException("找不到id为" + id + "的公告"); |
| | |
| | | |
| | | @Override |
| | | public void changeDownState(Long id) { |
| | | //获取当前人员角色,判断是不是审核角色 |
| | | List<String> roleIds = new ArrayList<>(); |
| | | List<Role> roleList = roleService.getUserRoleList(SecurityUtils.getUserId()); |
| | | for (Role role : roleList) { |
| | | roleIds.add(role.getId()); |
| | | } |
| | | if (!roleIds.contains("77462b362bad4c88a7a5c64cbdd25d91")) { |
| | | throw new ValidationException("非运营角色不能清除权重"); |
| | | } |
| | | FilmWorks filmWork = filmWorksMapper.selectById(id); |
| | | if (filmWork == null) { |
| | | throw new ValidationException("找不到id为" + id + "的公告"); |
| | |
| | | |
| | | @Override |
| | | public void batchPublish(BatchDTO dto) { |
| | | //获取当前人员角色,判断是不是审核角色 |
| | | List<String> roleIds = new ArrayList<>(); |
| | | List<Role> roleList = roleService.getUserRoleList(SecurityUtils.getUserId()); |
| | | for (Role role : roleList) { |
| | | roleIds.add(role.getId()); |
| | | } |
| | | if (!roleIds.contains("77462b362bad4c88a7a5c64cbdd25d91")) { |
| | | throw new ValidationException("非运营角色不能发布"); |
| | | } |
| | | |
| | | List<FilmWorks> list = filmWorksMapper.selectList(new LambdaQueryWrapper<FilmWorks>().in(FilmWorks::getId, dto.getIds())); |
| | | for (FilmWorks filmWork : list) { |
| | | filmWork.setStatus(Constants.COMMON_PUBLISH_STATUS.published.name()); |
| | |
| | | filmWorksVO.setAvatar(currentCustomer.getCover()); |
| | | return filmWorksVO; |
| | | } |
| | | |
| | | @Override |
| | | public void batchApproved(BatchDTO dto) { |
| | | //获取当前人员角色,判断是不是审核角色 |
| | | List<String> roleIds = new ArrayList<>(); |
| | | List<Role> roleList = roleService.getUserRoleList(SecurityUtils.getUserId()); |
| | | for (Role role : roleList) { |
| | | roleIds.add(role.getId()); |
| | | } |
| | | if (!roleIds.contains("86a36a0b789c4d0e840f7b807c09459b")) { |
| | | throw new ValidationException("非审核角色不能审批"); |
| | | } |
| | | List<FilmWorks> list = filmWorksMapper.selectList(new LambdaQueryWrapper<FilmWorks>().in(FilmWorks::getId, dto.getIds())); |
| | | //判断所有的状态都是待审核 |
| | | if (!list.stream().allMatch(filmWork -> Constants.COMMON_PUBLISH_STATUS.pending_review.name().equals(filmWork.getStatus()) || Constants.COMMON_PUBLISH_STATUS.rejected.name().equals(filmWork.getStatus()))) { |
| | | throw new ValidationException("只有待审核或者审核拒绝的才能批量审核"); |
| | | } |
| | | for (FilmWorks filmWork : list) { |
| | | filmWork.setStatus(Constants.COMMON_PUBLISH_STATUS.approved.name()); |
| | | filmWork.setAuditDate(LocalDate.now()); |
| | | filmWorksMapper.updateById(filmWork); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void batchRejected(BatchDTO dto) { |
| | | //获取当前人员角色,判断是不是审核角色 |
| | | List<String> roleIds = new ArrayList<>(); |
| | | List<Role> roleList = roleService.getUserRoleList(SecurityUtils.getUserId()); |
| | | for (Role role : roleList) { |
| | | roleIds.add(role.getId()); |
| | | } |
| | | if (!roleIds.contains("86a36a0b789c4d0e840f7b807c09459b")) { |
| | | throw new ValidationException("非审核角色不能审批"); |
| | | } |
| | | List<FilmWorks> list = filmWorksMapper.selectList(new LambdaQueryWrapper<FilmWorks>().in(FilmWorks::getId, dto.getIds())); |
| | | //判断所有的状态都是待审核或者审核通过 |
| | | if (!list.stream().allMatch(filmWork -> Constants.COMMON_PUBLISH_STATUS.pending_review.name().equals(filmWork.getStatus()) || Constants.COMMON_PUBLISH_STATUS.approved.name().equals(filmWork.getStatus()))) { |
| | | throw new ValidationException("只有待审核或者审核通过的状态才能批量审核"); |
| | | } |
| | | for (FilmWorks filmWork : list) { |
| | | filmWork.setStatus(Constants.COMMON_PUBLISH_STATUS.rejected.name()); |
| | | filmWork.setAuditDate(LocalDate.now()); |
| | | filmWorksMapper.updateById(filmWork); |
| | | } |
| | | } |
| | | } |