Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: topics and comments #170

Closed
wants to merge 46 commits into from
Closed

Conversation

fdkevin0
Copy link
Contributor

@fdkevin0 fdkevin0 commented Jun 4, 2022

获取条目全部讨论

GET /p/subjects/{subject_id}/topics

Query

  • limit
  • offset

响应:

{
  "data": [
    {
      "created_at": "2008-07-14T15:34:07+08:00",
      "creator": {
        "username": "2",
        "nickname": "nickname 2"
      },
      "title": "拿这个来测试",
      "id": 1,
      "replies": 76
    }
  ],
  "hasMore": false,
  "limit": 10,
  "offset": 0
}
获取条目讨论内容

GET /p/subjects/{subject_id}/topics/{topic_id}

Query

  • limit
  • offset

响应:

{
  "created_at": "2008-07-14T15:34:07+08:00",
  "comments": {
    "data": [
      {
        "created_at": "2016-01-15T20:58:20+08:00",
        "creator": {
          "username": "",
          "nickname": ""
        },
        "text": "这个帖子竟然没人挖(bgm38)",
        "replies": [
          {
            "created_at": "2016-01-17T01:25:12+08:00",
            "creator": {
              "username": "",
              "nickname": ""
            },
            "text": "专业挖坟的么=_=",
            "id": 68013
          }
        ],
        "id": 67970
      }
    ],
    "has_more": true,
    "limit": 10,
    "offset": 0
  },
  "creator": {
    "username": "2",
    "nickname": "nickname 2"
  },
  "title": "拿这个来测试",
  "id": 1,
  "replies": 76
}
获取角色讨论内容

GET /p/characters/{character_id}/comments

Query

  • limit
  • offset

响应:

{
  "data": [
    {
      "created_at": "2012-11-08T22:36:32+08:00",
      "creator": {
        "username": "",
        "nickname": ""
      },
      "text": "9/101\n渣渣~",
      "replies": [
        {
          "created_at": "2012-11-08T22:40:32+08:00",
          "creator": {
            "username": "14127",
            "nickname": "nickname 14127"
          },
          "text": "哈哈 我也是9/101",
          "id": 1039
        }
  ],
  "has_more": false,
  "limit": 30,
  "offset": 0
}

close #67

@trim21
Copy link
Contributor

trim21 commented Jun 4, 2022

DatelineCreatedAt 的话改成这个名

@trim21
Copy link
Contributor

trim21 commented Jun 4, 2022

倾向于先加私有API,让前端开发者吐槽一下之后再做公开API

@fdkevin0
Copy link
Contributor Author

fdkevin0 commented Jun 4, 2022

倾向于先加私有API,让前端开发者吐槽一下之后再做公开API

私有API是指什么?

@trim21
Copy link
Contributor

trim21 commented Jun 4, 2022

@codecov
Copy link

codecov bot commented Jun 4, 2022

Codecov Report

Merging #170 (abd3578) into master (cad99f3) will decrease coverage by 2.15%.
The diff coverage is 29.58%.

❗ Current head abd3578 differs from pull request most recent head 6728440. Consider uploading reports for the commit 6728440 to get more accurate results

@@            Coverage Diff             @@
##           master     #170      +/-   ##
==========================================
- Coverage   47.41%   45.26%   -2.16%     
==========================================
  Files          97      101       +4     
  Lines        5559     6279     +720     
==========================================
+ Hits         2636     2842     +206     
- Misses       2651     3159     +508     
- Partials      272      278       +6     
Impacted Files Coverage Δ
internal/model/type.go 100.00% <ø> (ø)
internal/strparse/convert.go 75.60% <0.00%> (-3.88%) ⬇️
internal/web/handler/character.go 32.18% <0.00%> (-3.72%) ⬇️
internal/web/handler/comments.go 0.00% <0.00%> (ø)
internal/web/handler/episode.go 0.00% <0.00%> (ø)
internal/web/handler/group_private.go 53.43% <0.00%> (-10.79%) ⬇️
internal/web/handler/index.go 25.17% <0.00%> (-3.99%) ⬇️
internal/web/handler/person.go 35.44% <0.00%> (-4.28%) ⬇️
internal/web/handler/query_parse.go 25.88% <0.00%> (-3.46%) ⬇️
internal/web/handler/subject.go 28.80% <0.00%> (-5.18%) ⬇️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cad99f3...6728440. Read the comment docs.

@trim21
Copy link
Contributor

trim21 commented Jun 15, 2022

所以这个分页是按照一级回复来的吗

@fdkevin0
Copy link
Contributor Author

fdkevin0 commented Jun 15, 2022

现在是二级回复,不过感觉分页真的是大麻烦,感觉 #53 (comment) 这样是比较合适的,亦或者重新设计数据库结构?

@fdkevin0
Copy link
Contributor Author

当前好像有三个 Issue 是讨论帖相关的了,需不需要合并下
#53
#67
#25

@trim21
Copy link
Contributor

trim21 commented Jun 15, 2022

重新设计数据库不太现实。

bangumi现在的浏览习惯是按照一级回复的时间顺序进行的,能不能看到二级回复只决于一级回复的位置。

感觉直接按照一级回复分页,然后二级回复不分页了,获取到某个一级回复的时候把对应的二级回复全都返回好了。

@trim21
Copy link
Contributor

trim21 commented Jun 15, 2022

@Ayase-252 觉得如何

@fdkevin0
Copy link
Contributor Author

要不然直接兼容两种模式,时间线和二级回复两种,让用户自己来选择?

@trim21
Copy link
Contributor

trim21 commented Jun 15, 2022

没必要时间线吧

@fdkevin0
Copy link
Contributor Author

时间线可以更快找到最新的回复,方便时间逆序,类似 V2ex,带个回复的对象这样

@trim21
Copy link
Contributor

trim21 commented Jun 15, 2022

有对应的前端功能再做吧。现在没啥必要

@Ayase-252
Copy link

如果按现在的,一级评论分页,二级评论不分没啥问题。

@trim21
Copy link
Contributor

trim21 commented Jun 21, 2022

/ping

@trim21
Copy link
Contributor

trim21 commented Jun 24, 2022

小组的公开ID是个 string,跟其他的怎么统一一下...

@trim21
Copy link
Contributor

trim21 commented Jun 28, 2022

抱歉,发现 gorm/gen 这边还是不要用 CreatedAtUpdatedAt 了,如果后面要 insert 或者 update 的话有可能 gorm 会自动更改这两列的值。用 UpdatedTimeCreatedTime 吧。API 的响应不用改。

title: Created At
type: string
format: date-time

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[diff] reported by reviewdog 🐶

Suggested change

@fdkevin0
Copy link
Contributor Author

小组的公开ID是个 string,跟其他的怎么统一一下...

namestring吧,ID还是int,这边兼容下同时支持namegroup_id好了

@trim21
Copy link
Contributor

trim21 commented Jun 29, 2022

在handler里面转一下吧,暴露出的API支持小组使用name

@trim21 trim21 mentioned this pull request Jul 11, 2022
@trim21
Copy link
Contributor

trim21 commented Jul 11, 2022

话说你还做吗,不做的话我就自己实现了...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

获取条目讨论
4 participants