LookSpaceServiceImpl.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package com.fdkankan.manage.service.impl;
  2. import cn.dev33.satoken.stp.StpUtil;
  3. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4. import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  5. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  6. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  7. import com.fdkankan.manage.common.ResultCode;
  8. import com.fdkankan.manage.exception.BusinessException;
  9. import com.fdkankan.manage.common.PageInfo;
  10. import com.fdkankan.common.util.DateUtil;
  11. import com.fdkankan.manage.entity.LookSpace;
  12. import com.fdkankan.manage.mapper.ILookSpaceMapper;
  13. import com.fdkankan.manage.service.ILookSpaceService;
  14. import com.fdkankan.manage.vo.request.LookSpaceParam;
  15. import org.apache.commons.lang3.StringUtils;
  16. import org.springframework.stereotype.Service;
  17. import java.util.Date;
  18. /**
  19. * <p>
  20. * 服务实现类
  21. * </p>
  22. *
  23. * @author
  24. * @since 2022-06-30
  25. */
  26. @Service
  27. public class LookSpaceServiceImpl extends ServiceImpl<ILookSpaceMapper, LookSpace> implements ILookSpaceService {
  28. @Override
  29. public PageInfo pageList(LookSpaceParam param) {
  30. LambdaQueryWrapper<LookSpace> wrapper = new LambdaQueryWrapper<>();
  31. if(StringUtils.isNotBlank(param.getVideoTitle())){
  32. wrapper.like(LookSpace::getVideoTitle,param.getVideoTitle());
  33. }
  34. wrapper.orderByDesc(LookSpace::getSort);
  35. wrapper.orderByDesc(LookSpace::getCreateTime);
  36. Page<LookSpace> page = new Page<>(param.getPageNum(),param.getPageSize());
  37. return PageInfo.PageInfo(this.page(page,wrapper));
  38. }
  39. @Override
  40. public void add(LookSpaceParam param) {
  41. if(StringUtils.isEmpty(param.getVideoTitle()) || StringUtils.isEmpty(param.getVideoFile())){
  42. throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
  43. }
  44. Long loginId = Long.valueOf(StpUtil.getLoginId().toString());
  45. LookSpace lookSpace = new LookSpace();
  46. lookSpace.setVideoFile(param.getVideoFile());
  47. lookSpace.setVideoTitle(param.getVideoTitle());
  48. lookSpace.setCreateUserId(loginId);
  49. lookSpace.setUpdateTime(DateUtil.date2String(new Date(),DateUtil.DEFAULT_DATE_FORMAT));
  50. this.save(lookSpace);
  51. }
  52. @Override
  53. public void updateByParam(LookSpaceParam param) {
  54. if(param.getId() == null){
  55. throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
  56. }
  57. LambdaUpdateWrapper<LookSpace> wrapper = new LambdaUpdateWrapper<>();
  58. if(StringUtils.isNotBlank(param.getVideoFile())){
  59. wrapper.set(LookSpace::getVideoFile,param.getVideoFile());
  60. }
  61. if(StringUtils.isNotBlank(param.getVideoTitle())){
  62. wrapper.set(LookSpace::getVideoTitle,param.getVideoTitle());
  63. }
  64. if(param.getIsShow()!=null){
  65. wrapper.set(LookSpace::getIsShow,param.getIsShow());
  66. }
  67. if(param.getSort() !=null){
  68. wrapper.set(LookSpace::getSort,param.getSort());
  69. }
  70. wrapper.eq(LookSpace::getId,param.getId());
  71. this.update(wrapper);
  72. }
  73. @Override
  74. public void isPush(Integer isPush,Long id) {
  75. LambdaUpdateWrapper<LookSpace> wrapper = new LambdaUpdateWrapper<>();
  76. wrapper.set(LookSpace::getIsPush,isPush);
  77. wrapper.eq(LookSpace::getId,id);
  78. this.update(wrapper);
  79. }
  80. }