完成10%

This commit is contained in:
rain
2026-07-24 18:11:16 +08:00
parent 8716a68fdb
commit 8870136d1b
33 changed files with 3853 additions and 336 deletions
+125 -7
View File
@@ -63,6 +63,22 @@
return formData;
}
function createChunkFormData(bodyOrFormData) {
var FormDataCtor = root.FormData;
var source = bodyOrFormData || {};
var formData;
if (FormDataCtor && bodyOrFormData instanceof FormDataCtor) return bodyOrFormData;
if (!FormDataCtor) throw new Error('当前环境不支持文件上传');
formData = new FormDataCtor();
formData.append('uploadId', source.uploadId);
formData.append('chunkIndex', source.chunkIndex);
formData.append('chunkMd5', source.chunkMd5);
formData.append('file', source.file);
return formData;
}
function buildApiUrl(baseUrl, path, query) {
var url = String(baseUrl || '').replace(/\/+$/, '') + '/' + String(path || '').replace(/^\/+/, '');
var params = new URLSearchParams();
@@ -119,6 +135,10 @@
return Object.assign({ tenantId: tenantId, clientId: clientId }, body || {});
}
function withClient(body) {
return Object.assign({}, body || {}, { clientId: clientId });
}
function toRequiredPathId(value, label) {
var text = String(value === undefined || value === null ? '' : value).trim();
@@ -143,6 +163,25 @@
: path + '/' + toRequiredPathId(commentId, '评论编号');
}
function buildFeedReplyPath(genealogyId, feedId, commentId, suffix) {
return buildFeedCommentPath(genealogyId, feedId, commentId) + '/replies' + (suffix || '');
}
function buildGenerationPoemPath(genealogyId, suffix) {
return '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') + '/generation-poems' + (suffix || '');
}
function buildLineagePath(genealogyId, suffix) {
return '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') + '/lineage' + (suffix || '');
}
function buildLineagePersonPath(genealogyId, personId, suffix) {
return buildLineagePath(
genealogyId,
'/persons/' + toRequiredPathId(personId, '人物编号') + (suffix || '')
);
}
async function login(body) {
var data = await request('POST', '/genealogy/pc/auth/login', {
auth: false,
@@ -168,7 +207,9 @@
}
async function deactivateAccount(body) {
var data = await request('POST', '/genealogy/pc/auth/account/deactivate', { body: body });
var data = await request('POST', '/genealogy/pc/auth/account/deactivate', {
body: withClient(body)
});
clearToken();
return data;
}
@@ -218,17 +259,34 @@
resetPassword: function (body) {
return request('PUT', '/genealogy/pc/auth/password/reset', {
auth: false,
body: Object.assign({ tenantId: tenantId }, body || {})
body: Object.assign({ grantType: 'password' }, withTenant(body))
});
},
changePhone: function (body) {
return request('PUT', '/genealogy/pc/auth/phone', { body: body });
return request('PUT', '/genealogy/pc/auth/phone', { body: withClient(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 });
},
uploadResumableChunk: function (bodyOrFormData) {
return request('POST', '/genealogy/pc/files/resumable/chunk', {
body: createChunkFormData(bodyOrFormData)
});
},
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 || {};
@@ -249,16 +307,16 @@
return request('POST', '/captcha/verify', { auth: false, body: withTenant(body) });
},
regionChildren: function (parentCode) {
return request('GET', '/genealogy/region/children', { auth: false, query: { parentCode: parentCode } });
return request('GET', '/genealogy/region/children', { query: { parentCode: parentCode } });
},
regionPath: function (regionCode) {
return request('GET', '/genealogy/region/path/' + encodeURIComponent(regionCode), { auth: false });
return request('GET', '/genealogy/region/path/' + encodeURIComponent(regionCode));
},
regionSearch: function (query) {
return request('GET', '/genealogy/region/search', { auth: false, query: query });
return request('GET', '/genealogy/region/search', { query: query });
},
regionDetail: function (regionCode) {
return request('GET', '/genealogy/region/' + encodeURIComponent(regionCode), { auth: false });
return request('GET', '/genealogy/region/' + encodeURIComponent(regionCode));
},
feeds: function (genealogyId) {
return request('GET', buildFeedPath(genealogyId));
@@ -290,11 +348,71 @@
feedCommentsPage: function (genealogyId, feedId, query) {
return request('GET', buildFeedCommentPath(genealogyId, feedId) + '/page', { query: query });
},
feedCommentReplies: function (genealogyId, feedId, commentId) {
return request('GET', buildFeedReplyPath(genealogyId, feedId, commentId));
},
feedCommentRepliesPage: function (genealogyId, feedId, commentId, query) {
return request('GET', buildFeedReplyPath(genealogyId, feedId, commentId, '/page'), { query: query });
},
createFeedComment: function (genealogyId, feedId, body) {
return request('POST', buildFeedCommentPath(genealogyId, feedId), { body: body });
},
deleteFeedComment: function (genealogyId, feedId, commentId) {
return request('DELETE', buildFeedCommentPath(genealogyId, feedId, commentId));
},
generationPoems: function (genealogyId) {
return request('GET', buildGenerationPoemPath(genealogyId));
},
generationPoemsManagement: function (genealogyId) {
return request('GET', buildGenerationPoemPath(genealogyId, '/management'));
},
createGenerationPoem: function (genealogyId, body) {
return request('POST', buildGenerationPoemPath(genealogyId), { body: body });
},
updateGenerationPoem: function (genealogyId, poemId, body) {
return request('PUT', buildGenerationPoemPath(genealogyId, '/' + toRequiredPathId(poemId, '字辈编号')), { body: body });
},
previewGenerationPoems: function (genealogyId, body) {
return request('POST', buildGenerationPoemPath(genealogyId, '/batch/preview'), { body: body });
},
saveGenerationPoems: function (genealogyId, body) {
return request('POST', buildGenerationPoemPath(genealogyId, '/batch/save'), { body: body });
},
lineagePersons: function (genealogyId) {
return request('GET', buildLineagePath(genealogyId, '/persons'));
},
lineagePersonsPage: function (genealogyId, query) {
return request('GET', buildLineagePath(genealogyId, '/persons/page'), { query: query });
},
lineagePersonOptions: function (genealogyId) {
return request('GET', buildLineagePath(genealogyId, '/persons/options'));
},
lineageTree: function (genealogyId) {
return request('GET', buildLineagePath(genealogyId, '/tree'));
},
createLineagePerson: function (genealogyId, body) {
return request('POST', buildLineagePath(genealogyId, '/persons'), { body: body });
},
lineagePersonDetail: function (genealogyId, personId) {
return request('GET', buildLineagePersonPath(genealogyId, personId));
},
updateLineagePerson: function (genealogyId, personId, body) {
return request('PUT', buildLineagePersonPath(genealogyId, personId), { body: body });
},
disableLineagePerson: function (genealogyId, personId) {
return request('DELETE', buildLineagePersonPath(genealogyId, personId));
},
createLineageChild: function (genealogyId, personId, body) {
return request('POST', buildLineagePersonPath(genealogyId, personId, '/children'), { body: body });
},
createLineageParent: function (genealogyId, personId, body) {
return request('POST', buildLineagePersonPath(genealogyId, personId, '/parents'), { body: body });
},
createLineageSibling: function (genealogyId, personId, body) {
return request('POST', buildLineagePersonPath(genealogyId, personId, '/siblings'), { body: body });
},
createLineageSpouse: function (genealogyId, personId, body) {
return request('POST', buildLineagePersonPath(genealogyId, personId, '/spouses'), { body: body });
}
};
}