Jelajahi Sumber

refactor(national-motion-module-system): 重构课程相关代码并添加新功能

- 修改 CourseVO 类名拼写错误,统一命名风格- 新增 CourseInfoVO 类,用于课程详情展示
- 更新相关服务和接口,适应新的 VO 类
- 添加计算两点间距离的工具类 PositionUtil
- 更新 .gitignore 文件,忽略 .git目录
SheepHy 2 minggu lalu
induk
melakukan
d64d9516c2

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

@@ -11,4 +11,13 @@ public interface IDetailService {
      * @return PlaceInfoVO {@link PlaceInfoVO}
      **/
     PlaceInfoVO getPlaceInfo(String id);
+    
+    /** 
+     * @Author SheepHy
+     * @Description 课程详情
+     * @Date 13:36 2025/7/8
+     * @Param 
+     * @return 
+     **/
+
 }

+ 4 - 4
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/AppHomeServiceImpl.java

@@ -62,7 +62,7 @@ public class AppHomeServiceImpl implements IAppHomeService {
                 .eq(AppCourses::getPriceType, 1).last("LIMIT 3"));
 
         // 合并课程信息
-        List<CoureseVO> courseVO = new ArrayList<>();
+        List<CourseVO> courseVO = new ArrayList<>();
         courseVO.addAll(convertToCoureseVOList(appCoursesFine));
         courseVO.addAll(convertToCoureseVOList(appCoursesFree));
 
@@ -131,11 +131,11 @@ public class AppHomeServiceImpl implements IAppHomeService {
      * @Description 合并课程信息
      * @Date 9:14 2025/7/4
      * @Param appCoureseList {@link List<AppCourses>}
-     * @return List<CoureseVO> {@link List<CoureseVO>}
+     * @return List<CoureseVO> {@link List< CourseVO >}
      **/
-    private List<CoureseVO> convertToCoureseVOList(List<AppCourses> appCoureseList) {
+    private List<CourseVO> convertToCoureseVOList(List<AppCourses> appCoureseList) {
         return appCoureseList.stream()
-                .map(courses -> new CoureseVO()
+                .map(courses -> new CourseVO()
                         .setId(courses.getId()).setCover(courses.getCover())
                         .setPriceType(courses.getPriceType())
                         .setSellingPrice(courses.getSellingPrice()))

+ 4 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/DetailServiceImpl.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.app.service.impl;
 
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import lombok.extern.log4j.Log4j2;
 import org.jeecg.modules.app.service.IDetailService;
 import org.jeecg.modules.app.vo.PlaceInfoVO;
 import org.jeecg.modules.system.app.entity.AppInstructor;
@@ -9,11 +10,13 @@ import org.jeecg.modules.system.app.entity.AppSite;
 import org.jeecg.modules.system.app.entity.AppSitePriceRules;
 import org.jeecg.modules.system.app.mapper.*;
 import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
-
+@Service
+@Log4j2
 public class DetailServiceImpl implements IDetailService {
     @Resource
     private AppSiteMapper appSiteMapper;

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

@@ -0,0 +1,43 @@
+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.math.BigDecimal;
+import java.util.Date;
+
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@Schema(description="课程详情返回VO")
+public class CourseInfoVO {
+    @Schema(description = "id")
+    private String id;
+    @Schema(description = "产品名称")
+    private String name;
+    @Schema(description = "费用类型;0 精品 1免费 仅课程")
+    private Integer priceType;
+    @Schema(description = "原价")
+    private BigDecimal originalPrice;
+    @Schema(description = "售价")
+    private BigDecimal sellingPrice;
+    @Schema(description = "封面")
+    private String cover;
+    @Schema(description = "视频")
+    private String video;
+    @Schema(description = "上课场地")
+    private String siteId;
+    @Schema(description = "KM")
+    private String km;
+    @Schema(description = "年销售")
+    private Integer sales;
+    @Schema(description = "开始时间")
+    private Date startTime;
+    @Schema(description = "结束时间")
+    private Date endTime;
+    @Schema(description = "课时")
+    private Integer classHour;
+
+}

+ 1 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/vo/CoureseVO.java → national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/vo/CourseVO.java

@@ -11,7 +11,7 @@ import java.math.BigDecimal;
 @Accessors(chain = true)
 @EqualsAndHashCode(callSuper = false)
 @Schema(description="产品信息返回VO")
-public class CoureseVO {
+public class CourseVO {
     @Schema(description = "主键id")
     private String id;
     @Schema(description = "封面")

+ 1 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/vo/HomeVO.java

@@ -17,6 +17,6 @@ public class HomeVO {
     @Schema(description = "教练列表")
     private List<InstructorVO> instructorList;
     @Schema(description = "课程列表")
-    private List<CoureseVO> courseList;
+    private List<CourseVO> courseList;
 
 }

+ 29 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/util/PositionUtil.java

@@ -0,0 +1,29 @@
+package org.jeecg.modules.system.util;
+
+public class PositionUtil {
+    /**
+     * 使用 Haversine 公式计算两点之间的直线距离
+     *
+     * @param lat1 第一个点的纬度(单位:度)
+     * @param lon1 第一个点的经度(单位:度)
+     * @param lat2 第二个点的纬度(单位:度)
+     * @param lon2 第二个点的经度(单位:度)
+     * @return 两点之间的直线距离(单位:公里)
+     */
+    public static double calculateDistance(double lat1, double lon1, double lat2, double lon2) {
+        final int EARTH_RADIUS_KM = 6371; // 地球平均半径,单位:公里
+        // 将角度转换为弧度
+        double lat1Rad = Math.toRadians(lat1);
+        double lat2Rad = Math.toRadians(lat2);
+        double deltaLat = Math.toRadians(lat2 - lat1);
+        double deltaLon = Math.toRadians(lon2 - lon1);
+        // Haversine 公式
+        double a = Math.pow(Math.sin(deltaLat / 2), 2)
+                + Math.cos(lat1Rad) * Math.cos(lat2Rad)
+                * Math.pow(Math.sin(deltaLon / 2), 2);
+        double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
+        // 计算距离并保留一位小数
+        double distance = EARTH_RADIUS_KM * c;
+        return Math.round(distance * 10) / 10.0; // 四舍五入保留一位小数
+    }
+}