diff --git a/Service/Application.Domain.Entity/Class1.cs b/Service/Application.Domain.Entity/Class1.cs deleted file mode 100644 index 0921ef7..0000000 --- a/Service/Application.Domain.Entity/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Application.Domain.Entity -{ - public class Class1 - { - - } -} diff --git a/Service/Application.Domain/Cache/BaseCache.cs b/Service/Application.Domain/Cache/BaseCache.cs new file mode 100644 index 0000000..c3e918f --- /dev/null +++ b/Service/Application.Domain/Cache/BaseCache.cs @@ -0,0 +1,7 @@ +namespace Application.Domain; + +public class BaseCache +{ + public static string BaseCacheKey = "BaseGameCache:{0}"; + public static string BaseCacheKeys = "BaseGameCache:{0}:{1}"; +} \ No newline at end of file diff --git a/Service/Application.Domain/Class1.cs b/Service/Application.Domain/Class1.cs deleted file mode 100644 index 11a0161..0000000 --- a/Service/Application.Domain/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Application.Domain -{ - public class Class1 - { - - } -} diff --git a/Service/Application.Domain/GlobalUsings.cs b/Service/Application.Domain/GlobalUsings.cs new file mode 100644 index 0000000..1470963 --- /dev/null +++ b/Service/Application.Domain/GlobalUsings.cs @@ -0,0 +1,4 @@ +global using Photon.Core; +global using SqlSugar; +global using Application.Domain.Entity; +global using Photon.Core.Redis; \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Pub/IAreaService.cs b/Service/Application.Domain/Services/Interface/Pub/IAreaService.cs new file mode 100644 index 0000000..0d55e4b --- /dev/null +++ b/Service/Application.Domain/Services/Interface/Pub/IAreaService.cs @@ -0,0 +1,16 @@ +namespace Application.Domain; + +public interface IAreaService +{ + /// + /// 获取所有区服 + /// + /// + Task> GetAreaData(); + /// + /// 获取区服信息 + /// + /// + /// + Task GetAreaInfo(int areaId); +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Pub/AreaService.cs b/Service/Application.Domain/Services/Service/Pub/AreaService.cs new file mode 100644 index 0000000..ac970f0 --- /dev/null +++ b/Service/Application.Domain/Services/Service/Pub/AreaService.cs @@ -0,0 +1,60 @@ +namespace Application.Domain; + +public class AreaService : IAreaService, ITransient +{ + private readonly ISqlSugarClient _dbClient; + private readonly IRedisCache _redisClient; + + public AreaService(ISqlSugarClient dbClient, IRedisCache redisClient) + { + _dbClient = dbClient; + _redisClient = redisClient; + } + + /// + /// 获取所有区服 + /// + /// + public async Task> GetAreaData() + { + string key = string.Format(BaseCache.BaseCacheKey, "AreaData"); + if (await _redisClient.ExistsAsync(key)) + { + return await _redisClient.GetAsync>(key); + } + else + { + var db = _dbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().ToListAsync(); + await _redisClient.SetAsync(key, data); + return data; + } + } + + public async Task GetAreaInfo(int areaId) + { + string key = string.Format(BaseCache.BaseCacheKeys, "AreaData", areaId); + if (await _redisClient.ExistsAsync(key)) + { + return await _redisClient.GetAsync(key); + } + else + { + var db = _dbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().Where(it => it.areaId == areaId).SingleAsync(); + await _redisClient.SetAsync(key, data); + return data; + } + } + + private async Task ClearAreaCache(int areaId = 0) + { + string key = string.Format(BaseCache.BaseCacheKey, "AreaData"); + await _redisClient.DelAsync(key); + if (areaId != 0) + { + key = string.Format(BaseCache.BaseCacheKeys, "AreaData", areaId); + await _redisClient.DelAsync(key); + } + } +} \ No newline at end of file diff --git a/Service/Application.Web/Application.Web.csproj b/Service/Application.Web/Application.Web.csproj index f94eefc..28bbe2e 100644 --- a/Service/Application.Web/Application.Web.csproj +++ b/Service/Application.Web/Application.Web.csproj @@ -15,4 +15,10 @@ + + + Always + + + diff --git a/Service/Application.Web/Common/StateHelper.cs b/Service/Application.Web/Common/StateHelper.cs index d39a2d1..58a8164 100644 --- a/Service/Application.Web/Common/StateHelper.cs +++ b/Service/Application.Web/Common/StateHelper.cs @@ -2,6 +2,15 @@ { public class StateHelper { + public static bool isOnline + { + get + { + var token = App.HttpContext.GetTokenInfo(); + return token != null; + } + } + public static string userId { get { @@ -14,7 +23,7 @@ get { var token = App.HttpContext.GetTokenInfo(); - return token.Claims["sid"]; + return token.Claims["token"]; } } } diff --git a/Service/Application.Web/Program.cs b/Service/Application.Web/Program.cs index a8ac47a..d74e7e5 100644 --- a/Service/Application.Web/Program.cs +++ b/Service/Application.Web/Program.cs @@ -1,5 +1,6 @@ using Microsoft.OpenApi.Models; +using Photon.Core.Redis; var builder = WebApplication.CreateBuilder(args); @@ -9,7 +10,7 @@ builder.Services.Inject(new List { });//框架初始化 builder.Configuration.RegisterConfig();//注入配置 -builder.Services.InjectMemory(); +builder.Services.InjectRedis(builder.Configuration); builder.Services.InjectSql(builder.Configuration); #region JWT与接口配置 diff --git a/Service/Application.Web/applicationsettings.json b/Service/Application.Web/applicationsettings.json index 4ade55b..87b360a 100644 --- a/Service/Application.Web/applicationsettings.json +++ b/Service/Application.Web/applicationsettings.json @@ -1,19 +1,29 @@ { "AutoProgram": 0, "Redis": { - "connection": "127.0.0.1,password=,defaultdatabase=1" + "connection": "127.0.0.1:6379,password=,defaultdatabase=5" }, "SqlData": [ { "type": 0, - "name": "KgDb", - "connect": "data source=kx.iyba.cn;database=kx.petera;user id=root;password=1f5ozxRGE3Y;pooling=true;port=23306;sslmode=Required;charset=utf8mb4;" + "name": "Kg.SeaTime.Game", + "connect": "data source=192.168.0.88;database=kg.seatime.game;user id=root;password=1f5ozxRGE3Y;pooling=true;port=3306;sslmode=Required;charset=utf8mb4;" + }, + { + "type": 0, + "name": "Kg.SeaTime.Resource", + "connect": "data source=192.168.0.88;database=kg.seatime.resource;user id=root;password=1f5ozxRGE3Y;pooling=true;port=3306;sslmode=Required;charset=utf8mb4;" + }, + { + "type": 0, + "name": "Kg.SeaTime.Log", + "connect": "data source=192.168.0.88;database=kg.seatime.log;user id=root;password=1f5ozxRGE3Y;pooling=true;port=3306;sslmode=Required;charset=utf8mb4;" } ], "JwtTokenOptions": { - "Issuer": "kx.petera", - "Audience": "kx.petera", - "SecurityKey": "DAbdA9fF9MYXDCFBEb75WKWWDAbDBWQi" + "Issuer": "kx.seatime", + "Audience": "kx.seatime", + "SecurityKey": "46055HR0n7FeNHhDKAYD2i9ZsdsYn4jn" }, "ResUrl": { "local": "http://192.168.0.142:5298", diff --git a/Web/src/assets/css/style.css b/Web/src/assets/css/style.css index 260a71a..5de4dc9 100644 --- a/Web/src/assets/css/style.css +++ b/Web/src/assets/css/style.css @@ -75,7 +75,7 @@ div { .foot { } -a { +body a { color: #1e5494; margin: 0 5px; text-decoration: underline; diff --git a/Web/src/composables/ApiService.ts b/Web/src/composables/ApiService.ts index 06468f7..2ec7cb5 100644 --- a/Web/src/composables/ApiService.ts +++ b/Web/src/composables/ApiService.ts @@ -92,7 +92,7 @@ export class ApiService { this.initialized = true; } - public static async Request( + public static async Request( method: HttpMethod, url: string, params: RequestParams = {} diff --git a/Web/src/model/common/ResultData.ts b/Web/src/model/common/ResultData.ts index 46468ce..067ee53 100644 --- a/Web/src/model/common/ResultData.ts +++ b/Web/src/model/common/ResultData.ts @@ -1,5 +1,5 @@ -export interface IResultData { +export interface IResultData { code: number msg: string data?: T diff --git a/Web/src/pages/index.vue b/Web/src/pages/index.vue index f34f768..284c7d9 100644 --- a/Web/src/pages/index.vue +++ b/Web/src/pages/index.vue @@ -87,22 +87,40 @@ 小G报时(18:33) +
+ {{ index }} - {{ item.name }} +