1
0

ApiAddressMapper.xml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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.kmall.api.dao.ApiAddressMapper">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.api.entity.AddressVo" id="addressMap">
  6. <result property="id" column="id"/>
  7. <result property="userId" column="user_id"/>
  8. <result property="userName" column="user_name"/>
  9. <result property="telNumber" column="tel_number"/>
  10. <result property="postalCode" column="postal_Code"/>
  11. <result property="nationalCode" column="national_Code"/>
  12. <result property="provinceName" column="province_Name"/>
  13. <result property="cityName" column="city_Name"/>
  14. <result property="countyName" column="county_Name"/>
  15. <result property="detailInfo" column="detail_Info"/>
  16. <result property="isDefault" column="is_default"/>
  17. <result property="latitude" column="latitude"/>
  18. <result property="longitude" column="longitude"/>
  19. </resultMap>
  20. <select id="queryObject" resultMap="addressMap">
  21. select * from mall_address where id = #{value}
  22. </select>
  23. <select id="queryList" resultMap="addressMap">
  24. select * from mall_address
  25. where 1 = 1
  26. <if test="user_id != null">
  27. and user_id = #{user_id}
  28. </if>
  29. <if test="telNumber and telNumber.trim() != ''">
  30. AND tel_number = #{telNumber}
  31. </if>
  32. <if test="is_default != null">
  33. AND is_default = #{is_default}
  34. </if>
  35. <choose>
  36. <when test="sidx != null and sidx.trim() != ''">
  37. order by ${sidx} ${order}
  38. </when>
  39. <otherwise>
  40. order by id desc
  41. </otherwise>
  42. </choose>
  43. <if test="offset != null and limit != null">
  44. limit #{offset}, #{limit}
  45. </if>
  46. </select>
  47. <select id="queryTotal" resultType="int">
  48. select count(*) from mall_address
  49. where 1 = 1
  50. <if test="userId != null">
  51. and user_id = #{user_id}
  52. </if>
  53. <if test="telNumber and telNumber.trim() != ''">
  54. AND tel_number = #{telNumber}
  55. </if>
  56. </select>
  57. <insert id="save" parameterType="com.kmall.api.entity.AddressVo" useGeneratedKeys="true" keyProperty="id">
  58. insert into mall_address(
  59. `user_id`,
  60. `user_name`,
  61. `tel_number`,
  62. `postal_Code`,
  63. `national_Code`,
  64. `province_Name`,
  65. `city_Name`,
  66. `county_Name`,
  67. `detail_Info`,
  68. `latitude`,
  69. `longitude`,
  70. `is_default`)
  71. values(
  72. #{userId},
  73. #{userName},
  74. #{telNumber},
  75. #{postalCode},
  76. #{nationalCode},
  77. #{provinceName},
  78. #{cityName},
  79. #{countyName},
  80. #{detailInfo},
  81. #{latitude},
  82. #{longitude},
  83. #{isDefault})
  84. </insert>
  85. <update id="update" parameterType="com.kmall.api.entity.AddressVo">
  86. update mall_address
  87. <set>
  88. <if test="userId != null">`user_id` = #{userId},</if>
  89. <if test="userName != null">`user_name` = #{userName},</if>
  90. <if test="telNumber != null">`tel_number` = #{telNumber},</if>
  91. <if test="postalCode != null">`postal_Code` = #{postalCode},</if>
  92. <if test="nationalCode != null">`national_Code` = #{nationalCode},</if>
  93. <if test="provinceName != null">`province_Name` = #{provinceName},</if>
  94. <if test="cityName != null">`city_Name` = #{cityName},</if>
  95. <if test="countyName != null">`county_Name` = #{countyName},</if>
  96. <if test="detailInfo != null">`detail_Info` = #{detailInfo},</if>
  97. <if test="isDefault != null">`is_default` = #{isDefault},</if>
  98. <if test="latitude != null">`latitude` = #{latitude},</if>
  99. <if test="longitude != null">`longitude` = #{longitude},</if>
  100. </set>
  101. where id = #{id}
  102. </update>
  103. <delete id="delete">
  104. delete from mall_address where id = #{value}
  105. </delete>
  106. <delete id="deleteBatch">
  107. delete from mall_address where id in
  108. <foreach item="id" collection="array" open="(" separator="," close=")">
  109. #{id}
  110. </foreach>
  111. </delete>
  112. </mapper>