:zap:数据返回格式改为可灵活扩展,跟ruoyi保存一致
This commit is contained in:
@@ -82,12 +82,7 @@ namespace ZR.ServiceCore.Middleware
|
||||
if (!HasPermi && !Permission.Equals("common"))
|
||||
{
|
||||
logger.Info($"用户{info.UserName}没有权限访问{url},当前权限[{Permission}]");
|
||||
JsonResult result = new(new ApiResult()
|
||||
{
|
||||
Code = (int)ResultCode.FORBIDDEN,
|
||||
Msg = $"你当前没有权限[{Permission}]访问,请联系管理员",
|
||||
Data = url
|
||||
})
|
||||
JsonResult result = new(new ApiResult((int)ResultCode.FORBIDDEN, $"你当前没有权限[{Permission}]访问,请联系管理员", url))
|
||||
{
|
||||
ContentType = "application/json",
|
||||
};
|
||||
|
||||
@@ -46,11 +46,8 @@ namespace ZR.ServiceCore.Middleware
|
||||
if (!string.IsNullOrEmpty(msg))
|
||||
{
|
||||
logger.Info($"请求参数错误,{msg}");
|
||||
ApiResult response = new()
|
||||
{
|
||||
Code = (int)ResultCode.PARAM_ERROR,
|
||||
Msg = msg
|
||||
};
|
||||
ApiResult response = new((int)ResultCode.PARAM_ERROR, msg);
|
||||
|
||||
context.Result = new JsonResult(response);
|
||||
}
|
||||
return base.OnActionExecutionAsync(context, next);
|
||||
|
||||
@@ -63,8 +63,9 @@ namespace ZR.Admin.WebApi.Filters
|
||||
{
|
||||
string msg = $"请求访问[{url}]失败,无法访问系统资源";
|
||||
//logger.Info(msg);
|
||||
|
||||
context.Result = new JsonResult(new ApiResult((int)ResultCode.DENY, msg));
|
||||
var r = new ApiResult((int)ResultCode.DENY, msg);
|
||||
|
||||
context.Result = new JsonResult(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user