feat: migrate app routes and business modules
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { hasRemoteConfig } from '@/utils/runtime-config.js'
|
||||
import {
|
||||
normalizeVipCapability,
|
||||
normalizeVipOrders,
|
||||
normalizeVipPackages
|
||||
} from './vip-contract.js'
|
||||
import {
|
||||
createRequestError,
|
||||
requestStrict
|
||||
} from './request-client.js'
|
||||
|
||||
const requireRemoteVip = (label) => {
|
||||
if (hasRemoteConfig()) return
|
||||
throw createRequestError(`${label}读取需要真实服务,当前本地预览不会伪造结果`, 'REMOTE_READ_REQUIRED')
|
||||
}
|
||||
|
||||
export const vipApi = {
|
||||
async getVipCapability(requestOptions = {}) {
|
||||
requireRemoteVip('VIP 购买能力')
|
||||
const capability = await requestStrict({
|
||||
url: '/genealogy/app/vip/capability',
|
||||
method: 'GET'
|
||||
}, {
|
||||
requestController: requestOptions.requestController ?? null
|
||||
})
|
||||
return normalizeVipCapability(capability)
|
||||
},
|
||||
|
||||
async getVipPackages(requestOptions = {}) {
|
||||
requireRemoteVip('VIP 套餐')
|
||||
const packages = await requestStrict({
|
||||
url: '/genealogy/app/vip/packages',
|
||||
method: 'GET'
|
||||
}, {
|
||||
requestController: requestOptions.requestController ?? null
|
||||
})
|
||||
return normalizeVipPackages(packages)
|
||||
},
|
||||
|
||||
async getVipOrders(requestOptions = {}) {
|
||||
requireRemoteVip('VIP 订单')
|
||||
const orders = await requestStrict({
|
||||
url: '/genealogy/app/vip/orders',
|
||||
method: 'GET'
|
||||
}, {
|
||||
requestController: requestOptions.requestController ?? null
|
||||
})
|
||||
return normalizeVipOrders(orders)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user