File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55
66## 获取所有诗词接口
77URL:
8- > GET http://localhost:5000/plugin/poem/demo/ all
8+ > GET http://localhost:5000/plugin/poem/all
99
1010Parameters:
1111- count: (可选)获取的数量,最小1,最大100,默认5
@@ -15,26 +15,63 @@ Response:
1515``` json
1616[
1717 {
18- "author" : " 苏轼" ,
19- "content" : " 一别都门三改火/天涯踏尽红尘/依然一笑作春温/无波真古井/有节是秋筠/惆怅孤帆连夜发/送行淡月微云/尊前不用翠眉颦/人生如逆旅/我亦是行人" ,
18+ "author" : " 欧阳修" ,
19+ "content" : [
20+ [
21+ " 去年元夜时" ,
22+ " 花市灯如昼" ,
23+ " 月上柳梢头" ,
24+ " 人约黄昏后"
25+ ],
26+ [
27+ " 今年元夜时" ,
28+ " 月与灯依旧" ,
29+ " 不见去年人" ,
30+ " 泪湿春衫袖"
31+ ]
32+ ],
2033 "create_time" : 1549438754000 ,
2134 "dynasty" : " 宋代" ,
22- "id" : 2 ,
35+ "id" : 1 ,
2336 "image" : " " ,
24- "title" : " 临江仙·送钱穆父 "
37+ "title" : " 生查子·元夕 "
2538 },
2639 {
2740 "author" : " 苏轼" ,
28- "content" : " 花褪残红青杏小/燕子飞时/绿水人家绕/枝上柳绵吹又少/天涯何处无芳草/墙里秋千墙外道/墙外行人/墙里佳人笑/笑渐不闻声渐悄/多情却被无情恼" ,
41+ "content" : [
42+ [
43+ " 一别都门三改火" ,
44+ " 天涯踏尽红尘" ,
45+ " 依然一笑作春温" ,
46+ " 无波真古井" ,
47+ " 有节是秋筠"
48+ ],
49+ [
50+ " 惆怅孤帆连夜发" ,
51+ " 送行淡月微云" ,
52+ " 尊前不用翠眉颦" ,
53+ " 人生如逆旅" ,
54+ " 我亦是行人"
55+ ]
56+ ],
2957 "create_time" : 1549438754000 ,
3058 "dynasty" : " 宋代" ,
31- "id" : 8 ,
59+ "id" : 2 ,
3260 "image" : " " ,
33- "title" : " 蝶恋花·春景 "
61+ "title" : " 临江仙·送钱穆父 "
3462 }
3563]
3664```
3765
66+ Response_description:
67+ - author: 作者
68+ - content: 内容。是一个二维数组,第一维数组用来区分词的每一阙(如果是古诗,那么第一维数组中只有一个元素),第二维数组用来区分古诗词的每一句。
69+ - create_time: 创建时间
70+ - dynasty: 作者所属朝代
71+ - id: id号码
72+ - image: 配图
73+ - title: 标题
74+
3875
3976## 获取所有作者接口
4077URL:
@@ -51,33 +88,3 @@ Response:
5188 " 薛涛"
5289]
5390```
54-
55- ## 搜索诗词接口
56- > GET http://localhost:5000/plugin/poem/search?q=浣溪沙
57-
58- Parameters:
59- - q: (必填)查询关键字
60-
61- Response:
62- ``` json
63- [
64- {
65- "author" : " 晏殊" ,
66- "content" : " 一曲新词酒一杯/去年天气旧亭台/夕阳西下几时回/无可奈何花落去/似曾相识燕归来/小园香径独徘徊" ,
67- "create_time" : 1549438754000 ,
68- "dynasty" : " 宋代" ,
69- "id" : 6 ,
70- "image" : " " ,
71- "title" : " 浣溪沙·一曲新词酒一杯"
72- },
73- {
74- "author" : " 纳兰性德" ,
75- "content" : " 残雪凝辉冷画屏/落梅横笛已三更/更无人处月胧明/我是人间惆怅客/知君何事泪纵横/断肠声里忆平生" ,
76- "create_time" : 1549438754000 ,
77- "dynasty" : " 清代" ,
78- "id" : 7 ,
79- "image" : " " ,
80- "title" : " 浣溪沙·残雪凝辉冷画屏"
81- }
82- ]
83- ```
Original file line number Diff line number Diff line change @@ -10,9 +10,17 @@ class Poem(Base):
1010 title = Column (String (50 ), nullable = False , comment = '标题' )
1111 author = Column (String (50 ), default = '未名' , comment = '作者' )
1212 dynasty = Column (String (50 ), default = '未知' , comment = '朝代' )
13- content = Column (Text , nullable = False , comment = '内容' )
13+ _content = Column ('content' , Text , nullable = False , comment = '内容,以/来分割每一句,以|来分割宋词的上下片 ' )
1414 image = Column (String (255 ), default = '' , comment = '配图' )
1515
16+ @property
17+ def content (self ):
18+ ret = []
19+ lis = self ._content .split ('|' )
20+ for x in lis :
21+ ret .append (x .split ('/' ))
22+ return ret
23+
1624 def get_all (self , form ):
1725 query = self .query .filter_by (delete_time = None )
1826
You can’t perform that action at this time.
0 commit comments