TbDeclareMapper.xml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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.pj.project.tb_declare.TbDeclareMapper">
  4. <!-- 增 [G] -->
  5. <insert id="add">
  6. insert into
  7. tb_declare (id, business_id, goods_name, gross_weight, num, production_date, expiration_date, storage_mode, production_mode, origin, producer_code, send_unit, receive_unit, route, driver_name, driver_phone, agent, agent_phone, china_car_no, china_car_suff, car_no, custom_proof, quarantine_proof, shop, production_code, container_code)
  8. values (#{id}, #{businessId}, #{goodsName}, #{grossWeight}, #{num}, #{productionDate}, #{expirationDate}, #{storageMode}, #{productionMode}, #{origin}, #{producerCode}, #{sendUnit}, #{receiveUnit}, #{route}, #{driverName}, #{driverPhone}, #{agent}, #{agentPhone}, #{chinaCarNo}, #{chinaCarSuff}, #{carNo}, #{customProof}, #{quarantineProof}, #{shop}, #{productionCode}, #{containerCode})
  9. </insert>
  10. <!-- 删 -->
  11. <delete id="delete">
  12. delete from tb_declare
  13. where id = #{id}
  14. </delete>
  15. <!-- 改 [G] -->
  16. <update id="update">
  17. update tb_declare set
  18. id = #{id},
  19. business_id = #{businessId},
  20. goods_name = #{goodsName},
  21. gross_weight = #{grossWeight},
  22. num = #{num},
  23. production_date = #{productionDate},
  24. expiration_date = #{expirationDate},
  25. storage_mode = #{storageMode},
  26. production_mode = #{productionMode},
  27. origin = #{origin},
  28. producer_code = #{producerCode},
  29. send_unit = #{sendUnit},
  30. receive_unit = #{receiveUnit},
  31. route = #{route},
  32. driver_name = #{driverName},
  33. driver_phone = #{driverPhone},
  34. agent = #{agent},
  35. agent_phone = #{agentPhone},
  36. china_car_no = #{chinaCarNo},
  37. china_car_suff = #{chinaCarSuff},
  38. car_no = #{carNo},
  39. custom_proof = #{customProof},
  40. quarantine_proof = #{quarantineProof},
  41. shop = #{shop},
  42. production_code = #{productionCode},
  43. container_code = #{containerCode}
  44. where id = #{id}
  45. </update>
  46. <!-- ================================== 查询相关 ================================== -->
  47. <!-- select id, business_id, goods_name, gross_weight, num, production_date, expiration_date, storage_mode, production_mode, origin, producer_code, send_unit, receive_unit, route, driver_name, driver_phone, agent, agent_phone, china_car_no, car_no, custom_proof, quarantine_proof, shop, production_code, container_code from tb_declare -->
  48. <!-- 通用映射:手动模式 -->
  49. <resultMap id="model" type="com.pj.project.tb_declare.TbDeclare">
  50. <result property="id" column="id"/>
  51. <result property="businessId" column="business_id"/>
  52. <result property="goodsName" column="goods_name"/>
  53. <result property="grossWeight" column="gross_weight"/>
  54. <result property="num" column="num"/>
  55. <result property="productionDate" column="production_date"/>
  56. <result property="expirationDate" column="expiration_date"/>
  57. <result property="storageMode" column="storage_mode"/>
  58. <result property="productionMode" column="production_mode"/>
  59. <result property="origin" column="origin"/>
  60. <result property="producerCode" column="producer_code"/>
  61. <result property="sendUnit" column="send_unit"/>
  62. <result property="receiveUnit" column="receive_unit"/>
  63. <result property="route" column="route"/>
  64. <result property="driverName" column="driver_name"/>
  65. <result property="driverPhone" column="driver_phone"/>
  66. <result property="agent" column="agent"/>
  67. <result property="agentPhone" column="agent_phone"/>
  68. <result property="chinaCarNo" column="china_car_no"/>
  69. <result property="chinaCarSuff" column="china_car_suff"/>
  70. <result property="carNo" column="car_no"/>
  71. <result property="customProof" column="custom_proof"/>
  72. <result property="quarantineProof" column="quarantine_proof"/>
  73. <result property="shop" column="shop"/>
  74. <result property="productionCode" column="production_code"/>
  75. <result property="containerCode" column="container_code"/>
  76. </resultMap>
  77. <!-- 公共查询sql片段 -->
  78. <sql id="select_sql">
  79. select *
  80. from tb_declare
  81. </sql>
  82. <!-- 查 - 根据id -->
  83. <select id="getById" resultType="com.pj.project.tb_declare.TbDeclare">
  84. <include refid="select_sql"></include>
  85. where id = #{id}
  86. </select>
  87. <!-- 查集合 - 根据条件(参数为空时代表忽略指定条件) [G] -->
  88. <select id="getList" resultMap="model">
  89. <include refid="select_sql"></include>
  90. <where>
  91. <if test=' this.has("id") '>and id = #{id}</if>
  92. <if test=' this.has("businessId") '>and business_id = #{businessId}</if>
  93. <if test=' this.has("customerId") '>and customer_id = #{customerId}</if>
  94. <if test=' this.has("declarePeople") '>and declare_people like concat('%',#{declarePeople},'%')</if>
  95. <if test=' this.has("goodsName") '>and goods_name = #{goodsName}</if>
  96. <if test=' this.has("grossWeight") '>and gross_weight = #{grossWeight}</if>
  97. <if test=' this.has("num") '>and num = #{num}</if>
  98. <if test=' this.has("productionDate") '>and production_date = #{productionDate}</if>
  99. <if test=' this.has("expirationDate") '>and expiration_date = #{expirationDate}</if>
  100. <if test=' this.has("storageMode") '>and storage_mode = #{storageMode}</if>
  101. <if test=' this.has("productionMode") '>and production_mode = #{productionMode}</if>
  102. <if test=' this.has("origin") '>and origin = #{origin}</if>
  103. <if test=' this.has("producerCode") '>and producer_code = #{producerCode}</if>
  104. <if test=' this.has("sendUnit") '>and send_unit = #{sendUnit}</if>
  105. <if test=' this.has("receiveUnit") '>and receive_unit = #{receiveUnit}</if>
  106. <if test=' this.has("route") '>and route = #{route}</if>
  107. <if test=' this.has("driverName") '>and driver_name = #{driverName}</if>
  108. <if test=' this.has("driverPhone") '>and driver_phone = #{driverPhone}</if>
  109. <if test=' this.has("agent") '>and agent = #{agent}</if>
  110. <if test=' this.has("agentPhone") '>and agent_phone = #{agentPhone}</if>
  111. <if test=' this.has("chinaCarNo") '>and china_car_no = #{chinaCarNo}</if>
  112. <if test=' this.has("carNo") '>and car_no = #{carNo}</if>
  113. <if test=' this.has("customProof") '>and custom_proof = #{customProof}</if>
  114. <if test=' this.has("quarantineProof") '>and quarantine_proof = #{quarantineProof}</if>
  115. <if test=' this.has("shop") '>and shop = #{shop}</if>
  116. <if test=' this.has("productionCode") '>and production_code = #{productionCode}</if>
  117. <if test=' this.has("containerCode") '>and container_code = #{containerCode}</if>
  118. <if test=' this.has("bind") '>and business_id is null or business_id=''</if>
  119. <if test=' this.has("declareNo") '>and (declare_no=#{declareNo} or business_id is null or business_id='')</if>
  120. </where>
  121. order by
  122. <choose>
  123. <when test='sortType == 1'>id desc</when>
  124. <when test='sortType == 2'>business_id desc</when>
  125. <when test='sortType == 3'>goods_name desc</when>
  126. <when test='sortType == 4'>gross_weight desc</when>
  127. <when test='sortType == 5'>num desc</when>
  128. <when test='sortType == 6'>production_date desc</when>
  129. <when test='sortType == 7'>expiration_date desc</when>
  130. <when test='sortType == 8'>storage_mode desc</when>
  131. <when test='sortType == 9'>production_mode desc</when>
  132. <when test='sortType == 10'>origin desc</when>
  133. <when test='sortType == 11'>producer_code desc</when>
  134. <when test='sortType == 12'>send_unit desc</when>
  135. <when test='sortType == 13'>receive_unit desc</when>
  136. <when test='sortType == 14'>route desc</when>
  137. <when test='sortType == 15'>driver_name desc</when>
  138. <when test='sortType == 16'>driver_phone desc</when>
  139. <when test='sortType == 17'>agent desc</when>
  140. <when test='sortType == 18'>agent_phone desc</when>
  141. <when test='sortType == 19'>china_car_no desc</when>
  142. <when test='sortType == 20'>car_no desc</when>
  143. <when test='sortType == 21'>custom_proof desc</when>
  144. <when test='sortType == 22'>quarantine_proof desc</when>
  145. <when test='sortType == 23'>shop desc</when>
  146. <when test='sortType == 24'>production_code desc</when>
  147. <when test='sortType == 25'>container_code desc</when>
  148. <otherwise>id desc</otherwise>
  149. </choose>
  150. </select>
  151. </mapper>