From 2e7b34cd8250497183110ef2dbd67889f6f17da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B6=9B?= <1420925946@qq.com> Date: Wed, 24 May 2023 03:31:46 +0000 Subject: [PATCH 01/12] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20=E5=88=98=E6=B6=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\345\210\230\346\266\233/.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "\345\210\230\346\266\233/.keep" diff --git "a/\345\210\230\346\266\233/.keep" "b/\345\210\230\346\266\233/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From 4e4f0094e505022aad7144c6c2ba1608016482af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B6=9B?= <1420925946@qq.com> Date: Sun, 28 May 2023 15:01:01 +0000 Subject: [PATCH 02/12] =?UTF-8?q?add=20=E5=88=98=E6=B6=9B/20230522-?= =?UTF-8?q?=E9=9B=86=E5=90=88&linq.md.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘涛 <1420925946@qq.com> --- ...20230522-\351\233\206\345\220\210&linq.md" | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 "\345\210\230\346\266\233/20230522-\351\233\206\345\220\210&linq.md" diff --git "a/\345\210\230\346\266\233/20230522-\351\233\206\345\220\210&linq.md" "b/\345\210\230\346\266\233/20230522-\351\233\206\345\220\210&linq.md" new file mode 100644 index 0000000..fed790d --- /dev/null +++ "b/\345\210\230\346\266\233/20230522-\351\233\206\345\220\210&linq.md" @@ -0,0 +1,54 @@ +## oo的第一天笔记 +1. 集合/linq + webAPI +2. uniapp + docker 微服务 +3. JS语言(弱类型语言 vue node,js):var a = 5 a="5" const arr=[1,2,3] 增删改查 +4. dot NET(C#,强类型,Java,C++):var a =5; a一直整形,只能通过强转 +5. 数组(较原始的集合):int[]arr = new int[5] 改,查 +6. 集合collection(装的都是同类型的元素):增删改查 +7. dotnet new console -o oo + +#### linq:语言集成查询; +```cs +List oo = new List{1,2,3,4,5,6,7,8,9,0}; +List result = new List(); //oo.count +for (int i =0;i 3 && oo[i] % 2 == 0){ + result.Ass(oo[i]); + } +} +result.Sort(); +for(int i =0;i 3 && oo[i] % 2 == 0] order by (条件); + +1. 查询表达式,特点:以select ,groupby结尾, +```cs +var res = from n in lst + where n > 3 && n % 2 == 0 + order by n + select n; +``` +2. 链式表达式 MVC +```cs +var res1 = lst.Where(n=> n>3 && n%2 ==0).OrderBy(n => n).Select(n=>n); + +var rnd = new Random(1000); +var arr = Enumerable.Range(0,100).Select(_ => rnd.Next(0,10)); +``` +//linq特性:延迟性(derfer),消耗性(exhaust) +//常用的方法:Where()/Select()/OrderBy()/GroupBy()/Single()/First() + +## 作业 +```cs +var rnd = new Random(1000); +var arr1 = Enumerable.Range(0,100).Select(_ => rnd.Next(0,10)); +var arr2 = arr1.GroupBy(n=>n).Select(n=>new{number=n.Key,frequency=n.Count()}).OrderBy(arr2=>arr2.number);; +foreach (var item in arr2) +{ + Console.Write(item); +} +``` \ No newline at end of file -- Gitee From 483d1e2a0f891b081dc2b8c243044a453706e37c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B6=9B?= <1420925946@qq.com> Date: Sun, 28 May 2023 15:01:24 +0000 Subject: [PATCH 03/12] =?UTF-8?q?add=20=E5=88=98=E6=B6=9B/20230523-LINQ.md?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘涛 <1420925946@qq.com> --- "\345\210\230\346\266\233/20230523-LINQ.md" | 119 ++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 "\345\210\230\346\266\233/20230523-LINQ.md" diff --git "a/\345\210\230\346\266\233/20230523-LINQ.md" "b/\345\210\230\346\266\233/20230523-LINQ.md" new file mode 100644 index 0000000..266f7be --- /dev/null +++ "b/\345\210\230\346\266\233/20230523-LINQ.md" @@ -0,0 +1,119 @@ +## 提交分支 +1. git branch //查询已存在的分支 +2. git branch oo //创建新分支 +3. git chekout oo //转换分支为oo +4. git add. +5. git commit -m "oo" +6. git config --global user.email "you@example.com" +7. git config --global user.name "Your Name" +8. git push +9. git push --set-upstream origin oo + +### this是扩展的意思 +```c# +//扩展方法->linq +var numD = arr.GroupBy(n=>n).ToDictionary(group=>group.Key,value=>value.Count()); +//查询表达式->linq +var res = from n in arr + group by into g + //既要键,又要次数 类:Student学生类(gender) (oo) new Student(){gender=..} + select new {g.Key,Count=g.Count()}; +``` +### 2维->转成1维 + ```c# + var mulArr = new int [][]{ + new int[]{1,2,3}, + new int[]{2,3,4}, + new int[]{5,6,7} + }; + var res2 = from arr1 in mulArr + from num in arr1 + select num; + ``` + ### Skip跳过n个Take取值n个 + ```c# + //Single,SingleDefault,First,Take,Skip + var numList = new List{1,2,3,4,5,6,7,8,9,0}; + var res = numList.Skip(3),Take(3); + ``` + + ### 连表 +```c# +var clsList = new List(){ + new Classes(){ClassId=1,ClassName="1班"}, + new Classes(){ClassId=2,ClassName="2班"} +}; +/* + select * from stuList s join clsList c on s.ClassId = c.ClassId(where) +*/ +var res = from stu in stuList + join cls in clsList on stu.ClassId equals cls.ClassId + select new { + stu.StuName, + cls.ClassName + }; + +foreach (var item in res) +{ + Console.WriteLine($"{iten.StuName},{item.ClassName}"); +}//完成 +``` + +### 克隆后打开克隆界面输入:git checkout oo + +### 课后习题 +```c# +var str = new string[]{"rust","csharp","python","java","c","golang"}; +//统计每个字符出现的次数,并且按照出现次数频率从高到低排序 +// var res3 = from n in str +// from c in n +// group c by c into g +// orderby g.Count() descending +// select new {g.Key,Count = g.Count()}; + +//使用扩展方法(链式)实现 +var re4 = str.SelectMany(c=>c).GroupBy(nn=>nn).Select(nn=>new {number = nn.Key,frequency= nn.Count()}).OrderBy(str=>str.number); +foreach (var item in re4) +{ + Console.WriteLine(item); +} +string pic1 = "4b069d702e7fec0dc06cf5815ece8503.jpeg"; +string pic2 = "4b069d702e7fec0dc06cf5815esn7005.jpeg"; +string pic3 = "4b069d702e7fec0dc06cf5815ets6730.jpeg"; +//使用AsParallel模拟同步下载三张图片 +//结果: +/* + pic1 下载完成 + pic3 下载完成 + pic2 下载完成 +*/ +List lis2 = new List(){pic1,pic2,pic3}; +var res5 = lis2.AsParallel().AsOrdered().Select(n=>{ + Thread.Sleep(2000); + return "pic1 下载完成 pic2下载完成 pic3下载完成"; +}); +foreach (var item in res5) +{ + Console.WriteLine(item); + return; +} +for (int i = 0; i < 5; i++) +{ + for (int j = 0; i < 4; i++) + { + for (int k = 0; i < 3; i++) + { + Console.WriteLine($"{i},{j},{k}"); + } + } +} +//使用linq打印所有排列组合 +var re9 = from ii in Enumerable.Range(0,5) + from jj in Enumerable.Range(0,4) + from kk in Enumerable.Range(0,3) + select(ii,jj,kk); +foreach (var item in re9) +{ + Console.WriteLine($"{item.ii},{item.jj},{item.kk}"); +} +``` \ No newline at end of file -- Gitee From 34c6259545e76314bfc4dfd24fc63a254098f6a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B6=9B?= <1420925946@qq.com> Date: Sun, 28 May 2023 15:01:47 +0000 Subject: [PATCH 04/12] =?UTF-8?q?add=20=E5=88=98=E6=B6=9B/20230524-=2001?= =?UTF-8?q?=E5=88=9D=E8=AF=86WebAPI.md.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘涛 <1420925946@qq.com> --- ...0524- 01\345\210\235\350\257\206WebAPI.md" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "\345\210\230\346\266\233/20230524- 01\345\210\235\350\257\206WebAPI.md" diff --git "a/\345\210\230\346\266\233/20230524- 01\345\210\235\350\257\206WebAPI.md" "b/\345\210\230\346\266\233/20230524- 01\345\210\235\350\257\206WebAPI.md" new file mode 100644 index 0000000..bd4dd31 --- /dev/null +++ "b/\345\210\230\346\266\233/20230524- 01\345\210\235\350\257\206WebAPI.md" @@ -0,0 +1,29 @@ +### 放入Program.cs +```c# +//依赖关系注入 +builder.Services.AddCors(c=>c.AddPolicy("any",p=>p.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin())); + +//注册 +app.UseCors("any"); +``` +### 创建 +```c# +dotnet new webapi -o oo +//右键Controllers->New C#创建一个Api Controller项目 +//模板样式 +namespace bb.Controllers +{ + [ApiController] + [Route("api/[controller]")] + public class NewApiController : ControllerBase + { + [HttpGet] + public string Get(){ + return "来咯"; + } + } +} +``` +### .net core与.net framework的区别 +1. .net core跨平台 +2. .net framework只能在Windows中 \ No newline at end of file -- Gitee From eeff95dead147422572ac6202340b3221a3373bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B6=9B?= <1420925946@qq.com> Date: Sun, 28 May 2023 15:02:07 +0000 Subject: [PATCH 05/12] =?UTF-8?q?add=20=E5=88=98=E6=B6=9B/20230525-promise?= =?UTF-8?q?&axios.md.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘涛 <1420925946@qq.com> --- .../20230525-promise&axios.md " | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 "\345\210\230\346\266\233/20230525-promise&axios.md " diff --git "a/\345\210\230\346\266\233/20230525-promise&axios.md " "b/\345\210\230\346\266\233/20230525-promise&axios.md " new file mode 100644 index 0000000..33a59f6 --- /dev/null +++ "b/\345\210\230\346\266\233/20230525-promise&axios.md " @@ -0,0 +1,117 @@ +## promise +### 描述 +一个 Promise 对象代表一个在这个 promise 被创建出来时不一定已知值的代理。它让你能够把异步操作最终的成功返回值或者失败原因和相应的处理程序关联起来。这样使得异步方法可以像同步方法那样返回值:异步方法并不会立即返回最终的值,而是会返回一个 promise,以便在未来某个时候把值交给使用者。 + +一个 Promise 必然处于以下几种状态之一: + +* 待定(pending):初始状态,既没有被兑现,也没有被拒绝。 +* 已兑现(fulfilled):意味着操作成功完成。 +* 已拒绝(rejected):意味着操作失败。 + +### Promise then&&catch + +待定状态的 Promise 对象要么会通过一个值被兑现,要么会通过一个原因(错误)被拒绝。当这些情况之一发生时,我们用 promise 的 then 方法排列起来的相关处理程序就会被调用。如果 promise 在一个相应的处理程序被绑定时就已经被兑现或被拒绝了,那么这个处理程序也同样会被调用,因此在完成异步操作和绑定处理方法之间不存在竞态条件。 + +因为 Promise.prototype.then 和 Promise.prototype.catch 方法返回的是 promise,所以它们可以被链式调用。 + + +### Promise reject&resolve 对象 +* Promise.resolve(value) 方法返回一个以给定值解析后的 Promise 对象。 +```js +const promise1 = Promise.resolve(123); + +promise1.then((value) => { + console.log(value); + // Expected output: 123 +}); +``` + +* Promise.reject() 方法返回一个带有拒绝原因的 Promise 对象。 +```js +Promise.reject(new Error('fail')) +``` + +## axios +使用 npm: +```js +$ npm install axios +``` + +使用 yarn: +```js +$ yarn add axios +``` + +使用 jsDelivr CDN: +```js +