增加课程资源接口
This commit is contained in:
@@ -13,8 +13,15 @@ public class CourseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private courseService courseService;
|
private courseService courseService;
|
||||||
|
|
||||||
|
// 返回课程信息
|
||||||
@GetMapping("getAll")
|
@GetMapping("getAll")
|
||||||
public ResultVo getAllCourses() {
|
public ResultVo getAllCourses() {
|
||||||
return ResultVo.Success("",courseService.getAllCourseInfo());
|
return ResultVo.Success("",courseService.getAllCourseInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//返回课程资源
|
||||||
|
@GetMapping("getResources")
|
||||||
|
public ResultVo getCourseResources() {
|
||||||
|
return ResultVo.Success("", courseService.getCourseResources());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.backend.webbackend.Service.Impl;
|
package com.backend.webbackend.Service.Impl;
|
||||||
|
|
||||||
import com.backend.webbackend.domain.Course;
|
import com.backend.webbackend.domain.Course;
|
||||||
|
import com.backend.webbackend.domain.TrainingResource;
|
||||||
import com.backend.webbackend.mapper.CourseMapper;
|
import com.backend.webbackend.mapper.CourseMapper;
|
||||||
|
import com.backend.webbackend.mapper.TrainingResourceMapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -9,15 +11,20 @@ import java.util.List;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class courseServiceImpl implements com.backend.webbackend.Service.courseService {
|
public class courseServiceImpl implements com.backend.webbackend.Service.courseService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
CourseMapper courseMapper;
|
CourseMapper courseMapper;
|
||||||
|
@Autowired
|
||||||
|
TrainingResourceMapper trainingResourceMapper;
|
||||||
|
|
||||||
|
// 返回课程信息
|
||||||
@Override
|
@Override
|
||||||
public List<Course> getAllCourseInfo() {
|
public List<Course> getAllCourseInfo() {
|
||||||
// List<Course> courses = courseMapper.selectAllCourses();
|
|
||||||
// String path = courses.get(0).getCourseIco().trim()+"/"+courses.get(0).getCourseName().trim();
|
|
||||||
// System.out.println("path:"+path);
|
|
||||||
return courseMapper.selectAllCourses();
|
return courseMapper.selectAllCourses();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//返回课程资源
|
||||||
|
@Override
|
||||||
|
public List<TrainingResource> getCourseResources(){
|
||||||
|
return trainingResourceMapper.getAllTraningResources();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.backend.webbackend.Service;
|
package com.backend.webbackend.Service;
|
||||||
|
|
||||||
import com.backend.webbackend.domain.Course;
|
import com.backend.webbackend.domain.Course;
|
||||||
|
import com.backend.webbackend.domain.TrainingResource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -8,4 +9,5 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
public interface courseService {
|
public interface courseService {
|
||||||
List<Course> getAllCourseInfo();
|
List<Course> getAllCourseInfo();
|
||||||
|
List<TrainingResource> getCourseResources();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.backend.webbackend.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @TableName resourse_type
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ResourseType {
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private String resourseTypeName;
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.backend.webbackend.mapper;
|
||||||
|
|
||||||
|
import com.backend.webbackend.domain.ResourseType;
|
||||||
|
import com.backend.webbackend.domain.TrainingResource;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Quella
|
||||||
|
* @description 针对表【resourse_type(资源类型)】的数据库操作Mapper
|
||||||
|
* @createDate 2026-01-13 15:57:20
|
||||||
|
* @Entity com.backend.webbackend.domain.ResourseType
|
||||||
|
*/
|
||||||
|
public interface ResourseTypeMapper {
|
||||||
|
|
||||||
|
int deleteByPrimaryKey(Long id);
|
||||||
|
|
||||||
|
int insert(ResourseType record);
|
||||||
|
|
||||||
|
int insertSelective(ResourseType record);
|
||||||
|
|
||||||
|
ResourseType selectByPrimaryKey(Long id);
|
||||||
|
|
||||||
|
int updateByPrimaryKeySelective(ResourseType record);
|
||||||
|
|
||||||
|
int updateByPrimaryKey(ResourseType record);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@ package com.backend.webbackend.mapper;
|
|||||||
|
|
||||||
import com.backend.webbackend.domain.TrainingResource;
|
import com.backend.webbackend.domain.TrainingResource;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Quella
|
* @author Quella
|
||||||
* @description 针对表【training_resource(培训资源表)】的数据库操作Mapper
|
* @description 针对表【training_resource(培训资源表)】的数据库操作Mapper
|
||||||
@@ -18,6 +20,8 @@ public interface TrainingResourceMapper {
|
|||||||
|
|
||||||
TrainingResource selectByPrimaryKey(Long id);
|
TrainingResource selectByPrimaryKey(Long id);
|
||||||
|
|
||||||
|
List<TrainingResource> getAllTraningResources();
|
||||||
|
|
||||||
int updateByPrimaryKeySelective(TrainingResource record);
|
int updateByPrimaryKeySelective(TrainingResource record);
|
||||||
|
|
||||||
int updateByPrimaryKey(TrainingResource record);
|
int updateByPrimaryKey(TrainingResource record);
|
||||||
|
|||||||
58
src/main/resources/mapper/ResourseTypeMapper.xml
Normal file
58
src/main/resources/mapper/ResourseTypeMapper.xml
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?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.backend.webbackend.mapper.ResourseTypeMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="com.backend.webbackend.domain.ResourseType">
|
||||||
|
<id property="id" column="id" />
|
||||||
|
<result property="resourseTypeName" column="resourse_type_name" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id,resourse_type_name
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
from resourse_type
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||||
|
delete from resourse_type
|
||||||
|
where id = #{id}
|
||||||
|
</delete>
|
||||||
|
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.backend.webbackend.domain.ResourseType" useGeneratedKeys="true">
|
||||||
|
insert into resourse_type
|
||||||
|
( id,resourse_type_name)
|
||||||
|
values (#{id},#{resourseTypeName})
|
||||||
|
</insert>
|
||||||
|
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.backend.webbackend.domain.ResourseType" useGeneratedKeys="true">
|
||||||
|
insert into resourse_type
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null">id,</if>
|
||||||
|
<if test="resourseTypeName != null">resourse_type_name,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null">#{id},</if>
|
||||||
|
<if test="resourseTypeName != null">#{resourseTypeName},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
<update id="updateByPrimaryKeySelective" parameterType="com.backend.webbackend.domain.ResourseType">
|
||||||
|
update resourse_type
|
||||||
|
<set>
|
||||||
|
<if test="resourseTypeName != null">
|
||||||
|
resourse_type_name = #{resourseTypeName},
|
||||||
|
</if>
|
||||||
|
</set>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
<update id="updateByPrimaryKey" parameterType="com.backend.webbackend.domain.ResourseType">
|
||||||
|
update resourse_type
|
||||||
|
set
|
||||||
|
resourse_type_name = #{resourseTypeName}
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
</mapper>
|
||||||
@@ -22,6 +22,11 @@
|
|||||||
from training_resource
|
from training_resource
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getAllTraningResources" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
from training_resource
|
||||||
|
</select>
|
||||||
|
|
||||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||||
delete from training_resource
|
delete from training_resource
|
||||||
|
|||||||
Reference in New Issue
Block a user