ExtracurricularExercisesMapper.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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.ExtracurricularExercisesDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.ExtracurricularExercises" id="ExtracurricularExercises">
  9. <result column="id_" property="id" />
  10. <result column="teacher_id_" property="teacherId" />
  11. <result column="student_id_list_" property="studentIdList" />
  12. <result column="batch_no_" property="batchNo" />
  13. <result column="title_" property="title" />
  14. <result column="attachments_" property="attachments" />
  15. <result column="content_" property="content" />
  16. <result column="expire_date_" property="expireDate" />
  17. <result column="completed_num_" property="completedNum" />
  18. <result column="expect_num_" property="expectNum" />
  19. <result column="create_time_" property="createTime" />
  20. <result column="update_time_" property="updateTime" />
  21. </resultMap>
  22. <sql id="queryPageCondition">
  23. <where>
  24. <if test="teacherId != null">
  25. teacher_id_ = #{teacherId}
  26. </if>
  27. <if test="title != null">
  28. title_ = #{title}
  29. </if>
  30. <if test="batchNo != null">
  31. batch_no_ = #{batchNo}
  32. </if>
  33. <if test="assignStartTime != null">
  34. AND create_time_ &gt;= #{assignStartTime}
  35. </if>
  36. <if test="assignEndTime != null">
  37. AND create_time_ &lt;= #{assignEndTime}
  38. </if>
  39. </where>
  40. </sql>
  41. <!-- 根据主键查询一条记录 -->
  42. <select id="get" resultMap="ExtracurricularExercises" >
  43. SELECT * FROM extracurricular_exercises WHERE id_ = #{id}
  44. </select>
  45. <!-- 全查询 -->
  46. <select id="findAll" resultMap="ExtracurricularExercises">
  47. SELECT * FROM extracurricular_exercises ORDER BY id_
  48. </select>
  49. <!-- 向数据库增加一条记录 -->
  50. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.ExtracurricularExercises" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  51. <!--
  52. <selectKey resultClass="int" keyProperty="id" >
  53. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  54. </selectKey>
  55. -->
  56. INSERT INTO extracurricular_exercises (id_,teacher_id_,student_id_list_,batch_no_,title_,attachments_,content_,expire_date_,completed_num_,expect_num_,create_time_,update_time_)
  57. VALUES(#{id},#{teacherId},#{studentIdList},#{batchNo},#{title},#{attachments},#{content},#{expireDate},#{completedNum},#{expectNum},NOW(), NOW())
  58. </insert>
  59. <!-- 根据主键查询一条记录 -->
  60. <update id="update" parameterType="com.ym.mec.biz.dal.entity.ExtracurricularExercises">
  61. UPDATE extracurricular_exercises
  62. <set>
  63. <if test="studentIdList != null">
  64. student_id_list_ = #{studentIdList},
  65. </if>
  66. <if test="expireDate != null">
  67. expire_date_ = #{expireDate},
  68. </if>
  69. <if test="batchNo != null">
  70. batch_no_ = #{batchNo},
  71. </if>
  72. <if test="id != null">
  73. id_ = #{id},
  74. </if>
  75. <if test="teacherId != null">
  76. teacher_id_ = #{teacherId},
  77. </if>
  78. <if test="title != null">
  79. title_ = #{title},
  80. </if>
  81. <if test="expectNum != null">
  82. expect_num_ = #{expectNum},
  83. </if>
  84. <if test="content != null">
  85. content_ = #{content},
  86. </if>
  87. <if test="attachments != null">
  88. attachments_ = #{attachments},
  89. </if>
  90. <if test="completedNum != null">
  91. completed_num_ = #{completedNum},
  92. </if>
  93. update_time_ = NOW()
  94. </set> WHERE id_ = #{id}
  95. </update>
  96. <!-- 根据主键删除一条记录 -->
  97. <delete id="delete" >
  98. DELETE FROM extracurricular_exercises WHERE id_ = #{id}
  99. </delete>
  100. <!-- 分页查询 -->
  101. <select id="queryPage" resultMap="ExtracurricularExercises" parameterType="map">
  102. SELECT * FROM extracurricular_exercises
  103. <include refid="queryPageCondition"/>
  104. ORDER BY id_ <include refid="global.limit"/>
  105. </select>
  106. <!-- 查询当前表的总记录数 -->
  107. <select id="queryCount" resultType="int">
  108. SELECT COUNT(*) FROM extracurricular_exercises
  109. <include refid="queryPageCondition"/>
  110. </select>
  111. <sql id="queryExtraExercisesCondition">
  112. <where>
  113. <if test="teacherId!=null">
  114. teacher_id_=#{teacherId}
  115. </if>
  116. <if test="createTime!=null">
  117. AND DATE_FORMAT(create_time_, '%Y-%m') = DATE_FORMAT(#{createTime}, '%Y-%m')
  118. </if>
  119. </where>
  120. </sql>
  121. <select id="countExtraExercises" resultType="int">
  122. SELECT COUNT(id_) FROM extracurricular_exercises
  123. <include refid="queryExtraExercisesCondition"/>
  124. </select>
  125. <select id="findExtraExercises" resultMap="ExtracurricularExercises">
  126. SELECT * FROM extracurricular_exercises
  127. <include refid="queryExtraExercisesCondition"/>
  128. ORDER BY create_time_ DESC
  129. <include refid="global.limit"/>
  130. </select>
  131. </mapper>