package cn.lili.modules.lmk.service.impl; import cn.lili.base.Result; import cn.lili.modules.lmk.domain.entity.Activity; import cn.lili.modules.lmk.domain.query.ActivityReportQuery; import cn.lili.modules.lmk.domain.query.MyActivityQuery; import cn.lili.modules.lmk.domain.vo.ActivityReportVO; import cn.lili.modules.lmk.domain.vo.ActivityVO; import cn.lili.modules.lmk.domain.vo.MyActivityVo; import cn.lili.modules.lmk.mapper.ActivityMapper; import cn.lili.modules.lmk.service.LmkFileService; import cn.lili.modules.lmk.service.MyActivityService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; @Service @RequiredArgsConstructor public class MyActivityServiceImpl extends ServiceImpl implements MyActivityService { private final ActivityMapper activityMapper; private final LmkFileService lmkFileService; @Override public Result getMyActivityList(MyActivityQuery query) { List myActivityList = activityMapper.getMyActivityList(query); for (MyActivityVo vo : myActivityList) { System.out.println(vo); if (!"文字".equals(vo.getCoverType())){ // String url = lmkFileService.getPreviewUrl(vo.getCover()); // vo.setUrl(url); } } return Result.ok().data(myActivityList); } @Override public Result cancelActivity(ActivityReportQuery query) { // TODO 判断是否在报名时间内 在的话可以取消报名, (若有报名费需要退款) ActivityReportVO vo = activityMapper.getActivityReport(query); Activity activity = activityMapper.selectById(vo.getActivityId()); Date date = new Date(); if(!date.before(activity.getReportStartTime()) && !date.after(activity.getReportEndTime())){ int affectedRows = activityMapper.cancelActivity(vo.getId()); if (affectedRows > 0) { return Result.ok("活动取消成功"); } else { // 可选:记录警告日志 throw new RuntimeException("活动不存在或已取消"); } }else { throw new RuntimeException("活动已不在报名时间内无法取消"); } } }