课程中心相关接口
This commit is contained in:
31
src/main/java/com/bicloud/controller/CourseController.java
Normal file
31
src/main/java/com/bicloud/controller/CourseController.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.bicloud.controller;
|
||||
|
||||
import com.bicloud.common.result.Result;
|
||||
import com.bicloud.pojo.vo.CourseCatVo;
|
||||
import com.bicloud.service.CourseService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CrossOrigin //跨域
|
||||
@RestController
|
||||
@RequestMapping("/course")
|
||||
@Tag(name = "课程中心", description = "课程中心相关接口")
|
||||
@Slf4j
|
||||
public class CourseController {
|
||||
private final CourseService courseService;
|
||||
|
||||
public CourseController(CourseService courseService) {
|
||||
this.courseService = courseService;
|
||||
}
|
||||
|
||||
// 获取课程分类列表
|
||||
@GetMapping("/cats")
|
||||
public Result<List<CourseCatVo>> listCourseCats() {
|
||||
List<CourseCatVo> cats = courseService.listCourseCats();
|
||||
return Result.success(cats);
|
||||
}
|
||||
|
||||
}
|
||||
13
src/main/java/com/bicloud/mapper/CourseMapper.java
Normal file
13
src/main/java/com/bicloud/mapper/CourseMapper.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.bicloud.mapper;
|
||||
|
||||
import com.bicloud.pojo.vo.CourseCatVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface CourseMapper {
|
||||
|
||||
// 课程分类列表
|
||||
List<CourseCatVo> listCourseCats();
|
||||
}
|
||||
11
src/main/java/com/bicloud/pojo/vo/CourseCatVo.java
Normal file
11
src/main/java/com/bicloud/pojo/vo/CourseCatVo.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.bicloud.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CourseCatVo {
|
||||
//分类id
|
||||
private Integer id;
|
||||
//分类名称
|
||||
private String catName;
|
||||
}
|
||||
11
src/main/java/com/bicloud/service/CourseService.java
Normal file
11
src/main/java/com/bicloud/service/CourseService.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.bicloud.service;
|
||||
|
||||
import com.bicloud.pojo.vo.CourseCatVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CourseService {
|
||||
|
||||
// 获取课程分类列表
|
||||
List<CourseCatVo> listCourseCats();
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.bicloud.service.impl;
|
||||
|
||||
import com.bicloud.mapper.CourseMapper;
|
||||
import com.bicloud.pojo.vo.CourseCatVo;
|
||||
import com.bicloud.service.CourseService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CourseServiceImpl implements CourseService {
|
||||
|
||||
private final CourseMapper courseMapper;
|
||||
|
||||
public CourseServiceImpl(CourseMapper courseMapper) {
|
||||
this.courseMapper = courseMapper;
|
||||
}
|
||||
|
||||
// 获取课程分类列表
|
||||
@Override
|
||||
public List<CourseCatVo> listCourseCats() {
|
||||
return courseMapper.listCourseCats();
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,12 @@ server:
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
url: jdbc:mysql://192.168.1.102:3308/genome1_db?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
||||
username: app_user
|
||||
password: "NewSecurePassword123"
|
||||
# url: jdbc:mysql://192.168.1.102:3308/genome1_db?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
||||
# username: app_user
|
||||
# password: "NewSecurePassword123"
|
||||
url: jdbc:mysql://192.168.1.102:3310/biology?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
||||
username: bicloud
|
||||
password: "Admin_Complex_Pass2024!"
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
hikari:
|
||||
connection-timeout: 30000
|
||||
|
||||
17
src/main/resources/mapper/CourseMapper.xml
Normal file
17
src/main/resources/mapper/CourseMapper.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.bicloud.mapper.CourseMapper">
|
||||
|
||||
<!-- 课程分类列表 -->
|
||||
<select id="listCourseCats" resultType="com.bicloud.pojo.vo.CourseCatVo">
|
||||
SELECT
|
||||
id,
|
||||
cat_name AS catName
|
||||
FROM biology_course_cats
|
||||
ORDER BY position ASC, id ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user