package com.yst.ovls.dao;
import com.yst.ovls.entity.Course;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
public interface CourseMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table course
*
* @mbg.generated Mon Jan 07 11:58:20 CST 2019
*/
@Delete({
"delete from course",
"where id = #{id,jdbcType=INTEGER}"
})
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table course
*
* @mbg.generated Mon Jan 07 11:58:20 CST 2019
*/
@Insert({
"insert into course (id, name, ",
"intro, learn_count, ",
"difficulty, score, ",
"image, publish_time, ",
"price, subject_id, ",
"direction_id, learn_time)",
"values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
"#{intro,jdbcType=VARCHAR}, #{learnCount,jdbcType=INTEGER}, ",
"#{difficulty,jdbcType=VARCHAR}, #{score,jdbcType=INTEGER}, ",
"#{image,jdbcType=VARCHAR}, #{publishTime,jdbcType=TIMESTAMP}, ",
"#{price,jdbcType=INTEGER}, #{subjectId,jdbcType=INTEGER}, ",
"#{directionId,jdbcType=INTEGER}, #{learnTime,jdbcType=INTEGER})"
})
int insert(Course record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table course
*
* @mbg.generated Mon Jan 07 11:58:20 CST 2019
*/
@InsertProvider(type=CourseSqlProvider.class, method="insertSelective")
int insertSelective(Course record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table course
*
* @mbg.generated Mon Jan 07 11:58:20 CST 2019
*/
@Select({
"select",
"id, name, intro, learn_count, difficulty, score, image, publish_time, price, ",
"subject_id, direction_id, learn_time",
"from course",
"where id = #{id,jdbcType=INTEGER}"
})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
@Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
@Result(column="intro", property="intro", jdbcType=JdbcType.VARCHAR),
@Result(column="learn_count", property="learnCount", jdbcType=JdbcType.INTEGER),
@Result(column="difficulty", property="difficulty", jdbcType=JdbcType.VARCHAR),
@Result(column="score", property="score", jdbcType=JdbcType.INTEGER),
@Result(column="image", property="image", jdbcType=JdbcType.VARCHAR),
@Result(column="publish_time", property="publishTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="price", property="price", jdbcType=JdbcType.INTEGER),
@Result(column="subject_id", property="subjectId", jdbcType=JdbcType.INTEGER),
@Result(column="direction_id", property="directionId", jdbcType=JdbcType.INTEGER),
@Result(column="learn_time", property="learnTime", jdbcType=JdbcType.INTEGER)
})
Course selectByPrimaryKey(Integer id);
/*
* @Description:
* @Author: yanshitong
* @Date: 2019/3/22 22:41
* @Param:[]
* @Return: java.util.List<com.yst.ovls.entity.Course>
* @Exception: 获取所有课程
*/
@Select({
"select",
"c.id, c.name, intro, learn_count, difficulty, score, image, publish_time, price, ",
"s.name subjectName, d.name directionName, learn_time",
"from course c , direction d, subject s",
"where c.subject_id = s.id and c.direction_id=d.id order by c.id"
})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
@Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
@Result(column="intro", property="intro", jdbcType=JdbcType.VARCHAR),
@Result(column="learn_count", property="learnCount", jdbcType=JdbcType.INTEGER),
@Result(column="difficulty", property="difficulty", jdbcType=JdbcType.VARCHAR),
@Result(column="score", property="score", jdbcType=JdbcType.INTEGER),
@Result(column="image", property="image", jdbcType=JdbcType.VARCHAR),
@Result(column="publish_time", property="publishTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="price", property="price", jdbcType=JdbcType.INTEGER),
@Result(column="subject_id", property="subjectId", jdbcType=JdbcType.INTEGER),
@Result(column="direction_id", property="directionId", jdbcType=JdbcType.INTEGER),
@Result(column="learn_time", property="learnTime", jdbcType=JdbcType.INTEGER)
})
List<Course> selectCourses();
/**
* 查询免费好课,价格为零,按照评价、访问量排序
*/
@Select({
"select",
"id, name, intro, learn_count, difficulty, score, image, publish_time, price, ",
"subject_id, direction_id, learn_time",
"from course",
"where price = 0",
"order by score desc,learn_count desc"
})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
@Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
@Result(column="intro", property="intro", jdbcType=JdbcType.VARCHAR),
@Result(column="learn_count", property="learnCount", jdbcType=JdbcType.INTEGER),
@Result(column="difficulty", property="difficulty", jdbcType=JdbcType.VARCHAR),
@Result(column="score", property="score", jdbcType=JdbcType.INTEGER),
@Result(column="image", property="image", jdbcType=JdbcType.VARCHAR),
@Result(column="publish_time", property="publishTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="price", property="price", jdbcType=JdbcType.INTEGER),
@Result(column="subject_id", property="subjectId", jdbcType=JdbcType.INTEGER),
@Result(column="direction_id", property="directionId", jdbcType=JdbcType.INTEGER),
@Result(column="learn_time", property="learnTime", jdbcType=JdbcType.INTEGER)
})
List<Course> selectFreeCourse();
//模糊查询
@Select({
"select ",
"id, name, intro, learn_count, difficulty, score, image, publish_time, price, ",
"subject_id, direction_id, learn_time",
"from course",
"where name like CONCAT('%', #{name,jdbcType=VARCHAR}, '%') ",
"order by learn_count desc"
})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
@Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
@Result(column="intro", property="intro", jdbcType=JdbcType.VARCHAR),
@Result(column="learn_count", property="learnCount", jdbcType=JdbcType.INTEGER),
@Result(column="difficulty", property="difficulty", jdbcType=JdbcType.VARCHAR),
@Result(column="score", property="score", jdbcType=JdbcType.INTEGER),
@Result(column="image", property="image", jdbcType=JdbcType.VARCHAR),
@Result(column="publish_time", property="publishTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="price", property="price", jdbcType=JdbcType.INTEGER),
@Result(column="subject_id", property="subjectId", jdbcType=JdbcType.INTEGER),
@Result(column="direction_id", property="directionId", jdbcType=JdbcType.INTEGER),
@Result(column="learn_time", property="learnTime", jdbcType=JdbcType.INTEGER)
})
Lis