CourseHomeworkTemplateMapper.xml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. <result column="subject_name_" property="subjectName"/>
  19. </resultMap>
  20. <!-- 根据主键查询一条记录 -->
  21. <select id="get" resultMap="CourseHomeworkTemplate">
  22. SELECT * FROM course_homework_template WHERE id_ = #{id}
  23. </select>
  24. <!-- 全查询 -->
  25. <select id="findAll" resultMap="CourseHomeworkTemplate">
  26. SELECT * FROM course_homework_template ORDER BY id_
  27. </select>
  28. <!-- 向数据库增加一条记录 -->
  29. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.CourseHomeworkTemplate" useGeneratedKeys="true"
  30. keyColumn="id" keyProperty="id">
  31. <!--
  32. <selectKey resultClass="int" keyProperty="id" >
  33. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  34. </selectKey>
  35. -->
  36. INSERT INTO course_homework_template
  37. (id_,name_,content_,create_time_,update_time_,class_group_type_,subject_id_)
  38. VALUES(#{id},#{name},#{content},now(),now(),#{classGroupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{subjectId})
  39. </insert>
  40. <!-- 根据主键查询一条记录 -->
  41. <update id="update" parameterType="com.ym.mec.biz.dal.entity.CourseHomeworkTemplate">
  42. UPDATE course_homework_template
  43. <set>
  44. <if test="delFlag != null">
  45. del_flag_ = #{delFlag,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  46. </if>
  47. <if test="subjectId != null">
  48. subject_id_ = #{subjectId},
  49. </if>
  50. <if test="updateTime != null">
  51. update_time_ = now(),
  52. </if>
  53. <if test="content != null">
  54. content_ = #{content},
  55. </if>
  56. <if test="classGroupType != null">
  57. class_group_type_ = #{classGroupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  58. </if>
  59. <if test="name != null">
  60. name_ = #{name},
  61. </if>
  62. </set>
  63. WHERE id_ = #{id}
  64. </update>
  65. <!-- 根据主键删除一条记录 -->
  66. <delete id="delete">
  67. UPDATE course_homework_template SET del_flag_ = 1 WHERE id_ = #{id}
  68. </delete>
  69. <sql id="queryCondition">
  70. <where>
  71. cht.del_flag_ = 0
  72. <if test="subjectIDs != null">
  73. and subject_id_ IN
  74. <foreach collection="subjectIDs" item="subjectID" open="(" close=")" separator=",">
  75. #{subjectID}
  76. </foreach>
  77. </if>
  78. <if test="classType != null and classType!=''">
  79. and class_group_type_ = #{classType}
  80. </if>
  81. </where>
  82. </sql>
  83. <!-- 分页查询 -->
  84. <select id="queryPage" resultMap="CourseHomeworkTemplate" parameterType="map">
  85. SELECT
  86. cht.*,
  87. s.name_ subject_name_
  88. FROM
  89. course_homework_template cht
  90. LEFT JOIN `subject` s ON cht.subject_id_=s.id_
  91. <include refid="queryCondition"/>
  92. ORDER BY id_
  93. <include refid="global.limit"/>
  94. </select>
  95. <!-- 查询当前表的总记录数 -->
  96. <select id="queryCount" resultType="int">
  97. SELECT COUNT(*) FROM course_homework_template cht
  98. <include refid="queryCondition"/>
  99. </select>
  100. <select id="getSubjectIDs" resultType="java.lang.String">
  101. SELECT
  102. cg.subject_id_list_
  103. FROM
  104. course_schedule cs
  105. LEFT JOIN class_group cg ON cs.class_group_id_=cg.id_
  106. WHERE cs.id_=#{courseScheduleID}
  107. </select>
  108. </mapper>