diff --git "a/\345\274\240\346\236\227\347\272\242/2021-6-15(\346\263\250\345\206\214\350\267\257\347\224\261).md" "b/\345\274\240\346\236\227\347\272\242/2021-06-15(\346\263\250\345\206\214\350\267\257\347\224\261).md" similarity index 100% rename from "\345\274\240\346\236\227\347\272\242/2021-6-15(\346\263\250\345\206\214\350\267\257\347\224\261).md" rename to "\345\274\240\346\236\227\347\272\242/2021-06-15(\346\263\250\345\206\214\350\267\257\347\224\261).md" diff --git "a/\345\274\240\346\236\227\347\272\242/2021-6-16(vueCli\345\212\250\346\200\201\350\267\257\347\224\261).md" "b/\345\274\240\346\236\227\347\272\242/2021-06-16(vueCli\345\212\250\346\200\201\350\267\257\347\224\261).md" similarity index 100% rename from "\345\274\240\346\236\227\347\272\242/2021-6-16(vueCli\345\212\250\346\200\201\350\267\257\347\224\261).md" rename to "\345\274\240\346\236\227\347\272\242/2021-06-16(vueCli\345\212\250\346\200\201\350\267\257\347\224\261).md" diff --git "a/\345\274\240\346\236\227\347\272\242/2021-6-18(vue\347\274\226\347\250\213\345\274\217\345\257\274\350\210\252,\345\221\275\345\220\215\350\267\257\347\224\261).md" "b/\345\274\240\346\236\227\347\272\242/2021-06-18(vue\347\274\226\347\250\213\345\274\217\345\257\274\350\210\252,\345\221\275\345\220\215\350\267\257\347\224\261).md" similarity index 100% rename from "\345\274\240\346\236\227\347\272\242/2021-6-18(vue\347\274\226\347\250\213\345\274\217\345\257\274\350\210\252,\345\221\275\345\220\215\350\267\257\347\224\261).md" rename to "\345\274\240\346\236\227\347\272\242/2021-06-18(vue\347\274\226\347\250\213\345\274\217\345\257\274\350\210\252,\345\221\275\345\220\215\350\267\257\347\224\261).md" diff --git "a/\345\274\240\346\236\227\347\272\242/2021-6-19(vue\345\221\275\345\220\215\347\273\204\344\273\266,\345\265\214\345\245\227\347\273\204\344\273\266).md" "b/\345\274\240\346\236\227\347\272\242/2021-06-19(vue\345\221\275\345\220\215\347\273\204\344\273\266,\345\265\214\345\245\227\347\273\204\344\273\266).md" similarity index 100% rename from "\345\274\240\346\236\227\347\272\242/2021-6-19(vue\345\221\275\345\220\215\347\273\204\344\273\266,\345\265\214\345\245\227\347\273\204\344\273\266).md" rename to "\345\274\240\346\236\227\347\272\242/2021-06-19(vue\345\221\275\345\220\215\347\273\204\344\273\266,\345\265\214\345\245\227\347\273\204\344\273\266).md" diff --git "a/\345\274\240\346\236\227\347\272\242/2021-06-22(API\351\203\250\345\210\206\345\221\275\344\273\244).md" "b/\345\274\240\346\236\227\347\272\242/2021-06-22(API\351\203\250\345\210\206\345\221\275\344\273\244).md" new file mode 100644 index 0000000000000000000000000000000000000000..c8839df657dfbc10fb0ecd594b3db4653d69f959 --- /dev/null +++ "b/\345\274\240\346\236\227\347\272\242/2021-06-22(API\351\203\250\345\210\206\345\221\275\344\273\244).md" @@ -0,0 +1,17 @@ +查看所有命令 dotnet -h + +获取有关命令的详细信息 dotent new -h + +mkdir MyApi.Api 创建文件夹:项目名称要与文件夹名称一致 + +dotnet new webapi:dotnet new - 根据指定的模板,创建新的项目、配置文件或解决方案。 + + + +dotnet run 服务器跑动 + + + +dotnet dev-certs https -h 信任证书 + +dotnet new webapi -n MyApi.Api \ No newline at end of file diff --git "a/\345\274\240\346\236\227\347\272\242/2021-06-23(API\345\242\236\345\210\240\346\224\271\346\237\245\345\237\272\347\241\200).md" "b/\345\274\240\346\236\227\347\272\242/2021-06-23(API\345\242\236\345\210\240\346\224\271\346\237\245\345\237\272\347\241\200).md" new file mode 100644 index 0000000000000000000000000000000000000000..e7ef56871deec232c2150988f0228f433e819e73 --- /dev/null +++ "b/\345\274\240\346\236\227\347\272\242/2021-06-23(API\345\242\236\345\210\240\346\224\271\346\237\245\345\237\272\347\241\200).md" @@ -0,0 +1,128 @@ +创建解决方案 dotnet new sln + +创建webapi文件不使用https协议 dotnet new webapi -n Admin3000.Backend.Api --no https + +将在解决方案中放入项目dotnet sln add Admin3000.Backend.Api + +生成项目及其所有依赖项 dotnet build + + +在服务器跑动dotnet run -p Admin3000.Backend.Api + +![Image text](./imgs/6.23/1.png) + + +![Image text](./imgs/6.23/2.png) + + + +![Image text](./imgs/6.23/3.png) + +## 增删改查 + +``` +using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; +using Admin3000.Backend.Api.Entity; +using System.Linq; + +namespace Admin3000.Backend.Controllers +{ + [ApiController] + [Route("[controller]")] + public class UsersController:ControllerBase{ + [HttpGet] + public IEnumerable Get(){ + + var users=GetUsers(); + return users; + + } + + [HttpGet("{id}")] + public dynamic Get(int id){ + var users=GetUsers(); + var user=users.Where(x=>x.Id==id).FirstOrDefault(); + return user; + } + [HttpPost] + public dynamic Post(dynamic model){ + return new{ + Code=1000, + Data=model, + Msg="创建用户成功" + }; + } + + + [HttpPut("{id}")] + public dynamic Put(int id,dynamic model){ + return new { + Code =1000, + Data =model, + Msg =string.Format("修改{0}用户",id) + }; + } + + + [HttpDelete("{id}")] + public dynamic Delete(int id){ + return new{ + Code =1000, + Msg=string.Format("删除{0}用户",id) + }; + } + private IEnumerable GetUsers(){ + var users=new List{ + new Users{ + Id=1, + Username="admin", + Password="123" + }, + new Users{ + Id=2, + Username="AIC", + Password="111" + } + }; + return users; + } + } +} +``` + +![Image text](./imgs/6.23/4.png) +![Image text](./imgs/6.23/4.1.png) + +``` +### +GET http://localhost:5000/users HTTP/1.1 + + +### 获取指定Id的用户 +GET http://localhost:5000/users/1 HTTP/1.1 + +### 创建用户 +POST http://localhost:5000/users HTTP/1.1 +Content-Type: application/json + +{ + "username":"爱吃兔子的草", + "password":"123" +} + +### 修改指定用户 + +PUT http://localhost:5000/users/1 HTTP/1.1 +Content-Type: application/json + +{ + "Username":"AIC", + "Password":"111" +} + +### 删除指定用户 + +DELETE http://localhost:5000/users/2 HTTP/1.1 +``` +![Image text](./imgs/6.23/5.png) \ No newline at end of file diff --git "a/\345\274\240\346\236\227\347\272\242/2021-06-26(API\350\277\236\346\216\245\346\225\260\346\215\256\345\272\223).md" "b/\345\274\240\346\236\227\347\272\242/2021-06-26(API\350\277\236\346\216\245\346\225\260\346\215\256\345\272\223).md" new file mode 100644 index 0000000000000000000000000000000000000000..99195ec07e28181ebc5724e0cada2ed7b1c49e69 --- /dev/null +++ "b/\345\274\240\346\236\227\347\272\242/2021-06-26(API\350\277\236\346\216\245\346\225\260\346\215\256\345\272\223).md" @@ -0,0 +1,33 @@ +安装Entity Framework Core + +``` +安装 + +dotnet add package Microsoft.EntityFrameworkCore.Sqlite(Sqlserver) + +移除 +dotnet remove package Microsoft.EntityFrameworkCore.Sqlite(Sqlserver) +``` + + + +创建模型 +``` +``` + + + +创建数据库(迁移数据库) + +``` +dotnet tool install --global dotnet-ef + +dotnet add package Microsoft.EntityFrameworkCore.Design + +dotnet ef migrations add (简介) + +dotnet ef database update +``` + + +备注services.msc \ No newline at end of file diff --git "a/\345\274\240\346\236\227\347\272\242/2021-06-29(API\345\260\201\350\243\205).md" "b/\345\274\240\346\236\227\347\272\242/2021-06-29(API\345\260\201\350\243\205).md" new file mode 100644 index 0000000000000000000000000000000000000000..73a03c895c1e257ad570c396d088b762f6366af1 --- /dev/null +++ "b/\345\274\240\346\236\227\347\272\242/2021-06-29(API\345\260\201\350\243\205).md" @@ -0,0 +1,75 @@ +API封装 + +重新抽象了实体的共有属性 + +``` +using System; + +namespace Admin3000.Backend.Api.Entity +{ + public abstract class BaseEntity{ + 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 int DisplayOrder{ get; set;} + public string Remarks{ get; set;} + } +} + +``` + +尝试建立主外键表关系 + +UserRoles.cs + +``` +using System; + +namespace Admin3000.Backend.Api.Entity +{ + public class UserRoles : BaseEntity + { + public string UserId{ get; set;} + public string RoleId{ get; set;} + + public virtual Users User{ get; set;} + public virtual Roles Role { get; set;} + } +} + +``` + +Roles.cs +``` +using System; +using System.Collections.Generic; +namespace Admin3000.Backend.Api.Entity +{ + public class Roles : BaseEntity + { + public string RoleName{ get; set;} + public virtual IEnumerable UserRoles { get; set;} + } +} +``` + +Users.cs +``` +using System; +using System.Collections.Generic; + +namespace Admin3000.Backend.Api.Entity +{ + public class Users : BaseEntity + { + public string Username { get; set; } + + public string Password { get; set; } + + //表关系建立 + public virtual IEnumerable UserRoles{ get; set;} + } +} +``` \ No newline at end of file diff --git "a/\345\274\240\346\236\227\347\272\242/2021-06-30(\345\260\201\350\243\205).md" "b/\345\274\240\346\236\227\347\272\242/2021-06-30(\345\260\201\350\243\205).md" new file mode 100644 index 0000000000000000000000000000000000000000..78122b6796181b014cf9bf53c5601040783dc9b3 --- /dev/null +++ "b/\345\274\240\346\236\227\347\272\242/2021-06-30(\345\260\201\350\243\205).md" @@ -0,0 +1 @@ +![Image text](./imgs/06-30_01.png) \ No newline at end of file diff --git "a/\345\274\240\346\236\227\347\272\242/2021-07-02(\345\260\201\350\243\205).md" "b/\345\274\240\346\236\227\347\272\242/2021-07-02(\345\260\201\350\243\205).md" new file mode 100644 index 0000000000000000000000000000000000000000..8008221654b492d5ded01d85c2a7a798b7ca5740 --- /dev/null +++ "b/\345\274\240\346\236\227\347\272\242/2021-07-02(\345\260\201\350\243\205).md" @@ -0,0 +1,22 @@ +# C# 基础 + +## 接口 + +接口的成员: + +属性,方法,事件 + +(注:接口只包含了成员的声明。其定义使用派生类) + +接口的作用: + +接口的用法: + +``` +public +``` + +## 泛型 + +## 属性 + diff --git "a/\345\274\240\346\236\227\347\272\242/2021-07-03(C#\345\237\272\347\241\200).md" "b/\345\274\240\346\236\227\347\272\242/2021-07-03(C#\345\237\272\347\241\200).md" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\345\274\240\346\236\227\347\272\242/imgs/06-30_01.png" "b/\345\274\240\346\236\227\347\272\242/imgs/06-30_01.png" new file mode 100644 index 0000000000000000000000000000000000000000..bd7c258ab166c9c4ac88c296f80814fcaca1ff68 Binary files /dev/null and "b/\345\274\240\346\236\227\347\272\242/imgs/06-30_01.png" differ diff --git "a/\345\274\240\346\236\227\347\272\242/imgs/6.23/1.png" "b/\345\274\240\346\236\227\347\272\242/imgs/6.23/1.png" new file mode 100644 index 0000000000000000000000000000000000000000..ae3a338e3ce874340b1721e05aebb6dc0830905d Binary files /dev/null and "b/\345\274\240\346\236\227\347\272\242/imgs/6.23/1.png" differ diff --git "a/\345\274\240\346\236\227\347\272\242/imgs/6.23/2.png" "b/\345\274\240\346\236\227\347\272\242/imgs/6.23/2.png" new file mode 100644 index 0000000000000000000000000000000000000000..e0c46a9bc4a3fee459b8355f4f629e3d203d8130 Binary files /dev/null and "b/\345\274\240\346\236\227\347\272\242/imgs/6.23/2.png" differ diff --git "a/\345\274\240\346\236\227\347\272\242/imgs/6.23/3.png" "b/\345\274\240\346\236\227\347\272\242/imgs/6.23/3.png" new file mode 100644 index 0000000000000000000000000000000000000000..308b0a23887909831d020f06fddcf1551d0cd720 Binary files /dev/null and "b/\345\274\240\346\236\227\347\272\242/imgs/6.23/3.png" differ diff --git "a/\345\274\240\346\236\227\347\272\242/imgs/6.23/4.1.png" "b/\345\274\240\346\236\227\347\272\242/imgs/6.23/4.1.png" new file mode 100644 index 0000000000000000000000000000000000000000..8e91571ddc01607676adf6c46adcd752e9bf6fb0 Binary files /dev/null and "b/\345\274\240\346\236\227\347\272\242/imgs/6.23/4.1.png" differ diff --git "a/\345\274\240\346\236\227\347\272\242/imgs/6.23/4.png" "b/\345\274\240\346\236\227\347\272\242/imgs/6.23/4.png" new file mode 100644 index 0000000000000000000000000000000000000000..01c23b4819402e9b774a70a8bebbd1551fb815b8 Binary files /dev/null and "b/\345\274\240\346\236\227\347\272\242/imgs/6.23/4.png" differ diff --git "a/\345\274\240\346\236\227\347\272\242/imgs/6.23/5.png" "b/\345\274\240\346\236\227\347\272\242/imgs/6.23/5.png" new file mode 100644 index 0000000000000000000000000000000000000000..355da12154d88f569b849dc9b21bfb6b30f47b81 Binary files /dev/null and "b/\345\274\240\346\236\227\347\272\242/imgs/6.23/5.png" differ