宠物板块第一期:宠物档案与后台审核

方案第一期的后端部分。宠物档案是整个板块的根——代喂任务、送养帖、
配种信息都会挂在它上面,所以免疫、绝育、体重这些事实只在这里存一份,
不在各业务表里重复填写与互相矛盾。

- pets / pet_media 两张表(迁移 036),另加三个可在管理端调整的配置:
  总开关、单账号档案上限、单只宠物照片上限。
- 客户端接口:档案增删改查。日期在校验阶段解析,格式或"未来的免疫日期"
  这类问题返回 400 并说明是哪个字段,而不是从写库深处抛出 500。
- 软删除:档案从列表消失但记录保留,将来代喂订单与送养记录仍能追溯。
- 后台审核:列表带主人昵称与星遇号;驳回必须填原因;被驳回的档案对外
  不可见,但主人仍能看到并读到原因。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Your Name
2026-09-05 16:53:55 +08:00
co-authored by Claude Opus 5
parent ce429afcf2
commit aee1881e69
4 changed files with 734 additions and 0 deletions
+7
View File
@@ -247,6 +247,11 @@ func (a *App) userRoutes() []rest.Route {
{Method: http.MethodGet, Path: "/api/v1/feed", Handler: auth(a.feed)},
{Method: http.MethodGet, Path: "/api/v1/posts/:id", Handler: auth(a.postDetail)},
{Method: http.MethodGet, Path: "/api/v1/users/:id/posts", Handler: auth(a.userPosts)},
{Method: http.MethodGet, Path: "/api/v1/pets", Handler: auth(a.myPets)},
{Method: http.MethodPost, Path: "/api/v1/pets", Handler: auth(a.createPet)},
{Method: http.MethodGet, Path: "/api/v1/pets/:id", Handler: auth(a.petDetail)},
{Method: http.MethodPut, Path: "/api/v1/pets/:id", Handler: auth(a.updatePet)},
{Method: http.MethodDelete, Path: "/api/v1/pets/:id", Handler: auth(a.deletePet)},
{Method: http.MethodPost, Path: "/api/v1/posts", Handler: auth(a.createPost)},
{Method: http.MethodPatch, Path: "/api/v1/posts/:id", Handler: auth(a.updatePost)},
{Method: http.MethodDelete, Path: "/api/v1/posts/:id", Handler: auth(a.deleteOwnPost)},
@@ -323,6 +328,8 @@ func (a *App) adminRoutes() []rest.Route {
{Method: http.MethodPost, Path: "/admin/v1/orders/:id/refund", Handler: permit("orders:manage", a.adminRefund)},
{Method: http.MethodGet, Path: "/admin/v1/messages", Handler: permit("messages:view", a.adminMessages)},
{Method: http.MethodPost, Path: "/admin/v1/messages/:id/moderate", Handler: permit("messages:manage", a.adminModerateMessage)},
{Method: http.MethodGet, Path: "/admin/v1/pets", Handler: permit("users:view", a.adminPets)},
{Method: http.MethodPost, Path: "/admin/v1/pets/:id/moderate", Handler: permit("users:manage", a.adminModeratePet)},
{Method: http.MethodGet, Path: "/admin/v1/chat-media", Handler: permit("messages:view", a.adminChatMedia)},
{Method: http.MethodPut, Path: "/admin/v1/chat-media/retention", Handler: permit("messages:manage", a.adminUpdateChatMediaRetention)},
{Method: http.MethodPost, Path: "/admin/v1/chat-media/cleanup", Handler: permit("messages:manage", a.adminCleanupDueChatMedia)},