1
This commit is contained in:
parent
ea93aee1bd
commit
d30d98fb3d
@ -71,6 +71,21 @@ async def move(
|
||||
return schemas.Msg(code=0, msg='ok', data='移动成功')
|
||||
|
||||
|
||||
@router.post("/sort")
|
||||
async def sort(
|
||||
game: str,
|
||||
data_in: schemas.DashboardSort,
|
||||
db: AsyncIOMotorDatabase = Depends(get_database),
|
||||
current_user: schemas.UserDB = Depends(deps.get_current_user)
|
||||
) -> schemas.Msg:
|
||||
"""
|
||||
看板排序
|
||||
"""
|
||||
for item in data_in.sort:
|
||||
await crud.dashboard.set_sort(db, index=item.dashboard_id, sort=item.sort)
|
||||
return schemas.Msg(code=0, msg='ok', data=1)
|
||||
|
||||
|
||||
@router.post("/copy")
|
||||
async def copy(
|
||||
data_in: schemas.DashboardCopy,
|
||||
|
@ -77,11 +77,11 @@ async def read_project(request: Request,
|
||||
|
||||
@router.get("/detail")
|
||||
async def detail(request: Request,
|
||||
game: str,
|
||||
db: AsyncIOMotorDatabase = Depends(get_database),
|
||||
ck: CKDrive = Depends(get_ck_db),
|
||||
current_user: schemas.UserDB = Depends(deps.get_current_user)
|
||||
):
|
||||
game: str,
|
||||
db: AsyncIOMotorDatabase = Depends(get_database),
|
||||
ck: CKDrive = Depends(get_ck_db),
|
||||
current_user: schemas.UserDB = Depends(deps.get_current_user)
|
||||
):
|
||||
"""查看项目信息"""
|
||||
res = await crud.project.find_one(db, {'game': game})
|
||||
event_count = await ck.count(game, 'event')
|
||||
@ -239,13 +239,12 @@ async def read_kanban(
|
||||
kanban = await crud.folder.read_folder(db, project_id=data_in.id, user_id=current_user.id, cat='kanban')
|
||||
|
||||
for item in kanban:
|
||||
dashboards = await crud.dashboard.find_many(db, {'pid': item['_id']})
|
||||
res['kanban'].append({
|
||||
'name': item['name'],
|
||||
'children': [],
|
||||
'_id': item['_id']
|
||||
})
|
||||
for d in dashboards:
|
||||
async for d in crud.dashboard.find(db, {'pid': item['_id']}).sort([('sort', 1)]):
|
||||
res['kanban'][-1]['children'].append({
|
||||
'name': d['name'],
|
||||
'_id': d['_id']
|
||||
@ -275,14 +274,14 @@ async def read_kanban(
|
||||
'isFolder': True
|
||||
})
|
||||
|
||||
for d in await crud.dashboard.find_many(db, {'pid': f['_id']}):
|
||||
async for d in crud.dashboard.find(db, {'pid': item['_id']}).sort([('sort', 1)]):
|
||||
res['spaces'][-1]['children'][-1]['children'].append({
|
||||
'name': d['name'],
|
||||
'_id': d['_id']
|
||||
})
|
||||
|
||||
# 空间 看板
|
||||
for d in await crud.dashboard.find_many(db, {'pid': item['_id']}):
|
||||
async for d in crud.dashboard.find(db, {'pid': item['_id']}).sort([('sort', 1)]):
|
||||
res['spaces'][-1]['children'].append({
|
||||
'name': d['name'],
|
||||
'_id': d['_id'],
|
||||
|
@ -55,7 +55,7 @@ class CRUDBase:
|
||||
async def distinct(self, db, key, filter=None):
|
||||
return await db[self.coll_name].distinct(key, filter)
|
||||
|
||||
async def find_ids(self, db, ids:list, *args, **kwargs):
|
||||
async def find_ids(self, db, ids: list, *args, **kwargs):
|
||||
return await self.find_many(db, {'_id': {'$in': ids}}, *args, **kwargs)
|
||||
|
||||
# async def _create_index(self, db: AsyncIOMotorDatabase, *args, **kwargs):
|
||||
|
@ -17,11 +17,13 @@ class CRUDDashboard(CRUDBase):
|
||||
)
|
||||
await db[self.coll_name].insert_one(db_obj.dict(by_alias=True))
|
||||
|
||||
async def set_sort(self, db: AsyncIOMotorDatabase, index: str, sort: int):
|
||||
await self.update_one(db, {'_id': index}, {'$set': {'sort': sort}})
|
||||
|
||||
async def create_index(self, db: AsyncIOMotorDatabase):
|
||||
await db[self.coll_name].create_index(
|
||||
[('project_id', pymongo.DESCENDING), ('name', pymongo.DESCENDING), ('user_id', pymongo.DESCENDING)],
|
||||
unique=True)
|
||||
|
||||
|
||||
|
||||
dashboard = CRUDDashboard('dashboard')
|
||||
|
@ -35,7 +35,7 @@ class Report(BaseModel):
|
||||
model: str
|
||||
graph_size: str
|
||||
sort: int = 1
|
||||
modelswitch: bool=False
|
||||
modelswitch: bool = False
|
||||
|
||||
|
||||
class EditShowReport(BaseModel):
|
||||
@ -59,6 +59,15 @@ class DashboardMove(BaseModel):
|
||||
cat: Category
|
||||
|
||||
|
||||
class Sort(BaseModel):
|
||||
dashboard_id: str
|
||||
sort: int
|
||||
|
||||
|
||||
class DashboardSort(BaseModel):
|
||||
sort: List[Sort]
|
||||
|
||||
|
||||
class DashboardCopy(BaseModel):
|
||||
source_ids: List[str]
|
||||
dest_project_id: str
|
||||
|
Loading…
Reference in New Issue
Block a user