| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="cn.com.goldenwater.dcproj.dao.PrivDao">
- <resultMap type="cn.com.goldenwater.dcproj.model.Priv" id="privResultMap">
- <result property="id" column="ID"/>
- <result property="flagLeaf" column="FLAG_LEAF"/>
- <result property="seq" column="SEQ"/>
- <result property="privType" column="PRIV_TYPE"/>
- <result property="privName" column="PRIV_NAME"/>
- <result property="ownerSystem" column="OWNER_SYSTEM"/>
- <result property="code" column="CODE"/>
- <result property="parentId" column="PARENT_ID"/>
- <result property="privUri" column="PRIV_URI"/>
- </resultMap>
- <resultMap type="cn.com.goldenwater.dcproj.dto.PrivDto" id="dtoPrivResultMap">
- <result property="id" column="ID"/>
- <result property="privName" column="PRIV_NAME"/>
- <result property="privType" column="PRIV_TYPE"/>
- <result property="privUri" column="PRIV_URI"/>
- <result property="parentId" column="PARENT_ID"/>
- <result property="parentName" column="PARENT_NAME"/>
- <result property="flagLeaf" column="FLAG_LEAF"/>
- <result property="flagLeafCn" column="FLAG_LEAF_CN"/>
- <result property="roleId" column="ROLE_ID"/>
- <result property="checked" column="CHECKED"/>
- <result property="ownerSystem" column="OWNER_SYSTEM"/>
- <result property="code" column="CODE"/>
- </resultMap>
- <sql id="table_columns">
- ID ,
- FLAG_LEAF ,
- SEQ ,
- PRIV_TYPE ,
- PRIV_NAME ,
- OWNER_SYSTEM ,
- CODE ,
- PARENT_ID ,
- PRIV_URI
- </sql>
- <sql id="table_columns2">
- ID ,
- FLAG_LEAF ,
- SEQ ,
- PRIV_TYPE ,
- PRIV_NAME ,
- OWNER_SYSTEM ,
- CODE ,
- PARENT_ID ,
- PRIV_URI
- </sql>
- <sql id="entity_properties">
- #{id},
- #{flagLeaf},
- #{seq},
- #{privType},
- #{privName},
- #{ownerSystem},
- #{code},
- #{parentId},
- #{privUri}
- </sql>
- <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
- <sql id="page_where">
- <trim prefix="where" prefixOverrides="and | or ">
- <if test="id != null and id != ''">and ID = #{id}</if>
- <if test="flagLeaf != null and flagLeaf != ''">and FLAG_LEAF = #{flagLeaf}</if>
- <if test="seq != null">and SEQ = #{seq}</if>
- <if test="privType != null and privType != ''">and PRIV_TYPE = #{privType}</if>
- <if test="privName != null and privName != ''">and PRIV_NAME LIKE '%'||#{privName}||'%'</if>
- <if test="ownerSystem != null and ownerSystem != ''">and OWNER_SYSTEM = #{ownerSystem}</if>
- <if test="code != null and code != ''">and CODE = #{code}</if>
- <if test="parentId != null and parentId != ''">and PARENT_ID = #{parentId}</if>
- <if test="privUri != null and privUri != ''">and PRIV_URI = #{privUri}</if>
- </trim>
- </sql>
- <select id="get" resultMap="privResultMap" parameterType="String">
- select
- <include refid="table_columns"/>
- from GW_SYS_PRIV where ID = #{id}
- </select>
- <select id="getBy" resultMap="privResultMap">
- select
- <include refid="table_columns"/>
- from GW_SYS_PRIV
- <include refid="page_where"/>
- </select>
- <select id="findAll" resultMap="privResultMap">
- select
- <include refid="table_columns"/>
- from GW_SYS_PRIV
- </select>
- <select id="findList" resultMap="privResultMap">
- select
- <include refid="table_columns"/>
- from GW_SYS_PRIV
- <include refid="page_where"/>
- ORDER BY ID
- </select>
- <select id="selectCount" resultType="int">
- select count(ID) from GW_SYS_PRIV
- <include refid="page_where"/>
- </select>
- <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.Priv">
- insert into GW_SYS_PRIV(
- <include refid="table_columns2"/>
- )
- values (
- <include refid="entity_properties"/>
- )
- </insert>
- <delete id="delete" parameterType="java.lang.String">
- delete from GW_SYS_PRIV where ID = #{id}
- </delete>
- <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.Priv">
- delete from GW_SYS_PRIV
- <include refid="page_where"/>
- </delete>
- <update id="deleteInFlag" parameterType="java.lang.String">
- update GW_SYS_PRIV set flag_valid = 0 where ID = #{id}
- </update>
- <update id="update" parameterType="cn.com.goldenwater.dcproj.model.Priv">
- update GW_SYS_PRIV
- <trim prefix="set" suffixOverrides=",">
- <if test="id != null and id != ''">ID = #{id},</if>
- <if test="flagLeaf != null and flagLeaf != ''">FLAG_LEAF = #{flagLeaf},</if>
- <if test="seq != null">SEQ = #{seq},</if>
- <if test="privType != null and privType != ''">PRIV_TYPE = #{privType},</if>
- <if test="privName != null and privName != ''">PRIV_NAME = #{privName},</if>
- <if test="ownerSystem != null and ownerSystem != ''">OWNER_SYSTEM = #{ownerSystem},</if>
- <if test="code != null and code != ''">CODE = #{code},</if>
- <if test="parentId != null and parentId != ''">PARENT_ID = #{parentId},</if>
- <if test="privUri != null and privUri != ''">PRIV_URI = #{privUri},</if>
- </trim>
- <where>ID = #{id}</where>
- </update>
- <!-- 其他自定义SQL -->
- <!-- 分页获取列表 -->
- <select id="findPageStatic" resultMap="dtoPrivResultMap" parameterType="cn.com.goldenwater.dcproj.param.PrivParam">
- select
- A.ID,A.PRIV_NAME,A.PARENT_ID,A.PRIV_URI,B.PRIV_NAME PARENT_NAME,A.PRIV_TYPE,A.FLAG_LEAF,
- CASE WHEN A.FLAG_LEAF='1' THEN '是' ELSE '否' END FLAG_LEAF_CN
- from GW_SYS_PRIV A
- LEFT JOIN GW_SYS_PRIV B ON A.PARENT_ID=B.ID
- where 1 = 1
- <if test="id != null and id != ''">and A.id = #{id}</if>
- <if test="privName != null and privName != ''">and A.priv_name like '%'||#{privName}||'%'</if>
- <if test="privType != null and privType != ''">and A.parent_type = #{privType}</if>
- <if test="privUri != null and privUri != ''">and A.priv_uri =#{privUri}</if>
- <if test="parentId != null and parentId != ''">and A.parent_id = #{parentId}</if>
- <if test="flagLeaf != null and flagLeaf != ''">and A.flagleaf=#{flagLeaf}</if>
- order by A.id desc
- </select>
- <!-- 根据角色id获取树 -->
- <select id="findTreeByRoleId" resultMap="dtoPrivResultMap" parameterType="String">
- select
- A.ID,
- A.PRIV_NAME,
- A.PRIV_TYPE,
- A.PRIV_URI,
- A.PARENT_ID,
- A.CODE,
- A.OWNER_SYSTEM,
- B.PRIV_NAME AS PARENT_NAME,
- A.FLAG_LEAF
- <if test="roleId != null and roleId != ''">
- ,B.ROLE_ID,
- CASE B.ROLE_ID WHEN #{roleId} THEN 1 ELSE 0 END CHECKED
- </if>
- FROM GW_SYS_PRIV A
- left JOIN GW_SYS_MENU M ON A.ID = M.PRIV_ID
- LEFT JOIN GW_SYS_PRIV B ON A.PARENT_ID=B.ID
- <if test="roleId != null and roleId != ''">
- LEFT JOIN (SELECT ROLE_ID,PRIV_ID FROM GW_SYS_REL_ROLE_PRIV WHERE ROLE_ID=#{roleId}) B ON B.PRIV_ID=A.ID
- </if>
- WHERE 1=1
- <if test="persId != null and persId!=''">
- AND A.ID IN
- (select distinct priv_id
- from gw_sys_rel_role_priv t
- where role_id in
- (select role_id from gw_sys_rel_user_role where user_id in (#{persId}))
- )
- </if>
- <if test="list != null and list.size()>0">
- AND A.OWNER_SYSTEM IN
- <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="name != null and name!=''">
- AND A.PRIV_NAME LIKE '%'||#{name}||'%'
- </if>
- ORDER BY M.OWN_APP, TO_NUMBER(A.SEQ)
- </select>
- <select id="findFirstLevelTree" resultMap="privResultMap" parameterType="String">
- select
- <include refid="table_columns"/>
- FROM GW_SYS_PRIV
- <where>
- <if test="list != null and list.size()>0">
- AND A.OWNER_SYSTEM IN
- <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <choose>
- <when test="name != null and name!=''">
- AND A.PRIV_NAME LIKE '%'||#{name}||'%'
- </when>
- <otherwise>
- and PARENT_ID = '0'
- </otherwise>
- </choose>
- </where>
- ORDER BY ID, SEQ
- </select>
- <select id="getListByUserId" resultType="cn.com.goldenwater.dcproj.dto.PrivSysDto" parameterType="string">
- select DISTINCT C.ID,C.PRIV_NAME,D.DICT_DESC
- PRIV_TYPE,C.PRIV_URI,C.PARENT_ID,C.FLAG_LEAF,C.CODE,C.SEQ,C.OWNER_SYSTEM
- from GW_SYS_REL_USER_ROLE A LEFT JOIN GW_SYS_REL_ROLE_PRIV B ON A.ROLE_ID=B.ROLE_ID LEFT JOIN GW_SYS_PRIV C ON
- B.PRIV_ID=C.ID LEFT JOIN GW_COM_DICT D ON C.PRIV_TYPE=D.DICT_CD
- WHERE A.USER_ID=#{userId}
- <!--<if test="ownerSystem != null and ownerSystem != ''">-->
- <!--AND C.OWNER_SYSTEM=#{ownerSystem}-->
- <!--</if>-->
- ORDER BY C.SEQ
- </select>
- <select id="getPriViewListByUserId" resultType="cn.com.goldenwater.dcproj.dto.PrivSysDto" parameterType="string">
- select DISTINCT C.ID,C.PRIV_NAME,D.DICT_DESC
- PRIV_TYPE,C.PRIV_URI,C.PARENT_ID,C.FLAG_LEAF,C.CODE,C.SEQ,C.OWNER_SYSTEM
- from GW_SYS_REL_USER_ROLE A left join gw_sys_role r on A.Role_Id=r.id LEFT JOIN GW_SYS_REL_ROLE_PRIV B
- ON A.ROLE_ID=B.ROLE_ID LEFT JOIN GW_SYS_PRIV C ON
- B.PRIV_ID=C.ID LEFT JOIN GW_COM_DICT D ON C.PRIV_TYPE=D.DICT_CD
- WHERE A.USER_ID=#{userId} and c.priv_name like '%${privName}%'
- <if test="orgId !='' and orgId !=null">
- and r.org_id=#{orgId}
- </if>
- ORDER BY C.SEQ
- </select>
- <select id="selectMaxSeqByParentId" resultType="java.lang.Long" parameterType="string">
- SELECT MAX(SEQ) SEQ FROM GW_SYS_PRIV WHERE PARENT_ID=#{parentId}
- </select>
- </mapper>
|