SectionMapper.xml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 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="getSectionListByDTO" resultType="sectionDTO">
  41. SELECT s.id,s.`name`
  42. FROM section s
  43. WHERE s.pid = #{pid}
  44. <if test="sectionList != null and !sectionList.isEmpty()">
  45. AND s.id IN
  46. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  47. #{item}
  48. </foreach>
  49. </if>
  50. </select>
  51. <insert id="addSectionData" parameterType="SectionDTO" keyProperty="id" useGeneratedKeys="true">
  52. insert into section(pid,`name`,createtime,timezone)
  53. values (#{pid},#{name},#{createTime},#{timezone})
  54. </insert>
  55. <select id="checkNameRepeated" resultType="Integer">
  56. select
  57. count(*)
  58. from section s
  59. where s.pid = #{pid} and s.name = #{name}
  60. <if test="id != null and id != 0">
  61. and s.id != #{id}
  62. </if>
  63. </select>
  64. <update id="updateSectionData" parameterType="SectionDTO">
  65. update section s
  66. set
  67. s.name = #{name}
  68. where s.id = #{id}
  69. </update>
  70. <select id="getSectionPidById" resultType="Integer">
  71. select s.pid
  72. from section s
  73. where s.id = #{id}
  74. </select>
  75. <delete id="deleteSectionDataById">
  76. delete
  77. from section
  78. where id = #{id};
  79. </delete>
  80. <select id="getAllSectionList" resultType="SectionDTO">
  81. SELECT s.id,s.name,s.pid
  82. FROM section s
  83. </select>
  84. <select id="getAllSectionListByPid" resultType="SectionDTO">
  85. select s.id,s.name,s.pid
  86. from section s
  87. left join global_location a on s.pid = a.id
  88. left join global_location c on a.pid = c.id
  89. left join global_location p on c.pid = p.id
  90. left join global_location g on p.pid = g.id
  91. where g.id = #{id}
  92. </select>
  93. </mapper>