// 🛒 Order Entity
// @Entity
// @Table(name = "orders")

print "🛒 Loading Order Entity...";

// @Entity
// @Table(name = "orders")
function Order(id, user_id, product_id, quantity, total) {
    print "🛒 Entity: Order";
    return "Order:" + str(id) + ":" + str(user_id) + ":" + str(product_id) + ":" + str(quantity) + ":" + str(total);
}

// Entity metadata for auto-table creation
function Order_getTableSchema() {
    print "🛒 Getting Order table schema...";
    
    let schema = {};
    return schema;
}

// Validation rules
function Order_validate(user_id, product_id, quantity, total) {
    print "✅ Validating Order data...";
    
    if (user_id <= 0) {
        print "❌ Validation error: Invalid user ID";
        return false;
    }
    
    if (product_id <= 0) {
        print "❌ Validation error: Invalid product ID";
        return false;
    }
    
    if (quantity <= 0) {
        print "❌ Validation error: Quantity must be positive";
        return false;
    }
    
    if (total <= 0) {
        print "❌ Validation error: Total must be positive";
        return false;
    }
    
    print "✅ Order validation passed";
    return true;
}

print "✅ Order Entity loaded successfully";
