fix namesapce

This commit is contained in:
2020-08-05 15:29:56 +08:00
parent f1138a5a10
commit 2abe486151
17 changed files with 117 additions and 120 deletions
@@ -1,49 +1,49 @@
using System;
using System.Linq;
using Microsoft.AspNetCore.Mvc.Filters;
using YYApi.Communications;
using YYApi.Exceptions;
using SimApi.Communications;
using SimApi.Exceptions;
namespace YYApi.Attributes
namespace SimApi.Attributes
{
/// <summary>
/// 检测登录中间件
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public class YYAuthAttribute : ActionFilterAttribute
public class SimApiAuthAttribute : ActionFilterAttribute
{
private string[] Types { get; }
//默认是user登录类型
public YYAuthAttribute()
public SimApiAuthAttribute()
{
Types = new[] { "user" };
}
//只检测一种用户类型的快捷方式
public YYAuthAttribute(string type)
public SimApiAuthAttribute(string type)
{
Types = new[] { type };
}
//设定特定类型的检测
public YYAuthAttribute(string[] types)
public SimApiAuthAttribute(string[] types)
{
Types = types;
}
public override void OnActionExecuting(ActionExecutingContext context)
{
var loginInfo = (YYLoginItem)context.HttpContext.Items["LoginInfo"];
var loginInfo = (SimApiLoginItem)context.HttpContext.Items["LoginInfo"];
//检测是否登录
if (loginInfo == null)
{
throw new YYApiException(401);
throw new SimApiException(401);
}
//检测用户类型
if (Types.Intersect(loginInfo.Type).Count() == 0)
{
throw new YYApiException(403);
throw new SimApiException(403);
}
}
}
@@ -1,20 +1,20 @@
using System;
using Swashbuckle.AspNetCore.Annotations;
namespace YYApi.Attributes
namespace SimApi.Attributes
{
/// <summary>
/// 快捷自定义接口文档类
/// </summary>
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
public class YYDocAttribute : SwaggerOperationAttribute
public class SimApiDocAttribute : SwaggerOperationAttribute
{
/// <summary>
/// 定义接口说明
/// </summary>
/// <param name="tag">接口分组</param>
/// <param name="name">接口名称</param>
public YYDocAttribute(string tag, string name)
public SimApiDocAttribute(string tag, string name)
{
Tags = new[] { tag };
Summary = name;