InfoAddressMapper.xml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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.ruoyi.system.mapper.InfoAddressMapper">
  6. <resultMap type="InfoAddress" id="InfoAddressResult">
  7. <result property="id" column="id" />
  8. <result property="userId" column="user_id" />
  9. <result property="name" column="name" />
  10. <result property="phone" column="phone" />
  11. <result property="address" column="address" />
  12. <result property="addressDetail" column="address_detail" />
  13. <result property="longitude" column="longitude" />
  14. <result property="latitude" column="latitude" />
  15. <result property="country" column="country" />
  16. <result property="province" column="province" />
  17. <result property="city" column="city" />
  18. <result property="area" column="area" />
  19. </resultMap>
  20. <sql id="selectInfoAddressVo">
  21. select id, user_id, name, phone, address, address_detail, longitude, latitude, country, province, city, area from info_address
  22. </sql>
  23. <select id="selectInfoAddressList" parameterType="InfoAddress" resultMap="InfoAddressResult">
  24. <include refid="selectInfoAddressVo"/>
  25. <where>
  26. <if test="userId != null "> and user_id = #{userId}</if>
  27. <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
  28. <if test="phone != null and phone != ''"> and phone = #{phone}</if>
  29. <if test="country != null and country != ''"> and country = #{country}</if>
  30. <if test="province != null and province != ''"> and province = #{province}</if>
  31. <if test="city != null and city != ''"> and city = #{city}</if>
  32. <if test="area != null and area != ''"> and area = #{area}</if>
  33. </where>
  34. order by id desc
  35. </select>
  36. <select id="selectInfoAddressById" parameterType="Long" resultMap="InfoAddressResult">
  37. <include refid="selectInfoAddressVo"/>
  38. where id = #{id}
  39. </select>
  40. <insert id="insertInfoAddress" parameterType="InfoAddress" useGeneratedKeys="true" keyProperty="id">
  41. insert into info_address
  42. <trim prefix="(" suffix=")" suffixOverrides=",">
  43. <if test="userId != null">user_id,</if>
  44. <if test="name != null and name != ''">name,</if>
  45. <if test="phone != null and phone != ''">phone,</if>
  46. <if test="address != null and address != ''">address,</if>
  47. <if test="addressDetail != null and addressDetail != ''">address_detail,</if>
  48. <if test="longitude != null">longitude,</if>
  49. <if test="latitude != null">latitude,</if>
  50. <if test="country != null">country,</if>
  51. <if test="province != null">province,</if>
  52. <if test="city != null">city,</if>
  53. <if test="area != null">area,</if>
  54. </trim>
  55. <trim prefix="values (" suffix=")" suffixOverrides=",">
  56. <if test="userId != null">#{userId},</if>
  57. <if test="name != null and name != ''">#{name},</if>
  58. <if test="phone != null and phone != ''">#{phone},</if>
  59. <if test="address != null and address != ''">#{address},</if>
  60. <if test="addressDetail != null and addressDetail != ''">#{addressDetail},</if>
  61. <if test="longitude != null">#{longitude},</if>
  62. <if test="latitude != null">#{latitude},</if>
  63. <if test="country != null">#{country},</if>
  64. <if test="province != null">#{province},</if>
  65. <if test="city != null">#{city},</if>
  66. <if test="area != null">#{area},</if>
  67. </trim>
  68. </insert>
  69. <update id="updateInfoAddress" parameterType="InfoAddress">
  70. update info_address
  71. <trim prefix="SET" suffixOverrides=",">
  72. <if test="userId != null">user_id = #{userId},</if>
  73. <if test="name != null and name != ''">name = #{name},</if>
  74. <if test="phone != null and phone != ''">phone = #{phone},</if>
  75. <if test="address != null and address != ''">address = #{address},</if>
  76. <if test="addressDetail != null and addressDetail != ''">address_detail = #{addressDetail},</if>
  77. <if test="longitude != null">longitude = #{longitude},</if>
  78. <if test="latitude != null">latitude = #{latitude},</if>
  79. <if test="country != null">country = #{country},</if>
  80. <if test="province != null">province = #{province},</if>
  81. <if test="city != null">city = #{city},</if>
  82. <if test="area != null">area = #{area},</if>
  83. </trim>
  84. where id = #{id}
  85. </update>
  86. <delete id="deleteInfoAddressById" parameterType="Long">
  87. delete from info_address where id = #{id}
  88. </delete>
  89. <delete id="deleteInfoAddressByIds" parameterType="String">
  90. delete from info_address where id in
  91. <foreach item="id" collection="array" open="(" separator="," close=")">
  92. #{id}
  93. </foreach>
  94. </delete>
  95. </mapper>