SysPostMapper.xml 5.4 KB

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