AddressMapper.xml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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.AddressMapper">
  4. <resultMap id="BaseResultMap" type="com.usoftchina.saas.document.entities.Address">
  5. <id column="ad_id" jdbcType="INTEGER" property="id" />
  6. <result column="ad_recorddate" jdbcType="TIMESTAMP" property="ad_recorddate" />
  7. <result column="companyId" jdbcType="INTEGER" property="companyId" />
  8. <result column="updaterId" jdbcType="INTEGER" property="updaterId" />
  9. <result column="updateTime" jdbcType="TIMESTAMP" property="updateTime" />
  10. <result column="ad_text1" jdbcType="VARCHAR" property="ad_text1" />
  11. <result column="ad_text2" jdbcType="VARCHAR" property="ad_text2" />
  12. <result column="ad_text3" jdbcType="VARCHAR" property="ad_text3" />
  13. <result column="ad_text4" jdbcType="VARCHAR" property="ad_text4" />
  14. <result column="ad_text5" jdbcType="VARCHAR" property="ad_text5" />
  15. </resultMap>
  16. <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.usoftchina.saas.document.entities.Address">
  17. <result column="ad_address" jdbcType="LONGVARCHAR" property="ad_address" />
  18. </resultMap>
  19. <sql id="Base_Column_List">
  20. ad_id, ad_recorddate, companyId, updaterId, updateTime, ad_text1, ad_text2, ad_text3,
  21. ad_text4, ad_text5
  22. </sql>
  23. <sql id="Blob_Column_List">
  24. ad_address
  25. </sql>
  26. <insert id="insert" parameterType="com.usoftchina.saas.document.entities.Address">
  27. <selectKey resultType="java.lang.Long" keyProperty="id">
  28. SELECT LAST_INSERT_ID() AS ID
  29. </selectKey>
  30. insert into address (ad_recorddate, companyId,
  31. updaterId, updateTime, ad_text1,
  32. ad_text2, ad_text3, ad_text4,
  33. ad_text5, ad_address)
  34. values (#{ad_recorddate,jdbcType=TIMESTAMP}, #{companyId,jdbcType=INTEGER},
  35. #{updaterId,jdbcType=INTEGER}, #{updateTime,jdbcType=TIMESTAMP}, #{ad_text1,jdbcType=VARCHAR},
  36. #{ad_text2,jdbcType=VARCHAR}, #{ad_text3,jdbcType=VARCHAR}, #{ad_text4,jdbcType=VARCHAR},
  37. #{ad_text5,jdbcType=VARCHAR}, #{ad_address,jdbcType=LONGVARCHAR})
  38. </insert>
  39. <insert id="insertSelective" parameterType="com.usoftchina.saas.document.entities.Address">
  40. <selectKey resultType="java.lang.Long" keyProperty="id">
  41. SELECT LAST_INSERT_ID() AS ID
  42. </selectKey>
  43. insert into address
  44. <trim prefix="(" suffix=")" suffixOverrides=",">
  45. <if test="ad_recorddate != null">
  46. ad_recorddate,
  47. </if>
  48. <if test="companyId != null">
  49. companyId,
  50. </if>
  51. <if test="updaterId != null">
  52. updaterId,
  53. </if>
  54. <if test="updateTime != null">
  55. updateTime,
  56. </if>
  57. <if test="ad_text1 != null">
  58. ad_text1,
  59. </if>
  60. <if test="ad_text2 != null">
  61. ad_text2,
  62. </if>
  63. <if test="ad_text3 != null">
  64. ad_text3,
  65. </if>
  66. <if test="ad_text4 != null">
  67. ad_text4,
  68. </if>
  69. <if test="ad_text5 != null">
  70. ad_text5,
  71. </if>
  72. <if test="ad_address != null">
  73. ad_address,
  74. </if>
  75. </trim>
  76. <trim prefix="values (" suffix=")" suffixOverrides=",">
  77. <if test="ad_recorddate != null">
  78. #{ad_recorddate,jdbcType=TIMESTAMP},
  79. </if>
  80. <if test="companyId != null">
  81. #{companyId,jdbcType=INTEGER},
  82. </if>
  83. <if test="updaterId != null">
  84. #{updaterId,jdbcType=INTEGER},
  85. </if>
  86. <if test="updateTime != null">
  87. #{updateTime,jdbcType=TIMESTAMP},
  88. </if>
  89. <if test="ad_text1 != null">
  90. #{ad_text1,jdbcType=VARCHAR},
  91. </if>
  92. <if test="ad_text2 != null">
  93. #{ad_text2,jdbcType=VARCHAR},
  94. </if>
  95. <if test="ad_text3 != null">
  96. #{ad_text3,jdbcType=VARCHAR},
  97. </if>
  98. <if test="ad_text4 != null">
  99. #{ad_text4,jdbcType=VARCHAR},
  100. </if>
  101. <if test="ad_text5 != null">
  102. #{ad_text5,jdbcType=VARCHAR},
  103. </if>
  104. <if test="ad_address != null">
  105. #{ad_address,jdbcType=LONGVARCHAR},
  106. </if>
  107. </trim>
  108. </insert>
  109. <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.Address">
  110. update address
  111. <set>
  112. <if test="ad_recorddate != null">
  113. ad_recorddate = #{ad_recorddate,jdbcType=TIMESTAMP},
  114. </if>
  115. <if test="companyId != null">
  116. companyId = #{companyId,jdbcType=INTEGER},
  117. </if>
  118. <if test="updaterId != null">
  119. updaterId = #{updaterId,jdbcType=INTEGER},
  120. </if>
  121. <if test="updateTime != null">
  122. updateTime = #{updateTime,jdbcType=TIMESTAMP},
  123. </if>
  124. <if test="ad_text1 != null">
  125. ad_text1 = #{ad_text1,jdbcType=VARCHAR},
  126. </if>
  127. <if test="ad_text2 != null">
  128. ad_text2 = #{ad_text2,jdbcType=VARCHAR},
  129. </if>
  130. <if test="ad_text3 != null">
  131. ad_text3 = #{ad_text3,jdbcType=VARCHAR},
  132. </if>
  133. <if test="ad_text4 != null">
  134. ad_text4 = #{ad_text4,jdbcType=VARCHAR},
  135. </if>
  136. <if test="ad_text5 != null">
  137. ad_text5 = #{ad_text5,jdbcType=VARCHAR},
  138. </if>
  139. <if test="ad_address != null">
  140. ad_address = #{ad_address,jdbcType=LONGVARCHAR},
  141. </if>
  142. </set>
  143. where ad_id = #{id}
  144. </update>
  145. <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.usoftchina.saas.document.entities.Address">
  146. update address
  147. set ad_recorddate = #{ad_recorddate,jdbcType=TIMESTAMP},
  148. companyId = #{companyId,jdbcType=INTEGER},
  149. updaterId = #{updaterId,jdbcType=INTEGER},
  150. updateTime = #{updateTime,jdbcType=TIMESTAMP},
  151. ad_text1 = #{ad_text1,jdbcType=VARCHAR},
  152. ad_text2 = #{ad_text2,jdbcType=VARCHAR},
  153. ad_text3 = #{ad_text3,jdbcType=VARCHAR},
  154. ad_text4 = #{ad_text4,jdbcType=VARCHAR},
  155. ad_text5 = #{ad_text5,jdbcType=VARCHAR},
  156. ad_address = #{ad_address,jdbcType=LONGVARCHAR}
  157. where ad_id = #{id}
  158. </update>
  159. <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.document.entities.Address">
  160. update address
  161. set ad_recorddate = #{ad_recorddate,jdbcType=TIMESTAMP},
  162. companyId = #{companyId,jdbcType=INTEGER},
  163. updaterId = #{updaterId,jdbcType=INTEGER},
  164. updateTime = #{updateTime,jdbcType=TIMESTAMP},
  165. ad_text1 = #{ad_text1,jdbcType=VARCHAR},
  166. ad_text2 = #{ad_text2,jdbcType=VARCHAR},
  167. ad_text3 = #{ad_text3,jdbcType=VARCHAR},
  168. ad_text4 = #{ad_text4,jdbcType=VARCHAR},
  169. ad_text5 = #{ad_text5,jdbcType=VARCHAR}
  170. where ad_id = #{id}
  171. </update>
  172. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  173. delete from address
  174. where ad_id = #{id}
  175. </delete>
  176. <delete id="deleteByIds" parameterType="java.lang.String">
  177. delete from address
  178. where ad_id in (#{ids,jdbcType=VARCHAR})
  179. </delete>
  180. <select id="selectAll" resultMap="ResultMapWithBLOBs">
  181. SELECT * FROM ADDRESS where COMPANYID=#{companyId} ORDER BY AD_ID DESC
  182. </select>
  183. <select id="selectCountByName" resultType="int">
  184. SELECT count(*) FROM ADDRESS
  185. <where>
  186. <if test="name!=null">
  187. and ad_address=#{name}
  188. </if>
  189. <if test="companyId!=null">
  190. and companyId=#{companyId}
  191. </if>
  192. <if test="id!=null and id!=0">
  193. and ad_id!=#{id}
  194. </if>
  195. </where>
  196. </select>
  197. <select id="getCombo" resultType="com.usoftchina.saas.commons.dto.ComboDTO">
  198. SELECT AD_ADDRESS display,AD_ADDRESS value FROM ADDRESS WHERE COMPANYID=#{companyId}
  199. </select>
  200. <select id="getCountFromPurchase" resultType="int">
  201. SELECT COUNT(*) FROM PURCHASE WHERE PU_SHIPADDRESSCODE = (SELECT AD_ADDRESS FROM ADDRESS WHERE AD_ID = #{id}) AND companyId = #{companyId}
  202. </select>
  203. </mapper>