QpSupplierMapper.xml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.zd.airbottle.mapper.QpSupplierMapper">
  6. <resultMap type="com.zd.airbottle.domain.QpSupplier" id="QpSupplierResult">
  7. <result property="id" column="id"/>
  8. <result property="companyName" column="company_name"/>
  9. <result property="companyShort" column="company_short"/>
  10. <result property="contacts" column="contacts"/>
  11. <result property="phone" column="phone"/>
  12. <result property="auditTime" column="audit_time"/>
  13. <result property="accountId" column="account_id"/>
  14. <result property="deptId" column="dept_id"/>
  15. <result property="deptName" column="dept_name"/>
  16. <result property="state" column="state"/>
  17. <result property="status" column="status"/>
  18. <result property="businessRecord" column="business_record"/>
  19. <result property="businessAddress" column="business_address"/>
  20. <result property="createBy" column="create_by"/>
  21. <result property="userId" column="user_id"/>
  22. <result property="updateTime" column="update_time"/>
  23. <result property="updateBy" column="update_by"/>
  24. <result property="createTime" column="create_time"/>
  25. </resultMap>
  26. <sql id="selectQpSupplierVo">
  27. select id,
  28. company_name,
  29. company_short,
  30. contacts,
  31. phone,
  32. account_id,
  33. dept_id,
  34. dept_name,
  35. audit_time,
  36. state,
  37. status,
  38. business_record,
  39. business_address,
  40. create_by,
  41. user_id,
  42. update_time,
  43. update_by,
  44. create_time
  45. from qp_supplier
  46. </sql>
  47. <sql id="selectQpSupplierListVo">
  48. select t.id,
  49. t.company_name,
  50. t.company_short,
  51. t.contacts,
  52. t.phone,
  53. t.account_id,
  54. t.dept_id,
  55. t.dept_name,
  56. t.audit_time,
  57. t.state,
  58. t.status,
  59. t.business_record,
  60. t.business_address,
  61. t.create_by,
  62. t.user_id,
  63. t.update_time,
  64. t.update_by,
  65. t.create_time
  66. from qp_supplier as t
  67. </sql>
  68. <select id="selectQpSupplierList" parameterType="com.zd.airbottle.domain.QpSupplier" resultMap="QpSupplierResult">
  69. <include refid="selectQpSupplierListVo"/>
  70. <where>
  71. <if test="companyName != null and companyName != ''">and t.company_name like concat('%', #{companyName},
  72. '%')
  73. </if>
  74. <if test="companyShort != null and companyShort != ''">and t.company_short = #{companyShort}</if>
  75. <if test="contacts != null and contacts != ''">and t.contacts = #{contacts}</if>
  76. <if test="state != null ">and t.state = #{state}</if>
  77. <if test="status != null ">and t.status = #{status}</if>
  78. <if test="accountId != null ">and t.account_id = #{accountId}</if>
  79. <if test="deptId != null ">and t.dept_id = #{deptId}</if>
  80. <if test="deptName != null ">and t.dept_name = #{deptName}</if>
  81. <if test="auditTime != null ">and t.audit_time = #{auditTime}</if>
  82. <if test="phone != null and phone != ''">and t.phone = #{phone}</if>
  83. <if test="businessRecord != null and businessRecord != ''">and t.business_record = #{businessRecord}</if>
  84. <if test="businessAddress != null and businessAddress != ''">and t.business_address = #{businessAddress}</if>
  85. <if test="userId != null ">and t.user_id = #{userId}</if>
  86. <if test="searchValue !=null and searchValue!=''">
  87. and (t.company_name like concat('%', #{searchValue},
  88. '%')
  89. or t.contacts like concat('%', #{searchValue},
  90. '%')
  91. or t.phone like concat('%', #{searchValue},
  92. '%'))
  93. </if>
  94. <if test="ids !=null and ids.size>0">
  95. and t.id in
  96. <foreach item="id" collection="ids" open="(" separator="," close=")">
  97. #{id}
  98. </foreach>
  99. </if>
  100. </where>
  101. </select>
  102. <select id="selectQpSupplierById" parameterType="java.lang.Long" resultMap="QpSupplierResult">
  103. <include refid="selectQpSupplierVo"/>
  104. where id = #{id}
  105. </select>
  106. <select id="checkName" resultType="java.lang.Boolean">
  107. select count(*) from qp_supplier
  108. where
  109. <choose>
  110. <when test="name!=null and name !='' and type!=null and type=2">
  111. company_short = #{name}
  112. </when>
  113. <otherwise>
  114. company_name like concat('%', #{name}, '%')
  115. </otherwise>
  116. </choose>
  117. </select>
  118. <select id="selectQpSupplierListByIds" resultType="com.zd.airbottle.domain.QpSupplier">
  119. <include refid="selectQpSupplierVo"/>
  120. where id in
  121. <foreach item="id" collection="array" open="(" separator="," close=")">
  122. #{id}
  123. </foreach>
  124. </select>
  125. <select id="selectQpSupplierByAccountId" resultType="com.zd.airbottle.domain.QpSupplier">
  126. <include refid="selectQpSupplierVo"/>
  127. where account_id = #{accountId}
  128. </select>
  129. <select id="getByIds" resultType="com.zd.airbottle.domain.QpSupplier">
  130. <include refid="selectQpSupplierVo"/>
  131. where id in
  132. <foreach item="id" collection="list" open="(" separator="," close=")">
  133. #{id}
  134. </foreach>
  135. </select>
  136. <insert id="insertQpSupplier" parameterType="com.zd.airbottle.domain.QpSupplier" useGeneratedKeys="true"
  137. keyProperty="id">
  138. insert into qp_supplier
  139. <trim prefix="(" suffix=")" suffixOverrides=",">
  140. <if test="companyName != null">company_name,</if>
  141. <if test="companyShort != null">company_short,</if>
  142. <if test="contacts != null">contacts,</if>
  143. <if test="phone != null">phone,</if>
  144. <if test="accountId != null">account_id,</if>
  145. <if test="deptId != null">dept_id,</if>
  146. <if test="deptName != null">dept_name,</if>
  147. <if test="auditTime != null">audit_time,</if>
  148. <if test="state != null">state,</if>
  149. <if test="status != null">status,</if>
  150. <if test="businessRecord != null">business_record,</if>
  151. <if test="businessAddress != null">business_address,</if>
  152. <if test="createBy != null">create_by,</if>
  153. <if test="userId != null">user_id,</if>
  154. <if test="updateTime != null">update_time,</if>
  155. <if test="updateBy != null">update_by,</if>
  156. <if test="createTime != null">create_time,</if>
  157. </trim>
  158. <trim prefix="values (" suffix=")" suffixOverrides=",">
  159. <if test="companyName != null">#{companyName},</if>
  160. <if test="companyShort != null">#{companyShort},</if>
  161. <if test="contacts != null">#{contacts},</if>
  162. <if test="phone != null">#{phone},</if>
  163. <if test="accountId != null">#{accountId},</if>
  164. <if test="deptId != null">#{deptId},</if>
  165. <if test="deptName != null">#{deptName},</if>
  166. <if test="auditTime != null">#{auditTime},</if>
  167. <if test="state != null">#{state},</if>
  168. <if test="status != null">#{status},</if>
  169. <if test="businessRecord != null">#{businessRecord},</if>
  170. <if test="businessAddress != null">#{businessAddress},</if>
  171. <if test="createBy != null">#{createBy},</if>
  172. <if test="userId != null">#{userId},</if>
  173. <if test="updateTime != null">#{updateTime},</if>
  174. <if test="updateBy != null">#{updateBy},</if>
  175. <if test="createTime != null">#{createTime},</if>
  176. </trim>
  177. </insert>
  178. <update id="updateQpSupplier" parameterType="com.zd.airbottle.domain.QpSupplier">
  179. update qp_supplier
  180. <trim prefix="SET" suffixOverrides=",">
  181. <if test="companyName != null">company_name = #{companyName},</if>
  182. <if test="companyShort != null">company_short = #{companyShort},</if>
  183. <if test="contacts != null">contacts = #{contacts},</if>
  184. <if test="phone != null">phone = #{phone},</if>
  185. <if test="accountId != null">account_id=#{accountId},</if>
  186. <if test="auditTime != null">audit_time = #{auditTime},</if>
  187. <if test="state != null">state = #{state},</if>
  188. <if test="status != null">status = #{status},</if>
  189. <if test="businessRecord != null">business_record = #{businessRecord},</if>
  190. <if test="businessAddress != null">business_address = #{businessAddress},</if>
  191. <if test="createBy != null">create_by = #{createBy},</if>
  192. <if test="userId != null">user_id = #{userId},</if>
  193. <if test="updateTime != null">update_time = #{updateTime},</if>
  194. <if test="updateBy != null">update_by = #{updateBy},</if>
  195. <if test="createTime != null">create_time = #{createTime},</if>
  196. </trim>
  197. where id = #{id}
  198. </update>
  199. <delete id="deleteQpSupplierById">
  200. delete
  201. from qp_supplier
  202. where id = #{id}
  203. </delete>
  204. <delete id="deleteQpSupplierByIds">
  205. delete from qp_supplier where id in
  206. <foreach item="id" collection="array" open="(" separator="," close=")">
  207. #{id}
  208. </foreach>
  209. </delete>
  210. </mapper>