This commit is contained in:
王思川 2022-11-18 16:18:32 +08:00
parent cc5d252b7a
commit c0b325114a
6 changed files with 48 additions and 5 deletions

View File

@ -67,4 +67,8 @@ def search_scorecard(db: Session, schema: Schema.SearchScoreCardReqBody):
def get_sub_table_data(mongodb: MongoHelper, tablename: str, obj_id: str):
Schema.GetSubTableDataQueryBody(**{"tablename": tablename, "obj_id": obj_id})
item = mongodb.find_data_by_id(dbname="打分卡配置", sheet=tablename, _id=obj_id)
if not item:
return None
return item.get("data")

View File

@ -42,3 +42,16 @@ def func(_id: str, db: Session = Depends(get_db), mongodb: MongoHelper = Depends
DataTableCrud.delete_data_table(db=db, mongodb=mongodb, _id=_id)
return {"info": "Success"}
@router.post("/view", summary="查看数据表")
def func(_id: str, db: Session = Depends(get_db), mongodb: MongoHelper = Depends(get_mongodb)):
item = ScoreCardCrud.get_scorecard_by_id(db=db, _id=_id)
if not item:
raise HTTPException(status_code=404, detail="ScoreCard Not Found")
if not item.data_table:
raise HTTPException(status_code=202, detail="DataTable Not Found")
table_data = ScoreCardCrud.get_sub_table_data(mongodb=mongodb, tablename="数据表", obj_id=item.data_table.obj_id)
return table_data

View File

@ -42,3 +42,16 @@ def func(_id: str, db: Session = Depends(get_db), mongodb: MongoHelper = Depends
IndexTableCrud.delete_index_table(db=db, mongodb=mongodb, _id=_id)
return {"info": "Success"}
@router.post("/view", summary="查看指标表")
def func(_id: str, db: Session = Depends(get_db), mongodb: MongoHelper = Depends(get_mongodb)):
item = ScoreCardCrud.get_scorecard_by_id(db=db, _id=_id)
if not item:
raise HTTPException(status_code=404, detail="ScoreCard Not Found")
if not item.index_table:
raise HTTPException(status_code=202, detail="IndexTable Not Found")
table_data = ScoreCardCrud.get_sub_table_data(mongodb=mongodb, tablename="指标表", obj_id=item.index_table.obj_id)
return table_data

View File

@ -42,3 +42,16 @@ def func(_id: str, db: Session = Depends(get_db), mongodb: MongoHelper = Depends
RankTableCrud.delete_rank_table(db=db, mongodb=mongodb, _id=_id)
return {"info": "Success"}
@router.post("/view", summary="查看评级表")
def func(_id: str, db: Session = Depends(get_db), mongodb: MongoHelper = Depends(get_mongodb)):
item = ScoreCardCrud.get_scorecard_by_id(db=db, _id=_id)
if not item:
raise HTTPException(status_code=404, detail="ScoreCard Not Found")
if not item.rank_table:
raise HTTPException(status_code=202, detail="RankTable Not Found")
table_data = ScoreCardCrud.get_sub_table_data(mongodb=mongodb, tablename="评级表", obj_id=item.rank_table.obj_id)
return table_data

View File

@ -28,14 +28,14 @@ def scorecard_to_dict(scorecard, mongodb: MongoHelper):
@router.post("/create", summary="新建打分卡")
def func(schema: Schema.CreateScoreCardReqBody, db: Session = Depends(get_db)):
item = Crud.get_scorecard_by_name(db=db, name=schema.name)
if item:
raise HTTPException(status_code=202, detail="ScoreCard Already Existed")
item = CategoryCrud.get_major_category_by_id(db=db, _id=schema.major_category_id)
if not item:
raise HTTPException(status_code=404, detail="MajorCategory Not Found")
item = Crud.get_scorecard_by_name(db=db, name=schema.name)
if item:
raise HTTPException(status_code=202, detail="ScoreCard Already Existed")
item = CategoryCrud.get_sub_category_by_id(db=db, _id=schema.subcategory_id)
if not item:
raise HTTPException(status_code=404, detail="Subcategory Not Found")

View File

@ -3,6 +3,6 @@
"wr_model_store": "mysql+pymysql://root:123456@localhost/wr_model_store?charset=utf8mb4"
},
"MongoDB": {
"test": "root:sromitdTW569kC#M@116.63.130.34:27018"
"test": "root:123456@localhost:27017"
}
}