1075 lines
32 KiB
Go
1075 lines
32 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: market.sql
|
|
|
|
package repository
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const countDataAssets = `-- name: CountDataAssets :one
|
|
SELECT COUNT(*)
|
|
FROM data_assets
|
|
WHERE (
|
|
NULLIF($1::text, '') IS NULL
|
|
OR asset_name ILIKE '%' || $1::text || '%'
|
|
OR data_description ILIKE '%' || $1::text || '%'
|
|
)
|
|
AND (
|
|
NULLIF($2::text, '') IS NULL
|
|
OR asset_type = $2::text
|
|
)
|
|
AND (
|
|
NULLIF($3::text, '') IS NULL
|
|
OR domain = $3::text
|
|
)
|
|
AND (
|
|
NULLIF($4::text, '') IS NULL
|
|
OR privacy_level = $4::text
|
|
)
|
|
AND (
|
|
$5::boolean IS NULL
|
|
OR supports_validation = $5::boolean
|
|
)
|
|
`
|
|
|
|
type CountDataAssetsParams struct {
|
|
Keyword pgtype.Text `json:"keyword"`
|
|
AssetType pgtype.Text `json:"asset_type"`
|
|
Domain pgtype.Text `json:"domain"`
|
|
PrivacyLevel pgtype.Text `json:"privacy_level"`
|
|
SupportsValidation pgtype.Bool `json:"supports_validation"`
|
|
}
|
|
|
|
func (q *Queries) CountDataAssets(ctx context.Context, arg CountDataAssetsParams) (int64, error) {
|
|
row := q.db.QueryRow(ctx, countDataAssets,
|
|
arg.Keyword,
|
|
arg.AssetType,
|
|
arg.Domain,
|
|
arg.PrivacyLevel,
|
|
arg.SupportsValidation,
|
|
)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const countOrders = `-- name: CountOrders :one
|
|
SELECT COUNT(*)
|
|
FROM orders
|
|
WHERE NULLIF($1::text, '') IS NULL
|
|
OR order_status = $1::text
|
|
`
|
|
|
|
func (q *Queries) CountOrders(ctx context.Context, orderStatus pgtype.Text) (int64, error) {
|
|
row := q.db.QueryRow(ctx, countOrders, orderStatus)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const countValidations = `-- name: CountValidations :one
|
|
SELECT COUNT(*)
|
|
FROM validations
|
|
`
|
|
|
|
func (q *Queries) CountValidations(ctx context.Context) (int64, error) {
|
|
row := q.db.QueryRow(ctx, countValidations)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const createBuyerRequest = `-- name: CreateBuyerRequest :one
|
|
INSERT INTO buyer_requests (
|
|
asset_id,
|
|
task_type,
|
|
model_type,
|
|
buyer_budget_min,
|
|
buyer_budget_max,
|
|
privacy_requirement,
|
|
usage_purpose,
|
|
request_note,
|
|
request_status
|
|
)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
|
RETURNING id, asset_id, task_type, model_type, buyer_budget_min, buyer_budget_max, privacy_requirement, usage_purpose, request_note, request_status, created_at, updated_at, user_id
|
|
`
|
|
|
|
type CreateBuyerRequestParams struct {
|
|
AssetID pgtype.UUID `json:"asset_id"`
|
|
TaskType string `json:"task_type"`
|
|
ModelType string `json:"model_type"`
|
|
BuyerBudgetMin pgtype.Numeric `json:"buyer_budget_min"`
|
|
BuyerBudgetMax pgtype.Numeric `json:"buyer_budget_max"`
|
|
PrivacyRequirement pgtype.Text `json:"privacy_requirement"`
|
|
UsagePurpose pgtype.Text `json:"usage_purpose"`
|
|
RequestNote pgtype.Text `json:"request_note"`
|
|
RequestStatus string `json:"request_status"`
|
|
}
|
|
|
|
func (q *Queries) CreateBuyerRequest(ctx context.Context, arg CreateBuyerRequestParams) (BuyerRequest, error) {
|
|
row := q.db.QueryRow(ctx, createBuyerRequest,
|
|
arg.AssetID,
|
|
arg.TaskType,
|
|
arg.ModelType,
|
|
arg.BuyerBudgetMin,
|
|
arg.BuyerBudgetMax,
|
|
arg.PrivacyRequirement,
|
|
arg.UsagePurpose,
|
|
arg.RequestNote,
|
|
arg.RequestStatus,
|
|
)
|
|
var i BuyerRequest
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.AssetID,
|
|
&i.TaskType,
|
|
&i.ModelType,
|
|
&i.BuyerBudgetMin,
|
|
&i.BuyerBudgetMax,
|
|
&i.PrivacyRequirement,
|
|
&i.UsagePurpose,
|
|
&i.RequestNote,
|
|
&i.RequestStatus,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.UserID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const createDataAsset = `-- name: CreateDataAsset :one
|
|
INSERT INTO data_assets (
|
|
asset_name,
|
|
asset_type,
|
|
domain,
|
|
application_scene,
|
|
data_description,
|
|
data_scale,
|
|
collection_method,
|
|
labeling_status,
|
|
update_frequency,
|
|
privacy_level,
|
|
permission_mode,
|
|
supports_validation,
|
|
seller_expected_price_min,
|
|
seller_expected_price_max,
|
|
quality_level,
|
|
scarcity_level,
|
|
base_value_score,
|
|
base_price_min,
|
|
base_price_max,
|
|
asset_status
|
|
)
|
|
VALUES (
|
|
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10,
|
|
$11, $12, $13, $14, $15, $16, $17, $18, $19, $20
|
|
)
|
|
RETURNING id, asset_name, asset_type, domain, application_scene, data_description, data_scale, collection_method, labeling_status, update_frequency, privacy_level, permission_mode, supports_validation, seller_expected_price_min, seller_expected_price_max, quality_level, scarcity_level, base_value_score, base_price_min, base_price_max, asset_status, created_at, updated_at
|
|
`
|
|
|
|
type CreateDataAssetParams struct {
|
|
AssetName string `json:"asset_name"`
|
|
AssetType string `json:"asset_type"`
|
|
Domain string `json:"domain"`
|
|
ApplicationScene pgtype.Text `json:"application_scene"`
|
|
DataDescription string `json:"data_description"`
|
|
DataScale string `json:"data_scale"`
|
|
CollectionMethod string `json:"collection_method"`
|
|
LabelingStatus pgtype.Text `json:"labeling_status"`
|
|
UpdateFrequency pgtype.Text `json:"update_frequency"`
|
|
PrivacyLevel string `json:"privacy_level"`
|
|
PermissionMode string `json:"permission_mode"`
|
|
SupportsValidation bool `json:"supports_validation"`
|
|
SellerExpectedPriceMin pgtype.Numeric `json:"seller_expected_price_min"`
|
|
SellerExpectedPriceMax pgtype.Numeric `json:"seller_expected_price_max"`
|
|
QualityLevel pgtype.Text `json:"quality_level"`
|
|
ScarcityLevel pgtype.Text `json:"scarcity_level"`
|
|
BaseValueScore pgtype.Numeric `json:"base_value_score"`
|
|
BasePriceMin pgtype.Numeric `json:"base_price_min"`
|
|
BasePriceMax pgtype.Numeric `json:"base_price_max"`
|
|
AssetStatus string `json:"asset_status"`
|
|
}
|
|
|
|
type CreateDataAssetRow struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
AssetName string `json:"asset_name"`
|
|
AssetType string `json:"asset_type"`
|
|
Domain string `json:"domain"`
|
|
ApplicationScene pgtype.Text `json:"application_scene"`
|
|
DataDescription string `json:"data_description"`
|
|
DataScale string `json:"data_scale"`
|
|
CollectionMethod string `json:"collection_method"`
|
|
LabelingStatus pgtype.Text `json:"labeling_status"`
|
|
UpdateFrequency pgtype.Text `json:"update_frequency"`
|
|
PrivacyLevel string `json:"privacy_level"`
|
|
PermissionMode string `json:"permission_mode"`
|
|
SupportsValidation bool `json:"supports_validation"`
|
|
SellerExpectedPriceMin pgtype.Numeric `json:"seller_expected_price_min"`
|
|
SellerExpectedPriceMax pgtype.Numeric `json:"seller_expected_price_max"`
|
|
QualityLevel pgtype.Text `json:"quality_level"`
|
|
ScarcityLevel pgtype.Text `json:"scarcity_level"`
|
|
BaseValueScore pgtype.Numeric `json:"base_value_score"`
|
|
BasePriceMin pgtype.Numeric `json:"base_price_min"`
|
|
BasePriceMax pgtype.Numeric `json:"base_price_max"`
|
|
AssetStatus string `json:"asset_status"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) CreateDataAsset(ctx context.Context, arg CreateDataAssetParams) (CreateDataAssetRow, error) {
|
|
row := q.db.QueryRow(ctx, createDataAsset,
|
|
arg.AssetName,
|
|
arg.AssetType,
|
|
arg.Domain,
|
|
arg.ApplicationScene,
|
|
arg.DataDescription,
|
|
arg.DataScale,
|
|
arg.CollectionMethod,
|
|
arg.LabelingStatus,
|
|
arg.UpdateFrequency,
|
|
arg.PrivacyLevel,
|
|
arg.PermissionMode,
|
|
arg.SupportsValidation,
|
|
arg.SellerExpectedPriceMin,
|
|
arg.SellerExpectedPriceMax,
|
|
arg.QualityLevel,
|
|
arg.ScarcityLevel,
|
|
arg.BaseValueScore,
|
|
arg.BasePriceMin,
|
|
arg.BasePriceMax,
|
|
arg.AssetStatus,
|
|
)
|
|
var i CreateDataAssetRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.AssetName,
|
|
&i.AssetType,
|
|
&i.Domain,
|
|
&i.ApplicationScene,
|
|
&i.DataDescription,
|
|
&i.DataScale,
|
|
&i.CollectionMethod,
|
|
&i.LabelingStatus,
|
|
&i.UpdateFrequency,
|
|
&i.PrivacyLevel,
|
|
&i.PermissionMode,
|
|
&i.SupportsValidation,
|
|
&i.SellerExpectedPriceMin,
|
|
&i.SellerExpectedPriceMax,
|
|
&i.QualityLevel,
|
|
&i.ScarcityLevel,
|
|
&i.BaseValueScore,
|
|
&i.BasePriceMin,
|
|
&i.BasePriceMax,
|
|
&i.AssetStatus,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const createOrder = `-- name: CreateOrder :one
|
|
INSERT INTO orders (
|
|
asset_id,
|
|
request_id,
|
|
pricing_id,
|
|
validation_id,
|
|
asset_name,
|
|
current_price,
|
|
negotiation_min,
|
|
negotiation_max,
|
|
validation_used,
|
|
delivery_mode,
|
|
order_status
|
|
)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
|
|
RETURNING id, asset_id, request_id, pricing_id, validation_id, asset_name, current_price, negotiation_min, negotiation_max, validation_used, delivery_mode, order_status, order_created_at, order_updated_at, user_id
|
|
`
|
|
|
|
type CreateOrderParams struct {
|
|
AssetID pgtype.UUID `json:"asset_id"`
|
|
RequestID pgtype.UUID `json:"request_id"`
|
|
PricingID pgtype.UUID `json:"pricing_id"`
|
|
ValidationID pgtype.UUID `json:"validation_id"`
|
|
AssetName string `json:"asset_name"`
|
|
CurrentPrice pgtype.Numeric `json:"current_price"`
|
|
NegotiationMin pgtype.Numeric `json:"negotiation_min"`
|
|
NegotiationMax pgtype.Numeric `json:"negotiation_max"`
|
|
ValidationUsed bool `json:"validation_used"`
|
|
DeliveryMode string `json:"delivery_mode"`
|
|
OrderStatus string `json:"order_status"`
|
|
}
|
|
|
|
func (q *Queries) CreateOrder(ctx context.Context, arg CreateOrderParams) (Order, error) {
|
|
row := q.db.QueryRow(ctx, createOrder,
|
|
arg.AssetID,
|
|
arg.RequestID,
|
|
arg.PricingID,
|
|
arg.ValidationID,
|
|
arg.AssetName,
|
|
arg.CurrentPrice,
|
|
arg.NegotiationMin,
|
|
arg.NegotiationMax,
|
|
arg.ValidationUsed,
|
|
arg.DeliveryMode,
|
|
arg.OrderStatus,
|
|
)
|
|
var i Order
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.AssetID,
|
|
&i.RequestID,
|
|
&i.PricingID,
|
|
&i.ValidationID,
|
|
&i.AssetName,
|
|
&i.CurrentPrice,
|
|
&i.NegotiationMin,
|
|
&i.NegotiationMax,
|
|
&i.ValidationUsed,
|
|
&i.DeliveryMode,
|
|
&i.OrderStatus,
|
|
&i.OrderCreatedAt,
|
|
&i.OrderUpdatedAt,
|
|
&i.UserID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const createPricingResult = `-- name: CreatePricingResult :one
|
|
INSERT INTO pricing_results (
|
|
asset_id,
|
|
request_id,
|
|
scenario_value_score,
|
|
scenario_price_min,
|
|
scenario_price_max,
|
|
suggested_price,
|
|
success_probability,
|
|
pricing_reason_1,
|
|
pricing_reason_2,
|
|
pricing_reason_3,
|
|
verification_suggestion,
|
|
pricing_status
|
|
)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)
|
|
RETURNING id, asset_id, request_id, scenario_value_score, scenario_price_min, scenario_price_max, suggested_price, success_probability, pricing_reason_1, pricing_reason_2, pricing_reason_3, verification_suggestion, pricing_status, created_at, updated_at, agent_task_match_explanation, agent_risk_advice, agent_budget_advice, agent_next_action
|
|
`
|
|
|
|
type CreatePricingResultParams struct {
|
|
AssetID pgtype.UUID `json:"asset_id"`
|
|
RequestID pgtype.UUID `json:"request_id"`
|
|
ScenarioValueScore pgtype.Numeric `json:"scenario_value_score"`
|
|
ScenarioPriceMin pgtype.Numeric `json:"scenario_price_min"`
|
|
ScenarioPriceMax pgtype.Numeric `json:"scenario_price_max"`
|
|
SuggestedPrice pgtype.Numeric `json:"suggested_price"`
|
|
SuccessProbability pgtype.Numeric `json:"success_probability"`
|
|
PricingReason1 pgtype.Text `json:"pricing_reason_1"`
|
|
PricingReason2 pgtype.Text `json:"pricing_reason_2"`
|
|
PricingReason3 pgtype.Text `json:"pricing_reason_3"`
|
|
VerificationSuggestion pgtype.Text `json:"verification_suggestion"`
|
|
PricingStatus string `json:"pricing_status"`
|
|
}
|
|
|
|
func (q *Queries) CreatePricingResult(ctx context.Context, arg CreatePricingResultParams) (PricingResult, error) {
|
|
row := q.db.QueryRow(ctx, createPricingResult,
|
|
arg.AssetID,
|
|
arg.RequestID,
|
|
arg.ScenarioValueScore,
|
|
arg.ScenarioPriceMin,
|
|
arg.ScenarioPriceMax,
|
|
arg.SuggestedPrice,
|
|
arg.SuccessProbability,
|
|
arg.PricingReason1,
|
|
arg.PricingReason2,
|
|
arg.PricingReason3,
|
|
arg.VerificationSuggestion,
|
|
arg.PricingStatus,
|
|
)
|
|
var i PricingResult
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.AssetID,
|
|
&i.RequestID,
|
|
&i.ScenarioValueScore,
|
|
&i.ScenarioPriceMin,
|
|
&i.ScenarioPriceMax,
|
|
&i.SuggestedPrice,
|
|
&i.SuccessProbability,
|
|
&i.PricingReason1,
|
|
&i.PricingReason2,
|
|
&i.PricingReason3,
|
|
&i.VerificationSuggestion,
|
|
&i.PricingStatus,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.AgentTaskMatchExplanation,
|
|
&i.AgentRiskAdvice,
|
|
&i.AgentBudgetAdvice,
|
|
&i.AgentNextAction,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const createValidation = `-- name: CreateValidation :one
|
|
INSERT INTO validations (
|
|
asset_id,
|
|
request_id,
|
|
validation_type,
|
|
validation_requested,
|
|
validation_status,
|
|
validation_signal,
|
|
validation_score,
|
|
risk_warning,
|
|
continue_recommendation,
|
|
validation_finished_at
|
|
)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
|
RETURNING id, asset_id, request_id, validation_type, validation_requested, validation_status, validation_signal, validation_score, risk_warning, continue_recommendation, validation_created_at, validation_finished_at, agent_validation_explanation, agent_continue_trade_advice, agent_delivery_advice, agent_risk_notice
|
|
`
|
|
|
|
type CreateValidationParams struct {
|
|
AssetID pgtype.UUID `json:"asset_id"`
|
|
RequestID pgtype.UUID `json:"request_id"`
|
|
ValidationType pgtype.Text `json:"validation_type"`
|
|
ValidationRequested bool `json:"validation_requested"`
|
|
ValidationStatus string `json:"validation_status"`
|
|
ValidationSignal pgtype.Text `json:"validation_signal"`
|
|
ValidationScore pgtype.Numeric `json:"validation_score"`
|
|
RiskWarning pgtype.Text `json:"risk_warning"`
|
|
ContinueRecommendation pgtype.Text `json:"continue_recommendation"`
|
|
ValidationFinishedAt pgtype.Timestamptz `json:"validation_finished_at"`
|
|
}
|
|
|
|
func (q *Queries) CreateValidation(ctx context.Context, arg CreateValidationParams) (Validation, error) {
|
|
row := q.db.QueryRow(ctx, createValidation,
|
|
arg.AssetID,
|
|
arg.RequestID,
|
|
arg.ValidationType,
|
|
arg.ValidationRequested,
|
|
arg.ValidationStatus,
|
|
arg.ValidationSignal,
|
|
arg.ValidationScore,
|
|
arg.RiskWarning,
|
|
arg.ContinueRecommendation,
|
|
arg.ValidationFinishedAt,
|
|
)
|
|
var i Validation
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.AssetID,
|
|
&i.RequestID,
|
|
&i.ValidationType,
|
|
&i.ValidationRequested,
|
|
&i.ValidationStatus,
|
|
&i.ValidationSignal,
|
|
&i.ValidationScore,
|
|
&i.RiskWarning,
|
|
&i.ContinueRecommendation,
|
|
&i.ValidationCreatedAt,
|
|
&i.ValidationFinishedAt,
|
|
&i.AgentValidationExplanation,
|
|
&i.AgentContinueTradeAdvice,
|
|
&i.AgentDeliveryAdvice,
|
|
&i.AgentRiskNotice,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getBuyerRequest = `-- name: GetBuyerRequest :one
|
|
SELECT id, asset_id, task_type, model_type, buyer_budget_min, buyer_budget_max, privacy_requirement, usage_purpose, request_note, request_status, created_at, updated_at, user_id
|
|
FROM buyer_requests
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetBuyerRequest(ctx context.Context, id pgtype.UUID) (BuyerRequest, error) {
|
|
row := q.db.QueryRow(ctx, getBuyerRequest, id)
|
|
var i BuyerRequest
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.AssetID,
|
|
&i.TaskType,
|
|
&i.ModelType,
|
|
&i.BuyerBudgetMin,
|
|
&i.BuyerBudgetMax,
|
|
&i.PrivacyRequirement,
|
|
&i.UsagePurpose,
|
|
&i.RequestNote,
|
|
&i.RequestStatus,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.UserID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getDataAsset = `-- name: GetDataAsset :one
|
|
SELECT id, asset_name, asset_type, domain, application_scene, data_description, data_scale, collection_method, labeling_status, update_frequency, privacy_level, permission_mode, supports_validation, seller_expected_price_min, seller_expected_price_max, quality_level, scarcity_level, base_value_score, base_price_min, base_price_max, asset_status, created_at, updated_at, user_id, agent_asset_summary, agent_recommended_tasks, agent_risk_per_mission_advice, agent_asset_explanation
|
|
FROM data_assets
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetDataAsset(ctx context.Context, id pgtype.UUID) (DataAsset, error) {
|
|
row := q.db.QueryRow(ctx, getDataAsset, id)
|
|
var i DataAsset
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.AssetName,
|
|
&i.AssetType,
|
|
&i.Domain,
|
|
&i.ApplicationScene,
|
|
&i.DataDescription,
|
|
&i.DataScale,
|
|
&i.CollectionMethod,
|
|
&i.LabelingStatus,
|
|
&i.UpdateFrequency,
|
|
&i.PrivacyLevel,
|
|
&i.PermissionMode,
|
|
&i.SupportsValidation,
|
|
&i.SellerExpectedPriceMin,
|
|
&i.SellerExpectedPriceMax,
|
|
&i.QualityLevel,
|
|
&i.ScarcityLevel,
|
|
&i.BaseValueScore,
|
|
&i.BasePriceMin,
|
|
&i.BasePriceMax,
|
|
&i.AssetStatus,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.UserID,
|
|
&i.AgentAssetSummary,
|
|
&i.AgentRecommendedTasks,
|
|
&i.AgentRiskPerMissionAdvice,
|
|
&i.AgentAssetExplanation,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getOrder = `-- name: GetOrder :one
|
|
SELECT id, asset_id, request_id, pricing_id, validation_id, asset_name, current_price, negotiation_min, negotiation_max, validation_used, delivery_mode, order_status, order_created_at, order_updated_at, user_id
|
|
FROM orders
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetOrder(ctx context.Context, id pgtype.UUID) (Order, error) {
|
|
row := q.db.QueryRow(ctx, getOrder, id)
|
|
var i Order
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.AssetID,
|
|
&i.RequestID,
|
|
&i.PricingID,
|
|
&i.ValidationID,
|
|
&i.AssetName,
|
|
&i.CurrentPrice,
|
|
&i.NegotiationMin,
|
|
&i.NegotiationMax,
|
|
&i.ValidationUsed,
|
|
&i.DeliveryMode,
|
|
&i.OrderStatus,
|
|
&i.OrderCreatedAt,
|
|
&i.OrderUpdatedAt,
|
|
&i.UserID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getPricingResult = `-- name: GetPricingResult :one
|
|
SELECT id, asset_id, request_id, scenario_value_score, scenario_price_min, scenario_price_max, suggested_price, success_probability, pricing_reason_1, pricing_reason_2, pricing_reason_3, verification_suggestion, pricing_status, created_at, updated_at, agent_task_match_explanation, agent_risk_advice, agent_budget_advice, agent_next_action
|
|
FROM pricing_results
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetPricingResult(ctx context.Context, id pgtype.UUID) (PricingResult, error) {
|
|
row := q.db.QueryRow(ctx, getPricingResult, id)
|
|
var i PricingResult
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.AssetID,
|
|
&i.RequestID,
|
|
&i.ScenarioValueScore,
|
|
&i.ScenarioPriceMin,
|
|
&i.ScenarioPriceMax,
|
|
&i.SuggestedPrice,
|
|
&i.SuccessProbability,
|
|
&i.PricingReason1,
|
|
&i.PricingReason2,
|
|
&i.PricingReason3,
|
|
&i.VerificationSuggestion,
|
|
&i.PricingStatus,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.AgentTaskMatchExplanation,
|
|
&i.AgentRiskAdvice,
|
|
&i.AgentBudgetAdvice,
|
|
&i.AgentNextAction,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getValidation = `-- name: GetValidation :one
|
|
SELECT id, asset_id, request_id, validation_type, validation_requested, validation_status, validation_signal, validation_score, risk_warning, continue_recommendation, validation_created_at, validation_finished_at, agent_validation_explanation, agent_continue_trade_advice, agent_delivery_advice, agent_risk_notice
|
|
FROM validations
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetValidation(ctx context.Context, id pgtype.UUID) (Validation, error) {
|
|
row := q.db.QueryRow(ctx, getValidation, id)
|
|
var i Validation
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.AssetID,
|
|
&i.RequestID,
|
|
&i.ValidationType,
|
|
&i.ValidationRequested,
|
|
&i.ValidationStatus,
|
|
&i.ValidationSignal,
|
|
&i.ValidationScore,
|
|
&i.RiskWarning,
|
|
&i.ContinueRecommendation,
|
|
&i.ValidationCreatedAt,
|
|
&i.ValidationFinishedAt,
|
|
&i.AgentValidationExplanation,
|
|
&i.AgentContinueTradeAdvice,
|
|
&i.AgentDeliveryAdvice,
|
|
&i.AgentRiskNotice,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listBuyerRequests = `-- name: ListBuyerRequests :many
|
|
SELECT id, asset_id, task_type, model_type, buyer_budget_min, buyer_budget_max, privacy_requirement, usage_purpose, request_note, request_status, created_at, updated_at, user_id
|
|
FROM buyer_requests
|
|
ORDER BY created_at DESC, id DESC
|
|
LIMIT $1 OFFSET $2
|
|
`
|
|
|
|
type ListBuyerRequestsParams struct {
|
|
Limit int32 `json:"limit"`
|
|
Offset int32 `json:"offset"`
|
|
}
|
|
|
|
func (q *Queries) ListBuyerRequests(ctx context.Context, arg ListBuyerRequestsParams) ([]BuyerRequest, error) {
|
|
rows, err := q.db.Query(ctx, listBuyerRequests, arg.Limit, arg.Offset)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []BuyerRequest
|
|
for rows.Next() {
|
|
var i BuyerRequest
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.AssetID,
|
|
&i.TaskType,
|
|
&i.ModelType,
|
|
&i.BuyerBudgetMin,
|
|
&i.BuyerBudgetMax,
|
|
&i.PrivacyRequirement,
|
|
&i.UsagePurpose,
|
|
&i.RequestNote,
|
|
&i.RequestStatus,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.UserID,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listDataAssets = `-- name: ListDataAssets :many
|
|
SELECT id, asset_name, asset_type, domain, application_scene, data_description, data_scale, collection_method, labeling_status, update_frequency, privacy_level, permission_mode, supports_validation, seller_expected_price_min, seller_expected_price_max, quality_level, scarcity_level, base_value_score, base_price_min, base_price_max, asset_status, created_at, updated_at, user_id, agent_asset_summary, agent_recommended_tasks, agent_risk_per_mission_advice, agent_asset_explanation
|
|
FROM data_assets
|
|
WHERE (
|
|
NULLIF($3::text, '') IS NULL
|
|
OR asset_name ILIKE '%' || $3::text || '%'
|
|
OR data_description ILIKE '%' || $3::text || '%'
|
|
)
|
|
AND (
|
|
NULLIF($4::text, '') IS NULL
|
|
OR asset_type = $4::text
|
|
)
|
|
AND (
|
|
NULLIF($5::text, '') IS NULL
|
|
OR domain = $5::text
|
|
)
|
|
AND (
|
|
NULLIF($6::text, '') IS NULL
|
|
OR privacy_level = $6::text
|
|
)
|
|
AND (
|
|
$7::boolean IS NULL
|
|
OR supports_validation = $7::boolean
|
|
)
|
|
ORDER BY created_at DESC, id DESC
|
|
LIMIT $1 OFFSET $2
|
|
`
|
|
|
|
type ListDataAssetsParams struct {
|
|
Limit int32 `json:"limit"`
|
|
Offset int32 `json:"offset"`
|
|
Keyword pgtype.Text `json:"keyword"`
|
|
AssetType pgtype.Text `json:"asset_type"`
|
|
Domain pgtype.Text `json:"domain"`
|
|
PrivacyLevel pgtype.Text `json:"privacy_level"`
|
|
SupportsValidation pgtype.Bool `json:"supports_validation"`
|
|
}
|
|
|
|
func (q *Queries) ListDataAssets(ctx context.Context, arg ListDataAssetsParams) ([]DataAsset, error) {
|
|
rows, err := q.db.Query(ctx, listDataAssets,
|
|
arg.Limit,
|
|
arg.Offset,
|
|
arg.Keyword,
|
|
arg.AssetType,
|
|
arg.Domain,
|
|
arg.PrivacyLevel,
|
|
arg.SupportsValidation,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []DataAsset
|
|
for rows.Next() {
|
|
var i DataAsset
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.AssetName,
|
|
&i.AssetType,
|
|
&i.Domain,
|
|
&i.ApplicationScene,
|
|
&i.DataDescription,
|
|
&i.DataScale,
|
|
&i.CollectionMethod,
|
|
&i.LabelingStatus,
|
|
&i.UpdateFrequency,
|
|
&i.PrivacyLevel,
|
|
&i.PermissionMode,
|
|
&i.SupportsValidation,
|
|
&i.SellerExpectedPriceMin,
|
|
&i.SellerExpectedPriceMax,
|
|
&i.QualityLevel,
|
|
&i.ScarcityLevel,
|
|
&i.BaseValueScore,
|
|
&i.BasePriceMin,
|
|
&i.BasePriceMax,
|
|
&i.AssetStatus,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.UserID,
|
|
&i.AgentAssetSummary,
|
|
&i.AgentRecommendedTasks,
|
|
&i.AgentRiskPerMissionAdvice,
|
|
&i.AgentAssetExplanation,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listOrders = `-- name: ListOrders :many
|
|
SELECT id, asset_id, request_id, pricing_id, validation_id, asset_name, current_price, negotiation_min, negotiation_max, validation_used, delivery_mode, order_status, order_created_at, order_updated_at, user_id
|
|
FROM orders
|
|
WHERE NULLIF($3::text, '') IS NULL
|
|
OR order_status = $3::text
|
|
ORDER BY order_created_at DESC, id DESC
|
|
LIMIT $1 OFFSET $2
|
|
`
|
|
|
|
type ListOrdersParams struct {
|
|
Limit int32 `json:"limit"`
|
|
Offset int32 `json:"offset"`
|
|
OrderStatus pgtype.Text `json:"order_status"`
|
|
}
|
|
|
|
func (q *Queries) ListOrders(ctx context.Context, arg ListOrdersParams) ([]Order, error) {
|
|
rows, err := q.db.Query(ctx, listOrders, arg.Limit, arg.Offset, arg.OrderStatus)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Order
|
|
for rows.Next() {
|
|
var i Order
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.AssetID,
|
|
&i.RequestID,
|
|
&i.PricingID,
|
|
&i.ValidationID,
|
|
&i.AssetName,
|
|
&i.CurrentPrice,
|
|
&i.NegotiationMin,
|
|
&i.NegotiationMax,
|
|
&i.ValidationUsed,
|
|
&i.DeliveryMode,
|
|
&i.OrderStatus,
|
|
&i.OrderCreatedAt,
|
|
&i.OrderUpdatedAt,
|
|
&i.UserID,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listPricingResults = `-- name: ListPricingResults :many
|
|
SELECT id, asset_id, request_id, scenario_value_score, scenario_price_min, scenario_price_max, suggested_price, success_probability, pricing_reason_1, pricing_reason_2, pricing_reason_3, verification_suggestion, pricing_status, created_at, updated_at, agent_task_match_explanation, agent_risk_advice, agent_budget_advice, agent_next_action
|
|
FROM pricing_results
|
|
ORDER BY created_at DESC, id DESC
|
|
LIMIT $1 OFFSET $2
|
|
`
|
|
|
|
type ListPricingResultsParams struct {
|
|
Limit int32 `json:"limit"`
|
|
Offset int32 `json:"offset"`
|
|
}
|
|
|
|
func (q *Queries) ListPricingResults(ctx context.Context, arg ListPricingResultsParams) ([]PricingResult, error) {
|
|
rows, err := q.db.Query(ctx, listPricingResults, arg.Limit, arg.Offset)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []PricingResult
|
|
for rows.Next() {
|
|
var i PricingResult
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.AssetID,
|
|
&i.RequestID,
|
|
&i.ScenarioValueScore,
|
|
&i.ScenarioPriceMin,
|
|
&i.ScenarioPriceMax,
|
|
&i.SuggestedPrice,
|
|
&i.SuccessProbability,
|
|
&i.PricingReason1,
|
|
&i.PricingReason2,
|
|
&i.PricingReason3,
|
|
&i.VerificationSuggestion,
|
|
&i.PricingStatus,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.AgentTaskMatchExplanation,
|
|
&i.AgentRiskAdvice,
|
|
&i.AgentBudgetAdvice,
|
|
&i.AgentNextAction,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listValidations = `-- name: ListValidations :many
|
|
SELECT id, asset_id, request_id, validation_type, validation_requested, validation_status, validation_signal, validation_score, risk_warning, continue_recommendation, validation_created_at, validation_finished_at, agent_validation_explanation, agent_continue_trade_advice, agent_delivery_advice, agent_risk_notice
|
|
FROM validations
|
|
ORDER BY validation_created_at DESC, id DESC
|
|
LIMIT $1 OFFSET $2
|
|
`
|
|
|
|
type ListValidationsParams struct {
|
|
Limit int32 `json:"limit"`
|
|
Offset int32 `json:"offset"`
|
|
}
|
|
|
|
func (q *Queries) ListValidations(ctx context.Context, arg ListValidationsParams) ([]Validation, error) {
|
|
rows, err := q.db.Query(ctx, listValidations, arg.Limit, arg.Offset)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Validation
|
|
for rows.Next() {
|
|
var i Validation
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.AssetID,
|
|
&i.RequestID,
|
|
&i.ValidationType,
|
|
&i.ValidationRequested,
|
|
&i.ValidationStatus,
|
|
&i.ValidationSignal,
|
|
&i.ValidationScore,
|
|
&i.RiskWarning,
|
|
&i.ContinueRecommendation,
|
|
&i.ValidationCreatedAt,
|
|
&i.ValidationFinishedAt,
|
|
&i.AgentValidationExplanation,
|
|
&i.AgentContinueTradeAdvice,
|
|
&i.AgentDeliveryAdvice,
|
|
&i.AgentRiskNotice,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const updateDataAssetStatus = `-- name: UpdateDataAssetStatus :one
|
|
UPDATE data_assets
|
|
SET asset_status = $2,
|
|
updated_at = now()
|
|
WHERE id = $1
|
|
RETURNING id, asset_name, asset_type, domain, application_scene, data_description, data_scale, collection_method, labeling_status, update_frequency, privacy_level, permission_mode, supports_validation, seller_expected_price_min, seller_expected_price_max, quality_level, scarcity_level, base_value_score, base_price_min, base_price_max, asset_status, created_at, updated_at, user_id, agent_asset_summary, agent_recommended_tasks, agent_risk_per_mission_advice, agent_asset_explanation
|
|
`
|
|
|
|
type UpdateDataAssetStatusParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
AssetStatus string `json:"asset_status"`
|
|
}
|
|
|
|
func (q *Queries) UpdateDataAssetStatus(ctx context.Context, arg UpdateDataAssetStatusParams) (DataAsset, error) {
|
|
row := q.db.QueryRow(ctx, updateDataAssetStatus, arg.ID, arg.AssetStatus)
|
|
var i DataAsset
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.AssetName,
|
|
&i.AssetType,
|
|
&i.Domain,
|
|
&i.ApplicationScene,
|
|
&i.DataDescription,
|
|
&i.DataScale,
|
|
&i.CollectionMethod,
|
|
&i.LabelingStatus,
|
|
&i.UpdateFrequency,
|
|
&i.PrivacyLevel,
|
|
&i.PermissionMode,
|
|
&i.SupportsValidation,
|
|
&i.SellerExpectedPriceMin,
|
|
&i.SellerExpectedPriceMax,
|
|
&i.QualityLevel,
|
|
&i.ScarcityLevel,
|
|
&i.BaseValueScore,
|
|
&i.BasePriceMin,
|
|
&i.BasePriceMax,
|
|
&i.AssetStatus,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.UserID,
|
|
&i.AgentAssetSummary,
|
|
&i.AgentRecommendedTasks,
|
|
&i.AgentRiskPerMissionAdvice,
|
|
&i.AgentAssetExplanation,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateOrderStatus = `-- name: UpdateOrderStatus :one
|
|
UPDATE orders
|
|
SET order_status = $2,
|
|
order_updated_at = now()
|
|
WHERE id = $1
|
|
RETURNING id, asset_id, request_id, pricing_id, validation_id, asset_name, current_price, negotiation_min, negotiation_max, validation_used, delivery_mode, order_status, order_created_at, order_updated_at, user_id
|
|
`
|
|
|
|
type UpdateOrderStatusParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
OrderStatus string `json:"order_status"`
|
|
}
|
|
|
|
func (q *Queries) UpdateOrderStatus(ctx context.Context, arg UpdateOrderStatusParams) (Order, error) {
|
|
row := q.db.QueryRow(ctx, updateOrderStatus, arg.ID, arg.OrderStatus)
|
|
var i Order
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.AssetID,
|
|
&i.RequestID,
|
|
&i.PricingID,
|
|
&i.ValidationID,
|
|
&i.AssetName,
|
|
&i.CurrentPrice,
|
|
&i.NegotiationMin,
|
|
&i.NegotiationMax,
|
|
&i.ValidationUsed,
|
|
&i.DeliveryMode,
|
|
&i.OrderStatus,
|
|
&i.OrderCreatedAt,
|
|
&i.OrderUpdatedAt,
|
|
&i.UserID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateValidationResult = `-- name: UpdateValidationResult :one
|
|
UPDATE validations
|
|
SET validation_status = $2,
|
|
validation_signal = $3,
|
|
validation_score = $4,
|
|
risk_warning = $5,
|
|
continue_recommendation = $6,
|
|
validation_finished_at = $7
|
|
WHERE id = $1
|
|
RETURNING id, asset_id, request_id, validation_type, validation_requested, validation_status, validation_signal, validation_score, risk_warning, continue_recommendation, validation_created_at, validation_finished_at, agent_validation_explanation, agent_continue_trade_advice, agent_delivery_advice, agent_risk_notice
|
|
`
|
|
|
|
type UpdateValidationResultParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
ValidationStatus string `json:"validation_status"`
|
|
ValidationSignal pgtype.Text `json:"validation_signal"`
|
|
ValidationScore pgtype.Numeric `json:"validation_score"`
|
|
RiskWarning pgtype.Text `json:"risk_warning"`
|
|
ContinueRecommendation pgtype.Text `json:"continue_recommendation"`
|
|
ValidationFinishedAt pgtype.Timestamptz `json:"validation_finished_at"`
|
|
}
|
|
|
|
func (q *Queries) UpdateValidationResult(ctx context.Context, arg UpdateValidationResultParams) (Validation, error) {
|
|
row := q.db.QueryRow(ctx, updateValidationResult,
|
|
arg.ID,
|
|
arg.ValidationStatus,
|
|
arg.ValidationSignal,
|
|
arg.ValidationScore,
|
|
arg.RiskWarning,
|
|
arg.ContinueRecommendation,
|
|
arg.ValidationFinishedAt,
|
|
)
|
|
var i Validation
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.AssetID,
|
|
&i.RequestID,
|
|
&i.ValidationType,
|
|
&i.ValidationRequested,
|
|
&i.ValidationStatus,
|
|
&i.ValidationSignal,
|
|
&i.ValidationScore,
|
|
&i.RiskWarning,
|
|
&i.ContinueRecommendation,
|
|
&i.ValidationCreatedAt,
|
|
&i.ValidationFinishedAt,
|
|
&i.AgentValidationExplanation,
|
|
&i.AgentContinueTradeAdvice,
|
|
&i.AgentDeliveryAdvice,
|
|
&i.AgentRiskNotice,
|
|
)
|
|
return i, err
|
|
}
|