|
|
@@ -0,0 +1,489 @@
|
|
|
+package shop.alien.store.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import shop.alien.entity.store.BarPerformance;
|
|
|
+import shop.alien.mapper.BarPerformanceMapper;
|
|
|
+import shop.alien.store.service.BarPerformanceService;
|
|
|
+import shop.alien.store.util.ai.AiContentModerationUtil;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 酒吧演出服务实现类
|
|
|
+ * 实现酒吧演出的CRUD、审核、上下线等核心业务功能
|
|
|
+ *
|
|
|
+ * @author assistant
|
|
|
+ * @since 2025-12-17
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class BarPerformanceServiceImpl implements BarPerformanceService {
|
|
|
+
|
|
|
+ private final BarPerformanceMapper barPerformanceMapper;
|
|
|
+ private final AiContentModerationUtil aiContentModerationUtil;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<BarPerformance> getBarPerformanceList(int page, int size, String status) {
|
|
|
+ IPage<BarPerformance> performancePage = new Page<>(page, size);
|
|
|
+ QueryWrapper<BarPerformance> queryWrapper = new QueryWrapper<>();
|
|
|
+ // 根据状态查询演出
|
|
|
+ queryWrapper.like(StringUtils.isNotEmpty(status), "status", status);
|
|
|
+ // 只查询未删除的记录
|
|
|
+ queryWrapper.eq("delete_flag", 0);
|
|
|
+ // 按创建时间降序排序
|
|
|
+ queryWrapper.orderByDesc("created_time");
|
|
|
+ return barPerformanceMapper.selectPage(performancePage, queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int addOrUpdateBarPerformance(BarPerformance barPerformance) {
|
|
|
+ // 1. 演出名称验证:必填且限20字
|
|
|
+ if (StringUtils.isEmpty(barPerformance.getPerformanceName())) {
|
|
|
+ throw new IllegalArgumentException("演出名称不能为空");
|
|
|
+ }
|
|
|
+ if (barPerformance.getPerformanceName().length() > 20) {
|
|
|
+ throw new IllegalArgumentException("演出名称长度不能超过20个字符");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 演出海报验证:必填且限1张
|
|
|
+ if (StringUtils.isEmpty(barPerformance.getPerformancePoster())) {
|
|
|
+ throw new IllegalArgumentException("演出海报不能为空");
|
|
|
+ }
|
|
|
+ // 检查海报是否有多张(逗号分隔)
|
|
|
+ String[] posterImages = barPerformance.getPerformancePoster().split(",");
|
|
|
+ if (posterImages.length > 1) {
|
|
|
+ throw new IllegalArgumentException("演出海报最多只能上传1张");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 演出类型和频次的关联验证:特邀演出(0)只能选单次(0)
|
|
|
+ if (barPerformance.getPerformanceType() != null && barPerformance.getPerformanceType() == 0) {
|
|
|
+ // 特邀演出
|
|
|
+ if (StringUtils.isEmpty(barPerformance.getPerformanceFrequency()) || !"0".equals(barPerformance.getPerformanceFrequency())) {
|
|
|
+ throw new IllegalArgumentException("特邀演出只能选择单次演出");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 4. 演出频次相关验证
|
|
|
+ String performanceFrequency = barPerformance.getPerformanceFrequency();
|
|
|
+ if (StringUtils.isEmpty(performanceFrequency)) {
|
|
|
+ throw new IllegalArgumentException("演出频次不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取今天的开始时间(用于时间验证)
|
|
|
+ java.util.Calendar cal = java.util.Calendar.getInstance();
|
|
|
+ cal.set(java.util.Calendar.HOUR_OF_DAY, 0);
|
|
|
+ cal.set(java.util.Calendar.MINUTE, 0);
|
|
|
+ cal.set(java.util.Calendar.SECOND, 0);
|
|
|
+ cal.set(java.util.Calendar.MILLISECOND, 0);
|
|
|
+ Date todayStart = cal.getTime();
|
|
|
+
|
|
|
+ switch (performanceFrequency) {
|
|
|
+ case "0": // 单次演出
|
|
|
+ if (barPerformance.getSingleStartDatetime() == null) {
|
|
|
+ throw new IllegalArgumentException("单次演出必须填写开始时间");
|
|
|
+ }
|
|
|
+ if (barPerformance.getSingleEndDatetime() == null) {
|
|
|
+ throw new IllegalArgumentException("单次演出必须填写结束时间");
|
|
|
+ }
|
|
|
+ // 验证开始时间必须是今天或以后
|
|
|
+ if (barPerformance.getSingleStartDatetime().before(todayStart)) {
|
|
|
+ throw new IllegalArgumentException("开始时间必须是今天或以后");
|
|
|
+ }
|
|
|
+ // 确保开始时间早于结束时间
|
|
|
+ if (barPerformance.getSingleStartDatetime().after(barPerformance.getSingleEndDatetime())) {
|
|
|
+ throw new IllegalArgumentException("开始时间不能晚于结束时间");
|
|
|
+ }
|
|
|
+ // 单次演出不需要周天数据,清除周天字段(设置为空字符串,确保数据库插入时包含该字段)
|
|
|
+ barPerformance.setPerformanceWeek("");
|
|
|
+ break;
|
|
|
+ case "1": // 每天定时
|
|
|
+ if (barPerformance.getDailyStartDate() == null) {
|
|
|
+ throw new IllegalArgumentException("每天定时演出必须填写开始日期");
|
|
|
+ }
|
|
|
+ if (barPerformance.getDailyEndDate() == null) {
|
|
|
+ throw new IllegalArgumentException("每天定时演出必须填写结束日期");
|
|
|
+ }
|
|
|
+ // 验证开始日期必须是今天或以后
|
|
|
+ if (barPerformance.getDailyStartDate().before(todayStart)) {
|
|
|
+ throw new IllegalArgumentException("开始日期必须是今天或以后");
|
|
|
+ }
|
|
|
+ // 确保开始日期早于或等于结束日期
|
|
|
+ if (barPerformance.getDailyStartDate().after(barPerformance.getDailyEndDate())) {
|
|
|
+ throw new IllegalArgumentException("开始日期不能晚于结束日期");
|
|
|
+ }
|
|
|
+ // 验证时间字段(复用single_start_datetime和single_end_datetime,只使用时间部分)
|
|
|
+ if (barPerformance.getSingleStartDatetime() == null) {
|
|
|
+ throw new IllegalArgumentException("每天定时演出必须填写开始时间");
|
|
|
+ }
|
|
|
+ if (barPerformance.getSingleEndDatetime() == null) {
|
|
|
+ throw new IllegalArgumentException("每天定时演出必须填写结束时间");
|
|
|
+ }
|
|
|
+ // 验证时间逻辑:开始时间必须早于结束时间(只比较时间部分,忽略日期部分)
|
|
|
+ if (!isTimeBefore(barPerformance.getSingleStartDatetime(), barPerformance.getSingleEndDatetime())) {
|
|
|
+ throw new IllegalArgumentException("开始时间必须早于结束时间");
|
|
|
+ }
|
|
|
+ // 每天定时不需要周天数据,清除周天字段(设置为空字符串,确保数据库插入时包含该字段)
|
|
|
+ barPerformance.setPerformanceWeek("");
|
|
|
+ break;
|
|
|
+ case "2": // 每周定时
|
|
|
+ if (barPerformance.getDailyStartDate() == null) {
|
|
|
+ throw new IllegalArgumentException("每周定时演出必须填写开始日期");
|
|
|
+ }
|
|
|
+ if (barPerformance.getDailyEndDate() == null) {
|
|
|
+ throw new IllegalArgumentException("每周定时演出必须填写结束日期");
|
|
|
+ }
|
|
|
+ // 验证开始日期必须是今天或以后
|
|
|
+ if (barPerformance.getDailyStartDate().before(todayStart)) {
|
|
|
+ throw new IllegalArgumentException("开始日期必须是今天或以后");
|
|
|
+ }
|
|
|
+ // 确保开始日期早于或等于结束日期
|
|
|
+ if (barPerformance.getDailyStartDate().after(barPerformance.getDailyEndDate())) {
|
|
|
+ throw new IllegalArgumentException("开始日期不能晚于结束日期");
|
|
|
+ }
|
|
|
+ // 每周定时演出需要验证演出日期(周几)
|
|
|
+ if (StringUtils.isEmpty(barPerformance.getPerformanceWeek())) {
|
|
|
+ throw new IllegalArgumentException("每周定时演出必须选择演出日期");
|
|
|
+ }
|
|
|
+ // 验证时间字段(复用single_start_datetime和single_end_datetime,只使用时间部分)
|
|
|
+ if (barPerformance.getSingleStartDatetime() == null) {
|
|
|
+ throw new IllegalArgumentException("每周定时演出必须填写开始时间");
|
|
|
+ }
|
|
|
+ if (barPerformance.getSingleEndDatetime() == null) {
|
|
|
+ throw new IllegalArgumentException("每周定时演出必须填写结束时间");
|
|
|
+ }
|
|
|
+ // 验证时间逻辑:开始时间必须早于结束时间(只比较时间部分,忽略日期部分)
|
|
|
+ if (!isTimeBefore(barPerformance.getSingleStartDatetime(), barPerformance.getSingleEndDatetime())) {
|
|
|
+ throw new IllegalArgumentException("开始时间必须早于结束时间");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ throw new IllegalArgumentException("演出频次类型无效");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 5. 图文详情图片验证:最多9张
|
|
|
+ if (StringUtils.isNotEmpty(barPerformance.getPerformanceDetail())) {
|
|
|
+ String[] detailImages = barPerformance.getPerformanceDetail().split(",");
|
|
|
+ if (detailImages.length > 9) {
|
|
|
+ throw new IllegalArgumentException("图文详情图片最多只能上传9张");
|
|
|
+ }
|
|
|
+ // 检查每张图片URL格式是否有效
|
|
|
+ for (String imageUrl : detailImages) {
|
|
|
+ if (StringUtils.isEmpty(imageUrl.trim())) {
|
|
|
+ throw new IllegalArgumentException("图文详情图片URL不能为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 6. 演出须知字数验证:限300字
|
|
|
+ if (StringUtils.isNotEmpty(barPerformance.getPerformanceNotice()) && barPerformance.getPerformanceNotice().length() > 300) {
|
|
|
+ throw new IllegalArgumentException("演出须知不能超过300个字符");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 7. 图文详情文字验证:限300字(如果有performanceContent字段)
|
|
|
+ if (StringUtils.isNotEmpty(barPerformance.getPerformanceContent()) && barPerformance.getPerformanceContent().length() > 300) {
|
|
|
+ throw new IllegalArgumentException("图文详情文字不能超过300个字符");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 8. 图文内容审核(调用AI内容审核接口)- 新增或更新时都必须进行
|
|
|
+ // - 文本:名称 + 详情 + 须知 + 风格(如果有)
|
|
|
+ // - 图片:海报URL(如果有) + 图文详情图片URL(如果有)
|
|
|
+ String moderationText = buildModerationText(barPerformance);
|
|
|
+ List<String> imageUrls = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotEmpty(barPerformance.getPerformancePoster())) {
|
|
|
+ imageUrls.add(barPerformance.getPerformancePoster());
|
|
|
+ }
|
|
|
+ // 添加图文详情图片到审核列表
|
|
|
+ if (StringUtils.isNotEmpty(barPerformance.getPerformanceDetail())) {
|
|
|
+ String[] detailImages = barPerformance.getPerformanceDetail().split(",");
|
|
|
+ for (String imageUrl : detailImages) {
|
|
|
+ if (StringUtils.isNotEmpty(imageUrl.trim())) {
|
|
|
+ imageUrls.add(imageUrl.trim());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 调用AI内容审核接口,如果检测到违规内容会抛出异常
|
|
|
+ AiContentModerationUtil.AuditResult auditResult = aiContentModerationUtil.auditContent(moderationText, imageUrls);
|
|
|
+ if (auditResult == null || !auditResult.isPassed()) {
|
|
|
+ String failureReason = (auditResult != null && StringUtils.isNotEmpty(auditResult.getFailureReason()))
|
|
|
+ ? auditResult.getFailureReason()
|
|
|
+ : "内容包含违规信息";
|
|
|
+ log.warn("酒吧演出内容审核失败:{}", failureReason);
|
|
|
+ throw new IllegalArgumentException("内容审核未通过:" + failureReason);
|
|
|
+ }
|
|
|
+ log.info("酒吧演出内容审核通过");
|
|
|
+
|
|
|
+ Integer id = barPerformance.getId();
|
|
|
+
|
|
|
+ if (id == null || id == 0) {
|
|
|
+ // 新增操作
|
|
|
+ Date nowDate = new Date(System.currentTimeMillis());
|
|
|
+ barPerformance.setCreatedTime(nowDate);
|
|
|
+ // 设置删除标记为0(未删除)
|
|
|
+ if (barPerformance.getDeleteFlag() == null) {
|
|
|
+ barPerformance.setDeleteFlag(0);
|
|
|
+ }
|
|
|
+ // 设置默认状态为待审核(0)
|
|
|
+ if (barPerformance.getStatus() == null) {
|
|
|
+ barPerformance.setStatus(0);
|
|
|
+ }
|
|
|
+ // 设置默认审核状态为待审核(0),对应数据库字段 review_status
|
|
|
+ if (barPerformance.getReviewStatus() == null) {
|
|
|
+ barPerformance.setReviewStatus(0);
|
|
|
+ }
|
|
|
+ // 设置默认上线状态为下线(0)
|
|
|
+ if (barPerformance.getOnlineStatus() == null) {
|
|
|
+ barPerformance.setOnlineStatus(0);
|
|
|
+ }
|
|
|
+ // 设置默认隐藏状态为不隐藏(0)
|
|
|
+ if (barPerformance.getHidden() == null) {
|
|
|
+ barPerformance.setHidden(0);
|
|
|
+ }
|
|
|
+ // 重置id,让数据库自动生成
|
|
|
+ barPerformance.setId(null);
|
|
|
+ // 确保 performance_week 不为 null(如果为 null 则设置为空字符串,避免数据库插入错误)
|
|
|
+ if (barPerformance.getPerformanceWeek() == null) {
|
|
|
+ barPerformance.setPerformanceWeek("");
|
|
|
+ }
|
|
|
+ return barPerformanceMapper.insert(barPerformance);
|
|
|
+ } else {
|
|
|
+ // 更新操作:先查询记录是否存在
|
|
|
+ BarPerformance existing = barPerformanceMapper.selectById(id);
|
|
|
+ if (existing == null) {
|
|
|
+ // 记录不存在,转为新增操作
|
|
|
+ barPerformance.setId(null);
|
|
|
+ Date nowDate = new Date(System.currentTimeMillis());
|
|
|
+ barPerformance.setCreatedTime(nowDate);
|
|
|
+ // 设置默认值
|
|
|
+ if (barPerformance.getDeleteFlag() == null) {
|
|
|
+ barPerformance.setDeleteFlag(0);
|
|
|
+ }
|
|
|
+ if (barPerformance.getStatus() == null) {
|
|
|
+ barPerformance.setStatus(0);
|
|
|
+ }
|
|
|
+ if (barPerformance.getReviewStatus() == null) {
|
|
|
+ barPerformance.setReviewStatus(0);
|
|
|
+ }
|
|
|
+ if (barPerformance.getOnlineStatus() == null) {
|
|
|
+ barPerformance.setOnlineStatus(0);
|
|
|
+ }
|
|
|
+ if (barPerformance.getHidden() == null) {
|
|
|
+ barPerformance.setHidden(0);
|
|
|
+ }
|
|
|
+ // 确保 performance_week 不为 null(如果为 null 则设置为空字符串,避免数据库插入错误)
|
|
|
+ if (barPerformance.getPerformanceWeek() == null) {
|
|
|
+ barPerformance.setPerformanceWeek("");
|
|
|
+ }
|
|
|
+ return barPerformanceMapper.insert(barPerformance);
|
|
|
+ } else {
|
|
|
+ // 记录存在,执行更新
|
|
|
+ return barPerformanceMapper.updateById(barPerformance);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BarPerformance getBarPerformanceDetail(Integer id) {
|
|
|
+ if (id == null || id <= 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryWrapper<BarPerformance> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("id", id);
|
|
|
+ queryWrapper.eq("delete_flag", 0);
|
|
|
+
|
|
|
+ return barPerformanceMapper.selectOne(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Integer deleteBarPerformance(Integer id) {
|
|
|
+ if (id == null || id <= 0) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ // 使用 MyBatis-Plus 的逻辑删除,会自动将 deleteFlag 设置为 1
|
|
|
+ return barPerformanceMapper.deleteById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Integer setOnlineStatus(Integer id, Integer onlineStatus) {
|
|
|
+ if (id == null || onlineStatus == null) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaUpdateWrapper<BarPerformance> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ lambdaUpdateWrapper.eq(BarPerformance::getId, id);
|
|
|
+ lambdaUpdateWrapper.set(BarPerformance::getOnlineStatus, onlineStatus);
|
|
|
+
|
|
|
+ return barPerformanceMapper.update(null, lambdaUpdateWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<BarPerformance> queryPerformanceListByStoreId(Integer page, Integer size, Integer storeId, String status) {
|
|
|
+ // 使用新的方法,支持按审核状态和分类筛选
|
|
|
+ // status参数转换为reviewStatus(对应数据库字段 review_status)
|
|
|
+ Integer reviewStatus = null;
|
|
|
+ if (StringUtils.isNotEmpty(status)) {
|
|
|
+ try {
|
|
|
+ reviewStatus = Integer.parseInt(status);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ // 忽略无效的状态值
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return queryPerformanceListByStoreIdAndCategory(page, size, storeId, reviewStatus, "all", null);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<BarPerformance> queryPerformanceListByStoreIdAndCategory(Integer page, Integer size, Integer storeId, Integer reviewStatus, String category, String performanceName) {
|
|
|
+ if (page == null || size == null || storeId == null || storeId <= 0) {
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ IPage<BarPerformance> performancePage = new Page<>(page, size);
|
|
|
+ QueryWrapper<BarPerformance> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("store_id", storeId);
|
|
|
+
|
|
|
+ // 按演出名称搜索(支持模糊搜索)
|
|
|
+ if (StringUtils.isNotEmpty(performanceName)) {
|
|
|
+ queryWrapper.like("performance_name", performanceName);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 按审核状态筛选(数据库字段 review_status)
|
|
|
+ if (reviewStatus != null) {
|
|
|
+ queryWrapper.eq("review_status", reviewStatus);
|
|
|
+ } else {
|
|
|
+ // 不查询草稿(review_status为null的记录)
|
|
|
+ queryWrapper.isNotNull("review_status");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 按演出分类筛选
|
|
|
+ if (StringUtils.isNotEmpty(category) && !"all".equals(category)) {
|
|
|
+ Date now = new Date();
|
|
|
+ // 获取今天的开始时间(00:00:00)
|
|
|
+ java.util.Calendar cal = java.util.Calendar.getInstance();
|
|
|
+ cal.setTime(now);
|
|
|
+ cal.set(java.util.Calendar.HOUR_OF_DAY, 0);
|
|
|
+ cal.set(java.util.Calendar.MINUTE, 0);
|
|
|
+ cal.set(java.util.Calendar.SECOND, 0);
|
|
|
+ cal.set(java.util.Calendar.MILLISECOND, 0);
|
|
|
+ Date todayStart = cal.getTime();
|
|
|
+
|
|
|
+ switch (category) {
|
|
|
+ case "not_started": // 未开始
|
|
|
+ queryWrapper.and(wrapper -> {
|
|
|
+ // 单次演出:开始时间 > 现在
|
|
|
+ wrapper.or(w -> w.eq("performance_frequency", "0")
|
|
|
+ .gt("single_start_datetime", now));
|
|
|
+ // 定时演出:开始日期 > 今天 或 (开始日期 = 今天 但还未到演出时间)
|
|
|
+ wrapper.or(w -> w.in("performance_frequency", "1", "2")
|
|
|
+ .gt("daily_start_date", todayStart));
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case "in_progress": // 进行中
|
|
|
+ queryWrapper.and(wrapper -> {
|
|
|
+ // 单次演出:开始时间 <= 现在 AND 结束时间 >= 现在
|
|
|
+ wrapper.or(w -> w.eq("performance_frequency", "0")
|
|
|
+ .le("single_start_datetime", now)
|
|
|
+ .ge("single_end_datetime", now));
|
|
|
+ // 定时演出:开始日期 <= 今天 AND 结束日期 >= 今天
|
|
|
+ wrapper.or(w -> w.in("performance_frequency", "1", "2")
|
|
|
+ .le("daily_start_date", todayStart)
|
|
|
+ .ge("daily_end_date", todayStart));
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case "ended": // 已结束
|
|
|
+ queryWrapper.and(wrapper -> {
|
|
|
+ // 单次演出:结束时间 < 现在
|
|
|
+ wrapper.or(w -> w.eq("performance_frequency", "0")
|
|
|
+ .lt("single_end_datetime", now));
|
|
|
+ // 定时演出:结束日期 < 今天
|
|
|
+ wrapper.or(w -> w.in("performance_frequency", "1", "2")
|
|
|
+ .lt("daily_end_date", todayStart));
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ // 其他情况,不添加额外条件
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ queryWrapper.eq("delete_flag", 0);
|
|
|
+ // 按提交时间(创建时间)倒序排序
|
|
|
+ queryWrapper.orderByDesc("created_time");
|
|
|
+
|
|
|
+ return barPerformanceMapper.selectPage(performancePage, queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 比较两个时间(只比较时间部分,忽略日期部分)
|
|
|
+ * 用于每天定时和每周定时演出的时间验证
|
|
|
+ *
|
|
|
+ * @param time1 开始时间
|
|
|
+ * @param time2 结束时间
|
|
|
+ * @return true表示time1早于time2,false表示time1晚于或等于time2
|
|
|
+ */
|
|
|
+ private boolean isTimeBefore(Date time1, Date time2) {
|
|
|
+ if (time1 == null || time2 == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ java.util.Calendar cal1 = java.util.Calendar.getInstance();
|
|
|
+ cal1.setTime(time1);
|
|
|
+ int hour1 = cal1.get(java.util.Calendar.HOUR_OF_DAY);
|
|
|
+ int minute1 = cal1.get(java.util.Calendar.MINUTE);
|
|
|
+ int second1 = cal1.get(java.util.Calendar.SECOND);
|
|
|
+
|
|
|
+ java.util.Calendar cal2 = java.util.Calendar.getInstance();
|
|
|
+ cal2.setTime(time2);
|
|
|
+ int hour2 = cal2.get(java.util.Calendar.HOUR_OF_DAY);
|
|
|
+ int minute2 = cal2.get(java.util.Calendar.MINUTE);
|
|
|
+ int second2 = cal2.get(java.util.Calendar.SECOND);
|
|
|
+
|
|
|
+ // 比较小时
|
|
|
+ if (hour1 < hour2) {
|
|
|
+ return true;
|
|
|
+ } else if (hour1 > hour2) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 小时相同,比较分钟
|
|
|
+ if (minute1 < minute2) {
|
|
|
+ return true;
|
|
|
+ } else if (minute1 > minute2) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 分钟相同,比较秒
|
|
|
+ return second1 < second2;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String buildModerationText(BarPerformance barPerformance) {
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ if (barPerformance == null) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(barPerformance.getPerformanceName())) {
|
|
|
+ sb.append("演出名称:").append(barPerformance.getPerformanceName()).append("\n");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(barPerformance.getPerformanceStyle())) {
|
|
|
+ sb.append("演出风格:").append(barPerformance.getPerformanceStyle()).append("\n");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(barPerformance.getPerformanceContent())) {
|
|
|
+ sb.append("演出详情:").append(barPerformance.getPerformanceContent()).append("\n");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(barPerformance.getPerformanceNotice())) {
|
|
|
+ sb.append("演出须知:").append(barPerformance.getPerformanceNotice()).append("\n");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(barPerformance.getPerformanceDetail())) {
|
|
|
+ sb.append("图文详情:").append(barPerformance.getPerformanceDetail()).append("\n");
|
|
|
+ }
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+}
|