添加 service.admin admin重复时警告日记

This commit is contained in:
洛水.山岭居室 2022-05-24 20:16:30 +08:00
parent 7c48eb842d
commit a0d17b1394

View File

@ -1,8 +1,10 @@
import logging
from typing import List
from pymysql import IntegrityError
from config import config
from logger import Log
from service.repository import AsyncRepository
from service.cache import RedisCache
@ -25,7 +27,8 @@ class AdminService:
async def add_admin(self, user_id: int) -> bool:
try:
await self.repository.add_admin(user_id)
except IntegrityError:
except IntegrityError as error:
Log.warning(f"{user_id} 已经存在数据库 \n", error)
pass
admin_list = await self.repository.get_admin()
for config_admin in config.ADMINISTRATORS: