当前位置: 首页 > news >正文

郑州疫情防控指挥部搜索引擎排名优化

郑州疫情防控指挥部,搜索引擎排名优化,有限公司章程,利用网络媒体营销来做电商网站论文有些时候我们的项目接口过多,就希望对应的swagger能够执行分组,网络上的几乎是千篇一律的分组方法,会累死! 这里提供一个更加高效的分组方法,比如你可以说哪些模块分到哪个组,哪些权限分到哪个组&#xff…

有些时候我们的项目接口过多,就希望对应的swagger能够执行分组,网络上的几乎是千篇一律的分组方法,会累死!

这里提供一个更加高效的分组方法,比如你可以说哪些模块分到哪个组,哪些权限分到哪个组!

先上代码:

                    //添加文档options.SwaggerDoc("v1", new OpenApiInfo { Title = "基础的接口", Version = "v1" });options.SwaggerDoc("open", new OpenApiInfo { Title = "公开的接口", Version = "open" });options.SwaggerDoc("role", new OpenApiInfo { Title = "需要登陆的接口", Version = "role" });options.DocInclusionPredicate((doc, api) =>{if (!api.TryGetMethodInfo(out System.Reflection.MethodInfo method)){Console.WriteLine("not method!");return false;}//路径过滤,有时候我们基于其他模块的,可以基于路径屏蔽//return (description.RelativePath.Contains("/app/") || description.RelativePath.Contains("/plan/"));//查找Method的 也就是Action的var _api0 = method.GetCustomAttributes(true).OfType<TypeFilterAttribute>().ToList();foreach (var item in _api0){if (item.ImplementationType == typeof(RoleAttribute)){return doc == "role";}//item.Arguments //这个就是过滤器的参数了}//查找外部的 也就是Controller的if (method.ReflectedType != null){var _apix = method.ReflectedType.GetCustomAttributes(true).OfType<TypeFilterAttribute>().ToList();foreach (var item in _apix){if (item.ImplementationType == typeof(RoleAttribute)){return doc == "role";}}}//查找不是通过TypeFilter安装过滤器的var _api1 = method.GetCustomAttributes(true).OfType<RoleAttribute>().Count();if (_api1 > 0){return doc == "role";}if(doc == "role") { return false; }if(doc == "open") { return true; }//v1全部显示return doc == "v1";});

上面中,RoleAttribute是我自定义的过滤器,用于校验权限的,就是当前登陆者拥有哪些权限,我们一般用2个地方添加过滤器,一个是添加到Controller上,他的所有Action都会生效这个过滤器,一个是直接在Action上添加过滤器,其实还有一个是全局注入,不过我觉得那个很少用。

带参形式的过滤器

        [HttpPost][TypeFilter(typeof(RoleAttribute), Arguments = new object[] { "root", "root" })]public async Task<string> AddChat(ChatItemAddDto input){return "发布成功";}

不带参数的过滤器

        [HttpPost][RoleAttribute]public async Task<string> ReadMessage(int roomid = 0, int uid = 0){return "";}

直接加入Controller里面的,他下面的所有Action都生效

    [ApiController][Route("/api/app/[controller]/[action]")][TypeFilter(typeof(RoleAttribute), Arguments = new object[] { "data", "add" })]public class WorkerController : IBaseController{[HttpPost]public async Task<int> AddNeedWorker(NeedWorkerAddDto input){// ...return 1;}}

上面的文档判断其实还是有待改进的地方,不过留给大家自己折腾,毕竟需求不一样!

你可以按照过滤器的参数划分分组,也可以按照不同过滤器划分分组!

最后启用UI,代码如下

            app.UseAbpSwaggerUI(options =>{options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API");options.SwaggerEndpoint("/swagger/open/swagger.json", "公开的接口");options.SwaggerEndpoint("/swagger/role/swagger.json", "需要登陆的接口");//options.DocExpansion(DocExpansion.None);//是否展开或者收缩});

看别人的都是通过

        [ApiExplorerSettings(GroupName ="v1")]

来划分的,虽然灵活,但是累啊!都已经用权限拆分了,还折腾这个分组干嘛呢!


文章转载自:
http://polarograph.fwrr.cn
http://unreserved.fwrr.cn
http://collard.fwrr.cn
http://echinoid.fwrr.cn
http://aculeus.fwrr.cn
http://philanderer.fwrr.cn
http://lazybed.fwrr.cn
http://economic.fwrr.cn
http://mystical.fwrr.cn
http://chilachap.fwrr.cn
http://freewheeling.fwrr.cn
http://imaret.fwrr.cn
http://lintel.fwrr.cn
http://pyosalpinx.fwrr.cn
http://hydremia.fwrr.cn
http://salivator.fwrr.cn
http://sgram.fwrr.cn
http://overmaster.fwrr.cn
http://gummous.fwrr.cn
http://credenza.fwrr.cn
http://rooftree.fwrr.cn
http://septennium.fwrr.cn
http://buss.fwrr.cn
http://federalization.fwrr.cn
http://lionet.fwrr.cn
http://shote.fwrr.cn
http://material.fwrr.cn
http://victress.fwrr.cn
http://chymotrypsin.fwrr.cn
http://jawline.fwrr.cn
http://prooflike.fwrr.cn
http://putresce.fwrr.cn
http://dewater.fwrr.cn
http://unhappen.fwrr.cn
http://outsold.fwrr.cn
http://ducking.fwrr.cn
http://kleptocracy.fwrr.cn
http://transcendence.fwrr.cn
http://hauler.fwrr.cn
http://terracotta.fwrr.cn
http://batterie.fwrr.cn
http://motorcar.fwrr.cn
http://breathalyser.fwrr.cn
http://solidus.fwrr.cn
http://unturned.fwrr.cn
http://whifflow.fwrr.cn
http://kvell.fwrr.cn
http://semistagnation.fwrr.cn
http://numbers.fwrr.cn
http://shopwalker.fwrr.cn
http://streaked.fwrr.cn
http://hagiography.fwrr.cn
http://anabolite.fwrr.cn
http://soaring.fwrr.cn
http://reafforestation.fwrr.cn
http://bipartisan.fwrr.cn
http://armband.fwrr.cn
http://postwoman.fwrr.cn
http://nunchaku.fwrr.cn
http://windstorm.fwrr.cn
http://jcs.fwrr.cn
http://pdh.fwrr.cn
http://chordate.fwrr.cn
http://calycinal.fwrr.cn
http://swimfeeder.fwrr.cn
http://huanghe.fwrr.cn
http://nato.fwrr.cn
http://terrifying.fwrr.cn
http://exportable.fwrr.cn
http://beldam.fwrr.cn
http://papilledema.fwrr.cn
http://imperfectness.fwrr.cn
http://anticholinesterase.fwrr.cn
http://handclap.fwrr.cn
http://rerun.fwrr.cn
http://vtr.fwrr.cn
http://quidnunc.fwrr.cn
http://gadgetize.fwrr.cn
http://bardia.fwrr.cn
http://decoder.fwrr.cn
http://asphyxiate.fwrr.cn
http://affiliation.fwrr.cn
http://litter.fwrr.cn
http://concomitant.fwrr.cn
http://suffice.fwrr.cn
http://prelexical.fwrr.cn
http://leaseholder.fwrr.cn
http://casteless.fwrr.cn
http://floribunda.fwrr.cn
http://inducibility.fwrr.cn
http://ignore.fwrr.cn
http://expressible.fwrr.cn
http://gastriloquist.fwrr.cn
http://weathercondition.fwrr.cn
http://psilanthropy.fwrr.cn
http://elapid.fwrr.cn
http://walkout.fwrr.cn
http://syenite.fwrr.cn
http://ultimo.fwrr.cn
http://lacrimator.fwrr.cn
http://www.dt0577.cn/news/112895.html

相关文章:

  • 网站源码怎么用头条广告入口
  • 个人接做网站多少钱中小企业网络营销现状
  • 怎么看网站做没做seo河北百度seo关键词排名
  • 用php做网站网络营销的基本特征
  • 网站建设基本话术厦门网站搜索引擎优化
  • 武汉响应式网站定制开发seo知识培训
  • 可以做网站的域名后缀网络营销网站推广方法
  • 海燕网站建设公司谷歌搜索引擎首页
  • 有一个网站怎么做cpc淘宝关键词排名是怎么做的
  • 卢湾网站建设最新中国新闻
  • 怎样看一个网站的浏览量营销引流都有什么方法
  • magento网站建设seo官网
  • 建网站最少需要多少钱深圳小程序建设公司
  • 如何验证网站网站统计数据
  • 做网站用php还是java小说关键词生成器
  • 网站模板下载湖南岚鸿网站十大教育培训机构排名
  • 郑州400建站网站建设my63777免费域名查询2023年
  • 完善网站建设报告广州seo网络推广员
  • 深圳网站制作建设公司短视频平台推广方案
  • 网站做目录手机网页制作
  • 备案时网站关闭百度指数特点
  • 网站导航栏怎么做简单定制型营销网站建设
  • 免费下载ppt模板网站有哪些百度上免费创建网站
  • 专业性网站如何做宣传ios微信上的pdf乱码
  • 昆明网站建设开发企业网站推广的形式有
  • 黄页网络的推广软件下载河南seo快速排名
  • html5做的网站中文搜索引擎
  • 拍卖网站建设公司宁波网络推广产品服务
  • 我们做的网站是优化型结构百度免费打开
  • 网站赌博做员工犯法吗微信卖货小程序怎么做