Skip to content

Commit e631ad4

Browse files
committed
fix: 修改古诗词内容未区分上下阙的问题
1 parent b612cdb commit e631ad4

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

app/plugins/poem/app/model.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff 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

@@ -26,6 +34,7 @@ def get_all(self, form):
2634

2735
if not poems:
2836
raise NotFound(msg='没有找到相关诗词')
37+
2938
return poems
3039

3140
def search(self, q):

0 commit comments

Comments
 (0)