Skip to content

Commit

Permalink
recover
Browse files Browse the repository at this point in the history
  • Loading branch information
wuranxu committed Jul 29, 2022
1 parent 98821ee commit fbc9845
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions app/crud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
from config import Config


class Mapper(type):
class Mapper(object):
__log__ = None
__model__ = None

def __new__(mcs, name, bases, attrs):
res = super().__new__(mcs, name, bases, attrs)
mcs.__log__ = attrs['__log__']
mcs.__model__ = attrs['__model__']
return res
# def __new__(mcs, name, bases, attrs):
# res = super().__new__(mcs, name, bases, attrs)
# mcs.__log__ = attrs['__log__']
# mcs.__model__ = attrs['__model__']
# return res

@classmethod
@RedisHelper.cache("dao")
Expand Down
6 changes: 3 additions & 3 deletions app/crud/config/AddressDao.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from app.crud import Mapper
from app.models import async_session
from app.models.address import PityGateway
from app.utils.decorator import dao
from app.utils.logger import Log


class PityGatewayDao(Mapper, metaclass=Mapper):
__log__ = Log("PityRedisConfigDao")
__model__ = PityGateway
@dao(PityGateway, Log("PityRedisConfigDao"))
class PityGatewayDao(Mapper):

@staticmethod
# @RedisHelper.cache(f"gateway", 1800)
Expand Down
6 changes: 3 additions & 3 deletions app/crud/test_case/ConstructorDao.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from app.models.constructor import Constructor
from app.models.test_case import TestCase
from app.schema.constructor import ConstructorForm, ConstructorIndex
from app.utils.decorator import dao
from app.utils.logger import Log


class ConstructorDao(Mapper, metaclass=Mapper):
__model__ = Constructor
__log__ = Log("ConstructorDao")
@dao(Constructor, Log("ConstructorDao"))
class ConstructorDao(Mapper):

@staticmethod
async def list_constructor(case_id: int) -> List[Constructor]:
Expand Down
4 changes: 2 additions & 2 deletions app/utils/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ def wrapper(cls):
:return:
"""
# 设置model和log
setattr(cls, "model", model)
setattr(cls, "log", log)
setattr(cls, "__model__", model)
setattr(cls, "__log__", log)
return cls

return wrapper
Expand Down

0 comments on commit fbc9845

Please sign in to comment.