From 0e5cab4f2756bd5b8e1647328e2b4c499f4d6aba Mon Sep 17 00:00:00 2001 From: "CORE-FOLDCC\\Core" <1813547935@qq.com> Date: Tue, 21 Apr 2026 16:02:06 +0800 Subject: [PATCH] Update Unity SDK for daily space like API --- .../BriskSdk/Runtime/Core/BriskModelMapper.cs | 10 ++++- .../Runtime/Models/BriskSpaceLikeResult.cs | 4 ++ .../Runtime/Models/BriskSpaceStats.cs | 2 + .../BriskSdk/Runtime/Models/BriskSpaceView.cs | 2 + .../Runtime/Space/BriskSpaceModule.cs | 25 ++++++++--- .../QuickStart/BriskQuickStartSample.cs | 42 ++++++++++++++----- .../Documentation~/QuickStart.md | 9 ++++ .../README.md | 2 + .../Runtime/Core/BriskModelMapper.cs | 10 ++++- .../Runtime/Models/BriskSpaceLikeResult.cs | 4 ++ .../Runtime/Models/BriskSpaceStats.cs | 2 + .../Runtime/Models/BriskSpaceView.cs | 2 + .../Runtime/Space/BriskSpaceModule.cs | 25 ++++++++--- .../QuickStart/BriskQuickStartSample.cs | 42 ++++++++++++++----- .../QuickStart/BriskQuickStartScene.unity | 4 +- README.md | 3 ++ 16 files changed, 154 insertions(+), 34 deletions(-) diff --git a/Assets/BriskSdk/Runtime/Core/BriskModelMapper.cs b/Assets/BriskSdk/Runtime/Core/BriskModelMapper.cs index 20917da..8a30bb8 100644 --- a/Assets/BriskSdk/Runtime/Core/BriskModelMapper.cs +++ b/Assets/BriskSdk/Runtime/Core/BriskModelMapper.cs @@ -249,8 +249,10 @@ internal static class BriskModelMapper ContentSizeBytes = BriskValueReader.GetLong(data, "content_size_bytes"), ContentChecksum = BriskValueReader.GetString(data, "content_checksum"), LikeCount = BriskValueReader.GetLong(data, "like_count"), + TodayLikeCount = BriskValueReader.GetLong(data, "today_like_count"), VisitCount = BriskValueReader.GetLong(data, "visit_count"), LikedByMe = BriskValueReader.GetBool(data, "liked_by_me"), + LikeResetAt = BriskValueReader.GetString(data, "like_reset_at"), UpdatedAt = BriskValueReader.GetString(data, "updated_at") }; } @@ -276,7 +278,9 @@ internal static class BriskModelMapper ContentSizeBytes = BriskValueReader.GetLong(data, "content_size_bytes"), ContentChecksum = BriskValueReader.GetString(data, "content_checksum"), LikeCount = BriskValueReader.GetLong(data, "like_count"), + TodayLikeCount = BriskValueReader.GetLong(data, "today_like_count"), VisitCount = BriskValueReader.GetLong(data, "visit_count"), + LikeResetAt = BriskValueReader.GetString(data, "like_reset_at"), UpdatedAt = BriskValueReader.GetString(data, "updated_at") }; } @@ -309,7 +313,11 @@ internal static class BriskModelMapper return new BriskSpaceLikeResult { Liked = BriskValueReader.GetBool(data, "liked"), - LikeCount = BriskValueReader.GetLong(data, "like_count") + Created = BriskValueReader.GetBool(data, "created"), + LikedByMe = BriskValueReader.GetBool(data, "liked_by_me"), + LikeCount = BriskValueReader.GetLong(data, "like_count"), + TodayLikeCount = BriskValueReader.GetLong(data, "today_like_count"), + LikeResetAt = BriskValueReader.GetString(data, "like_reset_at") }; } diff --git a/Assets/BriskSdk/Runtime/Models/BriskSpaceLikeResult.cs b/Assets/BriskSdk/Runtime/Models/BriskSpaceLikeResult.cs index 3637490..b9812e3 100644 --- a/Assets/BriskSdk/Runtime/Models/BriskSpaceLikeResult.cs +++ b/Assets/BriskSdk/Runtime/Models/BriskSpaceLikeResult.cs @@ -1,5 +1,9 @@ public sealed class BriskSpaceLikeResult { public bool Liked; + public bool Created; + public bool LikedByMe; public long LikeCount; + public long TodayLikeCount; + public string LikeResetAt; } diff --git a/Assets/BriskSdk/Runtime/Models/BriskSpaceStats.cs b/Assets/BriskSdk/Runtime/Models/BriskSpaceStats.cs index 48fb95b..0f6bbaf 100644 --- a/Assets/BriskSdk/Runtime/Models/BriskSpaceStats.cs +++ b/Assets/BriskSdk/Runtime/Models/BriskSpaceStats.cs @@ -12,6 +12,8 @@ public sealed class BriskSpaceStats public long ContentSizeBytes; public string ContentChecksum; public long LikeCount; + public long TodayLikeCount; public long VisitCount; + public string LikeResetAt; public string UpdatedAt; } diff --git a/Assets/BriskSdk/Runtime/Models/BriskSpaceView.cs b/Assets/BriskSdk/Runtime/Models/BriskSpaceView.cs index d6338e8..63726e3 100644 --- a/Assets/BriskSdk/Runtime/Models/BriskSpaceView.cs +++ b/Assets/BriskSdk/Runtime/Models/BriskSpaceView.cs @@ -12,7 +12,9 @@ public sealed class BriskSpaceView public long ContentSizeBytes; public string ContentChecksum; public long LikeCount; + public long TodayLikeCount; public long VisitCount; public bool LikedByMe; + public string LikeResetAt; public string UpdatedAt; } diff --git a/Assets/BriskSdk/Runtime/Space/BriskSpaceModule.cs b/Assets/BriskSdk/Runtime/Space/BriskSpaceModule.cs index 8ef72e4..ec97fe6 100644 --- a/Assets/BriskSdk/Runtime/Space/BriskSpaceModule.cs +++ b/Assets/BriskSdk/Runtime/Space/BriskSpaceModule.cs @@ -68,23 +68,23 @@ public sealed class BriskSpaceModule } /// - /// 按玩家 ID 获取最近点赞列表。 + /// 按玩家 ID 获取点赞列表。 /// - public async Task> GetLikesByPlayerIdAsync(string playerId, int limit = 20) + public async Task> GetLikesByPlayerIdAsync(string playerId, int limit = 20, bool currentCycleOnly = false) { ValidatePlayerId(playerId); return await ExecuteAsync(async context => { - var data = await context.HttpClient.GetRawDataAsync($"/spaces/{playerId}/likes", CreateLimitQuery(limit), true); + var data = await context.HttpClient.GetRawDataAsync($"/spaces/{playerId}/likes", CreateLikesQuery(limit, currentCycleOnly), true); return (IReadOnlyList)BriskModelMapper.ToSpaceLikeItems(data); }); } /// - /// 按登录身份获取最近点赞列表。 + /// 按登录身份获取点赞列表。 /// - public async Task> GetLikesByLoginIdentityAsync(string loginProvider, string loginUserId, int limit = 20) + public async Task> GetLikesByLoginIdentityAsync(string loginProvider, string loginUserId, int limit = 20, bool currentCycleOnly = false) { ValidateLoginIdentity(loginProvider, loginUserId); @@ -92,6 +92,10 @@ public sealed class BriskSpaceModule { var query = CreateLoginIdentityQuery(loginProvider, loginUserId); query["limit"] = NormalizeLimit(limit); + if (currentCycleOnly) + { + query["scope"] = "cycle"; + } var data = await context.HttpClient.GetRawDataAsync("/spaces/by-login/likes", query, true); return (IReadOnlyList)BriskModelMapper.ToSpaceLikeItems(data); }); @@ -262,6 +266,17 @@ public sealed class BriskSpaceModule }; } + private static Dictionary CreateLikesQuery(int limit, bool currentCycleOnly) + { + var query = CreateLimitQuery(limit); + if (currentCycleOnly) + { + query["scope"] = "cycle"; + } + + return query; + } + private static void ValidatePlayerId(string playerId) { RequireNotEmpty(playerId, nameof(playerId)); diff --git a/Assets/BriskSdk/Samples/QuickStart/BriskQuickStartSample.cs b/Assets/BriskSdk/Samples/QuickStart/BriskQuickStartSample.cs index efc9d75..8581813 100644 --- a/Assets/BriskSdk/Samples/QuickStart/BriskQuickStartSample.cs +++ b/Assets/BriskSdk/Samples/QuickStart/BriskQuickStartSample.cs @@ -475,14 +475,16 @@ public sealed class BriskQuickStartSample : MonoBehaviour DrawValueRow("内容版本", _mySpaceView == null ? "-" : _mySpaceView.ContentVersion.ToString()); DrawValueRow("内容类型", _mySpaceView == null ? "-" : NullToDash(_mySpaceView.ContentType)); DrawValueRow("内容大小", _mySpaceView == null ? "-" : _mySpaceView.ContentSizeBytes + " bytes"); - DrawValueRow("点赞数", _mySpaceStats == null ? "-" : _mySpaceStats.LikeCount.ToString()); + DrawValueRow("累计点赞数", _mySpaceStats == null ? "-" : _mySpaceStats.LikeCount.ToString()); + DrawValueRow("今日点赞数", _mySpaceStats == null ? "-" : _mySpaceStats.TodayLikeCount.ToString()); DrawValueRow("访问数", _mySpaceStats == null ? "-" : _mySpaceStats.VisitCount.ToString()); + DrawValueRow("今日点赞重置", _mySpaceStats == null ? "-" : FormatLikeResetAt(_mySpaceStats.LikeResetAt)); DrawValueRow("更新时间", _mySpaceView == null ? "-" : NullToDash(_mySpaceView.UpdatedAt)); GUILayout.Space(8f); - GUILayout.Label("最近给我点赞的用户", _sectionTitleStyle); + GUILayout.Label("今天给我点赞的用户", _sectionTitleStyle); if (_mySpaceLikes.Count == 0) { - GUILayout.Label("暂无点赞记录。", _bodyStyle); + GUILayout.Label("当前周期暂无点赞记录。", _bodyStyle); } else { @@ -509,9 +511,11 @@ public sealed class BriskQuickStartSample : MonoBehaviour DrawValueRow("PlayerId", _targetSpaceView == null ? "-" : NullToDash(_targetSpaceView.PlayerId)); DrawValueRow("内容类型", _targetSpaceView == null ? "-" : NullToDash(_targetSpaceView.ContentType)); DrawValueRow("内容大小", _targetSpaceView == null ? "-" : _targetSpaceView.ContentSizeBytes + " bytes"); - DrawValueRow("点赞数", _targetSpaceStats == null ? "-" : _targetSpaceStats.LikeCount.ToString()); + DrawValueRow("累计点赞数", _targetSpaceStats == null ? "-" : _targetSpaceStats.LikeCount.ToString()); + DrawValueRow("今日点赞数", _targetSpaceStats == null ? "-" : _targetSpaceStats.TodayLikeCount.ToString()); DrawValueRow("访问数", _targetSpaceStats == null ? "-" : _targetSpaceStats.VisitCount.ToString()); - DrawValueRow("我的点赞状态", _targetSpaceView != null && _targetSpaceView.LikedByMe ? "已点赞" : "未点赞"); + DrawValueRow("今日点赞状态", _targetSpaceView != null && _targetSpaceView.LikedByMe ? "今日已点赞" : "今日未点赞"); + DrawValueRow("今日点赞重置", _targetSpaceView == null ? "-" : FormatLikeResetAt(_targetSpaceView.LikeResetAt)); GUILayout.Space(8f); GUILayout.Label("空间内容", _sectionTitleStyle); GUILayout.TextArea(_targetSpaceContentText ?? string.Empty, _textAreaStyle, GUILayout.Height(240f)); @@ -520,8 +524,8 @@ public sealed class BriskQuickStartSample : MonoBehaviour DrawCard("操作", () => { DrawInlineButtons( - new ButtonSpec("点赞", LikeTargetSpaceAsync, false, true), - new ButtonSpec("取消点赞", UnlikeTargetSpaceAsync, false, true)); + new ButtonSpec("今日点赞", LikeTargetSpaceAsync, false, _targetSpaceView != null && !_targetSpaceView.LikedByMe), + new ButtonSpec("撤销今日点赞", UnlikeTargetSpaceAsync, false, _targetSpaceView != null && _targetSpaceView.LikedByMe)); }); } @@ -636,7 +640,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour _mySpaceView = await Brisk.Space.GetByPlayerIdAsync(Brisk.PlayerId); _mySpaceStats = await Brisk.Space.GetStatsByPlayerIdAsync(Brisk.PlayerId); - _mySpaceLikes = await Brisk.Space.GetLikesByPlayerIdAsync(Brisk.PlayerId, 10); + _mySpaceLikes = await Brisk.Space.GetLikesByPlayerIdAsync(Brisk.PlayerId, 10, true); SpacePayloadText = await DownloadSpaceTextAsync(_mySpaceView, () => Brisk.Space.DownloadContentByPlayerIdAsync(Brisk.PlayerId)); } @@ -673,13 +677,15 @@ public sealed class BriskQuickStartSample : MonoBehaviour private async Task LikeTargetSpaceAsync() { - await Brisk.Space.LikeByPlayerIdAsync(SpacePlayerId); + var result = await Brisk.Space.LikeByPlayerIdAsync(SpacePlayerId); + Log("空间今日点赞结果: created=" + result.Created + ", total=" + result.LikeCount + ", today=" + result.TodayLikeCount); await LoadTargetSpaceAsync(); } private async Task UnlikeTargetSpaceAsync() { - await Brisk.Space.UnlikeByPlayerIdAsync(SpacePlayerId); + var result = await Brisk.Space.UnlikeByPlayerIdAsync(SpacePlayerId); + Log("空间撤销今日点赞结果: total=" + result.LikeCount + ", today=" + result.TodayLikeCount); await LoadTargetSpaceAsync(); } @@ -1120,6 +1126,22 @@ public sealed class BriskQuickStartSample : MonoBehaviour return string.IsNullOrWhiteSpace(value) ? "-" : value; } + private static string FormatLikeResetAt(string value) + { + if (string.IsNullOrWhiteSpace(value)) + { + return "-"; + } + + DateTimeOffset parsed; + if (!DateTimeOffset.TryParse(value, out parsed)) + { + return value; + } + + return parsed.LocalDateTime.ToString("yyyy-MM-dd HH:mm:ss"); + } + private static async Task DownloadSpaceTextAsync(BriskSpaceView view, Func> downloadContent) { if (view == null || !view.ContentExists || downloadContent == null) diff --git a/PackageSource/com.foldcc.cc-framework.brisk-game-server/Documentation~/QuickStart.md b/PackageSource/com.foldcc.cc-framework.brisk-game-server/Documentation~/QuickStart.md index 8e0d493..2831fa8 100644 --- a/PackageSource/com.foldcc.cc-framework.brisk-game-server/Documentation~/QuickStart.md +++ b/PackageSource/com.foldcc.cc-framework.brisk-game-server/Documentation~/QuickStart.md @@ -64,6 +64,11 @@ await Brisk.Space.UpdateMyAsync(new var mySpace = await Brisk.Space.GetByPlayerIdAsync(Brisk.PlayerId); var myContent = await Brisk.Space.DownloadContentByPlayerIdAsync(Brisk.PlayerId); var text = Encoding.UTF8.GetString(myContent.Bytes); + +var likeResult = await Brisk.Space.LikeByPlayerIdAsync("target-player-id"); +Debug.Log($"total={likeResult.LikeCount}, today={likeResult.TodayLikeCount}, created={likeResult.Created}"); + +var todayLikes = await Brisk.Space.GetLikesByPlayerIdAsync(Brisk.PlayerId, 20, true); ``` Notes: @@ -72,6 +77,10 @@ Notes: - `GetByPlayerIdAsync(...)` returns metadata only - use `DownloadContentByPlayerIdAsync(...)` to read the actual content bytes - `UpdateMyAsync(...)` automatically picks text / binary / json behavior from the payload type +- space likes are now tracked by natural day in `Asia/Shanghai` +- `BriskSpaceView` / `BriskSpaceStats` include both `LikeCount` and `TodayLikeCount` +- `BriskSpaceView` also includes `LikedByMe` and `LikeResetAt` +- `GetLikesByPlayerIdAsync(..., currentCycleOnly: true)` returns current-cycle likes only ## Sample diff --git a/PackageSource/com.foldcc.cc-framework.brisk-game-server/README.md b/PackageSource/com.foldcc.cc-framework.brisk-game-server/README.md index f07e857..0cfb517 100644 --- a/PackageSource/com.foldcc.cc-framework.brisk-game-server/README.md +++ b/PackageSource/com.foldcc.cc-framework.brisk-game-server/README.md @@ -87,6 +87,8 @@ http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path - `UpdateMyAsync(string)` 直接上传文本 - `UpdateMyAsync(byte[])` 直接上传二进制 - `UpdateMyAsync(object)` 自动序列化为 JSON +- `LikeByPlayerIdAsync(...)` / `UnlikeByPlayerIdAsync(...)` 返回累计点赞数、今日点赞数、当前周期是否创建新点赞、重置时间 +- `GetLikesByPlayerIdAsync(playerId, limit, true)` 和 `GetLikesByLoginIdentityAsync(..., true)` 可只读取当前周期点赞记录 ## 目录结构 diff --git a/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Core/BriskModelMapper.cs b/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Core/BriskModelMapper.cs index 20917da..8a30bb8 100644 --- a/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Core/BriskModelMapper.cs +++ b/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Core/BriskModelMapper.cs @@ -249,8 +249,10 @@ internal static class BriskModelMapper ContentSizeBytes = BriskValueReader.GetLong(data, "content_size_bytes"), ContentChecksum = BriskValueReader.GetString(data, "content_checksum"), LikeCount = BriskValueReader.GetLong(data, "like_count"), + TodayLikeCount = BriskValueReader.GetLong(data, "today_like_count"), VisitCount = BriskValueReader.GetLong(data, "visit_count"), LikedByMe = BriskValueReader.GetBool(data, "liked_by_me"), + LikeResetAt = BriskValueReader.GetString(data, "like_reset_at"), UpdatedAt = BriskValueReader.GetString(data, "updated_at") }; } @@ -276,7 +278,9 @@ internal static class BriskModelMapper ContentSizeBytes = BriskValueReader.GetLong(data, "content_size_bytes"), ContentChecksum = BriskValueReader.GetString(data, "content_checksum"), LikeCount = BriskValueReader.GetLong(data, "like_count"), + TodayLikeCount = BriskValueReader.GetLong(data, "today_like_count"), VisitCount = BriskValueReader.GetLong(data, "visit_count"), + LikeResetAt = BriskValueReader.GetString(data, "like_reset_at"), UpdatedAt = BriskValueReader.GetString(data, "updated_at") }; } @@ -309,7 +313,11 @@ internal static class BriskModelMapper return new BriskSpaceLikeResult { Liked = BriskValueReader.GetBool(data, "liked"), - LikeCount = BriskValueReader.GetLong(data, "like_count") + Created = BriskValueReader.GetBool(data, "created"), + LikedByMe = BriskValueReader.GetBool(data, "liked_by_me"), + LikeCount = BriskValueReader.GetLong(data, "like_count"), + TodayLikeCount = BriskValueReader.GetLong(data, "today_like_count"), + LikeResetAt = BriskValueReader.GetString(data, "like_reset_at") }; } diff --git a/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Models/BriskSpaceLikeResult.cs b/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Models/BriskSpaceLikeResult.cs index 3637490..b9812e3 100644 --- a/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Models/BriskSpaceLikeResult.cs +++ b/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Models/BriskSpaceLikeResult.cs @@ -1,5 +1,9 @@ public sealed class BriskSpaceLikeResult { public bool Liked; + public bool Created; + public bool LikedByMe; public long LikeCount; + public long TodayLikeCount; + public string LikeResetAt; } diff --git a/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Models/BriskSpaceStats.cs b/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Models/BriskSpaceStats.cs index 48fb95b..0f6bbaf 100644 --- a/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Models/BriskSpaceStats.cs +++ b/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Models/BriskSpaceStats.cs @@ -12,6 +12,8 @@ public sealed class BriskSpaceStats public long ContentSizeBytes; public string ContentChecksum; public long LikeCount; + public long TodayLikeCount; public long VisitCount; + public string LikeResetAt; public string UpdatedAt; } diff --git a/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Models/BriskSpaceView.cs b/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Models/BriskSpaceView.cs index d6338e8..63726e3 100644 --- a/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Models/BriskSpaceView.cs +++ b/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Models/BriskSpaceView.cs @@ -12,7 +12,9 @@ public sealed class BriskSpaceView public long ContentSizeBytes; public string ContentChecksum; public long LikeCount; + public long TodayLikeCount; public long VisitCount; public bool LikedByMe; + public string LikeResetAt; public string UpdatedAt; } diff --git a/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Space/BriskSpaceModule.cs b/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Space/BriskSpaceModule.cs index 8ef72e4..ec97fe6 100644 --- a/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Space/BriskSpaceModule.cs +++ b/PackageSource/com.foldcc.cc-framework.brisk-game-server/Runtime/Space/BriskSpaceModule.cs @@ -68,23 +68,23 @@ public sealed class BriskSpaceModule } /// - /// 按玩家 ID 获取最近点赞列表。 + /// 按玩家 ID 获取点赞列表。 /// - public async Task> GetLikesByPlayerIdAsync(string playerId, int limit = 20) + public async Task> GetLikesByPlayerIdAsync(string playerId, int limit = 20, bool currentCycleOnly = false) { ValidatePlayerId(playerId); return await ExecuteAsync(async context => { - var data = await context.HttpClient.GetRawDataAsync($"/spaces/{playerId}/likes", CreateLimitQuery(limit), true); + var data = await context.HttpClient.GetRawDataAsync($"/spaces/{playerId}/likes", CreateLikesQuery(limit, currentCycleOnly), true); return (IReadOnlyList)BriskModelMapper.ToSpaceLikeItems(data); }); } /// - /// 按登录身份获取最近点赞列表。 + /// 按登录身份获取点赞列表。 /// - public async Task> GetLikesByLoginIdentityAsync(string loginProvider, string loginUserId, int limit = 20) + public async Task> GetLikesByLoginIdentityAsync(string loginProvider, string loginUserId, int limit = 20, bool currentCycleOnly = false) { ValidateLoginIdentity(loginProvider, loginUserId); @@ -92,6 +92,10 @@ public sealed class BriskSpaceModule { var query = CreateLoginIdentityQuery(loginProvider, loginUserId); query["limit"] = NormalizeLimit(limit); + if (currentCycleOnly) + { + query["scope"] = "cycle"; + } var data = await context.HttpClient.GetRawDataAsync("/spaces/by-login/likes", query, true); return (IReadOnlyList)BriskModelMapper.ToSpaceLikeItems(data); }); @@ -262,6 +266,17 @@ public sealed class BriskSpaceModule }; } + private static Dictionary CreateLikesQuery(int limit, bool currentCycleOnly) + { + var query = CreateLimitQuery(limit); + if (currentCycleOnly) + { + query["scope"] = "cycle"; + } + + return query; + } + private static void ValidatePlayerId(string playerId) { RequireNotEmpty(playerId, nameof(playerId)); diff --git a/PackageSource/com.foldcc.cc-framework.brisk-game-server/Samples~/QuickStart/BriskQuickStartSample.cs b/PackageSource/com.foldcc.cc-framework.brisk-game-server/Samples~/QuickStart/BriskQuickStartSample.cs index efc9d75..8581813 100644 --- a/PackageSource/com.foldcc.cc-framework.brisk-game-server/Samples~/QuickStart/BriskQuickStartSample.cs +++ b/PackageSource/com.foldcc.cc-framework.brisk-game-server/Samples~/QuickStart/BriskQuickStartSample.cs @@ -475,14 +475,16 @@ public sealed class BriskQuickStartSample : MonoBehaviour DrawValueRow("内容版本", _mySpaceView == null ? "-" : _mySpaceView.ContentVersion.ToString()); DrawValueRow("内容类型", _mySpaceView == null ? "-" : NullToDash(_mySpaceView.ContentType)); DrawValueRow("内容大小", _mySpaceView == null ? "-" : _mySpaceView.ContentSizeBytes + " bytes"); - DrawValueRow("点赞数", _mySpaceStats == null ? "-" : _mySpaceStats.LikeCount.ToString()); + DrawValueRow("累计点赞数", _mySpaceStats == null ? "-" : _mySpaceStats.LikeCount.ToString()); + DrawValueRow("今日点赞数", _mySpaceStats == null ? "-" : _mySpaceStats.TodayLikeCount.ToString()); DrawValueRow("访问数", _mySpaceStats == null ? "-" : _mySpaceStats.VisitCount.ToString()); + DrawValueRow("今日点赞重置", _mySpaceStats == null ? "-" : FormatLikeResetAt(_mySpaceStats.LikeResetAt)); DrawValueRow("更新时间", _mySpaceView == null ? "-" : NullToDash(_mySpaceView.UpdatedAt)); GUILayout.Space(8f); - GUILayout.Label("最近给我点赞的用户", _sectionTitleStyle); + GUILayout.Label("今天给我点赞的用户", _sectionTitleStyle); if (_mySpaceLikes.Count == 0) { - GUILayout.Label("暂无点赞记录。", _bodyStyle); + GUILayout.Label("当前周期暂无点赞记录。", _bodyStyle); } else { @@ -509,9 +511,11 @@ public sealed class BriskQuickStartSample : MonoBehaviour DrawValueRow("PlayerId", _targetSpaceView == null ? "-" : NullToDash(_targetSpaceView.PlayerId)); DrawValueRow("内容类型", _targetSpaceView == null ? "-" : NullToDash(_targetSpaceView.ContentType)); DrawValueRow("内容大小", _targetSpaceView == null ? "-" : _targetSpaceView.ContentSizeBytes + " bytes"); - DrawValueRow("点赞数", _targetSpaceStats == null ? "-" : _targetSpaceStats.LikeCount.ToString()); + DrawValueRow("累计点赞数", _targetSpaceStats == null ? "-" : _targetSpaceStats.LikeCount.ToString()); + DrawValueRow("今日点赞数", _targetSpaceStats == null ? "-" : _targetSpaceStats.TodayLikeCount.ToString()); DrawValueRow("访问数", _targetSpaceStats == null ? "-" : _targetSpaceStats.VisitCount.ToString()); - DrawValueRow("我的点赞状态", _targetSpaceView != null && _targetSpaceView.LikedByMe ? "已点赞" : "未点赞"); + DrawValueRow("今日点赞状态", _targetSpaceView != null && _targetSpaceView.LikedByMe ? "今日已点赞" : "今日未点赞"); + DrawValueRow("今日点赞重置", _targetSpaceView == null ? "-" : FormatLikeResetAt(_targetSpaceView.LikeResetAt)); GUILayout.Space(8f); GUILayout.Label("空间内容", _sectionTitleStyle); GUILayout.TextArea(_targetSpaceContentText ?? string.Empty, _textAreaStyle, GUILayout.Height(240f)); @@ -520,8 +524,8 @@ public sealed class BriskQuickStartSample : MonoBehaviour DrawCard("操作", () => { DrawInlineButtons( - new ButtonSpec("点赞", LikeTargetSpaceAsync, false, true), - new ButtonSpec("取消点赞", UnlikeTargetSpaceAsync, false, true)); + new ButtonSpec("今日点赞", LikeTargetSpaceAsync, false, _targetSpaceView != null && !_targetSpaceView.LikedByMe), + new ButtonSpec("撤销今日点赞", UnlikeTargetSpaceAsync, false, _targetSpaceView != null && _targetSpaceView.LikedByMe)); }); } @@ -636,7 +640,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour _mySpaceView = await Brisk.Space.GetByPlayerIdAsync(Brisk.PlayerId); _mySpaceStats = await Brisk.Space.GetStatsByPlayerIdAsync(Brisk.PlayerId); - _mySpaceLikes = await Brisk.Space.GetLikesByPlayerIdAsync(Brisk.PlayerId, 10); + _mySpaceLikes = await Brisk.Space.GetLikesByPlayerIdAsync(Brisk.PlayerId, 10, true); SpacePayloadText = await DownloadSpaceTextAsync(_mySpaceView, () => Brisk.Space.DownloadContentByPlayerIdAsync(Brisk.PlayerId)); } @@ -673,13 +677,15 @@ public sealed class BriskQuickStartSample : MonoBehaviour private async Task LikeTargetSpaceAsync() { - await Brisk.Space.LikeByPlayerIdAsync(SpacePlayerId); + var result = await Brisk.Space.LikeByPlayerIdAsync(SpacePlayerId); + Log("空间今日点赞结果: created=" + result.Created + ", total=" + result.LikeCount + ", today=" + result.TodayLikeCount); await LoadTargetSpaceAsync(); } private async Task UnlikeTargetSpaceAsync() { - await Brisk.Space.UnlikeByPlayerIdAsync(SpacePlayerId); + var result = await Brisk.Space.UnlikeByPlayerIdAsync(SpacePlayerId); + Log("空间撤销今日点赞结果: total=" + result.LikeCount + ", today=" + result.TodayLikeCount); await LoadTargetSpaceAsync(); } @@ -1120,6 +1126,22 @@ public sealed class BriskQuickStartSample : MonoBehaviour return string.IsNullOrWhiteSpace(value) ? "-" : value; } + private static string FormatLikeResetAt(string value) + { + if (string.IsNullOrWhiteSpace(value)) + { + return "-"; + } + + DateTimeOffset parsed; + if (!DateTimeOffset.TryParse(value, out parsed)) + { + return value; + } + + return parsed.LocalDateTime.ToString("yyyy-MM-dd HH:mm:ss"); + } + private static async Task DownloadSpaceTextAsync(BriskSpaceView view, Func> downloadContent) { if (view == null || !view.ContentExists || downloadContent == null) diff --git a/PackageSource/com.foldcc.cc-framework.brisk-game-server/Samples~/QuickStart/BriskQuickStartScene.unity b/PackageSource/com.foldcc.cc-framework.brisk-game-server/Samples~/QuickStart/BriskQuickStartScene.unity index 3230947..a8727fe 100644 --- a/PackageSource/com.foldcc.cc-framework.brisk-game-server/Samples~/QuickStart/BriskQuickStartScene.unity +++ b/PackageSource/com.foldcc.cc-framework.brisk-game-server/Samples~/QuickStart/BriskQuickStartScene.unity @@ -259,7 +259,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: BaseUrl: https://brisk.lightyears.ltd - GameKey: briskh5verify + GameKey: game_a1faf5ee93d0 ClientVersion: 1.0.0 DeviceId: editor-device ValidateSessionOnInitialize: 1 @@ -268,7 +268,7 @@ MonoBehaviour: LoginCode: Nickname: "Unity\u793A\u4F8B\u73A9\u5BB6" AvatarUrl: - RankKey: h5-verify-rank-20260410034312-5cdd + RankKey: rank-20260411062004-2bce SubmitScoreValue: 128 LeaderboardLimit: 10 AroundMeRange: 5 diff --git a/README.md b/README.md index e600c84..d4fb208 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ Brisk Unity SDK 原始开发工程。 - `Brisk.Space.UpdateMyAsync(byte[])` 可直接更新二进制内容 - `Brisk.Space.UpdateMyAsync(object)` 会自动转成 JSON 上传 - `Brisk.Space.DownloadContentByPlayerIdAsync(playerId)` 获取原始 bytes + - `Brisk.Space.LikeByPlayerIdAsync(playerId)` / `UnlikeByPlayerIdAsync(playerId)` 会返回累计点赞数、今日点赞数、当前周期是否创建了新点赞、重置时间 + - `Brisk.Space.GetLikesByPlayerIdAsync(playerId, limit, true)` 可只读取当前周期点赞列表 云存档上传补充约定: @@ -82,6 +84,7 @@ Brisk Unity SDK 原始开发工程。 - 排行榜读取、提交分数、赛季查询 - 云存档上传下载 - 玩家空间读取、点赞、更新、访客 +- 玩家空间今日点赞数、今日点赞状态、今日点赞重置时间 - 全局事件日志与最近一次结果输出 当前样例已经直接使用 `UploadTextAsync` / `DownloadTextAsync` 这类快捷接口;如果业务需要,也可以继续走原始 bytes 接口。