1 Star 0 Fork 1.9K

craft zhang/核心商城系统(CoreShop)

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CustomRouteAttribute.cs 2.09 KB
一键复制 编辑 原始数据 按行查看 历史
JianWeie 提交于 2021-06-01 14:37 +08:00 . 添加项目文件。
/***********************************************************************
* Project: CoreCms.Net *
* Web: https://CoreCms.Net *
* ProjectName: 核心内容管理系统 *
* Author: 大灰灰 *
* Email: JianWeie@163.com *
* Versions: 1.0 *
* CreateTime: 2020-02-02 18:53:27
* NameSpace: CoreCms.Net.Framework.Swagger
* FileName: CustomRouteAttribute
* ClassDescription:
***********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
namespace CoreCms.Net.Swagger
{
/// <summary>
/// 自定义路由 /api/{version}/[controler]/[action]
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class CustomRouteAttribute : RouteAttribute, IApiDescriptionGroupNameProvider
{
/// <summary>
/// 分组名称,是来实现接口 IApiDescriptionGroupNameProvider
/// </summary>
public string GroupName { get; set; }
/// <summary>
/// 自定义路由构造函数,继承基类路由
/// </summary>
/// <param name="actionName"></param>
public CustomRouteAttribute(string actionName = "[action]") : base("/api/{version}/[controller]/" + actionName)
{
}
/// <summary>
/// 自定义版本+路由构造函数,继承基类路由
/// </summary>
/// <param name="actionName"></param>
/// <param name="version"></param>
public CustomRouteAttribute(CustomApiVersion.ApiVersions version, string actionName = "") : base($"/api/{version.ToString()}/[controller]/{actionName}")
{
GroupName = version.ToString();
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/craft-zhang/CoreShop.git
git@gitee.com:craft-zhang/CoreShop.git
craft-zhang
CoreShop
核心商城系统(CoreShop)
master

搜索帮助

371d5123 14472233 46e8bd33 14472233