SysPostMapper.xml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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.aidex.system.mapper.SysPostMapper">
  6. <sql id="postColumns">
  7. a.id as "id",
  8. a.post_code AS "postCode",
  9. a.post_name AS "postName",
  10. a.sort,
  11. a.status AS "status",
  12. a.create_by AS "createBy",
  13. a.create_dept AS "createDept",
  14. a.create_time AS "createTime",
  15. a.update_by AS "updateBy",
  16. a.update_time AS "updateTime",
  17. a.update_ip AS "updateIp",
  18. a.remark AS "remark",
  19. a.version AS "version"
  20. </sql>
  21. <sql id="postJoins">
  22. </sql>
  23. <sql id="postOrderBy">
  24. order by a.sort
  25. </sql>
  26. <select id="get" resultType="SysPost">
  27. SELECT
  28. <include refid="postColumns"/>
  29. FROM sys_post a
  30. <include refid="postJoins"/>
  31. WHERE id = #{id}
  32. </select>
  33. <select id="findList" resultType="SysPost">
  34. SELECT
  35. <include refid="postColumns"/>
  36. FROM sys_post a
  37. WHERE a.del_flag = #{DEL_FLAG_NORMAL}
  38. <if test="postCode != null and postCode != ''">
  39. AND post_code like concat(concat('%', #{postCode}),'%')
  40. </if>
  41. <if test="postName != null and postName != ''">
  42. AND post_name like concat(concat('%', #{postName}),'%')
  43. </if>
  44. <if test="status != null and status != ''">
  45. AND status = #{status}
  46. </if>
  47. <if test="notEqualId != null and notEqualId != ''">
  48. AND id != #{notEqualId}
  49. </if>
  50. <include refid="postOrderBy"/>
  51. </select>
  52. <select id="findListWithUnique" resultType="SysPost">
  53. SELECT
  54. a.id
  55. FROM sys_post a
  56. WHERE a.del_flag = #{DEL_FLAG_NORMAL}
  57. <if test="postCode != null and postCode != ''">
  58. AND post_code = #{postCode}
  59. </if>
  60. <if test="postName != null and postName != ''">
  61. AND post_name = #{postName}
  62. </if>
  63. <if test="notEqualId != null and notEqualId != ''">
  64. AND id != #{notEqualId}
  65. </if>
  66. </select>
  67. <update id="update" >
  68. update sys_post
  69. <set>
  70. post_code = #{postCode},
  71. post_name = #{postName},
  72. sort = #{sort},
  73. status = #{status},
  74. update_by = #{updateBy},
  75. update_time = #{updateTime},
  76. update_ip = #{updateIp},
  77. remark = #{remark},
  78. version = version + 1
  79. </set>
  80. where id = #{id} and version = #{version}
  81. </update>
  82. <insert id="insert">
  83. insert into sys_post(
  84. id,
  85. post_code,
  86. post_name,
  87. sort,
  88. status,
  89. create_by,
  90. create_dept,
  91. create_time,
  92. update_by,
  93. update_time,
  94. update_ip,
  95. remark,
  96. del_flag,
  97. version
  98. )values(
  99. #{id},
  100. #{postCode},
  101. #{postName},
  102. #{sort},
  103. #{status},
  104. #{createBy},
  105. #{createDept},
  106. #{createTime},
  107. #{updateBy},
  108. #{updateTime},
  109. #{updateIp},
  110. #{remark},
  111. #{DEL_FLAG_NORMAL},
  112. 1
  113. )
  114. </insert>
  115. <update id="delete" >
  116. UPDATE sys_post SET
  117. del_flag = #{DEL_FLAG_DELETE}
  118. WHERE id = #{id}
  119. </update>
  120. <delete id="deletePostByIds">
  121. UPDATE sys_post SET
  122. del_flag = '1'
  123. WHERE id in
  124. <foreach collection="array" item="ids" open="(" separator="," close=")">
  125. #{ids}
  126. </foreach>
  127. </delete>
  128. <select id="selectPostListByUserId" resultType="String">
  129. select p.id
  130. from sys_post p
  131. left join sys_user_post up on up.post_id = p.id
  132. left join sys_user u on u.id = up.user_id
  133. where u.id = #{userId}
  134. </select>
  135. <select id="selectPostsByUserName" resultType="SysPost">
  136. select p.id, p.post_name as postName, p.post_code as postCode
  137. from sys_post p
  138. left join sys_user_post up on up.post_id = p.id
  139. left join sys_user u on u.id = up.user_id
  140. where u.user_name = #{userName}
  141. </select>
  142. <select id="findMaxSort" resultType="Integer">
  143. SELECT max(a.sort)
  144. FROM sys_post a
  145. WHERE status = #{DEL_FLAG_NORMAL}
  146. </select>
  147. </mapper>