MastCustomerMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  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="jp.yamoto.farm.crm.biz.master.mapper.MastCustomerMapper">
  6. <resultMap type="MastCustomerVo" id="MastCustomerResult">
  7. <result property="id" column="id"/>
  8. <result property="customerId" column="customer_id"/>
  9. <result property="firstName" column="first_name"/>
  10. <result property="lastName" column="last_name"/>
  11. <result property="customerName" column="customer_name"/>
  12. <result property="phoneNumber" column="phone_number"/>
  13. <result property="sysCustomerId" column="sys_customer_id"/>
  14. <result property="memberId" column="member_id"/>
  15. <result property="furiganaSei" column="furigana_sei"/>
  16. <result property="furiganaMei" column="furigana_mei"/>
  17. <result property="companyName" column="company_name"/>
  18. <result property="departmentName" column="department_name"/>
  19. <result property="postalCode" column="postal_code"/>
  20. <result property="prefecture" column="prefecture"/>
  21. <result property="city" column="city"/>
  22. <result property="townStreetArea" column="town_street_area"/>
  23. <result property="buildingEtc" column="building_etc"/>
  24. <result property="address" column="address"/>
  25. <result property="mailAddress" column="mail_address"/>
  26. <result property="mobile" column="mobile"/>
  27. <result property="fax" column="fax"/>
  28. <result property="farmerId" column="farmer_id"/>
  29. <result property="discontinuedFlg" column="discontinued_flg"/>
  30. <result property="discontinuedDate" column="discontinued_date"/>
  31. <result property="createTime" column="create_time"/>
  32. <result property="createBy" column="create_by"/>
  33. <result property="createPgId" column="create_pg_id"/>
  34. <result property="updateTime" column="update_time"/>
  35. <result property="updateBy" column="update_by"/>
  36. <result property="updatePgId" column="update_pg_id"/>
  37. <result property="version" column="version"/>
  38. </resultMap>
  39. <sql id="selectMastCustomerVo">
  40. select
  41. id,
  42. customer_id,
  43. first_name,
  44. last_name,
  45. customer_name,
  46. phone_number,
  47. sys_customer_id,
  48. member_id,
  49. furigana_sei,
  50. furigana_mei,
  51. company_name,
  52. department_name,
  53. postal_code,
  54. prefecture,
  55. city,
  56. town_street_area,
  57. building_etc,
  58. address,
  59. mail_address,
  60. mobile,
  61. fax,
  62. farmer_id,
  63. discontinued_flg,
  64. discontinued_date,
  65. create_time,
  66. create_by,
  67. create_pg_id,
  68. update_time,
  69. update_by,
  70. update_pg_id,
  71. version
  72. from mast_customer
  73. </sql>
  74. <select id="selectList" parameterType="MastCustomer" resultMap="MastCustomerResult">
  75. <include refid="selectMastCustomerVo"/>
  76. <where>
  77. <if test="id != null and id != ''">
  78. and id = #{id}
  79. </if>
  80. <if test="customerId != null and customerId != ''">
  81. and customer_id = #{customerId}
  82. </if>
  83. <if test="firstName != null and firstName != ''">
  84. and first_name = #{firstName}
  85. </if>
  86. <if test="lastName != null and lastName != ''">
  87. and last_name = #{lastName}
  88. </if>
  89. <if test="customerName != null and customerName != ''">
  90. and customer_name = #{customerName}
  91. </if>
  92. <if test="phoneNumber != null and phoneNumber != ''">
  93. and phone_number = #{phoneNumber}
  94. </if>
  95. <if test="sysCustomerId != null and sysCustomerId != ''">
  96. and sys_customer_id = #{sysCustomerId}
  97. </if>
  98. <if test="memberId != null and memberId != ''">
  99. and member_id = #{memberId}
  100. </if>
  101. <if test="furiganaSei != null and furiganaSei != ''">
  102. and furigana_sei = #{furiganaSei}
  103. </if>
  104. <if test="furiganaMei != null and furiganaMei != ''">
  105. and furigana_mei = #{furiganaMei}
  106. </if>
  107. <if test="companyName != null and companyName != ''">
  108. and company_name = #{companyName}
  109. </if>
  110. <if test="departmentName != null and departmentName != ''">
  111. and department_name = #{departmentName}
  112. </if>
  113. <if test="postalCode != null and postalCode != ''">
  114. and postal_code = #{postalCode}
  115. </if>
  116. <if test="prefecture != null and prefecture != ''">
  117. and prefecture = #{prefecture}
  118. </if>
  119. <if test="city != null and city != ''">
  120. and city = #{city}
  121. </if>
  122. <if test="townStreetArea != null and townStreetArea != ''">
  123. and town_street_area = #{townStreetArea}
  124. </if>
  125. <if test="buildingEtc != null and buildingEtc != ''">
  126. and building_etc = #{buildingEtc}
  127. </if>
  128. <if test="address != null and address != ''">
  129. and address = #{address}
  130. </if>
  131. <if test="mailAddress != null and mailAddress != ''">
  132. and mail_address = #{mailAddress}
  133. </if>
  134. <if test="mobile != null and mobile != ''">
  135. and mobile = #{mobile}
  136. </if>
  137. <if test="fax != null and fax != ''">
  138. and fax = #{fax}
  139. </if>
  140. <if test="farmerId != null and farmerId != ''">
  141. and farmer_id = #{farmerId}
  142. </if>
  143. <if test="discontinuedFlg != null ">
  144. and discontinued_flg = #{discontinuedFlg}
  145. </if>
  146. <if test="discontinuedDate != null and discontinuedDate != ''">
  147. and discontinued_date = #{discontinuedDate}
  148. </if>
  149. </where>
  150. </select>
  151. <select id="selectById" parameterType="String" resultMap="MastCustomerResult">
  152. <include refid="selectMastCustomerVo"/>
  153. where id = #{id}
  154. </select>
  155. <select id="getCustomerIdCount" parameterType="String" resultType="java.lang.Integer">
  156. SELECT
  157. count(1)
  158. FROM
  159. mast_customer
  160. <where>
  161. <if test="customerId != null and customerId != ''">
  162. and customer_id = #{customerId}
  163. </if>
  164. </where>
  165. </select>
  166. <insert id="insert" parameterType="MastCustomer">
  167. insert into mast_customer
  168. <trim prefix="(" suffix=")" suffixOverrides=",">
  169. <if test="id != null">
  170. id,
  171. </if>
  172. <if test="customerId != null">
  173. customer_id,
  174. </if>
  175. <if test="firstName != null">
  176. first_name,
  177. </if>
  178. <if test="lastName != null">
  179. last_name,
  180. </if>
  181. <if test="customerName != null">
  182. customer_name,
  183. </if>
  184. <if test="phoneNumber != null">
  185. phone_number,
  186. </if>
  187. <if test="sysCustomerId != null">
  188. sys_customer_id,
  189. </if>
  190. <if test="memberId != null">
  191. member_id,
  192. </if>
  193. <if test="furiganaSei != null">
  194. furigana_sei,
  195. </if>
  196. <if test="furiganaMei != null">
  197. furigana_mei,
  198. </if>
  199. <if test="companyName != null">
  200. company_name,
  201. </if>
  202. <if test="departmentName != null">
  203. department_name,
  204. </if>
  205. <if test="postalCode != null">
  206. postal_code,
  207. </if>
  208. <if test="prefecture != null">
  209. prefecture,
  210. </if>
  211. <if test="city != null">
  212. city,
  213. </if>
  214. <if test="townStreetArea != null">
  215. town_street_area,
  216. </if>
  217. <if test="buildingEtc != null">
  218. building_etc,
  219. </if>
  220. <if test="address != null">
  221. address,
  222. </if>
  223. <if test="mailAddress != null">
  224. mail_address,
  225. </if>
  226. <if test="mobile != null">
  227. mobile,
  228. </if>
  229. <if test="fax != null">
  230. fax,
  231. </if>
  232. <if test="farmerId != null">
  233. farmer_id,
  234. </if>
  235. <if test="discontinuedFlg != null">
  236. discontinued_flg,
  237. </if>
  238. <if test="discontinuedDate != null">
  239. discontinued_date,
  240. </if>
  241. <if test="createTime != null">
  242. create_time,
  243. </if>
  244. <if test="createBy != null">
  245. create_by,
  246. </if>
  247. <if test="createPgId != null">
  248. create_pg_id,
  249. </if>
  250. <if test="updateTime != null">
  251. update_time,
  252. </if>
  253. <if test="updateBy != null">
  254. update_by,
  255. </if>
  256. <if test="updatePgId != null">
  257. update_pg_id,
  258. </if>
  259. <if test="version != null">
  260. version,
  261. </if>
  262. </trim>
  263. <trim prefix="values (" suffix=")" suffixOverrides=",">
  264. <if test="id != null">
  265. #{id},
  266. </if>
  267. <if test="customerId != null">
  268. #{customerId},
  269. </if>
  270. <if test="firstName != null">
  271. #{firstName},
  272. </if>
  273. <if test="lastName != null">
  274. #{lastName},
  275. </if>
  276. <if test="customerName != null">
  277. #{customerName},
  278. </if>
  279. <if test="phoneNumber != null">
  280. #{phoneNumber},
  281. </if>
  282. <if test="sysCustomerId != null">
  283. #{sysCustomerId},
  284. </if>
  285. <if test="memberId != null">
  286. #{memberId},
  287. </if>
  288. <if test="furiganaSei != null">
  289. #{furiganaSei},
  290. </if>
  291. <if test="furiganaMei != null">
  292. #{furiganaMei},
  293. </if>
  294. <if test="companyName != null">
  295. #{companyName},
  296. </if>
  297. <if test="departmentName != null">
  298. #{departmentName},
  299. </if>
  300. <if test="postalCode != null">
  301. #{postalCode},
  302. </if>
  303. <if test="prefecture != null">
  304. #{prefecture},
  305. </if>
  306. <if test="city != null">
  307. #{city},
  308. </if>
  309. <if test="townStreetArea != null">
  310. #{townStreetArea},
  311. </if>
  312. <if test="buildingEtc != null">
  313. #{buildingEtc},
  314. </if>
  315. <if test="address != null">
  316. #{address},
  317. </if>
  318. <if test="mailAddress != null">
  319. #{mailAddress},
  320. </if>
  321. <if test="mobile != null">
  322. #{mobile},
  323. </if>
  324. <if test="fax != null">
  325. #{fax},
  326. </if>
  327. <if test="farmerId != null">
  328. #{farmerId},
  329. </if>
  330. <if test="discontinuedFlg != null">
  331. #{discontinuedFlg},
  332. </if>
  333. <if test="discontinuedDate != null">
  334. #{discontinuedDate},
  335. </if>
  336. <if test="createTime != null">
  337. #{createTime},
  338. </if>
  339. <if test="createBy != null">
  340. #{createBy},
  341. </if>
  342. <if test="createPgId != null">
  343. #{createPgId},
  344. </if>
  345. <if test="updateTime != null">
  346. #{updateTime},
  347. </if>
  348. <if test="updateBy != null">
  349. #{updateBy},
  350. </if>
  351. <if test="updatePgId != null">
  352. #{updatePgId},
  353. </if>
  354. <if test="version != null">
  355. #{version},
  356. </if>
  357. </trim>
  358. </insert>
  359. <update id="update" parameterType="MastCustomer">
  360. update mast_customer
  361. <trim prefix="SET" suffixOverrides=",">
  362. <if test="id != null">
  363. id = #{id},
  364. </if>
  365. <if test="customerId != null">
  366. customer_id = #{customerId},
  367. </if>
  368. <if test="firstName != null">
  369. first_name = #{firstName},
  370. </if>
  371. <if test="lastName != null">
  372. last_name = #{lastName},
  373. </if>
  374. <if test="customerName != null">
  375. customer_name = #{customerName},
  376. </if>
  377. <if test="phoneNumber != null">
  378. phone_number = #{phoneNumber},
  379. </if>
  380. <if test="sysCustomerId != null">
  381. sys_customer_id = #{sysCustomerId},
  382. </if>
  383. <if test="memberId != null">
  384. member_id = #{memberId},
  385. </if>
  386. <if test="furiganaSei != null">
  387. furigana_sei = #{furiganaSei},
  388. </if>
  389. <if test="furiganaMei != null">
  390. furigana_mei = #{furiganaMei},
  391. </if>
  392. <if test="companyName != null">
  393. company_name = #{companyName},
  394. </if>
  395. <if test="departmentName != null">
  396. department_name = #{departmentName},
  397. </if>
  398. <if test="postalCode != null">
  399. postal_code = #{postalCode},
  400. </if>
  401. <if test="prefecture != null">
  402. prefecture = #{prefecture},
  403. </if>
  404. <if test="city != null">
  405. city = #{city},
  406. </if>
  407. <if test="townStreetArea != null">
  408. town_street_area = #{townStreetArea},
  409. </if>
  410. <if test="buildingEtc != null">
  411. building_etc = #{buildingEtc},
  412. </if>
  413. <if test="address != null">
  414. address = #{address},
  415. </if>
  416. <if test="mailAddress != null">
  417. mail_address = #{mailAddress},
  418. </if>
  419. <if test="mobile != null">
  420. mobile = #{mobile},
  421. </if>
  422. <if test="fax != null">
  423. fax = #{fax},
  424. </if>
  425. <if test="farmerId != null">
  426. farmer_id = #{farmerId},
  427. </if>
  428. <if test="discontinuedFlg != null">
  429. discontinued_flg = #{discontinuedFlg},
  430. </if>
  431. <if test="discontinuedDate != null">
  432. discontinued_date = #{discontinuedDate},
  433. </if>
  434. <if test="createTime != null">
  435. create_time = #{createTime},
  436. </if>
  437. <if test="createBy != null">
  438. create_by = #{createBy},
  439. </if>
  440. <if test="createPgId != null">
  441. create_pg_id = #{createPgId},
  442. </if>
  443. <if test="updateTime != null">
  444. update_time = #{updateTime},
  445. </if>
  446. <if test="updateBy != null">
  447. update_by = #{updateBy},
  448. </if>
  449. <if test="updatePgId != null">
  450. update_pg_id = #{updatePgId},
  451. </if>
  452. version = version + 1
  453. </trim>
  454. where
  455. id = #{id}
  456. and version = #{version}
  457. </update>
  458. <delete id="deleteById" parameterType="String">
  459. delete
  460. from
  461. mast_customer
  462. where
  463. id = #{id}
  464. </delete>
  465. <update id="deleteLogicByIdAndVersion" parameterType="MastOkyakusama">
  466. update
  467. mast_customer
  468. set
  469. haisi_flg = 1,
  470. version = version + 1,
  471. <if test="updateBy != null">
  472. update_by = #{updateBy},
  473. </if>
  474. <if test="updateTime != null">
  475. update_time = #{updateTime}
  476. </if>
  477. <where>
  478. <if test="customerId != null and customerId != ''">
  479. and customer_id = #{customerId}
  480. </if>
  481. and version = #{version}
  482. and haisi_flg = 0
  483. </where>
  484. </update>
  485. </mapper>