소스 검색

fix:酒吧演出人员配置详情数据

panzhilin 3 달 전
부모
커밋
986e0e59a1

+ 4 - 3
alien-store/src/main/java/shop/alien/store/controller/BarPerformanceController.java

@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
 import shop.alien.entity.store.BarPerformance;
 import shop.alien.entity.store.dto.BarPerformanceOnlineStatusDto;
+import shop.alien.entity.store.vo.BarPerformanceDetailVo;
 import shop.alien.store.service.BarPerformanceService;
 
 /**
@@ -84,15 +85,15 @@ public class BarPerformanceController {
      * 获取酒吧演出详情
      *
      * @param id 演出ID
-     * @return 演出详情
+     * @return 演出详情(包含表演嘉宾信息)
      */
     @ApiOperation("获取酒吧演出详情")
     @ApiImplicitParam(name = "id", value = "演出ID", dataType = "Integer", paramType = "query", required = true)
     @GetMapping("/detail")
-    public R<BarPerformance> getBarPerformanceDetail(@RequestParam Integer id) {
+    public R<BarPerformanceDetailVo> getBarPerformanceDetail(@RequestParam Integer id) {
         log.info("BarPerformanceController.getBarPerformanceDetail?id={}", id);
         try {
-            BarPerformance performance = barPerformanceService.getBarPerformanceDetail(id);
+            BarPerformanceDetailVo performance = barPerformanceService.getBarPerformanceDetail(id);
             if (performance != null) {
                 return R.data(performance);
             } else {

+ 3 - 2
alien-store/src/main/java/shop/alien/store/service/BarPerformanceService.java

@@ -2,6 +2,7 @@ package shop.alien.store.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import shop.alien.entity.store.BarPerformance;
+import shop.alien.entity.store.vo.BarPerformanceDetailVo;
 
 /**
  * 酒吧演出服务接口
@@ -34,9 +35,9 @@ public interface BarPerformanceService {
      * 获取酒吧演出详情
      *
      * @param id 演出ID
-     * @return 演出详情
+     * @return 演出详情(包含表演嘉宾信息)
      */
-    BarPerformance getBarPerformanceDetail(Integer id);
+    BarPerformanceDetailVo getBarPerformanceDetail(Integer id);
 
     /**
      * 删除酒吧演出

+ 91 - 2
alien-store/src/main/java/shop/alien/store/service/impl/BarPerformanceServiceImpl.java

@@ -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