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 + + + + + + + +