StudentInstrumentMapper.xml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. <mapper namespace="com.ym.mec.biz.dal.dao.StudentInstrumentDao">
  4. <resultMap id="StudentInstrument" type="com.ym.mec.biz.dal.entity.StudentInstrument">
  5. <!--@mbg.generated-->
  6. <!--@Table student_instrument-->
  7. <id column="id_" property="id"/>
  8. <result column="student_id_" property="studentId"/>
  9. <result column="organ_id_" property="organId"/>
  10. <result column="goods_id_" property="goodsId"/>
  11. <result column="goods_category_id_" property="goodsCategoryId"/>
  12. <result column="goods_category_name_" property="goodsCategoryName"/>
  13. <result column="status_" property="status"/>
  14. <result column="start_time_" property="startTime"/>
  15. <result column="end_time_" property="endTime"/>
  16. <result column="create_time_" property="createTime"/>
  17. <result column="update_time" property="updateTime"/>
  18. <result column="goods_name_" property="goodsName"/>
  19. <result column="specification_" property="specification"/>
  20. <result column="goods_brand_" property="goodsBrand"/>
  21. <result column="goods_img_" property="goodsImg"/>
  22. </resultMap>
  23. <select id="get" parameterType="java.lang.Integer" resultMap="StudentInstrument">
  24. <!--@mbg.generated-->
  25. SELECT * FROM student_instrument
  26. where id_ = #{id}
  27. </select>
  28. <delete id="delete" parameterType="java.lang.Integer">
  29. <!--@mbg.generated-->
  30. delete from student_instrument
  31. where id_ = #{id}
  32. </delete>
  33. <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.StudentInstrument"
  34. useGeneratedKeys="true">
  35. <!--@mbg.generated-->
  36. insert into student_instrument
  37. (student_id_,organ_id_,goods_id_,goods_category_id_,goods_category_name_,goods_name_,goods_brand_,specification_,goods_img_,
  38. status_, start_time_, end_time_, create_time_, update_time
  39. )
  40. values
  41. (#{studentId},#{organId},#{goodsId},#{goodsCategoryId},#{goodsCategoryName},#{goodsName},#{goodsBrand},#{specification},#{goodsImg},
  42. #{status}, #{startTime}, #{endTime}, NOW(), NOW()
  43. )
  44. </insert>
  45. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentInstrument">
  46. <!--@mbg.generated-->
  47. update student_instrument
  48. <set>
  49. <if test="studentId != null">
  50. student_id_ = #{studentId},
  51. </if>
  52. <if test="organId != null">
  53. organ_id_ = #{organId},
  54. </if>
  55. <if test="goodsId != null">
  56. goods_id_ = #{goodsId},
  57. </if>
  58. <if test="goodsName != null">
  59. goods_name_ = #{goodsName},
  60. </if>
  61. <if test="goodsBrand != null">
  62. goods_brand_ = #{goodsBrand},
  63. </if>
  64. <if test="specification != null">
  65. specification_ = #{specification},
  66. </if>
  67. <if test="goodsImg != null">
  68. goods_img_ = #{goodsImg},
  69. </if>
  70. <if test="status != null">
  71. status_ = #{status},
  72. </if>
  73. <if test="startTime != null">
  74. start_time_ = #{startTime},
  75. </if>
  76. <if test="endTime != null">
  77. end_time_ = #{endTime},
  78. </if>
  79. <if test="createTime != null">
  80. create_time_ = #{createTime},
  81. </if>
  82. <if test="updateTime != null">
  83. update_time = #{updateTime},
  84. </if>
  85. </set>
  86. where id_ = #{id}
  87. </update>
  88. <!-- 全查询 -->
  89. <select id="findAll" resultMap="StudentInstrument">
  90. SELECT *
  91. FROM student
  92. </select>
  93. <!-- 分页查询 -->
  94. <select id="queryPage" resultMap="StudentInstrument" parameterType="map">
  95. SELECT si.*,su.username_ studentName,su.phone_ phone,o.name_ organName FROM student_instrument si
  96. LEFT JOIN sys_user su ON su.id_ = si.student_id_
  97. LEFT JOIN organization o ON o.id_ = si.organ_id_
  98. <include refid="queryPageSql"/>
  99. <include refid="global.limit"/>
  100. </select>
  101. <!-- 查询当前表的总记录数 -->
  102. <select id="queryCount" resultType="int">
  103. SELECT COUNT(*)
  104. FROM student_instrument si
  105. LEFT JOIN sys_user su ON su.id_ = si.student_id_
  106. <include refid="queryPageSql"/>
  107. </select>
  108. <sql id="queryPageSql">
  109. <where>
  110. <if test="studentId != null">
  111. AND si.student_id_ = #{studentId}
  112. </if>
  113. <if test="organId != null">
  114. AND FIND_IN_SET(si.organ_id_,#{organId})
  115. </if>
  116. <if test="goodsId != null">
  117. AND si.goods_id_ = #{goodsId}
  118. </if>
  119. <if test="goodsCategoryId != null">
  120. AND si.goods_category_id_ = #{goodsCategoryId}
  121. </if>
  122. <if test="goodsBrand != null">
  123. AND si.goods_brand_ LIKE CONCAT('%',#{goodsBrand},'%')
  124. </if>
  125. <if test="specification != null">
  126. AND si.specification_ LIKE CONCAT('%',#{specification},'%')
  127. </if>
  128. <if test="search != null">
  129. AND (si.student_id_ = #{search} OR su.phone_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%'))
  130. </if>
  131. </where>
  132. </sql>
  133. <insert id="batchAdd" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  134. insert into student_instrument
  135. (student_id_,organ_id_,goods_id_,goods_category_id_,goods_category_name_,goods_name_,goods_brand_,specification_,goods_img_,
  136. status_, start_time_, end_time_, create_time_, update_time)
  137. VALUE
  138. <foreach collection="studentInstruments" item="item" separator=",">
  139. (#{item.studentId},#{item.organId},#{item.goodsId},#{item.goodsCategoryId},#{item.goodsCategoryName},#{item.goodsName},#{item.goodsBrand},#{item.specification},#{item.goodsImg},
  140. #{item.status}, #{item.startTime},
  141. #{item.endTime}, NOW(), NOW())
  142. </foreach>
  143. </insert>
  144. <update id="batchUpdate">
  145. <![CDATA[
  146. UPDATE student_instrument
  147. SET status_ = 0
  148. WHERE end_time_ <= NOW()
  149. ]]>
  150. </update>
  151. </mapper>