Explorar o código

refactor(app): 重构课程信息获取接口

- 修改 getCourseInfo 方法返回类型,从 VerifyCourseInfoDTO 列表改为 CoursesPriceRulesVO 列表
- 移除 VerifyCourseInfoDTO 类,简化数据结构
- 优化课程信息处理逻辑,直接在查询结果中添加额外字段
- 更新相关 mapper 和 controller 接口
SheepHy hai 4 días
pai
achega
e83b5c38fd

+ 1 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/controller/commercial/CommercialController.java

@@ -79,7 +79,7 @@ public class CommercialController {
      */
     @Operation(summary = "课程详情")
     @GetMapping("/getCourseInfo/{courseId}")
-    public Result<List<VerifyCourseInfoDTO>> getCourseInfo(@Schema(description = "课程ID") @PathVariable("courseId") String courseId) {
+    public Result<List<CoursesPriceRulesVO>> getCourseInfo(@Schema(description = "课程ID") @PathVariable("courseId") String courseId) {
         return Result.OK(appCoureseService.getCourseInfo(courseId));
     }
 

+ 6 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/vo/CoursesPriceRulesVO.java

@@ -29,6 +29,12 @@ public class CoursesPriceRulesVO implements Serializable {
     @Schema(description = "是否今日")
     private Boolean orToday;
 
+    @Schema(description = "是否完成")
+    private Boolean orDone;
+
+    @Schema(description = "课程类型")
+    private Integer courseType;
+
     @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @Schema(description = "开始时间")

+ 0 - 24
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/vo/VerifyCourseInfoDTO.java

@@ -1,24 +0,0 @@
-package org.jeecg.modules.app.vo;
-
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-import java.io.Serializable;
-import java.util.List;
-
-@Data
-@Accessors(chain = true)
-@EqualsAndHashCode(callSuper = false)
-@Schema(description = "验课信息响应对象")
-public class VerifyCourseInfoDTO implements Serializable {
-    private static final long serialVersionUID = 1L;
-
-    @Schema(description = "课程类型")
-    private Integer courseType;
-
-    private List<CoursesPriceRulesVO> toDayVoList;
-
-    private List<CoursesPriceRulesVO> voList;
-}

+ 1 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppSitePlaceMapper.xml

@@ -15,7 +15,7 @@
 
     <select id="getPlaceInfoNoFixation" resultType="org.jeecg.modules.app.vo.PlaceInfoVO$PlaceInfoGymMsgVO">
         SELECT
-            a.id,
+            b.id,
             a.name,
             a.advance_time,
             MIN(b.original_price) AS original_price,

+ 2 - 2
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/IAppCoureseService.java

@@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.app.form.ClassPostponeForm;
 import org.jeecg.modules.app.vo.AppCoursesPageVO;
+import org.jeecg.modules.app.vo.CoursesPriceRulesVO;
 import org.jeecg.modules.app.vo.FamilyUserVO;
-import org.jeecg.modules.app.vo.VerifyCourseInfoDTO;
 import org.jeecg.modules.system.app.dto.AppCoursesDTO;
 import org.jeecg.modules.system.app.dto.AppCoursesInfoPageDTO;
 import org.jeecg.modules.system.app.dto.AppCoursesPageDTO;
@@ -51,7 +51,7 @@ public interface IAppCoureseService extends IService<AppCourses> {
 
     List<AppSiteAddressDTO> queryAddressList();
 
-    List<VerifyCourseInfoDTO> getCourseInfo(String courseId);
+    List<CoursesPriceRulesVO> getCourseInfo(String courseId);
 
     Boolean temporaryCourse(String coursePriceRulesId, String userId);
 

+ 1 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/IAppGameService.java

@@ -40,4 +40,5 @@ public interface IAppGameService extends IService<AppGame> {
 
     IPage<AppGameDTO> queryWitchPriceRulesPage(AppGamePageDTO dto);
 
+
 }

+ 12 - 11
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppCoureseServiceImpl.java

@@ -261,18 +261,15 @@ public class AppCoureseServiceImpl extends ServiceImpl<AppCoursesMapper, AppCour
     }
 
     @Override
-    public List<VerifyCourseInfoDTO> getCourseInfo(String courseId) {
+    public List<CoursesPriceRulesVO> getCourseInfo(String courseId) {
 
-        List<VerifyCourseInfoDTO> verifyCourseInfoDTOList = new ArrayList<>();
+        List<CoursesPriceRulesVO> verifyCourseInfoDTOList = new ArrayList<>();
 
         List<AppCoursesPriceRules> priceRulesList = priceRulesMapper.selectList(Wrappers.lambdaQuery(AppCoursesPriceRules.class).eq(AppCoursesPriceRules::getCoursesId, courseId));
 
         Map<Integer, List<AppCoursesPriceRules>> map = priceRulesList.stream().collect(Collectors.groupingBy(AppCoursesPriceRules::getCoursesType));
 
         map.keySet().forEach(key -> {
-            VerifyCourseInfoDTO  verifyCourseInfoDTO = new VerifyCourseInfoDTO();
-            List<CoursesPriceRulesVO> toDayVoList = new ArrayList<>();
-            List<CoursesPriceRulesVO> voList = new ArrayList<>();
             map.get(key).forEach(priceRules -> {
                 CoursesPriceRulesVO coursesPriceRulesVO = new CoursesPriceRulesVO();
                 coursesPriceRulesVO.setId(priceRules.getId());
@@ -301,16 +298,20 @@ public class AppCoureseServiceImpl extends ServiceImpl<AppCoursesMapper, AppCour
                 LocalDate localDate = priceRules.getStartTime().toInstant()
                         .atZone(ZoneId.systemDefault())
                         .toLocalDate();
+                if (coursesPriceRulesVO.getEndTime().after(new Date())) {
+                    coursesPriceRulesVO.setOrDone(false);
+                }else {
+                    coursesPriceRulesVO.setOrDone(true);
+                }
                 if (today.isAfter(localDate)) {
-                    toDayVoList.add(coursesPriceRulesVO);
+                    coursesPriceRulesVO.setOrToday(true);
                 } else {
-                    voList.add(coursesPriceRulesVO);
+                    coursesPriceRulesVO.setOrToday(false);
                 }
+                coursesPriceRulesVO.setCourseType(key);
+                verifyCourseInfoDTOList.add(coursesPriceRulesVO);
             });
-            verifyCourseInfoDTO.setCourseType(key);
-            verifyCourseInfoDTO.setToDayVoList(toDayVoList);
-            verifyCourseInfoDTO.setVoList(voList);
-            verifyCourseInfoDTOList.add(verifyCourseInfoDTO);
+
         });
 
         return verifyCourseInfoDTOList;