Skip to content

Commit dcb062f

Browse files
committed
feat: 增加了config配置项
1 parent 0c9488f commit dcb062f

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

app/plugins/poem/app/model.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
from lin.core import lin_config
12
from lin.exception import NotFound
23
from lin.interface import InfoCrud as Base
3-
from sqlalchemy import Column, String, Integer
4+
from sqlalchemy import Column, String, Integer, Text
45

56

67
class Poem(Base):
78
id = Column(Integer, primary_key=True, autoincrement=True)
89
title = Column(String(50), nullable=False, comment='标题')
910
author = Column(String(50), default='未名', comment='作者')
1011
dynasty = Column(String(50), default='位置', comment='朝代')
11-
content = Column(String(255), nullable=False, comment='内容')
12+
content = Column(Text, nullable=False, comment='内容')
13+
image = Column(String(255), default='', comment='配图')
1214

1315
def get_all(self):
14-
poems = self.query.filter_by(delete_time=None).all()
16+
poems = self.query.filter_by(delete_time=None).limit(
17+
lin_config.get_config('poem.limit')
18+
).all()
1519
if not poems:
1620
raise NotFound(msg='没有找到相关诗词')
1721
return poems

app/plugins/poem/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
limit = 20

0 commit comments

Comments
 (0)