| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <?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.RoleDao">
- <resultMap type="cn.com.goldenwater.dcproj.model.Role" id="roleResultMap">
- <result property="id" column="ID"/>
- <result property="ofcId" column="OFC_ID"/>
- <result property="roleName" column="ROLE_NAME"/>
- <result property="flagValid" column="FLAG_VALID"/>
- <result property="dataScope" column="DATA_SCOPE"/>
- <result property="ownerSystem" column="OWNER_SYSTEM"/>
- <result property="orgId" column="ORG_ID"/>
- </resultMap>
- <resultMap type="cn.com.goldenwater.dcproj.dto.RoleDto" id="dtoRoleResultMap">
- <result property="id" column="ID"/>
- <result property="ofcId" column="OFC_ID"/>
- <result property="ofcName" column="OFC_NAME"/>
- <result property="roleName" column="ROLE_NAME"/>
- <result property="flagValid" column="FLAG_VALID"/>
- <result property="dataScope" column="DATA_SCOPE"/>
- <result property="isCurrentUser" column="IS_CURRENT_USER"/>
- <result property="ownerSystem" column="OWNER_SYSTEM"/>
- <result property="orgId" column="ORG_ID"/>
- </resultMap>
- <sql id="table_columns">
- ID ,
- ROLE_NAME ,
- OFC_ID ,
- OWNER_SYSTEM ,
- FLAG_VALID ,
- DATA_SCOPE,ORG_ID
- </sql>
- <sql id="table_columns2">
- ID ,
- ROLE_NAME ,
- OFC_ID ,
- OWNER_SYSTEM ,
- FLAG_VALID ,
- DATA_SCOPE,ORG_ID
- </sql>
- <sql id="entity_properties">
- #{id},
- #{roleName},
- #{ofcId},
- #{ownerSystem},
- #{flagValid},
- #{dataScope},#{orgId}
- </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="roleName != null and roleName != ''">and ROLE_NAME LIKE concat('%',#{roleName},'%')</if>
- <if test="ofcId != null and ofcId != ''">and OFC_ID = #{ofcId}</if>
- <if test="ownerSystem != null and ownerSystem != ''">and OWNER_SYSTEM = #{ownerSystem}</if>
- <if test="flagValid != null and flagValid != ''">and FLAG_VALID = #{flagValid}</if>
- <if test="dataScope != null and dataScope != ''">and DATA_SCOPE = #{dataScope}</if>
- <if test="orgId != null and orgId != ''">and ORG_ID = #{orgId}</if>
- </trim>
- </sql>
- <select id="get" resultMap="roleResultMap" parameterType="String">
- select
- <include refid="table_columns"/>
- from GW_SYS_ROLE where ID = #{id}
- </select>
- <select id="getone" parameterType="String" resultMap="roleResultMap">
- select
- <include refid="table_columns"/>
- from GW_SYS_ROLE where role_name=#{roleName}
- <choose>
- <when test="ofcId !=null and ofcId !=''">
- and ofc_id=#{ofcId}
- </when>
- <otherwise>
- and ofc_id is null
- </otherwise>
- </choose>
- </select>
- <select id="getBy" resultMap="roleResultMap">
- select
- <include refid="table_columns"/>
- from GW_SYS_ROLE
- <include refid="page_where"/>
- </select>
- <select id="findAll" resultMap="roleResultMap">
- select
- <include refid="table_columns"/>
- from GW_SYS_ROLE
- </select>
- <select id="findList" resultMap="roleResultMap">
- select
- <include refid="table_columns"/>
- from GW_SYS_ROLE
- <include refid="page_where"/>
- ORDER BY ID
- </select>
- <select id="selectCount" resultType="int">
- select count(ID) from GW_SYS_ROLE
- <include refid="page_where"/>
- </select>
- <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.Role">
- insert into GW_SYS_ROLE(
- <include refid="table_columns2"/>
- )
- values (
- <include refid="entity_properties"/>
- )
- </insert>
- <delete id="delete" parameterType="java.lang.String">
- delete from GW_SYS_ROLE where ID = #{id}
- </delete>
- <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.Role">
- delete from GW_SYS_ROLE
- <include refid="page_where"/>
- </delete>
- <update id="deleteInFlag" parameterType="java.lang.String">
- update GW_SYS_ROLE set flag_valid = 0 where ID = #{id}
- </update>
- <update id="update" parameterType="cn.com.goldenwater.dcproj.model.Role">
- update GW_SYS_ROLE
- <trim prefix="set" suffixOverrides=",">
- <if test="id != null and id != ''">ID = #{id},</if>
- <if test="roleName != null and roleName != ''">ROLE_NAME = #{roleName},</if>
- <if test="ofcId != null and ofcId != ''">OFC_ID = #{ofcId},</if>
- <if test="ownerSystem != null and ownerSystem != ''">OWNER_SYSTEM = #{ownerSystem},</if>
- <if test="flagValid != null and flagValid != ''">FLAG_VALID = #{flagValid},</if>
- <if test="dataScope != null and dataScope != ''">DATA_SCOPE = #{dataScope},</if>
- <if test="orgId != null and orgId != ''">ORG_ID = #{orgId},</if>
- </trim>
- <where>ID = #{id}</where>
- </update>
- <!-- 根据用户id获取角色列表 -->
- <select id="getRoleByUserId" parameterType="String" resultMap="dtoRoleResultMap">
- SELECT B.ID,B.OFC_ID,B.ROLE_NAME,B.FLAG_VALID,B.DATA_SCOPE,B.OWNER_SYSTEM,
- CASE A.USER_ID WHEN #{userId} THEN 1 ELSE 0 END IS_CURRENT_USER
- FROM (SELECT * FROM GW_SYS_REL_USER_ROLE where user_id=#{userId})
- A RIGHT JOIN GW_SYS_ROLE B ON A.ROLE_ID=B.ID
- WHERE B.FLAG_VALID='1'
- <if test="list != null and list.size()>0">
- AND B.OWNER_SYSTEM IN
- <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <include refid="choseSql"/>
- <if test="name != null and name!=''">
- AND B.ROLE_NAME LIKE CONCAT('%', #{name}, '%')
- </if>
- ORDER BY B.ID
- </select>
- <sql id="choseSql">
- <choose>
- <when test="province !=null and province !=''">
- and B.ofc_id = #{orgId}
- </when>
- <otherwise>
- and B.ofc_id is null
- </otherwise>
- </choose>
- </sql>
- <!-- 分页获取角色列表 -->
- <select id="findPageDto" parameterType="cn.com.goldenwater.dcproj.param.RoleParam" resultMap="dtoRoleResultMap">
- SELECT B.ID,B.OFC_ID,B.ROLE_NAME,B.FLAG_VALID,B.DATA_SCOPE
- FROM GW_SYS_ROLE B
- WHERE 1=1
- <if test="roleName != null and roleName != ''">and B.ROLE_NAME LIKE concat('%',#{roleName},'%')</if>
- <if test="flagValid != null">and B.FLAG_VALID = #{flagValid}</if>
- <if test="dataScope != null and dataScope != ''">and B.DATA_SCOPE = #{dataScope}</if>
- <include refid="choseSql"/>
- ORDER BY B.ID DESC
- </select>
- <!-- 福建省标准化工地 移动端查询权限 -->
- <select id="getTabPriByUserId" resultMap="roleResultMap">
- select r.* from GW_SYS_ROLE r
- where r.org_id = #{orgId} and r.id in (select ur.role_id from GW_SYS_REL_USER_ROLE ur where ur.user_id = #{userId} )
- </select>
- </mapper>
|