现在有的接口对接测试完成
This commit is contained in:
+176
-38
@@ -52,17 +52,6 @@
|
||||
return data && (data.token || data.accessToken || data.access_token || data.tokenValue) || '';
|
||||
}
|
||||
|
||||
function createFormData(fileOrFormData) {
|
||||
var FormDataCtor = root.FormData;
|
||||
|
||||
if (FormDataCtor && fileOrFormData instanceof FormDataCtor) return fileOrFormData;
|
||||
if (!FormDataCtor) throw new Error('当前环境不支持文件上传');
|
||||
|
||||
var formData = new FormDataCtor();
|
||||
formData.append('file', fileOrFormData);
|
||||
return formData;
|
||||
}
|
||||
|
||||
function createChunkFormData(bodyOrFormData) {
|
||||
var FormDataCtor = root.FormData;
|
||||
var source = bodyOrFormData || {};
|
||||
@@ -132,11 +121,15 @@
|
||||
}
|
||||
|
||||
function withTenant(body) {
|
||||
return Object.assign({ tenantId: tenantId, clientId: clientId }, body || {});
|
||||
return Object.assign({ tenantId: tenantId }, body || {});
|
||||
}
|
||||
|
||||
function withClient(body) {
|
||||
return Object.assign({}, body || {}, { clientId: clientId });
|
||||
function buildVerificationPath(operationCode, suffix) {
|
||||
return '/genealogy/pc/auth/verification/' + toRequiredPathId(operationCode, 'PC 认证动作') + (suffix || '');
|
||||
}
|
||||
|
||||
function buildSmsCodePath(operationCode) {
|
||||
return '/genealogy/pc/auth/sms/' + toRequiredPathId(operationCode, 'PC 短信认证动作') + '/code';
|
||||
}
|
||||
|
||||
function toRequiredPathId(value, label) {
|
||||
@@ -182,6 +175,63 @@
|
||||
);
|
||||
}
|
||||
|
||||
function buildGrowthRecordPath(genealogyId, recordId) {
|
||||
var path = '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') + '/growth-records';
|
||||
|
||||
return recordId === undefined || recordId === null || recordId === ''
|
||||
? path
|
||||
: path + '/' + toRequiredPathId(recordId, '成长记录编号');
|
||||
}
|
||||
|
||||
function buildRelativeRecordPath(genealogyId, relativeId) {
|
||||
var path = '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') + '/relative-records';
|
||||
|
||||
return relativeId === undefined || relativeId === null || relativeId === ''
|
||||
? path
|
||||
: path + '/' + toRequiredPathId(relativeId, '亲友记录编号');
|
||||
}
|
||||
|
||||
function buildMemoPath(genealogyId, memoId) {
|
||||
var path = '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') + '/memos';
|
||||
|
||||
return memoId === undefined || memoId === null || memoId === ''
|
||||
? path
|
||||
: path + '/' + toRequiredPathId(memoId, '备忘录编号');
|
||||
}
|
||||
|
||||
function buildMeritRecordPath(genealogyId, meritId) {
|
||||
return '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') +
|
||||
'/merit-records/' + toRequiredPathId(meritId, '功德记录编号');
|
||||
}
|
||||
|
||||
function buildArticlePath(genealogyId, articleId) {
|
||||
return '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') +
|
||||
'/articles/' + toRequiredPathId(articleId, '谱文编号');
|
||||
}
|
||||
|
||||
function buildAlbumPath(genealogyId, albumId) {
|
||||
return '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') +
|
||||
'/albums/' + toRequiredPathId(albumId, '相册编号');
|
||||
}
|
||||
|
||||
function buildAlbumPhotoPath(genealogyId, albumId, photoId) {
|
||||
return buildAlbumPath(genealogyId, albumId) + '/photos/' + toRequiredPathId(photoId, '相册照片编号');
|
||||
}
|
||||
|
||||
function buildVideoPath(genealogyId, videoId) {
|
||||
return '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') +
|
||||
'/videos/' + toRequiredPathId(videoId, '视频编号');
|
||||
}
|
||||
|
||||
function buildCeremonyPath(genealogyId, ceremonyId) {
|
||||
return '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') +
|
||||
'/ceremonies/' + toRequiredPathId(ceremonyId, '祭祀活动编号');
|
||||
}
|
||||
|
||||
function buildCeremonyGiftPath(genealogyId, ceremonyId, giftId) {
|
||||
return buildCeremonyPath(genealogyId, ceremonyId) + '/gifts/' + toRequiredPathId(giftId, '祭品编号');
|
||||
}
|
||||
|
||||
async function login(body) {
|
||||
var data = await request('POST', '/genealogy/pc/auth/login', {
|
||||
auth: false,
|
||||
@@ -208,7 +258,7 @@
|
||||
|
||||
async function deactivateAccount(body) {
|
||||
var data = await request('POST', '/genealogy/pc/auth/account/deactivate', {
|
||||
body: withClient(body)
|
||||
body: body
|
||||
});
|
||||
clearToken();
|
||||
return data;
|
||||
@@ -240,11 +290,11 @@
|
||||
},
|
||||
login: login,
|
||||
loginBySms: loginBySms,
|
||||
sendSmsCode: function (body) {
|
||||
return request('POST', '/genealogy/pc/auth/sms/code', {
|
||||
sendSmsCode: function (operationCode, body) {
|
||||
return request('POST', buildSmsCodePath(operationCode), {
|
||||
auth: false,
|
||||
// 最新接口文档要求短信发送场景携带 grantType 与验证码票据。
|
||||
body: Object.assign({ grantType: 'sms' }, withTenant(body))
|
||||
// PC 认证目录以路径 operationCode 绑定动作;clientid 只由请求头提供。
|
||||
body: Object.assign({ grantType: 'sms', tenantId: tenantId }, body || {})
|
||||
});
|
||||
},
|
||||
currentProfile: function () {
|
||||
@@ -263,13 +313,10 @@
|
||||
});
|
||||
},
|
||||
changePhone: function (body) {
|
||||
return request('PUT', '/genealogy/pc/auth/phone', { body: withClient(body) });
|
||||
return request('PUT', '/genealogy/pc/auth/phone', { body: body });
|
||||
},
|
||||
deactivateAccount: deactivateAccount,
|
||||
logout: logout,
|
||||
uploadFile: function (fileOrFormData) {
|
||||
return request('POST', '/genealogy/pc/files/upload', { body: createFormData(fileOrFormData) });
|
||||
},
|
||||
initResumableUpload: function (body) {
|
||||
return request('POST', '/genealogy/pc/files/resumable/init', { body: body });
|
||||
},
|
||||
@@ -281,30 +328,28 @@
|
||||
completeResumableUpload: function (body) {
|
||||
return request('POST', '/genealogy/pc/files/resumable/complete', { body: body });
|
||||
},
|
||||
createFileReference: function (body) {
|
||||
return request('POST', '/genealogy/pc/files/reference', { body: body });
|
||||
},
|
||||
deleteFileReference: function (query) {
|
||||
return request('DELETE', '/genealogy/pc/files/reference', { query: query });
|
||||
},
|
||||
captchaRequirement: function (body) {
|
||||
var source = body || {};
|
||||
captchaRequirement: function (operationCode, query) {
|
||||
var source = query || {};
|
||||
|
||||
return request('GET', '/captcha/require', {
|
||||
return request('GET', buildVerificationPath(operationCode, '/require'), {
|
||||
auth: false,
|
||||
query: {
|
||||
tenantId: source.tenantId || tenantId,
|
||||
clientId: source.clientId || clientId,
|
||||
sceneCode: source.sceneCode,
|
||||
subject: source.subject
|
||||
}
|
||||
});
|
||||
},
|
||||
captchaChallenge: function (body) {
|
||||
return request('POST', '/captcha/challenge', { auth: false, body: withTenant(body) });
|
||||
captchaChallenge: function (operationCode, body) {
|
||||
return request('POST', buildVerificationPath(operationCode, '/challenge'), { auth: false, body: body });
|
||||
},
|
||||
captchaVerify: function (body) {
|
||||
return request('POST', '/captcha/verify', { auth: false, body: withTenant(body) });
|
||||
captchaVerify: function (operationCode, body) {
|
||||
return request('POST', buildVerificationPath(operationCode, '/verify'), { auth: false, body: body });
|
||||
},
|
||||
captchaChallengeUrl: function (operationCode) {
|
||||
return buildApiUrl(baseUrl, buildVerificationPath(operationCode, '/challenge'));
|
||||
},
|
||||
captchaVerifyUrl: function (operationCode) {
|
||||
return buildApiUrl(baseUrl, buildVerificationPath(operationCode, '/verify'));
|
||||
},
|
||||
regionChildren: function (parentCode) {
|
||||
return request('GET', '/genealogy/region/children', { query: { parentCode: parentCode } });
|
||||
@@ -318,6 +363,21 @@
|
||||
regionDetail: function (regionCode) {
|
||||
return request('GET', '/genealogy/region/' + encodeURIComponent(regionCode));
|
||||
},
|
||||
genealogyQuota: function () {
|
||||
return request('GET', '/genealogy/pc/genealogies/quota');
|
||||
},
|
||||
notifications: function (query) {
|
||||
return request('GET', '/genealogy/pc/notifications', { query: query });
|
||||
},
|
||||
unreadNotificationCount: function () {
|
||||
return request('GET', '/genealogy/pc/notifications/unread-count');
|
||||
},
|
||||
markNotificationRead: function (notificationId) {
|
||||
return request('POST', '/genealogy/pc/notifications/' + toRequiredPathId(notificationId, '通知编号') + '/read');
|
||||
},
|
||||
markAllNotificationsRead: function () {
|
||||
return request('POST', '/genealogy/pc/notifications/read-all');
|
||||
},
|
||||
feeds: function (genealogyId) {
|
||||
return request('GET', buildFeedPath(genealogyId));
|
||||
},
|
||||
@@ -413,6 +473,84 @@
|
||||
},
|
||||
createLineageSpouse: function (genealogyId, personId, body) {
|
||||
return request('POST', buildLineagePersonPath(genealogyId, personId, '/spouses'), { body: body });
|
||||
},
|
||||
growthRecords: function (genealogyId) {
|
||||
return request('GET', buildGrowthRecordPath(genealogyId));
|
||||
},
|
||||
createGrowthRecord: function (genealogyId, body) {
|
||||
return request('POST', buildGrowthRecordPath(genealogyId), { body: body });
|
||||
},
|
||||
growthRecordDetail: function (genealogyId, recordId) {
|
||||
return request('GET', buildGrowthRecordPath(genealogyId, recordId));
|
||||
},
|
||||
updateGrowthRecord: function (genealogyId, recordId, body) {
|
||||
return request('PUT', buildGrowthRecordPath(genealogyId, recordId), { body: body });
|
||||
},
|
||||
deleteGrowthRecord: function (genealogyId, recordId) {
|
||||
return request('DELETE', buildGrowthRecordPath(genealogyId, recordId));
|
||||
},
|
||||
relativeRecords: function (genealogyId) {
|
||||
return request('GET', buildRelativeRecordPath(genealogyId));
|
||||
},
|
||||
createRelativeRecord: function (genealogyId, body) {
|
||||
return request('POST', buildRelativeRecordPath(genealogyId), { body: body });
|
||||
},
|
||||
relativeRecordDetail: function (genealogyId, relativeId) {
|
||||
return request('GET', buildRelativeRecordPath(genealogyId, relativeId));
|
||||
},
|
||||
updateRelativeRecord: function (genealogyId, relativeId, body) {
|
||||
return request('PUT', buildRelativeRecordPath(genealogyId, relativeId), { body: body });
|
||||
},
|
||||
deleteRelativeRecord: function (genealogyId, relativeId) {
|
||||
return request('DELETE', buildRelativeRecordPath(genealogyId, relativeId));
|
||||
},
|
||||
memos: function (genealogyId) {
|
||||
return request('GET', buildMemoPath(genealogyId));
|
||||
},
|
||||
createMemo: function (genealogyId, body) {
|
||||
return request('POST', buildMemoPath(genealogyId), { body: body });
|
||||
},
|
||||
memoDetail: function (genealogyId, memoId) {
|
||||
return request('GET', buildMemoPath(genealogyId, memoId));
|
||||
},
|
||||
updateMemo: function (genealogyId, memoId, body) {
|
||||
return request('PUT', buildMemoPath(genealogyId, memoId), { body: body });
|
||||
},
|
||||
deleteMemo: function (genealogyId, memoId) {
|
||||
return request('DELETE', buildMemoPath(genealogyId, memoId));
|
||||
},
|
||||
deleteMeritRecord: function (genealogyId, meritId) {
|
||||
return request('DELETE', buildMeritRecordPath(genealogyId, meritId));
|
||||
},
|
||||
deleteArticle: function (genealogyId, articleId) {
|
||||
return request('DELETE', buildArticlePath(genealogyId, articleId));
|
||||
},
|
||||
deleteAlbum: function (genealogyId, albumId) {
|
||||
return request('DELETE', buildAlbumPath(genealogyId, albumId));
|
||||
},
|
||||
deleteAlbumPhoto: function (genealogyId, albumId, photoId) {
|
||||
return request('DELETE', buildAlbumPhotoPath(genealogyId, albumId, photoId));
|
||||
},
|
||||
deleteVideo: function (genealogyId, videoId) {
|
||||
return request('DELETE', buildVideoPath(genealogyId, videoId));
|
||||
},
|
||||
replaceCeremonyInvitees: function (genealogyId, ceremonyId, body) {
|
||||
return request('PUT', buildCeremonyPath(genealogyId, ceremonyId) + '/invitees', { body: body });
|
||||
},
|
||||
ceremonyInvitations: function (genealogyId, ceremonyId) {
|
||||
return request('GET', buildCeremonyPath(genealogyId, ceremonyId) + '/invitations');
|
||||
},
|
||||
respondCeremonyInvitation: function (genealogyId, ceremonyId, body) {
|
||||
return request('PUT', buildCeremonyPath(genealogyId, ceremonyId) + '/invitations/me', { body: body });
|
||||
},
|
||||
myCeremonyInvitations: function () {
|
||||
return request('GET', '/genealogy/pc/genealogies/ceremony-invitations/mine');
|
||||
},
|
||||
deleteCeremony: function (genealogyId, ceremonyId) {
|
||||
return request('DELETE', buildCeremonyPath(genealogyId, ceremonyId));
|
||||
},
|
||||
deleteCeremonyGift: function (genealogyId, ceremonyId, giftId) {
|
||||
return request('DELETE', buildCeremonyGiftPath(genealogyId, ceremonyId, giftId));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user