SectionMapper.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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.welampiot.dao.SectionDao">
  4. <select id="getAllList" resultType="com.welampiot.dto.SectionDTO">
  5. select id,name from section
  6. </select>
  7. <select id="getListByPid" parameterType="java.lang.Integer" resultType="com.welampiot.dto.SectionDTO">
  8. select id,name from section
  9. where pid = #{pid,jdbcType=INTEGER}
  10. </select>
  11. <select id="getListByPidList" parameterType="java.util.List" resultType="com.welampiot.dto.SectionDTO">
  12. select id,name from section
  13. where pid in
  14. <foreach item="item" collection="pidList" open="(" separator="," close=")">
  15. #{item}
  16. </foreach>
  17. </select>
  18. <select id="getListByIdList" parameterType="java.util.List" resultType="com.welampiot.dto.SectionDTO">
  19. select id,name,pid,lampcount as lampCount,lamp_pole_count as lampPoleCount from section
  20. <if test="idList != null and !idList.isEmpty()">
  21. where id in
  22. <foreach item="item" collection="idList" open="(" separator="," close=")">
  23. #{item}
  24. </foreach>
  25. </if>
  26. </select>
  27. <select id="getOneById" parameterType="int" resultType="com.welampiot.dto.SectionDTO">
  28. select id,name,pid from section where id = #{id}
  29. </select>
  30. <select id="getPidBySectionList" resultType="sectionDTO">
  31. SELECT DISTINCT s.pid
  32. FROM section s
  33. <if test="sectionList != null and !sectionList.isEmpty()">
  34. WHERE s.id IN
  35. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  36. #{item}
  37. </foreach>
  38. </if>
  39. </select>
  40. <select id="getListByVO" parameterType="com.welampiot.vo.SectionVO" resultType="com.welampiot.dto.SectionDTO">
  41. select a.id,a.name,a.pid
  42. <choose>
  43. <when test="version == 1">
  44. ,b.english_name as area
  45. </when>
  46. <when test="version == 2">
  47. ,b.ru_name as area
  48. </when>
  49. <otherwise>
  50. ,b.chinese_name as area
  51. </otherwise>
  52. </choose>
  53. from section a
  54. left join global_location as b on b.id = a.pid
  55. <if test="idList != null and !idList.isEmpty()">
  56. where a.id in
  57. <foreach item="item" collection="idList" open="(" separator="," close=")">
  58. #{item}
  59. </foreach>
  60. </if>
  61. </select>
  62. <select id="getSectionListByDTO" resultType="sectionDTO">
  63. SELECT s.id,s.`name`
  64. FROM section s
  65. WHERE s.pid = #{pid}
  66. <if test="sectionList != null and !sectionList.isEmpty()">
  67. AND s.id IN
  68. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  69. #{item}
  70. </foreach>
  71. </if>
  72. </select>
  73. <insert id="addSectionData" parameterType="SectionDTO" keyProperty="id" useGeneratedKeys="true">
  74. insert into section(pid,`name`,createtime,timezone)
  75. values (#{pid},#{name},#{createTime},#{timezone})
  76. </insert>
  77. <select id="checkNameRepeated" resultType="Integer">
  78. select
  79. count(*)
  80. from section s
  81. where s.pid = #{pid} and s.name = #{name}
  82. <if test="id != null and id != 0">
  83. and s.id != #{id}
  84. </if>
  85. </select>
  86. <update id="updateSectionData" parameterType="SectionDTO">
  87. update section s
  88. set
  89. s.name = #{name}
  90. where s.id = #{id}
  91. </update>
  92. <select id="getSectionPidById" resultType="Integer">
  93. select s.pid
  94. from section s
  95. where s.id = #{id}
  96. </select>
  97. <delete id="deleteSectionDataById">
  98. delete
  99. from section
  100. where id = #{id};
  101. </delete>
  102. <select id="getAllSectionList" resultType="SectionDTO">
  103. SELECT s.id,s.name,s.pid
  104. FROM section s
  105. </select>
  106. <select id="getAllSectionListByPid" resultType="SectionDTO">
  107. select s.id,s.name,s.pid
  108. from section s
  109. left join global_location a on s.pid = a.id
  110. left join global_location c on a.pid = c.id
  111. left join global_location p on c.pid = p.id
  112. left join global_location g on p.pid = g.id
  113. where g.id = #{id}
  114. </select>
  115. </mapper>