StudentInstrumentMapper.xml 7.6 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="orderId"/>
  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. start_time_ = #{startTime},
  81. end_time_ = #{endTime},
  82. <if test="changeOrderId != null">
  83. change_order_id_ = #{changeOrderId},
  84. </if>
  85. <if test="createTime != null">
  86. create_time_ = #{createTime},
  87. </if>
  88. <if test="delFlag != null">
  89. del_flag_ = #{delFlag},
  90. </if>
  91. update_time = NOW(),
  92. </set>
  93. where id_ = #{id}
  94. </update>
  95. <!-- 全查询 -->
  96. <select id="findAll" resultMap="StudentInstrument">
  97. SELECT *
  98. FROM student
  99. </select>
  100. <!-- 分页查询 -->
  101. <select id="queryPage" resultMap="StudentInstrument" parameterType="map">
  102. SELECT si.*,su.username_ studentName,su.phone_ phone,o.name_ organName FROM student_instrument si
  103. LEFT JOIN sys_user su ON su.id_ = si.student_id_
  104. LEFT JOIN organization o ON o.id_ = si.organ_id_
  105. <include refid="queryPageSql"/>
  106. <include refid="global.limit"/>
  107. </select>
  108. <!-- 查询当前表的总记录数 -->
  109. <select id="queryCount" resultType="int">
  110. SELECT COUNT(*)
  111. FROM student_instrument si
  112. LEFT JOIN sys_user su ON su.id_ = si.student_id_
  113. <include refid="queryPageSql"/>
  114. </select>
  115. <sql id="queryPageSql">
  116. <where>
  117. <if test="studentId != null">
  118. AND si.student_id_ = #{studentId}
  119. </if>
  120. <if test="organId != null">
  121. AND FIND_IN_SET(si.organ_id_,#{organId})
  122. </if>
  123. <if test="goodsId != null">
  124. AND si.goods_id_ = #{goodsId}
  125. </if>
  126. <if test="goodsCategoryId != null">
  127. AND si.goods_category_id_ = #{goodsCategoryId}
  128. </if>
  129. <if test="goodsBrand != null">
  130. AND si.goods_brand_ LIKE CONCAT('%',#{goodsBrand},'%')
  131. </if>
  132. <if test="specification != null">
  133. AND si.specification_ LIKE CONCAT('%',#{specification},'%')
  134. </if>
  135. <if test="status != null">
  136. AND si.status_ = #{status}
  137. </if>
  138. <if test="search != null">
  139. AND (si.student_id_ = #{search} OR su.phone_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%'))
  140. </if>
  141. AND si.del_flag_ = 0
  142. </where>
  143. </sql>
  144. <insert id="batchAdd" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  145. insert into student_instrument
  146. (student_id_,organ_id_,goods_id_,goods_category_id_,goods_category_name_,goods_name_,goods_brand_,specification_,goods_img_,
  147. order_id_,change_order_id_,status_, start_time_, end_time_, create_time_, update_time)
  148. VALUE
  149. <foreach collection="studentInstruments" item="item" separator=",">
  150. (#{item.studentId},#{item.organId},#{item.goodsId},#{item.goodsCategoryId},#{item.goodsCategoryName},#{item.goodsName},#{item.goodsBrand},#{item.specification},#{item.goodsImg},
  151. #{item.orderId},#{item.changeOrderId},#{item.status}, #{item.startTime},
  152. #{item.endTime}, NOW(), NOW())
  153. </foreach>
  154. </insert>
  155. <update id="batchUpdate">
  156. <![CDATA[
  157. UPDATE student_instrument
  158. SET status_ = 0
  159. WHERE end_time_ <= NOW()
  160. ]]>
  161. </update>
  162. <select id="getListByEndTime" resultMap="StudentInstrument">
  163. <![CDATA[
  164. SELECT *
  165. FROM student_instrument
  166. WHERE end_time_ >= #{startTime}
  167. AND end_time_ <= #{endTime}
  168. ]]>
  169. </select>
  170. <select id="getByOrderId" resultMap="StudentInstrument">
  171. SELECT *
  172. FROM student_instrument
  173. WHERE change_order_id_ = #{orderId}
  174. </select>
  175. <select id="getStudentInstrument" resultMap="StudentInstrument">
  176. SELECT * FROM student_instrument WHERE student_id_ = #{studentId} AND goods_id_ = #{goodsId} AND del_flag_ = 0
  177. </select>
  178. </mapper>