511 lines
14 KiB
Go
511 lines
14 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 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, asset_status)
|
|
VALUES ($1, $2, $3, $4,
|
|
$5, $6, $7, $8,
|
|
$9, $10, $11, $12,
|
|
$13, $14, $15)
|
|
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"`
|
|
AssetStatus string `json:"asset_status"`
|
|
}
|
|
|
|
func (q *Queries) CreateDataAsset(ctx context.Context, arg CreateDataAssetParams) (DataAsset, 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.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,
|
|
)
|
|
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
|
|
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,
|
|
)
|
|
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
|
|
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,
|
|
)
|
|
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
|
|
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,
|
|
)
|
|
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
|
|
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,
|
|
)
|
|
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
|
|
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,
|
|
)
|
|
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
|
|
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,
|
|
); 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
|
|
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,
|
|
); 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
|
|
FROM orders
|
|
ORDER BY order_created_at DESC, id DESC
|
|
LIMIT $1 OFFSET $2
|
|
`
|
|
|
|
type ListOrdersParams struct {
|
|
Limit int32 `json:"limit"`
|
|
Offset int32 `json:"offset"`
|
|
}
|
|
|
|
func (q *Queries) ListOrders(ctx context.Context, arg ListOrdersParams) ([]Order, error) {
|
|
rows, err := q.db.Query(ctx, listOrders, arg.Limit, arg.Offset)
|
|
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,
|
|
); 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
|
|
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,
|
|
); 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
|
|
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,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|