OrderYearMaxDurationMapper.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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.goafanti.common.dao.OrderYearMaxDurationMapper">
  4. <resultMap type="com.goafanti.common.model.OrderYearMaxDuration" id="OrderYearMaxDurationMap">
  5. <result property="id" column="id" jdbcType="INTEGER"/>
  6. <result property="orderNo" column="order_no" jdbcType="VARCHAR"/>
  7. <result property="year" column="year" jdbcType="INTEGER"/>
  8. <result property="status" column="status" jdbcType="INTEGER"/>
  9. <result property="maxDuration" column="max_duration" jdbcType="VARCHAR"/>
  10. <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  11. </resultMap>
  12. <!--查询单个-->
  13. <select id="queryById" resultMap="OrderYearMaxDurationMap">
  14. select id,
  15. order_no,
  16. year,
  17. status,
  18. max_duration,
  19. create_time
  20. from order_year_max_duration
  21. where id = #{id}
  22. </select>
  23. <!--查询指定行数据-->
  24. <select id="findOrderYearMaxDurationList" resultMap="OrderYearMaxDurationMap">
  25. select
  26. id, order_no, year, status, max_duration, create_time
  27. from order_year_max_duration
  28. <where>
  29. <if test="id != null">
  30. and id = #{id}
  31. </if>
  32. <if test="orderNo != null and orderNo != ''">
  33. and order_no = #{orderNo}
  34. </if>
  35. <if test="year != null">
  36. and year = #{year}
  37. </if>
  38. <if test="status != null">
  39. and status = #{status}
  40. </if>
  41. <if test="maxDuration != null">
  42. and max_duration = #{maxDuration}
  43. </if>
  44. <if test="createTime != null">
  45. and create_time = #{createTime}
  46. </if>
  47. </where>
  48. limit #{pageable.offset}, #{pageable.pageSize}
  49. </select>
  50. <!--统计总行数-->
  51. <select id="queryAllByCount" resultType="java.lang.Integer">
  52. select count(1)
  53. from order_year_max_duration
  54. <where>
  55. <if test="id != null">
  56. and id = #{id}
  57. </if>
  58. <if test="orderNo != null and orderNo != ''">
  59. and order_no = #{orderNo}
  60. </if>
  61. <if test="year != null">
  62. and year = #{year}
  63. </if>
  64. <if test="status != null">
  65. and status = #{status}
  66. </if>
  67. <if test="maxDuration != null">
  68. and max_duration = #{maxDuration}
  69. </if>
  70. <if test="createTime != null">
  71. and create_time = #{createTime}
  72. </if>
  73. </where>
  74. </select>
  75. <!--新增所有列-->
  76. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  77. insert into order_year_max_duration(order_no, year, status, max_duration)
  78. values (#{orderNo}, #{year}, #{status}, #{maxDuration})
  79. </insert>
  80. <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
  81. insert into order_year_max_duration(order_no, year, status, max_duration)
  82. values
  83. <foreach collection="entities" item="entity" separator=",">
  84. (#{entity.orderNo}, #{entity.year}, #{entity.status}, #{entity.maxDuration})
  85. </foreach>
  86. </insert>
  87. <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
  88. insert into order_year_max_duration(order_no, year, status, max_duration, create_time)
  89. values
  90. <foreach collection="entities" item="entity" separator=",">
  91. (#{entity.orderNo}, #{entity.year}, #{entity.status}, #{entity.maxDuration}, #{entity.createTime})
  92. </foreach>
  93. on duplicate key update
  94. order_no = values(order_no),
  95. year = values(year),
  96. status = values(status),
  97. max_duration = values(max_duration),
  98. create_time = values(create_time)
  99. </insert>
  100. <!--通过主键修改数据-->
  101. <update id="update">
  102. update order_year_max_duration
  103. <set>
  104. <if test="orderNo != null and orderNo != ''">
  105. order_no = #{orderNo},
  106. </if>
  107. <if test="year != null">
  108. year = #{year},
  109. </if>
  110. <if test="status != null">
  111. status = #{status},
  112. </if>
  113. <if test="maxDuration != null">
  114. max_duration = #{maxDuration},
  115. </if>
  116. <if test="createTime != null">
  117. create_time = #{createTime},
  118. </if>
  119. </set>
  120. where id = #{id}
  121. </update>
  122. <!--通过主键删除-->
  123. <delete id="deleteById">
  124. delete
  125. from order_year_max_duration
  126. where id = #{id}
  127. </delete>
  128. <select id="selectByOrderNo" resultMap="OrderYearMaxDurationMap">
  129. select
  130. id, order_no, year, status, max_duration, create_time
  131. from order_year_max_duration
  132. where order_no = #{orderNo,jdbcType=VARCHAR}
  133. </select>
  134. <update id="updateByOrderNoAndYear">
  135. update order_year_max_duration
  136. <set>
  137. <if test="orderNo != null and orderNo != ''">
  138. order_no = #{orderNo},
  139. </if>
  140. <if test="status != null">
  141. status = #{status},
  142. </if>
  143. <if test="maxDuration != null">
  144. max_duration = #{maxDuration},
  145. </if>
  146. </set>
  147. where order_no = #{orderNo} and year = #{year}
  148. </update>
  149. </mapper>