Initial commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
from typing import List
|
||||
|
||||
from scm.models.units import UnitModel
|
||||
|
||||
from auth.utils.mongo import use_auth_collection
|
||||
from core.app import app
|
||||
from core.utils.api import get_namespace_api
|
||||
|
||||
BASE = get_namespace_api('user')
|
||||
|
||||
|
||||
@app.get(BASE + '/me')
|
||||
async def get():
|
||||
return {"code": 0,
|
||||
"result": {"userId": "1",
|
||||
"username": "admin",
|
||||
"realName": "احمد رضا عزیزان",
|
||||
"avatar": "https://q1.qlogo.cn/g?b=qq&nk=190848757&s=640",
|
||||
"desc": "manager",
|
||||
"password": "admin",
|
||||
"token": "fakeToken1",
|
||||
"homePath": "/dashboard/analysis",
|
||||
"roles": [{"roleName": "Super Admin",
|
||||
"value": "super"}]},
|
||||
"message": "ok",
|
||||
"type": "success"}
|
||||
|
||||
|
||||
@app.get(BASE + '/units')
|
||||
async def get_units() -> List[UnitModel]:
|
||||
cursor = use_auth_collection('units').find()
|
||||
return [UnitModel(**document) async for document in cursor]
|
||||
|
||||
|
||||
@app.post(BASE + '/units/create')
|
||||
async def post(document: UnitModel):
|
||||
document = document.init_id().mongo_dict()
|
||||
result = await use_auth_collection('units').insert_one(document)
|
||||
return result.inserted_id
|
||||
Reference in New Issue
Block a user