SchoolRegionMapper.xml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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.miaxis.app.school.mapper.SchoolRegionMapper">
  6. <resultMap type="SchoolRegion" id="SchoolRegionResult">
  7. <result property="id" column="id" />
  8. <result property="inscode" column="inscode" />
  9. <result property="seq" column="seq" />
  10. <result property="name" column="name" />
  11. <result property="address" column="address" />
  12. <result property="area" column="area" />
  13. <result property="type" column="type" />
  14. <result property="vehicletype" column="vehicletype" />
  15. <result property="polygon" column="polygon" />
  16. <result property="totalvehnum" column="totalvehnum" />
  17. <result property="curvehnum" column="curvehnum" />
  18. <result property="status" column="status" />
  19. <result property="flag" column="flag" />
  20. <result property="areaCode" column="area_code" />
  21. <result property="poiLon" column="poi_lon" />
  22. <result property="poiLat" column="poi_lat" />
  23. <result property="createTime" column="create_time" />
  24. <result property="updateTime" column="update_time" />
  25. </resultMap>
  26. <select id="selectSchoolRegionUrlList" parameterType="com.miaxis.app.school.dto.SchoolRegionDTO" resultType="com.miaxis.app.school.dto.SchoolRegionVO">
  27. SELECT sr.id,sr.NAME region_name,s.NAME school_name,sr.address,
  28. sr.area,sr.type,sr.vehicletype,sr.totalvehnum,sr.curvehnum,sr.poi_lon,sr.poi_lat,sri.url,
  29. (2 * 6378.137 * ASIN(SQRT(POW( SIN( PI( ) * ( 120.211162- s.poi_lon ) / 360 ), 2 ) + COS( PI( ) * 30.186584 / 180 ) * COS( sr.poi_lat * PI( ) / 180 ) * POW( SIN( PI( ) * ( 30.186584- s.poi_lat ) / 360 ), 2 )) ) ) AS distance
  30. FROM school_region sr
  31. left JOIN school_info s ON sr.inscode = s.inscode
  32. left join school_region_images sri on sr.id = sri. region_id
  33. <where>
  34. <if test="areaCode != null and areaCode != ''"> and area_code = #{areaCode}</if>
  35. </where>
  36. order by distance desc
  37. </select>
  38. <sql id="selectSchoolRegionVo">
  39. select id, inscode, seq, name, address, area, type, vehicletype, polygon, totalvehnum, curvehnum, status, flag, area_code, poi_lon, poi_lat, create_time, update_time from school_region
  40. </sql>
  41. <select id="selectSchoolRegionList" parameterType="SchoolRegion" resultMap="SchoolRegionResult">
  42. <include refid="selectSchoolRegionVo"/>
  43. <where>
  44. <if test="inscode != null and inscode != ''"> and inscode = #{inscode}</if>
  45. <if test="seq != null and seq != ''"> and seq = #{seq}</if>
  46. <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
  47. <if test="address != null and address != ''"> and address = #{address}</if>
  48. <if test="area != null "> and area = #{area}</if>
  49. <if test="type != null "> and type = #{type}</if>
  50. <if test="vehicletype != null and vehicletype != ''"> and vehicletype = #{vehicletype}</if>
  51. <if test="polygon != null and polygon != ''"> and polygon = #{polygon}</if>
  52. <if test="totalvehnum != null "> and totalvehnum = #{totalvehnum}</if>
  53. <if test="curvehnum != null "> and curvehnum = #{curvehnum}</if>
  54. <if test="status != null "> and status = #{status}</if>
  55. <if test="flag != null "> and flag = #{flag}</if>
  56. <if test="areaCode != null and areaCode != ''"> and area_code = #{areaCode}</if>
  57. <if test="poiLon != null "> and poi_lon = #{poiLon}</if>
  58. <if test="poiLat != null "> and poi_lat = #{poiLat}</if>
  59. </where>
  60. </select>
  61. <select id="selectSchoolRegionById" parameterType="Long" resultMap="SchoolRegionResult">
  62. <include refid="selectSchoolRegionVo"/>
  63. where id = #{id}
  64. </select>
  65. <insert id="insertSchoolRegion" parameterType="SchoolRegion">
  66. insert into school_region
  67. <trim prefix="(" suffix=")" suffixOverrides=",">
  68. <if test="id != null">id,</if>
  69. <if test="inscode != null">inscode,</if>
  70. <if test="seq != null">seq,</if>
  71. <if test="name != null">name,</if>
  72. <if test="address != null">address,</if>
  73. <if test="area != null">area,</if>
  74. <if test="type != null">type,</if>
  75. <if test="vehicletype != null">vehicletype,</if>
  76. <if test="polygon != null">polygon,</if>
  77. <if test="totalvehnum != null">totalvehnum,</if>
  78. <if test="curvehnum != null">curvehnum,</if>
  79. <if test="status != null">status,</if>
  80. <if test="flag != null">flag,</if>
  81. <if test="areaCode != null">area_code,</if>
  82. <if test="poiLon != null">poi_lon,</if>
  83. <if test="poiLat != null">poi_lat,</if>
  84. <if test="createTime != null">create_time,</if>
  85. <if test="updateTime != null">update_time,</if>
  86. </trim>
  87. <trim prefix="values (" suffix=")" suffixOverrides=",">
  88. <if test="id != null">#{id},</if>
  89. <if test="inscode != null">#{inscode},</if>
  90. <if test="seq != null">#{seq},</if>
  91. <if test="name != null">#{name},</if>
  92. <if test="address != null">#{address},</if>
  93. <if test="area != null">#{area},</if>
  94. <if test="type != null">#{type},</if>
  95. <if test="vehicletype != null">#{vehicletype},</if>
  96. <if test="polygon != null">#{polygon},</if>
  97. <if test="totalvehnum != null">#{totalvehnum},</if>
  98. <if test="curvehnum != null">#{curvehnum},</if>
  99. <if test="status != null">#{status},</if>
  100. <if test="flag != null">#{flag},</if>
  101. <if test="areaCode != null">#{areaCode},</if>
  102. <if test="poiLon != null">#{poiLon},</if>
  103. <if test="poiLat != null">#{poiLat},</if>
  104. <if test="createTime != null">#{createTime},</if>
  105. <if test="updateTime != null">#{updateTime},</if>
  106. </trim>
  107. </insert>
  108. <update id="updateSchoolRegion" parameterType="SchoolRegion">
  109. update school_region
  110. <trim prefix="SET" suffixOverrides=",">
  111. <if test="inscode != null">inscode = #{inscode},</if>
  112. <if test="seq != null">seq = #{seq},</if>
  113. <if test="name != null">name = #{name},</if>
  114. <if test="address != null">address = #{address},</if>
  115. <if test="area != null">area = #{area},</if>
  116. <if test="type != null">type = #{type},</if>
  117. <if test="vehicletype != null">vehicletype = #{vehicletype},</if>
  118. <if test="polygon != null">polygon = #{polygon},</if>
  119. <if test="totalvehnum != null">totalvehnum = #{totalvehnum},</if>
  120. <if test="curvehnum != null">curvehnum = #{curvehnum},</if>
  121. <if test="status != null">status = #{status},</if>
  122. <if test="flag != null">flag = #{flag},</if>
  123. <if test="areaCode != null">area_code = #{areaCode},</if>
  124. <if test="poiLon != null">poi_lon = #{poiLon},</if>
  125. <if test="poiLat != null">poi_lat = #{poiLat},</if>
  126. <if test="createTime != null">create_time = #{createTime},</if>
  127. <if test="updateTime != null">update_time = #{updateTime},</if>
  128. </trim>
  129. where id = #{id}
  130. </update>
  131. <delete id="deleteSchoolRegionById" parameterType="Long">
  132. delete from school_region where id = #{id}
  133. </delete>
  134. <delete id="deleteSchoolRegionByIds" parameterType="String">
  135. delete from school_region where id in
  136. <foreach item="id" collection="array" open="(" separator="," close=")">
  137. #{id}
  138. </foreach>
  139. </delete>
  140. </mapper>