MastFarmerMapper.xml 17 KB

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