StudentInstrumentMapper.xml 7.1 KB

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