Commit Graph

18 Commits

Author SHA1 Message Date
Pine 3061ceb2d8 实时通知体系后端:NotificationService 三通道(落库+MQTT+SSE)、迁移0057、通知接口增强(分页/分类/单条已读/未读计数/公告)、SSE /notify/events 鉴权流,事件接入任务/接单/认证/信用/培训/服务/点赞/评论/运营审核 2026-09-05 10:37:14 +08:00
Pine 6bb988cc3e refactor: 角色组织账号模型重构 - 阶段一
1. capabilities 写入 JWT,避免每次请求查库
2. 移除 service 账号类型,非 operator/carrier 统一归为 opc_member
3. 前端统一基于 capabilities 判断权限
4. 清理登录接口死代码,恢复账号密码登录
5. 移除 enterprise/provider/government/investor/developer 角色
6. 清理 seed.py 中多余角色和权限定义
7. 重写 rbac_portals.py 只保留 carrier 路由
2026-09-03 00:35:40 +08:00
Pine 700bafdb26 feat(invite): 完整邀请归因系统
数据模型:
- User表添加inviter_id/invite_code/invited_at/invite_share_count字段
- 新建invite_records表记录分享/扫码/注册归因
- MySQL迁移已执行

后端API(/invite/*):
- GET /invite/me 获取我的邀请码和统计
- GET /invite/qrcode 生成带邀请参数的小程序码(体验版/正式版)
- POST /invite/share 记录分享行为
- POST /invite/scan 记录扫码行为(无需登录)
- GET /invite/invitees 获取我邀请的用户列表

登录归因:
- wx_login支持inviter参数,新用户自动绑定邀请人
- 用户列表返回inviter_name和invite_count

服务层:
- invite_service.py:邀请码生成、归因绑定、小程序码生成、统计
2026-09-02 02:18:41 +08:00
Pine 40c2f75b18 feat(admin): 大厅与社区治理接口(岗位/OPC服务/人才/大厅任务/帖子)
- /admin/hall/jobs* 岗位列表与审核上下架
- /admin/hall/services* OPC 服务审核
- /admin/hall/talents* 人才档案列表与上架下架
- /admin/hall/tasks* 大厅任务审核列表(含 pending)与通过/驳回/下架
- /admin/community/posts* 帖子列表、隐藏/恢复、置顶/取消置顶
- 全部走 operator 角色 + write_audit 审计
2026-08-31 23:05:13 +08:00
Pine dbc29eee59 feat(membership): 成员制归属重构与叠加制身份(多对多成员表+转园两级审核)
- park_members/company_members 多对多成员表(0028),users.affiliation 为派生缓存由 sync_user_affiliation 刷新
- 转园两级审核状态机(0029):pending_from→pending_to→approved,支持用户/企业整体转园与运营端兜底
- 叠加制身份(0030):身份恒为运营/载体/OPC,企业管理员为能力叠加非身份,去除 enterprise/carrier 直写角色
- rbac 新增 memberships/park-transfers/企业管理员工作台 /admin/ent/* 接口

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-31 20:36:26 +08:00
Pine 7493383f6a feat(users): 建号规则收紧与手机号绑定
- 管理端/园区端创建用户:账号系统随机生成不可指定,手机号必填且全局唯一
- 管理端用户管理支持绑定/更换手机号(PATCH /admin/users/{id}/phone)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-30 22:29:44 +08:00
Pine 985b85cb4e feat(oss): 统一OSS/CDN对象存储与直链出口体系
- infrastructure/oss.py 重写:服务端上传/预签名上下行/CDN鉴权直链(方式A)/resolve_url·to_object_path 出入口规范
- config.py 新增 OSS_REGION/OSS_CDN_BASE_URL/OSS_CDN_AUTH_KEY
- media_upload 统一走 oss 单例,返回 CDN 直链;dispatcher /oss 前缀路由
- 管理端用户列表头像出口 CDN 化
2026-08-28 17:17:38 +08:00
Pine 89396eb6b0 chore: 汇总提交(园区资料/内容审核/任务相关)+迁移0019/0021及部署编排调整 2026-08-27 21:02:47 +08:00
Pine 8697119aaa feat(park-company): 园区企业→成员 + 企业算力(折扣%/配额,只增不减) 后端
- 迁移0015:park_companies 加 compute_discount/compute_quota/compute_quota_used/engine_group/owner_user_id;users 加 park_company_id(成员归属一家企业)
- tenants.py:company_members/get/add/remove(写 users.park_company_id)、available_members(候选)、set_company_compute(折扣%/配额 单调非降,越界 ValueError)、sync_company_engine(引擎组倍率同步,best-effort)
- park/routers.py:carrier 端点 company-members GET/POST/DELETE、company-pool、companies/{cid}/compute(monotonic+引擎同步);鉴权 _carrier_user+_my_park 隔离本园区
- compute_client.py:set_user_group_by_username、set_group_group_ratio(组倍率=1-discount%)、grant_user_quota_by_username(解析引擎id后 add_quota)
- rbac_admin.py:平台兜底 GET /park/tenants/{tid}/companies、PUT .../companies/{cid}/compute(monotonic+audit)
- _user_to_dict 暴露 park_company_id
- 单调校验服务端强判:折扣降/配额负增 → 400

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-26 19:57:37 +08:00
Pine 97f0a0698c feat(park): 平台园区/屏幕绑定 + OPC认证入园转园审核 + 园区端carrier修复
- rbac_admin 新增 /admin/park/screens|tenants|devices/{id}/bind|unbind 及 OPC认证/入园/转园审核端点
- tenants.list_all_screens 带 online(MQTT心跳),bind/unbind 完备
- park/routers: tenant_bind 绑定即 set_role(carrier);_my_park 兜底 username→admin_username 解析园区(修"未关联任何园区")

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-26 19:02:58 +08:00
Pine bc6265eb67 feat(opc): OPC认证/入园/转园 端点 + 园区端方案B审核 + 迁移0013
- rbac_opc.py: /opc/certification/apply|mine、/opc/park-transfer/apply|mine
- rbac_admin.py: platform operator 兜底 list/review (opc-certifications/park-admissions/park-transfers),通过回填 users.set_classification
- park/routers.py: carrier 角色凭 operator_user_id 定位本园区,/park/api park-admissions|transfers view+review
- park/tenants.py: bind_admin 写 operator_user_id + find_by_operator_user_id
- 迁移 0013: opc_certifications + park_transfers + park_tenants.operator_user_id
2026-08-26 15:43:34 +08:00
Pine 0039a809ac feat(user): 用户认证状态/所属/账号类型 分类字段
- users 增: certification_status(uncertified|pending|certified|rejected)+certification_time, affiliation(independent|park)+park_id/park_name, account_type(opc_default|park_staff|platform_staff|provider|enterprise); alembic 0007
- repo: set_classification; _user_to_dict 含全部新字段; profile 返回认证/所属/账号类型
- admin: POST /admin/users/{id}/classification(认证/分类设置, action:user.manage) + UserClassificationRequest schema
- 迁移已应用, 导入通过
2026-08-25 16:24:19 +08:00
Pine 1ca2e38559 feat(compute): 算力引擎对接改造 + 用户生命周期自动同步
- config: 置顶 load_dotenv(.env),修复 .env 未生效;COMPUTE_ADMIN_TOKEN 改读 PINEAGENTS_INTERNAL_TOKEN(回退旧名),新增独立 COMPUTE_RELAY_TOKEN
- compute_client: 空令牌不下发 Bearer(避免 httpx 非法头);proxy 空令牌返 503 中文诊断;新增 sync_user_enabled/sync_delete_user
- relay: /v1 转发改走 COMPUTE_RELAY_TOKEN(真实消费令牌),空令牌不下发
- rbac_admin: 平台用户创建→自动建引擎账号+签PAT;启用/禁用→同步引擎状态;删除→同步删引擎账号(最佳努力,失败静默)
2026-08-25 12:08:14 +08:00
Pine 83e542c2c2 feat(平台端): 完整用户管理 — 新增 修改(PUT /admin/users/{id}) + 删除(DELETE /admin/users/{id})
UserRepository.delete(硬删);UpdateUserRequest(昵称/角色/子角色/组织/区域);update_user 调 update_profile+set_role,
delete_user 调 delete;走 action:user.manage + write_audit。TestClient:create/update/delete 均 200。
2026-08-24 18:40:59 +08:00
Pine 01ef3c9637 refactor: schemas 抽取(DTO 从 models.py 与路由内联迁至 api/schemas/)
- 新建 api/schemas/:auth/agents/admin/ecosystem/investor/opc/operator/org/portals
- models.py 移除 15 个 Pydantic DTO(保留 ORM 数据模型层)
- 13 个路由内联 DTO 全部迁出,路由瘦身仅剩处理逻辑
- 全量 66 测试通过
2026-08-24 09:51:52 +08:00
Pine 2c737478dc fix: UserAdminService.create_user 返回原始 user(含 id),路由转 profile
- 修复 create_user 后 write_audit 取 user.id 的 KeyError
- 22 受影响测试 + 全量 66 全绿
2026-08-24 09:39:52 +08:00
Pine c99662cfec feat: 业务层 services 抽取完成(工作台/用户管理)
- DashboardService:OPC 工作台聚合(统计/进行中任务/智能体建议/月度收入/消息)
- UserAdminService:建号+默认身份联动、角色分配提权防护(action:role.grant_perm 仅超管)
- rbac_opc dashboard / rbac_admin create_user+set_role 接线
- services 层覆盖全部核心业务域,路由全瘦身
2026-08-24 09:35:08 +08:00
Pine 980a2db6d9 refactor: 平台应用异步四层架构(接口/业务/领域/基础设施)
- 基础设施层 async:SQLAlchemy 异步引擎/会话、33 Repository async 化、models/security/seed 迁入 infrastructure、新增 cache.py(redis.asyncio) 与 oss.py(aioboto3)
- 接口层:routers 迁 api/routers 并全 async,dependencies 迁 api/dependencies(get_db/get_current_user async)
- 依赖:sqlalchemy[asyncio]/aiosqlite/asyncmy/redis/aioboto3;config 异步 URL + Redis/OSS 配置
- 删除废弃:旧同步 db/dependencies/repositories/storage
- 验证:平台 19 路由 + 培训 48 路由全注册;/health /auth/login /auth/me /admin/tasks /notifications 等接口 async 可用
2026-08-23 23:52:58 +08:00