mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-02 09:26:12 +08:00
✨ web api 初稿
This commit is contained in:
parent
6cbc6f7d4d
commit
76f271584f
@ -17,9 +17,11 @@ from .token_manager import token_manager
|
||||
from ..config.db_config import SubscribeDupException
|
||||
from ..config import NoSuchUserException, NoSuchTargetException, NoSuchSubscribeException, config
|
||||
from .types import (
|
||||
Cookie,
|
||||
TokenResp,
|
||||
GlobalConf,
|
||||
StatusResp,
|
||||
CookieTarget,
|
||||
SubscribeResp,
|
||||
PlatformConfig,
|
||||
AddSubscribeReq,
|
||||
@ -197,3 +199,33 @@ async def update_weigth_config(platformName: str, target: str, weight_config: We
|
||||
except NoSuchTargetException:
|
||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, "no such subscribe")
|
||||
return StatusResp(ok=True, msg="")
|
||||
|
||||
|
||||
@router.get("/cookie")
|
||||
async def get_cookie() -> list[Cookie]:
|
||||
pass
|
||||
|
||||
|
||||
@router.post("/cookie")
|
||||
async def add_cookie(site_name: str, content: str) -> StatusResp:
|
||||
pass
|
||||
|
||||
|
||||
@router.delete("/cookie")
|
||||
async def del_cookie(site_name: str, content: str) -> StatusResp:
|
||||
pass
|
||||
|
||||
|
||||
@router.get("/cookie_target")
|
||||
async def get_cookie_target() -> list[CookieTarget]:
|
||||
pass
|
||||
|
||||
|
||||
@router.post("/cookie_target")
|
||||
async def add_cookie_target(site_name: str, target: str) -> StatusResp:
|
||||
pass
|
||||
|
||||
|
||||
@router.delete("/cookie_target")
|
||||
async def del_cookie_target(site_name: str, target: str) -> StatusResp:
|
||||
pass
|
||||
|
@ -6,14 +6,22 @@ class PlatformConfig(BaseModel):
|
||||
categories: dict[int, str]
|
||||
enabledTag: bool
|
||||
platformName: str
|
||||
site_name: str
|
||||
hasTarget: bool
|
||||
|
||||
|
||||
class SiteConfig(BaseModel):
|
||||
name: str
|
||||
enable_cookie: bool
|
||||
|
||||
|
||||
AllPlatformConf = dict[str, PlatformConfig]
|
||||
AllSiteConf = dict[str, SiteConfig]
|
||||
|
||||
|
||||
class GlobalConf(BaseModel):
|
||||
platformConf: AllPlatformConf
|
||||
siteConf: AllSiteConf
|
||||
|
||||
|
||||
class TokenResp(BaseModel):
|
||||
@ -50,3 +58,40 @@ class AddSubscribeReq(BaseModel):
|
||||
class StatusResp(BaseModel):
|
||||
ok: bool
|
||||
msg: str
|
||||
|
||||
|
||||
from typing import Any
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class Target(BaseModel):
|
||||
platform_name: str
|
||||
target_name: str
|
||||
target: str
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
|
||||
class Cookie(BaseModel):
|
||||
site_name: str
|
||||
friendly_name: str
|
||||
last_usage: datetime
|
||||
status: str
|
||||
cd_milliseconds: int
|
||||
is_universal: bool
|
||||
is_anonymous: bool
|
||||
tags: dict[str, Any]
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
|
||||
class CookieTarget(BaseModel):
|
||||
target: Target
|
||||
cookie: Cookie
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
Loading…
x
Reference in New Issue
Block a user