Skip to content

Commit cd89bb1

Browse files
committed
[重构]1. 重构代码
1 parent fcbc251 commit cd89bb1

File tree

5 files changed

+115
-80
lines changed

5 files changed

+115
-80
lines changed
Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,40 @@
1-
using GameFrameX.Entity;
1+
// GameFrameX 组织下的以及组织衍生的项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
2+
//
3+
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE 文件。
4+
//
5+
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
6+
7+
using GameFrameX.Entity;
28
using Microsoft.AspNetCore.Mvc;
39

4-
namespace GameFrameX.Client.Api
10+
namespace GameFrameX.Client.Api;
11+
12+
/// <summary>
13+
///
14+
/// </summary>
15+
[Route("api/[controller]/[action]")]
16+
[ApiController]
17+
public class BaseController : Controller
18+
{
19+
}
20+
21+
/// <summary>
22+
///
23+
/// </summary>
24+
/// <typeparam name="T"></typeparam>
25+
public class BaseController<T> : BaseController where T : EntityBase, new()
526
{
627
/// <summary>
728
///
829
/// </summary>
9-
[Route("api/[controller]/[action]")]
10-
[ApiController]
11-
public class BaseController : Controller
12-
{
13-
14-
}
30+
protected readonly BaseService<T> PBaseService;
1531

1632
/// <summary>
1733
///
1834
/// </summary>
19-
/// <typeparam name="T"></typeparam>
20-
public class BaseController<T> : BaseController where T : EntityBase, new()
35+
/// <param name="service"></param>
36+
public BaseController(BaseService<T> service)
2137
{
22-
/// <summary>
23-
///
24-
/// </summary>
25-
protected readonly BaseService<T> PBaseService;
26-
27-
/// <summary>
28-
///
29-
/// </summary>
30-
/// <param name="service"></param>
31-
public BaseController(BaseService<T> service)
32-
{
33-
this.PBaseService = service;
34-
}
38+
this.PBaseService = service;
3539
}
3640
}

GameFrameX.Client.Api/BaseService.cs

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,49 @@
1-
using System.Linq.Expressions;
1+
// GameFrameX 组织下的以及组织衍生的项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
2+
//
3+
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE 文件。
4+
//
5+
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
6+
7+
using System.Linq.Expressions;
28
using GameFrameX.Client.Api.SqlSugar;
39
using GameFrameX.Entity;
410

5-
namespace GameFrameX.Client.Api
11+
namespace GameFrameX.Client.Api;
12+
13+
/// <summary>
14+
///
15+
/// </summary>
16+
public class BaseService
617
{
18+
}
19+
20+
/// <summary>
21+
///
22+
/// </summary>
23+
/// <typeparam name="T"></typeparam>
24+
public class BaseService<T> : BaseService where T : EntityBase, new()
25+
{
26+
/// <summary>
27+
///
28+
/// </summary>
29+
protected readonly Repository<T> Repository;
30+
731
/// <summary>
832
///
933
/// </summary>
10-
public class BaseService
34+
/// <param name="settings"></param>
35+
public BaseService(Repository<T> settings)
1136
{
37+
this.Repository = settings;
1238
}
1339

1440
/// <summary>
1541
///
1642
/// </summary>
17-
/// <typeparam name="T"></typeparam>
18-
public class BaseService<T> : BaseService where T : EntityBase, new()
43+
/// <param name="filter"></param>
44+
/// <returns></returns>
45+
public async Task<T> GetAsync(Expression<Func<T, bool>> filter)
1946
{
20-
/// <summary>
21-
///
22-
/// </summary>
23-
protected readonly Repository<T> Repository;
24-
25-
/// <summary>
26-
///
27-
/// </summary>
28-
/// <param name="settings"></param>
29-
public BaseService(Repository<T> settings)
30-
{
31-
this.Repository = settings;
32-
}
33-
34-
/// <summary>
35-
///
36-
/// </summary>
37-
/// <param name="filter"></param>
38-
/// <returns></returns>
39-
public async Task<T> GetAsync(Expression<Func<T, bool>> filter)
40-
{
41-
return await Repository.AsQueryable().Where(m => m.IsDelete == false).FirstAsync(filter);
42-
}
47+
return await Repository.AsQueryable().Where(m => m.IsDelete == false).FirstAsync(filter);
4348
}
4449
}

GameFrameX.Client.Api/ConstValue.cs

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,43 @@
1-
namespace GameFrameX.Client.Api
1+
// GameFrameX 组织下的以及组织衍生的项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
2+
//
3+
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE 文件。
4+
//
5+
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
6+
7+
namespace GameFrameX.Client.Api;
8+
9+
/// <summary>
10+
///
11+
/// </summary>
12+
public static class ConstValue
213
{
314
/// <summary>
4-
///
15+
/// 主渠道默认值
516
/// </summary>
6-
public static class ConstValue
7-
{
8-
/// <summary>
9-
/// 主渠道默认值
10-
/// </summary>
11-
public const string ChannelNameDefault = "default";
17+
public const string ChannelNameDefault = "default";
1218

13-
/// <summary>
14-
/// 包名默认值
15-
/// </summary>
16-
public const string PackageNameDefault = "default";
19+
/// <summary>
20+
/// 包名默认值
21+
/// </summary>
22+
public const string PackageNameDefault = "default";
1723

18-
/// <summary>
19-
/// 平台默认值
20-
/// </summary>
21-
public const string PlatformDefault = "default";
24+
/// <summary>
25+
/// 平台默认值
26+
/// </summary>
27+
public const string PlatformDefault = "default";
2228

23-
/// <summary>
24-
/// 语言默认值
25-
/// </summary>
26-
public const string LanguageDefault = "default";
29+
/// <summary>
30+
/// 语言默认值
31+
/// </summary>
32+
public const string LanguageDefault = "default";
2733

28-
/// <summary>
29-
/// 子渠道默认值
30-
/// </summary>
31-
public const string SubChannelNameDefault = "default";
34+
/// <summary>
35+
/// 子渠道默认值
36+
/// </summary>
37+
public const string SubChannelNameDefault = "default";
3238

33-
/// <summary>
34-
/// 程序版本默认值
35-
/// </summary>
36-
public const string AppVersionDefault = "default";
37-
}
39+
/// <summary>
40+
/// 程序版本默认值
41+
/// </summary>
42+
public const string AppVersionDefault = "default";
3843
}

GameFrameX.Client.Api/GameFrameX.Client.Api.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
<Link>.dockerignore</Link>
2828
</Content>
2929
</ItemGroup>
30+
31+
<ItemGroup>
32+
<PackageReference Include="GameFrameX.Foundation.Http.Normalization" Version="1.0.3" />
33+
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="7.2.0" />
34+
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="7.2.0" />
35+
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
36+
</ItemGroup>
3037

3138

3239
</Project>

GameFrameX.Client.Api/GlobalUsing.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// GameFrameX 组织下的以及组织衍生的项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
2+
//
3+
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE 文件。
4+
//
5+
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
6+
7+
global using System.ComponentModel.DataAnnotations;
8+
global using SqlSugar;
9+
global using GameFrameX.Application.Client.Api.GameResourceVersion;
10+
global using GameFrameX.Client.Api.Result;
11+
global using GameFrameX.Entity.Client;
12+
global using GameFrameX.Foundation.Http.Normalization;
13+
global using Microsoft.AspNetCore.Mvc;
14+
global using Newtonsoft.Json;

0 commit comments

Comments
 (0)