Skip to content

Commit 589c255

Browse files
committed
202208
1 parent 4ef50fa commit 589c255

File tree

575 files changed

+347979
-358764
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

575 files changed

+347979
-358764
lines changed

NetCore/History.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
2-
3-
# History
4-
5-
3.0.0
6-
7-
+ Transport from netframework version 2.8
8-
9-
3.2.2
10-
11-
+ httpapi add group property
12-
+ app.UseHttpApi(options => ....)
13-
+ Add DescritionAttribute to method
14-
15-
3.2.3
16-
17-
+ Parameter mismatch check
18-
19-
3.2.4
20-
21-
+ Friendly exception
1+
2+
3+
# History
4+
5+
3.0.0
6+
7+
+ Transport from netframework version 2.8
8+
9+
3.2.2
10+
11+
+ httpapi add group property
12+
+ app.UseHttpApi(options => ....)
13+
+ Add DescritionAttribute to method
14+
15+
3.2.3
16+
17+
+ Parameter mismatch check
18+
19+
3.2.4
20+
21+
+ Friendly exception
Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,76 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Web;
4-
using System.Data;
5-
using System.Drawing;
6-
using App.HttpApi;
7-
using System.ComponentModel;
8-
//using App.Core;
9-
using Newtonsoft.Json;
10-
using System.Xml.Serialization;
11-
//using System.Web.Script.Serialization;
12-
using System.Collections;
13-
14-
namespace App
15-
{
16-
public partial class Demo
17-
{
18-
19-
//---------------------------------------------
20-
// 自定义类
21-
//---------------------------------------------
22-
[HttpApi("Complex type parameter")]
23-
[HttpParam("father", "Father,如:{Name:'Kevin', Birth:'1979-12-01', Sex:0}")]
24-
public Person CreateGirl(Person father)
25-
{
26-
return new Person()
27-
{
28-
Name = father?.Name + "'s dear daughter",
29-
Birth = System.DateTime.Now,
30-
Sex = Sex.Female,
31-
Father = father
32-
};
33-
}
34-
35-
[HttpApi("null值处理")]
36-
public static Person CreateNull()
37-
{
38-
return null;
39-
}
40-
41-
[HttpApi("返回复杂对象")]
42-
public static Person GetPerson()
43-
{
44-
var father = new Person() { Name = "Father" };
45-
var mother = new Person() { Name = "Mother" };
46-
var son = new Person() { Name = "Son", Father = father, Mather=mother};
47-
var grandson = new Person() { Name = "GrandSon", Father = son };
48-
son.Children.Add(grandson);
49-
father.Children.Add(son);
50-
return father;
51-
}
52-
53-
54-
[HttpApi("返回Xml对象", Type = ResponseType.XML)]
55-
public static Person GetPersonXml()
56-
{
57-
return new Person() { Name = "Cherry" };
58-
}
59-
60-
[HttpApi("返回复杂对象,并用APIResult进行封装", Wrap = true)]
61-
public static Person GetPersonData()
62-
{
63-
return new Person() { Name = "Kevin" };
64-
}
65-
66-
[HttpApi("返回APIResult对象")]
67-
public static APIResult GetPersons()
68-
{
69-
var persons = new List<Person>(){
70-
new Person(){ Name="Kevin", Sex=Sex.Male, Birth=new DateTime(2000, 01, 01)},
71-
new Person(){ Name="Cherry", Sex=Sex.Female, Birth=new DateTime(2010, 01, 01)}
72-
};
73-
return new APIResult(true, "", persons);
74-
}
75-
}
76-
}
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Web;
4+
using System.Data;
5+
using System.Drawing;
6+
using App.HttpApi;
7+
using System.ComponentModel;
8+
//using App.Core;
9+
using Newtonsoft.Json;
10+
using System.Xml.Serialization;
11+
//using System.Web.Script.Serialization;
12+
using System.Collections;
13+
14+
namespace App
15+
{
16+
public partial class Demo
17+
{
18+
19+
//---------------------------------------------
20+
// 自定义类
21+
//---------------------------------------------
22+
[HttpApi("Complex type parameter")]
23+
[HttpParam("father", "Father,如:{Name:'Kevin', Birth:'1979-12-01', Sex:0}")]
24+
public Person CreateGirl(Person father)
25+
{
26+
return new Person()
27+
{
28+
Name = father?.Name + "'s dear daughter",
29+
Birth = System.DateTime.Now,
30+
Sex = Sex.Female,
31+
Father = father
32+
};
33+
}
34+
35+
[HttpApi("null值处理")]
36+
public static Person CreateNull()
37+
{
38+
return null;
39+
}
40+
41+
[HttpApi("返回复杂对象")]
42+
public static Person GetPerson()
43+
{
44+
var father = new Person() { Name = "Father" };
45+
var mother = new Person() { Name = "Mother" };
46+
var son = new Person() { Name = "Son", Father = father, Mather=mother};
47+
var grandson = new Person() { Name = "GrandSon", Father = son };
48+
son.Children.Add(grandson);
49+
father.Children.Add(son);
50+
return father;
51+
}
52+
53+
54+
[HttpApi("返回Xml对象", Type = ResponseType.XML)]
55+
public static Person GetPersonXml()
56+
{
57+
return new Person() { Name = "Cherry" };
58+
}
59+
60+
[HttpApi("返回复杂对象,并用APIResult进行封装", Wrap = true)]
61+
public static Person GetPersonData()
62+
{
63+
return new Person() { Name = "Kevin" };
64+
}
65+
66+
[HttpApi("返回APIResult对象")]
67+
public static APIResult GetPersons()
68+
{
69+
var persons = new List<Person>(){
70+
new Person(){ Name="Kevin", Sex=Sex.Male, Birth=new DateTime(2000, 01, 01)},
71+
new Person(){ Name="Cherry", Sex=Sex.Female, Birth=new DateTime(2010, 01, 01)}
72+
};
73+
return new APIResult(true, "", persons);
74+
}
75+
}
76+
}
Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,84 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Web;
4-
using System.Data;
5-
using System.Drawing;
6-
using App.HttpApi;
7-
using System.ComponentModel;
8-
//using App.Core;
9-
//using Newtonsoft.Json;
10-
//using System.Xml.Serialization;
11-
//using System.Web.Script.Serialization;
12-
using System.Collections;
13-
using App.Web;
14-
15-
namespace App
16-
{
17-
public partial class Demo
18-
{
19-
20-
//---------------------------------------------
21-
// Token 机制
22-
// 1. 获取动态token
23-
// 2. 访问需要健权的接口,带上token参数
24-
// 3. 服务器端统一在 global 里面做token校验
25-
//---------------------------------------------
26-
[HttpApi("获取Token")]
27-
public string GetToken(string appKey, string appSecret)
28-
{
29-
return Token.Create(appKey, appSecret, 1);
30-
}
31-
32-
33-
[HttpApi("NeedTokenApi", AuthToken=true)]
34-
public string GetData()
35-
{
36-
var now = DateTime.Now;
37-
return now.ToString();
38-
}
39-
40-
41-
42-
//---------------------------------------------
43-
// 控制访问权限
44-
//---------------------------------------------
45-
[HttpApi("User login", AuthTraffic=1)]
46-
public string Login(string name, string password)
47-
{
48-
AuthHelper.Login("1", "Admin", "Admins", DateTime.Now.AddDays(1));
49-
System.Threading.Thread.Sleep(200);
50-
return "Login success";
51-
}
52-
53-
[HttpApi("注销")]
54-
public string Logout()
55-
{
56-
AuthHelper.Logout();
57-
System.Threading.Thread.Sleep(200);
58-
return "注销成功";
59-
}
60-
61-
62-
[HttpApi("用户必须登录后才能访问该接口,若无授权则返回401错误", AuthLogin=true)]
63-
public string LimitLogin()
64-
{
65-
System.Threading.Thread.Sleep(200);
66-
return "访问成功(已登录)";
67-
}
68-
69-
[HttpApi("限制用户访问,若无授权则返回401错误", AuthUsers = "Admin,Kevin")]
70-
public string LimitUser()
71-
{
72-
System.Threading.Thread.Sleep(200);
73-
return "访问成功(限制用户Admin,Kevin)";
74-
}
75-
76-
[HttpApi("限制角色访问,若无授权则返回401错误", AuthRoles = "Admins")]
77-
public string LimitRole()
78-
{
79-
System.Threading.Thread.Sleep(200);
80-
return "访问成功(限制角色Admins)";
81-
}
82-
83-
}
84-
}
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Web;
4+
using System.Data;
5+
using System.Drawing;
6+
using App.HttpApi;
7+
using System.ComponentModel;
8+
//using App.Core;
9+
//using Newtonsoft.Json;
10+
//using System.Xml.Serialization;
11+
//using System.Web.Script.Serialization;
12+
using System.Collections;
13+
using App.Web;
14+
15+
namespace App
16+
{
17+
public partial class Demo
18+
{
19+
20+
//---------------------------------------------
21+
// Token 机制
22+
// 1. 获取动态token
23+
// 2. 访问需要健权的接口,带上token参数
24+
// 3. 服务器端统一在 global 里面做token校验
25+
//---------------------------------------------
26+
[HttpApi("获取Token")]
27+
public string GetToken(string appKey, string appSecret)
28+
{
29+
return Token.Create(appKey, appSecret, 1);
30+
}
31+
32+
33+
[HttpApi("NeedTokenApi", AuthToken=true)]
34+
public string GetData()
35+
{
36+
var now = DateTime.Now;
37+
return now.ToString();
38+
}
39+
40+
41+
42+
//---------------------------------------------
43+
// 控制访问权限
44+
//---------------------------------------------
45+
[HttpApi("User login", AuthTraffic=1)]
46+
public string Login(string name, string password)
47+
{
48+
AuthHelper.Login("1", "Admin", "Admins", DateTime.Now.AddDays(1));
49+
System.Threading.Thread.Sleep(200);
50+
return "Login success";
51+
}
52+
53+
[HttpApi("注销")]
54+
public string Logout()
55+
{
56+
AuthHelper.Logout();
57+
System.Threading.Thread.Sleep(200);
58+
return "注销成功";
59+
}
60+
61+
62+
[HttpApi("用户必须登录后才能访问该接口,若无授权则返回401错误", AuthLogin=true)]
63+
public string LimitLogin()
64+
{
65+
System.Threading.Thread.Sleep(200);
66+
return "访问成功(已登录)";
67+
}
68+
69+
[HttpApi("限制用户访问,若无授权则返回401错误", AuthUsers = "Admin,Kevin")]
70+
public string LimitUser()
71+
{
72+
System.Threading.Thread.Sleep(200);
73+
return "访问成功(限制用户Admin,Kevin)";
74+
}
75+
76+
[HttpApi("限制角色访问,若无授权则返回401错误", AuthRoles = "Admins")]
77+
public string LimitRole()
78+
{
79+
System.Threading.Thread.Sleep(200);
80+
return "访问成功(限制角色Admins)";
81+
}
82+
83+
}
84+
}

0 commit comments

Comments
 (0)