From 8a38d58aef8de2b144a907bd0a815c6b132cb36c Mon Sep 17 00:00:00 2001 From: Argo-MacBookPro Date: Wed, 24 Oct 2018 17:12:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8A=9F=E8=83=BD=EF=BC=9A?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0swagger=20webapi=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 669 +++++++++--------- Bootstrap.Admin/Bootstrap.Admin.csproj | 5 + .../Controllers/AdminController.cs | 8 - Bootstrap.Admin/HttpHeaderOperation.cs | 36 + Bootstrap.Admin/Startup.cs | 41 +- Bootstrap.Admin/Views/Admin/Api.cshtml | 20 - Bootstrap.Admin/wwwroot/css/api.css | 35 - Bootstrap.Admin/wwwroot/js/apidoc.js | 105 --- DatabaseScripts/InitData.sql | 2 +- DatabaseScripts/SQLite/InitData.sql | 2 +- 10 files changed, 416 insertions(+), 507 deletions(-) create mode 100644 Bootstrap.Admin/HttpHeaderOperation.cs delete mode 100644 Bootstrap.Admin/Views/Admin/Api.cshtml delete mode 100644 Bootstrap.Admin/wwwroot/css/api.css delete mode 100644 Bootstrap.Admin/wwwroot/js/apidoc.js diff --git a/.gitignore b/.gitignore index 9cdc2578..75ece7d5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,340 +1,340 @@ ###### -- File Created With Git Source Control Provider 2015 -- ###### ###### -- From https://github.com/github/gitignore -- ###### ###### -- Warning Regenerating this file will erase all your custom ignores, unless you add them below the Custom Ignore section at the bottom -- ###### -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider -.idea/ -*.sln.iml - -# CodeRush personal settings -.cr/personal - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -# Local History for Visual Studio -.localhistory/ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ # MAC Files **/.DS_Store @@ -346,6 +346,7 @@ ASALocalRun/ [Kk]eys/ lib/ *.db +Bootstrap.Admin.xml ###### -- Custom Ignore Section, Make sure all files you add to the git repo are below this line -- ###### diff --git a/Bootstrap.Admin/Bootstrap.Admin.csproj b/Bootstrap.Admin/Bootstrap.Admin.csproj index 4192c346..474fc04c 100644 --- a/Bootstrap.Admin/Bootstrap.Admin.csproj +++ b/Bootstrap.Admin/Bootstrap.Admin.csproj @@ -7,12 +7,17 @@ true + + Z:\src\Longbow\BootstrapAdmin\Bootstrap.Admin\Bootstrap.Admin.xml + + + diff --git a/Bootstrap.Admin/Controllers/AdminController.cs b/Bootstrap.Admin/Controllers/AdminController.cs index d12e60ea..9fb1a204 100644 --- a/Bootstrap.Admin/Controllers/AdminController.cs +++ b/Bootstrap.Admin/Controllers/AdminController.cs @@ -141,13 +141,5 @@ namespace Bootstrap.Admin.Controllers { return View(new NavigatorBarModel(this)); } - /// - /// - /// - /// - public ActionResult Api() - { - return View(new NavigatorBarModel(this)); - } } } diff --git a/Bootstrap.Admin/HttpHeaderOperation.cs b/Bootstrap.Admin/HttpHeaderOperation.cs new file mode 100644 index 00000000..4c15bb29 --- /dev/null +++ b/Bootstrap.Admin/HttpHeaderOperation.cs @@ -0,0 +1,36 @@ +using Microsoft.AspNetCore.Authorization; +using Swashbuckle.AspNetCore.Swagger; +using Swashbuckle.AspNetCore.SwaggerGen; +using System.Collections.Generic; +using System.Linq; +using Operation = Swashbuckle.AspNetCore.Swagger.Operation; + +namespace Bootstrap.Admin +{ + /// + /// + /// + public class HttpHeaderOperation : IOperationFilter + { + /// + /// + /// + /// + /// + public void Apply(Operation operation, OperationFilterContext context) + { + if (operation.Parameters == null) operation.Parameters = new List(); + + if (context.MethodInfo.GetCustomAttributes(typeof(AllowAnonymousAttribute), true).Count() == 0) + { + operation.Parameters.Add(new NonBodyParameter() + { + Name = "Authorization", //添加Authorization头部参数 + In = "header", + Type = "string", + Required = false + }); + } + } + } +} diff --git a/Bootstrap.Admin/Startup.cs b/Bootstrap.Admin/Startup.cs index 0ee13690..ca9abb1f 100644 --- a/Bootstrap.Admin/Startup.cs +++ b/Bootstrap.Admin/Startup.cs @@ -18,22 +18,35 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; +using Swashbuckle.AspNetCore.Swagger; using System; using System.Collections.Generic; using System.IO; namespace Bootstrap.Admin { + /// + /// + /// public class Startup { + /// + /// + /// + /// public Startup(IConfiguration configuration) { Configuration = configuration; } - + /// + /// + /// public IConfiguration Configuration { get; } - // This method gets called by the runtime. Use this method to add services to the container. + /// + /// + /// + /// public void ConfigureServices(IServiceCollection services) { services.Configure(options => @@ -65,9 +78,26 @@ namespace Bootstrap.Admin JsonConvert.DefaultSettings = () => options.SerializerSettings; }).SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options => options.Cookie.Path = "/"); + services.AddSwaggerGen(options => + { + options.SwaggerDoc("v1", new Info + { + Version = "v1", + Title = "BootstrapAdmin API" + }); + + //Set the comments path for the swagger json and ui. + var xmlPath = Path.Combine(AppContext.BaseDirectory, "Bootstrap.Admin.xml"); + options.IncludeXmlComments(xmlPath); + options.OperationFilter(); // 添加httpHeader参数 + }); } - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + /// + /// + /// + /// + /// public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) @@ -93,6 +123,11 @@ namespace Bootstrap.Admin name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); + app.UseSwagger(); + app.UseSwaggerUI(c => + { + c.SwaggerEndpoint("/swagger/v1/swagger.json", "BootstrapAdmin API V1"); + }); } } } \ No newline at end of file diff --git a/Bootstrap.Admin/Views/Admin/Api.cshtml b/Bootstrap.Admin/Views/Admin/Api.cshtml deleted file mode 100644 index 44931219..00000000 --- a/Bootstrap.Admin/Views/Admin/Api.cshtml +++ /dev/null @@ -1,20 +0,0 @@ -@model NavigatorBarModel -@{ - ViewBag.Title = "Api 文档"; -} -@section javascript { - -} -@section css { - -} -
-

接口返回值定义

-
成功返回True,失败返回False
-
Json字符串
-
-
-

接口请求定义

-
Content-Type:application/json; charset=utf-8
-
Token:362a4733-341a-464d-ab12-e01554338839
-
\ No newline at end of file diff --git a/Bootstrap.Admin/wwwroot/css/api.css b/Bootstrap.Admin/wwwroot/css/api.css deleted file mode 100644 index ad1e082d..00000000 --- a/Bootstrap.Admin/wwwroot/css/api.css +++ /dev/null @@ -1,35 +0,0 @@ -h3 { - margin-top: 0; - color: #000; -} - -.btn { - text-shadow: none; -} - -.control-label { - width: 80px; -} - -.main-content { - padding: 15px; -} - - .main-content > section:not(:first-child) { - padding-top: 10px; - } - - .main-content > section > div { - line-height: 26px; - } - - .main-content > section > div > div { - display: inline-block; - word-break: break-all; - } - -.test { - display: none; - padding: 10px 0 0 0; - color: #5cb85c; -} diff --git a/Bootstrap.Admin/wwwroot/js/apidoc.js b/Bootstrap.Admin/wwwroot/js/apidoc.js deleted file mode 100644 index 2d5af49a..00000000 --- a/Bootstrap.Admin/wwwroot/js/apidoc.js +++ /dev/null @@ -1,105 +0,0 @@ -$(function () { - var ajax = function (options) { - options = $.extend({ - test: false, - div: undefined, - anonymous: false, - title: '未录入', - url: '', - method: 'get', - data: '', - headers: {}, - success: function (result) { - }, - error: function (textStatus, errorThrown) { - } - }, options); - if (options.url == '') { - document.writeln("请求地址丢失!"); - return; - } - $.ajax({ - url: options.url, - data: options.data, - type: options.method, - headers: options.headers, - success: function (result) { - if (!options.test) { - var $body = $('#main-content'); - $body.append('
'); - var $section = $body.find('section').last(); - $section.append($.format('

{0}

', options.title)); - $section.append($.format('
{0}
', options.url)); - $section.append($.format('
{0}
', options.anonymous ? "允许" : "不允许")); - $section.append($.format('
{0}
', JSON.stringify(options.headers))); - $section.append($.format('
{0}
', options.method)); - $section.append($.format('
{0}
', JSON.stringify(options.data))); - $section.append($.format('
{0}
', JSON.stringify(result))); - $section.append('
'); - $section.append($.format('
', JSON.stringify(options), JSON.stringify(options.data))); - $section.append('
') - options.success(result); - } - else { - if (options.div) { - options.div.html($.format('
{0}
', JSON.stringify(result))).show(); - } - } - }, - error: function (XMLHttpRequest, textStatus, errorThrown) { - var $body = $('body'); - var $section = $body.find('section').last(); - $section.append($.format('
textStatus:{0}
', textStatus)); - $section.append($.format('
errorThrown:{0}
', errorThrown)); - options.error(textStatus, errorThrown); - } - }); - }; - - $('body').on('click', 'button', function () { - var $input = $(this).parent().prev(); - var options = $.extend(JSON.parse($input.attr('data-val')), { data: JSON.parse($input.val()) }, { test: true, div: $(this).parent().parent().next() }); - ajax(options); - }); - - // 接口调用 - ajax({ - title: '用户登陆调用接口', - anonymous: true, - url: '../api/login', method: 'POST', data: { userName: 'Test', password: '1' }, success: function (result) { - var token = result.Token; - ajax({ - title: '用户登陆信息接口', url: '../api/login', headers: { Token: token }, - method: 'GET' - }); - ajax({ - title: '指定用户信息接口', url: '../api/Users', headers: { Token: token }, - method: 'GET', data: { userName: "Test" } - }); - ajax({ - title: '检查当前用户名是否可用接口', url: '../api/Users', headers: { Token: token }, - method: 'PUT', data: { UserName: "101", UserStatus: 9 } - }); - ajax({ - title: '更改用户显示名称接口', url: '../api/Users', headers: { Token: token }, - method: 'PUT', data: { UserName: "101", UserStatus: 1, DisplayName: "1010" } - }); - ajax({ - title: '更改用户密码接口', url: '../api/Users', headers: { Token: token }, - method: 'PUT', data: { UserName: "101", UserStatus: 2, Password: "1", NewPassword: "2" } - }); - ajax({ - title: '新建用户接口', url: '../api/Users', headers: { Token: token }, - method: 'POST', data: { ID: 0, UserName: "102", Password: "1", DisplayName: "102" } - }); - ajax({ - title: '更新用户接口', url: '../api/Users', headers: { Token: token }, - method: 'POST', data: { ID: 21, UserName: "102", Password: "1", DisplayName: "102" } - }); - ajax({ - title: '删除用户接口', url: '../api/Users', headers: { Token: token }, - method: 'DELETE', data: { "": "50,51" } - }); - } - }); -}); \ No newline at end of file diff --git a/DatabaseScripts/InitData.sql b/DatabaseScripts/InitData.sql index 7774ebc8..b383c690 100644 --- a/DatabaseScripts/InitData.sql +++ b/DatabaseScripts/InitData.sql @@ -48,7 +48,7 @@ INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [C INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (14, 0, N'程序异常', 140, N'fa fa-cubes', N'~/Admin/Exceptions', N'0') INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (16, 0, N'工具集合', 160, N'fa fa-gavel', N'#', N'0') INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (17, 16, N'客户端测试', 10, N'fa fa-wrench', N'~/Admin/Mobile', N'0') -INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (18, 16, N'API文档', 10, N'fa fa-wrench', N'~/Admin/Api', N'0') +INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (18, 16, N'API文档', 10, N'fa fa-wrench', N'~/swagger', N'0') INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (19, 16, N'图标集', 10, N'fa fa-dashboard', N'~/Admin/FAIcon', N'0') SET IDENTITY_INSERT [dbo].[Navigations] OFF diff --git a/DatabaseScripts/SQLite/InitData.sql b/DatabaseScripts/SQLite/InitData.sql index 0114d411..ab603154 100644 --- a/DatabaseScripts/SQLite/InitData.sql +++ b/DatabaseScripts/SQLite/InitData.sql @@ -42,7 +42,7 @@ INSERT INTO [Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Ca INSERT INTO [Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (14, 0, '程序异常', 140, 'fa fa-cubes', '~/Admin/Exceptions', '0'); INSERT INTO [Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (16, 0, '工具集合', 160, 'fa fa-gavel', '#', '0'); INSERT INTO [Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (17, 16, '客户端测试', 10, 'fa fa-wrench', '~/Admin/Mobile', '0'); -INSERT INTO [Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (18, 16, 'API文档', 10, 'fa fa-wrench', '~/Admin/Api', '0'); +INSERT INTO [Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (18, 16, 'API文档', 10, 'fa fa-wrench', '~/swagger', '0'); INSERT INTO [Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (19, 16, '图标集', 10, 'fa fa-dashboard', '~/Admin/FAIco', '0'); DELETE FROM GROUPS WHERE ID = 1;