(no commit message provided)
Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) <aider@aider.chat>
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
from flask import Blueprint, request, jsonify, current_app
|
||||
from app.services.bom_service import BomService
|
||||
from app.models.base import MaterialBase
|
||||
from app.extensions import db
|
||||
from flask_jwt_extended import jwt_required
|
||||
from sqlalchemy import distinct
|
||||
|
||||
bom_bp = Blueprint('bom', __name__)
|
||||
|
||||
@ -54,3 +56,20 @@ def get_material_base_list():
|
||||
except Exception as e:
|
||||
current_app.logger.error(f'获取基础物料列表失败: {str(e)}')
|
||||
return jsonify({'code': 500, 'msg': '内部服务器错误'}), 500
|
||||
|
||||
@bom_bp.route('/parents', methods=['GET'])
|
||||
@jwt_required()
|
||||
def get_bom_parents():
|
||||
"""获取所有已定义BOM的父件物料列表"""
|
||||
try:
|
||||
subq = db.session.query(distinct(BomTable.parent_id)).subquery()
|
||||
parents = MaterialBase.query.join(subq, MaterialBase.id == subq.c.parent_id).all()
|
||||
data = [item.to_dict() for item in parents]
|
||||
return jsonify({
|
||||
'code': 200,
|
||||
'msg': 'success',
|
||||
'data': data
|
||||
})
|
||||
except Exception as e:
|
||||
current_app.logger.error(f'获取BOM父件列表失败: {str(e)}')
|
||||
return jsonify({'code': 500, 'msg': '内部服务器错误'}), 500
|
||||
|
||||
Reference in New Issue
Block a user