Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 902e0e4

Browse files
committed
refactor: naming
1 parent 81e4436 commit 902e0e4

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

cover/excoveralls.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

lib/groupher_server/cms/cms.ex

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ defmodule GroupherServer.CMS do
1010
alias Delegate.{
1111
AbuseReport,
1212
ArticleCURD,
13-
ArticleOperation,
13+
ArticleCommunity,
1414
ArticleEmotion,
1515
ArticleComment,
1616
ArticleCollect,
@@ -97,21 +97,21 @@ defmodule GroupherServer.CMS do
9797
defdelegate set_collect_folder(collect, folder), to: ArticleCollect
9898
defdelegate undo_set_collect_folder(collect, folder), to: ArticleCollect
9999

100-
# ArticleOperation
100+
# ArticleCommunity
101101
# >> set flag on article, like: pin / unpin article
102-
defdelegate set_community_flags(community_info, queryable, attrs), to: ArticleOperation
103-
defdelegate pin_article(thread, id, community_id), to: ArticleOperation
104-
defdelegate undo_pin_article(thread, id, community_id), to: ArticleOperation
102+
defdelegate set_community_flags(community_info, queryable, attrs), to: ArticleCommunity
103+
defdelegate pin_article(thread, id, community_id), to: ArticleCommunity
104+
defdelegate undo_pin_article(thread, id, community_id), to: ArticleCommunity
105105

106-
defdelegate lock_article_comment(content), to: ArticleOperation
106+
defdelegate lock_article_comment(content), to: ArticleCommunity
107107

108108
# >> tag: set / unset
109-
defdelegate set_tag(thread, tag, content_id), to: ArticleOperation
110-
defdelegate unset_tag(thread, tag, content_id), to: ArticleOperation
109+
defdelegate set_tag(thread, tag, content_id), to: ArticleCommunity
110+
defdelegate unset_tag(thread, tag, content_id), to: ArticleCommunity
111111
# >> community: set / unset
112-
defdelegate set_community(thread, article_id, community_id), to: ArticleOperation
113-
defdelegate unset_community(thread, article_id, community_id), to: ArticleOperation
114-
defdelegate move_article(thread, article_id, community_id), to: ArticleOperation
112+
defdelegate set_community(thread, article_id, community_id), to: ArticleCommunity
113+
defdelegate unset_community(thread, article_id, community_id), to: ArticleCommunity
114+
defdelegate move_article(thread, article_id, community_id), to: ArticleCommunity
115115

116116
defdelegate emotion_to_article(thread, article_id, args, user), to: ArticleEmotion
117117
defdelegate undo_emotion_to_article(thread, article_id, args, user), to: ArticleEmotion

lib/groupher_server/cms/delegates/article_operation.ex renamed to lib/groupher_server/cms/delegates/article_community.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule GroupherServer.CMS.Delegate.ArticleOperation do
1+
defmodule GroupherServer.CMS.Delegate.ArticleCommunity do
22
@moduledoc """
33
set / unset operations for Article-like resource
44
"""
@@ -8,7 +8,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleOperation do
88

99
import Helper.ErrorCode
1010
import ShortMaps
11-
import Helper.Utils, only: [strip_struct: 1, integerfy: 1, done: 1]
11+
import Helper.Utils, only: [strip_struct: 1, done: 1]
1212
import GroupherServer.CMS.Helper.Matcher2
1313

1414
alias Helper.Types, as: T

lib/groupher_server/cms/delegates/article_curd.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
2020
alias Accounts.User
2121
alias CMS.{Author, Community, PinnedArticle, Embeds, Delegate, Tag}
2222

23-
alias Delegate.ArticleOperation
23+
alias Delegate.ArticleCommunity
2424

2525
alias Ecto.Multi
2626

@@ -133,7 +133,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
133133
do_create_article(action.target, attrs, author, community)
134134
end)
135135
|> Multi.run(:set_community, fn _, %{create_article: article} ->
136-
ArticleOperation.set_community(thread, article.id, community.id)
136+
ArticleCommunity.set_community(thread, article.id, community.id)
137137
end)
138138
|> Multi.run(:set_community_flag, fn _, %{create_article: article} ->
139139
exec_set_community_flag(community, article, action)
@@ -186,10 +186,10 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
186186
ORM.update(content, args)
187187
end)
188188
|> Multi.run(:update_edit_status, fn _, %{update_article: update_article} ->
189-
ArticleOperation.update_edit_status(update_article)
189+
ArticleCommunity.update_edit_status(update_article)
190190
end)
191191
|> Multi.run(:update_tag, fn _, _ ->
192-
# TODO: move it to ArticleOperation module
192+
# TODO: move it to ArticleCommunity module
193193
exec_update_tags(content, args)
194194
end)
195195
|> Repo.transaction()
@@ -399,7 +399,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
399399
defp exec_set_tag(thread, id, %{tags: tags}) do
400400
try do
401401
Enum.each(tags, fn tag ->
402-
{:ok, _} = ArticleOperation.set_tag(thread, %Tag{id: tag.id}, id)
402+
{:ok, _} = ArticleCommunity.set_tag(thread, %Tag{id: tag.id}, id)
403403
end)
404404

405405
{:ok, "psss"}
@@ -412,7 +412,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
412412

413413
# TODO: flag 逻辑似乎有问题
414414
defp exec_set_community_flag(%Community{} = community, content, %{flag: _flag}) do
415-
ArticleOperation.set_community_flags(community, content, %{
415+
ArticleCommunity.set_community_flags(community, content, %{
416416
trash: false
417417
})
418418
end

0 commit comments

Comments
 (0)