| | |
| | | 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 { |
| | | dto.setUserId(SecurityUtils.getUserId()); |
| | | } catch (Exception e) { |
| | | dto.setUserId(null); |
| | | } |
| | | |
| | | List<FilmWorksVO> list = filmWorksMapper.queryPage(dto,page); |
| | | page.setRecords(list); |
| | | |
| | | |
| | | return page; |
| | | } |
| | | |
| | |
| | | filmWorksMapper.updateById(filmWork); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void changeTopState(Long id) { |
| | | FilmWorks filmWork = filmWorksMapper.selectById(id); |
| | | if (filmWork == null) { |
| | | throw new ValidationException("找不到id为" + id + "的公告"); |
| | | } |
| | | if (Constants.COMMON_PUBLISH_STATUS.unpublished.name().equals(filmWork.getStatus())) { |
| | | throw new ValidationException("未发布作品不能置顶,请先发布"); |
| | | } |
| | | |
| | | FilmWorks filmWorkTop = filmWorksMapper.getTopStickyWeight(); |
| | | if (!ObjectUtils.isEmpty(filmWorkTop)) { |
| | | filmWork.setStickyWeight(filmWorkTop.getStickyWeight() + 100); |
| | | } else { |
| | | filmWork.setStickyWeight(100); |
| | | } |
| | | filmWorksMapper.updateById(filmWork); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void changeDownState(Long id) { |
| | | FilmWorks filmWork = filmWorksMapper.selectById(id); |
| | | if (filmWork == null) { |
| | | throw new ValidationException("找不到id为" + id + "的公告"); |
| | | } |
| | | if (Constants.COMMON_PUBLISH_STATUS.unpublished.name().equals(filmWork.getStatus())) { |
| | | throw new ValidationException("未发布作品无需清除权重"); |
| | | } |
| | | filmWork.setStickyWeight(0); |
| | | filmWorksMapper.updateById(filmWork); |
| | | } |
| | | |
| | | @Override |
| | | public void batchDelete(BatchDTO dto) { |
| | | filmWorksMapper.deleteBatchIds(dto.getIds()); |
| | |
| | | |
| | | @Override |
| | | public FilmWorksVO detail(Long id) { |
| | | FilmWorks filmWork = filmWorksMapper.selectById(id); |
| | | if(filmWork==null){ |
| | | // userId 可以是空,因为用户可以登录 |
| | | |
| | | String userId = SecurityUtils.getUserId(); |
| | | FilmWorksVO filmWorksVO = filmWorksMapper.selectInfoById(id,userId); |
| | | if(filmWorksVO==null){ |
| | | return null; |
| | | } |
| | | FilmWorksVO filmWorksVO = new FilmWorksVO(); |
| | | BeanUtils.copyProperties(filmWork,filmWorksVO); |
| | | CustomerDTO currentCustomer = customerMapper.getCurrentCustomer(filmWork.getCreateBy()); |
| | | CustomerDTO currentCustomer = customerMapper.getCurrentCustomer(filmWorksVO.getCreateBy()); |
| | | filmWorksVO.setNickname(currentCustomer.getNickName()); |
| | | filmWorksVO.setAvatar(currentCustomer.getCover()); |
| | | return filmWorksVO; |