From 0df7f645a6ed7c0e4440d954648f397a22cc9f08 Mon Sep 17 00:00:00 2001 From: MichaelWin Date: Tue, 28 Oct 2025 13:50:07 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91?= =?UTF-8?q?=E6=95=99=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/corewing/app/entity/Course.java | 67 +++++++++++++++++++ .../com/corewing/app/mapper/CourseMapper.java | 17 +++++ .../corewing/app/service/CourseService.java | 10 +++ .../app/service/impl/CourseServiceImpl.java | 24 +++++++ .../java/com/corewing/app/vo/CourseVO.java | 57 ++++++++++++++++ src/main/resources/db/app_course.sql | 44 ++++++++++++ src/main/resources/mapper/CourseMapper.xml | 45 +++++++++++++ 7 files changed, 264 insertions(+) create mode 100644 src/main/java/com/corewing/app/entity/Course.java create mode 100644 src/main/java/com/corewing/app/mapper/CourseMapper.java create mode 100644 src/main/java/com/corewing/app/service/CourseService.java create mode 100644 src/main/java/com/corewing/app/service/impl/CourseServiceImpl.java create mode 100644 src/main/java/com/corewing/app/vo/CourseVO.java create mode 100644 src/main/resources/db/app_course.sql create mode 100644 src/main/resources/mapper/CourseMapper.xml diff --git a/src/main/java/com/corewing/app/entity/Course.java b/src/main/java/com/corewing/app/entity/Course.java new file mode 100644 index 0000000..63b0d4a --- /dev/null +++ b/src/main/java/com/corewing/app/entity/Course.java @@ -0,0 +1,67 @@ +package com.corewing.app.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 教程 + */ +@Data +@TableName("app_course") +public class Course implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 教程id + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 教程标题 + */ + private String courseTitle; + + /** + * 教程描述 + */ + private String description; + + /** + * 教程详情 + */ + private String content; + + /** + * 查看次数 + */ + private Integer viewCount; + + /** + * 推荐状态:0不推荐,1推荐 + */ + private Integer recommendStatus; + + /** + * 状态:1正常,2关闭 + */ + private Integer status; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + +} diff --git a/src/main/java/com/corewing/app/mapper/CourseMapper.java b/src/main/java/com/corewing/app/mapper/CourseMapper.java new file mode 100644 index 0000000..61e8981 --- /dev/null +++ b/src/main/java/com/corewing/app/mapper/CourseMapper.java @@ -0,0 +1,17 @@ +package com.corewing.app.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.corewing.app.entity.Course; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 教程 Mapper 接口 + */ + +@Mapper +public interface CourseMapper extends BaseMapper { + + Page pageList(Page page, @Param("categoryId") int categoryId, @Param("courseTitle") String courseTitle); +} diff --git a/src/main/java/com/corewing/app/service/CourseService.java b/src/main/java/com/corewing/app/service/CourseService.java new file mode 100644 index 0000000..78caaa1 --- /dev/null +++ b/src/main/java/com/corewing/app/service/CourseService.java @@ -0,0 +1,10 @@ +package com.corewing.app.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.corewing.app.entity.Course; + +public interface CourseService extends IService { + IPage pageList(Page page, int categoryId, String courseTitle); +} diff --git a/src/main/java/com/corewing/app/service/impl/CourseServiceImpl.java b/src/main/java/com/corewing/app/service/impl/CourseServiceImpl.java new file mode 100644 index 0000000..be96b8b --- /dev/null +++ b/src/main/java/com/corewing/app/service/impl/CourseServiceImpl.java @@ -0,0 +1,24 @@ +package com.corewing.app.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.corewing.app.entity.Course; +import com.corewing.app.mapper.CourseMapper; +import com.corewing.app.service.CourseService; +import org.springframework.stereotype.Service; + +@Service +public class CourseServiceImpl extends ServiceImpl implements CourseService { + + private final CourseMapper courseMapper; + + public CourseServiceImpl(CourseMapper courseMapper) { + this.courseMapper = courseMapper; + } + + @Override + public IPage pageList(Page page, int categoryId, String courseTitle) { + return courseMapper.pageList(page, categoryId, courseTitle); + } +} diff --git a/src/main/java/com/corewing/app/vo/CourseVO.java b/src/main/java/com/corewing/app/vo/CourseVO.java new file mode 100644 index 0000000..dd2c7db --- /dev/null +++ b/src/main/java/com/corewing/app/vo/CourseVO.java @@ -0,0 +1,57 @@ +package com.corewing.app.vo; + +import lombok.Data; + +import java.util.Date; + +@Data +public class CourseVO { + + private Long id; + + /** + * 教程标题 + */ + private String courseTitle; + + /** + * 教程描述 + */ + private String description; + + /** + * 教程详情 + */ + private String content; + + /** + * 查看次数 + */ + private Integer viewCount; + + /** + * 推荐状态:0不推荐,1推荐 + */ + private Integer recommendStatus; + + /** + * 状态:1正常,2关闭 + */ + private Integer status; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 教程分类名称 + */ + private String categoryTitle; + +} diff --git a/src/main/resources/db/app_course.sql b/src/main/resources/db/app_course.sql new file mode 100644 index 0000000..cd4782f --- /dev/null +++ b/src/main/resources/db/app_course.sql @@ -0,0 +1,44 @@ +/* + Navicat Premium Dump SQL + + Source Server : 120.24.204.180 + Source Server Type : MySQL + Source Server Version : 80036 (8.0.36) + Source Host : 120.24.204.180:3306 + Source Schema : app + + Target Server Type : MySQL + Target Server Version : 80036 (8.0.36) + File Encoding : 65001 + + Date: 28/10/2025 13:46:26 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for app_course +-- ---------------------------- +DROP TABLE IF EXISTS `app_course`; +CREATE TABLE `app_course` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id', + `course_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '教程标题', + `description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '教程描述', + `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '教程详情', + `view_count` int DEFAULT '0' COMMENT '查看次数', + `recommend_status` int DEFAULT '0' COMMENT '推荐状态:0不推荐,1推荐', + `status` tinyint(1) DEFAULT '1' COMMENT '状态:1正常,2关闭', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='使用教程表'; + +-- ---------------------------- +-- Records of app_course +-- ---------------------------- +BEGIN; +INSERT INTO `app_course` (`id`, `course_title`, `description`, `content`, `view_count`, `recommend_status`, `status`, `create_time`, `update_time`) VALUES (1, '快速开始指南', '了解酷翼应用的基本功能与布局,快速上手使用各项功能。', NULL, 0, 0, 1, '2025-10-28 12:03:52', NULL); +COMMIT; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/src/main/resources/mapper/CourseMapper.xml b/src/main/resources/mapper/CourseMapper.xml new file mode 100644 index 0000000..27daeb4 --- /dev/null +++ b/src/main/resources/mapper/CourseMapper.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + select c.*, cc.category_title + from app_course c + left join app_course_category_relation ccr on c.id = ccr.course_id + left join app_course_category cc on cc.id = ccr.category_id + + + + + + + + From 4c66e875cfe8ee3c4763f7b55a49a89f0657e38f Mon Sep 17 00:00:00 2001 From: MichaelWin Date: Tue, 28 Oct 2025 13:50:41 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91?= =?UTF-8?q?=E6=95=99=E7=A8=8B=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../corewing/app/entity/CourseCategory.java | 64 +++++++++++++++++++ .../app/entity/CourseCategoryRelation.java | 32 ++++++++++ .../app/service/CourseCategoryService.java | 7 ++ .../impl/CourseCategoryServiceImpl.java | 11 ++++ src/main/resources/db/app_course_category.sql | 44 +++++++++++++ 5 files changed, 158 insertions(+) create mode 100644 src/main/java/com/corewing/app/entity/CourseCategory.java create mode 100644 src/main/java/com/corewing/app/entity/CourseCategoryRelation.java create mode 100644 src/main/java/com/corewing/app/service/CourseCategoryService.java create mode 100644 src/main/java/com/corewing/app/service/impl/CourseCategoryServiceImpl.java create mode 100644 src/main/resources/db/app_course_category.sql diff --git a/src/main/java/com/corewing/app/entity/CourseCategory.java b/src/main/java/com/corewing/app/entity/CourseCategory.java new file mode 100644 index 0000000..182c93a --- /dev/null +++ b/src/main/java/com/corewing/app/entity/CourseCategory.java @@ -0,0 +1,64 @@ +package com.corewing.app.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 教程分类 + */ +@Data +@TableName("app_course_category") +public class CourseCategory implements Serializable { + + /** + * 分类id + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 图标 + */ + private String icon; + + /** + * 分类名称 + */ + private String categoryTitle; + + /** + * 分类描述 + */ + private String description; + + /** + * 类别:category分类,tag标签 + */ + private String type; + + /** + * 置首页:0不置首,1置首页 + */ + private Integer firstStatus; + + /** + * 状态:1正常,2关闭 + */ + private Integer status; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + +} diff --git a/src/main/java/com/corewing/app/entity/CourseCategoryRelation.java b/src/main/java/com/corewing/app/entity/CourseCategoryRelation.java new file mode 100644 index 0000000..dad1658 --- /dev/null +++ b/src/main/java/com/corewing/app/entity/CourseCategoryRelation.java @@ -0,0 +1,32 @@ +package com.corewing.app.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 教程与分类关系实体 + */ +@Data +@TableName("app_course_category_relation") +public class CourseCategoryRelation implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * id + */ + private Long id; + + /** + * 教程id + */ + private Long CourseId; + + /** + * 教程分类id + */ + private Long CategoryId; + +} diff --git a/src/main/java/com/corewing/app/service/CourseCategoryService.java b/src/main/java/com/corewing/app/service/CourseCategoryService.java new file mode 100644 index 0000000..16042c4 --- /dev/null +++ b/src/main/java/com/corewing/app/service/CourseCategoryService.java @@ -0,0 +1,7 @@ +package com.corewing.app.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.corewing.app.entity.CourseCategory; + +public interface CourseCategoryService extends IService { +} diff --git a/src/main/java/com/corewing/app/service/impl/CourseCategoryServiceImpl.java b/src/main/java/com/corewing/app/service/impl/CourseCategoryServiceImpl.java new file mode 100644 index 0000000..a061047 --- /dev/null +++ b/src/main/java/com/corewing/app/service/impl/CourseCategoryServiceImpl.java @@ -0,0 +1,11 @@ +package com.corewing.app.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.corewing.app.entity.CourseCategory; +import com.corewing.app.mapper.CourseCategoryMapper; +import com.corewing.app.service.CourseCategoryService; +import org.springframework.stereotype.Service; + +@Service +public class CourseCategoryServiceImpl extends ServiceImpl implements CourseCategoryService { +} diff --git a/src/main/resources/db/app_course_category.sql b/src/main/resources/db/app_course_category.sql new file mode 100644 index 0000000..3d12be6 --- /dev/null +++ b/src/main/resources/db/app_course_category.sql @@ -0,0 +1,44 @@ +/* + Navicat Premium Dump SQL + + Source Server : 120.24.204.180 + Source Server Type : MySQL + Source Server Version : 80036 (8.0.36) + Source Host : 120.24.204.180:3306 + Source Schema : app + + Target Server Type : MySQL + Target Server Version : 80036 (8.0.36) + File Encoding : 65001 + + Date: 28/10/2025 13:46:32 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for app_course_category +-- ---------------------------- +DROP TABLE IF EXISTS `app_course_category`; +CREATE TABLE `app_course_category` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id', + `icon` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '图标', + `category_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '分类名称', + `description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '分类描述', + `first_status` int NOT NULL DEFAULT '2' COMMENT '置首页:1置首,2不置首', + `type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '类别:category分类,tag标签', + `status` tinyint(1) DEFAULT '0' COMMENT '状态:1正常,2关闭', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='使用教程分类/标签表'; + +-- ---------------------------- +-- Records of app_course_category +-- ---------------------------- +BEGIN; +INSERT INTO `app_course_category` (`id`, `icon`, `category_title`, `description`, `first_status`, `type`, `status`, `create_time`, `update_time`) VALUES (1, NULL, '快速指南', NULL, 1, 'category', 1, '2025-10-28 12:06:03', NULL); +COMMIT; + +SET FOREIGN_KEY_CHECKS = 1; From 816396d9c05eeca05291159cb550904f7667c0f6 Mon Sep 17 00:00:00 2001 From: MichaelWin Date: Tue, 28 Oct 2025 13:51:04 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91?= =?UTF-8?q?=E6=95=99=E7=A8=8B=E4=B8=8E=E5=88=86=E7=B1=BB=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/mapper/CourseCategoryMapper.java | 12 ++++++ .../mapper/CourseCategoryRelationMapper.java | 13 +++++++ .../CourseCategoryRelationService.java | 7 ++++ .../CourseCategoryRelationServiceImpl.java | 11 ++++++ .../db/app_course_category_relation.sql | 38 +++++++++++++++++++ 5 files changed, 81 insertions(+) create mode 100644 src/main/java/com/corewing/app/mapper/CourseCategoryMapper.java create mode 100644 src/main/java/com/corewing/app/mapper/CourseCategoryRelationMapper.java create mode 100644 src/main/java/com/corewing/app/service/CourseCategoryRelationService.java create mode 100644 src/main/java/com/corewing/app/service/impl/CourseCategoryRelationServiceImpl.java create mode 100644 src/main/resources/db/app_course_category_relation.sql diff --git a/src/main/java/com/corewing/app/mapper/CourseCategoryMapper.java b/src/main/java/com/corewing/app/mapper/CourseCategoryMapper.java new file mode 100644 index 0000000..c790d4e --- /dev/null +++ b/src/main/java/com/corewing/app/mapper/CourseCategoryMapper.java @@ -0,0 +1,12 @@ +package com.corewing.app.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.corewing.app.entity.CourseCategory; +import org.apache.ibatis.annotations.Mapper; + +/** + * 教程分类 Mapper接口 + */ +@Mapper +public interface CourseCategoryMapper extends BaseMapper { +} diff --git a/src/main/java/com/corewing/app/mapper/CourseCategoryRelationMapper.java b/src/main/java/com/corewing/app/mapper/CourseCategoryRelationMapper.java new file mode 100644 index 0000000..f31211e --- /dev/null +++ b/src/main/java/com/corewing/app/mapper/CourseCategoryRelationMapper.java @@ -0,0 +1,13 @@ +package com.corewing.app.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.corewing.app.entity.CourseCategoryRelation; +import org.apache.ibatis.annotations.Mapper; + + +/** + * 教程与教程分类关系Mapper接口 + */ +@Mapper +public interface CourseCategoryRelationMapper extends BaseMapper { +} diff --git a/src/main/java/com/corewing/app/service/CourseCategoryRelationService.java b/src/main/java/com/corewing/app/service/CourseCategoryRelationService.java new file mode 100644 index 0000000..ffad240 --- /dev/null +++ b/src/main/java/com/corewing/app/service/CourseCategoryRelationService.java @@ -0,0 +1,7 @@ +package com.corewing.app.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.corewing.app.entity.CourseCategoryRelation; + +public interface CourseCategoryRelationService extends IService { +} diff --git a/src/main/java/com/corewing/app/service/impl/CourseCategoryRelationServiceImpl.java b/src/main/java/com/corewing/app/service/impl/CourseCategoryRelationServiceImpl.java new file mode 100644 index 0000000..b98372e --- /dev/null +++ b/src/main/java/com/corewing/app/service/impl/CourseCategoryRelationServiceImpl.java @@ -0,0 +1,11 @@ +package com.corewing.app.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.corewing.app.entity.CourseCategoryRelation; +import com.corewing.app.mapper.CourseCategoryRelationMapper; +import com.corewing.app.service.CourseCategoryRelationService; +import org.springframework.stereotype.Service; + +@Service +public class CourseCategoryRelationServiceImpl extends ServiceImpl implements CourseCategoryRelationService { +} diff --git a/src/main/resources/db/app_course_category_relation.sql b/src/main/resources/db/app_course_category_relation.sql new file mode 100644 index 0000000..7952eca --- /dev/null +++ b/src/main/resources/db/app_course_category_relation.sql @@ -0,0 +1,38 @@ +/* + Navicat Premium Dump SQL + + Source Server : 120.24.204.180 + Source Server Type : MySQL + Source Server Version : 80036 (8.0.36) + Source Host : 120.24.204.180:3306 + Source Schema : app + + Target Server Type : MySQL + Target Server Version : 80036 (8.0.36) + File Encoding : 65001 + + Date: 28/10/2025 13:46:38 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for app_course_category_relation +-- ---------------------------- +DROP TABLE IF EXISTS `app_course_category_relation`; +CREATE TABLE `app_course_category_relation` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id', + `course_id` bigint DEFAULT NULL COMMENT '教程id', + `category_id` bigint DEFAULT NULL COMMENT '教程分类id', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='教程与教程分类关系表'; + +-- ---------------------------- +-- Records of app_course_category_relation +-- ---------------------------- +BEGIN; +INSERT INTO `app_course_category_relation` (`id`, `course_id`, `category_id`) VALUES (1, 1, 1); +COMMIT; + +SET FOREIGN_KEY_CHECKS = 1; From c18366836f7acff72d29727c656a4a05e2267356 Mon Sep 17 00:00:00 2001 From: MichaelWin Date: Tue, 28 Oct 2025 13:51:19 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91?= =?UTF-8?q?=E6=95=99=E7=A8=8B=E6=8E=A5=E5=8F=A3=E6=8E=A7=E5=88=B6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/controller/CourseController.java | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/main/java/com/corewing/app/controller/CourseController.java diff --git a/src/main/java/com/corewing/app/controller/CourseController.java b/src/main/java/com/corewing/app/controller/CourseController.java new file mode 100644 index 0000000..ea10563 --- /dev/null +++ b/src/main/java/com/corewing/app/controller/CourseController.java @@ -0,0 +1,74 @@ +package com.corewing.app.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.corewing.app.common.Result; +import com.corewing.app.entity.Course; +import com.corewing.app.entity.CourseCategory; +import com.corewing.app.service.CourseCategoryService; +import com.corewing.app.service.CourseService; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * 教程接口 + */ +@RequestMapping("/course") +@RestController +public class CourseController { + + private final CourseService courseService; + private final CourseCategoryService courseCategoryService; + + public CourseController(CourseService courseService, CourseCategoryService courseCategoryService) { + this.courseService = courseService; + this.courseCategoryService = courseCategoryService; + } + + /** + * 分类查询列表 + * + * @param firstStatus 置首状态(选填) + * + */ + @GetMapping("/category") + public Result> category( + @RequestParam(required = false, defaultValue = "0") Integer firstStatus + ) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(firstStatus != 0, CourseCategory::getFirstStatus, firstStatus); + List list = courseCategoryService.list(wrapper); + return Result.success(list); + } + + /** + * 分页查询教程列表 + * + * @param current 当前页码 + * @param size 每页数量 + * @param categoryId 分类ID(选填) + * @param courseTitle 教程标题(选填) + * + */ + @GetMapping("/page") + public Result> getPageList( + @RequestParam(defaultValue = "1") Long current, + @RequestParam(defaultValue = "10") Long size, + @RequestParam(required = false, defaultValue = "0") Integer categoryId, + @RequestParam(required = false) String courseTitle) { + try { + Page page = new Page<>(current, size); + IPage pageResult = courseService.pageList(page, categoryId, courseTitle); + return Result.success(pageResult); + } catch (Exception e) { + return Result.error(e.getMessage()); + } + } + + +} From e264cb15b9f9b7fba749edc6d81b48ebe6748611 Mon Sep 17 00:00:00 2001 From: MichaelWin Date: Tue, 28 Oct 2025 13:51:49 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91?= =?UTF-8?q?=E6=8E=92=E9=99=A4=E6=95=99=E7=A8=8B=E6=8E=A5=E5=8F=A3=E6=9C=AA?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=8B=A6=E6=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/corewing/app/config/SaTokenConfig.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/corewing/app/config/SaTokenConfig.java b/src/main/java/com/corewing/app/config/SaTokenConfig.java index ac5df33..f936ae9 100644 --- a/src/main/java/com/corewing/app/config/SaTokenConfig.java +++ b/src/main/java/com/corewing/app/config/SaTokenConfig.java @@ -27,6 +27,8 @@ public class SaTokenConfig implements WebMvcConfigurer { .excludePathPatterns("/sys/user/login") // 排除反馈接口(支持匿名提交) .excludePathPatterns("/feedback", "/feedback/**") + // 排除教程接口(支持匿名查询) + .excludePathPatterns("/course", "/course/**") // 排除固件查询接口(不需要登录) .excludePathPatterns("/firmware/**") // 排除静态资源 From 577b37b768c28421fcdef3a19d7741d3a4d6e446 Mon Sep 17 00:00:00 2001 From: MichaelWin Date: Tue, 28 Oct 2025 14:40:22 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=9B=BD=E9=99=85=E5=8C=96=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/corewing/app/controller/CourseController.java | 7 ++++++- src/main/java/com/corewing/app/entity/Course.java | 5 +++++ src/main/java/com/corewing/app/entity/CourseCategory.java | 5 +++++ src/main/java/com/corewing/app/mapper/CourseMapper.java | 2 +- src/main/java/com/corewing/app/service/CourseService.java | 2 +- .../com/corewing/app/service/impl/CourseServiceImpl.java | 4 ++-- src/main/resources/mapper/CourseMapper.xml | 3 +-- 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/corewing/app/controller/CourseController.java b/src/main/java/com/corewing/app/controller/CourseController.java index ea10563..a4d3daf 100644 --- a/src/main/java/com/corewing/app/controller/CourseController.java +++ b/src/main/java/com/corewing/app/controller/CourseController.java @@ -8,6 +8,8 @@ import com.corewing.app.entity.Course; import com.corewing.app.entity.CourseCategory; import com.corewing.app.service.CourseCategoryService; import com.corewing.app.service.CourseService; +import com.corewing.app.util.I18nUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -20,6 +22,7 @@ import java.util.List; */ @RequestMapping("/course") @RestController +@Slf4j public class CourseController { private final CourseService courseService; @@ -40,8 +43,10 @@ public class CourseController { public Result> category( @RequestParam(required = false, defaultValue = "0") Integer firstStatus ) { + log.info("当前语言环境:{}", I18nUtil.getCurrentLocale().getLanguage()); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(firstStatus != 0, CourseCategory::getFirstStatus, firstStatus); + wrapper.eq(CourseCategory::getLang, I18nUtil.getCurrentLocale().getLanguage()); List list = courseCategoryService.list(wrapper); return Result.success(list); } @@ -63,7 +68,7 @@ public class CourseController { @RequestParam(required = false) String courseTitle) { try { Page page = new Page<>(current, size); - IPage pageResult = courseService.pageList(page, categoryId, courseTitle); + IPage pageResult = courseService.pageList(page, categoryId, courseTitle, I18nUtil.getCurrentLocale().getLanguage()); return Result.success(pageResult); } catch (Exception e) { return Result.error(e.getMessage()); diff --git a/src/main/java/com/corewing/app/entity/Course.java b/src/main/java/com/corewing/app/entity/Course.java index 63b0d4a..ee6fe51 100644 --- a/src/main/java/com/corewing/app/entity/Course.java +++ b/src/main/java/com/corewing/app/entity/Course.java @@ -53,6 +53,11 @@ public class Course implements Serializable { */ private Integer status; + /** + * 语言:中文zh,英文:en + */ + private String lang; + /** * 创建时间 */ diff --git a/src/main/java/com/corewing/app/entity/CourseCategory.java b/src/main/java/com/corewing/app/entity/CourseCategory.java index 182c93a..ee9af4e 100644 --- a/src/main/java/com/corewing/app/entity/CourseCategory.java +++ b/src/main/java/com/corewing/app/entity/CourseCategory.java @@ -51,6 +51,11 @@ public class CourseCategory implements Serializable { */ private Integer status; + /** + * 语言:中文zh,英文:en + */ + private String lang; + /** * 创建时间 */ diff --git a/src/main/java/com/corewing/app/mapper/CourseMapper.java b/src/main/java/com/corewing/app/mapper/CourseMapper.java index 61e8981..ead0a19 100644 --- a/src/main/java/com/corewing/app/mapper/CourseMapper.java +++ b/src/main/java/com/corewing/app/mapper/CourseMapper.java @@ -13,5 +13,5 @@ import org.apache.ibatis.annotations.Param; @Mapper public interface CourseMapper extends BaseMapper { - Page pageList(Page page, @Param("categoryId") int categoryId, @Param("courseTitle") String courseTitle); + Page pageList(Page page, @Param("categoryId") int categoryId, @Param("courseTitle") String courseTitle, @Param("lang") String lang); } diff --git a/src/main/java/com/corewing/app/service/CourseService.java b/src/main/java/com/corewing/app/service/CourseService.java index 78caaa1..e56052b 100644 --- a/src/main/java/com/corewing/app/service/CourseService.java +++ b/src/main/java/com/corewing/app/service/CourseService.java @@ -6,5 +6,5 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.corewing.app.entity.Course; public interface CourseService extends IService { - IPage pageList(Page page, int categoryId, String courseTitle); + IPage pageList(Page page, int categoryId, String courseTitle, String lang); } diff --git a/src/main/java/com/corewing/app/service/impl/CourseServiceImpl.java b/src/main/java/com/corewing/app/service/impl/CourseServiceImpl.java index be96b8b..902f6fe 100644 --- a/src/main/java/com/corewing/app/service/impl/CourseServiceImpl.java +++ b/src/main/java/com/corewing/app/service/impl/CourseServiceImpl.java @@ -18,7 +18,7 @@ public class CourseServiceImpl extends ServiceImpl impleme } @Override - public IPage pageList(Page page, int categoryId, String courseTitle) { - return courseMapper.pageList(page, categoryId, courseTitle); + public IPage pageList(Page page, int categoryId, String courseTitle, String lang) { + return courseMapper.pageList(page, categoryId, courseTitle, lang); } } diff --git a/src/main/resources/mapper/CourseMapper.xml b/src/main/resources/mapper/CourseMapper.xml index 27daeb4..5db8871 100644 --- a/src/main/resources/mapper/CourseMapper.xml +++ b/src/main/resources/mapper/CourseMapper.xml @@ -24,13 +24,12 @@ left join app_course_category cc on cc.id = ccr.category_id - -