Files
geo/apps/ops-web/src/lib/media-supply.ts
T
root aa96143754 style: format web apps with prettier and sort imports
Apply repo-wide Prettier/lint normalization across admin-web,
desktop-client and ops-web: single quotes, no semicolons, trailing
commas, consistent line wrapping, and import ordering. Also drop an
unused brand-logo import in DesktopShell.vue.

No behavior changes — formatting only.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-08 11:56:18 +08:00

122 lines
3.0 KiB
TypeScript

import { http } from '@/lib/http'
export interface OpsMediaSupplyResource {
id: number
supplier_resource_id: string
model_id: number
name: string
status: string
cost_price_cents: number
cost_prices: Record<string, number>
sell_price_cents: number
resource_url?: string | null
baidu_weight?: number | null
resource_remark?: string | null
customer_visible: boolean
channel_type?: string | null
region?: string | null
inclusion_effect?: string | null
link_type?: string | null
publish_rate?: string | null
delivery_speed?: string | null
last_synced_at: string
}
export interface OpsMediaSupplyResourcesParams {
model_id?: number
keyword?: string
remark_keyword?: string
channel_type?: string
region?: string
inclusion_effect?: string
link_type?: string
min_price_cents?: number
max_price_cents?: number
visibility?: string
page?: number
page_size?: number
}
export interface OpsMediaSupplyResourcesResponse {
items: OpsMediaSupplyResource[]
total: number
page: number
size: number
}
export interface OpsMediaSupplyWallet {
tenant_id: number
tenant_name?: string | null
user_id: number
user_name?: string | null
user_phone?: string | null
balance_cents: number
updated_at: string
last_ledger_at?: string | null
ledger_entries: number
}
export interface OpsMediaSupplyWalletsResponse {
items: OpsMediaSupplyWallet[]
total: number
page: number
size: number
}
export interface OpsMediaSupplyWalletsParams {
keyword?: string
tenant_id?: number
page?: number
page_size?: number
}
export const opsMediaSupplyApi = {
listResources(params: OpsMediaSupplyResourcesParams) {
return http.get<OpsMediaSupplyResourcesResponse>(
'/media-supply/resources',
params as Record<string, unknown>,
)
},
setPrice(
id: number,
payload: { price_type?: string; sell_price_cents: number; enabled?: boolean },
) {
return http.put<{ updated: boolean }, typeof payload>(
`/media-supply/resources/${id}/price`,
payload,
)
},
setVisibility(id: number, customerVisible: boolean) {
return http.put<{ updated: boolean }, { customer_visible: boolean }>(
`/media-supply/resources/${id}/visibility`,
{ customer_visible: customerVisible },
)
},
queueSync(modelId = 1) {
return http.post<
{ id: number; job_key: string; status: string },
{ reason: string; config_override: { model_id: number } }
>('/scheduler/jobs/media_supply_cache_sync/run', {
reason: 'ops 手动同步媒体资源缓存',
config_override: { model_id: modelId },
})
},
listWallets(params: OpsMediaSupplyWalletsParams) {
return http.get<OpsMediaSupplyWalletsResponse>(
'/media-supply/wallets',
params as Record<string, unknown>,
)
},
adjustWallet(payload: {
tenant_id: number
user_id: number
delta_cents: number
note?: string
}) {
return http.post<OpsMediaSupplyWallet, typeof payload>(
'/media-supply/wallets/adjustments',
payload,
)
},
}