数据库文档编写,开发规范文档,数据库接入
This commit is contained in:
@@ -20,8 +20,19 @@ function safeNumber(v: any): number {
|
||||
return isFinite(n) ? n : 0
|
||||
}
|
||||
|
||||
export async function fetchProductOverview(period: string): Promise<ProductOverview> {
|
||||
const { startIso, endIso } = computeDateRange(period)
|
||||
export async function fetchProductOverview(period: string, range?: { start: string; end: string } | null): Promise<ProductOverview> {
|
||||
let startIso: string;
|
||||
let endIso: string;
|
||||
|
||||
if (range != null && range.start && range.end) {
|
||||
startIso = range.start;
|
||||
endIso = range.end;
|
||||
} else {
|
||||
const computedRange = computeDateRange(period)
|
||||
startIso = computedRange.startIso
|
||||
endIso = computedRange.endIso
|
||||
}
|
||||
|
||||
const row = await rpcOrNull('rpc_product_insights_overview', {
|
||||
p_start: toDateOnly(startIso),
|
||||
p_end: toDateOnly(endIso)
|
||||
@@ -39,8 +50,19 @@ export async function fetchProductOverview(period: string): Promise<ProductOverv
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchTopProducts(period: string, limit: number = 10): Promise<Array<ProductRank>> {
|
||||
const { startIso, endIso } = computeDateRange(period)
|
||||
export async function fetchTopProducts(period: string, limit: number = 10, range?: { start: string; end: string } | null): Promise<Array<ProductRank>> {
|
||||
let startIso: string;
|
||||
let endIso: string;
|
||||
|
||||
if (range != null && range.start && range.end) {
|
||||
startIso = range.start;
|
||||
endIso = range.end;
|
||||
} else {
|
||||
const computedRange = computeDateRange(period)
|
||||
startIso = computedRange.startIso
|
||||
endIso = computedRange.endIso
|
||||
}
|
||||
|
||||
const rows = await rpcOrEmptyArray('rpc_analytics_top_products', {
|
||||
p_start_date: toDateOnly(startIso),
|
||||
p_end_date: toDateOnly(endIso),
|
||||
@@ -61,8 +83,19 @@ export async function fetchTopProducts(period: string, limit: number = 10): Prom
|
||||
return list
|
||||
}
|
||||
|
||||
export async function fetchProductTrend(period: string, productId: string): Promise<Array<ProductTrendRow>> {
|
||||
const { startIso, endIso } = computeDateRange(period)
|
||||
export async function fetchProductTrend(period: string, productId: string, range?: { start: string; end: string } | null): Promise<Array<ProductTrendRow>> {
|
||||
let startIso: string;
|
||||
let endIso: string;
|
||||
|
||||
if (range != null && range.start && range.end) {
|
||||
startIso = range.start;
|
||||
endIso = range.end;
|
||||
} else {
|
||||
const computedRange = computeDateRange(period)
|
||||
startIso = computedRange.startIso
|
||||
endIso = computedRange.endIso
|
||||
}
|
||||
|
||||
const rows = await rpcOrEmptyArray('rpc_analytics_product_trend', {
|
||||
p_start_date: toDateOnly(startIso),
|
||||
p_end_date: toDateOnly(endIso),
|
||||
@@ -83,8 +116,19 @@ export async function fetchProductTrend(period: string, productId: string): Prom
|
||||
return out
|
||||
}
|
||||
|
||||
export async function fetchCategorySales(period: string): Promise<Array<UTSJSONObject>> {
|
||||
const { startIso, endIso } = computeDateRange(period)
|
||||
export async function fetchCategorySales(period: string, range?: { start: string; end: string } | null): Promise<Array<UTSJSONObject>> {
|
||||
let startIso: string;
|
||||
let endIso: string;
|
||||
|
||||
if (range != null && range.start && range.end) {
|
||||
startIso = range.start;
|
||||
endIso = range.end;
|
||||
} else {
|
||||
const computedRange = computeDateRange(period)
|
||||
startIso = computedRange.startIso
|
||||
endIso = computedRange.endIso
|
||||
}
|
||||
|
||||
return await rpcOrEmptyArray('rpc_analytics_category_sales', {
|
||||
p_start_date: toDateOnly(startIso),
|
||||
p_end_date: toDateOnly(endIso)
|
||||
@@ -95,8 +139,19 @@ export async function fetchStockInsights(period: string): Promise<Array<UTSJSONO
|
||||
return await rpcOrEmptyArray('rpc_product_insights_stock', {} as any)
|
||||
}
|
||||
|
||||
export async function fetchPriceTrend(period: string): Promise<Array<UTSJSONObject>> {
|
||||
const { startIso, endIso } = computeDateRange(period)
|
||||
export async function fetchPriceTrend(period: string, range?: { start: string; end: string } | null): Promise<Array<UTSJSONObject>> {
|
||||
let startIso: string;
|
||||
let endIso: string;
|
||||
|
||||
if (range != null && range.start && range.end) {
|
||||
startIso = range.start;
|
||||
endIso = range.end;
|
||||
} else {
|
||||
const computedRange = computeDateRange(period)
|
||||
startIso = computedRange.startIso
|
||||
endIso = computedRange.endIso
|
||||
}
|
||||
|
||||
return await rpcOrEmptyArray('rpc_analytics_price_trend', {
|
||||
p_start: startIso,
|
||||
p_end: endIso
|
||||
|
||||
Reference in New Issue
Block a user