待测试
This commit is contained in:
+79
-4
@@ -521,13 +521,20 @@ const normalizeProfileUpdatePayload = (payload) => {
|
||||
throw new TypeError('个人资料请求包含未声明字段')
|
||||
}
|
||||
const normalized = {}
|
||||
for (const [field, limit] of [['nickName', 30], ['realName', 30], ['sex', Infinity]]) {
|
||||
for (const [field, limit] of [['nickName', 30], ['realName', 30]]) {
|
||||
if (!Object.prototype.hasOwnProperty.call(payload, field)) continue
|
||||
const value = normalizeOptionalAuthText(payload[field], field)
|
||||
if (!value) continue
|
||||
if (value.length > limit) throw new TypeError(`${field} 超出长度限制`)
|
||||
normalized[field] = value
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(payload, 'sex')) {
|
||||
const sex = normalizeOptionalAuthText(payload.sex, 'sex')
|
||||
if (sex) {
|
||||
if (!['0', '1', '2'].includes(sex)) throw new TypeError('sex 必须为 0、1 或 2')
|
||||
normalized.sex = sex
|
||||
}
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(payload, 'birthday')) {
|
||||
const value = normalizeOptionalAuthText(payload.birthday, 'birthday')
|
||||
if (value) {
|
||||
@@ -705,7 +712,12 @@ const normalizeFeedbackPayload = (payload) => {
|
||||
throw new TypeError(`反馈字段 ${optionalField} 必须是字符串`)
|
||||
}
|
||||
const value = payload[optionalField].trim()
|
||||
if (value) normalized[optionalField] = value
|
||||
if (value) {
|
||||
if (optionalField === 'feedbackType' && !['advice', 'bug', 'complaint', 'other'].includes(value)) {
|
||||
throw new TypeError('feedbackType 必须为 advice、bug、complaint 或 other')
|
||||
}
|
||||
normalized[optionalField] = value
|
||||
}
|
||||
}
|
||||
return normalized
|
||||
}
|
||||
@@ -1586,17 +1598,62 @@ const normalizeAlbumPhotoCreatePayload = (payload) => {
|
||||
return data
|
||||
}
|
||||
|
||||
const normalizeVideoPayload = (payload) => {
|
||||
const allowedFields = new Set(['videoTitle', 'videoDesc', 'coverOssId', 'videoOssId', 'durationSeconds', 'sortOrder', 'status'])
|
||||
assertPlainPayload(payload, allowedFields, '视频请求')
|
||||
const videoTitle = normalizeOptionalAuthText(payload.videoTitle, '视频标题')
|
||||
if (!videoTitle) throw new TypeError('视频标题不能为空')
|
||||
const videoOssId = normalizeOssIdString(payload.videoOssId, '视频文件 OSS ID')
|
||||
const data = { videoTitle, videoOssId }
|
||||
const videoDesc = normalizeOptionalAuthText(payload.videoDesc, '视频说明')
|
||||
if (videoDesc) data.videoDesc = videoDesc
|
||||
if (payload.coverOssId !== undefined && payload.coverOssId !== null && payload.coverOssId !== '') {
|
||||
data.coverOssId = normalizeOssIdString(payload.coverOssId, '视频封面 OSS ID')
|
||||
}
|
||||
for (const field of ['durationSeconds', 'sortOrder']) {
|
||||
const value = normalizeOptionalSafeInteger(payload[field], field)
|
||||
if (value !== undefined) data[field] = value
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(payload, 'status')) {
|
||||
const status = normalizeOptionalAuthText(payload.status, 'status')
|
||||
if (status) {
|
||||
if (!['0', '1'].includes(status)) throw new TypeError('status 必须为 0 或 1')
|
||||
data.status = status
|
||||
}
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
const normalizeCeremonyPayload = (payload) => {
|
||||
const allowedFields = new Set(['ceremonyType', 'ceremonyTitle', 'ceremonyDesc', 'ceremonyTime', 'location', 'coverOssId', 'sortOrder', 'status'])
|
||||
const allowedFields = new Set(['ceremonyType', 'ceremonyTitle', 'ceremonyDesc', 'ceremonyTime', 'location', 'locationAddress', 'longitude', 'latitude', 'coverOssId', 'sortOrder', 'status'])
|
||||
assertPlainPayload(payload, allowedFields, '礼仪活动请求')
|
||||
const ceremonyType = normalizeOptionalAuthText(payload.ceremonyType, 'ceremonyType')
|
||||
const ceremonyTitle = normalizeOptionalAuthText(payload.ceremonyTitle, 'ceremonyTitle')
|
||||
if (!ceremonyType || !ceremonyTitle) throw new TypeError('请填写活动类型和活动标题')
|
||||
const data = { ceremonyType, ceremonyTitle }
|
||||
for (const field of ['ceremonyDesc', 'ceremonyTime', 'location', 'status']) {
|
||||
for (const field of ['ceremonyDesc', 'ceremonyTime', 'location', 'locationAddress']) {
|
||||
const value = normalizeOptionalAuthText(payload[field], field)
|
||||
if (value) data[field] = value
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(payload, 'status')) {
|
||||
const status = normalizeOptionalAuthText(payload.status, 'status')
|
||||
if (status) {
|
||||
if (!['0', '1'].includes(status)) throw new TypeError('status 必须为 0 或 1')
|
||||
data.status = status
|
||||
}
|
||||
}
|
||||
const hasLongitude = payload.longitude !== undefined && payload.longitude !== null && payload.longitude !== ''
|
||||
const hasLatitude = payload.latitude !== undefined && payload.latitude !== null && payload.latitude !== ''
|
||||
if (hasLongitude !== hasLatitude) throw new TypeError('longitude 和 latitude 必须同时提供')
|
||||
if (hasLongitude) {
|
||||
const longitude = typeof payload.longitude === 'number' ? payload.longitude : Number(payload.longitude)
|
||||
const latitude = typeof payload.latitude === 'number' ? payload.latitude : Number(payload.latitude)
|
||||
if (!Number.isFinite(longitude) || !Number.isFinite(latitude)) {
|
||||
throw new TypeError('longitude 和 latitude 必须是有限数字')
|
||||
}
|
||||
data.longitude = longitude
|
||||
data.latitude = latitude
|
||||
}
|
||||
if (payload.coverOssId !== undefined && payload.coverOssId !== null && payload.coverOssId !== '') {
|
||||
data.coverOssId = normalizeOssIdString(payload.coverOssId, 'coverOssId')
|
||||
}
|
||||
@@ -3301,6 +3358,24 @@ export const appApi = {
|
||||
async getFeedback(requestOptions = {}) {
|
||||
return readRemoteList('/genealogy/app/feedback', '我的反馈', requestOptions)
|
||||
},
|
||||
async getVideos(genealogyId, requestOptions = {}) {
|
||||
const id = normalizeGenealogyPathId(genealogyId)
|
||||
return readRemoteList(`/genealogy/app/genealogies/${id}/videos`, '家族视频', requestOptions)
|
||||
},
|
||||
async getVideoDetail(genealogyId, videoId, requestOptions = {}) {
|
||||
const id = normalizeGenealogyPathId(genealogyId)
|
||||
const normalizedVideoId = normalizeResourcePathId(videoId, '视频标识')
|
||||
return readRemoteObject(`/genealogy/app/genealogies/${id}/videos/${normalizedVideoId}`, '家族视频详情', requestOptions)
|
||||
},
|
||||
async createVideo(genealogyId, payload, requestOptions = {}) {
|
||||
const id = normalizeGenealogyPathId(genealogyId)
|
||||
return writeRemoteObject(`/genealogy/app/genealogies/${id}/videos`, 'POST', normalizeVideoPayload(payload), '家族视频', requestOptions)
|
||||
},
|
||||
async updateVideo(genealogyId, videoId, payload, requestOptions = {}) {
|
||||
const id = normalizeGenealogyPathId(genealogyId)
|
||||
const normalizedVideoId = normalizeResourcePathId(videoId, '视频标识')
|
||||
return writeRemoteObject(`/genealogy/app/genealogies/${id}/videos/${normalizedVideoId}`, 'PUT', normalizeVideoPayload(payload), '家族视频', requestOptions)
|
||||
},
|
||||
async deleteVideo(genealogyId, videoId, requestOptions = {}) {
|
||||
const id = normalizeGenealogyPathId(genealogyId)
|
||||
const normalizedVideoId = normalizeResourcePathId(videoId, '视频标识')
|
||||
|
||||
Reference in New Issue
Block a user