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.

Commit9e05206

Browse files
author
mydearxym
committed
chore: wip
1 parent8ff259d commit9e05206

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

‎lib/groupher_server/cms/delegates/article_curd.ex‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
130130
end
131131
end
132132

133+
@specensure_author_exists(User.t())::{:ok,User.t()}
133134
defensure_author_exists(%User{}=user)do
134135
# unique_constraint: avoid race conditions, make sure user_id unique
135136
# foreign_key_constraint: check foreign key: user_id exsit or not

‎lib/groupher_server/cms/delegates/community_sync.ex‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
44
"""
55
importEcto.Query,warn:false
66
importHelper.ErrorCode
7+
importHelper.CommonTypes
78
# import ShortMaps
89

910
aliasHelper.ORM
@@ -17,6 +18,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
1718
@doc"""
1819
get wiki
1920
"""
21+
@specget_wiki(Community.t())::{:ok,CommunityWiki.t()}
2022
defget_wiki(%Community{raw:raw})do
2123
with{:ok,community}<-ORM.find_by(Community,raw:raw),
2224
{:ok,wiki}<-ORM.find_by(CommunityWiki,community_id:community.id)do
@@ -30,6 +32,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
3032
@doc"""
3133
get cheatsheet
3234
"""
35+
@specget_cheatsheet(Community.t())::{:ok,CommunityCheatsheet.t()}
3336
defget_cheatsheet(%Community{raw:raw})do
3437
with{:ok,community}<-ORM.find_by(Community,raw:raw),
3538
{:ok,wiki}<-ORM.find_by(CommunityCheatsheet,community_id:community.id)do
@@ -43,6 +46,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
4346
@doc"""
4447
sync wiki
4548
"""
49+
@specsync_github_content(Community.t(),atom)::{:ok,CommunityWiki.t()}
4650
defsync_github_content(%Community{id:id},:wiki,attrs)do
4751
with{:ok,community}<-ORM.find(Community,id)do
4852
attrs=Map.merge(attrs,%{community_id:community.id})
@@ -54,6 +58,7 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
5458
@doc"""
5559
sync cheatsheet
5660
"""
61+
@specsync_github_content(Community.t(),atom())::{:ok,CommunityCheatsheet.t()}
5762
defsync_github_content(%Community{id:id},:cheatsheet,attrs)do
5863
with{:ok,community}<-ORM.find(Community,id)do
5964
attrs=Map.merge(attrs,%{community_id:community.id})
@@ -65,10 +70,17 @@ defmodule GroupherServer.CMS.Delegate.CommunitySync do
6570
@doc"""
6671
add contributor to exsit wiki contributors list
6772
"""
73+
@specadd_contributor(Community.t(),github_contributor())::
74+
{:ok,CommunityWiki}|custom_error()
6875
defadd_contributor(%CommunityWiki{id:id},contributor_attrs)do
6976
do_add_contributor(CommunityWiki,id,contributor_attrs)
7077
end
7178

79+
@doc"""
80+
add contributor to exsit cheatsheet contributors list
81+
"""
82+
@specadd_contributor(Community.t(),github_contributor())::
83+
{:ok,CommunityCheatsheet}|custom_error()
7284
defadd_contributor(%CommunityCheatsheet{id:id},contributor_attrs)do
7385
do_add_contributor(CommunityCheatsheet,id,contributor_attrs)
7486
end

‎lib/helper/common_types.ex‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
defmoduleHelper.CommonTypesdo
2+
@moduledoc"""
3+
common types for lint
4+
"""
5+
6+
@typegithub_contributor::%{
7+
github_id:String.t(),
8+
avatar:String.t(),
9+
html_url:String.t(),
10+
nickname:String.t(),
11+
bio:nil|String.t(),
12+
location:nil|String.t(),
13+
company:nil|String.t()
14+
}
15+
16+
@typecustom_error::{:error,[message:String.t(),code:Number.t()]}
17+
end

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp