CustomerMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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.bz.smart_city.dao.CustomerMapper">
  4. <!--auto generated Code-->
  5. <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.Customer">
  6. <result column="id" property="id" jdbcType="INTEGER"/>
  7. <result column="site_id" property="siteId" jdbcType="INTEGER"/>
  8. <result column="customer_name" property="customerName" jdbcType="VARCHAR"/>
  9. <result column="customer_phone" property="customerPhone" jdbcType="VARCHAR"/>
  10. <result column="customer_contact_person" property="customerContactPerson" jdbcType="VARCHAR"/>
  11. <result column="push_url" property="pushUrl" jdbcType="VARCHAR"/>
  12. <result column="customer_no" property="customerNo" jdbcType="VARCHAR"/>
  13. <result column="token" property="token" jdbcType="VARCHAR"/>
  14. <result column="remark" property="remark" jdbcType="VARCHAR"/>
  15. <result column="status" property="status" jdbcType="INTEGER"/>
  16. <result column="customer_org_id" property="customerOrgId" jdbcType="INTEGER"/>
  17. <result column="date_create" property="dateCreate" jdbcType="TIMESTAMP"/>
  18. <result column="date_update" property="dateUpdate" jdbcType="TIMESTAMP"/>
  19. <result column="create_by" property="createBy" jdbcType="VARCHAR"/>
  20. <result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
  21. <result column="parent_id" property="parentId" jdbcType="INTEGER"/>
  22. <result column="children_num" property="childrenNum" jdbcType="INTEGER"/>
  23. </resultMap>
  24. <!--auto generated Code-->
  25. <sql id="Base_Column_List">
  26. id,
  27. site_id,
  28. customer_name,
  29. customer_phone,
  30. customer_contact_person,
  31. push_url,
  32. customer_no,
  33. token,
  34. remark,
  35. `status`,
  36. customer_org_id,
  37. date_create,
  38. date_update,
  39. create_by,
  40. update_by,
  41. parent_id,
  42. children_num
  43. </sql>
  44. <!--auto generated Code-->
  45. <insert id="insert" useGeneratedKeys="true" keyProperty="customer.id">
  46. INSERT INTO sc_customer (
  47. id,
  48. site_id,
  49. customer_name,
  50. customer_phone,
  51. customer_contact_person,
  52. push_url,
  53. customer_no,
  54. token,
  55. remark,
  56. `status`,
  57. customer_org_id,
  58. date_create,
  59. date_update,
  60. create_by,
  61. update_by,
  62. parent_id,
  63. children_num
  64. ) VALUES (
  65. #{customer.id,jdbcType=INTEGER},
  66. #{customer.siteId,jdbcType=INTEGER},
  67. #{customer.customerName,jdbcType=VARCHAR},
  68. #{customer.customerPhone,jdbcType=VARCHAR},
  69. #{customer.customerContactPerson,jdbcType=VARCHAR},
  70. #{customer.pushUrl,jdbcType=VARCHAR},
  71. #{customer.customerNo,jdbcType=VARCHAR}
  72. #{customer.token,jdbcType=VARCHAR}
  73. #{customer.remark,jdbcType=VARCHAR},
  74. #{customer.status,jdbcType=INTEGER},
  75. #{customer.customerOrgId,jdbcType=INTEGER},
  76. #{customer.dateCreate,jdbcType=TIMESTAMP},
  77. #{customer.dateUpdate,jdbcType=TIMESTAMP},
  78. #{customer.createBy,jdbcType=VARCHAR},
  79. #{customer.updateBy,jdbcType=VARCHAR},
  80. #{customer.parentId,jdbcType=INTEGER},
  81. #{customer.childrenNum,jdbcType=INTEGER}
  82. )
  83. </insert>
  84. <!--auto generated Code-->
  85. <insert id="insertSelective" useGeneratedKeys="true" keyProperty="customer.id">
  86. INSERT INTO sc_customer
  87. <trim prefix="(" suffix=")" suffixOverrides=",">
  88. <if test="customer.id!=null"> id,</if>
  89. <if test="customer.siteId!=null"> site_id,</if>
  90. <if test="customer.customerName!=null"> customer_name,</if>
  91. <if test="customer.customerPhone!=null"> customer_phone,</if>
  92. <if test="customer.customerContactPerson!=null"> customer_contact_person,</if>
  93. <if test="customer.pushUrl!=null"> push_url,</if>
  94. <if test="customer.customerNo!=null"> customer_no,</if>
  95. <if test="customer.token!=null"> token,</if>
  96. <if test="customer.remark!=null"> remark,</if>
  97. <if test="customer.status!=null"> `status`,</if>
  98. <if test="customer.customerOrgId!=null"> customer_org_id,</if>
  99. <if test="customer.dateCreate!=null"> date_create,</if>
  100. <if test="customer.dateUpdate!=null"> date_update,</if>
  101. <if test="customer.createBy!=null"> create_by,</if>
  102. <if test="customer.updateBy!=null"> update_by,</if>
  103. <if test="customer.parentId!=null"> parent_id,</if>
  104. <if test="customer.childrenNum!=null"> children_num,</if>
  105. </trim>
  106. VALUES
  107. <trim prefix="(" suffix=")" suffixOverrides=",">
  108. <if test="customer.id!=null">#{customer.id,jdbcType=INTEGER},
  109. </if>
  110. <if test="customer.siteId!=null">#{customer.siteId,jdbcType=INTEGER},
  111. </if>
  112. <if test="customer.customerName!=null">#{customer.customerName,jdbcType=VARCHAR},
  113. </if>
  114. <if test="customer.customerPhone!=null">#{customer.customerPhone,jdbcType=VARCHAR},
  115. </if>
  116. <if test="customer.customerContactPerson!=null">#{customer.customerContactPerson,jdbcType=VARCHAR},
  117. </if>
  118. <if test="customer.pushUrl!=null">#{customer.pushUrl,jdbcType=VARCHAR},
  119. </if>
  120. <if test="customer.customerNo!=null">#{customer.customerNo,jdbcType=VARCHAR},
  121. </if>
  122. <if test="customer.token!=null">#{customer.token,jdbcType=VARCHAR},
  123. </if>
  124. <if test="customer.remark!=null">#{customer.remark,jdbcType=VARCHAR},
  125. </if>
  126. <if test="customer.status!=null">#{customer.status,jdbcType=INTEGER},
  127. </if>
  128. <if test="customer.customerOrgId!=null">#{customer.customerOrgId,jdbcType=INTEGER},
  129. </if>
  130. <if test="customer.dateCreate!=null">#{customer.dateCreate,jdbcType=TIMESTAMP},
  131. </if>
  132. <if test="customer.dateUpdate!=null">#{customer.dateUpdate,jdbcType=TIMESTAMP},
  133. </if>
  134. <if test="customer.createBy!=null">#{customer.createBy,jdbcType=VARCHAR},
  135. </if>
  136. <if test="customer.updateBy!=null">#{customer.updateBy,jdbcType=VARCHAR},
  137. </if>
  138. <if test="customer.parentId!=null">#{customer.parentId,jdbcType=INTEGER},
  139. </if>
  140. <if test="customer.childrenNum!=null">#{customer.childrenNum,jdbcType=INTEGER},
  141. </if>
  142. </trim>
  143. </insert>
  144. <!--auto generated Code-->
  145. <insert id="insertList">
  146. INSERT INTO sc_customer (
  147. id,
  148. site_id,
  149. customer_name,
  150. customer_phone,
  151. customer_contact_person,
  152. push_url,
  153. customer_no,
  154. token,
  155. remark,
  156. `status`,
  157. customer_org_id,
  158. date_create,
  159. date_update,
  160. create_by,
  161. update_by,
  162. parent_id,
  163. children_num
  164. )VALUES
  165. <foreach collection="customers" item="customer" index="index" separator=",">
  166. (
  167. #{customer.id,jdbcType=INTEGER},
  168. #{customer.siteId,jdbcType=INTEGER},
  169. #{customer.customerName,jdbcType=VARCHAR},
  170. #{customer.customerPhone,jdbcType=VARCHAR},
  171. #{customer.customerContactPerson,jdbcType=VARCHAR},
  172. #{customer.pushUrl,jdbcType=VARCHAR},
  173. #{customer.customerNo,jdbcType=VARCHAR},
  174. #{customer.token,jdbcType=VARCHAR},
  175. #{customer.remark,jdbcType=VARCHAR},
  176. #{customer.status,jdbcType=INTEGER},
  177. #{customer.customerOrgId,jdbcType=INTEGER},
  178. #{customer.dateCreate,jdbcType=TIMESTAMP},
  179. #{customer.dateUpdate,jdbcType=TIMESTAMP},
  180. #{customer.createBy,jdbcType=VARCHAR},
  181. #{customer.updateBy,jdbcType=VARCHAR},
  182. #{customer.parentId,jdbcType=INTEGER},
  183. #{customer.childrenNum,jdbcType=INTEGER}
  184. )
  185. </foreach>
  186. </insert>
  187. <!--auto generated Code-->
  188. <update id="updateByPrimaryKeySelective">
  189. UPDATE sc_customer
  190. <set>
  191. <if test="customer.siteId != null"> site_id= #{customer.siteId,jdbcType=INTEGER},</if>
  192. <if test="customer.customerName != null"> customer_name= #{customer.customerName,jdbcType=VARCHAR},</if>
  193. <if test="customer.customerPhone != null"> customer_phone= #{customer.customerPhone,jdbcType=VARCHAR},</if>
  194. <if test="customer.customerContactPerson != null"> customer_contact_person= #{customer.customerContactPerson,jdbcType=VARCHAR},</if>
  195. <if test="customer.pushUrl != null"> push_url= #{customer.pushUrl,jdbcType=VARCHAR},</if>
  196. <if test="customer.customerNo != null"> customer_no= #{customer.customerNo,jdbcType=VARCHAR},</if>
  197. <if test="customer.token != null"> token= #{customer.token,jdbcType=VARCHAR},</if>
  198. <if test="customer.remark != null"> remark= #{customer.remark,jdbcType=VARCHAR},</if>
  199. <if test="customer.status != null"> `status`= #{customer.status,jdbcType=INTEGER},</if>
  200. <if test="customer.customerOrgId != null"> customer_org_id= #{customer.customerOrgId,jdbcType=INTEGER},</if>
  201. <if test="customer.dateCreate != null"> date_create= #{customer.dateCreate,jdbcType=TIMESTAMP},</if>
  202. <if test="customer.dateUpdate != null"> date_update= #{customer.dateUpdate,jdbcType=TIMESTAMP},</if>
  203. <if test="customer.createBy != null"> create_by= #{customer.createBy,jdbcType=VARCHAR},</if>
  204. <if test="customer.updateBy != null"> update_by= #{customer.updateBy,jdbcType=VARCHAR},</if>
  205. <if test="customer.parentId != null"> parent_id= #{customer.parentId,jdbcType=INTEGER},</if>
  206. <if test="customer.childrenNum != null"> children_num= #{customer.childrenNum,jdbcType=INTEGER}</if>
  207. </set>
  208. WHERE id = #{customer.id,jdbcType=INTEGER}
  209. </update>
  210. <select id="getList" resultMap="BaseResultMap">
  211. select id,customer_name from sc_customer where status = 1
  212. <if test="siteId != null and siteId != 0 "> and site_id = #{siteId,jdbcType=INTEGER}</if>
  213. </select>
  214. <select id="getCustomerList" resultType="com.bz.smart_city.dto.CustomerDto">
  215. select <include refid="Base_Column_List"></include> from sc_customer
  216. where status = 1
  217. <if test="siteId != null"> and site_id = #{siteId} </if>
  218. <if test="customerName != null and customerName != ''"> and customer_name like concat('%',#{customerName} ,'%')</if>
  219. order by date_create desc
  220. </select>
  221. <select id="findByNameUnique" resultType="int">
  222. select count(1) from sc_customer where status = 1 and customer_name = #{customerName}
  223. <if test="siteId != null"> and site_id = #{siteId} </if>
  224. <if test="id != null"> and id != #{id}</if>
  225. </select>
  226. <select id="findByNoUnique" resultType="int">
  227. select count(1) from sc_customer where status = 1 and customer_no = #{customerNo}
  228. </select>
  229. <select id="findById" resultMap="BaseResultMap">
  230. select <include refid="Base_Column_List"/> from sc_customer where status = 1 and id = #{customerId}
  231. </select>
  232. <select id="findByIds" resultType="com.bz.smart_city.entity.Customer">
  233. select <include refid="Base_Column_List"></include> from sc_customer where 1 = 1
  234. <if test="ids != null">
  235. and id in <foreach collection="ids" item="item" open="(" separator="," close=")">#{item}</foreach>
  236. </if>
  237. </select>
  238. <select id="getListById" resultMap="BaseResultMap">
  239. select id,customer_name,customer_no from sc_customer where status = 1
  240. and id = #{customerId}
  241. </select>
  242. <select id="getCustomerTree" resultType="com.bz.smart_city.dto.CustomerDto">
  243. select <include refid="Base_Column_List"></include> from sc_customer
  244. where status = 1
  245. <if test="siteId != null"> and site_id = #{siteId} </if>
  246. <if test="customerName != null and customerName != ''"> and customer_name like concat('%',#{customerName} ,'%')</if>
  247. order by date_create desc
  248. </select>
  249. <select id="countChildrenNum" resultType="java.lang.Integer">
  250. select count(1) from sc_customer where status = 1 and parent_id = #{customerId}
  251. </select>
  252. <select id="getCustomerByCustomerno" resultType="com.bz.smart_city.dto.CustomerDto">
  253. select <include refid="Base_Column_List"></include> from sc_customer
  254. where status = 1 and customer_no = #{customerNo}
  255. order by date_create desc
  256. </select>
  257. </mapper>