✨swagger新增分组
This commit is contained in:
parent
240a607875
commit
e8ab6d47eb
@ -14,6 +14,8 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// 公共模块
|
||||
/// </summary>
|
||||
[Route("[controller]/[action]")]
|
||||
[Tags("公共模块Common")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class CommonController : BaseController
|
||||
{
|
||||
private OptionsSetting OptionsSetting;
|
||||
|
||||
@ -11,6 +11,8 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// 文章目录Controller
|
||||
/// </summary>
|
||||
[Route("article/ArticleCategory")]
|
||||
[Tags("文章目录")]
|
||||
[ApiExplorerSettings(GroupName = "article")]
|
||||
public class ArticleCategoryController : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
@ -59,7 +61,7 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
public IActionResult GetArticleCategory(int CategoryId)
|
||||
{
|
||||
var response = _ArticleCategoryService.GetFirst(x => x.CategoryId == CategoryId);
|
||||
|
||||
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,8 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("article")]
|
||||
[Tags("文章管理")]
|
||||
[ApiExplorerSettings(GroupName = "article")]
|
||||
public class ArticleController : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
@ -32,7 +34,7 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("list")]
|
||||
[ActionPermissionFilter(Permission = "system:article:list")]
|
||||
[ActionPermissionFilter(RolePermi = "admin")]
|
||||
public IActionResult Query([FromQuery] ArticleQueryDto parm)
|
||||
{
|
||||
var response = _ArticleService.GetList(parm);
|
||||
|
||||
@ -1,8 +1,4 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Enums;
|
||||
using Infrastructure.Extensions;
|
||||
using Mapster;
|
||||
using Infrastructure.Extensions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using ZR.Admin.WebApi.Extensions;
|
||||
@ -10,7 +6,6 @@ using ZR.Admin.WebApi.Filters;
|
||||
using ZR.CodeGenerator;
|
||||
using ZR.CodeGenerator.Model;
|
||||
using ZR.CodeGenerator.Service;
|
||||
using ZR.Common;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Model.System.Generate;
|
||||
@ -23,6 +18,8 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("tool/gen")]
|
||||
[Tags("代码生成CodeGenerator")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class CodeGeneratorController : BaseController
|
||||
{
|
||||
private readonly CodeGeneraterService _CodeGeneraterService = new CodeGeneraterService();
|
||||
|
||||
@ -14,6 +14,8 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/CommonLang")]
|
||||
[Tags("多语言配置CommonLang")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class CommonLangController : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@ -14,6 +14,8 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/config")]
|
||||
[Tags("系统配置SysConfig")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysConfigController : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@ -13,6 +13,8 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/dept")]
|
||||
[Tags("部门管理SysDept")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysDeptController : BaseController
|
||||
{
|
||||
public ISysDeptService DeptService;
|
||||
|
||||
@ -13,6 +13,8 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/dict/data")]
|
||||
[Tags("字典数据SysDictData")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysDictDataController : BaseController
|
||||
{
|
||||
private readonly ISysDictDataService SysDictDataService;
|
||||
|
||||
@ -13,6 +13,8 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/dict/type")]
|
||||
[Tags("字典数据类型SysDictType")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysDictTypeController : BaseController
|
||||
{
|
||||
private readonly ISysDictService SysDictService;
|
||||
|
||||
@ -1,13 +1,9 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Enums;
|
||||
using Infrastructure.Model;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Common;
|
||||
using ZR.Model.System;
|
||||
using ZR.Service.System.IService;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers
|
||||
{
|
||||
@ -16,6 +12,8 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("tool/file")]
|
||||
[Tags(" 文件存储SysFile")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysFileController : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
@ -37,15 +35,13 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
[ActionPermissionFilter(Permission = "tool:file:list")]
|
||||
public IActionResult QuerySysFile([FromQuery] SysFileQueryDto parm)
|
||||
{
|
||||
//开始拼装查询条件
|
||||
var predicate = Expressionable.Create<SysFile>();
|
||||
//搜索条件查询语法参考Sqlsugar
|
||||
|
||||
predicate = predicate.AndIF(parm.BeginCreate_time != null, it => it.Create_time >= parm.BeginCreate_time);
|
||||
predicate = predicate.AndIF(parm.EndCreate_time != null, it => it.Create_time <= parm.EndCreate_time);
|
||||
predicate = predicate.AndIF(parm.StoreType != null, m => m.StoreType == parm.StoreType);
|
||||
predicate = predicate.AndIF(parm.FileId != null, m => m.Id == parm.FileId);
|
||||
|
||||
//搜索条件查询语法参考Sqlsugar
|
||||
var response = _SysFileService.GetPages(predicate.ToExpression(), parm, x => x.Id, OrderByType.Desc);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
@ -16,6 +16,8 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// <summary>
|
||||
/// 登录
|
||||
/// </summary>
|
||||
[Tags("登录SysLogin")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysLoginController : BaseController
|
||||
{
|
||||
static readonly NLog.Logger logger = NLog.LogManager.GetLogger("LoginController");
|
||||
@ -157,6 +159,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
public SysLogininfor RecordLogInfo(HttpContext context)
|
||||
{
|
||||
var ipAddr = context.GetClientUserIp();
|
||||
@ -194,7 +197,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
{
|
||||
return ToResponse(ResultCode.CAPTCHA_ERROR, "验证码错误");
|
||||
}
|
||||
|
||||
|
||||
SysUser user = sysUserService.Register(dto);
|
||||
if (user.UserId > 0)
|
||||
{
|
||||
|
||||
@ -12,6 +12,8 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("/system/menu")]
|
||||
[Tags("菜单管理SysMenu")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysMenuController : BaseController
|
||||
{
|
||||
private readonly ISysRoleService sysRoleService;
|
||||
|
||||
@ -17,6 +17,8 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/notice")]
|
||||
[Tags("系统通知SysNotice")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysNoticeController : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@ -14,6 +14,8 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/post")]
|
||||
[Tags("岗位管理SysPost")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysPostController : BaseController
|
||||
{
|
||||
private readonly ISysPostService PostService;
|
||||
@ -68,7 +70,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
throw new CustomException($"修改岗位{post.PostName}失败,岗位编码已存在");
|
||||
}
|
||||
post.ToCreate(HttpContext);
|
||||
|
||||
|
||||
return ToResponse(PostService.Add(post));
|
||||
}
|
||||
|
||||
@ -122,7 +124,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// 岗位导出
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Log(BusinessType = BusinessType.EXPORT, IsSaveResponseData = false, Title= "岗位导出")]
|
||||
[Log(BusinessType = BusinessType.EXPORT, IsSaveResponseData = false, Title = "岗位导出")]
|
||||
[HttpGet("export")]
|
||||
[ActionPermissionFilter(Permission = "system:post:export")]
|
||||
public IActionResult Export()
|
||||
|
||||
@ -12,6 +12,8 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/user/profile")]
|
||||
[Tags("个人中心SysProfile")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysProfileController : BaseController
|
||||
{
|
||||
private readonly ISysUserService UserService;
|
||||
|
||||
@ -13,6 +13,8 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/role")]
|
||||
[Tags("角色管理SysRole")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysRoleController : BaseController
|
||||
{
|
||||
private readonly ISysRoleService sysRoleService;
|
||||
|
||||
@ -15,6 +15,8 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/user")]
|
||||
[Tags("用户管理SysUser")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysUserController : BaseController
|
||||
{
|
||||
private readonly ISysUserService UserService;
|
||||
|
||||
@ -10,6 +10,8 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/userRole")]
|
||||
[Tags("用户角色管理SysUserRole")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysUserRoleController : BaseController
|
||||
{
|
||||
private readonly ISysUserRoleService SysUserRoleService;
|
||||
|
||||
@ -16,6 +16,8 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/Tasks")]
|
||||
[Tags("计划Tasks")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class TasksController : BaseController
|
||||
{
|
||||
private ISysTasksQzService _tasksQzService;
|
||||
|
||||
@ -1,11 +1,7 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Enums;
|
||||
using Infrastructure.Extensions;
|
||||
using Infrastructure.Extensions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Common;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
@ -18,6 +14,8 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("/monitor/jobLog")]
|
||||
[Tags("任务日志TasksLog")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class TasksLogController : BaseController
|
||||
{
|
||||
private readonly ISysTasksLogService tasksLogService;
|
||||
|
||||
@ -1,11 +1,6 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Extensions;
|
||||
using Infrastructure.Model;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@ -14,6 +9,8 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
||||
/// <summary>
|
||||
/// 系统监控
|
||||
/// </summary>
|
||||
[Tags("系统监控Monitor")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class MonitorController : BaseController
|
||||
{
|
||||
private OptionsSetting Options;
|
||||
|
||||
@ -11,6 +11,8 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("monitor/SqlDiffLog")]
|
||||
[Tags("差异日志SqlDiffLog")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SqlDiffLogController : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@ -13,6 +13,8 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("/monitor/logininfor")]
|
||||
[Tags("登录日志SysLogininfor")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysLogininforController : BaseController
|
||||
{
|
||||
private ISysLoginService sysLoginService;
|
||||
|
||||
@ -11,6 +11,8 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("/monitor/operlog")]
|
||||
[Tags("操作日志SysOperlog")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysOperlogController : BaseController
|
||||
{
|
||||
private ISysOperLogService sysOperLogService;
|
||||
|
||||
@ -8,6 +8,8 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
||||
{
|
||||
[Verify]
|
||||
[Route("monitor/online")]
|
||||
[Tags("在线用户SysUserOnline")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SysUserOnlineController : BaseController
|
||||
{
|
||||
private IHubContext<Hub> HubContext;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.Filters;
|
||||
using Swashbuckle.AspNetCore.SwaggerUI;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ZR.Admin.WebApi.Extensions
|
||||
@ -33,7 +33,13 @@ namespace ZR.Admin.WebApi.Extensions
|
||||
};
|
||||
});
|
||||
});
|
||||
app.UseSwaggerUI(c => c.SwaggerEndpoint("v1/swagger.json", "ZrAdmin v1"));
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint("sys/swagger.json", "系统管理");
|
||||
c.SwaggerEndpoint("article/swagger.json", "文章管理");
|
||||
c.SwaggerEndpoint("v1/swagger.json", "business");
|
||||
c.DocExpansion(DocExpansion.None); //->修改界面打开时自动折叠
|
||||
});
|
||||
}
|
||||
|
||||
public static void AddSwaggerConfig(this IServiceCollection services)
|
||||
@ -43,6 +49,20 @@ namespace ZR.Admin.WebApi.Extensions
|
||||
|
||||
services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("sys", new OpenApiInfo
|
||||
{
|
||||
Title = "ZrAdmin.NET Api",
|
||||
Version = "v1",
|
||||
Description = "系统管理",
|
||||
Contact = new OpenApiContact { Name = "ZRAdmin doc", Url = new Uri("https://www.izhaorui.cn/doc") }
|
||||
});
|
||||
c.SwaggerDoc("article", new OpenApiInfo
|
||||
{
|
||||
Title = "ZrAdmin.NET Api",
|
||||
Version = "v1",
|
||||
Description = "文章管理",
|
||||
Contact = new OpenApiContact { Name = "ZRAdmin doc", Url = new Uri("https://www.izhaorui.cn/doc") }
|
||||
});
|
||||
c.SwaggerDoc("v1", new OpenApiInfo
|
||||
{
|
||||
Title = "ZrAdmin.NET Api",
|
||||
@ -94,6 +114,20 @@ namespace ZR.Admin.WebApi.Extensions
|
||||
new List<string>()
|
||||
}
|
||||
});
|
||||
|
||||
//判断接口归于哪个分组
|
||||
c.DocInclusionPredicate((docName, apiDescription) =>
|
||||
{
|
||||
if (docName == "v1")
|
||||
{
|
||||
//当分组为NoGroup时,只要没加特性的都属于这个组
|
||||
return string.IsNullOrEmpty(apiDescription.GroupName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return apiDescription.GroupName == docName;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user