mirror of
https://github.com/tgbot-collection/YYeTsBot.git
synced 2025-11-25 03:15:05 +08:00
announcement support
This commit is contained in:
2
API.md
2
API.md
@@ -594,7 +594,7 @@
|
||||
|
||||
## 获取公告
|
||||
|
||||
* GET `/api/announcmement`,接受URL参数 size、page
|
||||
* GET `/api/announcement`,接受URL参数 size、page
|
||||
|
||||
```json
|
||||
{
|
||||
|
||||
2
YYeTsFE
2
YYeTsFE
Submodule YYeTsFE updated: fd7abcb1f1...c19a3bb778
@@ -85,11 +85,14 @@ class AnnouncementMongoResource(AnnouncementResource, Mongo):
|
||||
def get_announcement(self, page: int, size: int) -> dict:
|
||||
condition = {}
|
||||
count = self.db["announcement"].count_documents(condition)
|
||||
data = self.db["announcement"].find(condition, projection={"_id": False, "ip": False}) \
|
||||
data = self.db["announcement"].find(condition, projection={"_id": True, "ip": False}) \
|
||||
.sort("_id", pymongo.DESCENDING).limit(size).skip((page - 1) * size)
|
||||
|
||||
data = list(data)
|
||||
for i in data:
|
||||
i["id"] = str(i["_id"])
|
||||
i.pop("_id")
|
||||
return {
|
||||
"data": list(data),
|
||||
"data": data,
|
||||
"count": count,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user