package cn.iocoder.yudao.module.system.framework.datapermission.config;

import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.framework.datapermission.core.rule.dept.DeptDataPermissionRuleCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * system 模块的数据权限 Configuration
 *
 * @author 芋道源码
 */
@Configuration(proxyBeanMethods = false)
public class DataPermissionConfiguration {

    @Bean
    public DeptDataPermissionRuleCustomizer sysDeptDataPermissionRuleCustomizer() {
        return rule -> {
            System.out.println("初始化系统数据权限规则...");
            // dept
            rule.addDeptColumn(AdminUserDO.class);
            rule.addDeptColumn(DeptDO.class, "id");
            // user
            rule.addUserColumn(AdminUserDO.class, "id");

            rule.addDeptColumn("trs_harmful_info_report", "department_id");
            rule.addDeptColumn("trs_rectify_info_report", "department_id");
            rule.addDeptColumn("trs_interview_article", "department_id");
            rule.addDeptColumn("trs_tech_org", "tech_org_id");
            rule.addDeptColumn("trs_policy_communications", "department_id");
            System.out.println("系统数据权限规则初始化完成");
        };
    }

}
