소스 검색

新增健身教练相关接口

zhangchen 2 일 전
부모
커밋
10569b5345

+ 32 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/StoreStaffDetailVo.java

@@ -0,0 +1,32 @@
+package shop.alien.entity.store.vo;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import shop.alien.entity.store.StoreStaffConfig;
+import shop.alien.entity.store.StoreStaffFitnessCourse;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 员工详情视图对象(包含员工信息和课程列表)
+ *
+ * @author system
+ * @since 2025-01-XX
+ */
+@Data
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@ApiModel(value = "StoreStaffDetailVo对象", description = "员工详情视图对象(包含员工信息和课程列表)")
+public class StoreStaffDetailVo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "员工基本信息")
+    private StoreStaffConfig staffInfo;
+
+    @ApiModelProperty(value = "运动健身员工课程信息列表")
+    private List<StoreStaffFitnessCourse> courseList;
+}
+

+ 39 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/StoreStaffFitnessDetailVo.java

@@ -0,0 +1,39 @@
+package shop.alien.entity.store.vo;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import shop.alien.entity.store.StoreStaffConfig;
+import shop.alien.entity.store.StoreStaffFitnessBase;
+import shop.alien.entity.store.StoreStaffFitnessCertification;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 健身教练详情视图对象(包含员工信息、基本信息和认证/荣誉列表)
+ *
+ * @author system
+ * @since 2025-01-XX
+ */
+@Data
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@ApiModel(value = "StoreStaffFitnessDetailVo对象", description = "健身教练详情视图对象(包含员工信息、基本信息和认证/荣誉列表)")
+public class StoreStaffFitnessDetailVo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "员工基本信息")
+    private StoreStaffConfig staffInfo;
+
+    @ApiModelProperty(value = "员工基本信息(运动健身)")
+    private StoreStaffFitnessBase baseInfo;
+
+    @ApiModelProperty(value = "认证列表(type=1)")
+    private List<StoreStaffFitnessCertification> certificationList;
+
+    @ApiModelProperty(value = "荣誉列表(type=2)")
+    private List<StoreStaffFitnessCertification> honorList;
+}
+

+ 81 - 1
alien-store/src/main/java/shop/alien/store/controller/StoreStaffConfigController.java

@@ -72,7 +72,7 @@ public class StoreStaffConfigController {
     @ApiOperation("员工导出")
     @ApiOperationSupport(order = 11)
     @GetMapping("/staffConfigExport")
-    public R staffConfigExport(@RequestParam(required = false) String status) throws IOException {
+    public R<String> staffConfigExport(@RequestParam(required = false) String status) throws IOException {
         log.info("PlatformStoreCouponController.staffConfigExport");
         String s = storeStaffConfigService.staffConfigExport(status);
         return R.data(s);
@@ -185,4 +185,84 @@ public class StoreStaffConfigController {
         return R.data(storeStaffConfigService.getFoodStaffConfigList(page, size, storeId, staffPosition, status));
     }
 
+    /**
+     * 根据ID查询员工详情(包含员工信息和课程列表)
+     *
+     * @param id 员工主键ID
+     * @return 员工详情(包含员工信息和课程列表)
+     */
+    @ApiOperation("根据ID查询员工详情(包含员工信息和课程列表)用户端")
+    @ApiOperationSupport(order = 8)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "员工主键ID", dataType = "Integer", paramType = "query", required = true)
+    })
+    @GetMapping("/getStaffDetailWithCourse")
+    public R<shop.alien.entity.store.vo.StoreStaffDetailVo> getStaffDetailWithCourse(
+            @RequestParam(value = "id") Integer id) {
+        log.info("查询员工详情(包含课程信息),id={}", id);
+        
+        try {
+            // 参数校验
+            if (id == null || id <= 0) {
+                log.warn("查询员工详情失败,员工ID无效:{}", id);
+                return R.fail("员工ID不能为空且必须大于0");
+            }
+            
+            shop.alien.entity.store.vo.StoreStaffDetailVo result = storeStaffConfigService.getStaffDetailWithCourse(id);
+            
+            if (result == null) {
+                log.warn("查询员工详情失败,员工不存在:id={}", id);
+                return R.fail("员工不存在");
+            }
+            
+            log.info("查询员工详情成功,id={},课程数量:{}", id, 
+                    result.getCourseList() != null ? result.getCourseList().size() : 0);
+            return R.data(result);
+        } catch (Exception e) {
+            log.error("查询员工详情异常,id={},异常信息:{}", id, e.getMessage(), e);
+            return R.fail("查询失败:" + e.getMessage());
+        }
+    }
+
+    /**
+     * 查询健身教练详情(包含员工信息、基本信息和认证/荣誉列表)
+     *
+     * @param id 员工主键ID
+     * @return 健身教练详情(包含员工信息、基本信息和认证/荣誉列表)
+     */
+    @ApiOperation("查询健身教练详情(包含员工信息、基本信息和认证/荣誉列表)用户端")
+    @ApiOperationSupport(order = 9)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "员工主键ID", dataType = "Integer", paramType = "query", required = true)
+    })
+    @GetMapping("/getFitnessCoachDetail")
+    public R<shop.alien.entity.store.vo.StoreStaffFitnessDetailVo> getFitnessCoachDetail(
+            @RequestParam(value = "id") Integer id) {
+        log.info("查询健身教练详情,id={}", id);
+        
+        try {
+            // 参数校验
+            if (id == null || id <= 0) {
+                log.warn("查询健身教练详情失败,员工ID无效:{}", id);
+                return R.fail("员工ID不能为空且必须大于0");
+            }
+            
+            shop.alien.entity.store.vo.StoreStaffFitnessDetailVo result = storeStaffConfigService.getFitnessCoachDetail(id);
+            
+            if (result == null) {
+                log.warn("查询健身教练详情失败,员工不存在:id={}", id);
+                return R.fail("员工不存在");
+            }
+            
+            log.info("查询健身教练详情成功,id={},认证数量:{},荣誉数量:{}", 
+                    id, 
+                    result.getCertificationList() != null ? result.getCertificationList().size() : 0,
+                    result.getHonorList() != null ? result.getHonorList().size() : 0);
+            return R.data(result);
+        } catch (Exception e) {
+            log.error("查询健身教练详情异常,id={},异常信息:{}", id, e.getMessage(), e);
+            return R.fail("查询失败:" + e.getMessage());
+        }
+    }
+
 }

+ 23 - 0
alien-store/src/main/java/shop/alien/store/service/StoreStaffConfigService.java

@@ -70,4 +70,27 @@ public interface StoreStaffConfigService {
      * @return 员工列表
      */
     IPage<StoreStaffConfig> getFoodStaffConfigList(int page, int size, Integer storeId, String staffPosition, String status);
+
+    /**
+     * 根据ID查询员工详情(包含员工信息和课程列表)
+     * <p>
+     * 查询员工基本信息以及关联的运动健身员工课程信息
+     * </p>
+     *
+     * @param id 员工主键ID,必须大于0
+     * @return 员工详情(包含员工信息和课程列表),如果员工不存在则返回null
+     */
+    shop.alien.entity.store.vo.StoreStaffDetailVo getStaffDetailWithCourse(Integer id);
+
+    /**
+     * 查询健身教练详情(包含员工信息、基本信息和认证/荣誉列表)
+     * <p>
+     * 查询员工基本信息、运动健身员工基本信息以及关联的认证和荣誉信息
+     * 认证和荣誉根据type字段分开(1-认证,2-荣誉)
+     * </p>
+     *
+     * @param id 员工主键ID,必须大于0
+     * @return 健身教练详情(包含员工信息、基本信息和认证/荣誉列表),如果员工不存在则返回null
+     */
+    shop.alien.entity.store.vo.StoreStaffFitnessDetailVo getFitnessCoachDetail(Integer id);
 }

+ 123 - 0
alien-store/src/main/java/shop/alien/store/service/impl/StoreStaffConfigServiceImpl.java

@@ -10,11 +10,17 @@ import lombok.RequiredArgsConstructor;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import lombok.extern.slf4j.Slf4j;
 import shop.alien.entity.store.StoreStaffConfig;
 import shop.alien.entity.store.excelVo.StoreStaffConfigExcelVo;
 import shop.alien.entity.store.excelVo.util.ExcelGenerator;
+import shop.alien.entity.store.vo.StoreStaffDetailVo;
+import shop.alien.entity.store.vo.StoreStaffFitnessDetailVo;
 import shop.alien.mapper.StoreStaffConfigMapper;
 import shop.alien.store.service.StoreStaffConfigService;
+import shop.alien.store.service.StoreStaffFitnessBaseService;
+import shop.alien.store.service.StoreStaffFitnessCertificationService;
+import shop.alien.store.service.StoreStaffFitnessCourseService;
 import shop.alien.store.util.CommonConstant;
 import shop.alien.util.ali.AliOSSUtil;
 
@@ -31,6 +37,7 @@ import java.util.UUID;
  * @Description: 员工管理
  */
 
+@Slf4j
 @Service
 @RequiredArgsConstructor
 public class StoreStaffConfigServiceImpl implements StoreStaffConfigService {
@@ -39,6 +46,22 @@ public class StoreStaffConfigServiceImpl implements StoreStaffConfigService {
 
     private final AliOSSUtil aliOSSUtil;
 
+    private final StoreStaffFitnessCourseService storeStaffFitnessCourseService;
+
+    private final StoreStaffFitnessBaseService storeStaffFitnessBaseService;
+
+    private final StoreStaffFitnessCertificationService storeStaffFitnessCertificationService;
+
+    /**
+     * 认证类型:认证
+     */
+    private static final Integer CERTIFICATION_TYPE = 1;
+
+    /**
+     * 认证类型:荣誉
+     */
+    private static final Integer HONOR_TYPE = 2;
+
     @Value("${spring.web.resources.excel-path}")
     private String excelPath;
     @Value("${spring.web.resources.excel-clearing-receipt}")
@@ -242,4 +265,104 @@ public class StoreStaffConfigServiceImpl implements StoreStaffConfigService {
         queryWrapper.orderByDesc("top_status", "top_time", "created_time");
         return storeStaffConfigMapper.selectPage(storePage, queryWrapper);
     }
+
+    @Override
+    public StoreStaffDetailVo getStaffDetailWithCourse(Integer id) {
+        log.info("查询员工详情(包含课程信息),id={}", id);
+        
+        // 参数校验
+        if (id == null || id <= 0) {
+            log.warn("查询员工详情失败,员工ID无效:{}", id);
+            return null;
+        }
+        
+        try {
+            // 查询员工基本信息
+            LambdaQueryWrapper<StoreStaffConfig> staffWrapper = new LambdaQueryWrapper<>();
+            staffWrapper.eq(StoreStaffConfig::getId, id)
+                    .eq(StoreStaffConfig::getDeleteFlag, CommonConstant.DELETE_FLAG_UNDELETE);
+            StoreStaffConfig staffConfig = storeStaffConfigMapper.selectOne(staffWrapper);
+            
+            if (staffConfig == null) {
+                log.warn("查询员工详情失败,员工不存在:id={}", id);
+                return null;
+            }
+            
+            // 查询关联的课程信息
+            List<shop.alien.entity.store.StoreStaffFitnessCourse> courseList = 
+                    storeStaffFitnessCourseService.getListByStaffId(id);
+            
+            // 构建返回对象
+            StoreStaffDetailVo detailVo = new StoreStaffDetailVo();
+            detailVo.setStaffInfo(staffConfig);
+            detailVo.setCourseList(courseList);
+            
+            log.info("查询员工详情成功,id={},课程数量:{}", id, courseList != null ? courseList.size() : 0);
+            return detailVo;
+        } catch (Exception e) {
+            log.error("查询员工详情异常,id={},异常信息:{}", id, e.getMessage(), e);
+            throw new RuntimeException("查询员工详情异常:" + e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public StoreStaffFitnessDetailVo getFitnessCoachDetail(Integer id) {
+        log.info("查询健身教练详情,id={}", id);
+        
+        // 参数校验
+        if (id == null || id <= 0) {
+            log.warn("查询健身教练详情失败,员工ID无效:{}", id);
+            return null;
+        }
+        
+        try {
+            // 查询员工基本信息
+            LambdaQueryWrapper<StoreStaffConfig> staffWrapper = new LambdaQueryWrapper<>();
+            staffWrapper.eq(StoreStaffConfig::getId, id)
+                    .eq(StoreStaffConfig::getDeleteFlag, CommonConstant.DELETE_FLAG_UNDELETE);
+            StoreStaffConfig staffConfig = storeStaffConfigMapper.selectOne(staffWrapper);
+            
+            if (staffConfig == null) {
+                log.warn("查询健身教练详情失败,员工不存在:id={}", id);
+                return null;
+            }
+            
+            // 查询员工基本信息(运动健身)
+            shop.alien.entity.store.StoreStaffFitnessBase baseInfo = null;
+            try {
+                shop.alien.entity.result.R<shop.alien.entity.store.StoreStaffFitnessBase> baseResult = 
+                        storeStaffFitnessBaseService.getByStaffId(id);
+                if (baseResult != null && shop.alien.entity.result.R.isSuccess(baseResult) && baseResult.getData() != null) {
+                    baseInfo = baseResult.getData();
+                }
+            } catch (Exception e) {
+                log.warn("查询员工基本信息失败,id={},异常信息:{}", id, e.getMessage());
+                // 基本信息查询失败不影响整体返回,设置为null即可
+            }
+            
+            // 查询认证列表(type=1)
+            List<shop.alien.entity.store.StoreStaffFitnessCertification> certificationList = 
+                    storeStaffFitnessCertificationService.getListByStaffIdAndType(id, CERTIFICATION_TYPE);
+            
+            // 查询荣誉列表(type=2)
+            List<shop.alien.entity.store.StoreStaffFitnessCertification> honorList = 
+                    storeStaffFitnessCertificationService.getListByStaffIdAndType(id, HONOR_TYPE);
+            
+            // 构建返回对象
+            StoreStaffFitnessDetailVo detailVo = new StoreStaffFitnessDetailVo();
+            detailVo.setStaffInfo(staffConfig);
+            detailVo.setBaseInfo(baseInfo);
+            detailVo.setCertificationList(certificationList != null ? certificationList : new ArrayList<>());
+            detailVo.setHonorList(honorList != null ? honorList : new ArrayList<>());
+            
+            log.info("查询健身教练详情成功,id={},认证数量:{},荣誉数量:{}", 
+                    id, 
+                    certificationList != null ? certificationList.size() : 0,
+                    honorList != null ? honorList.size() : 0);
+            return detailVo;
+        } catch (Exception e) {
+            log.error("查询健身教练详情异常,id={},异常信息:{}", id, e.getMessage(), e);
+            throw new RuntimeException("查询健身教练详情异常:" + e.getMessage(), e);
+        }
+    }
 }