diff --git a/Service/Application.Domain/Services/Service/Pub/NoticeService.cs b/Service/Application.Domain/Services/Service/Pub/NoticeService.cs index b4cabef..e1d69cd 100644 --- a/Service/Application.Domain/Services/Service/Pub/NoticeService.cs +++ b/Service/Application.Domain/Services/Service/Pub/NoticeService.cs @@ -20,6 +20,6 @@ public class NoticeService:INoticeService,ITransient public async Task> GetNoticeData(int page, int limit, RefAsync total) { var db = _dbClient.AsTenant().GetConnectionWithAttr(); - return await db.Queryable().ToPageListAsync(page, limit, total); + return await db.Queryable().OrderByDescending(it=>it.addTime).ToPageListAsync(page, limit, total); } } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/User/GameAccountService.cs b/Service/Application.Domain/Services/Service/User/GameAccountService.cs index 7048487..f36abcd 100644 --- a/Service/Application.Domain/Services/Service/User/GameAccountService.cs +++ b/Service/Application.Domain/Services/Service/User/GameAccountService.cs @@ -25,7 +25,11 @@ public class GameAccountService : IGameAccountService, ITransient { var db = _dbClient.AsTenant().GetConnectionWithAttr(); var data = await db.Queryable().Where(it => it.openId == openId).FirstAsync(); - await _redisClient.AddHashAsync(key, openId, data); + if (data != null) + { + await _redisClient.AddHashAsync(key, openId, data); + } + return data; } } @@ -41,11 +45,15 @@ public class GameAccountService : IGameAccountService, ITransient { var db = _dbClient.AsTenant().GetConnectionWithAttr(); var data = await db.Queryable().Where(it => it.accId == accId).FirstAsync(); - await _redisClient.AddHashAsync(key, accId, data); + if (data != null) + { + await _redisClient.AddHashAsync(key, accId, data); + } + return data; } } - + public async Task GetAccInfoByToken(string token) { var db = _dbClient.AsTenant().GetConnectionWithAttr(); @@ -86,7 +94,7 @@ public class GameAccountService : IGameAccountService, ITransient } } - public async Task Regist(string userName, string nick, string pwd, string remAccId = "", + public async Task Regist(string userName, string nick, string pwd, string remAccId = "", string openId = "") { game_account result = new game_account(); @@ -116,12 +124,13 @@ public class GameAccountService : IGameAccountService, ITransient { result = null; } + await _dbClient.AsTenant().CommitTranAsync(); } catch { result = null; - await _dbClient.AsTenant().RollbackTranAsync(); + await _dbClient.AsTenant().RollbackTranAsync(); } return result; diff --git a/Service/Application.Web/Controllers/Pub/PubController.cs b/Service/Application.Web/Controllers/Pub/PubController.cs index 3789432..98533c0 100644 --- a/Service/Application.Web/Controllers/Pub/PubController.cs +++ b/Service/Application.Web/Controllers/Pub/PubController.cs @@ -12,11 +12,13 @@ namespace Application.Web.Controllers.Pub { private readonly IAreaService _areaService; private readonly INoticeService _noticeService; + private readonly IGameAccountService _accountService; - public PubController(IAreaService areaService, INoticeService noticeService) + public PubController(IAreaService areaService, INoticeService noticeService,IGameAccountService accountService) { _areaService = areaService; _noticeService = noticeService; + _accountService = accountService; } /// @@ -28,16 +30,35 @@ namespace Application.Web.Controllers.Pub public async Task GetMain(string? sid) { bool isOnline = false; + game_account account = new game_account(); if (!string.IsNullOrEmpty(sid)) { - isOnline = true; + account = await _accountService.GetAccInfoByToken(sid); + if (account != null) + { + isOnline = true; + } } - + var areaData = await _areaService.GetAreaData(); var notice = await _noticeService.GetNoticeDataByTake(5); int OnCount = 100; - return PoAction.Ok(new { area = areaData, notice, isOnline, onCount = OnCount }); + return PoAction.Ok(new { area = areaData, notice, isOnline, onCount = OnCount,account }); + } + + /// + /// 获取公告列表 + /// + /// + /// + /// + [HttpGet] + public async Task GetNoticeData(int page,int limit) + { + RefAsync total = 0; + var data = await _noticeService.GetNoticeData(page, limit, total); + return PoAction.Ok(new { data, total=total.Value }); } } } \ No newline at end of file diff --git a/Service/Application.Web/GlobalUsings.cs b/Service/Application.Web/GlobalUsings.cs index dc70310..7482651 100644 --- a/Service/Application.Web/GlobalUsings.cs +++ b/Service/Application.Web/GlobalUsings.cs @@ -4,6 +4,7 @@ global using Photon.Core.Services; global using Photon.Core.SqlSugar; global using Photon.Core.Assist; global using Photon.Core.Timer; +global using SqlSugar; global using Application.Service.Pub; global using Application.Domain; diff --git a/Web/src/components/Pagination.vue b/Web/src/components/Pagination.vue index 133b617..8d9d232 100644 --- a/Web/src/components/Pagination.vue +++ b/Web/src/components/Pagination.vue @@ -2,10 +2,10 @@
- =====☆官方公告☆===== + =====☆官方公告☆=====
- {{ index + 1 }}.{{ item.title }} + {{ index + 1 }}.{{ item.title }}
暂无公告.
@@ -63,9 +62,9 @@ =====☆服务导航☆=====
- 客服 - .关于.合作 + 客服. + 关于. + 合作
@@ -85,15 +84,19 @@ const areaData = ref>([]); const noticeData = ref>([]); const isOnline = ref(false); const OnCount = ref(0); +const AccountInfo = ref(); const Initialize = async (): Promise => { - var result = await PubService.GetMain(StateHelper.Sid); + var result = await PubService.GetMain(StateHelper.Sid); if (result.code == 0) { + isOnline.value = result.data.isOnline; + if (isOnline.value == false) { + StateHelper.OffOnline(); + } areaData.value = result.data?.area; noticeData.value = result.data.notice; - isOnline.value = result.data.isOnline; OnCount.value = result.data.onCount; - + AccountInfo.value = result.data.account; } else { MessageExtend.ShowToast(result.msg, "fail"); diff --git a/Web/src/pages/login/register.vue b/Web/src/pages/login/register.vue new file mode 100644 index 0000000..41a40c8 --- /dev/null +++ b/Web/src/pages/login/register.vue @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Web/src/pages/news/index.vue b/Web/src/pages/news/index.vue new file mode 100644 index 0000000..993b6c5 --- /dev/null +++ b/Web/src/pages/news/index.vue @@ -0,0 +1,59 @@ + + + + \ No newline at end of file diff --git a/Web/src/pages/news/info.vue b/Web/src/pages/news/info.vue new file mode 100644 index 0000000..41a40c8 --- /dev/null +++ b/Web/src/pages/news/info.vue @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Web/src/services/Index/PubService.ts b/Web/src/services/Index/PubService.ts index d901512..fb93b79 100644 --- a/Web/src/services/Index/PubService.ts +++ b/Web/src/services/Index/PubService.ts @@ -6,4 +6,12 @@ export class PubService { static async GetMain(sid: string) { return await ApiService.Request("get", "/Pub/GetMain", { sid }); } + + /** + * GetNoticeData + * GET /Pub/GetNoticeData + */ + static async GetNoticeData(page: number, limit: number) { + return await ApiService.Request("get", "/Pub/GetNoticeData", { page, limit }); + } } \ No newline at end of file