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