对于成品的条形码进行功能实现
This commit is contained in:
@ -1,11 +1,14 @@
|
||||
# inventory-backend/app/api/v1/inbound/product.py
|
||||
from flask import Blueprint, request, jsonify
|
||||
# 引用更名后的服务
|
||||
from app.services.inbound.product_service import ProductInboundService
|
||||
import traceback
|
||||
|
||||
# 蓝图命名改为 inbound_product_bp
|
||||
inbound_product_bp = Blueprint('inbound_product', __name__)
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 0. 基础物料搜索
|
||||
# ------------------------------------------------------------------
|
||||
@inbound_product_bp.route('/search-base', methods=['GET'])
|
||||
def search_base():
|
||||
try:
|
||||
@ -14,6 +17,10 @@ def search_base():
|
||||
except Exception as e:
|
||||
return jsonify({"code": 500, "msg": str(e)}), 500
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 1. 获取列表
|
||||
# ------------------------------------------------------------------
|
||||
@inbound_product_bp.route('/list', methods=['GET'])
|
||||
def get_list():
|
||||
try:
|
||||
@ -25,14 +32,30 @@ def get_list():
|
||||
except Exception as e:
|
||||
return jsonify({"code": 500, "msg": str(e)}), 500
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 2. 新增入库 (修改:返回创建的对象数据,用于打印)
|
||||
# ------------------------------------------------------------------
|
||||
@inbound_product_bp.route('/submit', methods=['POST'])
|
||||
def submit():
|
||||
try:
|
||||
ProductInboundService.handle_inbound(request.get_json())
|
||||
return jsonify({"code": 200, "msg": "入库成功"})
|
||||
# 调用 Service 处理入库,获取新创建的对象
|
||||
new_stock = ProductInboundService.handle_inbound(request.get_json())
|
||||
|
||||
# 返回成功信息以及新创建的数据(包含生成的ID和SKU),供前端打印使用
|
||||
return jsonify({
|
||||
"code": 200,
|
||||
"msg": "入库成功",
|
||||
"data": new_stock.to_dict()
|
||||
})
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return jsonify({"code": 500, "msg": str(e)}), 500
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 3. 更新入库
|
||||
# ------------------------------------------------------------------
|
||||
@inbound_product_bp.route('/<int:id>', methods=['PUT'])
|
||||
def update(id):
|
||||
try:
|
||||
@ -41,6 +64,10 @@ def update(id):
|
||||
except Exception as e:
|
||||
return jsonify({"code": 500, "msg": str(e)}), 500
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 4. 删除
|
||||
# ------------------------------------------------------------------
|
||||
@inbound_product_bp.route('/<int:id>', methods=['DELETE'])
|
||||
def delete(id):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user