//package com.engine.salary.config;
//
//import com.weaver.common.component.permission.container.FrontDataContainer;
//import com.weaver.common.mybatis.permission.config.PermissionConfig;
//import com.weaver.common.mybatis.permission.container.PermissionDataContainer;
//import com.weaver.common.mybatis.permission.model.PermissionModuleSourceBean;
//import com.weaver.common.mybatis.permission.model.PermissionModuleTargetBean;
//import com.weaver.common.mybatis.permission.service.PermissionModuleSourceService;
//import com.weaver.common.mybatis.permission.service.PermissionModuleTargetService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//
//import javax.annotation.PostConstruct;
//
///**
// * @description: 数据权限配置
// * @author: xiajun
// * @modified By: xiajun
// * @date: Created in 2023/6/7 10:28
// * @version:v1.0
// */
//@Configuration
//public class SalaryPermissionConfig {
//
//    @Autowired
//    private PermissionConfig permissionConfig;
//    @Autowired
//    private PermissionModuleSourceService permissionModuleSourceService;
//    @Autowired
//    private PermissionModuleTargetService permissionModuleTargetService;
//
//    public static final String TABLE_NAME = "hrsa";
//    public static final String PERMISSION_ID = "salary_standard_share";
//
//    /**
//     * 初始化模块支持的权限类型
//     */
//    @PostConstruct
//    public void init() {
//
//        // 初始化权限字典数据
//        permissionConfig.initPermissionData();
//
//        // 给permissionId指定sourceType 类型 ，可以是多个
//        PermissionModuleSourceBean permissionModuleSourceBean = new PermissionModuleSourceBean();
//        permissionModuleSourceBean.setPermissionId(PERMISSION_ID);
//        permissionModuleSourceBean.setSourceType(1); // 指定资源
//        permissionModuleSourceService.addBySql(permissionModuleSourceBean);
//
//        // 给permissionId指定targetType 类型 ，可以是多个
//        PermissionModuleTargetBean resourceTarget = new PermissionModuleTargetBean();
//        resourceTarget.setPermissionId(PERMISSION_ID);
//        resourceTarget.setTargetType(1); // 人力资源
//        permissionModuleTargetService.addBySql(resourceTarget);
//
//        PermissionModuleTargetBean departmentTarget = new PermissionModuleTargetBean();
//        departmentTarget.setPermissionId(PERMISSION_ID);
//        departmentTarget.setTargetType(2); // 部门+安全级别
//        permissionModuleTargetService.addBySql(departmentTarget);
//
//        PermissionModuleTargetBean departmentTarget2 = new PermissionModuleTargetBean();
//        departmentTarget2.setPermissionId(PERMISSION_ID);
//        departmentTarget2.setTargetType(2001); // 部门+包含兼职部门
//        permissionModuleTargetService.addBySql(departmentTarget2);
//
//        PermissionModuleTargetBean departmentTarget3 = new PermissionModuleTargetBean();
//        departmentTarget3.setPermissionId(PERMISSION_ID);
//        departmentTarget3.setTargetType(3); // 部门+所有下级部门+安全级别
//        permissionModuleTargetService.addBySql(departmentTarget3);
//
//        PermissionModuleTargetBean departmentTarget4 = new PermissionModuleTargetBean();
//        departmentTarget4.setPermissionId(PERMISSION_ID);
//        departmentTarget4.setTargetType(3001); // 部门+所有下级部门+包含兼职部门
//        permissionModuleTargetService.addBySql(departmentTarget4);
//
//        PermissionModuleTargetBean departmentTarget5 = new PermissionModuleTargetBean();
//        departmentTarget5.setPermissionId(PERMISSION_ID);
//        departmentTarget5.setTargetType(3002); // 部门+所有下级部门+包含兼职部门+安全级别
//        permissionModuleTargetService.addBySql(departmentTarget5);
//
//        PermissionModuleTargetBean departmentTarget6 = new PermissionModuleTargetBean();
//        departmentTarget6.setPermissionId(PERMISSION_ID);
//        departmentTarget6.setTargetType(2002); // 部门+包含兼职部门+安全级别
//        permissionModuleTargetService.addBySql(departmentTarget6);
//
//        PermissionModuleTargetBean branchTarget = new PermissionModuleTargetBean();
//        branchTarget.setPermissionId(PERMISSION_ID);
//        branchTarget.setTargetType(5); // 分部+安全级别
//        permissionModuleTargetService.addBySql(branchTarget);
//
//        PermissionModuleTargetBean branchTarget501 = new PermissionModuleTargetBean();
//        branchTarget501.setPermissionId(PERMISSION_ID);
//        branchTarget501.setTargetType(501); // 分部+安全级别
//        permissionModuleTargetService.addBySql(branchTarget501);
//
//        PermissionModuleTargetBean branchTarget502 = new PermissionModuleTargetBean();
//        branchTarget502.setPermissionId(PERMISSION_ID);
//        branchTarget502.setTargetType(502); // 分部+安全级别+兼职
//        permissionModuleTargetService.addBySql(branchTarget502);
//
//        PermissionModuleTargetBean branchTarget2 = new PermissionModuleTargetBean();
//        branchTarget2.setPermissionId(PERMISSION_ID);
//        branchTarget2.setTargetType(6); // 分部+所有下级分部+安全级别
//        permissionModuleTargetService.addBySql(branchTarget2);
//
//        PermissionModuleTargetBean roleTarget = new PermissionModuleTargetBean();
//        roleTarget.setPermissionId(PERMISSION_ID);
//        roleTarget.setTargetType(10); // 角色+角色级别+安全级别
//        permissionModuleTargetService.addBySql(roleTarget);
//
//        PermissionModuleTargetBean allPeopleTarget = new PermissionModuleTargetBean();
//        allPeopleTarget.setPermissionId(PERMISSION_ID);
//        allPeopleTarget.setTargetType(11); // 所有人+安全级别
//        permissionModuleTargetService.addBySql(allPeopleTarget);
//
//        PermissionModuleTargetBean positionTarget = new PermissionModuleTargetBean();
//        positionTarget.setPermissionId(PERMISSION_ID);
//        positionTarget.setTargetType(12); // 岗位+指定部门
//        permissionModuleTargetService.addBySql(positionTarget);
//
//        PermissionModuleTargetBean positionTarget12001 = new PermissionModuleTargetBean();
//        positionTarget12001.setPermissionId(PERMISSION_ID);
//        positionTarget12001.setTargetType(12001); // 岗位+指定部门+安全级别
//        permissionModuleTargetService.addBySql(positionTarget12001);
//
//        PermissionModuleTargetBean positionTarget12111 = new PermissionModuleTargetBean();
//        positionTarget12111.setPermissionId(PERMISSION_ID);
//        positionTarget12111.setTargetType(12111); // 岗位+指定部门+包含兼职岗位
//        permissionModuleTargetService.addBySql(positionTarget12111);
//
//        PermissionModuleTargetBean positionTarget12112 = new PermissionModuleTargetBean();
//        positionTarget12112.setPermissionId(PERMISSION_ID);
//        positionTarget12112.setTargetType(12112); // 岗位+指定部门+包含兼职岗位+安全级别
//        permissionModuleTargetService.addBySql(positionTarget12112);
//
//        PermissionModuleTargetBean positionTarget1201 = new PermissionModuleTargetBean();
//        positionTarget1201.setPermissionId(PERMISSION_ID);
//        positionTarget1201.setTargetType(1201); // 兼职岗位+安全级别
//        permissionModuleTargetService.addBySql(positionTarget1201);
//
//        PermissionModuleTargetBean positionTarget2 = new PermissionModuleTargetBean();
//        positionTarget2.setPermissionId(PERMISSION_ID);
//        positionTarget2.setTargetType(13); // 岗位+指定分部
//        permissionModuleTargetService.addBySql(positionTarget2);
//
//        PermissionModuleTargetBean positionTarget13001 = new PermissionModuleTargetBean();
//        positionTarget13001.setPermissionId(PERMISSION_ID);
//        positionTarget13001.setTargetType(13001); // 岗位+指定分部+安全级别
//        permissionModuleTargetService.addBySql(positionTarget13001);
//
//        PermissionModuleTargetBean positionTarget13110 = new PermissionModuleTargetBean();
//        positionTarget13110.setPermissionId(PERMISSION_ID);
//        positionTarget13110.setTargetType(13110); // 岗位+指定分部+包含兼职岗位 + 安全级别
//        permissionModuleTargetService.addBySql(positionTarget13110);
//
//        PermissionModuleTargetBean positionTarget1311 = new PermissionModuleTargetBean();
//        positionTarget1311.setPermissionId(PERMISSION_ID);
//        positionTarget1311.setTargetType(1311); // 岗位+总部
//        permissionModuleTargetService.addBySql(positionTarget1311);
//
//        PermissionModuleTargetBean positionTarget1312 = new PermissionModuleTargetBean();
//        positionTarget1312.setPermissionId(PERMISSION_ID);
//        positionTarget1312.setTargetType(1312); // 岗位+总部+安全级别
//        permissionModuleTargetService.addBySql(positionTarget1312);
//
//        PermissionModuleTargetBean positionTarget13111 = new PermissionModuleTargetBean();
//        positionTarget13111.setPermissionId(PERMISSION_ID);
//        positionTarget13111.setTargetType(13111); // 岗位+总部+包含兼职岗位
//        permissionModuleTargetService.addBySql(positionTarget13111);
//
//        PermissionModuleTargetBean positionTarget13112 = new PermissionModuleTargetBean();
//        positionTarget13112.setPermissionId(PERMISSION_ID);
//        positionTarget13112.setTargetType(13112); // 岗位+总部+包含兼职岗位+安全级别
//        permissionModuleTargetService.addBySql(positionTarget13112);
//
//        PermissionModuleTargetBean groupTarget = new PermissionModuleTargetBean();
//        groupTarget.setPermissionId(PERMISSION_ID);
//        groupTarget.setTargetType(14); // 群组+安全级别
//        permissionModuleTargetService.addBySql(groupTarget);
//
//        PermissionModuleTargetBean groupTarget2 = new PermissionModuleTargetBean();
//        groupTarget2.setPermissionId(PERMISSION_ID);
//        groupTarget2.setTargetType(1411); // 群组
//        permissionModuleTargetService.addBySql(groupTarget2);
//
//        // 创建权限表
//        // 一般模块要创建固定的权限表，类似流程模块可以调用这个接口，其他环境一般没有建表权限，以脚本的形式提供
//        // databaseService.createPermissionTable(TABLE_NAME,PERMISSION_ID);
//
//        // 初始化permissionId和权限表的关系
//        FrontDataContainer.permissionFrontDataMap.put(PERMISSION_ID, TABLE_NAME);
//        PermissionDataContainer.permissionDataContainer.put(PERMISSION_ID, TABLE_NAME);
//    }
//}
