SysPostMapper.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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.sooka.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="selectPostList" parameterType="SysPost" resultMap="SysPostResult">
  23. <include refid="selectPostVo"/>
  24. <where>
  25. <if test="exportIds != null and exportIds != ''"> and post_id in (${exportIds})</if>
  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="postName != null and postName != ''">
  33. AND post_name like concat('%', #{postName}, '%')
  34. </if>
  35. </where>
  36. </select>
  37. <select id="selectPostAll" resultMap="SysPostResult">
  38. <include refid="selectPostVo"/>
  39. </select>
  40. <select id="selectPostsByUserId" parameterType="Long" resultMap="SysPostResult">
  41. SELECT p.post_id, p.post_name, p.post_code
  42. FROM sys_user u
  43. LEFT JOIN sys_user_post up ON u.user_id = up.user_id
  44. LEFT JOIN sys_post p ON up.post_id = p.post_id
  45. WHERE up.user_id = #{userId}
  46. </select>
  47. <select id="selectPostById" parameterType="Long" resultMap="SysPostResult">
  48. <include refid="selectPostVo"/>
  49. where post_id = #{postId}
  50. </select>
  51. <select id="checkPostNameUnique" parameterType="String" resultMap="SysPostResult">
  52. <include refid="selectPostVo"/>
  53. where post_name=#{postName}
  54. </select>
  55. <select id="checkPostCodeUnique" parameterType="String" resultMap="SysPostResult">
  56. <include refid="selectPostVo"/>
  57. where post_code=#{postCode}
  58. </select>
  59. <delete id="deletePostByIds" parameterType="Long">
  60. delete from sys_post where post_id in
  61. <foreach collection="array" item="postId" open="(" separator="," close=")">
  62. #{postId}
  63. </foreach>
  64. </delete>
  65. <update id="updatePost" parameterType="SysPost">
  66. update sys_post
  67. <set>
  68. <if test="postCode != null and postCode != ''">post_code = #{postCode},</if>
  69. <if test="postName != null and postName != ''">post_name = #{postName},</if>
  70. <if test="postSort != null and postSort != ''">post_sort = #{postSort},</if>
  71. <if test="status != null and status != ''">status = #{status},</if>
  72. <if test="remark != null">remark = #{remark},</if>
  73. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  74. update_time = sysdate()
  75. </set>
  76. where post_id = #{postId}
  77. </update>
  78. <insert id="insertPost" parameterType="SysPost" useGeneratedKeys="true" keyProperty="postId">
  79. insert into sys_post(
  80. <if test="postId != null and postId != 0">post_id,</if>
  81. <if test="postCode != null and postCode != ''">post_code,</if>
  82. <if test="postName != null and postName != ''">post_name,</if>
  83. <if test="postSort != null and postSort != ''">post_sort,</if>
  84. <if test="status != null and status != ''">status,</if>
  85. <if test="remark != null and remark != ''">remark,</if>
  86. <if test="createBy != null and createBy != ''">create_by,</if>
  87. create_time
  88. )values(
  89. <if test="postId != null and postId != 0">#{postId},</if>
  90. <if test="postCode != null and postCode != ''">#{postCode},</if>
  91. <if test="postName != null and postName != ''">#{postName},</if>
  92. <if test="postSort != null and postSort != ''">#{postSort},</if>
  93. <if test="status != null and status != ''">#{status},</if>
  94. <if test="remark != null and remark != ''">#{remark},</if>
  95. <if test="createBy != null and createBy != ''">#{createBy},</if>
  96. sysdate()
  97. )
  98. </insert>
  99. </mapper>