StudentInstrumentMapper.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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" useGeneratedKeys="true">
  34. <!--@mbg.generated-->
  35. insert into student_instrument (student_id_,organ_id_,goods_id_,goods_category_id_,goods_category_name_,goods_name_,goods_brand_,specification_,goods_img_, status_, start_time_, end_time_, create_time_, update_time
  36. )
  37. values (#{studentId},#{organId},#{goodsId},#{goodsCategoryId},#{goodsCategoryName},#{goodsName},#{goodsBrand},#{specification},#{goodsImg}, #{status}, #{startTime}, #{endTime}, NOW(), NOW()
  38. )
  39. </insert>
  40. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentInstrument">
  41. <!--@mbg.generated-->
  42. update student_instrument
  43. <set>
  44. <if test="studentId != null">
  45. student_id_ = #{studentId},
  46. </if>
  47. <if test="organId != null">
  48. organ_id_ = #{organId},
  49. </if>
  50. <if test="goodsId != null">
  51. goods_id_ = #{goodsId},
  52. </if>
  53. <if test="goodsName != null">
  54. goods_name_ = #{goodsName},
  55. </if>
  56. <if test="goodsBrand != null">
  57. goods_brand_ = #{goodsBrand},
  58. </if>
  59. <if test="specification != null">
  60. specification_ = #{specification},
  61. </if>
  62. <if test="goodsImg != null">
  63. goods_img_ = #{goodsImg},
  64. </if>
  65. <if test="status != null">
  66. status_ = #{status},
  67. </if>
  68. <if test="startTime != null">
  69. start_time_ = #{startTime},
  70. </if>
  71. <if test="endTime != null">
  72. end_time_ = #{endTime},
  73. </if>
  74. <if test="createTime != null">
  75. create_time_ = #{createTime},
  76. </if>
  77. <if test="updateTime != null">
  78. update_time = #{updateTime},
  79. </if>
  80. </set>
  81. where id_ = #{id}
  82. </update>
  83. <!-- 全查询 -->
  84. <select id="findAll" resultMap="StudentInstrument">
  85. SELECT *
  86. FROM student
  87. </select>
  88. <!-- 分页查询 -->
  89. <select id="queryPage" resultMap="StudentInstrument" parameterType="map">
  90. SELECT si.*,su.username_ studentName,su.phone_ phone,o.name_ organName FROM student_instrument si
  91. LEFT JOIN sys_user su ON su.id_ = si.student_id_
  92. LEFT JOIN organization o ON o.id_ = si.organ_id_
  93. <include refid="queryPageSql"/>
  94. <include refid="global.limit"/>
  95. </select>
  96. <!-- 查询当前表的总记录数 -->
  97. <select id="queryCount" resultType="int">
  98. SELECT COUNT(*)
  99. FROM student_instrument si
  100. LEFT JOIN sys_user su ON su.id_ = si.student_id_
  101. <include refid="queryPageSql"/>
  102. </select>
  103. <sql id="queryPageSql">
  104. <where>
  105. <if test="studentId != null">
  106. AND si.student_id_ = #{studentId}
  107. </if>
  108. <if test="organId != null">
  109. AND FIND_IN_SET(si.organ_id_,#{organId})
  110. </if>
  111. <if test="goodsId != null">
  112. AND si.goods_id_ = #{goodsId}
  113. </if>
  114. <if test="goodsCategoryId != null">
  115. AND si.goods_category_id_ = #{goodsCategoryId}
  116. </if>
  117. <if test="goodsBrand != null">
  118. AND si.goods_brand_ LIKE CONCAT('%',#{goodsBrand},'%')
  119. </if>
  120. <if test="specification != null">
  121. AND si.specification_ LIKE CONCAT('%',#{specification},'%')
  122. </if>
  123. <if test="search != null">
  124. AND (si.student_id_ = #{search} OR su.phone_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%'))
  125. </if>
  126. </where>
  127. </sql>
  128. <insert id="batchAdd" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  129. insert into student_instrument (student_id_,organ_id_,goods_id_,goods_category_id_,goods_category_name_,goods_name_,goods_brand_,specification_,goods_img_, status_, start_time_, end_time_, create_time_, update_time)
  130. VALUE
  131. <foreach collection="studentInstruments" item="item" separator=",">
  132. (#{item.studentId},#{item.organId},#{item.goodsId},#{item.goodsCategoryId},#{item.goodsCategoryName},#{item.goodsName},#{item.goodsBrand},#{item.specification},#{item.goodsImg}, #{item.status}, #{item.startTime},
  133. #{item.endTime}, NOW(), NOW())
  134. </foreach>
  135. </insert>
  136. </mapper>