You've already forked CC-Framework.BriskGameServer
Compare commits
3 Commits
a257a8a912
...
3a4f2f6652
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a4f2f6652 | |||
| 4fd2222d6d | |||
| 0e5cab4f27 |
@@ -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")
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -68,23 +68,23 @@ public sealed class BriskSpaceModule
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按玩家 ID 获取最近点赞列表。
|
||||
/// 按玩家 ID 获取点赞列表。
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> GetLikesByPlayerIdAsync(string playerId, int limit = 20)
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> 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<BriskSpaceLikeItem>)BriskModelMapper.ToSpaceLikeItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按登录身份获取最近点赞列表。
|
||||
/// 按登录身份获取点赞列表。
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> GetLikesByLoginIdentityAsync(string loginProvider, string loginUserId, int limit = 20)
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> 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<BriskSpaceLikeItem>)BriskModelMapper.ToSpaceLikeItems(data);
|
||||
});
|
||||
@@ -236,7 +240,7 @@ public sealed class BriskSpaceModule
|
||||
/// <summary>
|
||||
/// 获取我的访客列表。
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<BriskSpaceVisit>> GetMyVisitsAsync(int limit = 20)
|
||||
public async Task<IReadOnlyList<BriskSpaceVisit>> GetMyVisitsAsync(int limit = 50)
|
||||
{
|
||||
return await ExecuteAsync(async context =>
|
||||
{
|
||||
@@ -262,6 +266,17 @@ public sealed class BriskSpaceModule
|
||||
};
|
||||
}
|
||||
|
||||
private static Dictionary<string, string> 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));
|
||||
|
||||
@@ -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<string> DownloadSpaceTextAsync(BriskSpaceView view, Func<Task<BriskSpaceContentDownloadResult>> downloadContent)
|
||||
{
|
||||
if (view == null || !view.ContentExists || downloadContent == null)
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# Changelog
|
||||
|
||||
## 0.4.0
|
||||
|
||||
- Added daily-cycle space like fields and result semantics to the Unity SDK models
|
||||
- Added current-cycle filtering support for space like list APIs
|
||||
- Updated the quick start sample to display total likes, today likes, like reset time, and current-cycle like actions
|
||||
- Changed `GetMyVisitsAsync()` default page size to `50` while preserving the optional `limit` parameter
|
||||
- Refreshed package and integration documentation to match the latest production API behavior
|
||||
|
||||
## 0.3.0
|
||||
|
||||
- Renamed the UPM package identifier to `com.foldcc.cc-framework.brisk-game-server`
|
||||
|
||||
@@ -64,6 +64,12 @@ 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);
|
||||
var visits = await Brisk.Space.GetMyVisitsAsync();
|
||||
```
|
||||
|
||||
Notes:
|
||||
@@ -72,6 +78,11 @@ 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
|
||||
- `GetMyVisitsAsync()` now defaults to the latest `50` visits, with `100` as the server-side max
|
||||
|
||||
## Sample
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ Brisk Unity SDK 的 UPM 发布目录。
|
||||
4. 输入:
|
||||
|
||||
```text
|
||||
http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path=/PackageSource/com.foldcc.cc-framework.brisk-game-server#v0.3.0
|
||||
http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path=/PackageSource/com.foldcc.cc-framework.brisk-game-server#v0.4.0
|
||||
```
|
||||
|
||||
### 方式二:修改 `Packages/manifest.json`
|
||||
@@ -30,12 +30,12 @@ http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path
|
||||
```json
|
||||
{
|
||||
"dependencies": {
|
||||
"com.foldcc.cc-framework.brisk-game-server": "http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path=/PackageSource/com.foldcc.cc-framework.brisk-game-server#v0.3.0"
|
||||
"com.foldcc.cc-framework.brisk-game-server": "http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path=/PackageSource/com.foldcc.cc-framework.brisk-game-server#v0.4.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
如果需要跟随主分支最新代码,可将末尾的 `#v0.3.0` 改成 `#main`;正式环境建议固定到发布 tag。
|
||||
如果需要跟随主分支最新代码,可将末尾的 `#v0.4.0` 改成 `#main`;正式环境建议固定到发布 tag。
|
||||
|
||||
## 开发态源码位置
|
||||
|
||||
@@ -87,6 +87,9 @@ 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)` 可只读取当前周期点赞记录
|
||||
- `GetMyVisitsAsync()` 默认读取最近 `50` 条访问记录,也可手动传入 `limit`
|
||||
|
||||
## 目录结构
|
||||
|
||||
|
||||
@@ -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")
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -68,23 +68,23 @@ public sealed class BriskSpaceModule
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按玩家 ID 获取最近点赞列表。
|
||||
/// 按玩家 ID 获取点赞列表。
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> GetLikesByPlayerIdAsync(string playerId, int limit = 20)
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> 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<BriskSpaceLikeItem>)BriskModelMapper.ToSpaceLikeItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按登录身份获取最近点赞列表。
|
||||
/// 按登录身份获取点赞列表。
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> GetLikesByLoginIdentityAsync(string loginProvider, string loginUserId, int limit = 20)
|
||||
public async Task<IReadOnlyList<BriskSpaceLikeItem>> 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<BriskSpaceLikeItem>)BriskModelMapper.ToSpaceLikeItems(data);
|
||||
});
|
||||
@@ -236,7 +240,7 @@ public sealed class BriskSpaceModule
|
||||
/// <summary>
|
||||
/// 获取我的访客列表。
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<BriskSpaceVisit>> GetMyVisitsAsync(int limit = 20)
|
||||
public async Task<IReadOnlyList<BriskSpaceVisit>> GetMyVisitsAsync(int limit = 50)
|
||||
{
|
||||
return await ExecuteAsync(async context =>
|
||||
{
|
||||
@@ -262,6 +266,17 @@ public sealed class BriskSpaceModule
|
||||
};
|
||||
}
|
||||
|
||||
private static Dictionary<string, string> 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));
|
||||
|
||||
@@ -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<string> DownloadSpaceTextAsync(BriskSpaceView view, Func<Task<BriskSpaceContentDownloadResult>> downloadContent)
|
||||
{
|
||||
if (view == null || !view.ContentExists || downloadContent == null)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "com.foldcc.cc-framework.brisk-game-server",
|
||||
"displayName": "FoldCC Brisk Game Server SDK",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"unity": "2021.3",
|
||||
"description": "A lightweight Unity SDK for Brisk game services, including bootstrap, auth, announcements, leaderboard, archive, and player space modules.",
|
||||
"keywords": [
|
||||
|
||||
10
README.md
10
README.md
@@ -34,6 +34,9 @@ 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)` 可只读取当前周期点赞列表
|
||||
- `Brisk.Space.GetMyVisitsAsync()` 默认读取最近 `50` 条访问记录,也可手动传入 `limit`
|
||||
|
||||
云存档上传补充约定:
|
||||
|
||||
@@ -82,6 +85,7 @@ Brisk Unity SDK 原始开发工程。
|
||||
- 排行榜读取、提交分数、赛季查询
|
||||
- 云存档上传下载
|
||||
- 玩家空间读取、点赞、更新、访客
|
||||
- 玩家空间今日点赞数、今日点赞状态、今日点赞重置时间
|
||||
- 全局事件日志与最近一次结果输出
|
||||
|
||||
当前样例已经直接使用 `UploadTextAsync` / `DownloadTextAsync` 这类快捷接口;如果业务需要,也可以继续走原始 bytes 接口。
|
||||
@@ -138,7 +142,7 @@ Brisk Unity SDK 原始开发工程。
|
||||
外部项目 Git Package 接入示例:
|
||||
|
||||
```text
|
||||
http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path=/PackageSource/com.foldcc.cc-framework.brisk-game-server#v0.3.0
|
||||
http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path=/PackageSource/com.foldcc.cc-framework.brisk-game-server#v0.4.0
|
||||
```
|
||||
|
||||
## 如何引入到项目
|
||||
@@ -165,12 +169,12 @@ http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path
|
||||
```json
|
||||
{
|
||||
"dependencies": {
|
||||
"com.foldcc.cc-framework.brisk-game-server": "http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path=/PackageSource/com.foldcc.cc-framework.brisk-game-server#v0.3.0"
|
||||
"com.foldcc.cc-framework.brisk-game-server": "http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path=/PackageSource/com.foldcc.cc-framework.brisk-game-server#v0.4.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
如果要跟随主分支最新代码,可把末尾的 `#v0.3.0` 改成 `#main`;正式项目仍建议固定到发布 tag。
|
||||
如果要跟随主分支最新代码,可把末尾的 `#v0.4.0` 改成 `#main`;正式项目仍建议固定到发布 tag。
|
||||
|
||||
## 文档位置
|
||||
|
||||
|
||||
Reference in New Issue
Block a user