<?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.xhkjedu.suser.mapper.system.UserModuleMapper">
    <!--根据用户id删除没有权限的常用模块-->
    <delete id="deleteNoRoleByUserId">
        DELETE FROM t_user_module WHERE userid=#{userid} AND moduleid
        NOT IN(SELECT rm.moduleid FROM t_user u LEFT JOIN t_user_role ur ON u.userid=ur.userid
        LEFT JOIN t_role_module rm ON ur.roleid=rm.roleid
        WHERE u.userid=#{userid} GROUP BY rm.moduleid)
    </delete>
</mapper>
