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

WIP: Indices #231

Closed
wants to merge 14 commits into from
Closed

WIP: Indices #231

wants to merge 14 commits into from

Conversation

RanKKI
Copy link
Member

@RanKKI RanKKI commented Oct 4, 2022

讨论 Issue #230

[POST] /indices 新建目录
请求数据

{
    "title": "标题信息",
    "description": "目录介绍"
}

返回数据

{
    "created_at": "2022-10-06T13:10:25+08:00",
    "update_at": "2022-10-06T13:10:25+08:00",
    "creator": {
        "username": "382951",
        "nickname": "树洞酱"
    },
    "title": "本地测试",
    "description": "这里是目录的介绍,12345123123",
    "total": 0,
    "id": 15471,
    "stat": {
        "comments": 0,
        "collects": 0
    },
    "ban": false,
    "nsfw": false
}

[PUT] /indices/<index_id> 修改目录
请求数据

{
    "title": "标题信息",
    "description": "目录介绍"
}

返回数据
, 200 代表修改成功

[DELETE] /indices/<index_id> 删除目录
请求数据

返回数据
, 200 代表修改成功

[POST] /indices/<index_id>/subjects 在目录中增加条目
请求数据

{
    "subject_id": 5,
    "sort": 13,
    "comment": "测试 comment"
}

返回数据

{
    "added_at": "2022-10-07T12:28:08+08:00",
    "date": null,
    "images": {
        "small": "https://lain.bgm.tv/pic/cover/s/e4/da/5_wUARf.jpg",
        "grid": "https://lain.bgm.tv/pic/cover/g/e4/da/5_wUARf.jpg",
        "large": "https://lain.bgm.tv/pic/cover/l/e4/da/5_wUARf.jpg",
        "medium": "https://lain.bgm.tv/pic/cover/m/e4/da/5_wUARf.jpg",
        "common": "https://lain.bgm.tv/pic/cover/c/e4/da/5_wUARf.jpg"
    },
    "name": "Call of Duty 4",
    "name_cn": "使命召唤 4: 现代战争",
    "comment": "测试 comment",
    "infobox": [],
    "id": 5,
    "type": 4
}

[PUT] /indices/<index_id>/subjects/<subject_id> 在目录中修改条目
请求数据

{
    "sort": 13,
    "comment": "测试 comment"
}

返回数据
, 200 代表修改成功

[DELETE] /indices/<index_id>/subjects/<subject_id> 在目录中删除条目
请求数据

返回数据
, 200 代表修改成功

[GET] /users//indices 获取用户创建的条目
请求数据

返回数据

[
    {
        "created_at": "2022-10-06T11:31:42+08:00",
        "update_at": "1970-01-01T08:00:00+08:00",
        "creator": {
            "username": "382951",
            "nickname": "树洞酱"
        },
        "title": "本地测试2",
        "description": "123",
        "total": 0,
        "id": 15467,
        "stat": {
            "comments": 0,
            "collects": 0
        },
        "ban": false,
        "nsfw": false
    }
]

[GET] /users//indices/collect 获取用户收藏的条目
请求数据

返回数据

{
    "user": {
        "username": "382951",
        "nickname": "树洞酱"
    },
    "indices": [
        {
            "created_at": "2022-10-06T11:31:42+08:00",
            "update_at": "1970-01-01T08:00:00+08:00",
            "creator": {
                "username": "382951",
                "nickname": "树洞酱"
            },
            "title": "本地测试2",
            "description": "123",
            "total": 0,
            "id": 15467,
            "stat": {
                "comments": 0,
                "collects": 0
            },
            "ban": false,
            "nsfw": false
        }
    ]
}

[POST] /indices/<index_id>/collect 收藏条目
请求数据

返回数据
, 200 代表修改成功,重复收藏会返回 202 (Accpeted)

[DELETE] /indices/<index_id>/collect 取消收藏条目
请求数据

返回数据
, 200 代表修改成功, 404 代表用户没有收藏该条目

@netlify
Copy link

netlify bot commented Oct 4, 2022

Deploy Preview for bangumi-org-server ready!

Name Link
🔨 Latest commit df9ab50
🔍 Latest deploy log https://app.netlify.com/sites/bangumi-org-server/deploys/634123cb695d1c0007aa7177
😎 Deploy Preview https://deploy-preview-231--bangumi-org-server.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@codecov
Copy link

codecov bot commented Oct 4, 2022

Codecov Report

Base: 49.72% // Head: 50.65% // Increases project coverage by +0.92% 🎉

Coverage data is based on head (b02c841) compared to base (3854514).
Patch coverage: 72.64% of modified lines in pull request are covered.

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #231      +/-   ##
==========================================
+ Coverage   49.72%   50.65%   +0.92%     
==========================================
  Files         197      197              
  Lines        7803     8073     +270     
==========================================
+ Hits         3880     4089     +209     
- Misses       3467     3505      +38     
- Partials      456      479      +23     
Impacted Files Coverage Δ
internal/web/handler/index.go 51.63% <71.05%> (+22.47%) ⬆️
internal/index/mysql_repository.go 66.98% <72.78%> (+12.56%) ⬆️
internal/web/handler.go 87.12% <100.00%> (+0.26%) ⬆️
internal/web/frontend/template_prod.go 37.50% <0.00%> (ø)
internal/auth/service.go 60.62% <0.00%> (+4.72%) ⬆️
internal/web/handler/common/access_token.go 81.81% <0.00%> (+22.72%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@trim21
Copy link
Contributor

trim21 commented Oct 6, 2022

desc改成description吧…

@trim21
Copy link
Contributor

trim21 commented Oct 7, 2022

[POST] /indices/<index_id>/subjects 不用返回条目信息了吧

@RanKKI
Copy link
Member Author

RanKKI commented Oct 7, 2022

[POST] /indices/<index_id>/subjects 不用返回条目信息了吧

我觉得加上比较合适。不像修改或者删除,信息都是已知或者只是移除。

新增之后如果需要在客户端增加内容或者展示啥东西,就可以省一个找信息的请求(比如 /indices/5/subject 或者 /subject/<subject_id>)

@trim21
Copy link
Contributor

trim21 commented Oct 7, 2022

也有道理。

@RanKKI
Copy link
Member Author

RanKKI commented Oct 8, 2022

删除目录之后,收藏目录列表应该怎么处理?是直接移除,还是告知该目录已被删除

@trim21
Copy link
Contributor

trim21 commented Oct 8, 2022

先不做(

@trim21
Copy link
Contributor

trim21 commented Oct 8, 2022

感觉这个PR一次加的东西有点多,要不先做目录条目增改删,其他的分开PR

@RanKKI
Copy link
Member Author

RanKKI commented Oct 8, 2022

感觉这个PR一次加的东西有点多,要不先做目录条目增改删,其他的分开PR

嗯, 我晚点有时间拆一下,目录本身的一个 pr,和用户相关的一个 pr

@trim21
Copy link
Contributor

trim21 commented Oct 8, 2022

sai老板目前给了目录条目的增改删权限,如果先做这个的话可以合并之后直接上线。然后目录表的增改还没给,大概可以跟前一个一起PR。

目录删除的话还要涉及目录留言和用户条目收藏两个表的删除权限,放在用户条目收藏API之后再PR比较好。(用户留言好像不删除,直接留在那也行,反正也看不到了)

没对应数据库权限的PR合了之后还要考虑额外加flag来启用,开发和部署都挺难受的…

@RanKKI RanKKI closed this Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants