package com.openhis.web.document.util;

import com.core.common.annotation.Excel;
import com.core.common.core.domain.entity.SysRole;
import com.core.common.utils.SecurityUtils;
import com.openhis.common.enums.DocPermissionEnum;
import com.openhis.web.document.dto.DocDefinitionDto;

import java.util.ArrayList;
import java.util.List;

public class PermissionProcessor {
    public static boolean hasPermission(DocDefinitionDto docDefinitionDto) {
//肯定还得改
        List<SysRole> roleList = SecurityUtils.getLoginUser().getRoleList();
        boolean result = false;
        for (SysRole role : roleList) {
            if (role.getRoleKey().equals("admin")) {
                return true;
            }
            if (role.getRoleKey().equals("doctor") && docDefinitionDto.getDoctorPermissionEnum() != DocPermissionEnum.VIEW.getValue()) {
                return true;
            }
            if (role.getRoleKey().equals("nurse") && docDefinitionDto.getNursingPermissionEnum() != DocPermissionEnum.VIEW.getValue()) {
                return true;
            }
            if (role.getRoleKey().equals("medicalSkill") && docDefinitionDto.getMedicalPermissionEnum() != DocPermissionEnum.VIEW.getValue()) {
                return true;
            }
            if (role.getRoleKey().equals("pharmacist") && docDefinitionDto.getPharmacistPermissionEnum() != DocPermissionEnum.VIEW.getValue()) {
                return true;
            }
        }
        return result;
    }
}
