【新增】教程

This commit is contained in:
2025-10-28 13:50:07 +08:00
parent ed2b7bfba6
commit 0df7f645a6
7 changed files with 264 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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<Course> {
Page<Course> pageList(Page<Course> page, @Param("categoryId") int categoryId, @Param("courseTitle") String courseTitle);
}

View File

@@ -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<Course> {
IPage<Course> pageList(Page<Course> page, int categoryId, String courseTitle);
}

View File

@@ -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<CourseMapper, Course> implements CourseService {
private final CourseMapper courseMapper;
public CourseServiceImpl(CourseMapper courseMapper) {
this.courseMapper = courseMapper;
}
@Override
public IPage<Course> pageList(Page<Course> page, int categoryId, String courseTitle) {
return courseMapper.pageList(page, categoryId, courseTitle);
}
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -0,0 +1,45 @@
<?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.corewing.app.mapper.CourseMapper">
<!-- 结果映射 -->
<resultMap id="VOResultMap" type="com.corewing.app.vo.CourseVO">
<id column="id" property="id"/>
<result column="course_title" property="courseTitle"/>
<result column="description" property="description"/>
<result column="content" property="content"/>
<result column="view_count" property="viewCount"/>
<result column="recommend_status" property="recommendStatus"/>
<result column="status" property="status"/>
<result column="category_title" property="categoryTitle"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<!-- 基础查询SQL片段 -->
<sql id="selectVOSql">
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
</sql>
<!-- 分页查询 -->
<select id="pageList" resultMap="VOResultMap">
<include refid="selectVOSql"/>
<where>
c.status = 1
<if test="categoryId != null and categoryId != 0">
AND cc.id = #{categoryId}
</if>
<if test="courseTitle != null and courseTitle != ''">
AND c.course_title like CONCAT('%', #{courseTitle}, '%')
</if>
</where>
ORDER BY c.recommend_status,c.create_time asc
</select>
</mapper>