♻️代码重构
This commit is contained in:
parent
c65952202a
commit
be515339fe
@ -1,11 +1,16 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Infrastructure.Extensions;
|
||||
using Infrastructure.Model;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MiniExcelLibs;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using Io = System.IO;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers
|
||||
namespace Infrastructure.Controllers
|
||||
{
|
||||
public class BaseController : ControllerBase
|
||||
{
|
||||
@ -60,7 +65,7 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
{
|
||||
throw new CustomException(fileName + "文件不存在");
|
||||
}
|
||||
var stream = Io.File.OpenRead(path); //创建文件流
|
||||
var stream = System.IO.File.OpenRead(path); //创建文件流
|
||||
|
||||
Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition");
|
||||
return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", HttpUtility.UrlEncode(fileName));
|
||||
@ -2,7 +2,7 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Infrastructure
|
||||
namespace Infrastructure.Converter
|
||||
{
|
||||
public class JsonConverterUtil
|
||||
{
|
||||
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Infrastructure
|
||||
namespace Infrastructure.Converter
|
||||
{
|
||||
/// <summary>
|
||||
/// Json任何类型读取到字符串属性
|
||||
@ -54,5 +54,10 @@
|
||||
/// 清空数据
|
||||
/// </summary>
|
||||
CLEAN = 9,
|
||||
|
||||
/// <summary>
|
||||
/// 下载
|
||||
/// </summary>
|
||||
DOWNLOAD = 10,
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace ZR.Common
|
||||
namespace Infrastructure.Helper
|
||||
{
|
||||
public class JnHelper
|
||||
{
|
||||
@ -1,6 +1,5 @@
|
||||
using Infrastructure.Extensions;
|
||||
using Infrastructure.Model;
|
||||
using Infrastructure.WebExtensins;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@ -15,6 +15,10 @@ namespace Infrastructure.Model
|
||||
/// 是否演示模式
|
||||
/// </summary>
|
||||
public bool DemoMode { get; set; }
|
||||
/// <summary>
|
||||
/// 初始化db
|
||||
/// </summary>
|
||||
public bool InitDb { get; set; }
|
||||
public MailOptions MailOptions { get; set; }
|
||||
public Upload Upload { get; set; }
|
||||
public ALIYUN_OSS ALIYUN_OSS { get; set; }
|
||||
|
||||
@ -1,5 +1,12 @@
|
||||
namespace ZR.Admin.WebApi.Extensions
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
|
||||
namespace Infrastructure
|
||||
{
|
||||
/// <summary>
|
||||
/// 跨域扩展
|
||||
/// </summary>
|
||||
public static class CorsExtension
|
||||
{
|
||||
/// <summary>
|
||||
@ -1,7 +1,10 @@
|
||||
|
||||
using Infrastructure.Extensions;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ZR.Admin.WebApi.Extensions
|
||||
namespace Infrastructure
|
||||
{
|
||||
public static class EntityExtension
|
||||
{
|
||||
@ -1,5 +1,4 @@
|
||||
using Infrastructure.Extensions;
|
||||
using IPTools.Core;
|
||||
using IPTools.Core;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -10,7 +9,7 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using UAParser;
|
||||
|
||||
namespace Infrastructure.WebExtensins
|
||||
namespace Infrastructure.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// HttpContext扩展类
|
||||
@ -220,7 +219,8 @@ namespace Infrastructure.WebExtensins
|
||||
if (HttpMethods.IsPost(reqMethod) || HttpMethods.IsPut(reqMethod) || HttpMethods.IsDelete(reqMethod))
|
||||
{
|
||||
param = context.GetBody();
|
||||
param = PwdRep().Replace(param, "***");
|
||||
string regex = "(?<=\"password\":\")[^\",]*";
|
||||
param = Regex.Replace(param, regex, "***");
|
||||
}
|
||||
if (param.IsEmpty())
|
||||
{
|
||||
@ -228,9 +228,6 @@ namespace Infrastructure.WebExtensins
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
[GeneratedRegex("(?<=\"password\":\")[^\",]*")]
|
||||
private static partial Regex PwdRep();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,6 +1,9 @@
|
||||
using AspNetCoreRateLimit;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
|
||||
namespace ZR.Admin.WebApi.Extensions
|
||||
namespace ZR.Infrastructure.WebExtensions
|
||||
{
|
||||
public static class IPRateExtension
|
||||
{
|
||||
@ -1,4 +1,7 @@
|
||||
using JinianNet.JNTemplate;
|
||||
using Infrastructure.Helper;
|
||||
using JinianNet.JNTemplate;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
|
||||
namespace Infrastructure
|
||||
{
|
||||
@ -8,18 +8,19 @@
|
||||
|
||||
<ItemGroup>
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
<Compile Remove="Model\PagedInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspectCore.Abstractions" Version="2.4.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||
<PackageReference Include="IPTools.China" Version="1.6.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.7" />
|
||||
<PackageReference Include="JinianNet.JNTemplate" Version="2.3.3" />
|
||||
<PackageReference Include="MiniExcel" Version="1.31.2" />
|
||||
<PackageReference Include="CSRedisCore" Version="3.8.670" />
|
||||
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,10 +1,9 @@
|
||||
using Infrastructure.Extensions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Model.System;
|
||||
using ZR.Service.IService;
|
||||
using ZR.Service.System;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
@ -14,7 +13,6 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// 公共模块
|
||||
/// </summary>
|
||||
[Route("[controller]/[action]")]
|
||||
[Tags("公共模块Common")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class CommonController : BaseController
|
||||
{
|
||||
@ -23,18 +21,22 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
|
||||
private IWebHostEnvironment WebHostEnvironment;
|
||||
private ISysFileService SysFileService;
|
||||
private IHelloService HelloService;
|
||||
|
||||
public CommonController(
|
||||
IOptions<OptionsSetting> options,
|
||||
IWebHostEnvironment webHostEnvironment,
|
||||
ISysFileService fileService)
|
||||
ISysFileService fileService,
|
||||
IHelloService helloService)
|
||||
{
|
||||
WebHostEnvironment = webHostEnvironment;
|
||||
SysFileService = fileService;
|
||||
OptionsSetting = options.Value;
|
||||
HelloService = helloService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// hello
|
||||
/// home
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Route("/")]
|
||||
@ -45,6 +47,18 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
"如果觉得项目有用,打赏作者喝杯咖啡作为奖励\n☛☛http://www.izhaorui.cn/doc/support.html\n");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// hello
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
[Route("/hello")]
|
||||
[HttpGet]
|
||||
public IActionResult Hello(string name)
|
||||
{
|
||||
return Ok(HelloService.SayHello(name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 企业消息测试
|
||||
/// </summary>
|
||||
|
||||
@ -11,7 +11,6 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// 文章目录Controller
|
||||
/// </summary>
|
||||
[Route("article/ArticleCategory")]
|
||||
[Tags("文章目录")]
|
||||
[ApiExplorerSettings(GroupName = "article")]
|
||||
public class ArticleCategoryController : BaseController
|
||||
{
|
||||
|
||||
@ -13,7 +13,6 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("article")]
|
||||
[Tags("文章管理")]
|
||||
[ApiExplorerSettings(GroupName = "article")]
|
||||
public class ArticleController : BaseController
|
||||
{
|
||||
@ -89,7 +88,7 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
var model = response.Adapt<ArticleDto>();
|
||||
if (model.IsPublic == 0 && userId != model.UserId)
|
||||
{
|
||||
return ToResponse(Infrastructure.ResultCode.CUSTOM_ERROR, "访问失败");
|
||||
return ToResponse(ResultCode.CUSTOM_ERROR, "访问失败");
|
||||
}
|
||||
if (model != null)
|
||||
{
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Infrastructure.Extensions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
@ -18,7 +17,6 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("tool/gen")]
|
||||
[Tags("代码生成CodeGenerator")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class CodeGeneratorController : BaseController
|
||||
{
|
||||
|
||||
@ -14,7 +14,6 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/CommonLang")]
|
||||
[Tags("多语言配置CommonLang")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class CommonLangController : BaseController
|
||||
{
|
||||
|
||||
@ -14,7 +14,6 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/config")]
|
||||
[Tags("系统配置SysConfig")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysConfigController : BaseController
|
||||
{
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
@ -13,7 +12,6 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/dept")]
|
||||
[Tags("部门管理SysDept")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysDeptController : BaseController
|
||||
{
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
@ -13,7 +12,6 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/dict/data")]
|
||||
[Tags("字典数据SysDictData")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysDictDataController : BaseController
|
||||
{
|
||||
|
||||
@ -13,7 +13,6 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/dict/type")]
|
||||
[Tags("字典数据类型SysDictType")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysDictTypeController : BaseController
|
||||
{
|
||||
|
||||
@ -12,7 +12,6 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("tool/file")]
|
||||
[Tags(" 文件存储SysFile")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysFileController : BaseController
|
||||
{
|
||||
|
||||
@ -12,7 +12,6 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// <summary>
|
||||
/// 登录
|
||||
/// </summary>
|
||||
[Tags("登录SysLogin")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysLoginController : BaseController
|
||||
{
|
||||
@ -160,7 +159,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// <returns></returns>
|
||||
[HttpPost("/register")]
|
||||
[AllowAnonymous]
|
||||
[Log(Title = "注册", BusinessType = Infrastructure.Enums.BusinessType.INSERT)]
|
||||
[Log(Title = "注册", BusinessType = BusinessType.INSERT)]
|
||||
public IActionResult Register([FromBody] RegisterDto dto)
|
||||
{
|
||||
SysConfig config = sysConfigService.GetSysConfigByKey("sys.account.register");
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
@ -12,7 +11,6 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("/system/menu")]
|
||||
[Tags("菜单管理SysMenu")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysMenuController : BaseController
|
||||
{
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
using Infrastructure.Constant;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using SqlSugar;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Admin.WebApi.Hubs;
|
||||
using ZR.Model;
|
||||
@ -17,7 +15,6 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/notice")]
|
||||
[Tags("系统通知SysNotice")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysNoticeController : BaseController
|
||||
{
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
using Infrastructure.Extensions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
@ -14,7 +12,6 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/post")]
|
||||
[Tags("岗位管理SysPost")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysPostController : BaseController
|
||||
{
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
@ -12,7 +11,6 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/user/profile")]
|
||||
[Tags("个人中心SysProfile")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysProfileController : BaseController
|
||||
{
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
@ -13,7 +12,6 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/role")]
|
||||
[Tags("角色管理SysRole")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysRoleController : BaseController
|
||||
{
|
||||
|
||||
@ -14,7 +14,6 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/user")]
|
||||
[Tags("用户管理SysUser")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysUserController : BaseController
|
||||
{
|
||||
|
||||
@ -10,7 +10,6 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/userRole")]
|
||||
[Tags("用户角色管理SysUserRole")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysUserRoleController : BaseController
|
||||
{
|
||||
@ -45,7 +44,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// <returns></returns>
|
||||
[HttpPost("create")]
|
||||
[ActionPermissionFilter(Permission = "system:roleusers:add")]
|
||||
[Log(Title = "添加角色用户", BusinessType = Infrastructure.Enums.BusinessType.INSERT)]
|
||||
[Log(Title = "添加角色用户", BusinessType = BusinessType.INSERT)]
|
||||
public IActionResult Create([FromBody] RoleUsersCreateDto roleUsersCreateDto)
|
||||
{
|
||||
var response = SysUserRoleService.InsertRoleUser(roleUsersCreateDto);
|
||||
@ -60,7 +59,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// <returns></returns>
|
||||
[HttpPost("delete")]
|
||||
[ActionPermissionFilter(Permission = "system:roleusers:remove")]
|
||||
[Log(Title = "删除角色用户", BusinessType = Infrastructure.Enums.BusinessType.DELETE)]
|
||||
[Log(Title = "删除角色用户", BusinessType = BusinessType.DELETE)]
|
||||
public IActionResult Delete([FromBody] RoleUsersCreateDto roleUsersCreateDto)
|
||||
{
|
||||
return SUCCESS(SysUserRoleService.DeleteRoleUserByUserIds(roleUsersCreateDto.RoleId, roleUsersCreateDto.UserIds));
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
using Infrastructure.Extensions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Quartz;
|
||||
using SqlSugar;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
@ -16,7 +14,6 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/Tasks")]
|
||||
[Tags("计划Tasks")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class TasksController : BaseController
|
||||
{
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Infrastructure.Extensions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Model;
|
||||
@ -14,7 +13,6 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("/monitor/jobLog")]
|
||||
[Tags("任务日志TasksLog")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class TasksLogController : BaseController
|
||||
{
|
||||
|
||||
@ -9,7 +9,6 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
||||
/// <summary>
|
||||
/// 系统监控
|
||||
/// </summary>
|
||||
[Tags("系统监控Monitor")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class MonitorController : BaseController
|
||||
{
|
||||
|
||||
@ -11,7 +11,6 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("monitor/SqlDiffLog")]
|
||||
[Tags("差异日志SqlDiffLog")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SqlDiffLogController : BaseController
|
||||
{
|
||||
|
||||
@ -13,7 +13,6 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("/monitor/logininfor")]
|
||||
[Tags("登录日志SysLogininfor")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysLogininforController : BaseController
|
||||
{
|
||||
|
||||
@ -11,7 +11,6 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("/monitor/operlog")]
|
||||
[Tags("操作日志SysOperlog")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysOperlogController : BaseController
|
||||
{
|
||||
@ -67,7 +66,7 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
||||
{
|
||||
if (!HttpContextExtension.IsAdmin(HttpContext))
|
||||
{
|
||||
return ToResponse(Infrastructure.ResultCode.CUSTOM_ERROR,"操作失败");
|
||||
return ToResponse(ResultCode.CUSTOM_ERROR,"操作失败");
|
||||
}
|
||||
sysOperLogService.CleanOperLog();
|
||||
|
||||
|
||||
@ -7,9 +7,11 @@ using ZR.Model.System.Dto;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers.monitor
|
||||
{
|
||||
/// <summary>
|
||||
/// 在线用户
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("monitor/online")]
|
||||
[Tags("在线用户SysUserOnline")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysUserOnlineController : BaseController
|
||||
{
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Infrastructure.Extensions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Web;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers
|
||||
@ -11,9 +10,6 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
[AllowAnonymous]
|
||||
public class WxOpenController : BaseController
|
||||
{
|
||||
private NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
public WxOpenController() { }
|
||||
|
||||
/// <summary>
|
||||
/// 获取签名
|
||||
/// </summary>
|
||||
|
||||
@ -75,6 +75,9 @@ namespace ZR.Admin.WebApi.Extensions
|
||||
//添加文档注释
|
||||
var baseDir = AppContext.BaseDirectory;
|
||||
c.IncludeXmlComments(Path.Combine(baseDir, "ZR.Model.xml"), true);
|
||||
c.IncludeXmlComments(Path.Combine(baseDir, "ZR.ServiceCore.xml"), true);
|
||||
c.IncludeXmlComments(Path.Combine(baseDir, "ZR.Service.xml"), true);
|
||||
c.IncludeXmlComments(Path.Combine(baseDir, "ZR.Admin.WebApi.xml"), true);
|
||||
|
||||
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||
var xmlPath = Path.Combine(baseDir, xmlFile);
|
||||
|
||||
@ -6,4 +6,5 @@ global using Infrastructure.Enums;
|
||||
global using Infrastructure.Model;
|
||||
global using Mapster;
|
||||
global using Infrastructure.Extensions;
|
||||
global using Infrastructure.WebExtensins;
|
||||
global using Infrastructure.Controllers;
|
||||
global using ZR.ServiceCore.Middleware;
|
||||
@ -80,8 +80,8 @@
|
||||
<!--<logger name="System.*" writeTo="blackhole" final="true" />-->
|
||||
<!-- Quartz -->
|
||||
<logger name="Quartz*" minlevel="Trace" maxlevel="Info" final="true" />
|
||||
<logger name="ZR.Admin.WebApi.Middleware.GlobalExceptionMiddleware" final="true" writeTo="console,errorfile"/>
|
||||
<logger name="ZR.Admin.WebApi.Extensions.DbExtension" final="true" writeTo="consoleSql,sqlfile"/>
|
||||
<logger name="ZR.ServiceCore.Middleware.GlobalExceptionMiddleware" final="true" writeTo="console,errorfile"/>
|
||||
<logger name="ZR.ServiceCore.SqlSugar.SqlsugarSetup" final="true" writeTo="consoleSql,sqlfile"/>
|
||||
<logger name="*" writeTo="console"/>
|
||||
|
||||
<logger name="*" minLevel="Trace" writeTo="allfile" />
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
using AspNetCoreRateLimit;
|
||||
using Infrastructure.Converter;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.Text.Json.Serialization;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Admin.WebApi.Hubs;
|
||||
using ZR.Admin.WebApi.Middleware;
|
||||
using ZR.Common.Cache;
|
||||
using ZR.Infrastructure.WebExtensions;
|
||||
using ZR.ServiceCore.Middleware;
|
||||
using ZR.ServiceCore.SqlSugar;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@ -83,7 +85,7 @@ builder.Services.AddMvc(options =>
|
||||
options.JsonSerializerOptions.WriteIndented = true;
|
||||
options.JsonSerializerOptions.Converters.Add(new JsonConverterUtil.DateTimeConverter());
|
||||
options.JsonSerializerOptions.Converters.Add(new JsonConverterUtil.DateTimeNullConverter());
|
||||
options.JsonSerializerOptions.Converters.Add(new Infrastructure.StringConverter());
|
||||
options.JsonSerializerOptions.Converters.Add(new StringConverter());
|
||||
});
|
||||
|
||||
builder.Services.AddSwaggerConfig();
|
||||
@ -93,7 +95,7 @@ InternalApp.ServiceProvider = app.Services;
|
||||
InternalApp.Configuration = builder.Configuration;
|
||||
InternalApp.WebHostEnvironment = app.Environment;
|
||||
//初始化db
|
||||
builder.Services.AddDb(builder.Configuration, app.Environment);
|
||||
builder.Services.AddDb(app.Environment);
|
||||
|
||||
//使用全局异常中间件
|
||||
app.UseMiddleware<GlobalExceptionMiddleware>();
|
||||
|
||||
@ -15,11 +15,9 @@
|
||||
<ProjectReference Include="..\ZR.Tasks\ZR.Tasks.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
|
||||
<PackageReference Include="Lazy.Captcha.Core" Version="2.0.3" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="7.0.6" />
|
||||
<PackageReference Include="NLog" Version="5.2.3" />
|
||||
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.3" />
|
||||
<PackageReference Include="Mapster" Version="7.3.0" />
|
||||
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.3" />
|
||||
@ -33,5 +31,11 @@
|
||||
<None Update="ip2region.db">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Content Update="wwwroot\Generatecode\**\*">
|
||||
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Update="wwwroot\export\**\*">
|
||||
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
"RefreshTokenTime": 5,//分钟
|
||||
"TokenType": "Bearer"
|
||||
},
|
||||
"InjectClass": [ "ZR.Repository", "ZR.Service", "ZR.Tasks" ], //自动注入类
|
||||
"InjectClass": [ "ZR.Repository", "ZR.Service", "ZR.Tasks", "ZR.ServiceCore" ], //自动注入类
|
||||
"ShowDbLog": true, //是否打印db日志
|
||||
"InitDb": false, //是否初始化db
|
||||
"DemoMode": false, //是否演示模式
|
||||
@ -130,6 +130,11 @@
|
||||
"Endpoint": "((post)|(put)):*",
|
||||
"Period": "3s",
|
||||
"Limit": 1
|
||||
},
|
||||
{
|
||||
"Endpoint": "*:*",
|
||||
"Period": "5s",
|
||||
"Limit": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Extensions;
|
||||
using Infrastructure.Helper;
|
||||
using Infrastructure.Model;
|
||||
using JinianNet.JNTemplate;
|
||||
using SqlSugar;
|
||||
@ -8,7 +9,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using ZR.CodeGenerator.Model;
|
||||
using ZR.Common;
|
||||
using ZR.Model.System.Generate;
|
||||
|
||||
namespace ZR.CodeGenerator
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
|
||||
<ProjectReference Include="..\Infrastructure\ZR.Infrastructure.csproj" />
|
||||
<ProjectReference Include="..\ZR.Common\ZR.Common.csproj" />
|
||||
<ProjectReference Include="..\ZR.Model\ZR.Model.csproj" />
|
||||
<ProjectReference Include="..\ZR.ServiceCore\ZR.ServiceCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -6,14 +6,10 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.13.0" />
|
||||
<PackageReference Include="CSRedisCore" Version="3.8.670" />
|
||||
<PackageReference Include="JinianNet.JNTemplate" Version="2.3.3" />
|
||||
<PackageReference Include="MailKit" Version="4.1.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" />
|
||||
<PackageReference Include="MiniExcel" Version="1.31.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
|
||||
<ProjectReference Include="..\Infrastructure\ZR.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@ -1 +0,0 @@
|
||||
此文件夹用于存放业务代码数据库实体类
|
||||
@ -1,9 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace ZR.Model
|
||||
{
|
||||
public enum ProteryConstant
|
||||
{
|
||||
NOTNULL = 0
|
||||
}
|
||||
}
|
||||
@ -12,4 +12,8 @@
|
||||
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.1.4.98" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@ -5,15 +5,13 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
|
||||
<ProjectReference Include="..\Infrastructure\ZR.Infrastructure.csproj" />
|
||||
<ProjectReference Include="..\ZR.Model\ZR.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Mapster" Version="7.3.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1" />
|
||||
<PackageReference Include="MySqlConnector" Version="2.2.6" />
|
||||
<PackageReference Include="NETCore.Encrypt" Version="2.1.1" />
|
||||
<PackageReference Include="SqlSugar.IOC" Version="2.0.0" />
|
||||
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.1.4.98" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -1 +1,4 @@
|
||||
global using System.Collections.Generic;
|
||||
global using System;
|
||||
global using SqlSugar;
|
||||
global using Newtonsoft.Json;
|
||||
59
ZR.Service/HelloService.cs
Normal file
59
ZR.Service/HelloService.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using SqlSugar.IOC;
|
||||
using ZR.Model.System;
|
||||
using ZR.Repository;
|
||||
using ZR.Service.IService;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// 注意:下面的AppService不要漏了
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IHelloService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class HelloService : BaseService<ArticleCategory>, IHelloService
|
||||
{
|
||||
/// <summary>
|
||||
/// 引用User服务
|
||||
/// </summary>
|
||||
private readonly ISysUserService userService;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="userService"></param>
|
||||
public HelloService(ISysUserService userService)
|
||||
{
|
||||
this.userService = userService;
|
||||
}
|
||||
/// <summary>
|
||||
/// 数据库使用案例
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public string SayHello(string name)
|
||||
{
|
||||
//构造函数式使用
|
||||
var user = JsonConvert.SerializeObject(userService.GetFirst(f => f.UserId == 1));
|
||||
Console.WriteLine(user);
|
||||
|
||||
var postService = App.GetRequiredService<ISysPostService>();
|
||||
Console.WriteLine(JsonConvert.SerializeObject(postService.GetId(1)));
|
||||
|
||||
BaseRepository<SysDept> deptRepo = new();
|
||||
Console.WriteLine(JsonConvert.SerializeObject(deptRepo.GetId(1)));
|
||||
|
||||
var result = DbScoped.SugarScope.Queryable<SysDictType>().Where(f => f.DictId == 1).First();
|
||||
Console.WriteLine(JsonConvert.SerializeObject(result));
|
||||
|
||||
//切换库
|
||||
//DbScoped.SugarScope.GetConnectionScope(2);
|
||||
|
||||
GetFirst(x => x.CategoryId == 1);
|
||||
Context.Queryable<SysUser>().First(f => f.UserId == 1);
|
||||
|
||||
return "Hello:" + name;
|
||||
}
|
||||
}
|
||||
}
|
||||
17
ZR.Service/IService/IHelloService.cs
Normal file
17
ZR.Service/IService/IHelloService.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using ZR.Model.System;
|
||||
|
||||
namespace ZR.Service.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// Hello接口
|
||||
/// </summary>
|
||||
public interface IHelloService : IBaseService<ArticleCategory>
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
string SayHello(string name);
|
||||
}
|
||||
}
|
||||
@ -2,11 +2,14 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<NoWarn>1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZR.Common\ZR.Common.csproj" />
|
||||
<ProjectReference Include="..\ZR.Repository\ZR.Repository.csproj" />
|
||||
<ProjectReference Include="..\ZR.ServiceCore\ZR.ServiceCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Model;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using ZR.Model.System;
|
||||
using ZR.Service.System;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Admin.WebApi.Filters
|
||||
namespace ZR.ServiceCore.Middleware
|
||||
{
|
||||
/// <summary>
|
||||
/// API授权判断
|
||||
@ -1,4 +1,8 @@
|
||||
using IPTools.Core;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Model;
|
||||
using IPTools.Core;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
@ -6,12 +10,12 @@ using NLog;
|
||||
using ZR.Model.System;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Admin.WebApi.Filters
|
||||
namespace ZR.ServiceCore.Middleware
|
||||
{
|
||||
public class GlobalActionMonitor : ActionFilterAttribute
|
||||
{
|
||||
static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
private ISysOperLogService OperLogService;
|
||||
private readonly ISysOperLogService OperLogService;
|
||||
public GlobalActionMonitor(ISysOperLogService operLogService)
|
||||
{
|
||||
OperLogService = operLogService;
|
||||
@ -126,7 +130,7 @@ namespace ZR.Admin.WebApi.Filters
|
||||
}
|
||||
}
|
||||
|
||||
private LogAttribute? GetLogAttribute(ControllerActionDescriptor controllerActionDescriptor)
|
||||
private LogAttribute GetLogAttribute(ControllerActionDescriptor controllerActionDescriptor)
|
||||
{
|
||||
var attribute = controllerActionDescriptor.MethodInfo.GetCustomAttributes(inherit: true)
|
||||
.FirstOrDefault(a => a.GetType().Equals(typeof(LogAttribute)));
|
||||
@ -1,18 +1,21 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Model;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using NLog;
|
||||
using ZR.Common;
|
||||
|
||||
//本命名空间暂时先不改,改动比较大2023年9月2日
|
||||
namespace ZR.Admin.WebApi.Filters
|
||||
{
|
||||
/// <summary>
|
||||
/// 授权校验访问
|
||||
/// 如果跳过授权登录在Action 或controller加上 AllowAnonymousAttribute
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.All)]
|
||||
public class VerifyAttribute : Attribute, IAuthorizationFilter
|
||||
{
|
||||
static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
/// <summary>
|
||||
/// 只判断token是否正确,不判断权限
|
||||
/// 如果需要判断权限的在Action上加上ApiActionPermission属性标识权限类别,ActionPermissionFilter作权限处理
|
||||
@ -32,7 +35,7 @@ namespace ZR.Admin.WebApi.Filters
|
||||
string ip = HttpContextExtension.GetClientUserIp(context.HttpContext);
|
||||
string url = context.HttpContext.Request.Path;
|
||||
var isAuthed = context.HttpContext.User.Identity.IsAuthenticated;
|
||||
|
||||
string osType = context.HttpContext.Request.Headers["os"];
|
||||
//使用jwt token校验2020-11-21
|
||||
TokenModel loginUser = JwtUtil.GetLoginUser(context.HttpContext);
|
||||
if (loginUser != null)
|
||||
@ -48,6 +51,11 @@ namespace ZR.Admin.WebApi.Filters
|
||||
var newToken = JwtUtil.GenerateJwtToken(JwtUtil.AddClaims(loginUser));
|
||||
|
||||
CacheHelper.SetCache(CK, CK, 1);
|
||||
//移动端不加下面这个获取不到自定义Header
|
||||
if (osType != null)
|
||||
{
|
||||
context.HttpContext.Response.Headers.Add("Access-Control-Expose-Headers", "X-Refresh-Token");
|
||||
}
|
||||
context.HttpContext.Response.Headers.Add("X-Refresh-Token", newToken);
|
||||
}
|
||||
}
|
||||
5
ZR.ServiceCore/GlobalUsing.cs
Normal file
5
ZR.ServiceCore/GlobalUsing.cs
Normal file
@ -0,0 +1,5 @@
|
||||
global using Newtonsoft.Json;
|
||||
global using SqlSugar;
|
||||
global using System;
|
||||
global using System.Collections.Generic;
|
||||
global using Infrastructure.Extensions;
|
||||
@ -1,12 +1,17 @@
|
||||
using IPTools.Core;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Model;
|
||||
using IPTools.Core;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using NLog;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.Json;
|
||||
using ZR.Common;
|
||||
using ZR.Model.System;
|
||||
using ZR.Service.System.IService;
|
||||
using textJson = System.Text.Json;
|
||||
|
||||
namespace ZR.Admin.WebApi.Middleware
|
||||
namespace ZR.ServiceCore.Middleware
|
||||
{
|
||||
/// <summary>
|
||||
/// 全局异常处理中间件
|
||||
@ -62,15 +67,15 @@ namespace ZR.Admin.WebApi.Middleware
|
||||
logLevel = NLog.LogLevel.Error;
|
||||
context.Response.StatusCode = 500;
|
||||
}
|
||||
var options = new JsonSerializerOptions
|
||||
var options = new textJson.JsonSerializerOptions
|
||||
{
|
||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||
PropertyNamingPolicy = textJson.JsonNamingPolicy.CamelCase,
|
||||
WriteIndented = true
|
||||
};
|
||||
|
||||
ApiResult apiResult = new(code, msg);
|
||||
string responseResult = JsonSerializer.Serialize(apiResult, options).ToLower();
|
||||
string responseResult = textJson.JsonSerializer.Serialize(apiResult, options);
|
||||
string ip = HttpContextExtension.GetClientUserIp(context);
|
||||
var ip_info = IpTool.Search(ip);
|
||||
|
||||
@ -119,8 +124,8 @@ namespace ZR.Admin.WebApi.Middleware
|
||||
$"\n> 操作地址:{sysOperLog.OperUrl}" +
|
||||
$"\n> 错误信息:{msg}\n\n> {error}";
|
||||
|
||||
WxNoticeHelper.SendMsg("系统出错", errorMsg, "", WxNoticeHelper.MsgType.markdown);
|
||||
SysOperLogService.InsertOperlog(sysOperLog);
|
||||
WxNoticeHelper.SendMsg("系统出错", errorMsg, "", WxNoticeHelper.MsgType.markdown);
|
||||
}
|
||||
|
||||
public static Endpoint GetEndpoint(HttpContext context)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user