@ccw-api/api
    Preparing search index...
    • 创建评论(回复评论时传 parentId / replyToId)

      Parameters

      • content: string

        评论内容

      • topic: MinimalTopicInfo

        主题信息

      • sectionType: SectionType

        板块类型

      • OptionalreplyToId: number

        被回复的评论 id(回复评论时传)

      • OptionalparentId: number

        父评论 id(回复评论时传)

      Returns Promise<Res>

      创建的评论

      1. 发顶层评论 a(id: 1):
      const a = await createComment("a内容", topic, sectionType);
      // a.id = 1,无 parentId / replyToId
      1. 回复 a 发 b(id: 2,replyToId: 1):
      const b = await createComment("b内容", topic, sectionType, 1);
      // b.id = 2,b.replyToId = 1
      // 请求未传 parentId,但后端会将其设为顶层评论 id:b.parentId = 1
      1. 回复 b 发 c(id: 3,replyToId: 2,parentId: 1):
      const c = await createComment("c内容", topic, sectionType, 2, 1);
      // c.replyToId = 2(被回复的 b),c.parentId = 1(顶层评论 id)

      即:b、c 的 parentId 都是 1。搜索/展示回复时按 parentId 归属到顶层楼层, replyToId 才是实际被回复的评论。