feat: 完成前端业务闭环与后端联调
This commit is contained in:
@@ -1,32 +1,22 @@
|
||||
import { listPreviewCeremonies } from '@/data/preview/records.js'
|
||||
import { hasRemoteConfig } from '@/utils/runtime-config.js'
|
||||
import {
|
||||
normalizeAppCeremonies,
|
||||
normalizeAppCeremony,
|
||||
normalizeAppCeremonyGift,
|
||||
normalizeAppCeremonyGifts,
|
||||
normalizeAppCeremonyWithTypeLabel,
|
||||
normalizeCeremonyGiftPayload,
|
||||
normalizeCeremonyInvitationResponsePayload,
|
||||
normalizeCeremonyInvitationRows,
|
||||
normalizeCeremonyInviteeOptions,
|
||||
normalizeCeremonyInviteePayload,
|
||||
normalizeCeremonyPayload,
|
||||
projectPreviewCeremonies
|
||||
normalizeCeremonyPayload
|
||||
} from './ceremony-contract.js'
|
||||
import { normalizeGenealogyPathId } from './genealogy-contract.js'
|
||||
import { normalizeResourcePathId } from './request-normalizers.js'
|
||||
import { createRequestError, requestStrict } from './request-client.js'
|
||||
|
||||
const requireRemoteCeremony = (message, code) => {
|
||||
if (hasRemoteConfig()) return
|
||||
throw createRequestError(message, code)
|
||||
}
|
||||
import { requestStrict } from './request-client.js'
|
||||
|
||||
export const ceremonyApi = {
|
||||
async createCeremony(genealogyId, payload, requestOptions = {}) {
|
||||
const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId)
|
||||
requireRemoteCeremony('创建礼仪活动需要真实服务,当前本地预览不会伪造保存成功', 'REMOTE_WRITE_REQUIRED')
|
||||
return requestStrict({
|
||||
url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies`,
|
||||
method: 'POST',
|
||||
@@ -37,7 +27,6 @@ export const ceremonyApi = {
|
||||
async updateCeremony(genealogyId, ceremonyId, payload, requestOptions = {}) {
|
||||
const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId)
|
||||
const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识')
|
||||
requireRemoteCeremony('修改礼仪活动需要真实服务,当前本地预览不会伪造保存成功', 'REMOTE_WRITE_REQUIRED')
|
||||
return requestStrict({
|
||||
url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}`,
|
||||
method: 'PUT',
|
||||
@@ -48,7 +37,6 @@ export const ceremonyApi = {
|
||||
async deleteCeremony(genealogyId, ceremonyId, requestOptions = {}) {
|
||||
const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId)
|
||||
const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识')
|
||||
requireRemoteCeremony('删除礼仪活动需要真实服务,当前本地预览不会伪造删除成功', 'REMOTE_WRITE_REQUIRED')
|
||||
await requestStrict({
|
||||
url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}`,
|
||||
method: 'DELETE'
|
||||
@@ -59,7 +47,6 @@ export const ceremonyApi = {
|
||||
async createCeremonyGift(genealogyId, ceremonyId, payload, requestOptions = {}) {
|
||||
const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId)
|
||||
const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识')
|
||||
requireRemoteCeremony('新增礼仪献礼需要真实服务,当前本地预览不会伪造保存成功', 'REMOTE_WRITE_REQUIRED')
|
||||
const gift = await requestStrict({
|
||||
url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}/gifts`,
|
||||
method: 'POST',
|
||||
@@ -72,7 +59,6 @@ export const ceremonyApi = {
|
||||
const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId)
|
||||
const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识')
|
||||
const normalizedGiftId = normalizeResourcePathId(giftId, '献礼标识')
|
||||
requireRemoteCeremony('删除礼仪献礼需要真实服务,当前本地预览不会伪造删除成功', 'REMOTE_WRITE_REQUIRED')
|
||||
await requestStrict({
|
||||
url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}/gifts/${normalizedGiftId}`,
|
||||
method: 'DELETE'
|
||||
@@ -82,9 +68,6 @@ export const ceremonyApi = {
|
||||
|
||||
async getCeremonies(genealogyId, requestOptions = {}) {
|
||||
const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId)
|
||||
if (!hasRemoteConfig()) {
|
||||
return projectPreviewCeremonies(listPreviewCeremonies(normalizedGenealogyId), normalizedGenealogyId)
|
||||
}
|
||||
const ceremonies = await requestStrict({
|
||||
url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies`,
|
||||
method: 'GET'
|
||||
@@ -96,7 +79,6 @@ export const ceremonyApi = {
|
||||
const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId)
|
||||
const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识')
|
||||
const invitees = normalizeCeremonyInviteePayload(payload)
|
||||
requireRemoteCeremony('活动受邀人写入需要真实服务,当前本地预览不会伪造结果', 'REMOTE_WRITE_REQUIRED')
|
||||
const invitations = await requestStrict({
|
||||
url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}/invitees`,
|
||||
method: 'PUT',
|
||||
@@ -108,7 +90,6 @@ export const ceremonyApi = {
|
||||
async getCeremonyInviteeOptions(genealogyId, ceremonyId, requestOptions = {}) {
|
||||
const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId)
|
||||
const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识')
|
||||
requireRemoteCeremony('活动受邀候选读取需要真实服务,当前本地预览不会伪造结果', 'REMOTE_READ_REQUIRED')
|
||||
const options = await requestStrict({
|
||||
url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}/invitee-options`,
|
||||
method: 'GET'
|
||||
@@ -119,7 +100,6 @@ export const ceremonyApi = {
|
||||
async getCeremonyInvitations(genealogyId, ceremonyId, requestOptions = {}) {
|
||||
const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId)
|
||||
const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识')
|
||||
requireRemoteCeremony('活动邀请名单读取需要真实服务,当前本地预览不会伪造结果', 'REMOTE_READ_REQUIRED')
|
||||
const invitations = await requestStrict({
|
||||
url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}/invitations`,
|
||||
method: 'GET'
|
||||
@@ -131,7 +111,6 @@ export const ceremonyApi = {
|
||||
const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId)
|
||||
const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识')
|
||||
const response = normalizeCeremonyInvitationResponsePayload(payload)
|
||||
requireRemoteCeremony('活动邀请响应写入需要真实服务,当前本地预览不会伪造结果', 'REMOTE_WRITE_REQUIRED')
|
||||
return requestStrict({
|
||||
url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}/invitations/me`,
|
||||
method: 'PUT',
|
||||
@@ -140,7 +119,6 @@ export const ceremonyApi = {
|
||||
},
|
||||
|
||||
async getMyCeremonyInvitations(requestOptions = {}) {
|
||||
requireRemoteCeremony('我的活动邀请读取需要真实服务,当前本地预览不会伪造结果', 'REMOTE_READ_REQUIRED')
|
||||
const invitations = await requestStrict({
|
||||
url: '/genealogy/app/genealogies/ceremony-invitations/mine',
|
||||
method: 'GET'
|
||||
@@ -151,20 +129,16 @@ export const ceremonyApi = {
|
||||
async getCeremonyDetail(genealogyId, ceremonyId, requestOptions = {}) {
|
||||
const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId)
|
||||
const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识')
|
||||
requireRemoteCeremony('礼仪详情需要真实读取服务,当前本地预览不会伪造详情', 'REMOTE_READ_REQUIRED')
|
||||
const ceremony = await requestStrict({
|
||||
url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}`,
|
||||
method: 'GET'
|
||||
}, { requestController: requestOptions.requestController ?? null })
|
||||
return normalizeAppCeremonyWithTypeLabel(
|
||||
normalizeAppCeremony(ceremony, normalizedGenealogyId, normalizedCeremonyId)
|
||||
)
|
||||
return normalizeAppCeremony(ceremony, normalizedGenealogyId, normalizedCeremonyId)
|
||||
},
|
||||
|
||||
async getCeremonyGifts(genealogyId, ceremonyId, requestOptions = {}) {
|
||||
const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId)
|
||||
const normalizedCeremonyId = normalizeResourcePathId(ceremonyId, '礼仪活动标识')
|
||||
requireRemoteCeremony('礼仪献礼需要真实读取服务,当前本地预览不会伪造列表', 'REMOTE_READ_REQUIRED')
|
||||
const gifts = await requestStrict({
|
||||
url: `/genealogy/app/genealogies/${normalizedGenealogyId}/ceremonies/${normalizedCeremonyId}/gifts`,
|
||||
method: 'GET'
|
||||
|
||||
Reference in New Issue
Block a user