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.

Commitbfdaae4

Browse files
committed
refactor(rss): blog create logic wip
1 parentfba92d5 commitbfdaae4

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ defmodule GroupherServer.CMS.Delegate.BlogCURD do
55
importEcto.Query,warn:false
66
importHelper.Utils,only:[strip_struct:1]
77

8+
importGroupherServer.CMS.Delegate.ArticleCURD,only:[create_article:4]
89
# import Helper.Utils, only: [done: 1]
910

1011
# import Helper.ErrorCode
@@ -40,7 +41,6 @@ defmodule GroupherServer.CMS.Delegate.BlogCURD do
4041
# IO.inspect(feed, label: "create blog")
4142
# 通过 feed 有没有 id 来 insert / update
4243
# 通过 blog_title, 组合 attrs 传给 create_article
43-
{:ok,:pass}
4444
end
4545

4646
# 2. 创建 blog
@@ -50,12 +50,30 @@ defmodule GroupherServer.CMS.Delegate.BlogCURD do
5050
# 前台获取作者信息的时候从 rss 表读取
5151
end
5252

53-
defpdo_create_blog(%Community{id:cid},attrs,%User{id:uid},%{id:id}=feed)do
53+
defpdo_create_blog(%Community{}=community,attrs,%User{}=user,%{id:_}=feed)do
5454
IO.inspect("rss 记录存在, 直接创建 blog",label:"do_create_blog")
55+
56+
# author = feed.author
57+
selected_feed=Enum.find(feed.history_feed,&(&1.title==attrs.title))
58+
IO.inspect(selected_feed,label:"target feed")
59+
IO.inspect(feed,label:"the author")
60+
# IO.inspect(feed, label: "feed -")
61+
62+
attrs=
63+
attrs
64+
|>Map.merge(%{link_addr:selected_feed.link_addr,published:selected_feed.published})
65+
66+
IO.inspect(attrs,label:"attrs -")
67+
create_article(community,:blog,attrs,user)
68+
# arg(:title, non_null(:string))
69+
# arg(:body, non_null(:string))
70+
# arg(:community_id, non_null(:id))
71+
# arg(:link_addr, :string)
5572
end
5673

5774
defpdo_create_blog(%Community{id:cid},attrs,%User{id:uid},feed)do
5875
IO.inspect("rss 记录不存在, 先创建 rss, 再创建 blog",label:"do_create_blog")
76+
{:ok,:pass}
5977
end
6078

6179
defcreate_blog_rss(attrs)do

‎test/groupher_server/cms/article_tags/post_tag_test.exs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ defmodule GroupherServer.Test.CMS.ArticleTag.PostTag do
139139
assertnotexist_in?(article_tag2,post.article_tags)
140140
end
141141

142-
test"can not set dup tag ",~m(community post article_tag_attrsarticle_tag_attrs2user)ado
142+
test"can not set dup tag ",~m(community post article_tag_attrs user)ado
143143
{:ok,article_tag}=CMS.create_article_tag(community,:post,article_tag_attrs,user)
144144
{:ok,post}=CMS.set_article_tag(:post,post.id,article_tag.id)
145145
{:ok,post}=CMS.set_article_tag(:post,post.id,article_tag.id)

‎test/groupher_server/seeds/clean_up_test.exs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ defmodule GroupherServer.Test.Seeds.CleanUp do
2222
describe"[community clean up]"do
2323
test"can clean up a community",~m(user post_attrs)ado
2424
{:ok,community}=CMS.seed_community(:home)
25-
{:ok,post}=CMS.create_article(community,:post,post_attrs,user)
25+
{:ok,_post}=CMS.create_article(community,:post,post_attrs,user)
2626

2727
{:ok,found}=ORM.find_all(ArticleTag,%{page:1,size:20})
2828
assertfound.total_count!==0

‎test/helper/rss_test.exs‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,20 @@ defmodule GroupherServer.Test.Helper.RSSTest do
2222
{:ok,feed}=CMS.blog_rss_feed(@rss)
2323
{:ok,_rss_record}=CMS.create_blog_rss(feed)
2424

25-
blog_attrs=mock_attrs(:blog,%{community_id:community.id})
25+
selected_feed=feed.history_feed|>List.first()
26+
title=selected_feed|>Map.get(:title)
27+
link_addr=selected_feed|>Map.get(:link_addr)
28+
# blog_attrs = mock_attrs(:blog, %{community_id: community.id})
29+
blog_attrs=%{
30+
rss:@rss,
31+
title:title,
32+
body:mock_rich_text("pleace use content field instead")
33+
}
2634

27-
blog_attrs=%{rss:@rss}
2835
{:ok,blog}=CMS.create_blog(community,blog_attrs,user)
36+
assertblog.title==title
37+
assertblog.link_addr==link_addr
38+
# blog
2939
end
3040
end
3141

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp