StudentInstrumentMapper.xml 7.5 KB

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