From ed16940d0fbae7914c0e61b6bb0c0db8d7f02447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=8F=B6=E5=AD=90?= <123546465> Date: Sun, 7 Jun 2020 22:47:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E5=8F=B6=E5=AD=90=E7=9A=84=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.gitignore" | 341 ++++++++++++++++++ .../WebApi0001.sln" | 25 ++ .../Controllers/WeatherForecastController.cs" | 70 ++++ .../WebApi0001/Domain/Admin1000DbContext.cs" | 18 + .../WebApi0001/Domain/BaseEntity.cs" | 30 ++ .../WebApi0001/Domain/DbInitializeHelper.cs" | 52 +++ .../WebApi0001/Domain/Model/Major.cs" | 17 + .../WebApi0001/Domain/Model/Student.cs" | 22 ++ .../WebApi0001/Helper/JsonHelper.cs" | 20 + .../WebApi0001/Program.cs" | 26 ++ .../Properties/launchSettings.json" | 30 ++ .../WebApi0001/Startup.cs" | 46 +++ .../WebApi0001/WeatherForecast.cs" | 15 + .../WebApi0001/WebApi0001.csproj" | 14 + .../WebApi0001/appsettings.Development.json" | 9 + .../WebApi0001/appsettings.json" | 10 + 16 files changed, 745 insertions(+) create mode 100644 "\345\260\217\345\217\266\345\255\220/.gitignore" create mode 100644 "\345\260\217\345\217\266\345\255\220/WebApi0001.sln" create mode 100644 "\345\260\217\345\217\266\345\255\220/WebApi0001/Controllers/WeatherForecastController.cs" create mode 100644 "\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/Admin1000DbContext.cs" create mode 100644 "\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/BaseEntity.cs" create mode 100644 "\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/DbInitializeHelper.cs" create mode 100644 "\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/Model/Major.cs" create mode 100644 "\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/Model/Student.cs" create mode 100644 "\345\260\217\345\217\266\345\255\220/WebApi0001/Helper/JsonHelper.cs" create mode 100644 "\345\260\217\345\217\266\345\255\220/WebApi0001/Program.cs" create mode 100644 "\345\260\217\345\217\266\345\255\220/WebApi0001/Properties/launchSettings.json" create mode 100644 "\345\260\217\345\217\266\345\255\220/WebApi0001/Startup.cs" create mode 100644 "\345\260\217\345\217\266\345\255\220/WebApi0001/WeatherForecast.cs" create mode 100644 "\345\260\217\345\217\266\345\255\220/WebApi0001/WebApi0001.csproj" create mode 100644 "\345\260\217\345\217\266\345\255\220/WebApi0001/appsettings.Development.json" create mode 100644 "\345\260\217\345\217\266\345\255\220/WebApi0001/appsettings.json" diff --git "a/\345\260\217\345\217\266\345\255\220/.gitignore" "b/\345\260\217\345\217\266\345\255\220/.gitignore" new file mode 100644 index 0000000..3e8a155 --- /dev/null +++ "b/\345\260\217\345\217\266\345\255\220/.gitignore" @@ -0,0 +1,341 @@ +## 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/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +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/ +# ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true +**/wwwroot/lib/ + +# 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/ + +# BeatPulse healthcheck temp database +healthchecksdb diff --git "a/\345\260\217\345\217\266\345\255\220/WebApi0001.sln" "b/\345\260\217\345\217\266\345\255\220/WebApi0001.sln" new file mode 100644 index 0000000..3961f38 --- /dev/null +++ "b/\345\260\217\345\217\266\345\255\220/WebApi0001.sln" @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30011.22 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApi0001", "WebApi0001\WebApi0001.csproj", "{5D33C04A-1271-440E-847C-7287B3A9791D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5D33C04A-1271-440E-847C-7287B3A9791D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5D33C04A-1271-440E-847C-7287B3A9791D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5D33C04A-1271-440E-847C-7287B3A9791D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5D33C04A-1271-440E-847C-7287B3A9791D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BA587871-332C-4A89-BC2C-DF183F15C2FD} + EndGlobalSection +EndGlobal diff --git "a/\345\260\217\345\217\266\345\255\220/WebApi0001/Controllers/WeatherForecastController.cs" "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Controllers/WeatherForecastController.cs" new file mode 100644 index 0000000..47e6201 --- /dev/null +++ "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Controllers/WeatherForecastController.cs" @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using WebApi0001.Domain.Model; +using WebApplication1.Domain; +using Microsoft.Extensions.DependencyInjection; +using WebApi0001.Helper; +using Microsoft.EntityFrameworkCore; + +namespace WebApi0001.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + + //依赖注入方法 1 + private readonly Admin1000DbContext _db; + + [ActivatorUtilitiesConstructor] + public WeatherForecastController(Admin1000DbContext dbContext) + { + _db = dbContext; + } + + + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + //方法2:注释logger + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + + //方法3 + //public WeatherForecastController(ILogger logger,Admin5000DbContext _db) + //{ + // _logger = logger; + // _db = dbContext; + //} + [HttpGet] + public string Get() + { + var res = _db.Students.Include(x => x.Major).ToList(); + return JsonHelper.SerializeObject(res); + } + + + + //public IEnumerable Get() + //{ + // var list = new List(); + // using (var db = new Admin1000DbContext()) + // { + // list = db.Students.ToList(); + // } + // return list; + + //} + } +} diff --git "a/\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/Admin1000DbContext.cs" "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/Admin1000DbContext.cs" new file mode 100644 index 0000000..efaa326 --- /dev/null +++ "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/Admin1000DbContext.cs" @@ -0,0 +1,18 @@ +using Microsoft.EntityFrameworkCore; +using WebApi0001.Domain.Model; + +namespace WebApplication1.Domain +{ + public class Admin1000DbContext : DbContext + { + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlServer("server=.;database=Admin1000;uid=sa;pwd=123456;"); + } + + public DbSet Majors { get; set; } + + public DbSet Students { get; set; } + } +} diff --git "a/\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/BaseEntity.cs" "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/BaseEntity.cs" new file mode 100644 index 0000000..cbb721e --- /dev/null +++ "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/BaseEntity.cs" @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace WebApi0001.Controllers +{ + public abstract class BaseEntity + { + public BaseEntity() + { + IsActived = true; + IsDeleted = false; + CreateTime = DateTime.Now; + UpdateTime = DateTime.Now; + } + + public int id { get; set; } + + public bool IsActived { get; set; } + + public bool IsDeleted { get; set; } + + public DateTime CreateTime { get; set; } + + public DateTime UpdateTime { get; set; } + + public string Remarks { get; set; } + } +} diff --git "a/\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/DbInitializeHelper.cs" "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/DbInitializeHelper.cs" new file mode 100644 index 0000000..52e4648 --- /dev/null +++ "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/DbInitializeHelper.cs" @@ -0,0 +1,52 @@ +using System.Linq; +using System.Security.Claims; +using WebApi0001.Domain.Model; + +namespace WebApplication1.Domain +{ + public class DbInitializeHelper + { + public static void Initilizer() + { + + using var db = new Admin1000DbContext(); + db.Database.EnsureCreated(); + + var hasStudents = db.Students.Any(); + if (!hasStudents) + { + var Majors = new Major + { + MajorName = "四年级二班", + MajorDescription = "一个品牌" + }; + db.Majors.Add(Majors); + + db.SaveChanges(); + + db.Students.AddRange(new Student[] + { + new Student + { + StudentName="张xx", + StudentSex="男", + StudentAge=18, + MajorId=Majors.id + }, + new Student + { + StudentName="李xx", + StudentSex="女", + StudentAge=18, + MajorId=Majors.id + } + }); + + db.SaveChanges(); + } + } + + + } + } + diff --git "a/\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/Model/Major.cs" "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/Model/Major.cs" new file mode 100644 index 0000000..71e9151 --- /dev/null +++ "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/Model/Major.cs" @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using WebApi0001.Controllers; + +namespace WebApi0001.Domain.Model +{ + public class Major : BaseEntity + { + public string MajorName { get; set; } + + public string MajorDescription { get; set; } + + public IEnumerable Students { get; set; } + } +} diff --git "a/\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/Model/Student.cs" "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/Model/Student.cs" new file mode 100644 index 0000000..d1a1102 --- /dev/null +++ "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Domain/Model/Student.cs" @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using WebApi0001.Controllers; + +namespace WebApi0001.Domain.Model +{ + public class Student : BaseEntity + { + public string StudentName { get; set; } + + public string StudentSex { get; set; } + + public int StudentAge { get; set; } + + + public int MajorId { get; set; } + + public Major Major { get; set; } + } +} diff --git "a/\345\260\217\345\217\266\345\255\220/WebApi0001/Helper/JsonHelper.cs" "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Helper/JsonHelper.cs" new file mode 100644 index 0000000..ad793c3 --- /dev/null +++ "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Helper/JsonHelper.cs" @@ -0,0 +1,20 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace WebApi0001.Helper +{ + public class JsonHelper + { + public static string SerializeObject(object obj) + { + return JsonConvert.SerializeObject(obj, Formatting.Indented, new JsonSerializerSettings + { + ReferenceLoopHandling = ReferenceLoopHandling.Ignore, + DateFormatString = "yyyy-MM-dd HH:mm:ss"//改变了时间显示的样子 + }); + } + } +} diff --git "a/\345\260\217\345\217\266\345\255\220/WebApi0001/Program.cs" "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Program.cs" new file mode 100644 index 0000000..6c80ec6 --- /dev/null +++ "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Program.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace WebApi0001 +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); + } +} diff --git "a/\345\260\217\345\217\266\345\255\220/WebApi0001/Properties/launchSettings.json" "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Properties/launchSettings.json" new file mode 100644 index 0000000..6cf85e3 --- /dev/null +++ "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Properties/launchSettings.json" @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:54718", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "weatherforecast", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "WebApi0001": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "weatherforecast", + "applicationUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git "a/\345\260\217\345\217\266\345\255\220/WebApi0001/Startup.cs" "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Startup.cs" new file mode 100644 index 0000000..79c36af --- /dev/null +++ "b/\345\260\217\345\217\266\345\255\220/WebApi0001/Startup.cs" @@ -0,0 +1,46 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using WebApplication1.Domain; + +namespace WebApi0001 +{ + 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.AddDbContext(); + services.AddControllers(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseRouting(); + + app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + + DbInitializeHelper.Initilizer(); + } + } +} diff --git "a/\345\260\217\345\217\266\345\255\220/WebApi0001/WeatherForecast.cs" "b/\345\260\217\345\217\266\345\255\220/WebApi0001/WeatherForecast.cs" new file mode 100644 index 0000000..facbd42 --- /dev/null +++ "b/\345\260\217\345\217\266\345\255\220/WebApi0001/WeatherForecast.cs" @@ -0,0 +1,15 @@ +using System; + +namespace WebApi0001 +{ + public class WeatherForecast + { + public DateTime Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string Summary { get; set; } + } +} diff --git "a/\345\260\217\345\217\266\345\255\220/WebApi0001/WebApi0001.csproj" "b/\345\260\217\345\217\266\345\255\220/WebApi0001/WebApi0001.csproj" new file mode 100644 index 0000000..7140c5e --- /dev/null +++ "b/\345\260\217\345\217\266\345\255\220/WebApi0001/WebApi0001.csproj" @@ -0,0 +1,14 @@ + + + + netcoreapp3.1 + + + + + + + + + + diff --git "a/\345\260\217\345\217\266\345\255\220/WebApi0001/appsettings.Development.json" "b/\345\260\217\345\217\266\345\255\220/WebApi0001/appsettings.Development.json" new file mode 100644 index 0000000..8983e0f --- /dev/null +++ "b/\345\260\217\345\217\266\345\255\220/WebApi0001/appsettings.Development.json" @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git "a/\345\260\217\345\217\266\345\255\220/WebApi0001/appsettings.json" "b/\345\260\217\345\217\266\345\255\220/WebApi0001/appsettings.json" new file mode 100644 index 0000000..d9d9a9b --- /dev/null +++ "b/\345\260\217\345\217\266\345\255\220/WebApi0001/appsettings.json" @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +} -- Gitee