Permission.xml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <!-- namespace必须指向DAO接口 -->
  5. <mapper namespace="com.jpsoft.picc.modules.sys.dao.PermissionDAO">
  6. <resultMap id="PermissionMap" type="com.jpsoft.picc.modules.sys.entity.Permission">
  7. <id property="id" column="id_"/>
  8. <result property="path" column="path_"/>
  9. <result property="method" column="method_"/>
  10. <result property="summary" column="summary_"/>
  11. <result property="delFlag" column="del_flag"/>
  12. <result property="createBy" column="create_by"/>
  13. <result property="updateBy" column="update_by"/>
  14. <result property="createTime" column="create_time"/>
  15. <result property="updateTime" column="update_time"/>
  16. </resultMap>
  17. <insert id="insert" parameterType="com.jpsoft.picc.modules.sys.entity.Permission">
  18. <!--
  19. <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
  20. select sys_guid() from dual
  21. </selectKey>
  22. -->
  23. <![CDATA[
  24. insert into sys_permission
  25. (id_,path_,method_,summary_,del_flag,create_by,update_by,create_time,update_time)
  26. values
  27. (
  28. #{id,jdbcType=VARCHAR}
  29. ,#{path,jdbcType=VARCHAR}
  30. ,#{method,jdbcType=VARCHAR}
  31. ,#{summary,jdbcType=VARCHAR}
  32. ,#{delFlag,jdbcType= NUMERIC }
  33. ,#{createBy,jdbcType=VARCHAR}
  34. ,#{updateBy,jdbcType=VARCHAR}
  35. ,#{createTime,jdbcType= TIMESTAMP }
  36. ,#{updateTime,jdbcType= TIMESTAMP }
  37. )
  38. ]]>
  39. </insert>
  40. <delete id="delete" parameterType="string">
  41. delete from sys_permission where id_=#{id,jdbcType=VARCHAR}
  42. </delete>
  43. <update id="update" parameterType="com.jpsoft.picc.modules.sys.entity.Permission">
  44. update sys_permission
  45. <set>
  46. <if test="path!=null">
  47. path_=#{path,jdbcType=VARCHAR},
  48. </if>
  49. <if test="method!=null">
  50. method_=#{method,jdbcType=VARCHAR},
  51. </if>
  52. <if test="summary!=null">
  53. summary_=#{summary,jdbcType=VARCHAR},
  54. </if>
  55. <if test="delFlag!=null">
  56. del_flag=#{delFlag,jdbcType= NUMERIC },
  57. </if>
  58. <if test="createBy!=null">
  59. create_by=#{createBy,jdbcType=VARCHAR},
  60. </if>
  61. <if test="updateBy!=null">
  62. update_by=#{updateBy,jdbcType=VARCHAR},
  63. </if>
  64. <if test="createTime!=null">
  65. create_time=#{createTime,jdbcType= TIMESTAMP },
  66. </if>
  67. <if test="updateTime!=null">
  68. update_time=#{updateTime,jdbcType= TIMESTAMP },
  69. </if>
  70. </set>
  71. where id_=#{id}
  72. </update>
  73. <select id="get" parameterType="string" resultMap="PermissionMap">
  74. select
  75. id_,path_,method_,summary_,del_flag,create_by,update_by,create_time,update_time from sys_permission where
  76. id_=#{0}
  77. </select>
  78. <select id="exist" parameterType="string" resultType="int">
  79. select count(*) from sys_permission where path_=#{path} and method_=#{method} and del_flag=0
  80. </select>
  81. <select id="list" resultMap="PermissionMap">
  82. select * from sys_permission where del_flag=0
  83. </select>
  84. <select id="search" parameterType="hashmap" resultMap="PermissionMap">
  85. <![CDATA[
  86. select * from sys_permission
  87. ]]>
  88. where del_flag=0
  89. <if test="searchParams.path != null">
  90. and path_ like #{searchParams.path}
  91. </if>
  92. <foreach item="sort" collection="sortList" open="order by" separator=",">
  93. ${sort.name} ${sort.order}
  94. </foreach>
  95. </select>
  96. <select id="hasPermitted" parameterType="string" resultType="int">
  97. <![CDATA[
  98. select count(*) from
  99. sys_user u,sys_user_role ur,sys_role_permission rp,sys_permission p
  100. where u.id_=#{userId}
  101. and u.id_=ur.user_id
  102. and ur.role_id = rp.role_id
  103. and rp.perm_id = p.id_
  104. and p.path_ = #{path}
  105. and p.method_ = #{method}
  106. ]]>
  107. </select>
  108. </mapper>