using IRaCIS.Core.Domain.Share;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace IRaCIS.Core.API
{
    public static class AuthorizationPolicySetup
    {

        public static void AddAuthorizationPolicySetup(this IServiceCollection services, IConfiguration configuration)
        {
            services.AddAuthorization(options =>
            {
                //影像质控策略  只允许 CRC  QA进行操作
                options.AddPolicy("ImageQCPolicy", policyBuilder =>
                {
                    policyBuilder.RequireClaim("userTypeEnumInt", ((int)UserTypeEnum.ClinicalResearchCoordinator).ToString(), ((int)UserTypeEnum.IQC).ToString());
                });

                //一致性核查策略  只允许 CRC  PM APM 进行操作
                options.AddPolicy("ImageCheckPolicy", policyBuilder =>
                {
                    policyBuilder.RequireClaim("userTypeEnumInt", ((int)UserTypeEnum.ProjectManager).ToString(), ((int)UserTypeEnum.ClinicalResearchCoordinator).ToString(), ((int)UserTypeEnum.APM).ToString());
                });




            });
        }
    }
}
