diff --git "a/\350\246\203\347\220\252\347\277\224/.gitignore" "b/\350\246\203\347\220\252\347\277\224/.gitignore" new file mode 100644 index 0000000000000000000000000000000000000000..3e8a1553fcff7845c779d3cb8014e151a9931506 --- /dev/null +++ "b/\350\246\203\347\220\252\347\277\224/.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/\350\246\203\347\220\252\347\277\224/WebApi.sln" "b/\350\246\203\347\220\252\347\277\224/WebApi.sln" new file mode 100644 index 0000000000000000000000000000000000000000..204e41ecaed94b81bb033c61328f678d10742aa8 --- /dev/null +++ "b/\350\246\203\347\220\252\347\277\224/WebApi.sln" @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.757 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApi", "WebApi\WebApi.csproj", "{57DCEE3F-0E47-44EA-9072-ED3713732292}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {57DCEE3F-0E47-44EA-9072-ED3713732292}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {57DCEE3F-0E47-44EA-9072-ED3713732292}.Debug|Any CPU.Build.0 = Debug|Any CPU + {57DCEE3F-0E47-44EA-9072-ED3713732292}.Release|Any CPU.ActiveCfg = Release|Any CPU + {57DCEE3F-0E47-44EA-9072-ED3713732292}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4951F838-3318-4C2E-A348-7B0302769DD4} + EndGlobalSection +EndGlobal diff --git "a/\350\246\203\347\220\252\347\277\224/WebApi/Controllers/TestController.cs" "b/\350\246\203\347\220\252\347\277\224/WebApi/Controllers/TestController.cs" new file mode 100644 index 0000000000000000000000000000000000000000..0ac4ace82925ffd14691b7331f616bfead683f04 --- /dev/null +++ "b/\350\246\203\347\220\252\347\277\224/WebApi/Controllers/TestController.cs" @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using WebApi.Domain.Entity; +using WebApi.Helper; +using WebApi.Interface; + +namespace WebApi.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class TestController : ControllerBase + { + private readonly IRespository _respository; + public TestController(IRespository respository) + { + _respository = respository; + + } + + public string Get() + { + var list = _respository.Table.ToList(); + return JsonHelper.SerializeObject(list); + } + + + + + + + + } +} diff --git "a/\350\246\203\347\220\252\347\277\224/WebApi/Controllers/ValuesController.cs" "b/\350\246\203\347\220\252\347\277\224/WebApi/Controllers/ValuesController.cs" new file mode 100644 index 0000000000000000000000000000000000000000..bfd6f528cb02bbc4c1bf7526136df4877119a20d --- /dev/null +++ "b/\350\246\203\347\220\252\347\277\224/WebApi/Controllers/ValuesController.cs" @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using WebApi.Domain; +using WebApi.Domain.Entity; +using WebApi.Helper; + +namespace WebApi.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ValuesController : ControllerBase + { + // GET api/values + private readonly Admin3000 _db; + + public ValuesController(Admin3000 dbContext) + { + _db = dbContext; + + } + + + // GET api/values + [HttpGet] + public string Get() + { + var res = _db.Users.ToList(); + + + return JsonHelper.SerializeObject(res); + + //var list = new List(); + + //using (var db = new Admin3000()) + //{ + // list = db.Users.ToList(); + //} + + //return list; + } + + // GET api/values/5 + [HttpGet("{id}")] + public ActionResult Get(int id) + { + return "value"; + } + + // POST api/values + [HttpPost] + public void Post([FromBody] string value) + { + } + + // PUT api/values/5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + + // DELETE api/values/5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git "a/\350\246\203\347\220\252\347\277\224/WebApi/Domain/Admin3000.cs" "b/\350\246\203\347\220\252\347\277\224/WebApi/Domain/Admin3000.cs" new file mode 100644 index 0000000000000000000000000000000000000000..da764cf57e2d46e1368c69af0ea4fb660201645d --- /dev/null +++ "b/\350\246\203\347\220\252\347\277\224/WebApi/Domain/Admin3000.cs" @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using WebApi.Domain.Entity; + +namespace WebApi.Domain +{ + public class Admin3000:DbContext + { + public DbSet Classes { get; set; } + public DbSet Users { get; set; } + + + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlServer("server=.;database=Admin3000;uid=sa;pwd=123456"); + } + + } +} diff --git "a/\350\246\203\347\220\252\347\277\224/WebApi/Domain/BaseEntity.cs" "b/\350\246\203\347\220\252\347\277\224/WebApi/Domain/BaseEntity.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ff4e1364e5bc53e397076d04396ec1f18d9b5c4d --- /dev/null +++ "b/\350\246\203\347\220\252\347\277\224/WebApi/Domain/BaseEntity.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace WebApi.Domain +{ + public class BaseEntity + { + public BaseEntity() + { + CreatedTime = DateTime.Now; + UpdateTime = DateTime.Now; + IsActived = true; + IsDeleted = false; + Remarks = "Nothing"; + + } + public int Id { get; set; } + public DateTime CreatedTime { get; set; } + public DateTime UpdateTime { get; set; } + public bool IsActived { get; set; } + public bool IsDeleted { get; set; } + public string Remarks { get; set; } + } +} diff --git "a/\350\246\203\347\220\252\347\277\224/WebApi/Domain/DbInitializer.cs" "b/\350\246\203\347\220\252\347\277\224/WebApi/Domain/DbInitializer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f92d94244202792f4bee52b150d08a5109d2ae67 --- /dev/null +++ "b/\350\246\203\347\220\252\347\277\224/WebApi/Domain/DbInitializer.cs" @@ -0,0 +1,57 @@ +using Microsoft.EntityFrameworkCore.Diagnostics; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using WebApi.Domain.Entity; + +namespace WebApi.Domain +{ + public class DbInitializer + { + public static void Seed() + { + using (var db = new Admin3000()) + { + db.Database.EnsureCreated(); + + if(!db.Database.EnsureCreated()){ + var Class = new Class() + { + ClassName = "终极一班", + ClassType = "战士", + + }; + var Class1 = new Class() + { + ClassName = "终级二班", + ClassType = "法师", + + }; + db.Classes.AddRange(Class, Class1); + db.SaveChanges(); + db.Users.AddRange(new Users[] + { + new Users + { + UsersName="李预期", + Where="河南", + ClassId=Class.Id + }, + new Users + { + UsersName="李生殖", + Where="广西", + ClassId=Class1.Id + } + + }); + db.SaveChanges(); + + } + + } + + } + } +} diff --git "a/\350\246\203\347\220\252\347\277\224/WebApi/Domain/Entity/Class.cs" "b/\350\246\203\347\220\252\347\277\224/WebApi/Domain/Entity/Class.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c2728d381b226b86550535fdeb3a9d93e62189e3 --- /dev/null +++ "b/\350\246\203\347\220\252\347\277\224/WebApi/Domain/Entity/Class.cs" @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace WebApi.Domain.Entity +{ + public class Class:BaseEntity + { + public string ClassName { get; set; } + public string ClassType { get; set; } + public IEnumerable Users { get; set; } + } +} diff --git "a/\350\246\203\347\220\252\347\277\224/WebApi/Domain/Entity/Users.cs" "b/\350\246\203\347\220\252\347\277\224/WebApi/Domain/Entity/Users.cs" new file mode 100644 index 0000000000000000000000000000000000000000..25b72e28a35d670af80afcc615ad2eec45aebd55 --- /dev/null +++ "b/\350\246\203\347\220\252\347\277\224/WebApi/Domain/Entity/Users.cs" @@ -0,0 +1,19 @@ +using Microsoft.AspNetCore.SignalR; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace WebApi.Domain.Entity +{ + public class Users:BaseEntity + { + public string UsersName { get; set; } + public string Where { get; set; } + + + public int ClassId { get; set; } + + public Class Class { get; set; } + } +} \ No newline at end of file diff --git "a/\350\246\203\347\220\252\347\277\224/WebApi/Helper/JsonHelper.cs" "b/\350\246\203\347\220\252\347\277\224/WebApi/Helper/JsonHelper.cs" new file mode 100644 index 0000000000000000000000000000000000000000..fd0abf85388a9f5ca449f9b480eb273c0421afbf --- /dev/null +++ "b/\350\246\203\347\220\252\347\277\224/WebApi/Helper/JsonHelper.cs" @@ -0,0 +1,23 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace WebApi.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/\350\246\203\347\220\252\347\277\224/WebApi/Interface/IRespository.cs" "b/\350\246\203\347\220\252\347\277\224/WebApi/Interface/IRespository.cs" new file mode 100644 index 0000000000000000000000000000000000000000..81926fba9fc8107fbd43bab03d69d855ccbe55fa --- /dev/null +++ "b/\350\246\203\347\220\252\347\277\224/WebApi/Interface/IRespository.cs" @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace WebApi.Interface +{ + public interface IRespository + { + IQueryable Table { get; } + T GetbyId(int id); + + void Insert(T entity); + + void MoreInsert(IEnumerable list); + + void Update(T entity); + void Deleted(T entity); + void Deleted(int id); + } +} diff --git "a/\350\246\203\347\220\252\347\277\224/WebApi/Program.cs" "b/\350\246\203\347\220\252\347\277\224/WebApi/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..f87ff3e9a38cd82948a57260f07692514452eec1 --- /dev/null +++ "b/\350\246\203\347\220\252\347\277\224/WebApi/Program.cs" @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; + +namespace WebApi +{ + public class Program + { + public static void Main(string[] args) + { + CreateWebHostBuilder(args).Build().Run(); + } + + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup(); + } +} diff --git "a/\350\246\203\347\220\252\347\277\224/WebApi/Properties/launchSettings.json" "b/\350\246\203\347\220\252\347\277\224/WebApi/Properties/launchSettings.json" new file mode 100644 index 0000000000000000000000000000000000000000..35ffafb1650e1fc2f6d1e79930e22f488f86cb91 --- /dev/null +++ "b/\350\246\203\347\220\252\347\277\224/WebApi/Properties/launchSettings.json" @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:1633", + "sslPort": 44367 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "api/values", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "WebApi": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "api/values", + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git "a/\350\246\203\347\220\252\347\277\224/WebApi/Realize/EfRepository.cs" "b/\350\246\203\347\220\252\347\277\224/WebApi/Realize/EfRepository.cs" new file mode 100644 index 0000000000000000000000000000000000000000..c6d431b07912b64a9b7be3823f456233a39fd4b0 --- /dev/null +++ "b/\350\246\203\347\220\252\347\277\224/WebApi/Realize/EfRepository.cs" @@ -0,0 +1,80 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography.X509Certificates; +using System.Threading.Tasks; +using WebApi.Domain; +using WebApi.Interface; + +namespace WebApi.Realize +{ + public class EfRepository : IRespository where T : BaseEntity + { + + protected readonly Admin3000 db; + + private DbSet _entity; + + private DbSet Entity + { + get + { + if (_entity == null) + { + _entity = db.Set(); + + } + return _entity; + } + } + + public IQueryable Table => Entity; + + public EfRepository(Admin3000 dbContext) + { + db = dbContext; + } + + + public void Deleted(T entity) + { + this._entity.Remove(entity); + db.SaveChanges(); + } + + public void Deleted(int id) + { + var row = Table.Where(x => x.Id == id).FirstOrDefault(); + Deleted(row); + db.SaveChanges(); + } + + + public T GetbyId(int id) + { + return _entity.Where(x => x.Id == id).FirstOrDefault(); + + + + } + + public void Insert(T entity) + { + _entity.Add(entity); + db.SaveChanges(); + } + + public void MoreInsert(IEnumerable list) + { + _entity.Add((T)list); + db.SaveChanges(); + } + + public void Update(T entity) + { + _entity.Update(entity); + db.SaveChanges(); + } + } +} diff --git "a/\350\246\203\347\220\252\347\277\224/WebApi/Startup.cs" "b/\350\246\203\347\220\252\347\277\224/WebApi/Startup.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ae138a3d824c438876615e9b4b83a422ccb2a7e1 --- /dev/null +++ "b/\350\246\203\347\220\252\347\277\224/WebApi/Startup.cs" @@ -0,0 +1,41 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using WebApi.Domain; +using WebApi.Interface; +using WebApi.Realize; + +namespace WebApi +{ + 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.AddScoped(typeof(IRespository<>), typeof(EfRepository<>)); + services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + } + + // 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()) + { + app.UseDeveloperExceptionPage(); + } + app.UseMvc(); + + DbInitializer.Seed(); + } + } +} diff --git "a/\350\246\203\347\220\252\347\277\224/WebApi/WeatherForecast.cs" "b/\350\246\203\347\220\252\347\277\224/WebApi/WeatherForecast.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5871af2a184c32297d627c31779fab837fdfb2a9 --- /dev/null +++ "b/\350\246\203\347\220\252\347\277\224/WebApi/WeatherForecast.cs" @@ -0,0 +1,15 @@ +using System; + +namespace WebApi +{ + 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/\350\246\203\347\220\252\347\277\224/WebApi/WebApi.csproj" "b/\350\246\203\347\220\252\347\277\224/WebApi/WebApi.csproj" new file mode 100644 index 0000000000000000000000000000000000000000..b28169ae13eff6786f7fadcc3fab08ca3765aab3 --- /dev/null +++ "b/\350\246\203\347\220\252\347\277\224/WebApi/WebApi.csproj" @@ -0,0 +1,19 @@ + + + + netcoreapp2.1 + + + + + + + + + + + + + + + diff --git "a/\350\246\203\347\220\252\347\277\224/WebApi/appsettings.Development.json" "b/\350\246\203\347\220\252\347\277\224/WebApi/appsettings.Development.json" new file mode 100644 index 0000000000000000000000000000000000000000..e203e9407e74a6b9662aab8fde5d73ae64665f18 --- /dev/null +++ "b/\350\246\203\347\220\252\347\277\224/WebApi/appsettings.Development.json" @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git "a/\350\246\203\347\220\252\347\277\224/WebApi/appsettings.json" "b/\350\246\203\347\220\252\347\277\224/WebApi/appsettings.json" new file mode 100644 index 0000000000000000000000000000000000000000..def9159a7d9403c04a926f64e71ef3ee7c9e4c57 --- /dev/null +++ "b/\350\246\203\347\220\252\347\277\224/WebApi/appsettings.json" @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning" + } + }, + "AllowedHosts": "*" +}