SysPostMapper.xml 4.9 KB

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