CourseHomeworkTemplateMapper.xml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.biz.dal.dao.CourseHomeworkTemplateDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.CourseHomeworkTemplate" id="CourseHomeworkTemplate">
  9. <result column="id_" property="id"/>
  10. <result column="name_" property="name"/>
  11. <result column="content_" property="content"/>
  12. <result column="del_flag_" property="delFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  13. <result column="create_time_" property="createTime"/>
  14. <result column="update_time_" property="updateTime"/>
  15. <result column="class_group_type_" property="classGroupType"
  16. typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  17. <result column="subject_id_" property="subjectId"/>
  18. </resultMap>
  19. <!-- 根据主键查询一条记录 -->
  20. <select id="get" resultMap="CourseHomeworkTemplate">
  21. SELECT * FROM course_homework_template WHERE id_ = #{id}
  22. </select>
  23. <!-- 全查询 -->
  24. <select id="findAll" resultMap="CourseHomeworkTemplate">
  25. SELECT * FROM course_homework_template ORDER BY id_
  26. </select>
  27. <!-- 向数据库增加一条记录 -->
  28. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.CourseHomeworkTemplate" useGeneratedKeys="true"
  29. keyColumn="id" keyProperty="id">
  30. <!--
  31. <selectKey resultClass="int" keyProperty="id" >
  32. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  33. </selectKey>
  34. -->
  35. INSERT INTO course_homework_template
  36. (id_,name_,content_,create_time_,update_time_,class_group_type_,subject_id_)
  37. VALUES(#{id},#{name},#{content},now(),now(),#{classGroupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{subjectId})
  38. </insert>
  39. <!-- 根据主键查询一条记录 -->
  40. <update id="update" parameterType="com.ym.mec.biz.dal.entity.CourseHomeworkTemplate">
  41. UPDATE course_homework_template
  42. <set>
  43. <if test="delFlag != null">
  44. del_flag_ = #{delFlag,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  45. </if>
  46. <if test="subjectId != null">
  47. subject_id_ = #{subjectId},
  48. </if>
  49. <if test="updateTime != null">
  50. update_time_ = now(),
  51. </if>
  52. <if test="content != null">
  53. content_ = #{content},
  54. </if>
  55. <if test="classGroupType != null">
  56. class_group_type_ = #{classGroupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  57. </if>
  58. <if test="name != null">
  59. name_ = #{name},
  60. </if>
  61. </set>
  62. WHERE id_ = #{id}
  63. </update>
  64. <!-- 根据主键删除一条记录 -->
  65. <delete id="delete">
  66. UPDATE course_homework_template SET del_flag_ = 1 WHERE id_ = #{id}
  67. </delete>
  68. <sql id="queryCondition">
  69. <where>
  70. <if test="subjectIDs != null">
  71. and subject_id_ IN
  72. <foreach collection="subjectIDs" item="subjectID" open="(" close=")" separator=",">
  73. #{subjectID}
  74. </foreach>
  75. </if>
  76. </where>
  77. </sql>
  78. <!-- 分页查询 -->
  79. <select id="queryPage" resultMap="CourseHomeworkTemplate" parameterType="map">
  80. SELECT * FROM course_homework_template
  81. <include refid="queryCondition"/>
  82. ORDER BY id_
  83. <include refid="global.limit"/>
  84. </select>
  85. <!-- 查询当前表的总记录数 -->
  86. <select id="queryCount" resultType="int">
  87. SELECT COUNT(*) FROM course_homework_template
  88. </select>
  89. <select id="getSubjectIDs" resultType="java.lang.String">
  90. SELECT
  91. cg.subject_id_list_
  92. FROM
  93. course_schedule cs
  94. LEFT JOIN class_group cg ON cs.class_group_id_=cg.id_
  95. WHERE cs.id_=#{courseScheduleID}
  96. </select>
  97. </mapper>