WeatherAreaMapper.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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.ufo.project.weather.mapper.WeatherAreaMapper">
  6. <resultMap type="WeatherArea" id="WeatherAreaResult">
  7. <result property="areaId" column="area_id" />
  8. <result property="nameCn" column="name_cn" />
  9. <result property="districtCn" column="district_cn" />
  10. <result property="provcnCn" column="provcn_cn" />
  11. <result property="nationCn" column="nation_cn" />
  12. <result property="continentCn" column="continent_cn" />
  13. <result property="cityId" column="city_id" />
  14. <result property="cityName" column="city_name" />
  15. <result property="parentName" column="parent_name" />
  16. <result property="longitude" column="longitude" />
  17. <result property="latitude" column="latitude" />
  18. <result property="areaName" column="area_name" />
  19. <result property="areaNumber" column="area_number" />
  20. </resultMap>
  21. <sql id="selectWeatherAreaVo">
  22. select area_id, name_cn, district_cn, provcn_cn, nation_cn, continent_cn, city_id, city_name, parent_name, longitude, latitude, area_name, area_number from weather_area
  23. </sql>
  24. <select id="selectWeatherAreaList" parameterType="WeatherArea" resultMap="WeatherAreaResult">
  25. <include refid="selectWeatherAreaVo"/>
  26. <where>
  27. <if test="areaId != null and areaId != ''"> and area_id = #{areaId}</if>
  28. <if test="nameCn != null and nameCn != ''"> and name_cn = #{nameCn}</if>
  29. <if test="districtCn != null and districtCn != ''"> and district_cn = #{districtCn}</if>
  30. <if test="provcnCn != null and provcnCn != ''"> and provcn_cn = #{provcnCn}</if>
  31. <if test="nationCn != null and nationCn != ''"> and nation_cn = #{nationCn}</if>
  32. <if test="continentCn != null and continentCn != ''"> and continent_cn = #{continentCn}</if>
  33. <if test="cityId != null "> and city_id = #{cityId}</if>
  34. <if test="cityName != null and cityName != ''"> and city_name like concat('%', #{cityName}, '%')</if>
  35. <if test="parentName != null and parentName != ''"> and parent_name like concat('%', #{parentName}, '%')</if>
  36. <if test="longitude != null and longitude != ''"> and longitude = #{longitude}</if>
  37. <if test="latitude != null and latitude != ''"> and latitude = #{latitude}</if>
  38. <if test="areaName != null and areaName != ''"> and area_name like concat('%', #{areaName}, '%')</if>
  39. <if test="areaNumber != null and areaNumber != ''"> and area_number = #{areaNumber}</if>
  40. </where>
  41. </select>
  42. <select id="selectWeatherAreaByAreaId" parameterType="String" resultMap="WeatherAreaResult">
  43. <include refid="selectWeatherAreaVo"/>
  44. where area_id = #{areaId}
  45. </select>
  46. <insert id="insertWeatherArea" parameterType="WeatherArea">
  47. insert into weather_area
  48. <trim prefix="(" suffix=")" suffixOverrides=",">
  49. <if test="areaId != null and areaId != ''">area_id,</if>
  50. <if test="nameCn != null">name_cn,</if>
  51. <if test="districtCn != null">district_cn,</if>
  52. <if test="provcnCn != null">provcn_cn,</if>
  53. <if test="nationCn != null">nation_cn,</if>
  54. <if test="continentCn != null">continent_cn,</if>
  55. <if test="cityId != null">city_id,</if>
  56. <if test="cityName != null">city_name,</if>
  57. <if test="parentName != null">parent_name,</if>
  58. <if test="longitude != null">longitude,</if>
  59. <if test="latitude != null">latitude,</if>
  60. <if test="areaName != null">area_name,</if>
  61. <if test="areaNumber != null">area_number,</if>
  62. </trim>
  63. <trim prefix="values (" suffix=")" suffixOverrides=",">
  64. <if test="areaId != null and areaId != ''">#{areaId},</if>
  65. <if test="nameCn != null">#{nameCn},</if>
  66. <if test="districtCn != null">#{districtCn},</if>
  67. <if test="provcnCn != null">#{provcnCn},</if>
  68. <if test="nationCn != null">#{nationCn},</if>
  69. <if test="continentCn != null">#{continentCn},</if>
  70. <if test="cityId != null">#{cityId},</if>
  71. <if test="cityName != null">#{cityName},</if>
  72. <if test="parentName != null">#{parentName},</if>
  73. <if test="longitude != null">#{longitude},</if>
  74. <if test="latitude != null">#{latitude},</if>
  75. <if test="areaName != null">#{areaName},</if>
  76. <if test="areaNumber != null">#{areaNumber},</if>
  77. </trim>
  78. </insert>
  79. <update id="updateWeatherArea" parameterType="WeatherArea">
  80. update weather_area
  81. <trim prefix="SET" suffixOverrides=",">
  82. <if test="nameCn != null">name_cn = #{nameCn},</if>
  83. <if test="districtCn != null">district_cn = #{districtCn},</if>
  84. <if test="provcnCn != null">provcn_cn = #{provcnCn},</if>
  85. <if test="nationCn != null">nation_cn = #{nationCn},</if>
  86. <if test="continentCn != null">continent_cn = #{continentCn},</if>
  87. <if test="cityId != null">city_id = #{cityId},</if>
  88. <if test="cityName != null">city_name = #{cityName},</if>
  89. <if test="parentName != null">parent_name = #{parentName},</if>
  90. <if test="longitude != null">longitude = #{longitude},</if>
  91. <if test="latitude != null">latitude = #{latitude},</if>
  92. <if test="areaName != null">area_name = #{areaName},</if>
  93. <if test="areaNumber != null">area_number = #{areaNumber},</if>
  94. </trim>
  95. where area_id = #{areaId}
  96. </update>
  97. <delete id="deleteWeatherAreaByAreaId" parameterType="String">
  98. delete from weather_area where area_id = #{areaId}
  99. </delete>
  100. <delete id="deleteWeatherAreaByAreaIds" parameterType="String">
  101. delete from weather_area where area_id in
  102. <foreach item="areaId" collection="array" open="(" separator="," close=")">
  103. #{areaId}
  104. </foreach>
  105. </delete>
  106. </mapper>