diff --git "a/\345\275\255\350\210\222\345\251\267/WebApi001/Domain/DbInitializeHelper.cs" "b/\345\275\255\350\210\222\345\251\267/WebApi001/Domain/DbInitializeHelper.cs" deleted file mode 100644 index 82398e3f030ffa49da079fbea03599fc0e49a0a3..0000000000000000000000000000000000000000 --- "a/\345\275\255\350\210\222\345\251\267/WebApi001/Domain/DbInitializeHelper.cs" +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using WebApi001.Domain.Entity; - -namespace WebApi001.Domain -{ - public class DbInitializeHelper - { - public static void Initialize() - { - using (var db = new Admin5000DbContext()) - { - var dbExist = db.Database.EnsureCreated(); - - var tempBrand = db.Brands.Any(); - if (!tempBrand) - { - var brand = new Brand - { - BrandName = "杰克琼斯", - Description = "丹麦品牌" - }; - - db.Brands.Add(brand); - - db.SaveChanges(); - - db.Products.AddRange(new Product[] - { - new Product - { - ProductName="牛仔裤", - ShortDesc="潮流新款", - FullDesc="这是一个详情描述,敷衍", - BrandId=brand.Id - }, - new Product - { - ProductName="衬衣_白色", - ShortDesc="宽松休闲", - FullDesc="这是一个详情描述,敷衍+1", - BrandId=brand.Id - }, - }); - db.SaveChanges(); - } - - - } - } - } -} diff --git "a/\345\275\255\350\210\222\345\251\267/WebApi001/Interface/IRespository.cs" "b/\345\275\255\350\210\222\345\251\267/WebApi001/Interface/IRespository.cs" deleted file mode 100644 index 011397b0d718012b31f592474b6b7f03ca226e3e..0000000000000000000000000000000000000000 --- "a/\345\275\255\350\210\222\345\251\267/WebApi001/Interface/IRespository.cs" +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace WebApi001.Interface -{ - interface IRespository - { - } -} diff --git "a/\345\275\255\350\210\222\345\251\267/WebApi001.sln" "b/\345\275\255\350\210\222\345\251\267/WebApi003.sln" similarity index 59% rename from "\345\275\255\350\210\222\345\251\267/WebApi001.sln" rename to "\345\275\255\350\210\222\345\251\267/WebApi003.sln" index f8a5582f2b0c531578c499277da0afba9f13721e..589b18fb11858aad9f8982e635cf0543fcafe6e5 100644 --- "a/\345\275\255\350\210\222\345\251\267/WebApi001.sln" +++ "b/\345\275\255\350\210\222\345\251\267/WebApi003.sln" @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30114.105 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApi001", "WebApi001\WebApi001.csproj", "{7294D209-D1AE-41D9-AC99-BF23065BD08F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApi003", "WebApi003\WebApi003.csproj", "{49543E4D-B8D8-4320-8016-AFFDB8C52670}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,15 +11,15 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7294D209-D1AE-41D9-AC99-BF23065BD08F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7294D209-D1AE-41D9-AC99-BF23065BD08F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7294D209-D1AE-41D9-AC99-BF23065BD08F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7294D209-D1AE-41D9-AC99-BF23065BD08F}.Release|Any CPU.Build.0 = Release|Any CPU + {49543E4D-B8D8-4320-8016-AFFDB8C52670}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {49543E4D-B8D8-4320-8016-AFFDB8C52670}.Debug|Any CPU.Build.0 = Debug|Any CPU + {49543E4D-B8D8-4320-8016-AFFDB8C52670}.Release|Any CPU.ActiveCfg = Release|Any CPU + {49543E4D-B8D8-4320-8016-AFFDB8C52670}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {71F544B9-9AD2-4535-B35A-93EB9931C304} + SolutionGuid = {A472EF7F-900D-41E7-8396-06C38AB61628} EndGlobalSection EndGlobal diff --git "a/\345\275\255\350\210\222\345\251\267/WebApi003/Controllers/ValuesController.cs" "b/\345\275\255\350\210\222\345\251\267/WebApi003/Controllers/ValuesController.cs" new file mode 100644 index 0000000000000000000000000000000000000000..8b651c9da836e81ead81d7344dac41d8d2bfb3ee --- /dev/null +++ "b/\345\275\255\350\210\222\345\251\267/WebApi003/Controllers/ValuesController.cs" @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using WebApi003.Domain.Entity; +using WebApi003.Domain.Helper; +using WebApi003.Interface; + +namespace WebApi003.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ValuesController : ControllerBase + { + private readonly IRespository _ProductIRespository; + + public ValuesController(IRespository ProductIRespository) + { + _ProductIRespository = ProductIRespository; + } + + public string Get() + { + var list = _ProductIRespository.Table.ToList(); + //串行 + return JsonHelper.SerializeObject(list); + } + } +} diff --git "a/\345\275\255\350\210\222\345\251\267/WebApi001/Controllers/WeatherForecastController.cs" "b/\345\275\255\350\210\222\345\251\267/WebApi003/Controllers/WeatherForecastController.cs" similarity index 63% rename from "\345\275\255\350\210\222\345\251\267/WebApi001/Controllers/WeatherForecastController.cs" rename to "\345\275\255\350\210\222\345\251\267/WebApi003/Controllers/WeatherForecastController.cs" index 5033c07d3d596adaff5c26920aa3ceb51c69b82b..48b597c5b64acdc4d9e2029f8c5316480850d4c6 100644 --- "a/\345\275\255\350\210\222\345\251\267/WebApi001/Controllers/WeatherForecastController.cs" +++ "b/\345\275\255\350\210\222\345\251\267/WebApi003/Controllers/WeatherForecastController.cs" @@ -3,32 +3,25 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json; -using WebApi001.Domain; -using WebApi001.Domain.Entity; using Microsoft.Extensions.DependencyInjection; -using System.Runtime.Serialization; -using Microsoft.EntityFrameworkCore; -using System.ComponentModel; -using WebApi001.Domain.Helper; +using Microsoft.Extensions.Logging; +using WebApi003.Domain; +using WebApi003.Domain.Entity; +using WebApi003.Domain.Helper; -namespace WebApi001.Controllers +namespace WebApi003.Controllers { [ApiController] [Route("[controller]")] public class WeatherForecastController : ControllerBase { //依赖注入 - //方法一 - private readonly Admin5000DbContext _db; - + private readonly Admin3200DbContext _db; [ActivatorUtilitiesConstructor] - public WeatherForecastController(Admin5000DbContext dbContext) + public WeatherForecastController(Admin3200DbContext dbContext) { _db = dbContext; } - private static readonly string[] Summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" @@ -41,17 +34,20 @@ namespace WebApi001.Controllers _logger = logger; } - //方法二:直接注释构造函数logger - - //方法三:将两个构造函数写在一起 - //public WeatherForecastController(ILogger logger,Admin5000DbContext _db) - //{ - // _logger = logger; - // _db = dbContext; - //} [HttpGet] + //public IEnumerable Get() public string Get() { + //前 + //var list = new List(); + //using(var db = new Admin3200DbContext()) + //{ + // list = db.Products.ToList(); + //} + //return list; + + + //var res = _db.Products.Include(x=>x.Brand).ToList();加Include(x=>x.Brand.)就会有一大串的Brand值 var res = _db.Products.ToList(); //json 串行 diff --git "a/\345\275\255\350\210\222\345\251\267/WebApi001/Domain/Admin5000DbContext.cs" "b/\345\275\255\350\210\222\345\251\267/WebApi003/Domain/Admin3200DbContext.cs" similarity index 76% rename from "\345\275\255\350\210\222\345\251\267/WebApi001/Domain/Admin5000DbContext.cs" rename to "\345\275\255\350\210\222\345\251\267/WebApi003/Domain/Admin3200DbContext.cs" index e7d781f1a506357a179542b9d4650e7252b79cba..27a6da4a14ebc82e094b56817d2ad5767250e278 100644 --- "a/\345\275\255\350\210\222\345\251\267/WebApi001/Domain/Admin5000DbContext.cs" +++ "b/\345\275\255\350\210\222\345\251\267/WebApi003/Domain/Admin3200DbContext.cs" @@ -3,17 +3,17 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using WebApi001.Domain.Entity; +using WebApi003.Domain.Entity; -namespace WebApi001.Domain +namespace WebApi003.Domain { - public class Admin5000DbContext:DbContext + public class Admin3200DbContext:DbContext { - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - optionsBuilder.UseSqlServer("server=.;database=Admin5000;uid=sa;pwd=123456;"); + optionsBuilder.UseSqlServer("server=.;database=Admin3200;uid=sa;pwd=123456"); } + public DbSet Products { get; set; } public DbSet Brands { get; set; } diff --git "a/\345\275\255\350\210\222\345\251\267/WebApi001/Domain/BaseEntity.cs" "b/\345\275\255\350\210\222\345\251\267/WebApi003/Domain/BaseEntity.cs" similarity index 81% rename from "\345\275\255\350\210\222\345\251\267/WebApi001/Domain/BaseEntity.cs" rename to "\345\275\255\350\210\222\345\251\267/WebApi003/Domain/BaseEntity.cs" index 36e1a7e62219b7d5659f0bd130d21694c6957dad..efcf167fef237bdf730c6a9d073acc292538d7c5 100644 --- "a/\345\275\255\350\210\222\345\251\267/WebApi001/Domain/BaseEntity.cs" +++ "b/\345\275\255\350\210\222\345\251\267/WebApi003/Domain/BaseEntity.cs" @@ -3,10 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace WebApi001.Domain +namespace WebApi003.Domain { - public abstract class BaseEntity + public class BaseEntity { + //设置默认值 public BaseEntity() { IsActived = true; @@ -20,6 +21,8 @@ namespace WebApi001.Domain public bool IsDeleted { get; set; } + public int DisplayOrder { get; set; } + public DateTime CreatedTime { get; set; } public DateTime UpdatedTime { get; set; } diff --git "a/\345\275\255\350\210\222\345\251\267/WebApi003/Domain/DbInitializeHelper.cs" "b/\345\275\255\350\210\222\345\251\267/WebApi003/Domain/DbInitializeHelper.cs" new file mode 100644 index 0000000000000000000000000000000000000000..b6e7b09f6cd7da9f5d4a5abae8b6b82174b38f69 --- /dev/null +++ "b/\345\275\255\350\210\222\345\251\267/WebApi003/Domain/DbInitializeHelper.cs" @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using WebApi003.Domain.Entity; + +namespace WebApi003.Domain +{ + public class DbInitializeHelper + { + public static void Initialize() + { + using (var db = new Admin3200DbContext()) + { + var dbExist = db.Database.EnsureCreated(); + //重复数据判断 + var tempBrand = db.Brands.Any(); + if (!tempBrand) + { + var brand = new Brand + { + BrandName = "DIOR", + Description = "DIOR迪奥," + + "由法国时装设计师克里斯汀·迪奥(Christian Dior)于1946年创于巴黎," + + "品牌保持高贵优雅的风格品位,演绎时尚魅惑,自信活力。" + + "在时装、珠宝及手表、香水、彩妆和护肤领域,迪奥是优雅与奢华的完美呈现。" + + "在线订购免运费,正品保证。" + }; + + db.Brands.Add(brand); + db.SaveChanges(); + + db.Products.AddRange(new Product[] + { + new Product + { + ProductName="中号 DIOR BOBBY 手袋", + ShortDesc="蓝色 Oblique 印花", + FullDesc="这款 Dior Bobby 手袋为单肩包款式,彰显高雅的轮廓与协调的比例。" + + "这款中号手袋采用蓝色 Oblique 印花帆布精心制作,饰以复古金色五金配件提升格调。" + + "搭配可拆卸、可调节的肩带,点缀有军装风格搭扣,可肩背、斜挎或手提。", + BrandId=brand.Id + }, + new Product + { + ProductName="#限量版 迪奥魅惑", + ShortDesc="魅惑星耀唇膏高订限量套装*", + FullDesc="魅惑星耀唇膏高订限量套装*,内含4款粉耀明星色,持妆闪耀,持久滋润双唇。" + + "经典DIOR迪奥粉高订设计,富于个性,内盖饰以化妆镜," + + "套装外盒缀以象征品牌的“D”字精巧挂饰和幸运星。", + BrandId=brand.Id + } + }); + db.SaveChanges(); + } + } + } + + } +} diff --git "a/\345\275\255\350\210\222\345\251\267/WebApi001/Domain/Entity/Brand.cs" "b/\345\275\255\350\210\222\345\251\267/WebApi003/Domain/Entity/Brand.cs" similarity index 89% rename from "\345\275\255\350\210\222\345\251\267/WebApi001/Domain/Entity/Brand.cs" rename to "\345\275\255\350\210\222\345\251\267/WebApi003/Domain/Entity/Brand.cs" index afe5b70ee5a03605ff94c143fc431fc206ca4173..fa32500a2115f5666b9ffcdda6d0f9b8310445f2 100644 --- "a/\345\275\255\350\210\222\345\251\267/WebApi001/Domain/Entity/Brand.cs" +++ "b/\345\275\255\350\210\222\345\251\267/WebApi003/Domain/Entity/Brand.cs" @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace WebApi001.Domain.Entity +namespace WebApi003.Domain.Entity { public class Brand:BaseEntity { @@ -12,7 +12,5 @@ namespace WebApi001.Domain.Entity public string Description { get; set; } public IEnumerable Products { get; set; } - - } } diff --git "a/\345\275\255\350\210\222\345\251\267/WebApi001/Domain/Entity/Product.cs" "b/\345\275\255\350\210\222\345\251\267/WebApi003/Domain/Entity/Product.cs" similarity index 56% rename from "\345\275\255\350\210\222\345\251\267/WebApi001/Domain/Entity/Product.cs" rename to "\345\275\255\350\210\222\345\251\267/WebApi003/Domain/Entity/Product.cs" index dab49c8ebcb5c6b97c1f940046604c020639b636..e2b6d3117054661392a926ba91f6fe6f678a7206 100644 --- "a/\345\275\255\350\210\222\345\251\267/WebApi001/Domain/Entity/Product.cs" +++ "b/\345\275\255\350\210\222\345\251\267/WebApi003/Domain/Entity/Product.cs" @@ -1,19 +1,21 @@ -using System; +using Microsoft.VisualBasic.CompilerServices; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace WebApi001.Domain.Entity +namespace WebApi003.Domain.Entity { public class Product:BaseEntity { public string ProductName { get; set; } - public string ShortDesc { get; set; } + public string ShortDesc { get; set; }//简介 - public string FullDesc { get; set; } + public string FullDesc { get; set; }//详情 public int BrandId { get; set; } + public Brand Brand { get; set; } } } diff --git "a/\345\275\255\350\210\222\345\251\267/WebApi001/Domain/Helper/JsonHelper.cs" "b/\345\275\255\350\210\222\345\251\267/WebApi003/Domain/Helper/JsonHelper.cs" similarity index 78% rename from "\345\275\255\350\210\222\345\251\267/WebApi001/Domain/Helper/JsonHelper.cs" rename to "\345\275\255\350\210\222\345\251\267/WebApi003/Domain/Helper/JsonHelper.cs" index 7e00c7664c3bd07f04e49e4428cc6aee1b948ac3..c42db4b60e990e619d7c2f180c46d303da60a378 100644 --- "a/\345\275\255\350\210\222\345\251\267/WebApi001/Domain/Helper/JsonHelper.cs" +++ "b/\345\275\255\350\210\222\345\251\267/WebApi003/Domain/Helper/JsonHelper.cs" @@ -2,16 +2,17 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json.Serialization; using System.Threading.Tasks; -namespace WebApi001.Domain.Helper +namespace WebApi003.Domain.Helper { - public class JsonHelper + public class JsonHelper //包装一下 { //序列化 public static string SerializeObject(object obj) { - //json 串行 + //json串行 return JsonConvert.SerializeObject(obj, Formatting.Indented, new JsonSerializerSettings { diff --git "a/\345\275\255\350\210\222\345\251\267/WebApi003/Implementation/EfRespository.cs" "b/\345\275\255\350\210\222\345\251\267/WebApi003/Implementation/EfRespository.cs" new file mode 100644 index 0000000000000000000000000000000000000000..ab2d9f0956ab50fb9b7b39d9eabb61713b207142 --- /dev/null +++ "b/\345\275\255\350\210\222\345\251\267/WebApi003/Implementation/EfRespository.cs" @@ -0,0 +1,82 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using WebApi003.Domain; +using WebApi003.Interface; + +namespace WebApi003.Implementation +{ + public class EfRespository : IRespository where T : BaseEntity + { + private readonly Admin3200DbContext db; + + public EfRespository(Admin3200DbContext dbContext) + { + db = dbContext; + } + + private DbSet _entity; + + protected DbSet Entity + { + get + { + return Entity; + } + } + + //属性 + //IQueryable可查询 + public IQueryable Table + { + get + { + if(_entity==null) + { + _entity = db.Set(); + } + return _entity; + } + + } + 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); + } + + public T GetById(int id) + { + return _entity.Where(x => x.Id == id).FirstOrDefault(); + } + + public void Insert(T entity) + { + //throw new NotImplementedException(); + _entity.Add(entity); + db.SaveChanges(); + } + + public void InsertBulk(IEnumerable list) + { + //throw new NotImplementedException(); + _entity.AddRange(list); + db.SaveChanges(); + } + + public void Update(T entity) + { + //throw new NotImplementedException(); + _entity.Update(entity); + db.SaveChanges(); + } + } +} diff --git "a/\345\275\255\350\210\222\345\251\267/WebApi003/Interface/IRespository.cs" "b/\345\275\255\350\210\222\345\251\267/WebApi003/Interface/IRespository.cs" new file mode 100644 index 0000000000000000000000000000000000000000..dd2e958c9dbbc562bb0ba9ce4036e2b1a587b47a --- /dev/null +++ "b/\345\275\255\350\210\222\345\251\267/WebApi003/Interface/IRespository.cs" @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace WebApi003.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/\345\275\255\350\210\222\345\251\267/WebApi001/Program.cs" "b/\345\275\255\350\210\222\345\251\267/WebApi003/Program.cs" similarity index 97% rename from "\345\275\255\350\210\222\345\251\267/WebApi001/Program.cs" rename to "\345\275\255\350\210\222\345\251\267/WebApi003/Program.cs" index 02f63b4327ea274bbb68e8ba9d2230d561da8e40..fe7fcbc54bd942aab00c70081514baee391f393e 100644 --- "a/\345\275\255\350\210\222\345\251\267/WebApi001/Program.cs" +++ "b/\345\275\255\350\210\222\345\251\267/WebApi003/Program.cs" @@ -7,7 +7,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -namespace WebApi001 +namespace WebApi003 { public class Program { diff --git "a/\345\275\255\350\210\222\345\251\267/WebApi001/Properties/launchSettings.json" "b/\345\275\255\350\210\222\345\251\267/WebApi003/Properties/launchSettings.json" similarity index 90% rename from "\345\275\255\350\210\222\345\251\267/WebApi001/Properties/launchSettings.json" rename to "\345\275\255\350\210\222\345\251\267/WebApi003/Properties/launchSettings.json" index 2f6ea349cdd636bf05452d000f895c18ba15fdda..9eb82cff48eaccfe74708db7ed5d4f38150da7e3 100644 --- "a/\345\275\255\350\210\222\345\251\267/WebApi001/Properties/launchSettings.json" +++ "b/\345\275\255\350\210\222\345\251\267/WebApi003/Properties/launchSettings.json" @@ -4,7 +4,7 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:56703", + "applicationUrl": "http://localhost:64326", "sslPort": 0 } }, @@ -17,7 +17,7 @@ "ASPNETCORE_ENVIRONMENT": "Development" } }, - "WebApi001": { + "WebApi003": { "commandName": "Project", "launchBrowser": true, "launchUrl": "weatherforecast", diff --git "a/\345\275\255\350\210\222\345\251\267/WebApi001/Startup.cs" "b/\345\275\255\350\210\222\345\251\267/WebApi003/Startup.cs" similarity index 84% rename from "\345\275\255\350\210\222\345\251\267/WebApi001/Startup.cs" rename to "\345\275\255\350\210\222\345\251\267/WebApi003/Startup.cs" index e9d2eb39f27aeeeb66b5e0ff2ef98935cb33b6fa..8a55d4adfcdc536f1bf70fab54189e16bcfc226a 100644 --- "a/\345\275\255\350\210\222\345\251\267/WebApi001/Startup.cs" +++ "b/\345\275\255\350\210\222\345\251\267/WebApi003/Startup.cs" @@ -9,9 +9,11 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using WebApi001.Domain; +using WebApi003.Domain; +using WebApi003.Implementation; +using WebApi003.Interface; -namespace WebApi001 +namespace WebApi003 { public class Startup { @@ -25,7 +27,8 @@ namespace WebApi001 // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddDbContext(); + services.AddDbContext(); + services.AddScoped(typeof(IRespository<>), typeof(EfRespository<>)); services.AddControllers(); } @@ -37,8 +40,6 @@ namespace WebApi001 app.UseDeveloperExceptionPage(); } - - app.UseRouting(); app.UseAuthorization(); diff --git "a/\345\275\255\350\210\222\345\251\267/WebApi001/WeatherForecast.cs" "b/\345\275\255\350\210\222\345\251\267/WebApi003/WeatherForecast.cs" similarity index 93% rename from "\345\275\255\350\210\222\345\251\267/WebApi001/WeatherForecast.cs" rename to "\345\275\255\350\210\222\345\251\267/WebApi003/WeatherForecast.cs" index f7e7578768d8494b9a8d1e6c5513003e3036bca9..2a69fe5710c1f138a753d19f875c7c7f61af81e9 100644 --- "a/\345\275\255\350\210\222\345\251\267/WebApi001/WeatherForecast.cs" +++ "b/\345\275\255\350\210\222\345\251\267/WebApi003/WeatherForecast.cs" @@ -1,6 +1,6 @@ using System; -namespace WebApi001 +namespace WebApi003 { public class WeatherForecast { diff --git "a/\345\275\255\350\210\222\345\251\267/WebApi001/WebApi001.csproj" "b/\345\275\255\350\210\222\345\251\267/WebApi003/WebApi003.csproj" similarity index 50% rename from "\345\275\255\350\210\222\345\251\267/WebApi001/WebApi001.csproj" rename to "\345\275\255\350\210\222\345\251\267/WebApi003/WebApi003.csproj" index f4e07678e5e8d7820d3a592bac34b497fa73f215..87a6ad18b0e237a185327d48ecd19c83359a2f8b 100644 --- "a/\345\275\255\350\210\222\345\251\267/WebApi001/WebApi001.csproj" +++ "b/\345\275\255\350\210\222\345\251\267/WebApi003/WebApi003.csproj" @@ -4,17 +4,6 @@ netcoreapp3.1 - - - - - - - - - - - @@ -22,9 +11,5 @@ - - - - diff --git "a/\345\275\255\350\210\222\345\251\267/WebApi001/appsettings.Development.json" "b/\345\275\255\350\210\222\345\251\267/WebApi003/appsettings.Development.json" similarity index 100% rename from "\345\275\255\350\210\222\345\251\267/WebApi001/appsettings.Development.json" rename to "\345\275\255\350\210\222\345\251\267/WebApi003/appsettings.Development.json" diff --git "a/\345\275\255\350\210\222\345\251\267/WebApi001/appsettings.json" "b/\345\275\255\350\210\222\345\251\267/WebApi003/appsettings.json" similarity index 100% rename from "\345\275\255\350\210\222\345\251\267/WebApi001/appsettings.json" rename to "\345\275\255\350\210\222\345\251\267/WebApi003/appsettings.json"