using Furion.FriendlyException;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace FlexJobApi.Core
{
///
/// 资源
///
public class Resource : CommonEntity, IDbAuditLogIgnore, IPhysicalDeletion
{
///
/// 应用名称
///
public string ApplicationName { get; set; }
///
/// 动态程序集名称
///
public string DynamicAssemblyName { get; set; }
///
/// 服务名称
///
public string ServiceName { get; set; }
///
/// 控制器名称
///
public string ControllerName { get; set; }
///
/// 控制器摘要
///
public string ControllerSummary { get; set; }
///
/// 委托名称
///
public string ActionName { get; set; }
///
/// 委托摘要
///
public string ActionSummary { get; set; }
///
/// 编号
///
[Required]
public string Code { get; set; }
///
/// 名称
///
[Required]
public string Name { get; set; }
///
/// 忽略权限
///
public bool AllowAnonymous { get; set; }
///
/// 请求方式
///
public EnumResourceMethod Method { get; set; }
///
/// 文件上传
///
public bool FileUpload { get; set; }
///
/// 路由区域
///
public string RouteArea { get; set; }
///
/// 路由
///
[Required]
public string Route { get; set; }
///
/// 请求类型名称
///
[Required]
public string RequestTypeName { get; set; }
///
/// 请求类型全名
///
[Required]
public string RequestTypeFullName { get; set; }
///
/// 响应类型名称
///
public string ResponseTypeName { get; set; }
///
/// 响应类型全名
///
public string ResponseTypeFullName { get; set; }
///
/// 是否已过期
///
public bool IsExpired { get; set; }
public HttpMethod GetHttpMethod()
{
switch (Method)
{
case EnumResourceMethod.Get:
return HttpMethod.Get;
case EnumResourceMethod.Post:
return HttpMethod.Post;
case EnumResourceMethod.Put:
return HttpMethod.Put;
case EnumResourceMethod.Delete:
return HttpMethod.Delete;
default:
throw Oops.Oh(EnumErrorCodeType.s400, "不支持的请求类型");
}
}
}
}