diff --git "a/\347\206\212\350\266\205/.gitignore" "b/\347\206\212\350\266\205/.gitignore" new file mode 100644 index 0000000000000000000000000000000000000000..3e8a1553fcff7845c779d3cb8014e151a9931506 --- /dev/null +++ "b/\347\206\212\350\266\205/.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/\347\206\212\350\266\205/DIText001.sln" "b/\347\206\212\350\266\205/DIText001.sln" new file mode 100644 index 0000000000000000000000000000000000000000..9f8612f64b71a234f1c1b660f2bf4265c5ec40e4 --- /dev/null +++ "b/\347\206\212\350\266\205/DIText001.sln" @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29613.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DIText001", "DIText001\DIText001.csproj", "{FC7570BD-1FAD-496C-A92C-3D8383FF2A2F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FC7570BD-1FAD-496C-A92C-3D8383FF2A2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FC7570BD-1FAD-496C-A92C-3D8383FF2A2F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FC7570BD-1FAD-496C-A92C-3D8383FF2A2F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FC7570BD-1FAD-496C-A92C-3D8383FF2A2F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {808919FA-4500-46A5-BAF2-1F914CC1BB7E} + EndGlobalSection +EndGlobal diff --git "a/\347\206\212\350\266\205/DIText001/Controllers/TextController.cs" "b/\347\206\212\350\266\205/DIText001/Controllers/TextController.cs" new file mode 100644 index 0000000000000000000000000000000000000000..85d91c4535b3f93e7187ae00cbefd7fce6a2e925 --- /dev/null +++ "b/\347\206\212\350\266\205/DIText001/Controllers/TextController.cs" @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using DIText001.DOMain.Entity; +using DIText001.Helper; +using DIText001.Interface; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace DIText001.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class TextController : ControllerBase + { + private readonly IRespository _userRepository; + public TextController(IRespository userRepository) + { + _userRepository = userRepository; + } + public string Get() + { + var list = _userRepository.Table.ToList(); + return JsonHelper.SerializeObject(list); + } + } +} \ No newline at end of file diff --git "a/\347\206\212\350\266\205/DIText001/Controllers/WeatherForecastController.cs" "b/\347\206\212\350\266\205/DIText001/Controllers/WeatherForecastController.cs" new file mode 100644 index 0000000000000000000000000000000000000000..fe7f1c644f0071b9e285943b5d6d2474b335de4c --- /dev/null +++ "b/\347\206\212\350\266\205/DIText001/Controllers/WeatherForecastController.cs" @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.DependencyInjection; +using DIText001.DOMain; +using DIText001.DOMain.Entity; +using Newtonsoft.Json; +using Microsoft.EntityFrameworkCore; +using DIText001.Helper; + +namespace DIText001.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private readonly Admin3000Context _db; + //[ActivatorUtilitiesConstructor] + //public WeatherForecastController(Admin3000Context dbContext) + //{ + // _db = dbContext; + //} + + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger,Admin3000Context dbContext) + { + _logger = logger; + _db = dbContext; + } + + [HttpGet] + public string Get() + { + //var rng = new Random(); + //return Enumerable.Range(1, 5).Select(index => new WeatherForecast + //{ + // Date = DateTime.Now.AddDays(index), + // TemperatureC = rng.Next(-20, 55), + // Summary = Summaries[rng.Next(Summaries.Length)] + //}) + //.ToArray(); + var res = _db.Users.Include(x=>x.Roles).ToList(); + + return JsonHelper.SerializeObject(res); + } + } +} diff --git "a/\347\206\212\350\266\205/DIText001/DIText001.csproj" "b/\347\206\212\350\266\205/DIText001/DIText001.csproj" new file mode 100644 index 0000000000000000000000000000000000000000..37cf19e372463070d640aabced7f568649e9e823 --- /dev/null +++ "b/\347\206\212\350\266\205/DIText001/DIText001.csproj" @@ -0,0 +1,16 @@ + + + + netcoreapp3.1 + + + + + + + + + + + + diff --git "a/\347\206\212\350\266\205/DIText001/DOMain/Admin3000Context.cs" "b/\347\206\212\350\266\205/DIText001/DOMain/Admin3000Context.cs" new file mode 100644 index 0000000000000000000000000000000000000000..85e0b7dfc2fa1f2d55981978e9a1eadafe07a8cc --- /dev/null +++ "b/\347\206\212\350\266\205/DIText001/DOMain/Admin3000Context.cs" @@ -0,0 +1,21 @@ +using DIText001.DOMain.Entity; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DIText001.DOMain +{ + public class Admin3000Context:DbContext + { + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlServer("server=.;database=Admin3000;uid=sa;pwd=123456"); + } + + public DbSet Users { get; set; } + + public DbSet Roles { get; set; } + } +} diff --git "a/\347\206\212\350\266\205/DIText001/DOMain/BaseEntity.cs" "b/\347\206\212\350\266\205/DIText001/DOMain/BaseEntity.cs" new file mode 100644 index 0000000000000000000000000000000000000000..7a9197f820934deb6ae305f518015e6aa5c7b5a0 --- /dev/null +++ "b/\347\206\212\350\266\205/DIText001/DOMain/BaseEntity.cs" @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DIText001.DOMain +{ + public abstract class BaseEntity + { + public BaseEntity() + { + IsActived = true; + IsDeleted = true; + CreatedTime = DateTime.Now; + UpdatedTime = DateTime.Now; + } + + public int Id { get; set; } + + public bool IsActived { get; set; } + + public bool IsDeleted { get; set; } + + public DateTime CreatedTime { get; set; } + + public DateTime UpdatedTime { get; set; } + + public string Remarks { get; set; } + } +} diff --git "a/\347\206\212\350\266\205/DIText001/DOMain/Dbinitializer.cs" "b/\347\206\212\350\266\205/DIText001/DOMain/Dbinitializer.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8fdab54856b1df7fcc0b341c2fe7e7ed298bd8e2 --- /dev/null +++ "b/\347\206\212\350\266\205/DIText001/DOMain/Dbinitializer.cs" @@ -0,0 +1,47 @@ +using DIText001.DOMain.Entity; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DIText001.DOMain +{ + public class Dbinitializer + { + public static void Seed() + { + using (var db = new Admin3000Context()) + { + db.Database.EnsureCreated(); + var hasUser = db.Users.Any(); + if (!hasUser) + { + var role1 = new Roles + { + RoleName = "熊超", + Description = "没错,我就是熊超" + }; + db.Roles.Add(role1); + db.SaveChanges(); + db.Users.AddRange(new Users[] + { + new Users + { + Username="xiongchao", + Password="123", + RoleId=role1.Id + + }, + new Users + { + Username="xiongchao1", + Password="12345", + RoleId=role1.Id + } + }); + } + db.SaveChanges(); + } + } + } +} diff --git "a/\347\206\212\350\266\205/DIText001/DOMain/Entity/Roles.cs" "b/\347\206\212\350\266\205/DIText001/DOMain/Entity/Roles.cs" new file mode 100644 index 0000000000000000000000000000000000000000..023673cba54016334c96bb1f45b655c95dccb0ca --- /dev/null +++ "b/\347\206\212\350\266\205/DIText001/DOMain/Entity/Roles.cs" @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DIText001.DOMain.Entity +{ + public class Roles:BaseEntity + { + public string RoleName { get; set; } + + public string Description { get; set; } + + public IEnumerable Users { get; set; } + } +} diff --git "a/\347\206\212\350\266\205/DIText001/DOMain/Entity/Users.cs" "b/\347\206\212\350\266\205/DIText001/DOMain/Entity/Users.cs" new file mode 100644 index 0000000000000000000000000000000000000000..21151645630a2dd5fb21dd1dec5b5d9be4a133d4 --- /dev/null +++ "b/\347\206\212\350\266\205/DIText001/DOMain/Entity/Users.cs" @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DIText001.DOMain.Entity +{ + public class Users:BaseEntity + { + public string Username { get; set; } + + public string Password { get; set; } + + public int RoleId { get; set; } + + public Roles Roles { get; set; } + } +} diff --git "a/\347\206\212\350\266\205/DIText001/Helper/JsonHelper.cs" "b/\347\206\212\350\266\205/DIText001/Helper/JsonHelper.cs" new file mode 100644 index 0000000000000000000000000000000000000000..41508da267cbddee81fb73c8574a35d72025f783 --- /dev/null +++ "b/\347\206\212\350\266\205/DIText001/Helper/JsonHelper.cs" @@ -0,0 +1,20 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DIText001.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/\347\206\212\350\266\205/DIText001/Implementation/EfRespository.cs" "b/\347\206\212\350\266\205/DIText001/Implementation/EfRespository.cs" new file mode 100644 index 0000000000000000000000000000000000000000..094b105daebf0eade65792d7676e919024523175 --- /dev/null +++ "b/\347\206\212\350\266\205/DIText001/Implementation/EfRespository.cs" @@ -0,0 +1,79 @@ +using DIText001.DOMain; +using DIText001.Interface; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DIText001.Implementation +{ + public class EfRespository : IRespository where T : BaseEntity + { + private readonly Admin3000Context db; + private DbSet _entity; + + protected DbSet Entity { get + { + if (_entity==null) + { + _entity = db.Set(); + } + return _entity; + } + } + public IQueryable Table + { + get + { + + return Entity; + } + } + public EfRespository(Admin3000Context dbContext) + { + db = dbContext; + } + public void Delete(T entity) + { + this._entity.Remove(entity); + db.SaveChanges(); + } + + public void Delete(int id) + { + var row=Table.Where(x => x.Id==id).FirstOrDefault(); + Delete(row); + db.SaveChanges(); + } + + + + public T GetById(int id) + { + return _entity.Where(x => x.Id == id).FirstOrDefault(); + db.SaveChanges(); + } + + public void insert(T entity) + { + _entity.Add(entity); + db.SaveChanges(); + } + + public void InsertBulk(IEnumerable list) + { + _entity.AddRange(list); + db.SaveChanges(); + } + + + public void Update(T entity) + { + _entity.Update(entity); + db.SaveChanges(); + } + + + } +} diff --git "a/\347\206\212\350\266\205/DIText001/Interface/IRespository.cs" "b/\347\206\212\350\266\205/DIText001/Interface/IRespository.cs" new file mode 100644 index 0000000000000000000000000000000000000000..6a4b9d9c4d42c5120e17dc891626ac8896bd5880 --- /dev/null +++ "b/\347\206\212\350\266\205/DIText001/Interface/IRespository.cs" @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DIText001.Interface +{ + public interface IRespository + { + IQueryable Table { get; } + + T GetById(int id); + + + void insert(T entity); + + void InsertBulk(IEnumerable list); + + void Update(T entity); + + void Delete(T entity); + + void Delete(int id); + } +} diff --git "a/\347\206\212\350\266\205/DIText001/Program.cs" "b/\347\206\212\350\266\205/DIText001/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..d3a6f46f00fff521fc2f6ce314713fb5b6d9dd9c --- /dev/null +++ "b/\347\206\212\350\266\205/DIText001/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 DIText001 +{ + 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/\347\206\212\350\266\205/DIText001/Properties/launchSettings.json" "b/\347\206\212\350\266\205/DIText001/Properties/launchSettings.json" new file mode 100644 index 0000000000000000000000000000000000000000..bf4587871407c1220bb28e3a1f098c53de6c8746 --- /dev/null +++ "b/\347\206\212\350\266\205/DIText001/Properties/launchSettings.json" @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:49802", + "sslPort": 44368 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "weatherforecast", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "DIText001": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "weatherforecast", + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git "a/\347\206\212\350\266\205/DIText001/Startup.cs" "b/\347\206\212\350\266\205/DIText001/Startup.cs" new file mode 100644 index 0000000000000000000000000000000000000000..2306afcf77be787987bd6932226a532a1bc52ec8 --- /dev/null +++ "b/\347\206\212\350\266\205/DIText001/Startup.cs" @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using DIText001.DOMain; +using DIText001.Implementation; +using DIText001.Interface; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpsPolicy; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace DIText001 +{ + 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(EfRespository<>)); + + 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.UseHttpsRedirection(); + + app.UseRouting(); + + app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + Dbinitializer.Seed(); + } + } +} diff --git "a/\347\206\212\350\266\205/DIText001/WeatherForecast.cs" "b/\347\206\212\350\266\205/DIText001/WeatherForecast.cs" new file mode 100644 index 0000000000000000000000000000000000000000..5dcce5d817629f8e16cdc87ada4c2c1bf0e60640 --- /dev/null +++ "b/\347\206\212\350\266\205/DIText001/WeatherForecast.cs" @@ -0,0 +1,15 @@ +using System; + +namespace DIText001 +{ + 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/\347\206\212\350\266\205/DIText001/appsettings.Development.json" "b/\347\206\212\350\266\205/DIText001/appsettings.Development.json" new file mode 100644 index 0000000000000000000000000000000000000000..8983e0fc1c5e2795ccfde0c771c6d66c88ef4a42 --- /dev/null +++ "b/\347\206\212\350\266\205/DIText001/appsettings.Development.json" @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git "a/\347\206\212\350\266\205/DIText001/appsettings.json" "b/\347\206\212\350\266\205/DIText001/appsettings.json" new file mode 100644 index 0000000000000000000000000000000000000000..d9d9a9bff6fd6f3ee7ea00de958f135a4a28c6e6 --- /dev/null +++ "b/\347\206\212\350\266\205/DIText001/appsettings.json" @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +}