32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
import uuid
|
|
|
|
from motor.motor_asyncio import AsyncIOMotorDatabase
|
|
import schemas
|
|
from crud.base import CRUDBase
|
|
|
|
__all__ = 'email_record',
|
|
|
|
from utils import get_uid
|
|
|
|
|
|
class Email_record(CRUDBase):
|
|
# 获取对应求职者的邮件发送数据
|
|
async def all_record(self, db: AsyncIOMotorDatabase, data_in: schemas.get_email_record):
|
|
return await self.find_many(db, {'user_id': data_in.user_id}, {'_id': 0})
|
|
|
|
# 获取所有数据
|
|
async def all_hint(self, db: AsyncIOMotorDatabase):
|
|
return await self.find_many(db, {})
|
|
|
|
# 修改数据
|
|
async def up_hint(self, db: AsyncIOMotorDatabase, data_in: schemas.Up_hint):
|
|
await self.update_many(db, {'_id': {'$in': data_in.hint_id}}, {'$set': {'read_status': 1}})
|
|
|
|
# 插入数据
|
|
async def create(self, db: AsyncIOMotorDatabase, data_in: schemas.email_record):
|
|
data_ins = schemas.email_records(**data_in.dict(), _id=uuid.uuid1().hex)
|
|
await self.insert_one(db, data_ins.dict(by_alias=True))
|
|
|
|
|
|
email_record = Email_record('email_record')
|