package cn.iocoder.yudao.module.supplier.config;

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

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

    @Bean(name = "supplierDeptDataPermissionRuleCustomizer")
    public DeptDataPermissionRuleCustomizer sysDeptDataPermissionRuleCustomizer() {
        return rule -> {
            // dept
            rule.addDeptColumn(SupplierDO.class);
            rule.addDeptColumn(DeptDO.class, "id");
            rule.addDeptColumn(SupplierDO.class, "dept_id");
            // user
            rule.addUserColumn(SupplierDO.class);
            rule.addUserColumn(AdminUserDO.class, "id");
            rule.addUserColumn(SupplierDO.class, "creator");
        };
    }

}
