Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commitb156819

Browse files
committed
refactor(cms-mutations): extract trash/undo_trash mutation
1 parent4710244 commitb156819

File tree

4 files changed

+33
-78
lines changed

4 files changed

+33
-78
lines changed

‎lib/groupher_server_web/schema/Helper/mutations.ex‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,34 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
5454
end
5555
end
5656
end
57+
58+
defmacroarticle_trash_mutation(thread)do
59+
quotedo
60+
@descunquote("trash a#{thread}, not delete")
61+
fieldunquote(:"trash_#{thread}"),unquote(thread)do
62+
arg(:id,non_null(:id))
63+
arg(:community_id,non_null(:id))
64+
arg(:thread,unquote(:"#{thread}_thread"),default_value:unquote(thread))
65+
66+
middleware(M.Authorize,:login)
67+
middleware(M.PassportLoader,source::community)
68+
middleware(M.Passport,claim:unquote("cms->c?->#{to_string(thread)}.trash"))
69+
70+
resolve(&R.CMS.trash_content/3)
71+
end
72+
73+
@descunquote("undo trash a#{thread}, not delete")
74+
fieldunquote(:"undo_trash_#{thread}"),unquote(thread)do
75+
arg(:id,non_null(:id))
76+
arg(:community_id,non_null(:id))
77+
arg(:thread,unquote(:"#{thread}_thread"),default_value:unquote(thread))
78+
79+
middleware(M.Authorize,:login)
80+
middleware(M.PassportLoader,source::community)
81+
middleware(M.Passport,claim:unquote("cms->c?->#{to_string(thread)}.undo_trash"))
82+
83+
resolve(&R.CMS.undo_trash_content/3)
84+
end
85+
end
86+
end
5787
end

‎lib/groupher_server_web/schema/cms/mutations/job.ex‎

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -73,34 +73,9 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Job do
7373
#############
7474
article_upvote_mutation(:job)
7575
article_pin_mutation(:job)
76+
article_trash_mutation(:job)
7677
#############
7778

78-
@desc"trash a job, not delete"
79-
field:trash_job,:jobdo
80-
arg(:id,non_null(:id))
81-
arg(:thread,:job_thread,default_value::job)
82-
arg(:community_id,non_null(:id))
83-
84-
middleware(M.Authorize,:login)
85-
middleware(M.PassportLoader,source::community)
86-
middleware(M.Passport,claim:"cms->c?->job.trash")
87-
88-
resolve(&R.CMS.trash_content/3)
89-
end
90-
91-
@desc"trash a job, not delete"
92-
field:undo_trash_job,:jobdo
93-
arg(:id,non_null(:id))
94-
arg(:thread,:job_thread,default_value::job)
95-
arg(:community_id,non_null(:id))
96-
97-
middleware(M.Authorize,:login)
98-
middleware(M.PassportLoader,source::community)
99-
middleware(M.Passport,claim:"cms->c?->job.undo_trash")
100-
101-
resolve(&R.CMS.undo_trash_content/3)
102-
end
103-
10479
@desc"delete a job"
10580
field:delete_job,:jobdo
10681
arg(:id,non_null(:id))

‎lib/groupher_server_web/schema/cms/mutations/post.ex‎

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,34 +47,9 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Post do
4747
#############
4848
article_upvote_mutation(:post)
4949
article_pin_mutation(:post)
50+
article_trash_mutation(:post)
5051
#############
5152

52-
@desc"trash a post, not delete"
53-
field:trash_post,:postdo
54-
arg(:id,non_null(:id))
55-
arg(:thread,:post_thread,default_value::post)
56-
arg(:community_id,non_null(:id))
57-
58-
middleware(M.Authorize,:login)
59-
middleware(M.PassportLoader,source::community)
60-
middleware(M.Passport,claim:"cms->c?->post.trash")
61-
62-
resolve(&R.CMS.trash_content/3)
63-
end
64-
65-
@desc"trash a post, not delete"
66-
field:undo_trash_post,:postdo
67-
arg(:id,non_null(:id))
68-
arg(:thread,:post_thread,default_value::post)
69-
arg(:community_id,non_null(:id))
70-
71-
middleware(M.Authorize,:login)
72-
middleware(M.PassportLoader,source::community)
73-
middleware(M.Passport,claim:"cms->c?->post.undo_trash")
74-
75-
resolve(&R.CMS.undo_trash_content/3)
76-
end
77-
7853
@desc"delete a cms/post"
7954
# TODO: if post belongs to multi communities, unset instead delete
8055
field:delete_post,:postdo

‎lib/groupher_server_web/schema/cms/mutations/repo.ex‎

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -72,34 +72,9 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Repo do
7272

7373
#############
7474
article_pin_mutation(:repo)
75+
article_trash_mutation(:repo)
7576
#############
7677

77-
@desc"trash a repo, not delete"
78-
field:trash_repo,:repodo
79-
arg(:id,non_null(:id))
80-
arg(:thread,:repo_thread,default_value::repo)
81-
arg(:community_id,non_null(:id))
82-
83-
middleware(M.Authorize,:login)
84-
middleware(M.PassportLoader,source::community)
85-
middleware(M.Passport,claim:"cms->c?->repo.trash")
86-
87-
resolve(&R.CMS.trash_content/3)
88-
end
89-
90-
@desc"trash a repo, not delete"
91-
field:undo_trash_repo,:repodo
92-
arg(:id,non_null(:id))
93-
arg(:thread,:repo_thread,default_value::repo)
94-
arg(:community_id,non_null(:id))
95-
96-
middleware(M.Authorize,:login)
97-
middleware(M.PassportLoader,source::community)
98-
middleware(M.Passport,claim:"cms->c?->repo.undo_trash")
99-
100-
resolve(&R.CMS.undo_trash_content/3)
101-
end
102-
10378
@desc"delete a repo"
10479
field:delete_repo,:repodo
10580
arg(:id,non_null(:id))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp