ExtracurricularExercisesMapper.xml 4.1 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.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. <!-- 根据主键查询一条记录 -->
  23. <select id="get" resultMap="ExtracurricularExercises" >
  24. SELECT * FROM extracurricular_exercises WHERE id_ = #{id}
  25. </select>
  26. <!-- 全查询 -->
  27. <select id="findAll" resultMap="ExtracurricularExercises">
  28. SELECT * FROM extracurricular_exercises ORDER BY id_
  29. </select>
  30. <!-- 向数据库增加一条记录 -->
  31. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.ExtracurricularExercises" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  32. <!--
  33. <selectKey resultClass="int" keyProperty="id" >
  34. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  35. </selectKey>
  36. -->
  37. 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_)
  38. VALUES(#{id},#{teacherId},#{studentIdList},#{batchNo},#{title},#{attachments},#{content},#{expireDate},#{completedNum},#{expectNum},NOW(), NOW())
  39. </insert>
  40. <!-- 根据主键查询一条记录 -->
  41. <update id="update" parameterType="com.ym.mec.biz.dal.entity.ExtracurricularExercises">
  42. UPDATE extracurricular_exercises
  43. <set>
  44. <if test="studentIdList != null">
  45. student_id_list_ = #{studentIdList},
  46. </if>
  47. <if test="expireDate != null">
  48. expire_date_ = #{expireDate},
  49. </if>
  50. <if test="batchNo != null">
  51. batch_no_ = #{batchNo},
  52. </if>
  53. <if test="id != null">
  54. id_ = #{id},
  55. </if>
  56. <if test="teacherId != null">
  57. teacher_id_ = #{teacherId},
  58. </if>
  59. <if test="title != null">
  60. title_ = #{title},
  61. </if>
  62. <if test="expectNum != null">
  63. expect_num_ = #{expectNum},
  64. </if>
  65. <if test="content != null">
  66. content_ = #{content},
  67. </if>
  68. <if test="attachments != null">
  69. attachments_ = #{attachments},
  70. </if>
  71. <if test="completedNum != null">
  72. completed_num_ = #{completedNum},
  73. </if>
  74. update_time_ = NOW()
  75. </set> WHERE id_ = #{id}
  76. </update>
  77. <!-- 根据主键删除一条记录 -->
  78. <delete id="delete" >
  79. DELETE FROM extracurricular_exercises WHERE id_ = #{id}
  80. </delete>
  81. <!-- 分页查询 -->
  82. <select id="queryPage" resultMap="ExtracurricularExercises" parameterType="map">
  83. SELECT * FROM extracurricular_exercises ORDER BY id_ <include refid="global.limit"/>
  84. </select>
  85. <!-- 查询当前表的总记录数 -->
  86. <select id="queryCount" resultType="int">
  87. SELECT COUNT(*) FROM extracurricular_exercises
  88. </select>
  89. <sql id="queryExtraExercisesCondition">
  90. <where>
  91. <if test="teacherId!=null">
  92. teacher_id_=#{teacherId}
  93. </if>
  94. <if test="createTime!=null">
  95. AND DATE_FORMAT(create_time_, '%Y-%m') = DATE_FORMAT(#{createTime}, '%Y-%m')
  96. </if>
  97. </where>
  98. </sql>
  99. <select id="countExtraExercises" resultType="int">
  100. SELECT COUNT(id_) FROM extracurricular_exercises
  101. <include refid="queryExtraExercisesCondition"/>
  102. </select>
  103. <select id="findExtraExercises" resultMap="ExtracurricularExercises">
  104. SELECT * FROM extracurricular_exercises
  105. <include refid="queryExtraExercisesCondition"/>
  106. ORDER BY create_time_ DESC
  107. <include refid="global.limit"/>
  108. </select>
  109. </mapper>