| | |
| | | package cn.lili.modules.lmk.service.impl; |
| | | |
| | | import cn.lili.base.Result; |
| | | import cn.lili.common.enums.ActivityCoverTypeEnum; |
| | | import cn.lili.common.enums.ActivityStatusEnum; |
| | | import cn.lili.modules.lmk.domain.entity.Activity; |
| | | import cn.lili.modules.lmk.domain.form.ActivityForm; |
| | |
| | | import cn.lili.modules.lmk.service.LmkFileService; |
| | | import cn.lili.modules.lmk.service.MyActivityService; |
| | | import cn.lili.modules.member.entity.vo.MemberVO; |
| | | import cn.lili.utils.COSUtil; |
| | | import cn.lili.utils.PageUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | private final MyActivityService activityService; |
| | | |
| | | private final ActivityReportMapper activityReportMapper; |
| | | private final COSUtil cOSUtil; |
| | | |
| | | @Override |
| | | public Result add(ActivityForm form) { |
| | |
| | | entity.setStatus(ActivityStatusEnum.NOT_STARTED.getType()); |
| | | //默认不为推荐 |
| | | entity.setRecommend(false); |
| | | //默认未发布 |
| | | entity.setPublish(false); |
| | | |
| | | baseMapper.insert(entity); |
| | | return Result.ok("添加成功"); |
| | |
| | | |
| | | Activity entity = baseMapper.selectById(form.getId()); |
| | | //判断修改前的封面类型是否为文本,文本不需要删除文件 |
| | | if (!"文字".equals(entity.getCoverType())){ |
| | | if (!ActivityCoverTypeEnum.TEXT.getType().equals(entity.getCoverType())){ |
| | | //判断路径是否改变 |
| | | if (!form.getCover().equals(entity.getCover())) { |
| | | //删除云服务器中旧的图片 |
| | |
| | | public Result removeById(String id) { |
| | | //TODO 先判断活动是否有报名人员 |
| | | //有的话不可删除 联中间表查询 |
| | | |
| | | |
| | | |
| | | |
| | | //删除,同时判断该对象的封面是否存在 ,存在则在云服务器删除 |
| | | ActivityVO vo = baseMapper.getById(id); |
| | | if (StringUtils.isNotEmpty(vo.getCover())){ |
| | |
| | | |
| | | baseMapper.getPage(page, query); |
| | | for (ActivityVO vo : page.getRecords()) { |
| | | if (!"文字".equals(vo.getCoverType())){ |
| | | String url = lmkFileService.getPreviewUrl(vo.getCover()); |
| | | vo.setUrl(url); |
| | | if (!ActivityCoverTypeEnum.TEXT.getType().equals(vo.getCoverType())){ |
| | | vo.setUrl(cOSUtil.getPreviewUrl(vo.getCover())); |
| | | } |
| | | } |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | |
| | | @Override |
| | | public Result getCanReportPage(ActivityQuery query){ |
| | | IPage<ActivityVO> page = PageUtil.getPage(query, ActivityVO.class); |
| | | |
| | | //已发布的活动 |
| | | baseMapper.getCanReportPage(page, query); |
| | | |
| | | for(ActivityVO activityVO : page.getRecords()){ |
| | | activityVO.setUrl(cOSUtil.getPreviewUrl(activityVO.getCover())); |
| | | } |
| | | |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | |
| | | .map(entity -> ActivityVO.getVoByEntity(entity, null)) |
| | | .collect(Collectors.toList()); |
| | | List<ActivityVO> reportActivityVo =vos.stream().filter(item -> ActivityStatusEnum.REPORT.getType().equals(item.getStatus())).collect(Collectors.toList()); |
| | | |
| | | |
| | | |
| | | return Result.ok().data(reportActivityVo); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public Result activityChangeStatus(ActivityForm form) { |
| | | Activity entity = baseMapper.selectById(form.getId()); |
| | | entity.setStatus(form.getStatus()); |
| | | entity.setPublish(form.getPublish()); |
| | | if (!form.getPublish()){ |
| | | //下架判断是否有人员报名,有报名的话禁止提醒无法下架 |
| | | ActivityMembersQuery activityMembersQuery = new ActivityMembersQuery(); |
| | | activityMembersQuery.setId(form.getId()); |
| | | if((long)activityMembersPage(activityMembersQuery).get("total") > 0){ |
| | | return Result.error("该活动无法下架,已存在报名人员"); |
| | | } |
| | | |
| | | } |
| | | baseMapper.updateById(entity); |
| | | return Result.ok(); |
| | | } |