SysPostMapper.xml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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.ruoyi.system.mapper.SysPostMapper">
  6. <resultMap type="SysPost" id="SysPostResult">
  7. <id property="postId" column="post_id" />
  8. <result property="postCode" column="post_code" />
  9. <result property="postName" column="post_name" />
  10. <result property="postSort" column="post_sort" />
  11. <result property="status" column="status" />
  12. <result property="createBy" column="create_by" />
  13. <result property="createTime" column="create_time" />
  14. <result property="updateBy" column="update_by" />
  15. <result property="updateTime" column="update_time" />
  16. <result property="remark" column="remark" />
  17. </resultMap>
  18. <sql id="selectPostVo">
  19. select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark
  20. from sys_post
  21. </sql>
  22. <select id="selectPostListByUserId2" parameterType="Long" resultMap="SysPostResult">
  23. select p.post_id,p.post_code,p.post_name
  24. from sys_post p
  25. left join sys_user_post up on up.post_id = p.post_id
  26. left join sys_user u on u.user_id = up.user_id
  27. where u.user_id = #{userId} and p.status = '0'
  28. </select>
  29. <select id="selectPostList" parameterType="SysPost" resultMap="SysPostResult">
  30. <include refid="selectPostVo"/>
  31. <where>
  32. <if test="postCode != null and postCode != ''">
  33. AND post_code like concat('%', #{postCode}, '%')
  34. </if>
  35. <if test="status != null and status != ''">
  36. AND status = #{status}
  37. </if>
  38. <if test="postName != null and postName != ''">
  39. AND post_name like concat('%', #{postName}, '%')
  40. </if>
  41. </where>
  42. </select>
  43. <select id="selectPostAll" resultMap="SysPostResult">
  44. <include refid="selectPostVo"/>
  45. </select>
  46. <select id="selectPostById" parameterType="Long" resultMap="SysPostResult">
  47. <include refid="selectPostVo"/>
  48. where post_id = #{postId}
  49. </select>
  50. <select id="selectPostListByUserId" parameterType="Long" resultType="Long">
  51. select p.post_id
  52. from sys_post p
  53. left join sys_user_post up on up.post_id = p.post_id
  54. left join sys_user u on u.user_id = up.user_id
  55. where u.user_id = #{userId}
  56. </select>
  57. <select id="selectPostsByUserName" parameterType="String" resultMap="SysPostResult">
  58. select p.post_id, p.post_name, p.post_code
  59. from sys_post p
  60. left join sys_user_post up on up.post_id = p.post_id
  61. left join sys_user u on u.user_id = up.user_id
  62. where u.user_name = #{userName}
  63. </select>
  64. <select id="checkPostNameUnique" parameterType="String" resultMap="SysPostResult">
  65. <include refid="selectPostVo"/>
  66. where post_name=#{postName} limit 1
  67. </select>
  68. <select id="checkPostCodeUnique" parameterType="String" resultMap="SysPostResult">
  69. <include refid="selectPostVo"/>
  70. where post_code=#{postCode} limit 1
  71. </select>
  72. <update id="updatePost" parameterType="SysPost">
  73. update sys_post
  74. <set>
  75. <if test="postCode != null and postCode != ''">post_code = #{postCode},</if>
  76. <if test="postName != null and postName != ''">post_name = #{postName},</if>
  77. <if test="postSort != null">post_sort = #{postSort},</if>
  78. <if test="status != null and status != ''">status = #{status},</if>
  79. <if test="remark != null">remark = #{remark},</if>
  80. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  81. update_time = sysdate()
  82. </set>
  83. where post_id = #{postId}
  84. </update>
  85. <insert id="insertPost" parameterType="SysPost" useGeneratedKeys="true" keyProperty="postId">
  86. insert into sys_post(
  87. <if test="postId != null and postId != 0">post_id,</if>
  88. <if test="postCode != null and postCode != ''">post_code,</if>
  89. <if test="postName != null and postName != ''">post_name,</if>
  90. <if test="postSort != null">post_sort,</if>
  91. <if test="status != null and status != ''">status,</if>
  92. <if test="remark != null and remark != ''">remark,</if>
  93. <if test="createBy != null and createBy != ''">create_by,</if>
  94. create_time
  95. )values(
  96. <if test="postId != null and postId != 0">#{postId},</if>
  97. <if test="postCode != null and postCode != ''">#{postCode},</if>
  98. <if test="postName != null and postName != ''">#{postName},</if>
  99. <if test="postSort != null">#{postSort},</if>
  100. <if test="status != null and status != ''">#{status},</if>
  101. <if test="remark != null and remark != ''">#{remark},</if>
  102. <if test="createBy != null and createBy != ''">#{createBy},</if>
  103. sysdate()
  104. )
  105. </insert>
  106. <delete id="deletePostById" parameterType="Long">
  107. delete from sys_post where post_id = #{postId}
  108. </delete>
  109. <delete id="deletePostByIds" parameterType="Long">
  110. delete from sys_post where post_id in
  111. <foreach collection="array" item="postId" open="(" separator="," close=")">
  112. #{postId}
  113. </foreach>
  114. </delete>
  115. </mapper>