疯狂的狮子li
2021-12-14 c5dbd04c9c99fc187ef526c0fda188dc30e51825
ruoyi-common/src/main/java/com/ruoyi/common/enums/DataScopeType.java
@@ -23,34 +23,39 @@
    /**
     * 全部数据权限
     */
    ALL("1", ""),
    ALL("1", "", ""),
    /**
     * 自定数据权限
     */
    CUSTOM("2", " #{#deptName} IN ( #{@sdss.getRoleCustom( #user.roleId )} ) "),
    CUSTOM("2", " #{#deptName} IN ( #{@sdss.getRoleCustom( #user.roleId )} ) ", ""),
    /**
     * 部门数据权限
     */
    DEPT("3", " #{#deptName} = #{#user.deptId} "),
    DEPT("3", " #{#deptName} = #{#user.deptId} ", ""),
    /**
     * 部门及以下数据权限
     */
    DEPT_AND_CHILD("4", " #{#deptName} IN ( #{@sdss.getDeptAndChild( #user.deptId )} )"),
    DEPT_AND_CHILD("4", " #{#deptName} IN ( #{@sdss.getDeptAndChild( #user.deptId )} )", ""),
    /**
     * 仅本人数据权限
     */
    SELF("5", " #{#userName?:1} = #{#user.userId} ");
    SELF("5", " #{#userName} = #{#user.userId} " , " 1 = 0 ");
    private final String code;
    /**
     * 语法 采用 spel 模板表达式
     */
    private final String sql;
    private final String sqlTemplate;
    /**
     * 不满足 sqlTemplate 则填充
     */
    private final String elseSql;
    public static DataScopeType findCode(String code) {
        if (StringUtils.isBlank(code)) {