<?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="com.doumee.dao.system.SystemPermissionMapper">
|
|
<!-- 查询系统权限列表 -->
|
<resultMap id="SystemPermissionListVO" type="com.doumee.dao.system.vo.SystemPermissionListVO" autoMapping="true">
|
<id column="ID" property="id"/>
|
<association property="createUserInfo" javaType="com.doumee.dao.system.model.SystemUser">
|
<id column="CREATE_USER_ID" property="id"/>
|
<result column="CREATE_USER_NAME" property="username"/>
|
</association>
|
<association property="updateUserInfo" javaType="com.doumee.dao.system.model.SystemUser">
|
<id column="UPDATE_USER_ID" property="id"/>
|
<result column="UPDATE_USER_NAME" property="username"/>
|
</association>
|
</resultMap>
|
<select id="selectManageList" resultMap="SystemPermissionListVO">
|
SELECT
|
perm.*,
|
create_user.ID CREATE_USER_ID, create_user.`USERNAME` CREATE_USER_NAME,
|
update_user.ID UPDETE_USER_ID, update_user.`USERNAME` UPDATE_USER_NAME
|
FROM SYSTEM_PERMISSION perm
|
LEFT JOIN `SYSTEM_USER` create_user ON create_user.ID = perm.CREATE_USER
|
LEFT JOIN `SYSTEM_USER` update_user ON update_user.ID = perm.UPDATE_USER
|
<where>
|
perm.DELETED = 0
|
<if test="dto.code != null and dto.code!=''">
|
AND perm.CODE LIKE CONCAT('%', #{dto.code}, '%')
|
</if>
|
<if test="dto.type != null">
|
AND ifnull(perm.type,0) in(0, ${dto.type})
|
</if>
|
<if test="dto.iscom != null">
|
AND ifnull(perm.iscom,0) =${dto.iscom}
|
</if>
|
<if test="dto.isshop != null">
|
AND ifnull(perm.isshop,0)=${dto.isshop}
|
</if>
|
<if test="dto.isadmin != null">
|
AND ifnull(perm.isadmin,0) = ${dto.isadmin}
|
</if>
|
<if test="dto.name != null and dto.name!=''">
|
AND perm.`NAME` LIKE CONCAT('%', #{dto.name}, '%')
|
</if>
|
</where>
|
${orderByClause}
|
</select>
|
|
<!-- 根据用户ID查询权限 -->
|
<select id="selectByUserId" parameterType="java.lang.Integer" resultType="com.doumee.dao.system.model.SystemPermission">
|
SELECT
|
perm.*
|
FROM SYSTEM_PERMISSION perm
|
INNER JOIN SYSTEM_ROLE_PERMISSION role_perm ON role_perm.PERMISSION_ID = perm.ID AND role_perm.DELETED = 0
|
INNER JOIN SYSTEM_ROLE role ON role.ID = role_perm.ROLE_ID AND role.DELETED = 0
|
INNER JOIN SYSTEM_USER_ROLE user_role ON user_role.ROLE_ID = role.ID AND user_role.DELETED = 0
|
<where>
|
perm.DELETED = 0
|
AND user_role.USER_ID = #{userId}
|
</where>
|
</select>
|
|
<!-- 根据角色ID查询权限 -->
|
<select id="selectByRoleId" parameterType="java.lang.Integer" resultType="com.doumee.dao.system.model.SystemPermission">
|
SELECT
|
perm.*
|
FROM SYSTEM_PERMISSION perm
|
INNER JOIN SYSTEM_ROLE_PERMISSION role_perm ON role_perm.PERMISSION_ID = perm.ID AND role_perm.DELETED = 0
|
<where>
|
perm.DELETED = 0
|
AND role_perm.ROLE_ID = #{roleId}
|
</where>
|
</select>
|
|
</mapper>
|