package com.sifang.modules.sys.init;

import com.sifang.modules.sys.common.entity.User;
import com.sifang.modules.sys.extention.permission.AbstractPermissionFilter;
import com.sifang.modules.sys.extention.permission.PermissionVo;
import com.sifang.modules.sys.extention.permission.filters.PlatformMemberPermissionFilter;

import java.util.HashMap;

public class LoginInitialization {

    public static void initPermission(User user){
        if("4".equals(user.getUserType())){//是平台的员工
            AbstractPermissionFilter apf = new PlatformMemberPermissionFilter();
            PermissionVo pv = new PermissionVo();
            pv.setUserId(user.getId());
            pv.setSysRoleId(user.getUserType());
            pv.setData(new HashMap<String, String>());

            apf.setVo(pv);
            apf.process();
            user.setApf(apf);
        }
        if("5".equals(user.getUserType())|| "6".equals(user.getUserType()) || User.USER_TYPE_ADVISOR.equals(user.getUserType())){//是服务商的员工
            AbstractPermissionFilter apf = new PlatformMemberPermissionFilter();
            PermissionVo pv = new PermissionVo();
            pv.setUserId(user.getId());
            pv.setSysRoleId(user.getUserType());
            pv.setData(new HashMap<String, String>());

            apf.setVo(pv);
            apf.process();
            user.setApf(apf);
        }else if("8".equals(user.getUserType())|| "9".equals(user.getUserType()) || User.USER_TYPE_HZS.equals(user.getUserType())){//是服务商的员工
            AbstractPermissionFilter apf = new PlatformMemberPermissionFilter();
            PermissionVo pv = new PermissionVo();
            pv.setUserId(user.getId());
            pv.setSysRoleId(user.getUserType());
            pv.setData(new HashMap<String, String>());

            apf.setVo(pv);
            apf.process();
            user.setApf(apf);
        }
    }
}
