| | |
| | | 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.common.security.context.UserContext; |
| | | import cn.lili.common.utils.StringUtils; |
| | | import cn.lili.modules.lmk.domain.entity.Activity; |
| | | import cn.lili.modules.lmk.domain.entity.ActivityReport; |
| | | import cn.lili.modules.lmk.domain.entity.MyCollect; |
| | | import cn.lili.modules.lmk.domain.form.ActivityReportForm; |
| | | import cn.lili.modules.lmk.domain.query.ActivityReportQuery; |
| | | import cn.lili.modules.lmk.domain.query.MyActivityQuery; |
| | |
| | | import cn.lili.modules.lmk.domain.vo.MyActivityVo; |
| | | import cn.lili.modules.lmk.mapper.ActivityMapper; |
| | | import cn.lili.modules.lmk.mapper.ActivityReportMapper; |
| | | import cn.lili.modules.lmk.mapper.MyCollectMapper; |
| | | import cn.lili.modules.lmk.service.MyActivityService; |
| | | import cn.lili.utils.COSUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xkzhangsan.time.utils.StringUtil; |
| | |
| | | import org.springframework.util.Assert; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | @RequiredArgsConstructor |
| | |
| | | private final ActivityMapper activityMapper; |
| | | |
| | | private final ActivityReportMapper activityReportMapper; |
| | | |
| | | private final COSUtil cOSUtil; |
| | | private final MyCollectMapper myCollectMapper; |
| | | |
| | | @Override |
| | | public Result getMyActivityList(MyActivityQuery query) { |
| | | String userId = UserContext.getCurrentUserId(); |
| | | List<MyActivityVo> myActivityList = activityMapper.getMyActivityList(query,userId); |
| | | |
| | | for (MyActivityVo myActivityVo : myActivityList){ |
| | | if (!ActivityCoverTypeEnum.TEXT.getType().equals(myActivityVo.getCoverType())){ |
| | | myActivityVo.setUrl(cOSUtil.getPreviewUrl(myActivityVo.getCover())); |
| | | } |
| | | } |
| | | return Result.ok().data(myActivityList); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public ActivityReportVO userReport(String activityId){ |
| | | |
| | | if (UserContext.getCurrentUserId() == null || UserContext.getCurrentUserId().isEmpty()){ |
| | | throw new RuntimeException("用户登录状态异常"); |
| | | } |
| | | return activityReportMapper.getActivityReport(activityId,UserContext.getCurrentUserId()); |
| | | } |
| | | |
| | | /**获得活动详情 并 活动账号报名活动情况,收藏情况 |
| | | * |
| | | * @param activityId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result detailByUsr(String activityId) { |
| | | //查询活动详情 |
| | | ActivityVO vo = baseMapper.getById(activityId); |
| | | Assert.notNull(vo, "记录不存在"); |
| | | |
| | | //查询报名情况 |
| | | ActivityReportVO reportVO = userReport(activityId); |
| | | //查询用户收藏情况 |
| | | MyCollect myCollect = new LambdaQueryChainWrapper<>(myCollectMapper) |
| | | .eq(MyCollect::getRefId,activityId) |
| | | .eq(MyCollect::getUserId,UserContext.getCurrentUserId()) |
| | | .eq(MyCollect::getDeleteFlag,false) |
| | | .one(); |
| | | vo.setIsCollect(myCollect != null); |
| | | if (!ActivityCoverTypeEnum.TEXT.getType().equals(vo.getCoverType())){ |
| | | vo.setUrl(cOSUtil.getPreviewUrl(vo.getCover())); |
| | | } |
| | | |
| | | //则当前用户未报名 |
| | | if (reportVO == null){ |
| | | vo.setIsReport(false); |