ExtracurricularExercisesMapper.xml 4.8 KB

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