zoukankan      html  css  js  c++  java
  • 注解式SQL Select语句判空

    这里有个神坑,标签和大于、小于号它可能识别不出来
    所以要用 【&gt;】代替【>】号,用【&lt;】代替【<】号
    @Select("<script>" +
    "select * from course " +
    "<where> " +
    "del_flag = 0 and id in " +
    "(select course_id from course_teacher where del_flag = 0 and user_id = #{userId})" +
    "<if test='courseName != null'> " +
    "and course_name like concat('%',#{courseName},'%') " +
    "</if>" +
    "<if test='openTime != null'> " +
    "and open_time &gt;= #{openTime} " +
    "</if>" +
    "<if test='endTime != null'> " +
    "and end_time &lt;= #{endTime} " +
    "</if> " +
    "</where> " +
    "</script>")
    @Results({
    @Result(property = "userId", column = "user_id"),
    @Result(property = "courseName", column = "course_name"),
    @Result(property = "openTime", column = "open_time"),
    @Result(property = "endTime",column = "end_time"),
    })
    List<Course> searchTeCourse(@Param("userId") Long userId,@Param("courseName") String courseName,@Param("openTime") Date openTime,@Param("endTime") Date endTime);
    下面那个@Results()那块加不加都可以。我是不加了,多此一举
  • 相关阅读:
    约瑟夫问题
    十点半
    鹊桥相会
    C语言实验——数日子
    汉诺塔
    读入字符串
    C语言实验——各位数字之和排序
    数据结构实验之链表五:单链表的拆分
    C语言实验——分割整数
    大一上学期
  • 原文地址:https://www.cnblogs.com/gslgb/p/13231088.html
Copyright © 2011-2022 走看看