FsUserAddressMapper.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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="com.fs.store.mapper.FsUserAddressMapper">
  6. <resultMap type="FsUserAddress" id="FsUserAddressResult">
  7. <result property="id" column="id" />
  8. <result property="userId" column="user_id" />
  9. <result property="realName" column="real_name" />
  10. <result property="phone" column="phone" />
  11. <result property="province" column="province" />
  12. <result property="city" column="city" />
  13. <result property="cityId" column="city_id" />
  14. <result property="district" column="district" />
  15. <result property="detail" column="detail" />
  16. <result property="postCode" column="post_code" />
  17. <result property="longitude" column="longitude" />
  18. <result property="latitude" column="latitude" />
  19. <result property="isDefault" column="is_default" />
  20. <result property="isDel" column="is_del" />
  21. <result property="createTime" column="create_time" />
  22. <result property="updateTime" column="update_time" />
  23. </resultMap>
  24. <sql id="selectFsUserAddressVo">
  25. select id, user_id, real_name, phone, province, city, city_id, district, detail, post_code, longitude, latitude, is_default, is_del, create_time, update_time from fs_user_address
  26. </sql>
  27. <select id="selectFsUserAddressList" parameterType="FsUserAddress" resultMap="FsUserAddressResult">
  28. <include refid="selectFsUserAddressVo"/>
  29. <where>
  30. <if test="userId != null "> and user_id = #{userId}</if>
  31. <if test="realName != null and realName != ''"> and real_name like concat('%', #{realName}, '%')</if>
  32. <if test="phone != null and phone != ''"> and phone = #{phone}</if>
  33. <if test="province != null and province != ''"> and province = #{province}</if>
  34. <if test="city != null and city != ''"> and city = #{city}</if>
  35. <if test="cityId != null "> and city_id = #{cityId}</if>
  36. <if test="district != null and district != ''"> and district = #{district}</if>
  37. <if test="detail != null and detail != ''"> and detail = #{detail}</if>
  38. <if test="postCode != null and postCode != ''"> and post_code = #{postCode}</if>
  39. <if test="longitude != null and longitude != ''"> and longitude = #{longitude}</if>
  40. <if test="latitude != null and latitude != ''"> and latitude = #{latitude}</if>
  41. <if test="isDefault != null "> and is_default = #{isDefault}</if>
  42. <if test="isDel != null "> and is_del = #{isDel}</if>
  43. </where>
  44. order by id desc
  45. </select>
  46. <select id="selectFsUserAddressById" parameterType="Long" resultMap="FsUserAddressResult">
  47. <include refid="selectFsUserAddressVo"/>
  48. where id = #{id}
  49. </select>
  50. <insert id="insertFsUserAddress" parameterType="FsUserAddress" useGeneratedKeys="true" keyProperty="id">
  51. insert into fs_user_address
  52. <trim prefix="(" suffix=")" suffixOverrides=",">
  53. <if test="userId != null">user_id,</if>
  54. <if test="realName != null and realName != ''">real_name,</if>
  55. <if test="phone != null and phone != ''">phone,</if>
  56. <if test="province != null and province != ''">province,</if>
  57. <if test="city != null and city != ''">city,</if>
  58. <if test="cityId != null">city_id,</if>
  59. <if test="district != null and district != ''">district,</if>
  60. <if test="detail != null and detail != ''">detail,</if>
  61. <if test="postCode != null and postCode != ''">post_code,</if>
  62. <if test="longitude != null and longitude != ''">longitude,</if>
  63. <if test="latitude != null and latitude != ''">latitude,</if>
  64. <if test="isDefault != null">is_default,</if>
  65. <if test="isDel != null">is_del,</if>
  66. <if test="createTime != null">create_time,</if>
  67. <if test="updateTime != null">update_time,</if>
  68. </trim>
  69. <trim prefix="values (" suffix=")" suffixOverrides=",">
  70. <if test="userId != null">#{userId},</if>
  71. <if test="realName != null and realName != ''">#{realName},</if>
  72. <if test="phone != null and phone != ''">#{phone},</if>
  73. <if test="province != null and province != ''">#{province},</if>
  74. <if test="city != null and city != ''">#{city},</if>
  75. <if test="cityId != null">#{cityId},</if>
  76. <if test="district != null and district != ''">#{district},</if>
  77. <if test="detail != null and detail != ''">#{detail},</if>
  78. <if test="postCode != null and postCode != ''">#{postCode},</if>
  79. <if test="longitude != null and longitude != ''">#{longitude},</if>
  80. <if test="latitude != null and latitude != ''">#{latitude},</if>
  81. <if test="isDefault != null">#{isDefault},</if>
  82. <if test="isDel != null">#{isDel},</if>
  83. <if test="createTime != null">#{createTime},</if>
  84. <if test="updateTime != null">#{updateTime},</if>
  85. </trim>
  86. </insert>
  87. <update id="updateFsUserAddress" parameterType="FsUserAddress">
  88. update fs_user_address
  89. <trim prefix="SET" suffixOverrides=",">
  90. <if test="userId != null">user_id = #{userId},</if>
  91. <if test="realName != null and realName != ''">real_name = #{realName},</if>
  92. <if test="phone != null and phone != ''">phone = #{phone},</if>
  93. <if test="province != null and province != ''">province = #{province},</if>
  94. <if test="city != null and city != ''">city = #{city},</if>
  95. <if test="cityId != null">city_id = #{cityId},</if>
  96. <if test="district != null and district != ''">district = #{district},</if>
  97. <if test="detail != null and detail != ''">detail = #{detail},</if>
  98. <if test="postCode != null and postCode != ''">post_code = #{postCode},</if>
  99. <if test="longitude != null and longitude != ''">longitude = #{longitude},</if>
  100. <if test="latitude != null and latitude != ''">latitude = #{latitude},</if>
  101. <if test="isDefault != null">is_default = #{isDefault},</if>
  102. <if test="isDel != null">is_del = #{isDel},</if>
  103. <if test="createTime != null">create_time = #{createTime},</if>
  104. <if test="updateTime != null">update_time = #{updateTime},</if>
  105. </trim>
  106. where id = #{id}
  107. </update>
  108. <update id="deleteFsUserAddressById" parameterType="Long">
  109. update fs_user_address set is_del=1 where id = #{id}
  110. </update>
  111. <update id="deleteFsUserAddressByIds" parameterType="String">
  112. update fs_user_address set is_del=1 where id in
  113. <foreach item="id" collection="array" open="(" separator="," close=")">
  114. #{id}
  115. </foreach>
  116. </update>
  117. </mapper>