|
|
@@ -7,15 +7,21 @@ 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.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import shop.alien.entity.store.BarPerformance;
|
|
|
+import shop.alien.entity.store.StoreStaffConfig;
|
|
|
+import shop.alien.entity.store.vo.BarPerformanceDetailVo;
|
|
|
+import shop.alien.entity.store.vo.PerformerVo;
|
|
|
import shop.alien.mapper.BarPerformanceMapper;
|
|
|
+import shop.alien.mapper.StoreStaffConfigMapper;
|
|
|
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;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 酒吧演出服务实现类
|
|
|
@@ -30,6 +36,7 @@ import java.util.List;
|
|
|
public class BarPerformanceServiceImpl implements BarPerformanceService {
|
|
|
|
|
|
private final BarPerformanceMapper barPerformanceMapper;
|
|
|
+ private final StoreStaffConfigMapper storeStaffConfigMapper;
|
|
|
private final AiContentModerationUtil aiContentModerationUtil;
|
|
|
|
|
|
@Override
|
|
|
@@ -299,16 +306,98 @@ public class BarPerformanceServiceImpl implements BarPerformanceService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public BarPerformance getBarPerformanceDetail(Integer id) {
|
|
|
+ public BarPerformanceDetailVo 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);
|
|
|
+ BarPerformance barPerformance = barPerformanceMapper.selectOne(queryWrapper);
|
|
|
+ if (barPerformance == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 转换为VO对象
|
|
|
+ BarPerformanceDetailVo detailVo = new BarPerformanceDetailVo();
|
|
|
+ BeanUtils.copyProperties(barPerformance, detailVo);
|
|
|
+
|
|
|
+ // 查询并设置表演嘉宾列表
|
|
|
+ List<PerformerVo> performers = queryPerformersByStaffConfigIds(barPerformance.getStaffConfigIds());
|
|
|
+ detailVo.setPerformers(performers);
|
|
|
+
|
|
|
+ return detailVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据员工配置ID字符串查询表演嘉宾列表
|
|
|
+ *
|
|
|
+ * @param staffConfigIds 员工配置ID字符串,逗号分隔,如 "41,25"
|
|
|
+ * @return 表演嘉宾列表
|
|
|
+ */
|
|
|
+ private List<PerformerVo> queryPerformersByStaffConfigIds(String staffConfigIds) {
|
|
|
+ List<PerformerVo> performerList = new ArrayList<>();
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(staffConfigIds)) {
|
|
|
+ return performerList;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 解析员工ID字符串
|
|
|
+ String[] idArray = staffConfigIds.split(",");
|
|
|
+ List<Integer> staffIdList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (String idStr : idArray) {
|
|
|
+ if (StringUtils.isNotEmpty(idStr.trim())) {
|
|
|
+ try {
|
|
|
+ Integer staffId = Integer.parseInt(idStr.trim());
|
|
|
+ if (staffId > 0) {
|
|
|
+ staffIdList.add(staffId);
|
|
|
+ }
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ log.warn("解析员工配置ID失败,无效的ID:{}", idStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (staffIdList.isEmpty()) {
|
|
|
+ return performerList;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 批量查询员工配置信息
|
|
|
+ List<StoreStaffConfig> staffList = storeStaffConfigMapper.selectBatchIds(staffIdList);
|
|
|
+
|
|
|
+ if (staffList != null && !staffList.isEmpty()) {
|
|
|
+ // 过滤已删除的员工,并转换为PerformerVo
|
|
|
+ performerList = staffList.stream()
|
|
|
+ .filter(staff -> staff != null && staff.getDeleteFlag() != null && staff.getDeleteFlag() == 0)
|
|
|
+ .map(this::convertToPerformerVo)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询表演嘉宾列表异常,staffConfigIds={},异常信息:{}",
|
|
|
+ staffConfigIds, e.getMessage(), e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return performerList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将StoreStaffConfig转换为PerformerVo
|
|
|
+ *
|
|
|
+ * @param staffConfig 员工配置信息
|
|
|
+ * @return 表演嘉宾VO
|
|
|
+ */
|
|
|
+ private PerformerVo convertToPerformerVo(StoreStaffConfig staffConfig) {
|
|
|
+ PerformerVo performerVo = new PerformerVo();
|
|
|
+ performerVo.setId(staffConfig.getId());
|
|
|
+ performerVo.setAvatar(staffConfig.getStaffImage());
|
|
|
+ performerVo.setName(staffConfig.getName());
|
|
|
+ performerVo.setStyle(staffConfig.getStaffPosition());
|
|
|
+ return performerVo;
|
|
|
}
|
|
|
|
|
|
@Override
|