Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb67cc38

Browse files
authored
Merge branch 'liaozb:master' into master
2 parents2e4045c +462977a commitb67cc38

File tree

48 files changed

+3320
-1969
lines changed

Some content is hidden

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

48 files changed

+3320
-1969
lines changed

‎APIJSON.NET/APIJSONCommon/ApiJson.Common.csprojrenamed to‎APIJSON.NET/APIJSON.Data/APIJSON.Data.csproj

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<ProjectSdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.1</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<Version>0.0.11</Version>
66
<Description>
77
0.0.11 升级sqlSugarCore版本 解决如果查找字段是关键字(例如:key)时出错的问题
@@ -20,13 +20,12 @@
2020
</ItemGroup>
2121

2222
<ItemGroup>
23-
<PackageReferenceInclude="AspectCore.Extensions.Reflection"Version="2.2.0" />
24-
<PackageReferenceInclude="Microsoft.Extensions.Options"Version="6.0.0" />
25-
<PackageReferenceInclude="sqlSugarCore"Version="5.0.9.1" />
23+
<PackageReferenceInclude="AspectCore.Extensions.Reflection"Version="2.4.0" />
24+
<PackageReferenceInclude="Microsoft.Extensions.Options"Version="8.0.1" />
25+
<PackageReferenceInclude="sqlSugarCore"Version="5.1.4.140" />
26+
<PackageReferenceInclude="Volo.Abp.Autofac"Version="8.0.2" />
2627
</ItemGroup>
2728

28-
<ItemGroup>
29-
<FolderInclude="Properties\" />
30-
</ItemGroup>
29+
3130

3231
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
usingSystem;
2+
usingSystem.Collections.Generic;
3+
usingSystem.Text;
4+
usingVolo.Abp.Autofac;
5+
usingVolo.Abp.Modularity;
6+
7+
namespaceAPIJSON.Data;
8+
[DependsOn(
9+
typeof(AbpAutofacModule))]
10+
publicclassApiJsonNetDataModule:AbpModule
11+
{
12+
publicoverridevoidConfigureServices(ServiceConfigurationContextcontext)
13+
{
14+
15+
}
16+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
usingAPIJSON.Data.Models;
2+
usingMicrosoft.Extensions.Configuration;
3+
usingSqlSugar;
4+
usingSystem;
5+
usingSystem.Collections.Generic;
6+
usingVolo.Abp.DependencyInjection;
7+
namespaceAPIJSON.Data;
8+
9+
publicclassDbContext:ISingletonDependency
10+
{
11+
publicDbContext(IConfigurationoptions)
12+
{
13+
Db=newSqlSugarClient(newConnectionConfig()
14+
{
15+
ConnectionString=options.GetConnectionString("ConnectionString"),
16+
DbType=(DbType)Enum.Parse(typeof(DbType),options.GetConnectionString("DbType")),InitKeyType=InitKeyType.Attribute,
17+
IsAutoCloseConnection=true
18+
});
19+
Db.Aop.OnLogExecuted=(sql,pars)=>//SQL执行完事件
20+
{
21+
22+
};
23+
Db.Aop.OnLogExecuting=(sql,pars)=>//SQL执行前事件
24+
{
25+
26+
};
27+
}
28+
publicSqlSugarClientDb;
29+
publicDbSet<Login>LoginDb{get{returnnewDbSet<Login>(Db);}}
30+
}
31+
publicclassDbSet<T>:SimpleClient<T>whereT:class,new()
32+
{
33+
publicDbSet(SqlSugarClientcontext):base(context)
34+
{
35+
36+
}
37+
publicList<T>GetByIds(dynamic[]ids)
38+
{
39+
returnContext.Queryable<T>().In(ids).ToList();;
40+
}
41+
}

‎APIJSON.NET/APIJSON.Data/FuncList.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
usingSystem;
2+
usingSystem.Linq;
3+
4+
namespaceAPIJSON.Data;
5+
6+
/// <summary>
7+
/// 自定义方法
8+
/// </summary>
9+
publicclassFuncList
10+
{
11+
/// <summary>
12+
///
13+
/// </summary>
14+
/// <param name="a"></param>
15+
/// <param name="b"></param>
16+
/// <returns></returns>
17+
publicstringMerge(objecta,objectb)
18+
{
19+
returna.ToString()+b.ToString();
20+
}
21+
22+
/// <summary>
23+
///
24+
/// </summary>
25+
/// <param name="a"></param>
26+
/// <param name="b"></param>
27+
/// <returns></returns>
28+
publicobjectMergeObj(objecta,objectb)
29+
{
30+
returnnew{a,b};
31+
}
32+
33+
/// <summary>
34+
///
35+
/// </summary>
36+
/// <param name="a"></param>
37+
/// <param name="b"></param>
38+
/// <returns></returns>
39+
publicboolisContain(objecta,objectb)
40+
{
41+
returna.ToString().Split(',').Contains(b);
42+
}
43+
}
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
usingSystem;
2+
usingSystem.IO;
3+
usingSystem.Security.Cryptography;
4+
usingSystem.Text;
5+
6+
namespaceAPIJSON.Data;
7+
8+
publicclassSimpleStringCipher
9+
{
10+
publicstaticSimpleStringCipherInstance{get;}
11+
12+
/// <summary>
13+
/// This constant string is used as a "salt" value for the PasswordDeriveBytes function calls.
14+
/// This size of the IV (in bytes) must = (keysize / 8). Default keysize is 256, so the IV must be
15+
/// 32 bytes long. Using a 16 character string here gives us 32 bytes when converted to a byte array.
16+
/// </summary>
17+
publicbyte[]InitVectorBytes;
18+
19+
/// <summary>
20+
/// Default password to encrypt/decrypt texts.
21+
/// It's recommented to set to another value for security.
22+
/// Default value: "gsKnGZ041HLL4IM8"
23+
/// </summary>
24+
publicstaticstringDefaultPassPhrase{get;set;}
25+
26+
/// <summary>
27+
/// Default value: Encoding.ASCII.GetBytes("jkE49230Tf093b42")
28+
/// </summary>
29+
publicstaticbyte[]DefaultInitVectorBytes{get;set;}
30+
31+
/// <summary>
32+
/// Default value: Encoding.ASCII.GetBytes("hgt!16kl")
33+
/// </summary>
34+
publicstaticbyte[]DefaultSalt{get;set;}
35+
36+
/// <summary>
37+
/// This constant is used to determine the keysize of the encryption algorithm.
38+
/// </summary>
39+
publicconstintKeysize=256;
40+
41+
staticSimpleStringCipher()
42+
{
43+
DefaultPassPhrase="gsKnGZ041HLL4IM9";
44+
DefaultInitVectorBytes=Encoding.ASCII.GetBytes("jkE49230Tf093b42");
45+
DefaultSalt=Encoding.ASCII.GetBytes("hgt!11kl");
46+
Instance=newSimpleStringCipher();
47+
}
48+
49+
publicSimpleStringCipher()
50+
{
51+
InitVectorBytes=DefaultInitVectorBytes;
52+
}
53+
54+
publicstringEncrypt(stringplainText,stringpassPhrase=null,byte[]salt=null)
55+
{
56+
if(plainText==null)
57+
{
58+
returnnull;
59+
}
60+
61+
if(passPhrase==null)
62+
{
63+
passPhrase=DefaultPassPhrase;
64+
}
65+
66+
if(salt==null)
67+
{
68+
salt=DefaultSalt;
69+
}
70+
71+
varplainTextBytes=Encoding.UTF8.GetBytes(plainText);
72+
using(varpassword=newRfc2898DeriveBytes(passPhrase,salt))
73+
{
74+
varkeyBytes=password.GetBytes(Keysize/8);
75+
using(varsymmetricKey=Aes.Create())
76+
{
77+
symmetricKey.Mode=CipherMode.CBC;
78+
using(varencryptor=symmetricKey.CreateEncryptor(keyBytes,InitVectorBytes))
79+
{
80+
using(varmemoryStream=newMemoryStream())
81+
{
82+
using(varcryptoStream=newCryptoStream(memoryStream,encryptor,CryptoStreamMode.Write))
83+
{
84+
cryptoStream.Write(plainTextBytes,0,plainTextBytes.Length);
85+
cryptoStream.FlushFinalBlock();
86+
varcipherTextBytes=memoryStream.ToArray();
87+
returnConvert.ToBase64String(cipherTextBytes);
88+
}
89+
}
90+
}
91+
}
92+
}
93+
}
94+
95+
publicstringDecrypt(stringcipherText,stringpassPhrase=null,byte[]salt=null)
96+
{
97+
if(string.IsNullOrEmpty(cipherText))
98+
{
99+
returnnull;
100+
}
101+
102+
if(passPhrase==null)
103+
{
104+
passPhrase=DefaultPassPhrase;
105+
}
106+
107+
if(salt==null)
108+
{
109+
salt=DefaultSalt;
110+
}
111+
112+
varcipherTextBytes=Convert.FromBase64String(cipherText);
113+
using(varpassword=newRfc2898DeriveBytes(passPhrase,salt))
114+
{
115+
varkeyBytes=password.GetBytes(Keysize/8);
116+
using(varsymmetricKey=Aes.Create())
117+
{
118+
symmetricKey.Mode=CipherMode.CBC;
119+
using(vardecryptor=symmetricKey.CreateDecryptor(keyBytes,InitVectorBytes))
120+
{
121+
using(varmemoryStream=newMemoryStream(cipherTextBytes))
122+
{
123+
using(varcryptoStream=newCryptoStream(memoryStream,decryptor,CryptoStreamMode.Read))
124+
{
125+
varplainTextBytes=newbyte[cipherTextBytes.Length];
126+
vardecryptedByteCount=cryptoStream.Read(plainTextBytes,0,plainTextBytes.Length);
127+
returnEncoding.UTF8.GetString(plainTextBytes,0,decryptedByteCount);
128+
}
129+
}
130+
}
131+
}
132+
}
133+
}
134+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
namespaceAPIJSON.Data;
2+
3+
usingSystem;
4+
usingSystem.Text.RegularExpressions;
5+
publicstaticclassStringExtensions
6+
{
7+
8+
/// <summary>
9+
/// 是否有值
10+
/// </summary>
11+
/// <param name="str"></param>
12+
/// <returns></returns>
13+
publicstaticboolIsValue(thisobjectstr)
14+
{
15+
returnstr!=null&&!string.IsNullOrEmpty(str.ToString());
16+
}
17+
18+
/// <summary>
19+
///
20+
/// </summary>
21+
/// <param name="param"></param>
22+
/// <returns></returns>
23+
publicstaticstringGetParamName(thisstringparam)
24+
{
25+
returnparam+newRandom().Next(1,100);
26+
}
27+
28+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespaceAPIJSON.Data;
2+
3+
usingglobal::SqlSugar;
4+
publicclassDbOptions
5+
{
6+
/// <summary>
7+
///
8+
/// </summary>
9+
publicDbTypeDbType{get;set;}
10+
11+
/// <summary>
12+
///
13+
/// </summary>
14+
publicstringConnectionString{get;set;}
15+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
usingSqlSugar;
2+
usingSystem;
3+
4+
namespaceAPIJSON.Data.Models;
5+
6+
publicclassLogin
7+
{
8+
[SugarColumn(IsNullable=false,IsPrimaryKey=true)]
9+
publicintuserId{get;set;}
10+
[SugarColumn(Length=100,ColumnDescription="用户名")]
11+
publicstringuserName{get;set;}
12+
[SugarColumn(Length=200,ColumnDescription="密码")]
13+
publicstringpassWord{get;set;}
14+
[SugarColumn(Length=100,ColumnDescription="密码盐")]
15+
publicstringpassWordSalt{get;set;}
16+
[SugarColumn(Length=100,ColumnDescription="权限组")]
17+
publicstringroleCode{get;set;}
18+
19+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespaceAPIJSON.Data.Models;
2+
3+
publicclassRoleItem
4+
{
5+
publicstring[]Table{get;set;}
6+
publicstring[]Column{get;set;}
7+
publicstring[]Filter{get;set;}
8+
}
9+
publicclassRole
10+
{
11+
publicstringName{get;set;}
12+
publicRoleItemSelect{get;set;}
13+
publicRoleItemUpdate{get;set;}
14+
publicRoleItemInsert{get;set;}
15+
publicRoleItemDelete{get;set;}
16+
17+
}
18+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp