CustomerMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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.usoftchina.saas.document.mapper.CustomerMapper">
  4. <resultMap id="BaseResultMap" type="com.usoftchina.saas.document.entities.Customer">
  5. <id column="cu_id" jdbcType="INTEGER" property="id" />
  6. <result column="cu_code" jdbcType="VARCHAR" property="cu_code" />
  7. <result column="cu_name" jdbcType="VARCHAR" property="cu_name" />
  8. <result column="cu_uu" jdbcType="VARCHAR" property="cu_uu" />
  9. <result column="cu_type" jdbcType="VARCHAR" property="cu_type" />
  10. <result column="cu_begindate" jdbcType="TIMESTAMP" property="cu_begindate" />
  11. <result column="cu_beginaramount" jdbcType="DOUBLE" property="cu_beginaramount" />
  12. <result column="cu_beginprerecamount" jdbcType="DOUBLE" property="cu_beginprerecamount" />
  13. <result column="cu_promisedays" jdbcType="DOUBLE" property="cu_promisedays" />
  14. <result column="cu_taxrate" jdbcType="DOUBLE" property="cu_taxrate" />
  15. <result column="cu_sellerid" jdbcType="INTEGER" property="cu_sellerid" />
  16. <result column="cu_sellercode" jdbcType="VARCHAR" property="cu_sellercode" />
  17. <result column="cu_sellername" jdbcType="VARCHAR" property="cu_sellername" />
  18. <result column="cu_credit" jdbcType="DOUBLE" property="cu_credit" />
  19. <result column="cu_status" jdbcType="VARCHAR" property="cu_status" />
  20. <result column="cu_statuscode" jdbcType="VARCHAR" property="cu_statuscode" />
  21. <result column="cu_recordmanid" jdbcType="INTEGER" property="cu_recordmanid" />
  22. <result column="cu_recordman" jdbcType="VARCHAR" property="cu_recordman" />
  23. <result column="cu_recorddate" jdbcType="TIMESTAMP" property="cu_recorddate" />
  24. <result column="companyid" jdbcType="INTEGER" property="companyId" />
  25. <result column="updaterid" jdbcType="INTEGER" property="updaterId" />
  26. <result column="updatetime" jdbcType="TIMESTAMP" property="updateTime" />
  27. <result column="cu_text1" jdbcType="VARCHAR" property="cu_text1" />
  28. <result column="cu_text2" jdbcType="VARCHAR" property="cu_text2" />
  29. <result column="cu_text3" jdbcType="VARCHAR" property="cu_text3" />
  30. <result column="cu_text4" jdbcType="VARCHAR" property="cu_text4" />
  31. <result column="cu_text5" jdbcType="VARCHAR" property="cu_text5" />
  32. <result column="cu_leftamount" jdbcType="DOUBLE" property="cu_leftamount" />
  33. <result column="cu_recamount" jdbcType="DOUBLE" property="cu_recamount" />
  34. </resultMap>
  35. <sql id="Base_Column_List">
  36. cu_id, cu_code, cu_name, cu_uu, cu_type, cu_begindate, cu_beginaramount, cu_beginprerecamount,
  37. cu_promisedays, cu_taxrate, cu_sellerid, cu_sellercode, cu_sellername, cu_credit,
  38. cu_status, cu_statuscode, cu_recordmanid, cu_recordman, cu_recorddate, companyid,
  39. updaterid, updatetime, cu_text1, cu_text2, cu_text3, cu_text4, cu_text5, cu_leftamount,
  40. cu_recamount
  41. </sql>
  42. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  43. select
  44. <include refid="Base_Column_List" />
  45. from customer
  46. where cu_id = #{cu_id,jdbcType=INTEGER}
  47. </select>
  48. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  49. delete from customer
  50. where cu_id = #{cu_id,jdbcType=INTEGER}
  51. </delete>
  52. <insert id="insertSelective" parameterType="com.usoftchina.saas.document.entities.Customer">
  53. <selectKey resultType="java.lang.Long" keyProperty="id">
  54. SELECT LAST_INSERT_ID() AS ID
  55. </selectKey>
  56. insert into customer
  57. <trim prefix="(" suffix=")" suffixOverrides=",">
  58. <if test="cu_code != null">
  59. cu_code,
  60. </if>
  61. <if test="cu_name != null">
  62. cu_name,
  63. </if>
  64. <if test="cu_uu != null">
  65. cu_uu,
  66. </if>
  67. <if test="cu_type != null">
  68. cu_type,
  69. </if>
  70. <if test="cu_begindate != null">
  71. cu_begindate,
  72. </if>
  73. <if test="cu_beginaramount != null">
  74. cu_beginaramount,
  75. </if>
  76. <if test="cu_beginprerecamount != null">
  77. cu_beginprerecamount,
  78. </if>
  79. <if test="cu_promisedays != null">
  80. cu_promisedays,
  81. </if>
  82. <if test="cu_taxrate != null">
  83. cu_taxrate,
  84. </if>
  85. <if test="cu_sellerid != null">
  86. cu_sellerid,
  87. </if>
  88. <if test="cu_sellercode != null">
  89. cu_sellercode,
  90. </if>
  91. <if test="cu_sellername != null">
  92. cu_sellername,
  93. </if>
  94. <if test="cu_credit != null">
  95. cu_credit,
  96. </if>
  97. <if test="cu_status != null">
  98. cu_status,
  99. </if>
  100. <if test="cu_statuscode != null">
  101. cu_statuscode,
  102. </if>
  103. <if test="cu_recordmanid != null">
  104. cu_recordmanid,
  105. </if>
  106. <if test="cu_recordman != null">
  107. cu_recordman,
  108. </if>
  109. <if test="cu_recorddate != null">
  110. cu_recorddate,
  111. </if>
  112. <if test="companyId != null">
  113. companyid,
  114. </if>
  115. <if test="updaterId != null">
  116. updaterid,
  117. </if>
  118. <if test="updateTime != null">
  119. updatetime,
  120. </if>
  121. <if test="cu_text1 != null">
  122. cu_text1,
  123. </if>
  124. <if test="cu_text2 != null">
  125. cu_text2,
  126. </if>
  127. <if test="cu_text3 != null">
  128. cu_text3,
  129. </if>
  130. <if test="cu_text4 != null">
  131. cu_text4,
  132. </if>
  133. <if test="cu_text5 != null">
  134. cu_text5,
  135. </if>
  136. <if test="cu_leftamount != null">
  137. cu_leftamount,
  138. </if>
  139. <if test="cu_recamount != null">
  140. cu_recamount,
  141. </if>
  142. </trim>
  143. <trim prefix="values (" suffix=")" suffixOverrides=",">
  144. <if test="cu_code != null">
  145. #{cu_code,jdbcType=VARCHAR},
  146. </if>
  147. <if test="cu_name != null">
  148. #{cu_name,jdbcType=VARCHAR},
  149. </if>
  150. <if test="cu_uu != null">
  151. #{cu_uu,jdbcType=VARCHAR},
  152. </if>
  153. <if test="cu_type != null">
  154. #{cu_type,jdbcType=VARCHAR},
  155. </if>
  156. <if test="cu_begindate != null">
  157. #{cu_begindate,jdbcType=TIMESTAMP},
  158. </if>
  159. <if test="cu_beginaramount != null">
  160. #{cu_beginaramount,jdbcType=DOUBLE},
  161. </if>
  162. <if test="cu_beginprerecamount != null">
  163. #{cu_beginprerecamount,jdbcType=DOUBLE},
  164. </if>
  165. <if test="cu_promisedays != null">
  166. #{cu_promisedays,jdbcType=DOUBLE},
  167. </if>
  168. <if test="cu_taxrate != null">
  169. #{cu_taxrate,jdbcType=DOUBLE},
  170. </if>
  171. <if test="cu_sellerid != null">
  172. #{cu_sellerid,jdbcType=INTEGER},
  173. </if>
  174. <if test="cu_sellercode != null">
  175. #{cu_sellercode,jdbcType=VARCHAR},
  176. </if>
  177. <if test="cu_sellername != null">
  178. #{cu_sellername,jdbcType=VARCHAR},
  179. </if>
  180. <if test="cu_credit != null">
  181. #{cu_credit,jdbcType=DOUBLE},
  182. </if>
  183. <if test="cu_status != null">
  184. #{cu_status,jdbcType=VARCHAR},
  185. </if>
  186. <if test="cu_statuscode != null">
  187. #{cu_statuscode,jdbcType=VARCHAR},
  188. </if>
  189. <if test="cu_recordmanid != null">
  190. #{cu_recordmanid,jdbcType=INTEGER},
  191. </if>
  192. <if test="cu_recordman != null">
  193. #{cu_recordman,jdbcType=VARCHAR},
  194. </if>
  195. <if test="cu_recorddate != null">
  196. #{cu_recorddate,jdbcType=TIMESTAMP},
  197. </if>
  198. <if test="companyId != null">
  199. #{companyId,jdbcType=INTEGER},
  200. </if>
  201. <if test="updaterId != null">
  202. #{updaterId,jdbcType=INTEGER},
  203. </if>
  204. <if test="updateTime != null">
  205. #{updateTime,jdbcType=TIMESTAMP},
  206. </if>
  207. <if test="cu_text1 != null">
  208. #{cu_text1,jdbcType=VARCHAR},
  209. </if>
  210. <if test="cu_text2 != null">
  211. #{cu_text2,jdbcType=VARCHAR},
  212. </if>
  213. <if test="cu_text3 != null">
  214. #{cu_text3,jdbcType=VARCHAR},
  215. </if>
  216. <if test="cu_text4 != null">
  217. #{cu_text4,jdbcType=VARCHAR},
  218. </if>
  219. <if test="cu_text5 != null">
  220. #{cu_text5,jdbcType=VARCHAR},
  221. </if>
  222. <if test="cu_leftamount != null">
  223. #{cu_leftamount,jdbcType=DOUBLE},
  224. </if>
  225. <if test="cu_recamount != null">
  226. #{cu_recamount,jdbcType=DOUBLE},
  227. </if>
  228. </trim>
  229. </insert>
  230. <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.Customer">
  231. update customer
  232. <set>
  233. <if test="cu_code != null">
  234. cu_code = #{cu_code,jdbcType=VARCHAR},
  235. </if>
  236. <if test="cu_name != null">
  237. cu_name = #{cu_name,jdbcType=VARCHAR},
  238. </if>
  239. <if test="cu_uu != null">
  240. cu_uu = #{cu_uu,jdbcType=VARCHAR},
  241. </if>
  242. <if test="cu_type != null">
  243. cu_type = #{cu_type,jdbcType=VARCHAR},
  244. </if>
  245. <if test="cu_begindate != null">
  246. cu_begindate = #{cu_begindate,jdbcType=TIMESTAMP},
  247. </if>
  248. <if test="cu_beginaramount != null">
  249. cu_beginaramount = #{cu_beginaramount,jdbcType=DOUBLE},
  250. </if>
  251. <if test="cu_beginprerecamount != null">
  252. cu_beginprerecamount = #{cu_beginprerecamount,jdbcType=DOUBLE},
  253. </if>
  254. <if test="cu_promisedays != null">
  255. cu_promisedays = #{cu_promisedays,jdbcType=DOUBLE},
  256. </if>
  257. <if test="cu_taxrate != null">
  258. cu_taxrate = #{cu_taxrate,jdbcType=DOUBLE},
  259. </if>
  260. <if test="cu_sellerid != null">
  261. cu_sellerid = #{cu_sellerid,jdbcType=INTEGER},
  262. </if>
  263. <if test="cu_sellercode != null">
  264. cu_sellercode = #{cu_sellercode,jdbcType=VARCHAR},
  265. </if>
  266. <if test="cu_sellername != null">
  267. cu_sellername = #{cu_sellername,jdbcType=VARCHAR},
  268. </if>
  269. <if test="cu_credit != null">
  270. cu_credit = #{cu_credit,jdbcType=DOUBLE},
  271. </if>
  272. <if test="cu_status != null">
  273. cu_status = #{cu_status,jdbcType=VARCHAR},
  274. </if>
  275. <if test="cu_statuscode != null">
  276. cu_statuscode = #{cu_statuscode,jdbcType=VARCHAR},
  277. </if>
  278. <if test="cu_recordmanid != null">
  279. cu_recordmanid = #{cu_recordmanid,jdbcType=INTEGER},
  280. </if>
  281. <if test="cu_recordman != null">
  282. cu_recordman = #{cu_recordman,jdbcType=VARCHAR},
  283. </if>
  284. <if test="cu_recorddate != null">
  285. cu_recorddate = #{cu_recorddate,jdbcType=TIMESTAMP},
  286. </if>
  287. <if test="companyId != null">
  288. companyid = #{companyId,jdbcType=INTEGER},
  289. </if>
  290. <if test="updaterId != null">
  291. updaterid = #{updaterId,jdbcType=INTEGER},
  292. </if>
  293. <if test="updateTime != null">
  294. updatetime = #{updateTime,jdbcType=TIMESTAMP},
  295. </if>
  296. <if test="cu_text1 != null">
  297. cu_text1 = #{cu_text1,jdbcType=VARCHAR},
  298. </if>
  299. <if test="cu_text2 != null">
  300. cu_text2 = #{cu_text2,jdbcType=VARCHAR},
  301. </if>
  302. <if test="cu_text3 != null">
  303. cu_text3 = #{cu_text3,jdbcType=VARCHAR},
  304. </if>
  305. <if test="cu_text4 != null">
  306. cu_text4 = #{cu_text4,jdbcType=VARCHAR},
  307. </if>
  308. <if test="cu_text5 != null">
  309. cu_text5 = #{cu_text5,jdbcType=VARCHAR},
  310. </if>
  311. <if test="cu_leftamount != null">
  312. cu_leftamount = #{cu_leftamount,jdbcType=DOUBLE},
  313. </if>
  314. <if test="cu_recamount != null">
  315. cu_recamount = #{cu_recamount,jdbcType=DOUBLE},
  316. </if>
  317. </set>
  318. where cu_id = #{id,jdbcType=INTEGER}
  319. </update>
  320. <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.document.entities.Customer">
  321. update customer
  322. set cu_code = #{cu_code,jdbcType=VARCHAR},
  323. cu_name = #{cu_name,jdbcType=VARCHAR},
  324. cu_uu = #{cu_uu,jdbcType=VARCHAR},
  325. cu_type = #{cu_type,jdbcType=VARCHAR},
  326. cu_begindate = #{cu_begindate,jdbcType=TIMESTAMP},
  327. cu_beginaramount = #{cu_beginaramount,jdbcType=DOUBLE},
  328. cu_beginprerecamount = #{cu_beginprerecamount,jdbcType=DOUBLE},
  329. cu_promisedays = #{cu_promisedays,jdbcType=DOUBLE},
  330. cu_taxrate = #{cu_taxrate,jdbcType=DOUBLE},
  331. cu_sellerid = #{cu_sellerid,jdbcType=INTEGER},
  332. cu_sellercode = #{cu_sellercode,jdbcType=VARCHAR},
  333. cu_sellername = #{cu_sellername,jdbcType=VARCHAR},
  334. cu_credit = #{cu_credit,jdbcType=DOUBLE},
  335. cu_status = #{cu_status,jdbcType=VARCHAR},
  336. cu_statuscode = #{cu_statuscode,jdbcType=VARCHAR},
  337. cu_recordmanid = #{cu_recordmanid,jdbcType=INTEGER},
  338. cu_recordman = #{cu_recordman,jdbcType=VARCHAR},
  339. cu_recorddate = #{cu_recorddate,jdbcType=TIMESTAMP},
  340. companyid = #{companyid,jdbcType=INTEGER},
  341. updaterid = #{updaterid,jdbcType=INTEGER},
  342. updatetime = #{updatetime,jdbcType=TIMESTAMP},
  343. cu_text1 = #{cu_text1,jdbcType=VARCHAR},
  344. cu_text2 = #{cu_text2,jdbcType=VARCHAR},
  345. cu_text3 = #{cu_text3,jdbcType=VARCHAR},
  346. cu_text4 = #{cu_text4,jdbcType=VARCHAR},
  347. cu_text5 = #{cu_text5,jdbcType=VARCHAR},
  348. cu_leftamount = #{cu_leftamount,jdbcType=DOUBLE},
  349. cu_recamount = #{cu_recamount,jdbcType=DOUBLE}
  350. where cu_id = #{id,jdbcType=INTEGER}
  351. </update>
  352. <select id="validateCodeWhenInsert" resultType="int">
  353. select count(1) from customer where cu_code = #{code} and companyId =#{companyId}
  354. </select>
  355. <select id="validateCodeWhenUpdate" resultType="int" >
  356. select count(1) from customer where cu_code = #{code} and cu_id != #{id} and companyId =#{companyId}
  357. </select>
  358. <select id="selectCodeById" parameterType="java.lang.Long" resultType="string">
  359. select
  360. cu_code
  361. from customer
  362. where cu_id = #{id,jdbcType=INTEGER}
  363. </select>
  364. </mapper>