首页接口更新&&支付页面调试
This commit is contained in:
@@ -1,34 +1,11 @@
|
||||
'use server'
|
||||
|
||||
import {ApiResponse, ExtraResp} from '@/lib/api'
|
||||
import {callByUser} from './base'
|
||||
|
||||
export async function listInitialization(props: {
|
||||
page: number
|
||||
size: number
|
||||
title?: string
|
||||
type?: number
|
||||
status?: number
|
||||
create_after?: Date
|
||||
create_before?: Date
|
||||
update_after?: Date
|
||||
update_before?: Date
|
||||
short_term_package?: number
|
||||
}) {
|
||||
return await callByUser<{
|
||||
short_term: string
|
||||
short_term_monthly: string
|
||||
long_term: string
|
||||
long_term_monthly: string
|
||||
list: {
|
||||
id: number
|
||||
title: string
|
||||
created_at: Date
|
||||
}[]
|
||||
}>('/api/announcement/list', props)
|
||||
}
|
||||
import {listAnnouncements} from './announcement'
|
||||
|
||||
type listAccountReq = {
|
||||
resource_no: string
|
||||
resource_no?: string
|
||||
create_after: Date
|
||||
create_before: Date
|
||||
}
|
||||
@@ -39,5 +16,68 @@ type listAccountResp = {
|
||||
}[]
|
||||
|
||||
export async function listAccount(props: listAccountReq) {
|
||||
return await callByUser<listAccountResp>('/api/account/list', props)
|
||||
return await callByUser<listAccountResp>('/api/resource/statistics/usage', props)
|
||||
}
|
||||
|
||||
export async function statisticsResourceFree() {
|
||||
return await callByUser<{
|
||||
long: {
|
||||
ResourceCount: number
|
||||
ResourceDailyFreeSum: number
|
||||
ResourceQuotaSum: number
|
||||
}
|
||||
short: {
|
||||
ResourceCount: number
|
||||
ResourceDailyFreeSum: number
|
||||
ResourceQuotaSum: number
|
||||
}
|
||||
}>('/api/resource/statistics/free')
|
||||
}
|
||||
|
||||
type listInitializationResp = {
|
||||
anno: ExtraResp<typeof listAnnouncements>
|
||||
free: ExtraResp<typeof statisticsResourceFree>
|
||||
usage: ExtraResp<typeof listAccount>
|
||||
}
|
||||
export async function listInitialization(): Promise<ApiResponse<listInitializationResp>> {
|
||||
const free = await statisticsResourceFree()
|
||||
if (!free.success) {
|
||||
return {
|
||||
success: false,
|
||||
status: 500,
|
||||
message: '套餐剩余数据获取失败',
|
||||
}
|
||||
}
|
||||
const anno = await listAnnouncements({
|
||||
page: 1,
|
||||
size: 5,
|
||||
})
|
||||
if (!anno.success) {
|
||||
return {
|
||||
success: false,
|
||||
status: 500,
|
||||
message: '公告数据获取失败',
|
||||
}
|
||||
}
|
||||
const usage = await listAccount({
|
||||
create_after: new Date(),
|
||||
create_before: new Date(),
|
||||
})
|
||||
if (!usage.success) {
|
||||
return {
|
||||
success: false,
|
||||
status: 500,
|
||||
message: '套餐用量数据获取失败',
|
||||
}
|
||||
}
|
||||
const data = {
|
||||
anno: anno.data,
|
||||
free: free.data,
|
||||
usage: usage.data,
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: data,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user