|
@@ -27,7 +27,11 @@ def classification_id_get_classification_info(db,id):
|
|
|
query = query.filter_by(classification_id = id,del_flag = '0')
|
|
|
return query.first()
|
|
|
|
|
|
-
|
|
|
+def template_id_get_classification_list(db,id):
|
|
|
+ query = db.query(TpPatternClassification)
|
|
|
+ query = query.filter_by(template_id = id,del_flag = '0')
|
|
|
+ query = query.order_by(TpPatternClassification.order_num.asc())
|
|
|
+ return query.all()
|
|
|
|
|
|
@router.post("/create")
|
|
|
async def create_pattern(
|
|
@@ -188,4 +192,51 @@ async def change_classification_visible(
|
|
|
except Exception as e:
|
|
|
# 处理异常
|
|
|
traceback.print_exc()
|
|
|
- raise HTTPException(status_code=500, detail=str(e))
|
|
|
+ raise HTTPException(status_code=500, detail=str(e))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+@router.get("/templateTree")
|
|
|
+async def get_pattern_list(
|
|
|
+ # name: str = Query(None, description='名称'),
|
|
|
+ # page: int = Query(1, gt=0, description='页码'),
|
|
|
+ # pageSize: int = Query(None, gt=0, description='每页条目数量'),
|
|
|
+ db: Session = Depends(get_db)
|
|
|
+):
|
|
|
+ try:
|
|
|
+ query = db.query(TpPatternTemplate)
|
|
|
+ query = query.filter_by(del_flag='0')
|
|
|
+ # if name:
|
|
|
+ # query = query.filter(TpPatternTemplate.name.like(f'%{name}%'))
|
|
|
+ # total_items = query.count()
|
|
|
+ # # 排序
|
|
|
+ # if pageSize is None:
|
|
|
+ # pageSize=total_items
|
|
|
+ query = query.order_by(TpPatternTemplate.order_num.asc())
|
|
|
+ # 执行分页查询
|
|
|
+ lists = query.all() # .offset((page - 1) * pageSize).limit(pageSize)
|
|
|
+ data = []
|
|
|
+ for info in lists:
|
|
|
+ classification_list=template_id_get_classification_list(db,info.template_id)
|
|
|
+ template_info = {"template_id": info.template_id,
|
|
|
+ "name": info.name,
|
|
|
+ "value": info.value,
|
|
|
+ "order_num": info.order_num,
|
|
|
+ "visible": info.visible,
|
|
|
+ "create_time": info.create_time}
|
|
|
+ if classification_list:
|
|
|
+ template_info['children']=[{"classification_id": classification.classification_id,
|
|
|
+ "name": classification.name,
|
|
|
+ "value": classification.value,
|
|
|
+ "order_num": classification.order_num,
|
|
|
+ "visible": classification.visible,
|
|
|
+ "image": classification.image,
|
|
|
+ "icon": classification.icon,
|
|
|
+ "size": classification.size,
|
|
|
+ "create_time": classification.create_time} for classification in classification_list]
|
|
|
+ data.append(template_info)
|
|
|
+ return {"code": 200, "msg": "查询成功", "data": data}
|
|
|
+ except Exception as e:
|
|
|
+ traceback.print_exc()
|
|
|
+ raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
|