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

Feature/#152 forward article #169

Merged

Conversation

titaneric
Copy link
Contributor

👏 解決掉的 issue / Resolved Issues

⛏ 變更內容 / Details of Changes

Route

  • 在delivery/http/route.go中的postBoards method,針對action = "forward_article" 呼叫delivery.ForwardArticle
  • 在delivery/http裡新增route_forward_article.go實作ForwardArticle method,呼叫usecase.ForwardArticle
  • 在usecase/token.go 新增PermissionForwardArticle 權限
  • 在uscase/usecase.go新增ForwardArticle method至Usecase interface
  • 在usecase/article.go裡面新增ForwardArticle method

Test

  • 在delivery/http/route_article_test.go裡面新增forwardArticle mock test method
  • 在delivery/http裡新增route_forward_article_test.go
  • 更新swagger.yml action 內容

@codecov-io
Copy link

codecov-io commented Apr 9, 2021

Codecov Report

Merging #169 (c8f4bbb) into development (17e0da1) will increase coverage by 1.20%.
The diff coverage is 70.73%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development     #169      +/-   ##
===============================================
+ Coverage        40.20%   41.40%   +1.20%     
===============================================
  Files               22       23       +1     
  Lines             1000     1041      +41     
===============================================
+ Hits               402      431      +29     
- Misses             539      547       +8     
- Partials            59       63       +4     
Impacted Files Coverage Δ
internal/usecase/article.go 33.33% <0.00%> (-6.67%) ⬇️
internal/usecase/token.go 0.00% <ø> (ø)
internal/usecase/usecase.go 100.00% <ø> (ø)
internal/delivery/http/route_forward_article.go 70.27% <70.27%> (ø)
internal/delivery/http/route.go 62.83% <100.00%> (+1.01%) ⬆️

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 17e0da1...c8f4bbb. Read the comment docs.

@@ -54,6 +54,8 @@ type Usecase interface {
// GetPopularArticles returns all popular articles
GetPopularArticles(ctx context.Context) ([]repository.PopularArticleRecord, error)
AppendComment(ctx context.Context, userID, boardID, filename, appendType, text string) (map[string]interface{}, error)
// ForwardArticle returns forwarding results
ForwardArticle(ctx context.Context, userID, boardID, filename, toEmail, toBoard string) (map[string]interface{}, error)
Copy link
Member

Choose a reason for hiding this comment

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

Email 和 Board 應該可以拆成兩個 method 比較好,一來是不太會同時兩個都填參數,而來是如果未來要新增新的 Forward 目標時,可以單純新增新的 method 這樣。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

沒問題,我改看看

@PichuChen
Copy link
Member

related to #155

@Ptt-official-app Ptt-official-app deleted a comment from PichuChen Apr 12, 2021
@titaneric
Copy link
Contributor Author

@PichuChen 已修改,目前改成用interface, @AmberFu 在實作 #155 可以參考一下,雖然好像順便做掉了QQ。
對Golang還不算熟悉,有更好的方式請指正,謝謝。

@@ -15,6 +15,8 @@ const (
PermissionReadTreasureInformation Permission = "READ_TREASURE_INFORMATION"
PermissionReadFavorite Permission = "READ_FAVORITE"
PermissionAppendComment Permission = "APPEND_COMMENT"
PermissionForwardArticleOut Permission = "FORWARD_ARTICLE"
PermissionForwardArticleTo Permission = "FORWARD_ARTICLE"
Copy link
Member

Choose a reason for hiding this comment

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

這邊兩個Key值一樣但是用了不一樣的變數名稱應該不太好?應該不用分Out和TO, 直接在註解下去說明這個權限主要是判斷可不可以轉出這樣?

Copy link
Contributor Author

@titaneric titaneric Apr 13, 2021

Choose a reason for hiding this comment

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

Sorry,這邊有點寫錯,應該key要不一樣的,會照你意思新增PermissionAddArticle,我再試著修改。

@@ -54,6 +54,8 @@ type Usecase interface {
// GetPopularArticles returns all popular articles
GetPopularArticles(ctx context.Context) ([]repository.PopularArticleRecord, error)
AppendComment(ctx context.Context, userID, boardID, filename, appendType, text string) (map[string]interface{}, error)
// ForwardArticle returns forwarding results
ForwardArticle(ctx context.Context, userID, boardID, filename string, to Forward) (map[string]interface{}, error)
Copy link
Member

Choose a reason for hiding this comment

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

這邊應該暫時還不需要這麼複雜...

Forward 另外拉成物件來實作的這件事應該要另外開ISSUE討論

@@ -54,6 +54,8 @@ type Usecase interface {
// GetPopularArticles returns all popular articles
GetPopularArticles(ctx context.Context) ([]repository.PopularArticleRecord, error)
AppendComment(ctx context.Context, userID, boardID, filename, appendType, text string) (map[string]interface{}, error)
// ForwardArticle returns forwarding results
ForwardArticle(ctx context.Context, userID, boardID, filename string, to Forward) (map[string]interface{}, error)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ForwardArticle(ctx context.Context, userID, boardID, filename string, to Forward) (map[string]interface{}, error)
ForwardArticleToBoard(ctx context.Context, userID, boardID, filename string, boardName string) (map[string]interface{}, error)
ForwardArticleToEmail(ctx context.Context, userID, boardID, filename string, email string) (map[string]interface{}, error)

@titaneric
Copy link
Contributor Author

@PichuChen 已更新

Copy link
Member

@PichuChen PichuChen left a comment

Choose a reason for hiding this comment

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

LGTM

@y2468101216
Copy link
Collaborator

LGTM

應該要討論一下轉板跟轉信是否要拆開成兩個API實作

Copy link
Contributor

@SivWatt SivWatt left a comment

Choose a reason for hiding this comment

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

LGTM

@PichuChen PichuChen merged commit ca596de into Ptt-official-app:development Apr 15, 2021
@PichuChen
Copy link
Member

LGTM

應該要討論一下轉板跟轉信是否要拆開成兩個API實作

在Usecase中確實是分兩個,其實本來就是分兩個,只是不小心在delivery做起來了

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.

[主線] [PTT] 實作轉錄看板文章 -- delivery/http
6 participants