change to get

This commit is contained in:
Jeremy Yin 2024-03-15 22:42:53 +08:00
parent 78e3c6d174
commit cec5266655
2 changed files with 6 additions and 6 deletions

View File

@ -95,13 +95,13 @@ async def get_user_chat_history(request: Request, req: GetUserChatHistoryInput)
return res return res
@app.post("/api/v1/get_chat_status_today") @app.get("/api/v1/get_chat_status_today")
async def get_chat_status_today(request: Request, req: GetChatStatusTodayInput) -> GetChatStatusTodayOutput: async def get_chat_status_today(request: Request, user_name: str) -> GetChatStatusTodayOutput:
pvd = Providers(db=request.app.db) pvd = Providers(db=request.app.db)
user = await pvd.user.get_user_by_name(req.user_name) user = await pvd.user.get_user_by_name(user_name)
if not user: if not user:
raise UserNotFoundError(req.user_name) raise UserNotFoundError(user_name)
ctx = Context(user=user) ctx = Context(user=user)
svc = Services(ctx, pvd) svc = Services(ctx, pvd)
res = await svc.chat.get_chat_status_today(req) res = await svc.chat.get_chat_status_today()
return res return res

View File

@ -47,7 +47,7 @@ class ChatService:
res.append(UserChatMessage(type=message.type.value, text=message.text)) res.append(UserChatMessage(type=message.type.value, text=message.text))
return res return res
async def get_chat_status_today(self, req: GetChatStatusTodayInput) -> GetChatStatusTodayOutput: async def get_chat_status_today(self) -> GetChatStatusTodayOutput:
count = await self.pvd.chat.get_user_chat_messages_count_today(user_id=self.ctx.user.id) count = await self.pvd.chat.get_user_chat_messages_count_today(user_id=self.ctx.user.id)
res = GetChatStatusTodayOutput(user_name=self.ctx.user.name, chat_cnt=count) res = GetChatStatusTodayOutput(user_name=self.ctx.user.name, chat_cnt=count)
return res return res