zerosaturation
cc7794e0f4
test(task): consumer + daily_task repo/service + like_bet ON CONFLICT 修订
...
Phase F.6 测试覆盖:
- mq/consumer_test.go: MQ consumer 单元测试,用 fakeDailyTaskService 模拟
ProcessTaskEvent(newHandleTaskEvent 唯一调用点)
- repository/daily_task_repo_test.go: DailyTaskRepository CRUD 单测
(复用 like_bet_repo_test.go 的 TestMain + dev PG 15432 sentinel 模式)
- service/daily_task_service_test.go: DailyTaskService.ProcessTaskEvent 核心
完成判定逻辑单测
- repository/like_bet_repo_test.go: UniqueConstraint 测试语义修订 —
BatchCreate 内部用 clause.OnConflict{DoNothing: true} 实现幂等,
重复 (exhibition_id, like_id) 不再报错,DB 仍保留 1 条记录
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-27 15:46:29 +08:00
zerosaturation
1e8a7476e0
feat(task): register task:event MQ consumer
...
- consumer.go: +newHandleTaskEvent(dailySvc) adapter.TaskHandler
- unmarshal TaskEventPayload -> delegate to ProcessTaskEvent
- returns non-nil error on failure -> Asynq MaxRetry=3
- consumer.go: RegisterHandlers signature +dailySvc parameter
- consumer.go: register TaskEvent with QueueDefault, MaxRetry=3
- main.go: pass dailySvc to taskmq.RegisterHandlers
Now task:event MQ messages produced by:
- assetService/mq/producer.go (Phase F.1) for daily_mint
- frontend reportEvent RPC -> gateway (Phase F.2 callers) for daily_login/browse_asset/place_asset
are consumed asynchronously and routed to ProcessTaskEvent.
spec: docs/superpowers/specs/2026-07-21-daily-task-config-driven-design.md §3 F3 + §4.2
plan: docs/superpowers/plans/2026-07-21-daily-task-config-driven-impl.md Phase E
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-27 15:42:10 +08:00
zerosaturation
e2f1122cc8
feat(task): GORM model + repository + ProcessTaskEvent engine
...
Phase B (model + repository):
- TaskDefinition: +TriggerEvent string, +TargetCount int
- UserDailyTaskProgress: +Progress int
- DailyTaskRepository: ListActiveDailyTaskDefinitions signature -> (starID, eventType string)
- IncrementProgress: atomic UPDATE progress=progress+1 WHERE status='pending'
(returns rows-affected 0 + re-read on race; caller decides completion transition)
- ResetAllDailyTasks: +progress: 0 in Updates map
- InitDailyTasksForUser: pass eventType='' (backward-compat)
Phase D (engine + ReportEvent delegation, spec §4.3):
- TaskEventResult struct (CompletedTaskKeys []string)
- DailyTaskService.ProcessTaskEvent: 5-step engine
1. ListActiveDailyTaskDefinitions(starID, eventType) - filter by trigger_event
2. GetOrCreateDailyProgress; skip if completed/claimed (day idempotency)
3. IncrementProgress (atomic +1)
4. if progress >= target_count -> status='completed'
5. UpdateDailyProgress + accumulate CompletedTaskKeys
- ReportEvent rewired: delegates to ProcessTaskEvent, maps TaskEventResult
to ReportEventResponse (F1: single isolation unit; MQ consumer + RPC both use engine)
- 3 callers (GetDailyTasks / ClaimDailyTask / ClaimAllDailyTasks) pass eventType=''
for backward-compat (preserves daily_login / daily_browse_asset before Phase F)
Note: Phase B and D are bundled because the signature change in B is what enables
D's engine to filter by trigger_event. Splitting would leave the codebase
uncompilable in the interim.
spec: docs/superpowers/specs/2026-07-21-daily-task-config-driven-design.md §4
plan: docs/superpowers/plans/2026-07-21-daily-task-config-driven-impl.md
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-27 15:41:35 +08:00
zerosaturation
a337f43f86
fix(config): port alignment + service test doubles (batch 4.1/4.5)
...
- gateway/config Dubbo URL 默认端口修正(原 20004/20005 与服务实际 20001/20004 不符);
- userService main.go 硬编码 WithPort(20000) 修死码, -port flag / PORT env 真正生效;
- .env.example 11 个 DUBBO URL 同步(对齐 serviceDefaultPorts map + 实际服务 bind);
- 删除 DUBBO_STARBOOK_SERVICE_URL 死引用(starbookService 已在 batch 4.2 删除);
- .env.example Service Ports 注释块补全 10 行, 与网关 Dubbo URL + port_test 三方一致;
- 10 个 service 各加 port_test.go, 断言 flag 默认与 serviceDefaultPorts map 一致;
- 11 个 port_test 总计 13 测试覆盖(网关 + 10 service);
- .gitignore 加 userService/main.go.bak 排除(临时备份)。
Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-24 14:02:14 +08:00
zerosaturation
e1326acaf9
fix(backend): service stability — bcrypt off-txn / login anti-enum / MQ stub / aiChat / event reliability / gateway aggregate (batch 3)
...
- 3.1 bcrypt 移出事务 (Register): repository.HashPassword 前移到 db.Transaction 之前,消除连接池占用。
- 3.2 Login 消除用户枚举 + 限流 + timing 抹平: pkg/errors 加 ErrInvalidCredential
/ErrTooManyLoginAttempts; 用户不存在/密码错/密码空 三路径统一返回同一错误;
mobile 5次/ip 20次 per 15min 限流 (Redis, fail-open 降级); user-not-found 走
dummy bcrypt 抹平 ~100ms 时序差,完全消除枚举侧信道;空密码分支已核实无时序 leak。
- 3.3 MQ streams adapter 停用 → stub: 0 业务调用方, 新 stub EventProducer.Publish no-op;
pkg/mq/mq.go Init 不再装配 streams; 全仓 grep 验证 11 处硬编码
'gallery'/'default' 集中到 pkg/queue/consts (值不变, 仅消漂移)。
- 3.5 JWT 密钥治理: pkg/jwt MustInit fail-fast + atomic.Value (见上一个 commit 293c7b1 )。
- 3.6 aiChat 健壮性: SaveContext 用 persona.ID(非 req.PersonaId); Redis/memory 错误
记 WARN 不静默; Dify err 映射稳定用户文案,原始 err 仅服务端日志。
- 3.7 statistic.Client 重构: TrackEvent 改 buffered channel (cap 1024) + dispatchLoop
worker; 失败 ERROR 日志带字段; drop 记 WARN; Close 可重复调用。
- 3.8 网关聚合: StarCache (60s TTL, singleflight) 替换 5+ 处 GetFanIdentities 链式调用;
DeleteAccount 改网关直调 userService.DeleteAccount(避免改 hand-written triple.go
风险,见报告 §5 proto 风险复盘); 铸造双写改异步 channel+consumer (3 retry)。
- 大量单测: 各子项 TDD (RED→GREEN), 关键并发 race_test (50 goroutine)。
Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-23 18:50:40 +08:00
zerosaturation
b7022d2dc1
fix(backend): auth boundary — trusted identity from ctx (batch 2)
...
- 新增 pkg/authctx: 从 Dubbo attachment/gRPC metadata 提取可信 user_id/star_id,
统一覆盖 req 同名字段, 缺身份返 Unauthenticated。
- 各 provider 接入(堵身份伪造/越权):
* moderation SubmitReport 等 6 RPC(举报人伪造)
* asset CheckAssetLike/GetAssetQrcode/TrackShare(点赞/分享归因伪造)
* social CheckFriendship(修 starID=0 隐私预言机)
* activity PurchaseItem/BatchPurchaseItem(水晶扣费伪造)等 5 RPC
* gallery/aiChat/task/notification 迁移 authctx, 删散落 extractUserInfo*
- social 正确性: GetUserLikedAssets OR 显式分组(防御); GetRandomUsersByStar 真随机(去 rand.Seed)。
- gateway: /auth/validate 移入 AuthMiddleware 保护组(/refresh 保留,依赖注入身份)。
- 删 userService 已迁移死函数; notification 缺身份错误码统一为 Unauthenticated。
- 各 provider 单测(伪造身份被覆盖 + 缺身份拒绝)。
Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-23 01:12:35 +08:00
zerosaturation
878bd46399
fix(backend): financial correctness — settlement/hours/mint idempotency (batch 1)
...
- settlement(1.1): exhibition_revenue_records 加 UNIQUE(exhibition_id,cycle_start_time)
+ CreateRevenueRecord ON CONFLICT DO NOTHING; MQ 用 settled_at 替代复用 is_processed;
恢复扫描器过滤改 settled_at IS NULL; created_at 统一毫秒; 删死代码 cleanup_worker.go。
- hours(1.2): 新增 exhibition_hours_log/asset_exhibition_hours_log(source_id 唯一)幂等表;
fan_profile/assetLevel 的 AddExhibitionHours 按 sourceID 幂等(事务包裹); 存量重算脚本。
- mint(1.4/1.5/1.6): crystal_transaction_records (source_id,change_type) 部分唯一索引
+ UpdateCrystalBalance/CreateMintOrder 幂等; 保底改 crypto/rand; 下线伪 tx_hash;
doMint Redis Lua 原子限流。
- migrations 001/002/003; 各服务单测(自包含, 缺 DB t.Skip)。
Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-23 01:11:54 +08:00
zerosaturation
c07e8e9c19
fix:修改数据看板bug
2026-07-03 14:57:14 +08:00
zerosaturation
d12a84c1f0
feat:增加队列修改收益方面把轮询改为MQ队列,修改数据看板的数据问题出错
2026-07-03 12:34:55 +08:00
zerosaturation
355ac4393b
feat:修改收益的计算
2026-07-03 12:34:55 +08:00
zerosaturation
3cd68acf6d
feat:完善计算点赞押注收益
2026-06-29 14:47:32 +08:00
zerosaturation
7eb6dad434
feat:新增举报和反馈功能
2026-06-22 17:19:48 +08:00
zerosaturation
271e0350c7
feat:重构code状态码
2026-06-15 16:28:35 +08:00
zerosaturation
0029fb8cc8
feat(statistic): T9-T12 dashboard 7 RPCs - additional business-side service modifications
...
Modifications to 5 existing business services for TrackEvent integration:
- socialService/asset_like_service.go: TrackEvent(asset.like) after LikeAsset
- galleryService/exhibition_service.go: TrackEvent(exhibition.start) + (exhibition.end with duration)
- taskService/revenue_service.go: TrackEvent(exhibition.revenue) after OnExhibitionCompleted
- assetService/mint_service.go: TrackEvent(asset.mint) after CreateMintOrder
- assetService/asset_level_service.go: TrackEvent(asset.level_up) in logLevelChange
- userService/user_service.go: fireCrystalChangeEvent wrapper (call site TBD by service owner)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 17:20:53 +08:00
zerosaturation
3707125549
feat(statistic): scaffold statisticService with go.mod and directory structure
2026-06-08 17:20:53 +08:00
zerosaturation
23a8051e96
feat: 修改头像显示不全,修改docker的配置
2026-06-04 16:41:20 +08:00
zerosaturation
5e33bbb031
feat: 修改用户经验bug和收益记录bug
2026-05-31 20:38:58 +08:00
zerosaturation
7c5d5a7275
feat:修改藏品等级硬编码改为根据数据库的配置来定义
2026-05-25 19:03:32 +08:00
zerosaturation
2a0db41dbf
fix: wire AssetLevelService into existing service constructors
2026-05-25 19:03:32 +08:00
zerosaturation
bee30a1824
feat: integrate asset level system with existing services
...
- mintService: Add AssetLevelService field and call GetOrCreateRecord after asset creation
- assetLikeService: Add AssetLevelService and call AddLikes/RemoveLikes in LikeAsset/UnlikeAsset
- revenueService: Add AssetLevelService and call AddExhibitionHours in OnExhibitionCompleted
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 19:03:31 +08:00
zerosaturation
2855cd512d
feat: 修改自动领取收益关闭,修复下架时间的bug,修改的光栅卡陀螺仪
2026-05-25 11:08:35 +08:00
zerosaturation
eaad2642a8
修改展示时长bug
2026-05-19 15:48:41 +08:00
zerosaturation
cf8671b5bb
修改经验问题和光栅卡铸造bug修改
2026-05-16 04:32:43 +08:00
zerosaturation
afb235afd3
feat: 合并代码,解决冲突
2026-05-16 02:42:32 +08:00
zerosaturation
c5bf9df955
feat: 经济系统重构 - 任务服务与画廊服务解耦
...
- galleryService 独立启动,配置 task-service-url
- 新增 taskService 到 galleryService 的 RPC 调用
- 更新 proto 文件并重新生成代码
- 新增展览唯一约束迁移脚本
- 修复多个 service 的配置和依赖关系
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 23:12:02 +08:00
zerosaturation
3ef3510303
feat:修改展示收益
2026-05-15 11:49:00 +08:00
zerosaturation
74182ad662
feat: 新增经济系统
2026-05-14 15:59:07 +08:00
zerosaturation
6866618ff6
fix: 引导任务修改bug
2026-04-22 17:35:43 +08:00
zerosaturation
bebdc13c80
fix: 修改任务系统的bug
2026-04-17 17:17:32 +08:00
zerosaturation
4e13c86aa4
fix: 修改任务系统奖励修复
2026-04-15 14:11:07 +08:00
ad20197352
feat: 每日任务集成
2026-04-14 14:32:56 +08:00