diff --git a/.tmp-openapi-validate/add-openapi-examples.js b/.tmp-openapi-validate/add-openapi-examples.js new file mode 100644 index 0000000..ee3fbb7 --- /dev/null +++ b/.tmp-openapi-validate/add-openapi-examples.js @@ -0,0 +1,268 @@ +const fs = require('fs'); +const path = require('path'); +const YAML = require('yaml'); + +const repoRoot = process.cwd(); +const rootFile = path.join(repoRoot, 'pocket-base', 'spec', 'openapi-wx.yaml'); +const splitDir = path.join(repoRoot, 'pocket-base', 'spec', 'openapi-wx'); + +const filePaths = [ + rootFile, + ...fs + .readdirSync(splitDir) + .filter((name) => name.endsWith('.yaml')) + .map((name) => path.join(splitDir, name)), +]; + +const docs = new Map( + filePaths.map((filePath) => [filePath, YAML.parse(fs.readFileSync(filePath, 'utf8'))]), +); + +function decodePointerSegment(segment) { + return segment.replace(/~1/g, '/').replace(/~0/g, '~'); +} + +function getByPointer(documentData, pointer) { + if (!pointer || pointer === '#' || pointer === '') { + return documentData; + } + + const segments = pointer + .replace(/^#/, '') + .split('/') + .filter(Boolean) + .map(decodePointerSegment); + + let current = documentData; + for (const segment of segments) { + if (current == null) { + return undefined; + } + current = current[segment]; + } + return current; +} + +function resolveRef(ref, currentFile) { + const [filePart, hashPart = ''] = ref.split('#'); + const targetFile = filePart + ? path.resolve(path.dirname(currentFile), filePart) + : currentFile; + const targetDoc = docs.get(targetFile); + if (!targetDoc) { + return { targetFile, targetKey: `${targetFile}#${hashPart}`, schema: undefined }; + } + + const pointer = hashPart ? `#${hashPart}` : '#'; + return { + targetFile, + targetKey: `${targetFile}${pointer}`, + schema: getByPointer(targetDoc, pointer), + }; +} + +function pickType(typeValue) { + if (Array.isArray(typeValue)) { + return typeValue.find((item) => item !== 'null') || typeValue[0]; + } + return typeValue; +} + +function cleanLabelText(text, fallback) { + if (!text || typeof text !== 'string') { + return fallback; + } + + const normalized = text + .split(/\r?\n/) + .map((line) => line.trim()) + .filter(Boolean) + .map((line) => line.replace(/^[\-\d\.\)\s]+/, '').trim()) + .find((line) => line && !/^(可选|必填|说明|注意)[。::]?$/u.test(line)); + + if (!normalized) { + return fallback; + } + + return normalized.replace(/[`"'<>]/g, '').trim() || fallback; +} + +function placeholderKey(key) { + return typeof key === 'string' && key.includes('|'); +} + +function deepMerge(baseValue, nextValue) { + if ( + baseValue && + nextValue && + typeof baseValue === 'object' && + typeof nextValue === 'object' && + !Array.isArray(baseValue) && + !Array.isArray(nextValue) + ) { + const merged = { ...baseValue }; + const nextKeys = Object.keys(nextValue); + const hasConcreteNextKeys = nextKeys.some((key) => !placeholderKey(key)); + + if (hasConcreteNextKeys) { + for (const key of Object.keys(merged)) { + if (placeholderKey(key)) { + delete merged[key]; + } + } + } + + for (const [key, value] of Object.entries(nextValue)) { + if (key in merged) { + merged[key] = deepMerge(merged[key], value); + } else { + merged[key] = value; + } + } + return merged; + } + return nextValue; +} + +function buildLabel(schemaLike, fallback) { + return cleanLabelText(schemaLike?.description || schemaLike?.title, fallback); +} + +function fallbackScalar(label, fieldType) { + return `${label}|${fieldType || 'string'}`; +} + +function buildExample(schemaLike, currentFile, fieldName = 'field', seenRefs = new Set()) { + if (schemaLike == null) { + return fallbackScalar(fieldName, 'string'); + } + + if (typeof schemaLike !== 'object' || Array.isArray(schemaLike)) { + return fallbackScalar(fieldName, 'string'); + } + + if (schemaLike.$ref) { + const { targetFile, targetKey, schema } = resolveRef(schemaLike.$ref, currentFile); + if (!schema) { + return fallbackScalar(fieldName, 'string'); + } + if (seenRefs.has(targetKey)) { + return fallbackScalar(fieldName, 'object'); + } + const nextSeen = new Set(seenRefs); + nextSeen.add(targetKey); + return buildExample(schema, targetFile, fieldName, nextSeen); + } + + if (schemaLike.allOf) { + return schemaLike.allOf.reduce((accumulator, item) => { + const nextValue = buildExample(item, currentFile, fieldName, seenRefs); + return deepMerge(accumulator, nextValue); + }, {}); + } + + if (schemaLike.oneOf && schemaLike.oneOf.length > 0) { + return buildExample(schemaLike.oneOf[0], currentFile, fieldName, seenRefs); + } + + if (schemaLike.anyOf && schemaLike.anyOf.length > 0) { + return buildExample(schemaLike.anyOf[0], currentFile, fieldName, seenRefs); + } + + const fieldType = + pickType(schemaLike.type) || + (schemaLike.properties || schemaLike.additionalProperties ? 'object' : undefined) || + (schemaLike.items ? 'array' : undefined) || + 'string'; + const fieldLabel = buildLabel(schemaLike, fieldName); + + if (fieldType === 'object') { + const exampleObject = {}; + + if (schemaLike.properties && typeof schemaLike.properties === 'object') { + for (const [propertyName, propertySchema] of Object.entries(schemaLike.properties)) { + exampleObject[propertyName] = buildExample( + propertySchema, + currentFile, + propertyName, + seenRefs, + ); + } + } + + if (Object.keys(exampleObject).length === 0 && schemaLike.additionalProperties) { + exampleObject[`${fieldLabel}字段|string`] = `${fieldLabel}值|string`; + } + + if (Object.keys(exampleObject).length === 0) { + exampleObject[`${fieldLabel}|string`] = `${fieldLabel}|string`; + } + + return exampleObject; + } + + if (fieldType === 'array') { + const itemFieldName = fieldName.endsWith('s') ? fieldName.slice(0, -1) : `${fieldName}_item`; + return [buildExample(schemaLike.items || {}, currentFile, itemFieldName, seenRefs)]; + } + + return fallbackScalar(fieldLabel, fieldType); +} + +function httpMethods(pathItem) { + return ['get', 'post', 'put', 'patch', 'delete', 'options', 'head', 'trace'].filter( + (method) => pathItem && typeof pathItem[method] === 'object', + ); +} + +for (const filePath of filePaths.filter((file) => file !== rootFile)) { + const documentData = docs.get(filePath); + if (!documentData || typeof documentData !== 'object') { + continue; + } + + if (documentData.components && documentData.components.schemas) { + for (const [schemaName, schemaValue] of Object.entries(documentData.components.schemas)) { + schemaValue.example = buildExample(schemaValue, filePath, schemaName, new Set()); + } + } + + if (documentData.paths) { + for (const pathItem of Object.values(documentData.paths)) { + for (const method of httpMethods(pathItem)) { + const operation = pathItem[method]; + + const requestContent = operation?.requestBody?.content; + if (requestContent && typeof requestContent === 'object') { + for (const media of Object.values(requestContent)) { + if (media && media.schema) { + delete media.examples; + media.example = buildExample(media.schema, filePath, 'request', new Set()); + } + } + } + + const responses = operation?.responses; + if (responses && typeof responses === 'object') { + for (const response of Object.values(responses)) { + const responseContent = response?.content; + if (!responseContent || typeof responseContent !== 'object') { + continue; + } + + for (const media of Object.values(responseContent)) { + if (media && media.schema) { + delete media.examples; + media.example = buildExample(media.schema, filePath, 'response', new Set()); + } + } + } + } + } + } + } + + fs.writeFileSync(filePath, YAML.stringify(documentData, { lineWidth: 0 }), 'utf8'); +} + +console.log(`Updated examples in ${filePaths.length - 1} split OpenAPI files.`); diff --git a/pocket-base/bai_web_pb_hooks/views/cart-order-manage.html b/pocket-base/bai_web_pb_hooks/views/cart-order-manage.html index 14364cb..8dd4b57 100644 --- a/pocket-base/bai_web_pb_hooks/views/cart-order-manage.html +++ b/pocket-base/bai_web_pb_hooks/views/cart-order-manage.html @@ -46,14 +46,24 @@ .summary-label { color: #64748b; font-size: 13px; } .summary-value { margin-top: 8px; font-size: 22px; font-weight: 700; color: #0f172a; } .profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; } + .preview-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; } .field-block { display: grid; gap: 6px; } + .field-block.full { grid-column: 1 / -1; } .field-label { font-size: 13px; color: #64748b; } + .preview-card { border: 1px solid #dbe3f0; border-radius: 14px; padding: 10px 12px; background: #f8fbff; min-width: 0; } + .preview-value { color: #0f172a; font-size: 14px; font-weight: 600; line-height: 1.5; word-break: break-word; } + .user-profile-shell { display: grid; gap: 12px; } + .edit-panel { border-top: 1px dashed #dbe3f0; padding-top: 14px; } + .attachment-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; } .attachment-panel { border: 1px solid #dbe3f0; border-radius: 14px; padding: 12px; background: #f8fbff; } + .attachment-panel.compact { padding: 10px; min-width: 0; } .attachment-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; } + .attachment-actions .btn { padding: 8px 12px; font-size: 13px; } .attachment-preview { margin-top: 10px; display: flex; align-items: center; gap: 12px; min-height: 72px; } .attachment-thumb { width: 72px; height: 72px; border-radius: 12px; border: 1px solid #dbe3f0; background: #fff; object-fit: cover; } .attachment-empty-thumb { width: 72px; height: 72px; border-radius: 12px; border: 1px solid #dbe3f0; background: #fff; color: #94a3b8; display: flex; align-items: center; justify-content: center; font-size: 12px; text-align: center; padding: 8px; } .attachment-meta { min-width: 0; display: grid; gap: 4px; } + .attachment-meta.compact { gap: 2px; } .attachment-link { color: #2563eb; text-decoration: none; font-size: 13px; font-weight: 600; word-break: break-all; } .attachment-hidden-input { display: none; } .detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; } @@ -68,17 +78,41 @@ @media (max-width: 1080px) { .layout { grid-template-columns: 1fr; } .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } + .preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } + .attachment-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .profile-grid { grid-template-columns: 1fr; } } @media (max-width: 720px) { .toolbar { grid-template-columns: 1fr; } .summary-grid { grid-template-columns: 1fr; } + .preview-grid { grid-template-columns: 1fr; } + .attachment-grid { grid-template-columns: 1fr; } table, thead, tbody, th, td, tr { display: block; } thead { display: none; } tr { border-bottom: 1px solid #e5e7eb; } td { display: flex; justify-content: space-between; gap: 10px; } td::before { content: attr(data-label); font-weight: 700; color: #475569; } } + html[data-theme="dark"] .preview-card, + html[data-theme="dark"] .attachment-panel { + background: rgba(0, 0, 0, 0.88) !important; + border-color: rgba(148, 163, 184, 0.22) !important; + color: #e5e7eb !important; + box-shadow: 0 18px 50px rgba(2, 6, 23, 0.18) !important; + } + html[data-theme="dark"] .preview-value, + html[data-theme="dark"] .attachment-link { + color: #f8fafc !important; + } + html[data-theme="dark"] .attachment-thumb, + html[data-theme="dark"] .attachment-empty-thumb { + background: rgba(15, 23, 42, 0.7) !important; + border-color: rgba(148, 163, 184, 0.22) !important; + color: #94a3b8 !important; + } + html[data-theme="dark"] .edit-panel { + border-top-color: rgba(148, 163, 184, 0.22) !important; + } {{ template "theme_head" . }} @@ -120,6 +154,8 @@ const state = { users: [], selectedOpenid: '', + isEditMode: false, + userEditDraft: null, userLevelOptions: [], attachmentDetails: { userUsersPicture: null, @@ -186,6 +222,75 @@ }) || null } + function buildUserDraft(user) { + return { + openid: user.openid || '', + users_name: user.users_name || '', + users_phone: user.users_phone || '', + users_level: user.users_level || '', + users_type: user.users_type || '', + users_status: user.users_status || '', + users_rank_level: user.users_rank_level === null || typeof user.users_rank_level === 'undefined' ? '' : user.users_rank_level, + users_auth_type: user.users_auth_type === null || typeof user.users_auth_type === 'undefined' ? '' : user.users_auth_type, + company_id: user.company_id || '', + users_tag: user.users_tag || '', + users_parent_id: user.users_parent_id || '', + users_promo_code: user.users_promo_code || '', + usergroups_id: user.usergroups_id || '', + users_id_number: user.users_id_number || '', + users_picture: user.users_picture || '', + users_id_pic_a: user.users_id_pic_a || '', + users_id_pic_b: user.users_id_pic_b || '', + users_title_picture: user.users_title_picture || '', + } + } + + function ensureEditDraft(user) { + if (!user) { + state.userEditDraft = null + return null + } + + if (!state.userEditDraft || normalizeText(state.userEditDraft.openid) !== normalizeText(user.openid)) { + state.userEditDraft = buildUserDraft(user) + } + + return state.userEditDraft + } + + function syncEditDraftFromDom() { + if (!state.isEditMode || !state.userEditDraft) { + return + } + + const fieldMap = { + userUsersName: 'users_name', + userUsersPhone: 'users_phone', + userUsersLevel: 'users_level', + userUsersType: 'users_type', + userUsersStatus: 'users_status', + userUsersRankLevel: 'users_rank_level', + userUsersAuthType: 'users_auth_type', + userCompanyId: 'company_id', + userUsersTag: 'users_tag', + userUsersParentId: 'users_parent_id', + userUsersPromoCode: 'users_promo_code', + userUsergroupsId: 'usergroups_id', + userUsersIdNumber: 'users_id_number', + userUsersPicture: 'users_picture', + userUsersIdPicA: 'users_id_pic_a', + userUsersIdPicB: 'users_id_pic_b', + userUsersTitlePicture: 'users_title_picture', + } + + Object.keys(fieldMap).forEach(function (id) { + const el = document.getElementById(id) + if (el) { + state.userEditDraft[fieldMap[id]] = el.value + } + }) + } + async function parseJsonSafe(res) { const contentType = String(res.headers.get('content-type') || '').toLowerCase() const rawText = await res.text() @@ -293,27 +398,32 @@ renderDetail() } - function renderAttachmentUploader(fieldId, label, value) { + function renderAttachmentCard(fieldId, label, value, editable) { const detail = state.attachmentDetails[fieldId] || null const url = detail && detail.attachments_url ? detail.attachments_url : '' const filename = detail && (detail.attachments_filename || detail.attachments_id) ? (detail.attachments_filename || detail.attachments_id) : normalizeText(value) - return '
' + return '
' + '' - + '
' - + '' - + '' - + '
' - + '' - + '' - + '
' + + (editable + ? '' + : '
' + escapeHtml(value || '-') + '
') + + (editable + ? '' + : '') + + (editable + ? '
' + + '' + + '' + + '
' + : '') + '
' + (url ? '' + escapeHtml(label) + '' : '
暂无预览
') - + '
' + + '
' + '
当前附件ID:' + escapeHtml(value || '-') + '
' + (url ? '查看图片:' + escapeHtml(filename || '附件') + '' @@ -321,6 +431,12 @@ + '
' + '
' + '
' + } + + function renderPreviewField(label, value) { + return '
' + + '
' + escapeHtml(label) + '
' + + '
' + escapeHtml(value || '-') + '
' + '
' } @@ -385,27 +501,53 @@ } function renderUserProfileForm(user) { - return '

用户信息维护

' - + '
' - + '
' - + '
' - + '
' - + '
' - + '
' - + '
' - + '
' - + '
' - + '
' - + '
' - + '
' - + '
' - + '
' + const draft = state.isEditMode ? ensureEditDraft(user) : null + const source = draft || user + + return '' } @@ -466,6 +608,8 @@ }) state.users = Array.isArray(data.items) ? data.items : [] state.userLevelOptions = Array.isArray(data.user_level_options) ? data.user_level_options : [] + state.isEditMode = false + state.userEditDraft = null if (!state.users.length) { state.selectedOpenid = '' } else if (!getSelectedUser()) { @@ -489,26 +633,29 @@ return } + syncEditDraftFromDom() + const draft = ensureEditDraft(user) + try { const data = await requestJson('/cart-order/manage-user-update', { openid: user.openid, - users_name: document.getElementById('userUsersName').value, - users_phone: document.getElementById('userUsersPhone').value, - users_level: document.getElementById('userUsersLevel').value, - users_type: document.getElementById('userUsersType').value, - users_status: document.getElementById('userUsersStatus').value, - users_rank_level: document.getElementById('userUsersRankLevel').value, - users_auth_type: document.getElementById('userUsersAuthType').value, - company_id: document.getElementById('userCompanyId').value, - users_tag: document.getElementById('userUsersTag').value, - users_parent_id: document.getElementById('userUsersParentId').value, - users_promo_code: document.getElementById('userUsersPromoCode').value, - usergroups_id: document.getElementById('userUsergroupsId').value, - users_id_number: document.getElementById('userUsersIdNumber').value, - users_picture: document.getElementById('userUsersPicture').value, - users_id_pic_a: document.getElementById('userUsersIdPicA').value, - users_id_pic_b: document.getElementById('userUsersIdPicB').value, - users_title_picture: document.getElementById('userUsersTitlePicture').value, + users_name: draft.users_name, + users_phone: draft.users_phone, + users_level: draft.users_level, + users_type: draft.users_type, + users_status: draft.users_status, + users_rank_level: draft.users_rank_level, + users_auth_type: draft.users_auth_type, + company_id: draft.company_id, + users_tag: draft.users_tag, + users_parent_id: draft.users_parent_id, + users_promo_code: draft.users_promo_code, + usergroups_id: draft.usergroups_id, + users_id_number: draft.users_id_number, + users_picture: draft.users_picture, + users_id_pic_a: draft.users_id_pic_a, + users_id_pic_b: draft.users_id_pic_b, + users_title_picture: draft.users_title_picture, }) const updatedUser = data && data.user ? data.user : null @@ -520,6 +667,8 @@ state.users[index] = Object.assign({}, state.users[index], updatedUser) } } + state.isEditMode = false + state.userEditDraft = null renderUserList() renderDetail() setStatus('用户信息保存成功。', 'success') @@ -538,6 +687,8 @@ return } + syncEditDraftFromDom() + const labelMap = { userUsersPicture: '头像', userUsersIdPicA: '证件正面', @@ -549,6 +700,15 @@ setStatus('正在上传' + (labelMap[fieldId] || '附件') + '...', '') const uploaded = await uploadAttachment(file, fieldId) input.value = uploaded.attachments_id || '' + if (state.userEditDraft) { + const draftFieldMap = { + userUsersPicture: 'users_picture', + userUsersIdPicA: 'users_id_pic_a', + userUsersIdPicB: 'users_id_pic_b', + userUsersTitlePicture: 'users_title_picture', + } + state.userEditDraft[draftFieldMap[fieldId]] = uploaded.attachments_id || '' + } state.attachmentDetails[fieldId] = uploaded renderDetail() setStatus((labelMap[fieldId] || '附件') + '上传成功,请点击“保存用户信息”完成写入。', 'success') @@ -570,6 +730,21 @@ detailWrapEl.addEventListener('click', function (event) { const target = event.target + if (target && target.id === 'enterEditBtn') { + const user = getSelectedUser() + state.isEditMode = true + state.userEditDraft = user ? buildUserDraft(user) : null + renderDetail() + return + } + + if (target && target.id === 'cancelEditBtn') { + state.isEditMode = false + state.userEditDraft = null + renderDetail() + return + } + if (target && target.id === 'saveUserBtn') { saveSelectedUser() return @@ -587,6 +762,7 @@ const clearAttachment = target.getAttribute('data-clear-attachment') if (clearAttachment) { + syncEditDraftFromDom() const input = document.getElementById(clearAttachment) const fileInput = document.getElementById(clearAttachment + 'File') if (input) { @@ -595,12 +771,25 @@ if (fileInput) { fileInput.value = '' } + if (state.userEditDraft) { + const draftFieldMap = { + userUsersPicture: 'users_picture', + userUsersIdPicA: 'users_id_pic_a', + userUsersIdPicB: 'users_id_pic_b', + userUsersTitlePicture: 'users_title_picture', + } + state.userEditDraft[draftFieldMap[clearAttachment]] = '' + } state.attachmentDetails[clearAttachment] = null renderDetail() } } }) + detailWrapEl.addEventListener('input', function () { + syncEditDraftFromDom() + }) + detailWrapEl.addEventListener('change', function (event) { const target = event.target if (!target || !target.getAttribute) { diff --git a/pocket-base/spec/openapi-wx.yaml b/pocket-base/spec/openapi-wx.yaml index 7773d3a..124dccb 100644 --- a/pocket-base/spec/openapi-wx.yaml +++ b/pocket-base/spec/openapi-wx.yaml @@ -42,51 +42,51 @@ tags: security: [] paths: /pb/api/system/users-count: - $ref: './openapi-wx/paths/system.yaml#/usersCount' + $ref: './openapi-wx/system.yaml#/paths/usersCount' /pb/api/system/refresh-token: - $ref: './openapi-wx/paths/system.yaml#/refreshToken' + $ref: './openapi-wx/system.yaml#/paths/refreshToken' /pb/api/wechat/login: - $ref: './openapi-wx/paths/wechat-auth.yaml#/wechatLogin' + $ref: './openapi-wx/wechat-auth.yaml#/paths/wechatLogin' /pb/api/wechat/profile: - $ref: './openapi-wx/paths/wechat-auth.yaml#/wechatProfile' + $ref: './openapi-wx/wechat-auth.yaml#/paths/wechatProfile' /pb/api/collections/tbl_company/records: - $ref: './openapi-wx/paths/company.yaml#/companyRecords' + $ref: './openapi-wx/company.yaml#/paths/companyRecords' /pb/api/collections/tbl_company/records/{recordId}: - $ref: './openapi-wx/paths/company.yaml#/companyRecordById' + $ref: './openapi-wx/company.yaml#/paths/companyRecordById' /pb/api/collections/tbl_attachments/records: - $ref: './openapi-wx/paths/attachments.yaml#/attachmentRecords' + $ref: './openapi-wx/attachments.yaml#/paths/attachmentRecords' /pb/api/collections/tbl_product_list/records: - $ref: './openapi-wx/paths/products.yaml#/productRecords' + $ref: './openapi-wx/products.yaml#/paths/productRecords' /pb/api/collections/tbl_document/records: - $ref: './openapi-wx/paths/documents.yaml#/documentRecords' + $ref: './openapi-wx/documents.yaml#/paths/documentRecords' /pb/api/cart/list: - $ref: './openapi-wx/paths/cart-hooks.yaml#/cartList' + $ref: './openapi-wx/cart.yaml#/paths/cartList' /pb/api/cart/detail: - $ref: './openapi-wx/paths/cart-hooks.yaml#/cartDetail' + $ref: './openapi-wx/cart.yaml#/paths/cartDetail' /pb/api/cart/create: - $ref: './openapi-wx/paths/cart-hooks.yaml#/cartCreate' + $ref: './openapi-wx/cart.yaml#/paths/cartCreate' /pb/api/cart/update: - $ref: './openapi-wx/paths/cart-hooks.yaml#/cartUpdate' + $ref: './openapi-wx/cart.yaml#/paths/cartUpdate' /pb/api/cart/delete: - $ref: './openapi-wx/paths/cart-hooks.yaml#/cartDelete' - /pb/api/order/list: - $ref: './openapi-wx/paths/order-hooks.yaml#/orderList' - /pb/api/order/detail: - $ref: './openapi-wx/paths/order-hooks.yaml#/orderDetail' - /pb/api/order/create: - $ref: './openapi-wx/paths/order-hooks.yaml#/orderCreate' - /pb/api/order/update: - $ref: './openapi-wx/paths/order-hooks.yaml#/orderUpdate' - /pb/api/order/delete: - $ref: './openapi-wx/paths/order-hooks.yaml#/orderDelete' + $ref: './openapi-wx/cart.yaml#/paths/cartDelete' /pb/api/collections/tbl_cart/records: - $ref: './openapi-wx/paths/cart-native.yaml#/cartRecords' + $ref: './openapi-wx/cart.yaml#/paths/cartRecords' /pb/api/collections/tbl_cart/records/{recordId}: - $ref: './openapi-wx/paths/cart-native.yaml#/cartRecordById' + $ref: './openapi-wx/cart.yaml#/paths/cartRecordById' + /pb/api/order/list: + $ref: './openapi-wx/order.yaml#/paths/orderList' + /pb/api/order/detail: + $ref: './openapi-wx/order.yaml#/paths/orderDetail' + /pb/api/order/create: + $ref: './openapi-wx/order.yaml#/paths/orderCreate' + /pb/api/order/update: + $ref: './openapi-wx/order.yaml#/paths/orderUpdate' + /pb/api/order/delete: + $ref: './openapi-wx/order.yaml#/paths/orderDelete' /pb/api/collections/tbl_order/records: - $ref: './openapi-wx/paths/order-native.yaml#/orderRecords' + $ref: './openapi-wx/order.yaml#/paths/orderRecords' /pb/api/collections/tbl_order/records/{recordId}: - $ref: './openapi-wx/paths/order-native.yaml#/orderRecordById' + $ref: './openapi-wx/order.yaml#/paths/orderRecordById' components: securitySchemes: BearerAuth: @@ -95,114 +95,114 @@ components: bearerFormat: JWT schemas: ApiResponseBase: - $ref: './openapi-wx/schemas/common.yaml#/ApiResponseBase' + $ref: './openapi-wx/system.yaml#/components/schemas/ApiResponseBase' ErrorResponse: - $ref: './openapi-wx/schemas/common.yaml#/ErrorResponse' - HookRecordBase: - $ref: './openapi-wx/schemas/common.yaml#/HookRecordBase' - PocketBaseNativeError: - $ref: './openapi-wx/schemas/common.yaml#/PocketBaseNativeError' - PocketBaseRecordBase: - $ref: './openapi-wx/schemas/common.yaml#/PocketBaseRecordBase' + $ref: './openapi-wx/system.yaml#/components/schemas/ErrorResponse' SystemRefreshTokenRequest: - $ref: './openapi-wx/schemas/system.yaml#/SystemRefreshTokenRequest' + $ref: './openapi-wx/system.yaml#/components/schemas/SystemRefreshTokenRequest' RefreshTokenResponse: - $ref: './openapi-wx/schemas/system.yaml#/RefreshTokenResponse' + $ref: './openapi-wx/system.yaml#/components/schemas/RefreshTokenResponse' UsersCountData: - $ref: './openapi-wx/schemas/system.yaml#/UsersCountData' + $ref: './openapi-wx/system.yaml#/components/schemas/UsersCountData' UsersCountResponse: - $ref: './openapi-wx/schemas/system.yaml#/UsersCountResponse' + $ref: './openapi-wx/system.yaml#/components/schemas/UsersCountResponse' UserInfo: - $ref: './openapi-wx/schemas/wechat-auth.yaml#/UserInfo' + $ref: './openapi-wx/wechat-auth.yaml#/components/schemas/UserInfo' WechatLoginRequest: - $ref: './openapi-wx/schemas/wechat-auth.yaml#/WechatLoginRequest' + $ref: './openapi-wx/wechat-auth.yaml#/components/schemas/WechatLoginRequest' WechatProfileRequest: - $ref: './openapi-wx/schemas/wechat-auth.yaml#/WechatProfileRequest' + $ref: './openapi-wx/wechat-auth.yaml#/components/schemas/WechatProfileRequest' AuthSuccessData: - $ref: './openapi-wx/schemas/wechat-auth.yaml#/AuthSuccessData' + $ref: './openapi-wx/wechat-auth.yaml#/components/schemas/AuthSuccessData' AuthSuccessResponse: - $ref: './openapi-wx/schemas/wechat-auth.yaml#/AuthSuccessResponse' + $ref: './openapi-wx/wechat-auth.yaml#/components/schemas/AuthSuccessResponse' WechatProfileResponseData: - $ref: './openapi-wx/schemas/wechat-auth.yaml#/WechatProfileResponseData' + $ref: './openapi-wx/wechat-auth.yaml#/components/schemas/WechatProfileResponseData' WechatProfileResponse: - $ref: './openapi-wx/schemas/wechat-auth.yaml#/WechatProfileResponse' + $ref: './openapi-wx/wechat-auth.yaml#/components/schemas/WechatProfileResponse' CompanyInfo: - $ref: './openapi-wx/schemas/company.yaml#/CompanyInfo' + $ref: './openapi-wx/wechat-auth.yaml#/components/schemas/CompanyInfo' + PocketBaseNativeError: + $ref: './openapi-wx/company.yaml#/components/schemas/PocketBaseNativeError' + PocketBaseRecordBase: + $ref: './openapi-wx/company.yaml#/components/schemas/PocketBaseRecordBase' PocketBaseCompanyFields: - $ref: './openapi-wx/schemas/company.yaml#/PocketBaseCompanyFields' + $ref: './openapi-wx/company.yaml#/components/schemas/PocketBaseCompanyFields' PocketBaseCompanyRecord: - $ref: './openapi-wx/schemas/company.yaml#/PocketBaseCompanyRecord' + $ref: './openapi-wx/company.yaml#/components/schemas/PocketBaseCompanyRecord' PocketBaseCompanyCreateRequest: - $ref: './openapi-wx/schemas/company.yaml#/PocketBaseCompanyCreateRequest' + $ref: './openapi-wx/company.yaml#/components/schemas/PocketBaseCompanyCreateRequest' PocketBaseCompanyUpdateRequest: - $ref: './openapi-wx/schemas/company.yaml#/PocketBaseCompanyUpdateRequest' + $ref: './openapi-wx/company.yaml#/components/schemas/PocketBaseCompanyUpdateRequest' PocketBaseCompanyListResponse: - $ref: './openapi-wx/schemas/company.yaml#/PocketBaseCompanyListResponse' + $ref: './openapi-wx/company.yaml#/components/schemas/PocketBaseCompanyListResponse' PocketBaseAttachmentRecord: - $ref: './openapi-wx/schemas/attachments.yaml#/PocketBaseAttachmentRecord' + $ref: './openapi-wx/attachments.yaml#/components/schemas/PocketBaseAttachmentRecord' PocketBaseAttachmentListResponse: - $ref: './openapi-wx/schemas/attachments.yaml#/PocketBaseAttachmentListResponse' + $ref: './openapi-wx/attachments.yaml#/components/schemas/PocketBaseAttachmentListResponse' PocketBaseProductListFields: - $ref: './openapi-wx/schemas/products.yaml#/PocketBaseProductListFields' + $ref: './openapi-wx/products.yaml#/components/schemas/PocketBaseProductListFields' PocketBaseProductListRecord: - $ref: './openapi-wx/schemas/products.yaml#/PocketBaseProductListRecord' + $ref: './openapi-wx/products.yaml#/components/schemas/PocketBaseProductListRecord' PocketBaseProductListListResponse: - $ref: './openapi-wx/schemas/products.yaml#/PocketBaseProductListListResponse' + $ref: './openapi-wx/products.yaml#/components/schemas/PocketBaseProductListListResponse' PocketBaseDocumentFields: - $ref: './openapi-wx/schemas/documents.yaml#/PocketBaseDocumentFields' + $ref: './openapi-wx/documents.yaml#/components/schemas/PocketBaseDocumentFields' PocketBaseDocumentRecord: - $ref: './openapi-wx/schemas/documents.yaml#/PocketBaseDocumentRecord' + $ref: './openapi-wx/documents.yaml#/components/schemas/PocketBaseDocumentRecord' PocketBaseDocumentListResponse: - $ref: './openapi-wx/schemas/documents.yaml#/PocketBaseDocumentListResponse' + $ref: './openapi-wx/documents.yaml#/components/schemas/PocketBaseDocumentListResponse' + HookRecordBase: + $ref: './openapi-wx/cart.yaml#/components/schemas/HookRecordBase' CartRecord: - $ref: './openapi-wx/schemas/cart-hooks.yaml#/CartRecord' + $ref: './openapi-wx/cart.yaml#/components/schemas/CartRecord' CartListRequest: - $ref: './openapi-wx/schemas/cart-hooks.yaml#/CartListRequest' + $ref: './openapi-wx/cart.yaml#/components/schemas/CartListRequest' CartDetailRequest: - $ref: './openapi-wx/schemas/cart-hooks.yaml#/CartDetailRequest' + $ref: './openapi-wx/cart.yaml#/components/schemas/CartDetailRequest' CartCreateRequest: - $ref: './openapi-wx/schemas/cart-hooks.yaml#/CartCreateRequest' + $ref: './openapi-wx/cart.yaml#/components/schemas/CartCreateRequest' CartUpdateRequest: - $ref: './openapi-wx/schemas/cart-hooks.yaml#/CartUpdateRequest' + $ref: './openapi-wx/cart.yaml#/components/schemas/CartUpdateRequest' CartDeleteRequest: - $ref: './openapi-wx/schemas/cart-hooks.yaml#/CartDeleteRequest' + $ref: './openapi-wx/cart.yaml#/components/schemas/CartDeleteRequest' CartListResponse: - $ref: './openapi-wx/schemas/cart-hooks.yaml#/CartListResponse' + $ref: './openapi-wx/cart.yaml#/components/schemas/CartListResponse' CartDeleteResponse: - $ref: './openapi-wx/schemas/cart-hooks.yaml#/CartDeleteResponse' - OrderRecord: - $ref: './openapi-wx/schemas/order-hooks.yaml#/OrderRecord' - OrderListRequest: - $ref: './openapi-wx/schemas/order-hooks.yaml#/OrderListRequest' - OrderDetailRequest: - $ref: './openapi-wx/schemas/order-hooks.yaml#/OrderDetailRequest' - OrderCreateRequest: - $ref: './openapi-wx/schemas/order-hooks.yaml#/OrderCreateRequest' - OrderUpdateRequest: - $ref: './openapi-wx/schemas/order-hooks.yaml#/OrderUpdateRequest' - OrderDeleteRequest: - $ref: './openapi-wx/schemas/order-hooks.yaml#/OrderDeleteRequest' - OrderListResponse: - $ref: './openapi-wx/schemas/order-hooks.yaml#/OrderListResponse' - OrderDeleteResponse: - $ref: './openapi-wx/schemas/order-hooks.yaml#/OrderDeleteResponse' + $ref: './openapi-wx/cart.yaml#/components/schemas/CartDeleteResponse' PocketBaseCartFields: - $ref: './openapi-wx/schemas/cart-native.yaml#/PocketBaseCartFields' + $ref: './openapi-wx/cart.yaml#/components/schemas/PocketBaseCartFields' PocketBaseCartRecord: - $ref: './openapi-wx/schemas/cart-native.yaml#/PocketBaseCartRecord' + $ref: './openapi-wx/cart.yaml#/components/schemas/PocketBaseCartRecord' PocketBaseCartCreateRequest: - $ref: './openapi-wx/schemas/cart-native.yaml#/PocketBaseCartCreateRequest' + $ref: './openapi-wx/cart.yaml#/components/schemas/PocketBaseCartCreateRequest' PocketBaseCartUpdateRequest: - $ref: './openapi-wx/schemas/cart-native.yaml#/PocketBaseCartUpdateRequest' + $ref: './openapi-wx/cart.yaml#/components/schemas/PocketBaseCartUpdateRequest' PocketBaseCartListResponse: - $ref: './openapi-wx/schemas/cart-native.yaml#/PocketBaseCartListResponse' + $ref: './openapi-wx/cart.yaml#/components/schemas/PocketBaseCartListResponse' + OrderRecord: + $ref: './openapi-wx/order.yaml#/components/schemas/OrderRecord' + OrderListRequest: + $ref: './openapi-wx/order.yaml#/components/schemas/OrderListRequest' + OrderDetailRequest: + $ref: './openapi-wx/order.yaml#/components/schemas/OrderDetailRequest' + OrderCreateRequest: + $ref: './openapi-wx/order.yaml#/components/schemas/OrderCreateRequest' + OrderUpdateRequest: + $ref: './openapi-wx/order.yaml#/components/schemas/OrderUpdateRequest' + OrderDeleteRequest: + $ref: './openapi-wx/order.yaml#/components/schemas/OrderDeleteRequest' + OrderListResponse: + $ref: './openapi-wx/order.yaml#/components/schemas/OrderListResponse' + OrderDeleteResponse: + $ref: './openapi-wx/order.yaml#/components/schemas/OrderDeleteResponse' PocketBaseOrderFields: - $ref: './openapi-wx/schemas/order-native.yaml#/PocketBaseOrderFields' + $ref: './openapi-wx/order.yaml#/components/schemas/PocketBaseOrderFields' PocketBaseOrderRecord: - $ref: './openapi-wx/schemas/order-native.yaml#/PocketBaseOrderRecord' + $ref: './openapi-wx/order.yaml#/components/schemas/PocketBaseOrderRecord' PocketBaseOrderCreateRequest: - $ref: './openapi-wx/schemas/order-native.yaml#/PocketBaseOrderCreateRequest' + $ref: './openapi-wx/order.yaml#/components/schemas/PocketBaseOrderCreateRequest' PocketBaseOrderUpdateRequest: - $ref: './openapi-wx/schemas/order-native.yaml#/PocketBaseOrderUpdateRequest' + $ref: './openapi-wx/order.yaml#/components/schemas/PocketBaseOrderUpdateRequest' PocketBaseOrderListResponse: - $ref: './openapi-wx/schemas/order-native.yaml#/PocketBaseOrderListResponse' + $ref: './openapi-wx/order.yaml#/components/schemas/PocketBaseOrderListResponse' diff --git a/pocket-base/spec/openapi-wx/attachments.yaml b/pocket-base/spec/openapi-wx/attachments.yaml new file mode 100644 index 0000000..588aa0c --- /dev/null +++ b/pocket-base/spec/openapi-wx/attachments.yaml @@ -0,0 +1,263 @@ +paths: + attachmentRecords: + get: + operationId: getPocketBaseAttachmentRecords + tags: + - 附件信息 + summary: 根据 attachments_id 查询单条或多条附件信息 + description: | + 使用 PocketBase 原生 records list 接口查询 `tbl_attachments`。 + + 当前线上权限规则: + - `listRule = is_delete = 0`,因此任何客户端都可直接读取未软删除附件 + - 原生 `create/update/delete` 仍仅管理员或管理后台用户允许 + + 标准调用方式有两种: + 1. 按 `attachments_id` 查询单条: + - `filter=attachments_id="ATT-1774599142438-8n1UcU"` + - `perPage=1` + - `page=1` + 2. 按多个 `attachments_id` 批量查询: + - 使用 `||` 组合多个等值条件 + - 例如:`filter=attachments_id="ATT-1774599142438-8n1UcU" || attachments_id="ATT-1774599143999-7pQkLm"` + - 传 `perPage` 为预期返回条数,`page=1` + + 注意: + - 这是 PocketBase 原生返回结构,不是 hooks 统一 `{ statusCode, errMsg, data }` 包装 + - `attachments_link` 返回的是 PocketBase 文件字段值,不是完整下载地址 + - 若需文件流地址,可按 PocketBase 标准文件路径自行拼接:`/pb/api/files/{collectionId}/{recordId}/{attachments_link}` + parameters: + - name: filter + in: query + required: false + description: | + PocketBase 标准过滤表达式。 + + - 按 `attachments_id` 精确查询单条:`attachments_id="ATT-1774599142438-8n1UcU"` + - 按多个 `attachments_id` 批量查询:`attachments_id="ATT-1774599142438-8n1UcU" || attachments_id="ATT-1774599143999-7pQkLm"` + - 不传该参数时,返回分页列表 + schema: + type: string + example: attachments_id="ATT-1774599142438-8n1UcU" + - name: page + in: query + required: false + description: 页码 + schema: + type: integer + minimum: 1 + default: 1 + - name: perPage + in: query + required: false + description: 每页条数;单查建议为 `1`,批量查询建议设置为预期条数 + schema: + type: integer + minimum: 1 + default: 20 + responses: + "200": + description: 查询成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseAttachmentListResponse + example: + page: page|integer + perPage: perPage|integer + totalItems: totalItems|integer + totalPages: totalPages|integer + items: + - id: PocketBase 记录主键|string + collectionId: 集合ID|string + collectionName: 集合名称|string + attachments_id: 附件业务 ID|string + attachments_link: PocketBase 文件字段值,可按标准文件路径拼接文件流地址|string + attachments_filename: 原始文件名|string + attachments_filetype: 文件类型 / MIME|string + attachments_size: 文件大小|number + attachments_owner: 上传者业务标识|string + attachments_md5: 文件 MD5|string + attachments_ocr: OCR 识别结果|string + attachments_status: 附件状态|string + attachments_remark: 备注|string + "400": + description: 查询参数错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "403": + description: 集合规则被锁定或服务端权限设置异常 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string +components: + schemas: + PocketBaseNativeError: + type: object + properties: + code: + type: + - integer + - string + description: 业务状态码 + example: 错误状态码 | integer + message: + type: string + example: PocketBase原生错误信息 | string + data: + description: 业务响应数据 + type: object + additionalProperties: true + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + PocketBaseAttachmentRecord: + type: object + properties: + id: + type: string + description: PocketBase 记录主键 + example: PocketBase记录主键 | string + collectionId: + type: string + description: 集合ID + example: 集合ID | string + collectionName: + type: string + description: 集合名称 + example: 集合名称 | string + attachments_id: + type: string + description: 附件业务 ID + example: 附件业务ID | string + attachments_link: + type: string + description: PocketBase 文件字段值,可按标准文件路径拼接文件流地址 + example: PocketBase文件字段值,可拼接文件流地址 | string + attachments_filename: + type: string + description: 原始文件名 + example: 原始文件名 | string + attachments_filetype: + type: string + description: 文件类型 / MIME + example: 文件类型或MIME | string + attachments_size: + type: + - number + - integer + - string + description: 文件大小 + example: 文件大小 | number + attachments_owner: + type: string + description: 上传者业务标识 + example: 上传者业务标识 | string + attachments_md5: + type: string + description: 文件 MD5 + example: 文件MD5 | string + attachments_ocr: + type: string + description: OCR 识别结果 + example: OCR识别结果 | string + attachments_status: + type: string + description: 附件状态 + example: 附件状态 | string + attachments_remark: + type: string + description: 备注 + example: 备注 | string + example: + id: PocketBase 记录主键|string + collectionId: 集合ID|string + collectionName: 集合名称|string + attachments_id: 附件业务 ID|string + attachments_link: PocketBase 文件字段值,可按标准文件路径拼接文件流地址|string + attachments_filename: 原始文件名|string + attachments_filetype: 文件类型 / MIME|string + attachments_size: 文件大小|number + attachments_owner: 上传者业务标识|string + attachments_md5: 文件 MD5|string + attachments_ocr: OCR 识别结果|string + attachments_status: 附件状态|string + attachments_remark: 备注|string + PocketBaseAttachmentListResponse: + type: object + required: + - page + - perPage + - totalItems + - totalPages + - items + properties: + page: + type: + - integer + - string + example: 页码 | integer + perPage: + type: + - integer + - string + example: 每页条数 | integer + totalItems: + type: + - integer + - string + example: 总记录数 | integer + totalPages: + type: + - integer + - string + example: 总页数 | integer + items: + type: array + items: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseAttachmentRecord + example: + page: page|integer + perPage: perPage|integer + totalItems: totalItems|integer + totalPages: totalPages|integer + items: + - id: PocketBase 记录主键|string + collectionId: 集合ID|string + collectionName: 集合名称|string + attachments_id: 附件业务 ID|string + attachments_link: PocketBase 文件字段值,可按标准文件路径拼接文件流地址|string + attachments_filename: 原始文件名|string + attachments_filetype: 文件类型 / MIME|string + attachments_size: 文件大小|number + attachments_owner: 上传者业务标识|string + attachments_md5: 文件 MD5|string + attachments_ocr: OCR 识别结果|string + attachments_status: 附件状态|string + attachments_remark: 备注|string diff --git a/pocket-base/spec/openapi-wx/cart.yaml b/pocket-base/spec/openapi-wx/cart.yaml new file mode 100644 index 0000000..8c7ecec --- /dev/null +++ b/pocket-base/spec/openapi-wx/cart.yaml @@ -0,0 +1,1521 @@ +paths: + cartList: + post: + operationId: postCartList + tags: + - 购物车 + summary: 按索引字段模糊查询购物车列表 + description: | + 调用自定义 hooks API 查询当前登录用户的购物车列表。 + + 查询规则: + - 仅允许查询当前 `Authorization` 对应用户自己的购物车记录 + - 支持通过 `keyword` 对多个索引相关字段做统一模糊搜索,当前实现覆盖: + - `cart_id` + - `cart_number` + - `cart_product_id` + - `product_name` + - 支持按 `cart_status` 精确过滤 + - 支持按 `cart_number` 精确过滤 + + 目标软删除契约: + - 目标行为应仅返回 `is_delete = 0` 的记录 + - 当前仓库实现尚未显式追加 `is_delete = 0` 过滤,请以实际后端代码为准 + security: + - BearerAuth: [] + requestBody: + required: false + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/CartListRequest + example: + keyword: 对 cart_id、cart_number、cart_product_id 等索引相关字段的统一模糊搜索关键字|string + cart_status: 购物车状态精确过滤|string + cart_number: 购物车名称或分组号精确过滤|string + responses: + "200": + description: 查询成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/CartListResponse + example: + items: + - pb_id: PocketBase 记录主键 id|string + created: PocketBase 系统创建时间|string + updated: PocketBase 系统更新时间|string + cart_id: 购物车业务 ID|string + cart_number: 购物车名称或分组号|string + cart_create: 购物车项创建时间,由数据库自动生成|string + cart_owner: 购物车所有者 openid|string + cart_product_id: 产品业务 ID|string + cart_product_quantity: 产品数量|integer + cart_status: 购物车状态|string + cart_at_price: 加入购物车时价格|integer + cart_remark: 备注|string + is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer + product_name: 产品名称(服务端联动补充)|string + product_modelnumber: 产品型号(服务端联动补充)|string + product_basic_price: 产品基础价格(服务端联动补充)|integer + "400": + description: 参数错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "401": + description: token 缺失、无效或已过期 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "415": + description: 请求体必须为 application/json + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + cartDetail: + post: + operationId: postCartDetail + tags: + - 购物车 + summary: 按 cart_id 精确查询购物车详情 + description: | + 调用自定义 hooks API 按 `cart_id` 查询单条购物车记录。 + + 查询规则: + - 仅允许访问当前 `Authorization` 对应用户自己的购物车记录 + - 查询键为业务 ID `cart_id`,不是 PocketBase 原生 `recordId` + + 目标软删除契约: + - 目标行为应仅允许查询 `is_delete = 0` 的记录 + - 当前仓库实现尚未显式追加 `is_delete = 0` 过滤,请以实际后端代码为准 + security: + - BearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/CartDetailRequest + example: + cart_id: 购物车业务 ID|string + responses: + "200": + description: 查询成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/CartRecord + example: + pb_id: PocketBase 记录主键 id|string + created: PocketBase 系统创建时间|string + updated: PocketBase 系统更新时间|string + cart_id: 购物车业务 ID|string + cart_number: 购物车名称或分组号|string + cart_create: 购物车项创建时间,由数据库自动生成|string + cart_owner: 购物车所有者 openid|string + cart_product_id: 产品业务 ID|string + cart_product_quantity: 产品数量|integer + cart_status: 购物车状态|string + cart_at_price: 加入购物车时价格|integer + cart_remark: 备注|string + is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer + product_name: 产品名称(服务端联动补充)|string + product_modelnumber: 产品型号(服务端联动补充)|string + product_basic_price: 产品基础价格(服务端联动补充)|integer + "400": + description: 参数错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "401": + description: token 缺失、无效或已过期 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "403": + description: 无权访问该购物车记录 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "404": + description: 未找到对应购物车记录 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "415": + description: 请求体必须为 application/json + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + cartCreate: + post: + operationId: postCartCreate + tags: + - 购物车 + summary: 新增购物车记录 + description: | + 调用自定义 hooks API 新增一条购物车记录。 + + 创建规则: + - 服务端自动根据当前 token 写入 `cart_owner` + - 服务端自动生成 `cart_id` + - 若未传 `cart_number`,服务端会自动生成展示编号 + - `cart_product_id`、`cart_product_quantity`、`cart_at_price` 为必填 + + 目标软删除契约: + - 新建记录应默认为 `is_delete = 0` + - 当前仓库导出响应中尚未显式返回 `is_delete` 字段 + security: + - BearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/CartCreateRequest + example: + cart_number: 可选;未传时服务端自动生成|string + cart_product_id: 产品业务 ID|string + cart_product_quantity: 产品数量,需为正整数|integer + cart_status: 可选;未传时默认 有效|string + cart_at_price: 加入购物车时价格|integer + cart_remark: 备注|string + responses: + "200": + description: 创建成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/CartRecord + example: + pb_id: PocketBase 记录主键 id|string + created: PocketBase 系统创建时间|string + updated: PocketBase 系统更新时间|string + cart_id: 购物车业务 ID|string + cart_number: 购物车名称或分组号|string + cart_create: 购物车项创建时间,由数据库自动生成|string + cart_owner: 购物车所有者 openid|string + cart_product_id: 产品业务 ID|string + cart_product_quantity: 产品数量|integer + cart_status: 购物车状态|string + cart_at_price: 加入购物车时价格|integer + cart_remark: 备注|string + is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer + product_name: 产品名称(服务端联动补充)|string + product_modelnumber: 产品型号(服务端联动补充)|string + product_basic_price: 产品基础价格(服务端联动补充)|integer + "400": + description: 参数错误、产品不存在或创建失败 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "401": + description: token 缺失、无效或已过期 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "415": + description: 请求体必须为 application/json + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "429": + description: 重复请求过于频繁 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + cartUpdate: + post: + operationId: postCartUpdate + tags: + - 购物车 + summary: 修改购物车记录 + description: | + 调用自定义 hooks API 按 `cart_id` 更新购物车记录。 + + 更新规则: + - 仅允许修改当前 `Authorization` 对应用户自己的购物车记录 + - `cart_id` 为必填,用于精确定位目标记录 + - 其余字段均为可选增量更新 + security: + - BearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/CartUpdateRequest + example: + cart_id: 购物车业务 ID|string + cart_number: cart_number|string + cart_product_id: cart_product_id|string + cart_product_quantity: cart_product_quantity|integer + cart_status: cart_status|string + cart_at_price: cart_at_price|integer + cart_remark: cart_remark|string + responses: + "200": + description: 更新成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/CartRecord + example: + pb_id: PocketBase 记录主键 id|string + created: PocketBase 系统创建时间|string + updated: PocketBase 系统更新时间|string + cart_id: 购物车业务 ID|string + cart_number: 购物车名称或分组号|string + cart_create: 购物车项创建时间,由数据库自动生成|string + cart_owner: 购物车所有者 openid|string + cart_product_id: 产品业务 ID|string + cart_product_quantity: 产品数量|integer + cart_status: 购物车状态|string + cart_at_price: 加入购物车时价格|integer + cart_remark: 备注|string + is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer + product_name: 产品名称(服务端联动补充)|string + product_modelnumber: 产品型号(服务端联动补充)|string + product_basic_price: 产品基础价格(服务端联动补充)|integer + "400": + description: 参数错误、产品不存在或更新失败 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "401": + description: token 缺失、无效或已过期 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "403": + description: 无权访问该购物车记录 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "404": + description: 未找到待修改的购物车记录 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "415": + description: 请求体必须为 application/json + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "429": + description: 重复请求过于频繁 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + cartDelete: + post: + operationId: postCartDelete + tags: + - 购物车 + summary: 软删除购物车记录 + description: | + 目标契约:按 `cart_id` 软删除购物车记录,将 `is_delete` 标记为 `1`,而不是物理删除。 + + 当前仓库实现差异: + - 当前 `cartOrderService.deleteCart()` 仍直接调用 `$app.delete(record)` 做物理删除 + - 因此当前后端实现与本软删除契约不一致 + - 若要严格按本文档执行,需先同步调整后端服务实现,并在列表/详情接口中补充 `is_delete = 0` 过滤 + security: + - BearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/CartDeleteRequest + example: + cart_id: 购物车业务 ID|string + responses: + "200": + description: 删除成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/CartDeleteResponse + example: + cart_id: 购物车业务 ID|string + is_delete: 目标软删除标记值;当前实现可能仍返回物理删除结果|integer + "400": + description: 参数错误或删除失败 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "401": + description: token 缺失、无效或已过期 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "403": + description: 无权访问该购物车记录 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "404": + description: 未找到待删除的购物车记录 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "415": + description: 请求体必须为 application/json + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "429": + description: 重复请求过于频繁 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + cartRecords: + get: + operationId: getPocketBaseCartRecords + tags: + - 购物车 + summary: 查询当前用户购物车列表或按业务 ID 精确查询 + description: | + 使用 PocketBase 原生 records list 接口查询 `tbl_cart`。 + + 当前线上权限规则: + - `listRule = @request.auth.id != "" && cart_owner = @request.auth.openid && is_delete = 0` + - 因此调用方只能读到 `cart_owner` 等于自己 `openid` 且未软删除的记录 + + 标准调用方式: + 1. 查询当前登录用户全部购物车: + - 不传 `filter` + - 可选传 `sort=-cart_create` + 2. 按业务 ID 精确查单条: + - `filter=cart_id="CART-..."` + - `perPage=1` + - `page=1` + + 注意: + - 这是 PocketBase 原生返回结构,不是 hooks 统一包装 + - 即使不传 `filter`,返回结果也会继续受 `listRule` 限制 + security: + - BearerAuth: [] + parameters: + - name: filter + in: query + required: false + description: | + PocketBase 标准过滤表达式。 + + - 查当前用户全部购物车时:不传 + - 按 `cart_id` 精确查单条时:`cart_id="CART-1770000000000-abc123"` + schema: + type: string + example: cart_id="CART-1770000000000-abc123" + - name: page + in: query + required: false + schema: + type: integer + minimum: 1 + default: 1 + - name: perPage + in: query + required: false + schema: + type: integer + minimum: 1 + default: 20 + - name: sort + in: query + required: false + description: PocketBase 原生排序表达式,推荐 `-cart_create` + schema: + type: string + example: -cart_create + responses: + "200": + description: 查询成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCartListResponse + example: + page: page|integer + perPage: perPage|integer + totalItems: totalItems|integer + totalPages: totalPages|integer + items: + - id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + cart_id: 购物车业务 ID|string + cart_number: 购物车名称或分组号|string + cart_create: 购物车项创建时间,由数据库自动生成|string + cart_owner: 购物车所有者 openid|string + cart_product_id: 产品业务 ID|string + cart_product_quantity: 产品数量|integer + cart_status: 购物车状态|string + cart_at_price: 加入购物车时价格|number + cart_remark: 备注|string + "400": + description: 查询参数错误或不满足 listRule + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "401": + description: token 缺失、无效或已过期 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "403": + description: 集合规则被锁定或服务端权限设置异常 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + post: + operationId: postPocketBaseCartRecord + tags: + - 购物车 + summary: 创建购物车记录 + description: | + 使用 PocketBase 原生 records create 接口向 `tbl_cart` 新增记录。 + + 当前线上权限规则: + - `createRule = @request.auth.id != "" && @request.body.cart_owner = @request.auth.openid` + - 因此客户端创建时必须显式提交 `cart_owner`,并且值必须等于当前 token 对应的 `openid` + + 这意味着: + - 不能依赖服务端自动补 owner + - 不能省略 `cart_owner` + - 不满足规则时 PocketBase 会直接返回 `400` + security: + - BearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCartCreateRequest + example: + cart_id: cart_id|string + cart_number: cart_number|string + cart_owner: 必须显式提交,且值必须等于当前 token 对应 openid|string + cart_product_id: cart_product_id|string + cart_product_quantity: cart_product_quantity|integer + cart_status: cart_status|string + cart_at_price: cart_at_price|number + cart_remark: cart_remark|string + responses: + "200": + description: 创建成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCartRecord + example: + id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + cart_id: 购物车业务 ID|string + cart_number: 购物车名称或分组号|string + cart_create: 购物车项创建时间,由数据库自动生成|string + cart_owner: 购物车所有者 openid|string + cart_product_id: 产品业务 ID|string + cart_product_quantity: 产品数量|integer + cart_status: 购物车状态|string + cart_at_price: 加入购物车时价格|number + cart_remark: 备注|string + "400": + description: 参数错误、违反字段约束或不满足 createRule + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "401": + description: token 缺失、无效或已过期 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "403": + description: 集合规则被锁定或服务端权限设置异常 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + cartRecordById: + patch: + operationId: patchPocketBaseCartRecordByRecordId + tags: + - 购物车 + summary: 更新购物车记录 + description: | + 使用 PocketBase 原生 records update 接口更新 `tbl_cart`。 + + 标准调用流程: + 1. 先通过 `GET /pb/api/collections/tbl_cart/records?filter=cart_id="..."&perPage=1&page=1` 找到原生 `recordId` + 2. 再调用当前 `PATCH /pb/api/collections/tbl_cart/records/{recordId}` + + 当前线上权限规则: + - `updateRule = @request.auth.id != "" && cart_owner = @request.auth.openid` + - 调用方只能修改自己的购物车记录 + security: + - BearerAuth: [] + parameters: + - name: recordId + in: path + required: true + schema: + type: string + example: l2r3nq7rqhuob0h + requestBody: + required: true + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCartUpdateRequest + example: + cart_number: cart_number|string + cart_owner: 若提交,必须仍等于当前 token 对应 openid|string + cart_product_id: cart_product_id|string + cart_product_quantity: cart_product_quantity|integer + cart_status: cart_status|string + cart_at_price: cart_at_price|number + cart_remark: cart_remark|string + responses: + "200": + description: 更新成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCartRecord + example: + id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + cart_id: 购物车业务 ID|string + cart_number: 购物车名称或分组号|string + cart_create: 购物车项创建时间,由数据库自动生成|string + cart_owner: 购物车所有者 openid|string + cart_product_id: 产品业务 ID|string + cart_product_quantity: 产品数量|integer + cart_status: 购物车状态|string + cart_at_price: 加入购物车时价格|number + cart_remark: 备注|string + "400": + description: 参数错误或违反字段约束 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "401": + description: token 缺失、无效或已过期 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "404": + description: 记录不存在或不满足 updateRule + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + delete: + operationId: deletePocketBaseCartRecordByRecordId + tags: + - 购物车 + summary: 删除购物车记录 + description: | + 使用 PocketBase 原生 records delete 接口删除 `tbl_cart`。 + + 当前线上权限规则: + - `deleteRule = @request.auth.id != "" && cart_owner = @request.auth.openid` + - 调用方只能删除自己的购物车记录 + security: + - BearerAuth: [] + parameters: + - name: recordId + in: path + required: true + schema: + type: string + example: l2r3nq7rqhuob0h + responses: + "204": + description: 删除成功 + "401": + description: token 缺失、无效或已过期 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "404": + description: 记录不存在或不满足 deleteRule + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string +components: + schemas: + ApiResponseBase: + type: object + required: + - statusCode + - errMsg + - data + properties: + statusCode: + type: + - integer + - string + description: 业务状态码 + example: 业务状态码 | integer + errMsg: + type: string + description: 业务提示信息 + example: 业务提示信息 | string + data: + description: 业务响应数据 + type: object + additionalProperties: true + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + ErrorResponse: + type: object + required: + - statusCode + - errMsg + - data + properties: + statusCode: + type: + - integer + - string + description: 业务状态码 + example: 业务状态码 | integer + errMsg: + type: string + description: 业务提示信息 + example: 失败原因提示 | string + data: + description: 业务响应数据 + type: object + additionalProperties: true + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + HookRecordBase: + type: object + properties: + pb_id: + type: string + description: PocketBase 记录主键 id + example: l2r3nq7rqhuob0h + created: + type: string + description: PocketBase 系统创建时间 + example: 2026-04-03 15:30:00.000Z + updated: + type: string + description: PocketBase 系统更新时间 + example: 2026-04-03 15:35:00.000Z + example: + pb_id: PocketBase 记录主键 id|string + created: PocketBase 系统创建时间|string + updated: PocketBase 系统更新时间|string + PocketBaseNativeError: + type: object + properties: + code: + type: + - integer + - string + description: 业务状态码 + example: 错误状态码 | integer + message: + type: string + example: PocketBase原生错误信息 | string + data: + description: 业务响应数据 + type: object + additionalProperties: true + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + PocketBaseRecordBase: + type: object + required: + - id + - collectionId + - collectionName + - created + - updated + properties: + id: + type: string + description: PocketBase 记录主键 + example: PocketBase记录主键 | string + collectionId: + type: string + example: 集合ID | string + collectionName: + type: string + example: 集合名称 | string + created: + type: string + description: 记录创建时间 + example: 记录创建时间 | string + updated: + type: string + description: 记录更新时间 + example: 记录更新时间 | string + example: + id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + CartRecord: + allOf: + - $ref: ../openapi-wx.yaml#/components/schemas/HookRecordBase + - type: object + properties: + cart_id: + type: string + description: 购物车业务 ID + example: CART-1770000000000-abc123 + cart_number: + type: string + description: 购物车名称或分组号 + example: wx-user-20260403153000 + cart_create: + type: string + description: 购物车项创建时间,由数据库自动生成 + example: 2026-04-03 15:30:00.000Z + cart_owner: + type: string + description: 购物车所有者 openid + example: wx-openid-user-001 + cart_product_id: + type: string + description: 产品业务 ID + example: PROD-1770000000000-abcd12 + cart_product_quantity: + type: + - integer + - number + description: 产品数量 + example: 2 + cart_status: + type: string + description: 购物车状态 + example: 有效 + cart_at_price: + type: + - integer + - number + description: 加入购物车时价格 + example: 1999 + cart_remark: + type: string + description: 备注 + example: 小程序加入购物车示例 + is_delete: + type: + - integer + - number + description: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出 + example: 0 + product_name: + type: string + description: 产品名称(服务端联动补充) + example: BAI 智能主机 + product_modelnumber: + type: string + description: 产品型号(服务端联动补充) + example: BAI-HOST-01 + product_basic_price: + type: + - integer + - number + - "null" + description: 产品基础价格(服务端联动补充) + example: 1999 + example: + pb_id: PocketBase 记录主键 id|string + created: PocketBase 系统创建时间|string + updated: PocketBase 系统更新时间|string + cart_id: 购物车业务 ID|string + cart_number: 购物车名称或分组号|string + cart_create: 购物车项创建时间,由数据库自动生成|string + cart_owner: 购物车所有者 openid|string + cart_product_id: 产品业务 ID|string + cart_product_quantity: 产品数量|integer + cart_status: 购物车状态|string + cart_at_price: 加入购物车时价格|integer + cart_remark: 备注|string + is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer + product_name: 产品名称(服务端联动补充)|string + product_modelnumber: 产品型号(服务端联动补充)|string + product_basic_price: 产品基础价格(服务端联动补充)|integer + CartListRequest: + type: object + properties: + keyword: + type: string + description: 对 `cart_id`、`cart_number`、`cart_product_id` 等索引相关字段的统一模糊搜索关键字 + example: CART-1770 + cart_status: + type: string + description: 购物车状态精确过滤 + example: 有效 + cart_number: + type: string + description: 购物车名称或分组号精确过滤 + example: wx-user-20260403153000 + example: + keyword: 对 cart_id、cart_number、cart_product_id 等索引相关字段的统一模糊搜索关键字|string + cart_status: 购物车状态精确过滤|string + cart_number: 购物车名称或分组号精确过滤|string + CartDetailRequest: + type: object + required: + - cart_id + properties: + cart_id: + type: string + description: 购物车业务 ID + example: CART-1770000000000-abc123 + example: + cart_id: 购物车业务 ID|string + CartCreateRequest: + type: object + required: + - cart_product_id + - cart_product_quantity + - cart_at_price + properties: + cart_number: + type: string + description: 可选;未传时服务端自动生成 + cart_product_id: + type: string + description: 产品业务 ID + example: PROD-1770000000000-abcd12 + cart_product_quantity: + type: + - integer + - number + description: 产品数量,需为正整数 + example: 2 + cart_status: + type: string + description: 可选;未传时默认 `有效` + example: 有效 + cart_at_price: + type: + - integer + - number + description: 加入购物车时价格 + example: 1999 + cart_remark: + type: string + description: 备注 + example: 小程序加入购物车示例 + example: + cart_number: 可选;未传时服务端自动生成|string + cart_product_id: 产品业务 ID|string + cart_product_quantity: 产品数量,需为正整数|integer + cart_status: 可选;未传时默认 有效|string + cart_at_price: 加入购物车时价格|integer + cart_remark: 备注|string + CartUpdateRequest: + type: object + required: + - cart_id + properties: + cart_id: + type: string + description: 购物车业务 ID + example: CART-1770000000000-abc123 + cart_number: + type: string + cart_product_id: + type: string + cart_product_quantity: + type: + - integer + - number + cart_status: + type: string + cart_at_price: + type: + - integer + - number + cart_remark: + type: string + example: + cart_id: 购物车业务 ID|string + cart_number: cart_number|string + cart_product_id: cart_product_id|string + cart_product_quantity: cart_product_quantity|integer + cart_status: cart_status|string + cart_at_price: cart_at_price|integer + cart_remark: cart_remark|string + CartDeleteRequest: + type: object + required: + - cart_id + properties: + cart_id: + type: string + description: 购物车业务 ID + example: CART-1770000000000-abc123 + example: + cart_id: 购物车业务 ID|string + CartListResponse: + type: object + properties: + items: + type: array + items: + $ref: ../openapi-wx.yaml#/components/schemas/CartRecord + example: + items: + - pb_id: PocketBase 记录主键 id|string + created: PocketBase 系统创建时间|string + updated: PocketBase 系统更新时间|string + cart_id: 购物车业务 ID|string + cart_number: 购物车名称或分组号|string + cart_create: 购物车项创建时间,由数据库自动生成|string + cart_owner: 购物车所有者 openid|string + cart_product_id: 产品业务 ID|string + cart_product_quantity: 产品数量|integer + cart_status: 购物车状态|string + cart_at_price: 加入购物车时价格|integer + cart_remark: 备注|string + is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer + product_name: 产品名称(服务端联动补充)|string + product_modelnumber: 产品型号(服务端联动补充)|string + product_basic_price: 产品基础价格(服务端联动补充)|integer + CartDeleteResponse: + type: object + properties: + cart_id: + type: string + description: 购物车业务 ID + example: CART-1770000000000-abc123 + is_delete: + type: + - integer + - number + description: 目标软删除标记值;当前实现可能仍返回物理删除结果 + example: 1 + example: + cart_id: 购物车业务 ID|string + is_delete: 目标软删除标记值;当前实现可能仍返回物理删除结果|integer + PocketBaseCartFields: + type: object + properties: + cart_id: + type: string + description: 购物车业务 ID + example: CART-1770000000000-abc123 + cart_number: + type: string + description: 购物车名称或分组号 + example: wx-user-20260403153000 + cart_create: + type: string + description: 购物车项创建时间,由数据库自动生成 + example: 2026-04-03 15:30:00.000Z + cart_owner: + type: string + description: 购物车所有者 openid + example: wx-openid-user-001 + cart_product_id: + type: string + description: 产品业务 ID + example: PROD-1770000000000-abcd12 + cart_product_quantity: + type: + - integer + - number + description: 产品数量 + example: 2 + cart_status: + type: string + description: 购物车状态 + example: 有效 + cart_at_price: + type: + - number + - integer + description: 加入购物车时价格 + example: 1999 + cart_remark: + type: string + description: 备注 + example: 小程序加入购物车示例 + example: + cart_id: 购物车业务 ID|string + cart_number: 购物车名称或分组号|string + cart_create: 购物车项创建时间,由数据库自动生成|string + cart_owner: 购物车所有者 openid|string + cart_product_id: 产品业务 ID|string + cart_product_quantity: 产品数量|integer + cart_status: 购物车状态|string + cart_at_price: 加入购物车时价格|number + cart_remark: 备注|string + PocketBaseCartRecord: + allOf: + - $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseRecordBase + - $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCartFields + example: + id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + cart_id: 购物车业务 ID|string + cart_number: 购物车名称或分组号|string + cart_create: 购物车项创建时间,由数据库自动生成|string + cart_owner: 购物车所有者 openid|string + cart_product_id: 产品业务 ID|string + cart_product_quantity: 产品数量|integer + cart_status: 购物车状态|string + cart_at_price: 加入购物车时价格|number + cart_remark: 备注|string + PocketBaseCartCreateRequest: + type: object + required: + - cart_id + - cart_number + - cart_owner + - cart_product_id + - cart_product_quantity + - cart_status + - cart_at_price + properties: + cart_id: + type: string + cart_number: + type: string + cart_owner: + type: string + description: 必须显式提交,且值必须等于当前 token 对应 openid + cart_product_id: + type: string + cart_product_quantity: + type: + - integer + - number + cart_status: + type: string + cart_at_price: + type: + - number + - integer + cart_remark: + type: string + example: + cart_id: cart_id|string + cart_number: cart_number|string + cart_owner: 必须显式提交,且值必须等于当前 token 对应 openid|string + cart_product_id: cart_product_id|string + cart_product_quantity: cart_product_quantity|integer + cart_status: cart_status|string + cart_at_price: cart_at_price|number + cart_remark: cart_remark|string + PocketBaseCartUpdateRequest: + type: object + properties: + cart_number: + type: string + cart_owner: + type: string + description: 若提交,必须仍等于当前 token 对应 openid + cart_product_id: + type: string + cart_product_quantity: + type: + - integer + - number + cart_status: + type: string + cart_at_price: + type: + - number + - integer + cart_remark: + type: string + example: + cart_number: cart_number|string + cart_owner: 若提交,必须仍等于当前 token 对应 openid|string + cart_product_id: cart_product_id|string + cart_product_quantity: cart_product_quantity|integer + cart_status: cart_status|string + cart_at_price: cart_at_price|number + cart_remark: cart_remark|string + PocketBaseCartListResponse: + type: object + required: + - page + - perPage + - totalItems + - totalPages + - items + properties: + page: + type: + - integer + - string + perPage: + type: + - integer + - string + totalItems: + type: + - integer + - string + totalPages: + type: + - integer + - string + items: + type: array + items: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCartRecord + example: + page: page|integer + perPage: perPage|integer + totalItems: totalItems|integer + totalPages: totalPages|integer + items: + - id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + cart_id: 购物车业务 ID|string + cart_number: 购物车名称或分组号|string + cart_create: 购物车项创建时间,由数据库自动生成|string + cart_owner: 购物车所有者 openid|string + cart_product_id: 产品业务 ID|string + cart_product_quantity: 产品数量|integer + cart_status: 购物车状态|string + cart_at_price: 加入购物车时价格|number + cart_remark: 备注|string diff --git a/pocket-base/spec/openapi-wx/company.yaml b/pocket-base/spec/openapi-wx/company.yaml new file mode 100644 index 0000000..e34c0cc --- /dev/null +++ b/pocket-base/spec/openapi-wx/company.yaml @@ -0,0 +1,903 @@ +paths: + companyRecords: + post: + operationId: postPocketBaseCompanyRecord + tags: + - 企业信息 + summary: 创建公司 + description: | + 使用 PocketBase 原生 records create 接口向 `tbl_company` 新增一行记录。 + + 当前线上权限规则: + - `createRule = ""`,因此任何客户端都可直接创建 + - 其他原生操作中,`update/delete/view` 仅管理员或管理后台用户允许 + + 注意: + - 这是 PocketBase 原生返回结构,不是 hooks 统一 `{ statusCode, errMsg, data }` 包装 + - `company_id` 由数据库自动生成,客户端创建时不需要传 + - `company_id` 仍带唯一索引,可用于后续按业务 id 查询 + requestBody: + required: true + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyCreateRequest + example: + company_name: 公司名称|string + company_type: 公司类型|string + company_entity: 公司法人|string + company_usci: 统一社会信用代码|string + company_nationality: 国家名称|string + company_nationality_code: 国家编码|string + company_province: 省份名称|string + company_province_code: 省份编码|string + company_city: 城市名称|string + company_city_code: 城市编码|string + company_district: 区 / 县名称|string + company_district_code: 区 / 县编码|string + company_postalcode: 邮编|string + company_add: 地址|string + company_status: 公司状态|string + company_level: 公司等级|string + company_owner_openid: 公司所有者 openid|string + company_remark: 备注|string + responses: + "200": + description: 创建成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyRecord + example: + id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + company_id: 公司业务 id,由数据库自动生成|string + company_name: 公司名称|string + company_type: 公司类型|string + company_entity: 公司法人|string + company_usci: 统一社会信用代码|string + company_nationality: 国家名称|string + company_nationality_code: 国家编码|string + company_province: 省份名称|string + company_province_code: 省份编码|string + company_city: 城市名称|string + company_city_code: 城市编码|string + company_district: 区/县名称|string + company_district_code: 区/县编码|string + company_postalcode: 邮政编码|string + company_add: 公司地址|string + company_status: 公司状态|string + company_level: 公司等级|string + company_owner_openid: 公司所有者 openid|string + company_remark: 备注|string + "400": + description: 参数错误或违反当前集合约束 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "403": + description: 集合规则被锁定或服务端权限设置异常 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + get: + operationId: getPocketBaseCompanyRecords + tags: + - 企业信息 + summary: 查询整个 tbl_company 列表 / 根据 company_id 查询对应公司信息 + description: | + 使用 PocketBase 原生 records list 接口查询 `tbl_company`。 + + 当前线上权限规则: + - `listRule = is_delete = 0`,因此默认只返回未软删除数据,且整个列表查询与条件查询都公开可读 + - `createRule = ""`,因此创建也公开可调用 + - `view/update/delete` 仅管理员或管理后台用户允许 + + 标准调用方式有两种: + 1. 根据 `company_id` 查询对应公司信息: + - `filter=company_id="WX-COMPANY-10001"` + - `perPage=1` + - `page=1` + 2. 查询整个 `tbl_company` 列表: + - 不传 `filter` + - 按需传 `page`、`perPage` + + 注意: + - 这是 PocketBase 原生返回结构,不是 hooks 统一 `{ statusCode, errMsg, data }` 包装 + - PocketBase 原生标准接口里,“按 `company_id` 查询单条”和“查询整个列表”共用同一个 `GET /records` 路径,因此文档以同一个 GET operation 展示两种调用模式 + parameters: + - name: filter + in: query + required: false + description: | + PocketBase 标准过滤表达式。 + + - 根据 `company_id` 查询单条时:`company_id="WX-COMPANY-10001"` + - 查询整个列表时:不传该参数 + schema: + type: string + example: company_id="WX-COMPANY-10001" + - name: page + in: query + required: false + description: 页码 + schema: + type: integer + minimum: 1 + default: 1 + - name: perPage + in: query + required: false + description: 每页条数;按 `company_id` 单查时建议固定为 `1` + schema: + type: integer + minimum: 1 + default: 20 + responses: + "200": + description: 查询成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyListResponse + example: + page: page|integer + perPage: perPage|integer + totalItems: totalItems|integer + totalPages: totalPages|integer + items: + - id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + company_id: 公司业务 id,由数据库自动生成|string + company_name: 公司名称|string + company_type: 公司类型|string + company_entity: 公司法人|string + company_usci: 统一社会信用代码|string + company_nationality: 国家名称|string + company_nationality_code: 国家编码|string + company_province: 省份名称|string + company_province_code: 省份编码|string + company_city: 城市名称|string + company_city_code: 城市编码|string + company_district: 区/县名称|string + company_district_code: 区/县编码|string + company_postalcode: 邮政编码|string + company_add: 公司地址|string + company_status: 公司状态|string + company_level: 公司等级|string + company_owner_openid: 公司所有者 openid|string + company_remark: 备注|string + "400": + description: 查询参数错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "403": + description: 集合规则被锁定或服务端权限设置异常 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + companyRecordById: + patch: + operationId: patchPocketBaseCompanyRecordByRecordId + tags: + - 企业信息 + summary: 通过 company_id 定位后修改公司信息 + description: | + 这是 PocketBase 原生标准更新接口,实际写入路径参数仍然必须使用记录主键 `recordId`。 + + 如果前端手里只有 `company_id`,标准调用流程是: + 1. 先调用 `GET /pb/api/collections/tbl_company/records?filter=company_id="..."&perPage=1&page=1` + 2. 从返回结果 `items[0].id` 中取出 PocketBase 原生记录主键 + 3. 再调用当前 `PATCH /pb/api/collections/tbl_company/records/{recordId}` 完成更新 + + 当前线上权限规则: + - `updateRule` 仅管理员或管理后台用户允许 + - 普通公开调用不能直接更新 + parameters: + - name: recordId + in: path + required: true + description: 通过 `company_id` 查询结果拿到的 PocketBase 记录主键 `id` + schema: + type: string + example: l2r3nq7rqhuob0h + requestBody: + required: true + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyUpdateRequest + example: + company_id: 所属公司业务 ID|string + company_name: 公司名称|string + company_type: 公司类型|string + company_entity: 公司法人|string + company_usci: 统一社会信用代码|string + company_nationality: 国家名称|string + company_nationality_code: 国家编码|string + company_province: 省份名称|string + company_province_code: 省份编码|string + company_city: 城市名称|string + company_city_code: 城市编码|string + company_district: 区 / 县名称|string + company_district_code: 区 / 县编码|string + company_postalcode: 邮编|string + company_add: 地址|string + company_status: 公司状态|string + company_level: 公司等级|string + company_owner_openid: 公司所有者 openid|string + company_remark: 备注|string + responses: + "200": + description: 更新成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyRecord + example: + id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + company_id: 公司业务 id,由数据库自动生成|string + company_name: 公司名称|string + company_type: 公司类型|string + company_entity: 公司法人|string + company_usci: 统一社会信用代码|string + company_nationality: 国家名称|string + company_nationality_code: 国家编码|string + company_province: 省份名称|string + company_province_code: 省份编码|string + company_city: 城市名称|string + company_city_code: 城市编码|string + company_district: 区/县名称|string + company_district_code: 区/县编码|string + company_postalcode: 邮政编码|string + company_add: 公司地址|string + company_status: 公司状态|string + company_level: 公司等级|string + company_owner_openid: 公司所有者 openid|string + company_remark: 备注|string + "400": + description: 参数错误或违反集合约束 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "403": + description: 当前调用方没有 update 权限 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "404": + description: 记录不存在 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string +components: + schemas: + PocketBaseNativeError: + type: object + properties: + code: + type: + - integer + - string + description: 业务状态码 + example: 错误状态码 | integer + message: + type: string + example: PocketBase原生错误信息 | string + data: + description: 业务响应数据 + type: object + additionalProperties: true + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + PocketBaseRecordBase: + type: object + required: + - id + - collectionId + - collectionName + - created + - updated + properties: + id: + type: string + description: PocketBase 记录主键 + example: PocketBase记录主键 | string + collectionId: + type: string + example: 集合ID | string + collectionName: + type: string + example: 集合名称 | string + created: + type: string + description: 记录创建时间 + example: 记录创建时间 | string + updated: + type: string + description: 记录更新时间 + example: 记录更新时间 | string + example: + id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + CompanyInfo: + anyOf: + - type: object + description: 用户所属公司信息;当用户尚未绑定公司时返回 `null` + properties: + pb_id: + type: string + description: PocketBase 记录主键 id + example: PocketBase记录主键id | string + company_id: + type: string + description: 公司业务 id,由数据库自动生成 + example: 公司业务id,由数据库自动生成 | string + company_name: + type: string + description: 公司名称 + example: 公司名称 | string + company_type: + type: string + description: 公司类型 + example: 公司类型 | string + company_entity: + type: string + description: 公司法人 + example: 公司法人 | string + company_usci: + type: string + description: 统一社会信用代码 + example: 统一社会信用代码 | string + company_nationality: + type: string + description: 国家名称 + example: 国家名称 | string + company_nationality_code: + type: string + description: 国家编码 + example: 国家编码 | string + company_province: + type: string + description: 省份名称 + example: 省份名称 | string + company_province_code: + type: string + description: 省份编码 + example: 省份编码 | string + company_city: + type: string + description: 城市名称 + example: 城市名称 | string + company_city_code: + type: string + description: 城市编码 + example: 城市编码 | string + company_district: + type: string + description: 区/县名称 + example: 区县名称 | string + company_district_code: + type: string + description: 区/县编码 + example: 区县编码 | string + company_postalcode: + type: string + description: 邮政编码 + example: 邮政编码 | string + company_add: + type: string + description: 公司地址 + example: 公司地址 | string + company_status: + type: string + description: 公司状态 + example: 公司状态 | string + company_level: + type: string + description: 公司等级 + example: 公司等级 | string + company_owner_openid: + type: string + description: 公司所有者 openid + example: 公司所有者openid | string + company_remark: + type: string + description: 备注 + example: 备注 | string + created: + type: string + description: 记录创建时间 + example: 记录创建时间 | string + updated: + type: string + description: 记录更新时间 + example: 记录更新时间 | string + example: + pb_id: PocketBase记录主键id | string + company_id: 公司业务id,由数据库自动生成 | string + company_name: 公司名称 | string + company_type: 公司类型 | string + company_entity: 公司法人 | string + company_usci: 统一社会信用代码 | string + company_nationality: 国家名称 | string + company_nationality_code: 国家编码 | string + company_province: 省份名称 | string + company_province_code: 省份编码 | string + company_city: 城市名称 | string + company_city_code: 城市编码 | string + company_district: 区县名称 | string + company_district_code: 区县编码 | string + company_postalcode: 邮政编码 | string + company_add: 公司地址 | string + company_status: 公司状态 | string + company_level: 公司等级 | string + company_owner_openid: 公司所有者openid | string + company_remark: 备注 | string + created: 记录创建时间 | string + updated: 记录更新时间 | string + - type: "null" + example: + pb_id: PocketBase 记录主键 id|string + company_id: 公司业务 id,由数据库自动生成|string + company_name: 公司名称|string + company_type: 公司类型|string + company_entity: 公司法人|string + company_usci: 统一社会信用代码|string + company_nationality: 国家名称|string + company_nationality_code: 国家编码|string + company_province: 省份名称|string + company_province_code: 省份编码|string + company_city: 城市名称|string + company_city_code: 城市编码|string + company_district: 区/县名称|string + company_district_code: 区/县编码|string + company_postalcode: 邮政编码|string + company_add: 公司地址|string + company_status: 公司状态|string + company_level: 公司等级|string + company_owner_openid: 公司所有者 openid|string + company_remark: 备注|string + created: 记录创建时间|string + updated: 记录更新时间|string + PocketBaseCompanyFields: + type: object + properties: + company_id: + type: string + description: 公司业务 id,由数据库自动生成 + example: 公司业务id,由数据库自动生成 | string + company_name: + type: string + description: 公司名称 + example: 公司名称 | string + company_type: + type: string + description: 公司类型 + example: 公司类型 | string + company_entity: + type: string + description: 公司法人 + example: 公司法人 | string + company_usci: + type: string + description: 统一社会信用代码 + example: 统一社会信用代码 | string + company_nationality: + type: string + description: 国家名称 + example: 国家名称 | string + company_nationality_code: + type: string + description: 国家编码 + example: 国家编码 | string + company_province: + type: string + description: 省份名称 + example: 省份名称 | string + company_province_code: + type: string + description: 省份编码 + example: 省份编码 | string + company_city: + type: string + description: 城市名称 + example: 城市名称 | string + company_city_code: + type: string + description: 城市编码 + example: 城市编码 | string + company_district: + type: string + description: 区/县名称 + example: 区县名称 | string + company_district_code: + type: string + description: 区/县编码 + example: 区县编码 | string + company_postalcode: + type: string + description: 邮政编码 + example: 邮政编码 | string + company_add: + type: string + description: 公司地址 + example: 公司地址 | string + company_status: + type: string + description: 公司状态 + example: 公司状态 | string + company_level: + type: string + description: 公司等级 + example: 公司等级 | string + company_owner_openid: + type: string + description: 公司所有者 openid + example: 公司所有者openid | string + company_remark: + type: string + description: 备注 + example: 备注 | string + example: + company_id: 公司业务 id,由数据库自动生成|string + company_name: 公司名称|string + company_type: 公司类型|string + company_entity: 公司法人|string + company_usci: 统一社会信用代码|string + company_nationality: 国家名称|string + company_nationality_code: 国家编码|string + company_province: 省份名称|string + company_province_code: 省份编码|string + company_city: 城市名称|string + company_city_code: 城市编码|string + company_district: 区/县名称|string + company_district_code: 区/县编码|string + company_postalcode: 邮政编码|string + company_add: 公司地址|string + company_status: 公司状态|string + company_level: 公司等级|string + company_owner_openid: 公司所有者 openid|string + company_remark: 备注|string + PocketBaseCompanyRecord: + allOf: + - $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseRecordBase + - $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyFields + example: + id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + company_id: 公司业务 id,由数据库自动生成|string + company_name: 公司名称|string + company_type: 公司类型|string + company_entity: 公司法人|string + company_usci: 统一社会信用代码|string + company_nationality: 国家名称|string + company_nationality_code: 国家编码|string + company_province: 省份名称|string + company_province_code: 省份编码|string + company_city: 城市名称|string + company_city_code: 城市编码|string + company_district: 区/县名称|string + company_district_code: 区/县编码|string + company_postalcode: 邮政编码|string + company_add: 公司地址|string + company_status: 公司状态|string + company_level: 公司等级|string + company_owner_openid: 公司所有者 openid|string + company_remark: 备注|string + PocketBaseCompanyCreateRequest: + type: object + properties: + company_name: + description: 公司名称 + type: string + company_type: + description: 公司类型 + type: string + company_entity: + description: 公司法人 + type: string + company_usci: + description: 统一社会信用代码 + type: string + company_nationality: + description: 国家名称 + type: string + company_nationality_code: + description: 国家编码 + type: string + company_province: + description: 省份名称 + type: string + company_province_code: + description: 省份编码 + type: string + company_city: + description: 城市名称 + type: string + company_city_code: + description: 城市编码 + type: string + company_district: + description: 区 / 县名称 + type: string + company_district_code: + description: 区 / 县编码 + type: string + company_postalcode: + description: 邮编 + type: string + company_add: + description: 地址 + type: string + company_status: + description: 公司状态 + type: string + company_level: + description: 公司等级 + type: string + company_owner_openid: + description: 公司所有者 openid + type: string + company_remark: + description: 备注 + type: string + additionalProperties: false + example: + company_name: 公司名称|string + company_type: 公司类型|string + company_entity: 公司法人|string + company_usci: 统一社会信用代码|string + company_nationality: 国家名称|string + company_nationality_code: 国家编码|string + company_province: 省份名称|string + company_province_code: 省份编码|string + company_city: 城市名称|string + company_city_code: 城市编码|string + company_district: 区 / 县名称|string + company_district_code: 区 / 县编码|string + company_postalcode: 邮编|string + company_add: 地址|string + company_status: 公司状态|string + company_level: 公司等级|string + company_owner_openid: 公司所有者 openid|string + company_remark: 备注|string + PocketBaseCompanyUpdateRequest: + type: object + properties: + company_id: + description: 所属公司业务 ID + type: string + company_name: + description: 公司名称 + type: string + company_type: + description: 公司类型 + type: string + company_entity: + description: 公司法人 + type: string + company_usci: + description: 统一社会信用代码 + type: string + company_nationality: + description: 国家名称 + type: string + company_nationality_code: + description: 国家编码 + type: string + company_province: + description: 省份名称 + type: string + company_province_code: + description: 省份编码 + type: string + company_city: + description: 城市名称 + type: string + company_city_code: + description: 城市编码 + type: string + company_district: + description: 区 / 县名称 + type: string + company_district_code: + description: 区 / 县编码 + type: string + company_postalcode: + description: 邮编 + type: string + company_add: + description: 地址 + type: string + company_status: + description: 公司状态 + type: string + company_level: + description: 公司等级 + type: string + company_owner_openid: + description: 公司所有者 openid + type: string + company_remark: + description: 备注 + type: string + additionalProperties: false + example: + company_id: 所属公司业务 ID|string + company_name: 公司名称|string + company_type: 公司类型|string + company_entity: 公司法人|string + company_usci: 统一社会信用代码|string + company_nationality: 国家名称|string + company_nationality_code: 国家编码|string + company_province: 省份名称|string + company_province_code: 省份编码|string + company_city: 城市名称|string + company_city_code: 城市编码|string + company_district: 区 / 县名称|string + company_district_code: 区 / 县编码|string + company_postalcode: 邮编|string + company_add: 地址|string + company_status: 公司状态|string + company_level: 公司等级|string + company_owner_openid: 公司所有者 openid|string + company_remark: 备注|string + PocketBaseCompanyListResponse: + type: object + required: + - page + - perPage + - totalItems + - totalPages + - items + properties: + page: + type: + - integer + - string + example: 页码 | integer + perPage: + type: + - integer + - string + example: 每页条数 | integer + totalItems: + type: + - integer + - string + example: 总记录数 | integer + totalPages: + type: + - integer + - string + example: 总页数 | integer + items: + type: array + items: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseCompanyRecord + example: + page: page|integer + perPage: perPage|integer + totalItems: totalItems|integer + totalPages: totalPages|integer + items: + - id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + company_id: 公司业务 id,由数据库自动生成|string + company_name: 公司名称|string + company_type: 公司类型|string + company_entity: 公司法人|string + company_usci: 统一社会信用代码|string + company_nationality: 国家名称|string + company_nationality_code: 国家编码|string + company_province: 省份名称|string + company_province_code: 省份编码|string + company_city: 城市名称|string + company_city_code: 城市编码|string + company_district: 区/县名称|string + company_district_code: 区/县编码|string + company_postalcode: 邮政编码|string + company_add: 公司地址|string + company_status: 公司状态|string + company_level: 公司等级|string + company_owner_openid: 公司所有者 openid|string + company_remark: 备注|string diff --git a/pocket-base/spec/openapi-wx/documents.yaml b/pocket-base/spec/openapi-wx/documents.yaml new file mode 100644 index 0000000..14632fb --- /dev/null +++ b/pocket-base/spec/openapi-wx/documents.yaml @@ -0,0 +1,468 @@ +paths: + documentRecords: + get: + operationId: getPocketBaseDocumentRecords + tags: + - 文档信息 + summary: 分页查询文档列表 / 按 system_dict_id 与 enum 双条件分页筛选文档 + description: | + 使用 PocketBase 原生 records list 接口查询 `tbl_document`。 + + 当前线上权限规则: + - `listRule = is_delete = 0`,因此任何客户端都可直接分页查询未软删除文档 + - `viewRule = is_delete = 0`,因此单条详情也只可读取未软删除文档 + - `create/update/delete` 仍仅管理员或管理后台用户允许 + + `document_type` 的存储格式为: + - `system_dict_id@dict_word_enum|system_dict_id@dict_word_enum` + + 业务上这里是两个独立条件,并且查询时两个条件都要满足: + - 条件 1:包含某个 `system_dict_id` + - 条件 2:包含某个 `enum` + + PocketBase 原生标准接口实际只有一个 `filter` 参数,因此应在同一个 `filter` 中写成两个 `contains` 条件,例如: + - `system_dict_id = DICT-1774599144591-hAEFQj` + - `enum = UT1` + - 最终:`document_type ~ "DICT-1774599144591-hAEFQj" && document_type ~ "@UT1"` + + 这条写法已经按线上真实数据验证通过。 + + 排序说明: + - 当前线上统一按 `document_create` 排序 + - 若要“最新上传的排在最前面”,请传 `sort=-document_create` + + 标准调用方式有两种: + 1. 查询整个文档列表: + - 不传 `filter` + - 按需传 `page`、`perPage` + - 若要按最新上传倒序,传 `sort=-document_create` + 2. 根据 `system_dict_id` 和 `enum` 两个业务条件分页筛选: + - 直接传 `filter=document_type ~ "" && document_type ~ "@"` + - 传 `page`、`perPage` + - 若要按最新上传倒序,传 `sort=-document_create` + + 注意: + - 这是 PocketBase 原生返回结构,不是 hooks 统一 `{ statusCode, errMsg, data }` 包装 + - 如果需要更复杂的条件组合,可继续使用 PocketBase 原生 `filter` 语法自行扩展 + parameters: + - name: filter + in: query + required: false + description: | + PocketBase 标准过滤表达式。 + + - 查全部列表时:不传 + - 按业务条件筛选时,同时写两个 `contains` 条件 + - 第二个条件建议带上 `@` 前缀,避免误命中 + - 例如:`document_type ~ "DICT-1774599144591-hAEFQj" && document_type ~ "@UT1"` + schema: + type: string + example: document_type ~ "DICT-1774599144591-hAEFQj" && document_type ~ "@UT1" + - name: page + in: query + required: false + description: 页码 + schema: + type: integer + minimum: 1 + default: 1 + - name: perPage + in: query + required: false + description: 每页条数 + schema: + type: integer + minimum: 1 + default: 20 + - name: sort + in: query + required: false + description: | + PocketBase 原生排序表达式。 + + 当前线上建议使用: + - `-document_create`:按最新上传倒序返回 + schema: + type: string + example: -document_create + responses: + "200": + description: 查询成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseDocumentListResponse + example: + page: page|integer + perPage: perPage|integer + totalItems: totalItems|integer + totalPages: totalPages|integer + items: + - id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + document_id: 文档业务 ID|string + document_create: 文档创建时间,由数据库自动生成|string + document_effect_date: 文档生效日期|string + document_expiry_date: 文档到期日期|string + document_title: 文档标题|string + document_type: 文档类型,多选时按 system_dict_id@dict_word_enum|... 保存|string + document_subtitle: 文档副标题|string + document_summary: 文档摘要|string + document_content: 正文内容,保存 Markdown|string + document_image: 图片附件 ID 集合,底层以 | 分隔|string + document_video: 视频附件 ID 集合,底层以 | 分隔|string + document_file: 文件附件 ID 集合,底层以 | 分隔|string + document_status: 文档状态,仅 有效 / 过期|string + document_owner: 上传者 openid|string + document_relation_model: 关联机型 / 模型标识|string + document_keywords: 关键词,多选后以 | 分隔|string + document_share_count: 分享次数|number + document_download_count: 下载次数|number + document_favorite_count: 收藏次数|number + document_embedding_status: 文档嵌入状态|string + document_embedding_error: 文档嵌入错误原因|string + document_embedding_lasttime: 最后一次嵌入更新时间|string + document_vector_version: 向量版本号 / 模型名称|string + document_product_categories: 产品关联文档,多选后以 | 分隔|string + document_application_scenarios: 筛选依据,多选后以 | 分隔|string + document_hotel_type: 适用场景,多选后以 | 分隔|string + document_remark: 备注|string + "400": + description: 查询参数错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "403": + description: 集合规则被锁定或服务端权限设置异常 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string +components: + schemas: + PocketBaseNativeError: + type: object + properties: + code: + type: + - integer + - string + description: 业务状态码 + example: 错误状态码 | integer + message: + type: string + example: PocketBase原生错误信息 | string + data: + description: 业务响应数据 + type: object + additionalProperties: true + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + PocketBaseRecordBase: + type: object + required: + - id + - collectionId + - collectionName + - created + - updated + properties: + id: + type: string + description: PocketBase 记录主键 + example: PocketBase记录主键 | string + collectionId: + type: string + example: 集合ID | string + collectionName: + type: string + example: 集合名称 | string + created: + type: string + description: 记录创建时间 + example: 记录创建时间 | string + updated: + type: string + description: 记录更新时间 + example: 记录更新时间 | string + example: + id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + PocketBaseDocumentFields: + type: object + properties: + document_id: + type: string + description: 文档业务 ID + example: 文档业务ID | string + document_create: + type: string + description: 文档创建时间,由数据库自动生成 + example: 文档创建时间,由数据库自动生成 | string + document_effect_date: + type: string + description: 文档生效日期 + example: 文档生效日期 | string + document_expiry_date: + type: string + description: 文档到期日期 + example: 文档到期日期 | string + document_title: + type: string + description: 文档标题 + example: 文档标题 | string + document_type: + type: string + description: 文档类型,多选时按 system_dict_id@dict_word_enum|... 保存 + example: 文档类型,按system_dict_id@dict_word_enum保存 | string + document_subtitle: + type: string + description: 文档副标题 + example: 文档副标题 | string + document_summary: + type: string + description: 文档摘要 + example: 文档摘要 | string + document_content: + type: string + description: 正文内容,保存 Markdown + example: 正文内容 | string + document_image: + type: string + description: 图片附件 ID 集合,底层以 | 分隔 + example: 图片附件ID串,底层按|分隔 | string + document_video: + type: string + description: 视频附件 ID 集合,底层以 | 分隔 + example: 视频附件ID串,底层按|分隔 | string + document_file: + type: string + description: 文件附件 ID 集合,底层以 | 分隔 + example: 文件附件ID串,底层按|分隔 | string + document_status: + type: string + description: 文档状态,仅 `有效` / `过期` + example: 文档状态 | string + document_owner: + type: string + description: 上传者 openid + example: 上传者openid | string + document_relation_model: + type: string + description: 关联机型 / 模型标识 + example: 关联机型标识 | string + document_keywords: + type: string + description: 关键词,多选后以 | 分隔 + example: 关键词,多选按|分隔 | string + document_share_count: + type: number + description: 分享次数 + example: 0 + document_download_count: + type: number + description: 下载次数 + example: 0 + document_favorite_count: + type: number + description: 收藏次数 + example: 0 + document_embedding_status: + type: string + description: 文档嵌入状态 + example: 文档嵌入状态 | string + document_embedding_error: + type: string + description: 文档嵌入错误原因 + example: 文档嵌入错误原因 | string + document_embedding_lasttime: + type: string + description: 最后一次嵌入更新时间 + example: 最后一次嵌入更新时间 | string + document_vector_version: + type: string + description: 向量版本号 / 模型名称 + example: 向量版本号或模型名称 | string + document_product_categories: + type: string + description: 产品关联文档,多选后以 | 分隔 + example: 产品关联文档,多选按|分隔 | string + document_application_scenarios: + type: string + description: 筛选依据,多选后以 | 分隔 + example: 筛选依据,多选按|分隔 | string + document_hotel_type: + type: string + description: 适用场景,多选后以 | 分隔 + example: 适用场景,多选按|分隔 | string + document_remark: + type: string + description: 备注 + example: 备注 | string + example: + document_id: 文档业务 ID|string + document_create: 文档创建时间,由数据库自动生成|string + document_effect_date: 文档生效日期|string + document_expiry_date: 文档到期日期|string + document_title: 文档标题|string + document_type: 文档类型,多选时按 system_dict_id@dict_word_enum|... 保存|string + document_subtitle: 文档副标题|string + document_summary: 文档摘要|string + document_content: 正文内容,保存 Markdown|string + document_image: 图片附件 ID 集合,底层以 | 分隔|string + document_video: 视频附件 ID 集合,底层以 | 分隔|string + document_file: 文件附件 ID 集合,底层以 | 分隔|string + document_status: 文档状态,仅 有效 / 过期|string + document_owner: 上传者 openid|string + document_relation_model: 关联机型 / 模型标识|string + document_keywords: 关键词,多选后以 | 分隔|string + document_share_count: 分享次数|number + document_download_count: 下载次数|number + document_favorite_count: 收藏次数|number + document_embedding_status: 文档嵌入状态|string + document_embedding_error: 文档嵌入错误原因|string + document_embedding_lasttime: 最后一次嵌入更新时间|string + document_vector_version: 向量版本号 / 模型名称|string + document_product_categories: 产品关联文档,多选后以 | 分隔|string + document_application_scenarios: 筛选依据,多选后以 | 分隔|string + document_hotel_type: 适用场景,多选后以 | 分隔|string + document_remark: 备注|string + PocketBaseDocumentRecord: + allOf: + - $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseRecordBase + - $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseDocumentFields + example: + id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + document_id: 文档业务 ID|string + document_create: 文档创建时间,由数据库自动生成|string + document_effect_date: 文档生效日期|string + document_expiry_date: 文档到期日期|string + document_title: 文档标题|string + document_type: 文档类型,多选时按 system_dict_id@dict_word_enum|... 保存|string + document_subtitle: 文档副标题|string + document_summary: 文档摘要|string + document_content: 正文内容,保存 Markdown|string + document_image: 图片附件 ID 集合,底层以 | 分隔|string + document_video: 视频附件 ID 集合,底层以 | 分隔|string + document_file: 文件附件 ID 集合,底层以 | 分隔|string + document_status: 文档状态,仅 有效 / 过期|string + document_owner: 上传者 openid|string + document_relation_model: 关联机型 / 模型标识|string + document_keywords: 关键词,多选后以 | 分隔|string + document_share_count: 分享次数|number + document_download_count: 下载次数|number + document_favorite_count: 收藏次数|number + document_embedding_status: 文档嵌入状态|string + document_embedding_error: 文档嵌入错误原因|string + document_embedding_lasttime: 最后一次嵌入更新时间|string + document_vector_version: 向量版本号 / 模型名称|string + document_product_categories: 产品关联文档,多选后以 | 分隔|string + document_application_scenarios: 筛选依据,多选后以 | 分隔|string + document_hotel_type: 适用场景,多选后以 | 分隔|string + document_remark: 备注|string + PocketBaseDocumentListResponse: + type: object + required: + - page + - perPage + - totalItems + - totalPages + - items + properties: + page: + type: + - integer + - string + example: 页码 | integer + perPage: + type: + - integer + - string + example: 每页条数 | integer + totalItems: + type: + - integer + - string + example: 总记录数 | integer + totalPages: + type: + - integer + - string + example: 总页数 | integer + items: + type: array + items: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseDocumentRecord + example: + page: page|integer + perPage: perPage|integer + totalItems: totalItems|integer + totalPages: totalPages|integer + items: + - id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + document_id: 文档业务 ID|string + document_create: 文档创建时间,由数据库自动生成|string + document_effect_date: 文档生效日期|string + document_expiry_date: 文档到期日期|string + document_title: 文档标题|string + document_type: 文档类型,多选时按 system_dict_id@dict_word_enum|... 保存|string + document_subtitle: 文档副标题|string + document_summary: 文档摘要|string + document_content: 正文内容,保存 Markdown|string + document_image: 图片附件 ID 集合,底层以 | 分隔|string + document_video: 视频附件 ID 集合,底层以 | 分隔|string + document_file: 文件附件 ID 集合,底层以 | 分隔|string + document_status: 文档状态,仅 有效 / 过期|string + document_owner: 上传者 openid|string + document_relation_model: 关联机型 / 模型标识|string + document_keywords: 关键词,多选后以 | 分隔|string + document_share_count: 分享次数|number + document_download_count: 下载次数|number + document_favorite_count: 收藏次数|number + document_embedding_status: 文档嵌入状态|string + document_embedding_error: 文档嵌入错误原因|string + document_embedding_lasttime: 最后一次嵌入更新时间|string + document_vector_version: 向量版本号 / 模型名称|string + document_product_categories: 产品关联文档,多选后以 | 分隔|string + document_application_scenarios: 筛选依据,多选后以 | 分隔|string + document_hotel_type: 适用场景,多选后以 | 分隔|string + document_remark: 备注|string diff --git a/pocket-base/spec/openapi-wx/order.yaml b/pocket-base/spec/openapi-wx/order.yaml new file mode 100644 index 0000000..91ad0aa --- /dev/null +++ b/pocket-base/spec/openapi-wx/order.yaml @@ -0,0 +1,1559 @@ +paths: + orderList: + post: + operationId: postOrderList + tags: + - 订单 + summary: 按索引字段模糊查询订单列表 + description: | + 调用自定义 hooks API 查询当前登录用户的订单列表。 + + 查询规则: + - 仅允许查询当前 `Authorization` 对应用户自己的订单记录 + - 支持通过 `keyword` 对多个索引相关字段做统一模糊搜索,当前实现覆盖: + - `order_id` + - `order_number` + - `order_source_id` + - 支持按 `order_status` 精确过滤 + - 支持按 `order_source` 精确过滤 + + 目标软删除契约: + - 目标行为应仅返回 `is_delete = 0` 的记录 + - 当前仓库实现尚未显式追加 `is_delete = 0` 过滤,请以实际后端代码为准 + security: + - BearerAuth: [] + requestBody: + required: false + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/OrderListRequest + example: + keyword: 对 order_id、order_number、order_source_id 等索引相关字段的统一模糊搜索关键字|string + order_status: 订单状态精确过滤|string + order_source: 订单来源精确过滤|string + responses: + "200": + description: 查询成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/OrderListResponse + example: + items: + - pb_id: PocketBase 记录主键 id|string + created: PocketBase 系统创建时间|string + updated: PocketBase 系统更新时间|string + order_id: 订单业务 ID|string + order_number: 订单编号|string + order_create: 订单创建时间,由数据库自动生成|string + order_owner: 订单所有者 openid|string + order_source: 订单来源|string + order_status: 订单状态|string + order_source_id: 来源关联业务 ID|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: 订单金额|integer + order_remark: 备注|string + is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer + "400": + description: 参数错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "401": + description: token 缺失、无效或已过期 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "415": + description: 请求体必须为 application/json + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + orderDetail: + post: + operationId: postOrderDetail + tags: + - 订单 + summary: 按 order_id 精确查询订单详情 + description: | + 调用自定义 hooks API 按 `order_id` 查询单条订单记录。 + + 查询规则: + - 仅允许访问当前 `Authorization` 对应用户自己的订单记录 + - 查询键为业务 ID `order_id`,不是 PocketBase 原生 `recordId` + + 目标软删除契约: + - 目标行为应仅允许查询 `is_delete = 0` 的记录 + - 当前仓库实现尚未显式追加 `is_delete = 0` 过滤,请以实际后端代码为准 + security: + - BearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/OrderDetailRequest + example: + order_id: 订单业务 ID|string + responses: + "200": + description: 查询成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/OrderRecord + example: + pb_id: PocketBase 记录主键 id|string + created: PocketBase 系统创建时间|string + updated: PocketBase 系统更新时间|string + order_id: 订单业务 ID|string + order_number: 订单编号|string + order_create: 订单创建时间,由数据库自动生成|string + order_owner: 订单所有者 openid|string + order_source: 订单来源|string + order_status: 订单状态|string + order_source_id: 来源关联业务 ID|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: 订单金额|integer + order_remark: 备注|string + is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer + "400": + description: 参数错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "401": + description: token 缺失、无效或已过期 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "403": + description: 无权访问该订单记录 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "404": + description: 未找到对应订单记录 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "415": + description: 请求体必须为 application/json + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + orderCreate: + post: + operationId: postOrderCreate + tags: + - 订单 + summary: 新增订单记录 + description: | + 调用自定义 hooks API 新增一条订单记录。 + + 创建规则: + - 服务端自动根据当前 token 写入 `order_owner` + - 服务端自动生成 `order_id` + - 若未传 `order_number`,服务端会自动生成展示编号 + - `order_source`、`order_source_id`、`order_snap`、`order_amount` 为必填 + + 目标软删除契约: + - 新建记录应默认为 `is_delete = 0` + - 当前仓库导出响应中尚未显式返回 `is_delete` 字段 + security: + - BearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/OrderCreateRequest + example: + order_number: 可选;未传时服务端自动生成|string + order_source: 订单来源|string + order_status: 可选;未传时默认 订单已生成|string + order_source_id: 来源关联业务 ID|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: 订单金额|integer + order_remark: 备注|string + responses: + "200": + description: 创建成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/OrderRecord + example: + pb_id: PocketBase 记录主键 id|string + created: PocketBase 系统创建时间|string + updated: PocketBase 系统更新时间|string + order_id: 订单业务 ID|string + order_number: 订单编号|string + order_create: 订单创建时间,由数据库自动生成|string + order_owner: 订单所有者 openid|string + order_source: 订单来源|string + order_status: 订单状态|string + order_source_id: 来源关联业务 ID|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: 订单金额|integer + order_remark: 备注|string + is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer + "400": + description: 参数错误或创建失败 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "401": + description: token 缺失、无效或已过期 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "415": + description: 请求体必须为 application/json + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "429": + description: 重复请求过于频繁 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + orderUpdate: + post: + operationId: postOrderUpdate + tags: + - 订单 + summary: 修改订单记录 + description: | + 调用自定义 hooks API 按 `order_id` 更新订单记录。 + + 更新规则: + - 仅允许修改当前 `Authorization` 对应用户自己的订单记录 + - `order_id` 为必填,用于精确定位目标记录 + - 其余字段均为可选增量更新 + security: + - BearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/OrderUpdateRequest + example: + order_id: 订单业务 ID|string + order_number: order_number|string + order_source: order_source|string + order_status: order_status|string + order_source_id: order_source_id|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: order_amount|integer + order_remark: order_remark|string + responses: + "200": + description: 更新成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/OrderRecord + example: + pb_id: PocketBase 记录主键 id|string + created: PocketBase 系统创建时间|string + updated: PocketBase 系统更新时间|string + order_id: 订单业务 ID|string + order_number: 订单编号|string + order_create: 订单创建时间,由数据库自动生成|string + order_owner: 订单所有者 openid|string + order_source: 订单来源|string + order_status: 订单状态|string + order_source_id: 来源关联业务 ID|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: 订单金额|integer + order_remark: 备注|string + is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer + "400": + description: 参数错误或更新失败 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "401": + description: token 缺失、无效或已过期 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "403": + description: 无权访问该订单记录 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "404": + description: 未找到待修改的订单记录 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "415": + description: 请求体必须为 application/json + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "429": + description: 重复请求过于频繁 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + orderDelete: + post: + operationId: postOrderDelete + tags: + - 订单 + summary: 软删除订单记录 + description: | + 目标契约:按 `order_id` 软删除订单记录,将 `is_delete` 标记为 `1`,而不是物理删除。 + + 当前仓库实现差异: + - 当前 `cartOrderService.deleteOrder()` 仍直接调用 `$app.delete(record)` 做物理删除 + - 因此当前后端实现与本软删除契约不一致 + - 若要严格按本文档执行,需先同步调整后端服务实现,并在列表/详情接口中补充 `is_delete = 0` 过滤 + security: + - BearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/OrderDeleteRequest + example: + order_id: 订单业务 ID|string + responses: + "200": + description: 删除成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/OrderDeleteResponse + example: + order_id: 订单业务 ID|string + is_delete: 目标软删除标记值;当前实现可能仍返回物理删除结果|integer + "400": + description: 参数错误或删除失败 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "401": + description: token 缺失、无效或已过期 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "403": + description: 无权访问该订单记录 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "404": + description: 未找到待删除的订单记录 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "415": + description: 请求体必须为 application/json + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "429": + description: 重复请求过于频繁 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + orderRecords: + get: + operationId: getPocketBaseOrderRecords + tags: + - 订单 + summary: 查询当前用户订单列表或按业务 ID 精确查询 + description: | + 使用 PocketBase 原生 records list 接口查询 `tbl_order`。 + + 当前线上权限规则: + - `listRule = @request.auth.id != "" && order_owner = @request.auth.openid && is_delete = 0` + - 因此调用方只能读到 `order_owner` 等于自己 `openid` 且未软删除的记录 + + 标准调用方式: + 1. 查询当前登录用户全部订单: + - 不传 `filter` + - 可选传 `sort=-order_create` + 2. 按业务 ID 精确查单条: + - `filter=order_id="ORDER-..."` + - `perPage=1` + - `page=1` + security: + - BearerAuth: [] + parameters: + - name: filter + in: query + required: false + schema: + type: string + example: order_id="ORDER-1770000000000-abc123" + - name: page + in: query + required: false + schema: + type: integer + minimum: 1 + default: 1 + - name: perPage + in: query + required: false + schema: + type: integer + minimum: 1 + default: 20 + - name: sort + in: query + required: false + description: PocketBase 原生排序表达式,推荐 `-order_create` + schema: + type: string + example: -order_create + responses: + "200": + description: 查询成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseOrderListResponse + example: + page: page|integer + perPage: perPage|integer + totalItems: totalItems|integer + totalPages: totalPages|integer + items: + - id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + order_id: 订单业务 ID|string + order_number: 订单编号|string + order_create: 订单创建时间,由数据库自动生成|string + order_owner: 订单所有者 openid|string + order_source: 订单来源|string + order_status: 订单状态|string + order_source_id: 来源关联业务 ID|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: 订单金额|number + order_remark: 备注|string + "400": + description: 查询参数错误或不满足 listRule + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "401": + description: token 缺失、无效或已过期 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "403": + description: 集合规则被锁定或服务端权限设置异常 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + post: + operationId: postPocketBaseOrderRecord + tags: + - 订单 + summary: 创建订单记录 + description: | + 使用 PocketBase 原生 records create 接口向 `tbl_order` 新增记录。 + + 当前线上权限规则: + - `createRule = @request.auth.id != "" && @request.body.order_owner = @request.auth.openid` + - 因此客户端创建时必须显式提交 `order_owner`,并且值必须等于当前 token 对应的 `openid` + + 这意味着: + - 不能依赖服务端自动补 owner + - 不能省略 `order_owner` + - 不满足规则时 PocketBase 会直接返回 `400` + security: + - BearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseOrderCreateRequest + example: + order_id: order_id|string + order_number: order_number|string + order_owner: 必须显式提交,且值必须等于当前 token 对应 openid|string + order_source: order_source|string + order_status: order_status|string + order_source_id: order_source_id|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: order_amount|number + order_remark: order_remark|string + responses: + "200": + description: 创建成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseOrderRecord + example: + id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + order_id: 订单业务 ID|string + order_number: 订单编号|string + order_create: 订单创建时间,由数据库自动生成|string + order_owner: 订单所有者 openid|string + order_source: 订单来源|string + order_status: 订单状态|string + order_source_id: 来源关联业务 ID|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: 订单金额|number + order_remark: 备注|string + "400": + description: 参数错误、违反字段约束或不满足 createRule + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "401": + description: token 缺失、无效或已过期 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "403": + description: 集合规则被锁定或服务端权限设置异常 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + orderRecordById: + patch: + operationId: patchPocketBaseOrderRecordByRecordId + tags: + - 订单 + summary: 更新订单记录 + description: | + 使用 PocketBase 原生 records update 接口更新 `tbl_order`。 + + 标准调用流程: + 1. 先通过 `GET /pb/api/collections/tbl_order/records?filter=order_id="..."&perPage=1&page=1` 找到原生 `recordId` + 2. 再调用当前 `PATCH /pb/api/collections/tbl_order/records/{recordId}` + + 当前线上权限规则: + - `updateRule = @request.auth.id != "" && order_owner = @request.auth.openid` + - 调用方只能修改自己的订单记录 + security: + - BearerAuth: [] + parameters: + - name: recordId + in: path + required: true + schema: + type: string + example: l2r3nq7rqhuob0h + requestBody: + required: true + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseOrderUpdateRequest + example: + order_number: order_number|string + order_owner: 若提交,必须仍等于当前 token 对应 openid|string + order_source: order_source|string + order_status: order_status|string + order_source_id: order_source_id|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: order_amount|number + order_remark: order_remark|string + responses: + "200": + description: 更新成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseOrderRecord + example: + id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + order_id: 订单业务 ID|string + order_number: 订单编号|string + order_create: 订单创建时间,由数据库自动生成|string + order_owner: 订单所有者 openid|string + order_source: 订单来源|string + order_status: 订单状态|string + order_source_id: 来源关联业务 ID|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: 订单金额|number + order_remark: 备注|string + "400": + description: 参数错误或违反字段约束 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "401": + description: token 缺失、无效或已过期 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "404": + description: 记录不存在或不满足 updateRule + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + delete: + operationId: deletePocketBaseOrderRecordByRecordId + tags: + - 订单 + summary: 删除订单记录 + description: | + 使用 PocketBase 原生 records delete 接口删除 `tbl_order`。 + + 当前线上权限规则: + - `deleteRule = @request.auth.id != "" && order_owner = @request.auth.openid` + - 调用方只能删除自己的订单记录 + security: + - BearerAuth: [] + parameters: + - name: recordId + in: path + required: true + schema: + type: string + example: l2r3nq7rqhuob0h + responses: + "204": + description: 删除成功 + "401": + description: token 缺失、无效或已过期 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "404": + description: 记录不存在或不满足 deleteRule + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string +components: + schemas: + ApiResponseBase: + type: object + required: + - statusCode + - errMsg + - data + properties: + statusCode: + type: + - integer + - string + description: 业务状态码 + example: 业务状态码 | integer + errMsg: + type: string + description: 业务提示信息 + example: 业务提示信息 | string + data: + description: 业务响应数据 + type: object + additionalProperties: true + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + ErrorResponse: + type: object + required: + - statusCode + - errMsg + - data + properties: + statusCode: + type: + - integer + - string + description: 业务状态码 + example: 业务状态码 | integer + errMsg: + type: string + description: 业务提示信息 + example: 失败原因提示 | string + data: + description: 业务响应数据 + type: object + additionalProperties: true + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + HookRecordBase: + type: object + properties: + pb_id: + type: string + description: PocketBase 记录主键 id + example: l2r3nq7rqhuob0h + created: + type: string + description: PocketBase 系统创建时间 + example: 2026-04-03 15:30:00.000Z + updated: + type: string + description: PocketBase 系统更新时间 + example: 2026-04-03 15:35:00.000Z + example: + pb_id: PocketBase 记录主键 id|string + created: PocketBase 系统创建时间|string + updated: PocketBase 系统更新时间|string + PocketBaseNativeError: + type: object + properties: + code: + type: + - integer + - string + description: 业务状态码 + example: 错误状态码 | integer + message: + type: string + example: PocketBase原生错误信息 | string + data: + description: 业务响应数据 + type: object + additionalProperties: true + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + PocketBaseRecordBase: + type: object + required: + - id + - collectionId + - collectionName + - created + - updated + properties: + id: + type: string + description: PocketBase 记录主键 + example: PocketBase记录主键 | string + collectionId: + type: string + example: 集合ID | string + collectionName: + type: string + example: 集合名称 | string + created: + type: string + description: 记录创建时间 + example: 记录创建时间 | string + updated: + type: string + description: 记录更新时间 + example: 记录更新时间 | string + example: + id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + OrderRecord: + allOf: + - $ref: ../openapi-wx.yaml#/components/schemas/HookRecordBase + - type: object + properties: + order_id: + type: string + description: 订单业务 ID + example: ORDER-1770000000000-abc123 + order_number: + type: string + description: 订单编号 + example: wx-user-20260403153500 + order_create: + type: string + description: 订单创建时间,由数据库自动生成 + example: 2026-04-03 15:35:00.000Z + order_owner: + type: string + description: 订单所有者 openid + example: wx-openid-user-001 + order_source: + type: string + description: 订单来源 + example: 购物车 + order_status: + type: string + description: 订单状态 + example: 订单已生成 + order_source_id: + type: string + description: 来源关联业务 ID + example: CART-1770000000000-abc123 + order_snap: + description: 订单快照 JSON + oneOf: + - type: object + additionalProperties: true + - type: array + items: + type: object + additionalProperties: true + order_amount: + type: + - integer + - number + description: 订单金额 + example: 3998 + order_remark: + type: string + description: 备注 + example: 小程序订单示例 + is_delete: + type: + - integer + - number + description: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出 + example: 0 + example: + pb_id: PocketBase 记录主键 id|string + created: PocketBase 系统创建时间|string + updated: PocketBase 系统更新时间|string + order_id: 订单业务 ID|string + order_number: 订单编号|string + order_create: 订单创建时间,由数据库自动生成|string + order_owner: 订单所有者 openid|string + order_source: 订单来源|string + order_status: 订单状态|string + order_source_id: 来源关联业务 ID|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: 订单金额|integer + order_remark: 备注|string + is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer + OrderListRequest: + type: object + properties: + keyword: + type: string + description: 对 `order_id`、`order_number`、`order_source_id` 等索引相关字段的统一模糊搜索关键字 + example: ORDER-1770 + order_status: + type: string + description: 订单状态精确过滤 + example: 订单已生成 + order_source: + type: string + description: 订单来源精确过滤 + example: 购物车 + example: + keyword: 对 order_id、order_number、order_source_id 等索引相关字段的统一模糊搜索关键字|string + order_status: 订单状态精确过滤|string + order_source: 订单来源精确过滤|string + OrderDetailRequest: + type: object + required: + - order_id + properties: + order_id: + type: string + description: 订单业务 ID + example: ORDER-1770000000000-abc123 + example: + order_id: 订单业务 ID|string + OrderCreateRequest: + type: object + required: + - order_source + - order_source_id + - order_snap + - order_amount + properties: + order_number: + type: string + description: 可选;未传时服务端自动生成 + order_source: + type: string + description: 订单来源 + example: 购物车 + order_status: + type: string + description: 可选;未传时默认 `订单已生成` + example: 订单已生成 + order_source_id: + type: string + description: 来源关联业务 ID + example: CART-1770000000000-abc123 + order_snap: + description: 订单快照 JSON + oneOf: + - type: object + additionalProperties: true + - type: array + items: + type: object + additionalProperties: true + order_amount: + type: + - integer + - number + description: 订单金额 + example: 3998 + order_remark: + type: string + description: 备注 + example: 小程序订单示例 + example: + order_number: 可选;未传时服务端自动生成|string + order_source: 订单来源|string + order_status: 可选;未传时默认 订单已生成|string + order_source_id: 来源关联业务 ID|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: 订单金额|integer + order_remark: 备注|string + OrderUpdateRequest: + type: object + required: + - order_id + properties: + order_id: + type: string + description: 订单业务 ID + example: ORDER-1770000000000-abc123 + order_number: + type: string + order_source: + type: string + order_status: + type: string + order_source_id: + type: string + order_snap: + oneOf: + - type: object + additionalProperties: true + - type: array + items: + type: object + additionalProperties: true + order_amount: + type: + - integer + - number + order_remark: + type: string + example: + order_id: 订单业务 ID|string + order_number: order_number|string + order_source: order_source|string + order_status: order_status|string + order_source_id: order_source_id|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: order_amount|integer + order_remark: order_remark|string + OrderDeleteRequest: + type: object + required: + - order_id + properties: + order_id: + type: string + description: 订单业务 ID + example: ORDER-1770000000000-abc123 + example: + order_id: 订单业务 ID|string + OrderListResponse: + type: object + properties: + items: + type: array + items: + $ref: ../openapi-wx.yaml#/components/schemas/OrderRecord + example: + items: + - pb_id: PocketBase 记录主键 id|string + created: PocketBase 系统创建时间|string + updated: PocketBase 系统更新时间|string + order_id: 订单业务 ID|string + order_number: 订单编号|string + order_create: 订单创建时间,由数据库自动生成|string + order_owner: 订单所有者 openid|string + order_source: 订单来源|string + order_status: 订单状态|string + order_source_id: 来源关联业务 ID|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: 订单金额|integer + order_remark: 备注|string + is_delete: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出|integer + OrderDeleteResponse: + type: object + properties: + order_id: + type: string + description: 订单业务 ID + example: ORDER-1770000000000-abc123 + is_delete: + type: + - integer + - number + description: 目标软删除标记值;当前实现可能仍返回物理删除结果 + example: 1 + example: + order_id: 订单业务 ID|string + is_delete: 目标软删除标记值;当前实现可能仍返回物理删除结果|integer + PocketBaseOrderFields: + type: object + properties: + order_id: + type: string + description: 订单业务 ID + example: ORDER-1770000000000-abc123 + order_number: + type: string + description: 订单编号 + example: wx-user-20260403153500 + order_create: + type: string + description: 订单创建时间,由数据库自动生成 + example: 2026-04-03 15:35:00.000Z + order_owner: + type: string + description: 订单所有者 openid + example: wx-openid-user-001 + order_source: + type: string + description: 订单来源 + example: 购物车 + order_status: + type: string + description: 订单状态 + example: 订单已生成 + order_source_id: + type: string + description: 来源关联业务 ID + example: CART-1770000000000-abc123 + order_snap: + description: 订单快照 JSON + oneOf: + - type: object + additionalProperties: true + - type: array + items: + type: object + additionalProperties: true + order_amount: + type: + - number + - integer + description: 订单金额 + example: 3998 + order_remark: + type: string + description: 备注 + example: 小程序订单示例 + example: + order_id: 订单业务 ID|string + order_number: 订单编号|string + order_create: 订单创建时间,由数据库自动生成|string + order_owner: 订单所有者 openid|string + order_source: 订单来源|string + order_status: 订单状态|string + order_source_id: 来源关联业务 ID|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: 订单金额|number + order_remark: 备注|string + PocketBaseOrderRecord: + allOf: + - $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseRecordBase + - $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseOrderFields + example: + id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + order_id: 订单业务 ID|string + order_number: 订单编号|string + order_create: 订单创建时间,由数据库自动生成|string + order_owner: 订单所有者 openid|string + order_source: 订单来源|string + order_status: 订单状态|string + order_source_id: 来源关联业务 ID|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: 订单金额|number + order_remark: 备注|string + PocketBaseOrderCreateRequest: + type: object + required: + - order_id + - order_number + - order_owner + - order_source + - order_status + - order_source_id + - order_snap + - order_amount + properties: + order_id: + type: string + order_number: + type: string + order_owner: + type: string + description: 必须显式提交,且值必须等于当前 token 对应 openid + order_source: + type: string + order_status: + type: string + order_source_id: + type: string + order_snap: + oneOf: + - type: object + additionalProperties: true + - type: array + items: + type: object + additionalProperties: true + order_amount: + type: + - number + - integer + order_remark: + type: string + example: + order_id: order_id|string + order_number: order_number|string + order_owner: 必须显式提交,且值必须等于当前 token 对应 openid|string + order_source: order_source|string + order_status: order_status|string + order_source_id: order_source_id|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: order_amount|number + order_remark: order_remark|string + PocketBaseOrderUpdateRequest: + type: object + properties: + order_number: + type: string + order_owner: + type: string + description: 若提交,必须仍等于当前 token 对应 openid + order_source: + type: string + order_status: + type: string + order_source_id: + type: string + order_snap: + oneOf: + - type: object + additionalProperties: true + - type: array + items: + type: object + additionalProperties: true + order_amount: + type: + - number + - integer + order_remark: + type: string + example: + order_number: order_number|string + order_owner: 若提交,必须仍等于当前 token 对应 openid|string + order_source: order_source|string + order_status: order_status|string + order_source_id: order_source_id|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: order_amount|number + order_remark: order_remark|string + PocketBaseOrderListResponse: + type: object + required: + - page + - perPage + - totalItems + - totalPages + - items + properties: + page: + type: + - integer + - string + perPage: + type: + - integer + - string + totalItems: + type: + - integer + - string + totalPages: + type: + - integer + - string + items: + type: array + items: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseOrderRecord + example: + page: page|integer + perPage: perPage|integer + totalItems: totalItems|integer + totalPages: totalPages|integer + items: + - id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + order_id: 订单业务 ID|string + order_number: 订单编号|string + order_create: 订单创建时间,由数据库自动生成|string + order_owner: 订单所有者 openid|string + order_source: 订单来源|string + order_status: 订单状态|string + order_source_id: 来源关联业务 ID|string + order_snap: + order_snap字段|string: order_snap值|string + order_amount: 订单金额|number + order_remark: 备注|string diff --git a/pocket-base/spec/openapi-wx/paths/attachments.yaml b/pocket-base/spec/openapi-wx/paths/attachments.yaml deleted file mode 100644 index 1fc4776..0000000 --- a/pocket-base/spec/openapi-wx/paths/attachments.yaml +++ /dev/null @@ -1,135 +0,0 @@ -attachmentRecords: - get: - operationId: getPocketBaseAttachmentRecords - tags: - - 附件信息 - summary: 根据 attachments_id 查询单条或多条附件信息 - description: | - 使用 PocketBase 原生 records list 接口查询 `tbl_attachments`。 - - 当前线上权限规则: - - `listRule = is_delete = 0`,因此任何客户端都可直接读取未软删除附件 - - 原生 `create/update/delete` 仍仅管理员或管理后台用户允许 - - 标准调用方式有两种: - 1. 按 `attachments_id` 查询单条: - - `filter=attachments_id="ATT-1774599142438-8n1UcU"` - - `perPage=1` - - `page=1` - 2. 按多个 `attachments_id` 批量查询: - - 使用 `||` 组合多个等值条件 - - 例如:`filter=attachments_id="ATT-1774599142438-8n1UcU" || attachments_id="ATT-1774599143999-7pQkLm"` - - 传 `perPage` 为预期返回条数,`page=1` - - 注意: - - 这是 PocketBase 原生返回结构,不是 hooks 统一 `{ statusCode, errMsg, data }` 包装 - - `attachments_link` 返回的是 PocketBase 文件字段值,不是完整下载地址 - - 若需文件流地址,可按 PocketBase 标准文件路径自行拼接:`/pb/api/files/{collectionId}/{recordId}/{attachments_link}` - parameters: - - name: filter - in: query - required: false - description: | - PocketBase 标准过滤表达式。 - - - 按 `attachments_id` 精确查询单条:`attachments_id="ATT-1774599142438-8n1UcU"` - - 按多个 `attachments_id` 批量查询:`attachments_id="ATT-1774599142438-8n1UcU" || attachments_id="ATT-1774599143999-7pQkLm"` - - 不传该参数时,返回分页列表 - schema: - type: string - example: attachments_id="ATT-1774599142438-8n1UcU" - - name: page - in: query - required: false - description: 页码 - schema: - type: integer - minimum: 1 - default: 1 - - name: perPage - in: query - required: false - description: 每页条数;单查建议为 `1`,批量查询建议设置为预期条数 - schema: - type: integer - minimum: 1 - default: 20 - responses: - '200': - description: 查询成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseAttachmentListResponse' - examples: - byAttachmentsId: - value: - page: 页码 | integer - perPage: 每页条数 | integer - totalItems: 总记录数 | integer - totalPages: 总页数 | integer - items: - - id: PocketBase记录主键 | string - collectionId: 集合ID | string - collectionName: 集合名称 | string - attachments_id: 附件业务ID | string - attachments_link: PocketBase文件字段值,可拼接文件流地址 | string - attachments_filename: 原始文件名 | string - attachments_filetype: 文件类型或MIME | string - attachments_size: 文件大小 | number - attachments_owner: 上传者业务标识 | string - attachments_md5: 文件MD5 | string - attachments_ocr: OCR识别结果 | string - attachments_status: 附件状态 | string - attachments_remark: 备注 | string - byAttachmentsIds: - value: - page: 页码 | integer - perPage: 每页条数 | integer - totalItems: 总记录数 | integer - totalPages: 总页数 | integer - items: - - id: PocketBase记录主键 | string - collectionId: 集合ID | string - collectionName: 集合名称 | string - attachments_id: ATT-1774599142438-8n1UcU - attachments_link: PocketBase文件字段值,可拼接文件流地址 | string - attachments_filename: 原始文件名 | string - attachments_filetype: 文件类型或MIME | string - attachments_size: 文件大小 | number - attachments_owner: 上传者业务标识 | string - attachments_md5: 文件MD5 | string - attachments_ocr: OCR识别结果 | string - attachments_status: 附件状态 | string - attachments_remark: 备注 | string - - id: PocketBase记录主键 | string - collectionId: 集合ID | string - collectionName: 集合名称 | string - attachments_id: ATT-1774599143999-7pQkLm - attachments_link: PocketBase文件字段值,可拼接文件流地址 | string - attachments_filename: 原始文件名 | string - attachments_filetype: 文件类型或MIME | string - attachments_size: 文件大小 | number - attachments_owner: 上传者业务标识 | string - attachments_md5: 文件MD5 | string - attachments_ocr: OCR识别结果 | string - attachments_status: 附件状态 | string - attachments_remark: 备注 | string - '400': - description: 查询参数错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '403': - description: 集合规则被锁定或服务端权限设置异常 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' diff --git a/pocket-base/spec/openapi-wx/paths/cart-hooks.yaml b/pocket-base/spec/openapi-wx/paths/cart-hooks.yaml deleted file mode 100644 index 715804e..0000000 --- a/pocket-base/spec/openapi-wx/paths/cart-hooks.yaml +++ /dev/null @@ -1,335 +0,0 @@ -cartList: - post: - operationId: postCartList - tags: - - 购物车 - summary: 按索引字段模糊查询购物车列表 - description: | - 调用自定义 hooks API 查询当前登录用户的购物车列表。 - - 查询规则: - - 仅允许查询当前 `Authorization` 对应用户自己的购物车记录 - - 支持通过 `keyword` 对多个索引相关字段做统一模糊搜索,当前实现覆盖: - - `cart_id` - - `cart_number` - - `cart_product_id` - - `product_name` - - 支持按 `cart_status` 精确过滤 - - 支持按 `cart_number` 精确过滤 - - 目标软删除契约: - - 目标行为应仅返回 `is_delete = 0` 的记录 - - 当前仓库实现尚未显式追加 `is_delete = 0` 过滤,请以实际后端代码为准 - security: - - BearerAuth: [] - requestBody: - required: false - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/CartListRequest' - responses: - '200': - description: 查询成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/CartListResponse' - '400': - description: 参数错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '401': - description: token 缺失、无效或已过期 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '415': - description: 请求体必须为 application/json - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - -cartDetail: - post: - operationId: postCartDetail - tags: - - 购物车 - summary: 按 cart_id 精确查询购物车详情 - description: | - 调用自定义 hooks API 按 `cart_id` 查询单条购物车记录。 - - 查询规则: - - 仅允许访问当前 `Authorization` 对应用户自己的购物车记录 - - 查询键为业务 ID `cart_id`,不是 PocketBase 原生 `recordId` - - 目标软删除契约: - - 目标行为应仅允许查询 `is_delete = 0` 的记录 - - 当前仓库实现尚未显式追加 `is_delete = 0` 过滤,请以实际后端代码为准 - security: - - BearerAuth: [] - requestBody: - required: true - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/CartDetailRequest' - responses: - '200': - description: 查询成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/CartRecord' - '400': - description: 参数错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '401': - description: token 缺失、无效或已过期 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '403': - description: 无权访问该购物车记录 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '404': - description: 未找到对应购物车记录 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '415': - description: 请求体必须为 application/json - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - -cartCreate: - post: - operationId: postCartCreate - tags: - - 购物车 - summary: 新增购物车记录 - description: | - 调用自定义 hooks API 新增一条购物车记录。 - - 创建规则: - - 服务端自动根据当前 token 写入 `cart_owner` - - 服务端自动生成 `cart_id` - - 若未传 `cart_number`,服务端会自动生成展示编号 - - `cart_product_id`、`cart_product_quantity`、`cart_at_price` 为必填 - - 目标软删除契约: - - 新建记录应默认为 `is_delete = 0` - - 当前仓库导出响应中尚未显式返回 `is_delete` 字段 - security: - - BearerAuth: [] - requestBody: - required: true - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/CartCreateRequest' - responses: - '200': - description: 创建成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/CartRecord' - '400': - description: 参数错误、产品不存在或创建失败 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '401': - description: token 缺失、无效或已过期 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '415': - description: 请求体必须为 application/json - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '429': - description: 重复请求过于频繁 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - -cartUpdate: - post: - operationId: postCartUpdate - tags: - - 购物车 - summary: 修改购物车记录 - description: | - 调用自定义 hooks API 按 `cart_id` 更新购物车记录。 - - 更新规则: - - 仅允许修改当前 `Authorization` 对应用户自己的购物车记录 - - `cart_id` 为必填,用于精确定位目标记录 - - 其余字段均为可选增量更新 - security: - - BearerAuth: [] - requestBody: - required: true - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/CartUpdateRequest' - responses: - '200': - description: 更新成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/CartRecord' - '400': - description: 参数错误、产品不存在或更新失败 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '401': - description: token 缺失、无效或已过期 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '403': - description: 无权访问该购物车记录 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '404': - description: 未找到待修改的购物车记录 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '415': - description: 请求体必须为 application/json - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '429': - description: 重复请求过于频繁 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - -cartDelete: - post: - operationId: postCartDelete - tags: - - 购物车 - summary: 软删除购物车记录 - description: | - 目标契约:按 `cart_id` 软删除购物车记录,将 `is_delete` 标记为 `1`,而不是物理删除。 - - 当前仓库实现差异: - - 当前 `cartOrderService.deleteCart()` 仍直接调用 `$app.delete(record)` 做物理删除 - - 因此当前后端实现与本软删除契约不一致 - - 若要严格按本文档执行,需先同步调整后端服务实现,并在列表/详情接口中补充 `is_delete = 0` 过滤 - security: - - BearerAuth: [] - requestBody: - required: true - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/CartDeleteRequest' - responses: - '200': - description: 删除成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/CartDeleteResponse' - '400': - description: 参数错误或删除失败 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '401': - description: token 缺失、无效或已过期 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '403': - description: 无权访问该购物车记录 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '404': - description: 未找到待删除的购物车记录 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '415': - description: 请求体必须为 application/json - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '429': - description: 重复请求过于频繁 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' diff --git a/pocket-base/spec/openapi-wx/paths/cart-native.yaml b/pocket-base/spec/openapi-wx/paths/cart-native.yaml deleted file mode 100644 index 2b4f1a2..0000000 --- a/pocket-base/spec/openapi-wx/paths/cart-native.yaml +++ /dev/null @@ -1,250 +0,0 @@ -cartRecords: - get: - operationId: getPocketBaseCartRecords - tags: - - 购物车 - summary: 查询当前用户购物车列表或按业务 ID 精确查询 - description: | - 使用 PocketBase 原生 records list 接口查询 `tbl_cart`。 - - 当前线上权限规则: - - `listRule = @request.auth.id != "" && cart_owner = @request.auth.openid && is_delete = 0` - - 因此调用方只能读到 `cart_owner` 等于自己 `openid` 且未软删除的记录 - - 标准调用方式: - 1. 查询当前登录用户全部购物车: - - 不传 `filter` - - 可选传 `sort=-cart_create` - 2. 按业务 ID 精确查单条: - - `filter=cart_id="CART-..."` - - `perPage=1` - - `page=1` - - 注意: - - 这是 PocketBase 原生返回结构,不是 hooks 统一包装 - - 即使不传 `filter`,返回结果也会继续受 `listRule` 限制 - security: - - BearerAuth: [] - parameters: - - name: filter - in: query - required: false - description: | - PocketBase 标准过滤表达式。 - - - 查当前用户全部购物车时:不传 - - 按 `cart_id` 精确查单条时:`cart_id="CART-1770000000000-abc123"` - schema: - type: string - example: cart_id="CART-1770000000000-abc123" - - name: page - in: query - required: false - schema: - type: integer - minimum: 1 - default: 1 - - name: perPage - in: query - required: false - schema: - type: integer - minimum: 1 - default: 20 - - name: sort - in: query - required: false - description: PocketBase 原生排序表达式,推荐 `-cart_create` - schema: - type: string - example: -cart_create - responses: - '200': - description: 查询成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseCartListResponse' - '400': - description: 查询参数错误或不满足 listRule - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '401': - description: token 缺失、无效或已过期 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '403': - description: 集合规则被锁定或服务端权限设置异常 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - post: - operationId: postPocketBaseCartRecord - tags: - - 购物车 - summary: 创建购物车记录 - description: | - 使用 PocketBase 原生 records create 接口向 `tbl_cart` 新增记录。 - - 当前线上权限规则: - - `createRule = @request.auth.id != "" && @request.body.cart_owner = @request.auth.openid` - - 因此客户端创建时必须显式提交 `cart_owner`,并且值必须等于当前 token 对应的 `openid` - - 这意味着: - - 不能依赖服务端自动补 owner - - 不能省略 `cart_owner` - - 不满足规则时 PocketBase 会直接返回 `400` - security: - - BearerAuth: [] - requestBody: - required: true - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseCartCreateRequest' - responses: - '200': - description: 创建成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseCartRecord' - '400': - description: 参数错误、违反字段约束或不满足 createRule - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '401': - description: token 缺失、无效或已过期 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '403': - description: 集合规则被锁定或服务端权限设置异常 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - -cartRecordById: - patch: - operationId: patchPocketBaseCartRecordByRecordId - tags: - - 购物车 - summary: 更新购物车记录 - description: | - 使用 PocketBase 原生 records update 接口更新 `tbl_cart`。 - - 标准调用流程: - 1. 先通过 `GET /pb/api/collections/tbl_cart/records?filter=cart_id="..."&perPage=1&page=1` 找到原生 `recordId` - 2. 再调用当前 `PATCH /pb/api/collections/tbl_cart/records/{recordId}` - - 当前线上权限规则: - - `updateRule = @request.auth.id != "" && cart_owner = @request.auth.openid` - - 调用方只能修改自己的购物车记录 - security: - - BearerAuth: [] - parameters: - - name: recordId - in: path - required: true - schema: - type: string - example: l2r3nq7rqhuob0h - requestBody: - required: true - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseCartUpdateRequest' - responses: - '200': - description: 更新成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseCartRecord' - '400': - description: 参数错误或违反字段约束 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '401': - description: token 缺失、无效或已过期 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '404': - description: 记录不存在或不满足 updateRule - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - delete: - operationId: deletePocketBaseCartRecordByRecordId - tags: - - 购物车 - summary: 删除购物车记录 - description: | - 使用 PocketBase 原生 records delete 接口删除 `tbl_cart`。 - - 当前线上权限规则: - - `deleteRule = @request.auth.id != "" && cart_owner = @request.auth.openid` - - 调用方只能删除自己的购物车记录 - security: - - BearerAuth: [] - parameters: - - name: recordId - in: path - required: true - schema: - type: string - example: l2r3nq7rqhuob0h - responses: - '204': - description: 删除成功 - '401': - description: token 缺失、无效或已过期 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '404': - description: 记录不存在或不满足 deleteRule - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' diff --git a/pocket-base/spec/openapi-wx/paths/company.yaml b/pocket-base/spec/openapi-wx/paths/company.yaml deleted file mode 100644 index df27177..0000000 --- a/pocket-base/spec/openapi-wx/paths/company.yaml +++ /dev/null @@ -1,290 +0,0 @@ -companyRecords: - post: - operationId: postPocketBaseCompanyRecord - tags: - - 企业信息 - summary: 创建公司 - description: | - 使用 PocketBase 原生 records create 接口向 `tbl_company` 新增一行记录。 - - 当前线上权限规则: - - `createRule = ""`,因此任何客户端都可直接创建 - - 其他原生操作中,`update/delete/view` 仅管理员或管理后台用户允许 - - 注意: - - 这是 PocketBase 原生返回结构,不是 hooks 统一 `{ statusCode, errMsg, data }` 包装 - - `company_id` 由数据库自动生成,客户端创建时不需要传 - - `company_id` 仍带唯一索引,可用于后续按业务 id 查询 - requestBody: - required: true - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseCompanyCreateRequest' - examples: - default: - value: - company_name: 微信侧测试企业 - company_type: 渠道商 - company_entity: 张三 - company_usci: '91310000123456789A' - company_nationality: 中国 - company_nationality_code: CN - company_province: 上海 - company_province_code: '310000' - company_city: 上海 - company_city_code: '310100' - company_district: 浦东新区 - company_district_code: '310115' - company_postalcode: '200000' - company_add: 上海市浦东新区XX路1号 - company_status: 有效 - company_level: A - company_owner_openid: wx-openid-owner-001 - company_remark: 小程序公开创建示例 - responses: - '200': - description: 创建成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseCompanyRecord' - '400': - description: 参数错误或违反当前集合约束 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '403': - description: 集合规则被锁定或服务端权限设置异常 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - get: - operationId: getPocketBaseCompanyRecords - tags: - - 企业信息 - summary: 查询整个 tbl_company 列表 / 根据 company_id 查询对应公司信息 - description: | - 使用 PocketBase 原生 records list 接口查询 `tbl_company`。 - - 当前线上权限规则: - - `listRule = is_delete = 0`,因此默认只返回未软删除数据,且整个列表查询与条件查询都公开可读 - - `createRule = ""`,因此创建也公开可调用 - - `view/update/delete` 仅管理员或管理后台用户允许 - - 标准调用方式有两种: - 1. 根据 `company_id` 查询对应公司信息: - - `filter=company_id="WX-COMPANY-10001"` - - `perPage=1` - - `page=1` - 2. 查询整个 `tbl_company` 列表: - - 不传 `filter` - - 按需传 `page`、`perPage` - - 注意: - - 这是 PocketBase 原生返回结构,不是 hooks 统一 `{ statusCode, errMsg, data }` 包装 - - PocketBase 原生标准接口里,“按 `company_id` 查询单条”和“查询整个列表”共用同一个 `GET /records` 路径,因此文档以同一个 GET operation 展示两种调用模式 - parameters: - - name: filter - in: query - required: false - description: | - PocketBase 标准过滤表达式。 - - - 根据 `company_id` 查询单条时:`company_id="WX-COMPANY-10001"` - - 查询整个列表时:不传该参数 - schema: - type: string - example: company_id="WX-COMPANY-10001" - - name: page - in: query - required: false - description: 页码 - schema: - type: integer - minimum: 1 - default: 1 - - name: perPage - in: query - required: false - description: 每页条数;按 `company_id` 单查时建议固定为 `1` - schema: - type: integer - minimum: 1 - default: 20 - responses: - '200': - description: 查询成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseCompanyListResponse' - examples: - byCompanyId: - value: - page: 页码 | integer - perPage: 每页条数 | integer - totalItems: 总记录数 | integer - totalPages: 总页数 | integer - items: - - id: PocketBase记录主键 | string - collectionId: 集合ID | string - collectionName: 集合名称 | string - created: 记录创建时间 | string - updated: 记录更新时间 | string - company_id: 公司业务id,由数据库自动生成 | string - company_name: 公司名称 | string - company_type: 公司类型 | string - company_entity: 公司法人 | string - company_usci: 统一社会信用代码 | string - company_nationality: 国家名称 | string - company_nationality_code: 国家编码 | string - company_province: 省份名称 | string - company_province_code: 省份编码 | string - company_city: 城市名称 | string - company_city_code: 城市编码 | string - company_district: 区县名称 | string - company_district_code: 区县编码 | string - company_postalcode: 邮政编码 | string - company_add: 公司地址 | string - company_status: 公司状态 | string - company_level: 公司等级 | string - company_owner_openid: 公司所有者openid | string - company_remark: 备注 | string - listAll: - value: - page: 页码 | integer - perPage: 每页条数 | integer - totalItems: 总记录数 | integer - totalPages: 总页数 | integer - items: - - id: PocketBase记录主键 | string - collectionId: 集合ID | string - collectionName: 集合名称 | string - created: 记录创建时间 | string - updated: 记录更新时间 | string - company_id: 公司业务id,由数据库自动生成 | string - company_name: 公司名称 | string - company_type: 公司类型 | string - company_entity: 公司法人 | string - company_usci: 统一社会信用代码 | string - company_nationality: 国家名称 | string - company_nationality_code: 国家编码 | string - company_province: 省份名称 | string - company_province_code: 省份编码 | string - company_city: 城市名称 | string - company_city_code: 城市编码 | string - company_district: 区县名称 | string - company_district_code: 区县编码 | string - company_postalcode: 邮政编码 | string - company_add: 公司地址 | string - company_status: 公司状态 | string - company_level: 公司等级 | string - company_owner_openid: 公司所有者openid | string - company_remark: 备注 | string - notFoundByCompanyId: - value: - page: 页码 | integer - perPage: 每页条数 | integer - totalItems: 总记录数 | integer - totalPages: 总页数 | integer - items: [] - '400': - description: 查询参数错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '403': - description: 集合规则被锁定或服务端权限设置异常 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - -companyRecordById: - patch: - operationId: patchPocketBaseCompanyRecordByRecordId - tags: - - 企业信息 - summary: 通过 company_id 定位后修改公司信息 - description: | - 这是 PocketBase 原生标准更新接口,实际写入路径参数仍然必须使用记录主键 `recordId`。 - - 如果前端手里只有 `company_id`,标准调用流程是: - 1. 先调用 `GET /pb/api/collections/tbl_company/records?filter=company_id="..."&perPage=1&page=1` - 2. 从返回结果 `items[0].id` 中取出 PocketBase 原生记录主键 - 3. 再调用当前 `PATCH /pb/api/collections/tbl_company/records/{recordId}` 完成更新 - - 当前线上权限规则: - - `updateRule` 仅管理员或管理后台用户允许 - - 普通公开调用不能直接更新 - parameters: - - name: recordId - in: path - required: true - description: 通过 `company_id` 查询结果拿到的 PocketBase 记录主键 `id` - schema: - type: string - example: l2r3nq7rqhuob0h - requestBody: - required: true - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseCompanyUpdateRequest' - examples: - default: - value: - company_name: 微信侧测试企业(更新) - company_status: 有效 - company_level: S - company_owner_openid: wx-openid-owner-001 - company_district: 徐汇区 - company_district_code: '310104' - company_remark: 通过 company_id 先定位再修改 - responses: - '200': - description: 更新成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseCompanyRecord' - '400': - description: 参数错误或违反集合约束 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '403': - description: 当前调用方没有 update 权限 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '404': - description: 记录不存在 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' diff --git a/pocket-base/spec/openapi-wx/paths/documents.yaml b/pocket-base/spec/openapi-wx/paths/documents.yaml deleted file mode 100644 index f1b8d5b..0000000 --- a/pocket-base/spec/openapi-wx/paths/documents.yaml +++ /dev/null @@ -1,222 +0,0 @@ -documentRecords: - get: - operationId: getPocketBaseDocumentRecords - tags: - - 文档信息 - summary: 分页查询文档列表 / 按 system_dict_id 与 enum 双条件分页筛选文档 - description: | - 使用 PocketBase 原生 records list 接口查询 `tbl_document`。 - - 当前线上权限规则: - - `listRule = is_delete = 0`,因此任何客户端都可直接分页查询未软删除文档 - - `viewRule = is_delete = 0`,因此单条详情也只可读取未软删除文档 - - `create/update/delete` 仍仅管理员或管理后台用户允许 - - `document_type` 的存储格式为: - - `system_dict_id@dict_word_enum|system_dict_id@dict_word_enum` - - 业务上这里是两个独立条件,并且查询时两个条件都要满足: - - 条件 1:包含某个 `system_dict_id` - - 条件 2:包含某个 `enum` - - PocketBase 原生标准接口实际只有一个 `filter` 参数,因此应在同一个 `filter` 中写成两个 `contains` 条件,例如: - - `system_dict_id = DICT-1774599144591-hAEFQj` - - `enum = UT1` - - 最终:`document_type ~ "DICT-1774599144591-hAEFQj" && document_type ~ "@UT1"` - - 这条写法已经按线上真实数据验证通过。 - - 排序说明: - - 当前线上统一按 `document_create` 排序 - - 若要“最新上传的排在最前面”,请传 `sort=-document_create` - - 标准调用方式有两种: - 1. 查询整个文档列表: - - 不传 `filter` - - 按需传 `page`、`perPage` - - 若要按最新上传倒序,传 `sort=-document_create` - 2. 根据 `system_dict_id` 和 `enum` 两个业务条件分页筛选: - - 直接传 `filter=document_type ~ "" && document_type ~ "@"` - - 传 `page`、`perPage` - - 若要按最新上传倒序,传 `sort=-document_create` - - 注意: - - 这是 PocketBase 原生返回结构,不是 hooks 统一 `{ statusCode, errMsg, data }` 包装 - - 如果需要更复杂的条件组合,可继续使用 PocketBase 原生 `filter` 语法自行扩展 - parameters: - - name: filter - in: query - required: false - description: | - PocketBase 标准过滤表达式。 - - - 查全部列表时:不传 - - 按业务条件筛选时,同时写两个 `contains` 条件 - - 第二个条件建议带上 `@` 前缀,避免误命中 - - 例如:`document_type ~ "DICT-1774599144591-hAEFQj" && document_type ~ "@UT1"` - schema: - type: string - example: document_type ~ "DICT-1774599144591-hAEFQj" && document_type ~ "@UT1" - - name: page - in: query - required: false - description: 页码 - schema: - type: integer - minimum: 1 - default: 1 - - name: perPage - in: query - required: false - description: 每页条数 - schema: - type: integer - minimum: 1 - default: 20 - - name: sort - in: query - required: false - description: | - PocketBase 原生排序表达式。 - - 当前线上建议使用: - - `-document_create`:按最新上传倒序返回 - schema: - type: string - example: -document_create - responses: - '200': - description: 查询成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseDocumentListResponse' - examples: - listAll: - value: - page: 页码 | integer - perPage: 每页条数 | integer - totalItems: 总记录数 | integer - totalPages: 总页数 | integer - items: - - id: PocketBase记录主键 | string - collectionId: 集合ID | string - collectionName: 集合名称 | string - created: 记录创建时间 | string - updated: 记录更新时间 | string - document_id: 文档业务ID | string - document_create: 文档创建时间,由数据库自动生成 | string - document_effect_date: 文档生效日期 | string - document_expiry_date: 文档到期日期 | string - document_title: 文档标题 | string - document_type: 文档类型,按system_dict_id@dict_word_enum保存 | string - document_subtitle: 文档副标题 | string - document_summary: 文档摘要 | string - document_content: 正文内容 | string - document_image: 图片附件ID串,底层按|分隔 | string - document_video: 视频附件ID串,底层按|分隔 | string - document_file: 文件附件ID串,底层按|分隔 | string - document_status: 文档状态 | string - document_owner: 上传者openid | string - document_relation_model: 关联机型标识 | string - document_keywords: 关键词,多选按|分隔 | string - document_share_count: 0 - document_download_count: 0 - document_favorite_count: 0 - document_embedding_status: 文档嵌入状态 | string - document_embedding_error: 文档嵌入错误原因 | string - document_embedding_lasttime: 最后一次嵌入更新时间 | string - document_vector_version: 向量版本号或模型名称 | string - document_product_categories: 产品关联文档,多选按|分隔 | string - document_application_scenarios: 筛选依据,多选按|分隔 | string - document_hotel_type: 适用场景,多选按|分隔 | string - document_remark: 备注 | string - filterByTypeToken: - value: - page: 页码 | integer - perPage: 每页条数 | integer - totalItems: 总记录数 | integer - totalPages: 总页数 | integer - items: - - id: PocketBase记录主键 | string - collectionId: 集合ID | string - collectionName: 集合名称 | string - created: 记录创建时间 | string - updated: 记录更新时间 | string - document_id: 文档业务ID | string - document_create: 文档创建时间,由数据库自动生成 | string - document_effect_date: 文档生效日期 | string - document_expiry_date: 文档到期日期 | string - document_title: 文档标题 | string - document_type: 文档类型,按system_dict_id@dict_word_enum保存 | string - document_subtitle: 文档副标题 | string - document_summary: 文档摘要 | string - document_content: 正文内容 | string - document_image: 图片附件ID串,底层按|分隔 | string - document_video: 视频附件ID串,底层按|分隔 | string - document_file: 文件附件ID串,底层按|分隔 | string - document_status: 文档状态 | string - document_owner: 上传者openid | string - document_relation_model: 关联机型标识 | string - document_keywords: 关键词,多选按|分隔 | string - document_share_count: 0 - document_download_count: 0 - document_favorite_count: 0 - document_embedding_status: 文档嵌入状态 | string - document_embedding_error: 文档嵌入错误原因 | string - document_embedding_lasttime: 最后一次嵌入更新时间 | string - document_vector_version: 向量版本号或模型名称 | string - document_product_categories: 产品关联文档,多选按|分隔 | string - document_application_scenarios: 筛选依据,多选按|分隔 | string - document_hotel_type: 适用场景,多选按|分隔 | string - document_remark: 备注 | string - - id: ofy47wp9mmm0aub - collectionId: pbc_3636602973 - collectionName: tbl_document - created: '2026-03-28 07:20:00.000Z' - updated: '2026-03-28 07:20:00.000Z' - document_id: DOC-1774680568340-TeUSQn - document_create: '2026-03-28 08:22:48.000Z' - document_effect_date: '' - document_expiry_date: '' - document_title: 易从碳达人节能系统,为酒店每天每间房省二元,以智能推动酒店ESG双碳落地!上海酒店用品展我们在E7A01等您!! - document_type: DICT-1774599144591-hAEFQj@UT1 - document_subtitle: '' - document_summary: '' - document_content: '' - document_image: ATT-1774680568287-zuhJWN - document_video: '' - document_file: '' - document_status: 有效 - document_owner: su13106859882 - document_relation_model: '' - document_keywords: '' - document_share_count: 0 - document_download_count: 0 - document_favorite_count: 0 - document_embedding_status: '' - document_embedding_error: '' - document_embedding_lasttime: '' - document_vector_version: '' - document_product_categories: '' - document_application_scenarios: '' - document_hotel_type: '' - document_remark: '' - '400': - description: 查询参数错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '403': - description: 集合规则被锁定或服务端权限设置异常 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' diff --git a/pocket-base/spec/openapi-wx/paths/order-hooks.yaml b/pocket-base/spec/openapi-wx/paths/order-hooks.yaml deleted file mode 100644 index a795de9..0000000 --- a/pocket-base/spec/openapi-wx/paths/order-hooks.yaml +++ /dev/null @@ -1,334 +0,0 @@ -orderList: - post: - operationId: postOrderList - tags: - - 订单 - summary: 按索引字段模糊查询订单列表 - description: | - 调用自定义 hooks API 查询当前登录用户的订单列表。 - - 查询规则: - - 仅允许查询当前 `Authorization` 对应用户自己的订单记录 - - 支持通过 `keyword` 对多个索引相关字段做统一模糊搜索,当前实现覆盖: - - `order_id` - - `order_number` - - `order_source_id` - - 支持按 `order_status` 精确过滤 - - 支持按 `order_source` 精确过滤 - - 目标软删除契约: - - 目标行为应仅返回 `is_delete = 0` 的记录 - - 当前仓库实现尚未显式追加 `is_delete = 0` 过滤,请以实际后端代码为准 - security: - - BearerAuth: [] - requestBody: - required: false - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/OrderListRequest' - responses: - '200': - description: 查询成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/OrderListResponse' - '400': - description: 参数错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '401': - description: token 缺失、无效或已过期 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '415': - description: 请求体必须为 application/json - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - -orderDetail: - post: - operationId: postOrderDetail - tags: - - 订单 - summary: 按 order_id 精确查询订单详情 - description: | - 调用自定义 hooks API 按 `order_id` 查询单条订单记录。 - - 查询规则: - - 仅允许访问当前 `Authorization` 对应用户自己的订单记录 - - 查询键为业务 ID `order_id`,不是 PocketBase 原生 `recordId` - - 目标软删除契约: - - 目标行为应仅允许查询 `is_delete = 0` 的记录 - - 当前仓库实现尚未显式追加 `is_delete = 0` 过滤,请以实际后端代码为准 - security: - - BearerAuth: [] - requestBody: - required: true - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/OrderDetailRequest' - responses: - '200': - description: 查询成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/OrderRecord' - '400': - description: 参数错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '401': - description: token 缺失、无效或已过期 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '403': - description: 无权访问该订单记录 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '404': - description: 未找到对应订单记录 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '415': - description: 请求体必须为 application/json - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - -orderCreate: - post: - operationId: postOrderCreate - tags: - - 订单 - summary: 新增订单记录 - description: | - 调用自定义 hooks API 新增一条订单记录。 - - 创建规则: - - 服务端自动根据当前 token 写入 `order_owner` - - 服务端自动生成 `order_id` - - 若未传 `order_number`,服务端会自动生成展示编号 - - `order_source`、`order_source_id`、`order_snap`、`order_amount` 为必填 - - 目标软删除契约: - - 新建记录应默认为 `is_delete = 0` - - 当前仓库导出响应中尚未显式返回 `is_delete` 字段 - security: - - BearerAuth: [] - requestBody: - required: true - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/OrderCreateRequest' - responses: - '200': - description: 创建成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/OrderRecord' - '400': - description: 参数错误或创建失败 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '401': - description: token 缺失、无效或已过期 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '415': - description: 请求体必须为 application/json - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '429': - description: 重复请求过于频繁 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - -orderUpdate: - post: - operationId: postOrderUpdate - tags: - - 订单 - summary: 修改订单记录 - description: | - 调用自定义 hooks API 按 `order_id` 更新订单记录。 - - 更新规则: - - 仅允许修改当前 `Authorization` 对应用户自己的订单记录 - - `order_id` 为必填,用于精确定位目标记录 - - 其余字段均为可选增量更新 - security: - - BearerAuth: [] - requestBody: - required: true - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/OrderUpdateRequest' - responses: - '200': - description: 更新成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/OrderRecord' - '400': - description: 参数错误或更新失败 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '401': - description: token 缺失、无效或已过期 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '403': - description: 无权访问该订单记录 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '404': - description: 未找到待修改的订单记录 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '415': - description: 请求体必须为 application/json - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '429': - description: 重复请求过于频繁 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - -orderDelete: - post: - operationId: postOrderDelete - tags: - - 订单 - summary: 软删除订单记录 - description: | - 目标契约:按 `order_id` 软删除订单记录,将 `is_delete` 标记为 `1`,而不是物理删除。 - - 当前仓库实现差异: - - 当前 `cartOrderService.deleteOrder()` 仍直接调用 `$app.delete(record)` 做物理删除 - - 因此当前后端实现与本软删除契约不一致 - - 若要严格按本文档执行,需先同步调整后端服务实现,并在列表/详情接口中补充 `is_delete = 0` 过滤 - security: - - BearerAuth: [] - requestBody: - required: true - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/OrderDeleteRequest' - responses: - '200': - description: 删除成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/OrderDeleteResponse' - '400': - description: 参数错误或删除失败 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '401': - description: token 缺失、无效或已过期 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '403': - description: 无权访问该订单记录 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '404': - description: 未找到待删除的订单记录 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '415': - description: 请求体必须为 application/json - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '429': - description: 重复请求过于频繁 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' diff --git a/pocket-base/spec/openapi-wx/paths/order-native.yaml b/pocket-base/spec/openapi-wx/paths/order-native.yaml deleted file mode 100644 index a47fe9c..0000000 --- a/pocket-base/spec/openapi-wx/paths/order-native.yaml +++ /dev/null @@ -1,241 +0,0 @@ -orderRecords: - get: - operationId: getPocketBaseOrderRecords - tags: - - 订单 - summary: 查询当前用户订单列表或按业务 ID 精确查询 - description: | - 使用 PocketBase 原生 records list 接口查询 `tbl_order`。 - - 当前线上权限规则: - - `listRule = @request.auth.id != "" && order_owner = @request.auth.openid && is_delete = 0` - - 因此调用方只能读到 `order_owner` 等于自己 `openid` 且未软删除的记录 - - 标准调用方式: - 1. 查询当前登录用户全部订单: - - 不传 `filter` - - 可选传 `sort=-order_create` - 2. 按业务 ID 精确查单条: - - `filter=order_id="ORDER-..."` - - `perPage=1` - - `page=1` - security: - - BearerAuth: [] - parameters: - - name: filter - in: query - required: false - schema: - type: string - example: order_id="ORDER-1770000000000-abc123" - - name: page - in: query - required: false - schema: - type: integer - minimum: 1 - default: 1 - - name: perPage - in: query - required: false - schema: - type: integer - minimum: 1 - default: 20 - - name: sort - in: query - required: false - description: PocketBase 原生排序表达式,推荐 `-order_create` - schema: - type: string - example: -order_create - responses: - '200': - description: 查询成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseOrderListResponse' - '400': - description: 查询参数错误或不满足 listRule - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '401': - description: token 缺失、无效或已过期 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '403': - description: 集合规则被锁定或服务端权限设置异常 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - post: - operationId: postPocketBaseOrderRecord - tags: - - 订单 - summary: 创建订单记录 - description: | - 使用 PocketBase 原生 records create 接口向 `tbl_order` 新增记录。 - - 当前线上权限规则: - - `createRule = @request.auth.id != "" && @request.body.order_owner = @request.auth.openid` - - 因此客户端创建时必须显式提交 `order_owner`,并且值必须等于当前 token 对应的 `openid` - - 这意味着: - - 不能依赖服务端自动补 owner - - 不能省略 `order_owner` - - 不满足规则时 PocketBase 会直接返回 `400` - security: - - BearerAuth: [] - requestBody: - required: true - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseOrderCreateRequest' - responses: - '200': - description: 创建成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseOrderRecord' - '400': - description: 参数错误、违反字段约束或不满足 createRule - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '401': - description: token 缺失、无效或已过期 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '403': - description: 集合规则被锁定或服务端权限设置异常 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - -orderRecordById: - patch: - operationId: patchPocketBaseOrderRecordByRecordId - tags: - - 订单 - summary: 更新订单记录 - description: | - 使用 PocketBase 原生 records update 接口更新 `tbl_order`。 - - 标准调用流程: - 1. 先通过 `GET /pb/api/collections/tbl_order/records?filter=order_id="..."&perPage=1&page=1` 找到原生 `recordId` - 2. 再调用当前 `PATCH /pb/api/collections/tbl_order/records/{recordId}` - - 当前线上权限规则: - - `updateRule = @request.auth.id != "" && order_owner = @request.auth.openid` - - 调用方只能修改自己的订单记录 - security: - - BearerAuth: [] - parameters: - - name: recordId - in: path - required: true - schema: - type: string - example: l2r3nq7rqhuob0h - requestBody: - required: true - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseOrderUpdateRequest' - responses: - '200': - description: 更新成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseOrderRecord' - '400': - description: 参数错误或违反字段约束 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '401': - description: token 缺失、无效或已过期 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '404': - description: 记录不存在或不满足 updateRule - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - delete: - operationId: deletePocketBaseOrderRecordByRecordId - tags: - - 订单 - summary: 删除订单记录 - description: | - 使用 PocketBase 原生 records delete 接口删除 `tbl_order`。 - - 当前线上权限规则: - - `deleteRule = @request.auth.id != "" && order_owner = @request.auth.openid` - - 调用方只能删除自己的订单记录 - security: - - BearerAuth: [] - parameters: - - name: recordId - in: path - required: true - schema: - type: string - example: l2r3nq7rqhuob0h - responses: - '204': - description: 删除成功 - '401': - description: token 缺失、无效或已过期 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '404': - description: 记录不存在或不满足 deleteRule - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' diff --git a/pocket-base/spec/openapi-wx/paths/products.yaml b/pocket-base/spec/openapi-wx/paths/products.yaml deleted file mode 100644 index d6ea2cf..0000000 --- a/pocket-base/spec/openapi-wx/paths/products.yaml +++ /dev/null @@ -1,119 +0,0 @@ -productRecords: - get: - operationId: getPocketBaseProductListRecords - tags: - - 产品信息 - summary: 根据产品分类精确筛选并按分类排序值升序返回产品列表 - description: | - 使用 PocketBase 原生 records list 接口查询 `tbl_product_list`。 - - 当前接口约定: - - 默认仅返回 `is_delete = 0` 的未软删除产品 - - 条件:按 `prod_list_category` 精确匹配筛选 - - 排序:按 `prod_list_sort` 从小到大排序 - - 标准调用参数建议: - - `filter=prod_list_category="<产品分类>"` - - `sort=prod_list_sort` - - 注意: - - 这是 PocketBase 原生返回结构,不是 hooks 统一 `{ statusCode, errMsg, data }` 包装 - - 若不传 `sort`,将由 PocketBase 默认排序策略决定返回顺序 - parameters: - - name: filter - in: query - required: true - description: | - PocketBase 标准过滤表达式,当前要求按产品分类精确值筛选。 - - 推荐写法:`prod_list_category="<产品分类>"` - schema: - type: string - example: prod_list_category="<产品分类>" - - name: page - in: query - required: false - description: 页码 - schema: - type: integer - minimum: 1 - default: 1 - - name: perPage - in: query - required: false - description: 每页条数 - schema: - type: integer - minimum: 1 - default: 20 - - name: sort - in: query - required: false - description: | - PocketBase 原生排序表达式。 - - 当前要求使用: - - `prod_list_sort`:按分类排序值从小到大 - schema: - type: string - example: prod_list_sort - responses: - '200': - description: 查询成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseProductListListResponse' - examples: - byCategoryAscSort: - value: - page: <页码>| - perPage: <每页条数>| - totalItems: <总记录数>| - totalPages: <总页数>| - items: - - id: | - collectionId: <集合ID>| - collectionName: <集合名称>| - created: <记录创建时间>| - updated: <记录更新时间>| - prod_list_id: <产品列表业务ID>| - prod_list_name: <产品名称>| - prod_list_modelnumber: <产品型号>| - prod_list_icon: <产品图标附件ID>| - prod_list_description: <产品说明>| - prod_list_feature: <产品特色>| - prod_list_parameters: - - name: <属性名>| - value: <属性值>| - prod_list_plantype: <产品方案>| - prod_list_category: <产品分类>| - prod_list_sort: 10 - prod_list_comm_type: <通讯类型>| - prod_list_series: <产品系列>| - prod_list_power_supply: <供电方式>| - prod_list_tags: <产品标签>| - prod_list_status: <产品状态>| - prod_list_basic_price: 1999 - prod_list_vip_price: - - viplevel: VIP1 - price: 1899 - prod_list_remark: <备注>| - '400': - description: 查询参数错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '403': - description: 集合规则被锁定或服务端权限设置异常 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseNativeError' diff --git a/pocket-base/spec/openapi-wx/paths/system.yaml b/pocket-base/spec/openapi-wx/paths/system.yaml deleted file mode 100644 index e47b02a..0000000 --- a/pocket-base/spec/openapi-wx/paths/system.yaml +++ /dev/null @@ -1,89 +0,0 @@ -usersCount: - post: - security: [] - operationId: postSystemUsersCount - tags: - - 系统 - summary: 查询用户总数 - description: 统计 `tbl_auth_users` 集合中的记录总数。 - responses: - '200': - description: 查询成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/UsersCountResponse' - '400': - description: 请求参数错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - -refreshToken: - post: - security: - - BearerAuth: [] - - {} - operationId: postSystemRefreshToken - tags: - - 系统 - summary: 刷新认证 token - description: | - 当当前 `Authorization` 仍有效时,直接基于当前 auth 用户续签。 - 当 token 失效时,可传入 `users_wx_code` 走微信 code 重新签发。 - requestBody: - required: false - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/SystemRefreshTokenRequest' - responses: - '200': - description: 刷新成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/RefreshTokenResponse' - '400': - description: 参数错误或微信 code 换取失败 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '401': - description: token 无效,且未提供有效的 `users_wx_code` - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '404': - description: 当前用户不存在 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '415': - description: 请求体不是 JSON - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '429': - description: 请求过于频繁 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' diff --git a/pocket-base/spec/openapi-wx/paths/wechat-auth.yaml b/pocket-base/spec/openapi-wx/paths/wechat-auth.yaml deleted file mode 100644 index b8c0020..0000000 --- a/pocket-base/spec/openapi-wx/paths/wechat-auth.yaml +++ /dev/null @@ -1,117 +0,0 @@ -wechatLogin: - post: - security: [] - operationId: postWechatLogin - tags: - - 微信认证 - summary: 微信登录或首次注册 - description: | - 使用微信 `users_wx_code` 换取微信 openid。 - 若 `tbl_auth_users` 中不存在对应用户,则自动创建新 auth 用户并返回 token。 - 首次注册时,`users_level` 默认保持为空,不自动写入会员等级。 - requestBody: - required: true - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/WechatLoginRequest' - responses: - '200': - description: 登录或注册成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/AuthSuccessResponse' - '400': - description: 参数错误或保存用户失败 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '401': - description: 认证失败 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '415': - description: 请求体不是 JSON - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '429': - description: 请求过于频繁 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - -wechatProfile: - post: - security: - - BearerAuth: [] - operationId: postWechatProfile - tags: - - 微信认证 - summary: 更新微信用户资料 - description: | - 基于当前 `Authorization` 对应的 auth 用户按“非空字段增量更新”资料。 - - 更新规则: - - 所有字段都不是必填 - - 如果传了 `users_phone_code`,服务端优先调用微信接口换取真实手机号并写入 `users_phone` - - 如果没传 `users_phone_code`,但传了 `users_phone`,则直接将该手机号写入数据库 - - 如果上传了 `users_picture`、`users_id_pic_a`、`users_id_pic_b`、`users_title_picture`,会按附件 ID 进行关联校验并更新 - - 若当前用户类型为 `游客`,且本次未显式传 `users_type`,服务端会自动升级为 `注册用户` - - 如果某个字段未传或传空,则不会清空数据库中的已有值 - - 只有请求体里非空的字段才会更新到数据库 - requestBody: - required: true - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/WechatProfileRequest' - responses: - '200': - description: 更新成功 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/WechatProfileResponse' - '400': - description: 参数错误、手机号已被占用、附件 ID 无效、微信手机号换取失败或资料更新失败 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '401': - description: token 无效或缺少 openid - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '415': - description: 请求体不是 JSON - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '429': - description: 请求过于频繁 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' - '500': - description: 服务端错误 - content: - application/json: - schema: - $ref: '../../openapi-wx.yaml#/components/schemas/ErrorResponse' diff --git a/pocket-base/spec/openapi-wx/products.yaml b/pocket-base/spec/openapi-wx/products.yaml new file mode 100644 index 0000000..bb43a17 --- /dev/null +++ b/pocket-base/spec/openapi-wx/products.yaml @@ -0,0 +1,413 @@ +paths: + productRecords: + get: + operationId: getPocketBaseProductListRecords + tags: + - 产品信息 + summary: 根据产品分类精确筛选并按分类排序值升序返回产品列表 + description: | + 使用 PocketBase 原生 records list 接口查询 `tbl_product_list`。 + + 当前接口约定: + - 默认仅返回 `is_delete = 0` 的未软删除产品 + - 条件:按 `prod_list_category` 精确匹配筛选 + - 排序:按 `prod_list_sort` 从小到大排序 + + 标准调用参数建议: + - `filter=prod_list_category="<产品分类>"` + - `sort=prod_list_sort` + + 注意: + - 这是 PocketBase 原生返回结构,不是 hooks 统一 `{ statusCode, errMsg, data }` 包装 + - 若不传 `sort`,将由 PocketBase 默认排序策略决定返回顺序 + parameters: + - name: filter + in: query + required: true + description: | + PocketBase 标准过滤表达式,当前要求按产品分类精确值筛选。 + + 推荐写法:`prod_list_category="<产品分类>"` + schema: + type: string + example: prod_list_category="<产品分类>" + - name: page + in: query + required: false + description: 页码 + schema: + type: integer + minimum: 1 + default: 1 + - name: perPage + in: query + required: false + description: 每页条数 + schema: + type: integer + minimum: 1 + default: 20 + - name: sort + in: query + required: false + description: | + PocketBase 原生排序表达式。 + + 当前要求使用: + - `prod_list_sort`:按分类排序值从小到大 + schema: + type: string + example: prod_list_sort + responses: + "200": + description: 查询成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseProductListListResponse + example: + page: page|integer + perPage: perPage|integer + totalItems: totalItems|integer + totalPages: totalPages|integer + items: + - id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + prod_list_id: 产品列表业务 ID,唯一标识|string + prod_list_name: 产品名称|string + prod_list_modelnumber: 产品型号|string + prod_list_icon: 产品图标附件 ID,保存 tbl_attachments.attachments_id|string + prod_list_description: 产品说明|string + prod_list_feature: 产品特色|string + prod_list_parameters: + - name: name|string + value: value|string + prod_list_plantype: 产品方案|string + prod_list_category: 产品分类(必填,单选)|string + prod_list_sort: 排序值(同分类内按升序)|number + prod_list_comm_type: 通讯类型|string + prod_list_series: 产品系列|string + prod_list_power_supply: 供电方式|string + prod_list_tags: 产品标签(辅助检索,以 | 聚合)|string + prod_list_status: 产品状态(有效 / 过期 / 主推等)|string + prod_list_basic_price: 基础价格|number + prod_list_vip_price: + - viplevel: viplevel|string + price: price|number + prod_list_remark: 备注|string + "400": + description: 查询参数错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "403": + description: 集合规则被锁定或服务端权限设置异常 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseNativeError + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string +components: + schemas: + PocketBaseNativeError: + type: object + properties: + code: + type: + - integer + - string + description: 业务状态码 + example: 错误状态码 | integer + message: + type: string + example: PocketBase原生错误信息 | string + data: + description: 业务响应数据 + type: object + additionalProperties: true + example: + code: 业务状态码|integer + message: message|string + data: + 业务响应数据字段|string: 业务响应数据值|string + PocketBaseRecordBase: + type: object + required: + - id + - collectionId + - collectionName + - created + - updated + properties: + id: + type: string + description: PocketBase 记录主键 + example: PocketBase记录主键 | string + collectionId: + type: string + example: 集合ID | string + collectionName: + type: string + example: 集合名称 | string + created: + type: string + description: 记录创建时间 + example: 记录创建时间 | string + updated: + type: string + description: 记录更新时间 + example: 记录更新时间 | string + example: + id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + PocketBaseProductListFields: + type: object + properties: + prod_list_id: + type: string + description: 产品列表业务 ID,唯一标识 + example: <产品列表业务ID>| + prod_list_name: + type: string + description: 产品名称 + example: <产品名称>| + prod_list_modelnumber: + type: string + description: 产品型号 + example: <产品型号>| + prod_list_icon: + type: string + description: 产品图标附件 ID,保存 `tbl_attachments.attachments_id` + example: <产品图标附件ID>| + prod_list_description: + type: string + description: 产品说明 + example: <产品说明>| + prod_list_feature: + type: string + description: 产品特色 + example: <产品特色>| + prod_list_parameters: + type: array + description: 产品参数数组,每项包含 name/value + items: + type: object + properties: + name: + type: string + example: <属性名>| + value: + type: string + example: <属性值>| + example: + - name: <属性名>| + value: <属性值>| + prod_list_plantype: + type: string + description: 产品方案 + example: <产品方案>| + prod_list_category: + type: string + description: 产品分类(必填,单选) + example: <产品分类>| + prod_list_sort: + type: + - number + - integer + description: 排序值(同分类内按升序) + example: 10 + prod_list_comm_type: + type: string + description: 通讯类型 + example: <通讯类型>| + prod_list_series: + type: string + description: 产品系列 + example: <产品系列>| + prod_list_power_supply: + type: string + description: 供电方式 + example: <供电方式>| + prod_list_tags: + type: string + description: 产品标签(辅助检索,以 `|` 聚合) + example: <产品标签>| + prod_list_status: + type: string + description: 产品状态(有效 / 过期 / 主推等) + example: <产品状态>| + prod_list_basic_price: + type: + - number + - integer + description: 基础价格 + example: 1999 + prod_list_vip_price: + type: array + description: 会员价数组,每项包含会员等级枚举值与价格 + items: + type: object + properties: + viplevel: + type: string + example: <会员等级枚举值>| + price: + type: + - number + - integer + example: 1899 + example: + - viplevel: VIP1 + price: 1899 + prod_list_remark: + type: string + description: 备注 + example: <备注>| + example: + prod_list_id: 产品列表业务 ID,唯一标识|string + prod_list_name: 产品名称|string + prod_list_modelnumber: 产品型号|string + prod_list_icon: 产品图标附件 ID,保存 tbl_attachments.attachments_id|string + prod_list_description: 产品说明|string + prod_list_feature: 产品特色|string + prod_list_parameters: + - name: name|string + value: value|string + prod_list_plantype: 产品方案|string + prod_list_category: 产品分类(必填,单选)|string + prod_list_sort: 排序值(同分类内按升序)|number + prod_list_comm_type: 通讯类型|string + prod_list_series: 产品系列|string + prod_list_power_supply: 供电方式|string + prod_list_tags: 产品标签(辅助检索,以 | 聚合)|string + prod_list_status: 产品状态(有效 / 过期 / 主推等)|string + prod_list_basic_price: 基础价格|number + prod_list_vip_price: + - viplevel: viplevel|string + price: price|number + prod_list_remark: 备注|string + PocketBaseProductListRecord: + allOf: + - $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseRecordBase + - $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseProductListFields + example: + id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + prod_list_id: 产品列表业务 ID,唯一标识|string + prod_list_name: 产品名称|string + prod_list_modelnumber: 产品型号|string + prod_list_icon: 产品图标附件 ID,保存 tbl_attachments.attachments_id|string + prod_list_description: 产品说明|string + prod_list_feature: 产品特色|string + prod_list_parameters: + - name: name|string + value: value|string + prod_list_plantype: 产品方案|string + prod_list_category: 产品分类(必填,单选)|string + prod_list_sort: 排序值(同分类内按升序)|number + prod_list_comm_type: 通讯类型|string + prod_list_series: 产品系列|string + prod_list_power_supply: 供电方式|string + prod_list_tags: 产品标签(辅助检索,以 | 聚合)|string + prod_list_status: 产品状态(有效 / 过期 / 主推等)|string + prod_list_basic_price: 基础价格|number + prod_list_vip_price: + - viplevel: viplevel|string + price: price|number + prod_list_remark: 备注|string + PocketBaseProductListListResponse: + type: object + required: + - page + - perPage + - totalItems + - totalPages + - items + properties: + page: + type: + - integer + - string + example: <页码>| + perPage: + type: + - integer + - string + example: <每页条数>| + totalItems: + type: + - integer + - string + example: <总记录数>| + totalPages: + type: + - integer + - string + example: <总页数>| + items: + type: array + items: + $ref: ../openapi-wx.yaml#/components/schemas/PocketBaseProductListRecord + example: + page: page|integer + perPage: perPage|integer + totalItems: totalItems|integer + totalPages: totalPages|integer + items: + - id: PocketBase 记录主键|string + collectionId: collectionId|string + collectionName: collectionName|string + created: 记录创建时间|string + updated: 记录更新时间|string + prod_list_id: 产品列表业务 ID,唯一标识|string + prod_list_name: 产品名称|string + prod_list_modelnumber: 产品型号|string + prod_list_icon: 产品图标附件 ID,保存 tbl_attachments.attachments_id|string + prod_list_description: 产品说明|string + prod_list_feature: 产品特色|string + prod_list_parameters: + - name: name|string + value: value|string + prod_list_plantype: 产品方案|string + prod_list_category: 产品分类(必填,单选)|string + prod_list_sort: 排序值(同分类内按升序)|number + prod_list_comm_type: 通讯类型|string + prod_list_series: 产品系列|string + prod_list_power_supply: 供电方式|string + prod_list_tags: 产品标签(辅助检索,以 | 聚合)|string + prod_list_status: 产品状态(有效 / 过期 / 主推等)|string + prod_list_basic_price: 基础价格|number + prod_list_vip_price: + - viplevel: viplevel|string + price: price|number + prod_list_remark: 备注|string diff --git a/pocket-base/spec/openapi-wx/schemas/attachments.yaml b/pocket-base/spec/openapi-wx/schemas/attachments.yaml deleted file mode 100644 index aee528f..0000000 --- a/pocket-base/spec/openapi-wx/schemas/attachments.yaml +++ /dev/null @@ -1,125 +0,0 @@ -PocketBaseAttachmentRecord: - type: object - properties: - id: - type: string - description: PocketBase 记录主键 - example: PocketBase记录主键 | string - collectionId: - type: string - description: 集合ID - example: 集合ID | string - collectionName: - type: string - description: 集合名称 - example: 集合名称 | string - attachments_id: - type: string - description: 附件业务 ID - example: 附件业务ID | string - attachments_link: - type: string - description: PocketBase 文件字段值,可按标准文件路径拼接文件流地址 - example: PocketBase文件字段值,可拼接文件流地址 | string - attachments_filename: - type: string - description: 原始文件名 - example: 原始文件名 | string - attachments_filetype: - type: string - description: 文件类型 / MIME - example: 文件类型或MIME | string - attachments_size: - type: - - number - - integer - - string - description: 文件大小 - example: 文件大小 | number - attachments_owner: - type: string - description: 上传者业务标识 - example: 上传者业务标识 | string - attachments_md5: - type: string - description: 文件 MD5 - example: 文件MD5 | string - attachments_ocr: - type: string - description: OCR 识别结果 - example: OCR识别结果 | string - attachments_status: - type: string - description: 附件状态 - example: 附件状态 | string - attachments_remark: - type: string - description: 备注 - example: 备注 | string - example: - id: PocketBase记录主键 | string - collectionId: 集合ID | string - collectionName: 集合名称 | string - attachments_id: 附件业务ID | string - attachments_link: PocketBase文件字段值,可拼接文件流地址 | string - attachments_filename: 原始文件名 | string - attachments_filetype: 文件类型或MIME | string - attachments_size: 文件大小 | number - attachments_owner: 上传者业务标识 | string - attachments_md5: 文件MD5 | string - attachments_ocr: OCR识别结果 | string - attachments_status: 附件状态 | string - attachments_remark: 备注 | string - -PocketBaseAttachmentListResponse: - type: object - required: - - page - - perPage - - totalItems - - totalPages - - items - properties: - page: - type: - - integer - - string - example: 页码 | integer - perPage: - type: - - integer - - string - example: 每页条数 | integer - totalItems: - type: - - integer - - string - example: 总记录数 | integer - totalPages: - type: - - integer - - string - example: 总页数 | integer - items: - type: array - items: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseAttachmentRecord' - example: - page: 页码 | integer - perPage: 每页条数 | integer - totalItems: 总记录数 | integer - totalPages: 总页数 | integer - items: - - id: PocketBase记录主键 | string - collectionId: 集合ID | string - collectionName: 集合名称 | string - attachments_id: 附件业务ID | string - attachments_link: PocketBase文件字段值,可拼接文件流地址 | string - attachments_filename: 原始文件名 | string - attachments_filetype: 文件类型或MIME | string - attachments_size: 文件大小 | number - attachments_owner: 上传者业务标识 | string - attachments_md5: 文件MD5 | string - attachments_ocr: OCR识别结果 | string - attachments_status: 附件状态 | string - attachments_remark: 备注 | string diff --git a/pocket-base/spec/openapi-wx/schemas/cart-hooks.yaml b/pocket-base/spec/openapi-wx/schemas/cart-hooks.yaml deleted file mode 100644 index 894f79a..0000000 --- a/pocket-base/spec/openapi-wx/schemas/cart-hooks.yaml +++ /dev/null @@ -1,185 +0,0 @@ -CartRecord: - allOf: - - $ref: '../../openapi-wx.yaml#/components/schemas/HookRecordBase' - - type: object - properties: - cart_id: - type: string - description: 购物车业务 ID - example: CART-1770000000000-abc123 - cart_number: - type: string - description: 购物车名称或分组号 - example: wx-user-20260403153000 - cart_create: - type: string - description: 购物车项创建时间,由数据库自动生成 - example: 2026-04-03 15:30:00.000Z - cart_owner: - type: string - description: 购物车所有者 openid - example: wx-openid-user-001 - cart_product_id: - type: string - description: 产品业务 ID - example: PROD-1770000000000-abcd12 - cart_product_quantity: - type: - - integer - - number - description: 产品数量 - example: 2 - cart_status: - type: string - description: 购物车状态 - example: 有效 - cart_at_price: - type: - - integer - - number - description: 加入购物车时价格 - example: 1999 - cart_remark: - type: string - description: 备注 - example: 小程序加入购物车示例 - is_delete: - type: - - integer - - number - description: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出 - example: 0 - product_name: - type: string - description: 产品名称(服务端联动补充) - example: BAI 智能主机 - product_modelnumber: - type: string - description: 产品型号(服务端联动补充) - example: BAI-HOST-01 - product_basic_price: - type: - - integer - - number - - 'null' - description: 产品基础价格(服务端联动补充) - example: 1999 - -CartListRequest: - type: object - properties: - keyword: - type: string - description: 对 `cart_id`、`cart_number`、`cart_product_id` 等索引相关字段的统一模糊搜索关键字 - example: CART-1770 - cart_status: - type: string - description: 购物车状态精确过滤 - example: 有效 - cart_number: - type: string - description: 购物车名称或分组号精确过滤 - example: wx-user-20260403153000 - -CartDetailRequest: - type: object - required: - - cart_id - properties: - cart_id: - type: string - description: 购物车业务 ID - example: CART-1770000000000-abc123 - -CartCreateRequest: - type: object - required: - - cart_product_id - - cart_product_quantity - - cart_at_price - properties: - cart_number: - type: string - description: 可选;未传时服务端自动生成 - cart_product_id: - type: string - description: 产品业务 ID - example: PROD-1770000000000-abcd12 - cart_product_quantity: - type: - - integer - - number - description: 产品数量,需为正整数 - example: 2 - cart_status: - type: string - description: 可选;未传时默认 `有效` - example: 有效 - cart_at_price: - type: - - integer - - number - description: 加入购物车时价格 - example: 1999 - cart_remark: - type: string - description: 备注 - example: 小程序加入购物车示例 - -CartUpdateRequest: - type: object - required: - - cart_id - properties: - cart_id: - type: string - description: 购物车业务 ID - example: CART-1770000000000-abc123 - cart_number: - type: string - cart_product_id: - type: string - cart_product_quantity: - type: - - integer - - number - cart_status: - type: string - cart_at_price: - type: - - integer - - number - cart_remark: - type: string - -CartDeleteRequest: - type: object - required: - - cart_id - properties: - cart_id: - type: string - description: 购物车业务 ID - example: CART-1770000000000-abc123 - -CartListResponse: - type: object - properties: - items: - type: array - items: - $ref: '../../openapi-wx.yaml#/components/schemas/CartRecord' - -CartDeleteResponse: - type: object - properties: - cart_id: - type: string - description: 购物车业务 ID - example: CART-1770000000000-abc123 - is_delete: - type: - - integer - - number - description: 目标软删除标记值;当前实现可能仍返回物理删除结果 - example: 1 diff --git a/pocket-base/spec/openapi-wx/schemas/cart-native.yaml b/pocket-base/spec/openapi-wx/schemas/cart-native.yaml deleted file mode 100644 index 8e4ea47..0000000 --- a/pocket-base/spec/openapi-wx/schemas/cart-native.yaml +++ /dev/null @@ -1,134 +0,0 @@ -PocketBaseCartFields: - type: object - properties: - cart_id: - type: string - description: 购物车业务 ID - example: CART-1770000000000-abc123 - cart_number: - type: string - description: 购物车名称或分组号 - example: wx-user-20260403153000 - cart_create: - type: string - description: 购物车项创建时间,由数据库自动生成 - example: 2026-04-03 15:30:00.000Z - cart_owner: - type: string - description: 购物车所有者 openid - example: wx-openid-user-001 - cart_product_id: - type: string - description: 产品业务 ID - example: PROD-1770000000000-abcd12 - cart_product_quantity: - type: - - integer - - number - description: 产品数量 - example: 2 - cart_status: - type: string - description: 购物车状态 - example: 有效 - cart_at_price: - type: - - number - - integer - description: 加入购物车时价格 - example: 1999 - cart_remark: - type: string - description: 备注 - example: 小程序加入购物车示例 - -PocketBaseCartRecord: - allOf: - - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseRecordBase' - - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseCartFields' - -PocketBaseCartCreateRequest: - type: object - required: - - cart_id - - cart_number - - cart_owner - - cart_product_id - - cart_product_quantity - - cart_status - - cart_at_price - properties: - cart_id: - type: string - cart_number: - type: string - cart_owner: - type: string - description: 必须显式提交,且值必须等于当前 token 对应 openid - cart_product_id: - type: string - cart_product_quantity: - type: - - integer - - number - cart_status: - type: string - cart_at_price: - type: - - number - - integer - cart_remark: - type: string - -PocketBaseCartUpdateRequest: - type: object - properties: - cart_number: - type: string - cart_owner: - type: string - description: 若提交,必须仍等于当前 token 对应 openid - cart_product_id: - type: string - cart_product_quantity: - type: - - integer - - number - cart_status: - type: string - cart_at_price: - type: - - number - - integer - cart_remark: - type: string - -PocketBaseCartListResponse: - type: object - required: - - page - - perPage - - totalItems - - totalPages - - items - properties: - page: - type: - - integer - - string - perPage: - type: - - integer - - string - totalItems: - type: - - integer - - string - totalPages: - type: - - integer - - string - items: - type: array - items: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseCartRecord' diff --git a/pocket-base/spec/openapi-wx/schemas/common.yaml b/pocket-base/spec/openapi-wx/schemas/common.yaml deleted file mode 100644 index de62eb5..0000000 --- a/pocket-base/spec/openapi-wx/schemas/common.yaml +++ /dev/null @@ -1,125 +0,0 @@ -ApiResponseBase: - type: object - required: - - statusCode - - errMsg - - data - properties: - statusCode: - type: - - integer - - string - description: "业务状态码" - example: 业务状态码 | integer - errMsg: - type: string - description: "业务提示信息" - example: 业务提示信息 | string - data: - description: "业务响应数据" - type: object - additionalProperties: true - example: - statusCode: 业务状态码 | integer - errMsg: 业务提示信息 | string - data: - 任意业务字段: 业务响应数据 | object - -ErrorResponse: - type: object - required: - - statusCode - - errMsg - - data - properties: - statusCode: - type: - - integer - - string - description: "业务状态码" - example: 业务状态码 | integer - errMsg: - type: string - description: "业务提示信息" - example: 失败原因提示 | string - data: - description: "业务响应数据" - type: object - additionalProperties: true - example: - statusCode: 业务状态码 | integer - errMsg: 失败原因提示 | string - data: - 任意错误字段: 错误附加信息 | object - -HookRecordBase: - type: object - properties: - pb_id: - type: string - description: PocketBase 记录主键 id - example: l2r3nq7rqhuob0h - created: - type: string - description: PocketBase 系统创建时间 - example: 2026-04-03 15:30:00.000Z - updated: - type: string - description: PocketBase 系统更新时间 - example: 2026-04-03 15:35:00.000Z - -PocketBaseNativeError: - type: object - properties: - code: - type: - - integer - - string - description: "业务状态码" - example: 错误状态码 | integer - message: - type: string - example: PocketBase原生错误信息 | string - data: - description: "业务响应数据" - type: object - additionalProperties: true - example: - code: 错误状态码 | integer - message: PocketBase原生错误信息 | string - data: - 任意错误字段: 原生错误附加信息 | object - -PocketBaseRecordBase: - type: object - required: - - id - - collectionId - - collectionName - - created - - updated - properties: - id: - type: string - description: "PocketBase 记录主键" - example: PocketBase记录主键 | string - collectionId: - type: string - example: 集合ID | string - collectionName: - type: string - example: 集合名称 | string - created: - type: string - description: "记录创建时间" - example: 记录创建时间 | string - updated: - type: string - description: "记录更新时间" - example: 记录更新时间 | string - example: - id: PocketBase记录主键 | string - collectionId: 集合ID | string - collectionName: 集合名称 | string - created: 记录创建时间 | string - updated: 记录更新时间 | string diff --git a/pocket-base/spec/openapi-wx/schemas/company.yaml b/pocket-base/spec/openapi-wx/schemas/company.yaml deleted file mode 100644 index a1c6610..0000000 --- a/pocket-base/spec/openapi-wx/schemas/company.yaml +++ /dev/null @@ -1,412 +0,0 @@ -CompanyInfo: - anyOf: - - type: object - description: 用户所属公司信息;当用户尚未绑定公司时返回 `null` - properties: - pb_id: - type: string - description: PocketBase 记录主键 id - example: PocketBase记录主键id | string - company_id: - type: string - description: 公司业务 id,由数据库自动生成 - example: 公司业务id,由数据库自动生成 | string - company_name: - type: string - description: 公司名称 - example: 公司名称 | string - company_type: - type: string - description: 公司类型 - example: 公司类型 | string - company_entity: - type: string - description: 公司法人 - example: 公司法人 | string - company_usci: - type: string - description: 统一社会信用代码 - example: 统一社会信用代码 | string - company_nationality: - type: string - description: 国家名称 - example: 国家名称 | string - company_nationality_code: - type: string - description: 国家编码 - example: 国家编码 | string - company_province: - type: string - description: 省份名称 - example: 省份名称 | string - company_province_code: - type: string - description: 省份编码 - example: 省份编码 | string - company_city: - type: string - description: 城市名称 - example: 城市名称 | string - company_city_code: - type: string - description: 城市编码 - example: 城市编码 | string - company_district: - type: string - description: 区/县名称 - example: 区县名称 | string - company_district_code: - type: string - description: 区/县编码 - example: 区县编码 | string - company_postalcode: - type: string - description: 邮政编码 - example: 邮政编码 | string - company_add: - type: string - description: 公司地址 - example: 公司地址 | string - company_status: - type: string - description: 公司状态 - example: 公司状态 | string - company_level: - type: string - description: 公司等级 - example: 公司等级 | string - company_owner_openid: - type: string - description: 公司所有者 openid - example: 公司所有者openid | string - company_remark: - type: string - description: 备注 - example: 备注 | string - created: - type: string - description: 记录创建时间 - example: 记录创建时间 | string - updated: - type: string - description: 记录更新时间 - example: 记录更新时间 | string - example: - pb_id: PocketBase记录主键id | string - company_id: 公司业务id,由数据库自动生成 | string - company_name: 公司名称 | string - company_type: 公司类型 | string - company_entity: 公司法人 | string - company_usci: 统一社会信用代码 | string - company_nationality: 国家名称 | string - company_nationality_code: 国家编码 | string - company_province: 省份名称 | string - company_province_code: 省份编码 | string - company_city: 城市名称 | string - company_city_code: 城市编码 | string - company_district: 区县名称 | string - company_district_code: 区县编码 | string - company_postalcode: 邮政编码 | string - company_add: 公司地址 | string - company_status: 公司状态 | string - company_level: 公司等级 | string - company_owner_openid: 公司所有者openid | string - company_remark: 备注 | string - created: 记录创建时间 | string - updated: 记录更新时间 | string - - type: 'null' - -PocketBaseCompanyFields: - type: object - properties: - company_id: - type: string - description: 公司业务 id,由数据库自动生成 - example: 公司业务id,由数据库自动生成 | string - company_name: - type: string - description: 公司名称 - example: 公司名称 | string - company_type: - type: string - description: 公司类型 - example: 公司类型 | string - company_entity: - type: string - description: 公司法人 - example: 公司法人 | string - company_usci: - type: string - description: 统一社会信用代码 - example: 统一社会信用代码 | string - company_nationality: - type: string - description: 国家名称 - example: 国家名称 | string - company_nationality_code: - type: string - description: 国家编码 - example: 国家编码 | string - company_province: - type: string - description: 省份名称 - example: 省份名称 | string - company_province_code: - type: string - description: 省份编码 - example: 省份编码 | string - company_city: - type: string - description: 城市名称 - example: 城市名称 | string - company_city_code: - type: string - description: 城市编码 - example: 城市编码 | string - company_district: - type: string - description: 区/县名称 - example: 区县名称 | string - company_district_code: - type: string - description: 区/县编码 - example: 区县编码 | string - company_postalcode: - type: string - description: 邮政编码 - example: 邮政编码 | string - company_add: - type: string - description: 公司地址 - example: 公司地址 | string - company_status: - type: string - description: 公司状态 - example: 公司状态 | string - company_level: - type: string - description: 公司等级 - example: 公司等级 | string - company_owner_openid: - type: string - description: 公司所有者 openid - example: 公司所有者openid | string - company_remark: - type: string - description: 备注 - example: 备注 | string - -PocketBaseCompanyRecord: - allOf: - - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseRecordBase' - - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseCompanyFields' - example: - id: PocketBase记录主键 | string - collectionId: 集合ID | string - collectionName: 集合名称 | string - created: 记录创建时间 | string - updated: 记录更新时间 | string - company_id: 公司业务id,由数据库自动生成 | string - company_name: 公司名称 | string - company_type: 公司类型 | string - company_entity: 公司法人 | string - company_usci: 统一社会信用代码 | string - company_nationality: 国家名称 | string - company_nationality_code: 国家编码 | string - company_province: 省份名称 | string - company_province_code: 省份编码 | string - company_city: 城市名称 | string - company_city_code: 城市编码 | string - company_district: 区县名称 | string - company_district_code: 区县编码 | string - company_postalcode: 邮政编码 | string - company_add: 公司地址 | string - company_status: 公司状态 | string - company_level: 公司等级 | string - company_owner_openid: 公司所有者openid | string - company_remark: 备注 | string - -PocketBaseCompanyCreateRequest: - type: object - properties: - company_name: - description: "公司名称" - type: string - company_type: - description: "公司类型" - type: string - company_entity: - description: "公司法人" - type: string - company_usci: - description: "统一社会信用代码" - type: string - company_nationality: - description: "国家名称" - type: string - company_nationality_code: - description: "国家编码" - type: string - company_province: - description: "省份名称" - type: string - company_province_code: - description: "省份编码" - type: string - company_city: - description: "城市名称" - type: string - company_city_code: - description: "城市编码" - type: string - company_district: - description: "区 / 县名称" - type: string - company_district_code: - description: "区 / 县编码" - type: string - company_postalcode: - description: "邮编" - type: string - company_add: - description: "地址" - type: string - company_status: - description: "公司状态" - type: string - company_level: - description: "公司等级" - type: string - company_owner_openid: - description: "公司所有者 openid" - type: string - company_remark: - description: "备注" - type: string - additionalProperties: false - -PocketBaseCompanyUpdateRequest: - type: object - properties: - company_id: - description: "所属公司业务 ID" - type: string - company_name: - description: "公司名称" - type: string - company_type: - description: "公司类型" - type: string - company_entity: - description: "公司法人" - type: string - company_usci: - description: "统一社会信用代码" - type: string - company_nationality: - description: "国家名称" - type: string - company_nationality_code: - description: "国家编码" - type: string - company_province: - description: "省份名称" - type: string - company_province_code: - description: "省份编码" - type: string - company_city: - description: "城市名称" - type: string - company_city_code: - description: "城市编码" - type: string - company_district: - description: "区 / 县名称" - type: string - company_district_code: - description: "区 / 县编码" - type: string - company_postalcode: - description: "邮编" - type: string - company_add: - description: "地址" - type: string - company_status: - description: "公司状态" - type: string - company_level: - description: "公司等级" - type: string - company_owner_openid: - description: "公司所有者 openid" - type: string - company_remark: - description: "备注" - type: string - additionalProperties: false - -PocketBaseCompanyListResponse: - type: object - required: - - page - - perPage - - totalItems - - totalPages - - items - properties: - page: - type: - - integer - - string - example: 页码 | integer - perPage: - type: - - integer - - string - example: 每页条数 | integer - totalItems: - type: - - integer - - string - example: 总记录数 | integer - totalPages: - type: - - integer - - string - example: 总页数 | integer - items: - type: array - items: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseCompanyRecord' - example: - page: 页码 | integer - perPage: 每页条数 | integer - totalItems: 总记录数 | integer - totalPages: 总页数 | integer - items: - - id: PocketBase记录主键 | string - collectionId: 集合ID | string - collectionName: 集合名称 | string - created: 记录创建时间 | string - updated: 记录更新时间 | string - company_id: 公司业务id,由数据库自动生成 | string - company_name: 公司名称 | string - company_type: 公司类型 | string - company_entity: 公司法人 | string - company_usci: 统一社会信用代码 | string - company_nationality: 国家名称 | string - company_nationality_code: 国家编码 | string - company_province: 省份名称 | string - company_province_code: 省份编码 | string - company_city: 城市名称 | string - company_city_code: 城市编码 | string - company_district: 区县名称 | string - company_district_code: 区县编码 | string - company_postalcode: 邮政编码 | string - company_add: 公司地址 | string - company_status: 公司状态 | string - company_level: 公司等级 | string - company_owner_openid: 公司所有者openid | string - company_remark: 备注 | string diff --git a/pocket-base/spec/openapi-wx/schemas/documents.yaml b/pocket-base/spec/openapi-wx/schemas/documents.yaml deleted file mode 100644 index b0a9ebd..0000000 --- a/pocket-base/spec/openapi-wx/schemas/documents.yaml +++ /dev/null @@ -1,221 +0,0 @@ -PocketBaseDocumentFields: - type: object - properties: - document_id: - type: string - description: "文档业务 ID" - example: 文档业务ID | string - document_create: - type: string - description: "文档创建时间,由数据库自动生成" - example: 文档创建时间,由数据库自动生成 | string - document_effect_date: - type: string - description: "文档生效日期" - example: 文档生效日期 | string - document_expiry_date: - type: string - description: "文档到期日期" - example: 文档到期日期 | string - document_title: - type: string - description: "文档标题" - example: 文档标题 | string - document_type: - type: string - description: "文档类型,多选时按 system_dict_id@dict_word_enum|... 保存" - example: 文档类型,按system_dict_id@dict_word_enum保存 | string - document_subtitle: - type: string - description: "文档副标题" - example: 文档副标题 | string - document_summary: - type: string - description: "文档摘要" - example: 文档摘要 | string - document_content: - type: string - description: "正文内容,保存 Markdown" - example: 正文内容 | string - document_image: - type: string - description: "图片附件 ID 集合,底层以 | 分隔" - example: 图片附件ID串,底层按|分隔 | string - document_video: - type: string - description: "视频附件 ID 集合,底层以 | 分隔" - example: 视频附件ID串,底层按|分隔 | string - document_file: - type: string - description: "文件附件 ID 集合,底层以 | 分隔" - example: 文件附件ID串,底层按|分隔 | string - document_status: - type: string - description: "文档状态,仅 `有效` / `过期`" - example: 文档状态 | string - document_owner: - type: string - description: "上传者 openid" - example: 上传者openid | string - document_relation_model: - type: string - description: "关联机型 / 模型标识" - example: 关联机型标识 | string - document_keywords: - type: string - description: "关键词,多选后以 | 分隔" - example: 关键词,多选按|分隔 | string - document_share_count: - type: number - description: "分享次数" - example: 0 - document_download_count: - type: number - description: "下载次数" - example: 0 - document_favorite_count: - type: number - description: "收藏次数" - example: 0 - document_embedding_status: - type: string - description: "文档嵌入状态" - example: 文档嵌入状态 | string - document_embedding_error: - type: string - description: "文档嵌入错误原因" - example: 文档嵌入错误原因 | string - document_embedding_lasttime: - type: string - description: "最后一次嵌入更新时间" - example: 最后一次嵌入更新时间 | string - document_vector_version: - type: string - description: "向量版本号 / 模型名称" - example: 向量版本号或模型名称 | string - document_product_categories: - type: string - description: "产品关联文档,多选后以 | 分隔" - example: 产品关联文档,多选按|分隔 | string - document_application_scenarios: - type: string - description: "筛选依据,多选后以 | 分隔" - example: 筛选依据,多选按|分隔 | string - document_hotel_type: - type: string - description: "适用场景,多选后以 | 分隔" - example: 适用场景,多选按|分隔 | string - document_remark: - type: string - description: "备注" - example: 备注 | string - -PocketBaseDocumentRecord: - allOf: - - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseRecordBase' - - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseDocumentFields' - example: - id: PocketBase记录主键 | string - collectionId: 集合ID | string - collectionName: 集合名称 | string - created: 记录创建时间 | string - updated: 记录更新时间 | string - document_id: 文档业务ID | string - document_create: 文档创建时间,由数据库自动生成 | string - document_effect_date: 文档生效日期 | string - document_expiry_date: 文档到期日期 | string - document_title: 文档标题 | string - document_type: 文档类型,按system_dict_id@dict_word_enum保存 | string - document_subtitle: 文档副标题 | string - document_summary: 文档摘要 | string - document_content: 正文内容 | string - document_image: 图片附件ID串,底层按|分隔 | string - document_video: 视频附件ID串,底层按|分隔 | string - document_file: 文件附件ID串,底层按|分隔 | string - document_status: 文档状态 | string - document_owner: 上传者openid | string - document_relation_model: 关联机型标识 | string - document_keywords: 关键词,多选按|分隔 | string - document_share_count: 0 - document_download_count: 0 - document_favorite_count: 0 - document_embedding_status: 文档嵌入状态 | string - document_embedding_error: 文档嵌入错误原因 | string - document_embedding_lasttime: 最后一次嵌入更新时间 | string - document_vector_version: 向量版本号或模型名称 | string - document_product_categories: 产品关联文档,多选按|分隔 | string - document_application_scenarios: 筛选依据,多选按|分隔 | string - document_hotel_type: 适用场景,多选按|分隔 | string - document_remark: 备注 | string - -PocketBaseDocumentListResponse: - type: object - required: - - page - - perPage - - totalItems - - totalPages - - items - properties: - page: - type: - - integer - - string - example: 页码 | integer - perPage: - type: - - integer - - string - example: 每页条数 | integer - totalItems: - type: - - integer - - string - example: 总记录数 | integer - totalPages: - type: - - integer - - string - example: 总页数 | integer - items: - type: array - items: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseDocumentRecord' - example: - page: 页码 | integer - perPage: 每页条数 | integer - totalItems: 总记录数 | integer - totalPages: 总页数 | integer - items: - - id: PocketBase记录主键 | string - collectionId: 集合ID | string - collectionName: 集合名称 | string - created: 记录创建时间 | string - updated: 记录更新时间 | string - document_id: 文档业务ID | string - document_create: 文档创建时间,由数据库自动生成 | string - document_effect_date: 文档生效日期 | string - document_expiry_date: 文档到期日期 | string - document_title: 文档标题 | string - document_type: 文档类型,按system_dict_id@dict_word_enum保存 | string - document_subtitle: 文档副标题 | string - document_summary: 文档摘要 | string - document_content: 正文内容 | string - document_image: 图片附件ID串,底层按|分隔 | string - document_video: 视频附件ID串,底层按|分隔 | string - document_file: 文件附件ID串,底层按|分隔 | string - document_status: 文档状态 | string - document_owner: 上传者openid | string - document_relation_model: 关联机型标识 | string - document_keywords: 关键词,多选按|分隔 | string - document_share_count: 0 - document_download_count: 0 - document_favorite_count: 0 - document_embedding_status: 文档嵌入状态 | string - document_embedding_error: 文档嵌入错误原因 | string - document_embedding_lasttime: 最后一次嵌入更新时间 | string - document_vector_version: 向量版本号或模型名称 | string - document_product_categories: 产品关联文档,多选按|分隔 | string - document_application_scenarios: 筛选依据,多选按|分隔 | string - document_hotel_type: 适用场景,多选按|分隔 | string - document_remark: 备注 | string diff --git a/pocket-base/spec/openapi-wx/schemas/order-hooks.yaml b/pocket-base/spec/openapi-wx/schemas/order-hooks.yaml deleted file mode 100644 index 79d9ecc..0000000 --- a/pocket-base/spec/openapi-wx/schemas/order-hooks.yaml +++ /dev/null @@ -1,191 +0,0 @@ -OrderRecord: - allOf: - - $ref: '../../openapi-wx.yaml#/components/schemas/HookRecordBase' - - type: object - properties: - order_id: - type: string - description: 订单业务 ID - example: ORDER-1770000000000-abc123 - order_number: - type: string - description: 订单编号 - example: wx-user-20260403153500 - order_create: - type: string - description: 订单创建时间,由数据库自动生成 - example: 2026-04-03 15:35:00.000Z - order_owner: - type: string - description: 订单所有者 openid - example: wx-openid-user-001 - order_source: - type: string - description: 订单来源 - example: 购物车 - order_status: - type: string - description: 订单状态 - example: 订单已生成 - order_source_id: - type: string - description: 来源关联业务 ID - example: CART-1770000000000-abc123 - order_snap: - description: 订单快照 JSON - oneOf: - - type: object - additionalProperties: true - - type: array - items: - type: object - additionalProperties: true - order_amount: - type: - - integer - - number - description: 订单金额 - example: 3998 - order_remark: - type: string - description: 备注 - example: 小程序订单示例 - is_delete: - type: - - integer - - number - description: 软删除标记;目标契约字段,当前 hooks 响应可能尚未显式透出 - example: 0 - -OrderListRequest: - type: object - properties: - keyword: - type: string - description: 对 `order_id`、`order_number`、`order_source_id` 等索引相关字段的统一模糊搜索关键字 - example: ORDER-1770 - order_status: - type: string - description: 订单状态精确过滤 - example: 订单已生成 - order_source: - type: string - description: 订单来源精确过滤 - example: 购物车 - -OrderDetailRequest: - type: object - required: - - order_id - properties: - order_id: - type: string - description: 订单业务 ID - example: ORDER-1770000000000-abc123 - -OrderCreateRequest: - type: object - required: - - order_source - - order_source_id - - order_snap - - order_amount - properties: - order_number: - type: string - description: 可选;未传时服务端自动生成 - order_source: - type: string - description: 订单来源 - example: 购物车 - order_status: - type: string - description: 可选;未传时默认 `订单已生成` - example: 订单已生成 - order_source_id: - type: string - description: 来源关联业务 ID - example: CART-1770000000000-abc123 - order_snap: - description: 订单快照 JSON - oneOf: - - type: object - additionalProperties: true - - type: array - items: - type: object - additionalProperties: true - order_amount: - type: - - integer - - number - description: 订单金额 - example: 3998 - order_remark: - type: string - description: 备注 - example: 小程序订单示例 - -OrderUpdateRequest: - type: object - required: - - order_id - properties: - order_id: - type: string - description: 订单业务 ID - example: ORDER-1770000000000-abc123 - order_number: - type: string - order_source: - type: string - order_status: - type: string - order_source_id: - type: string - order_snap: - oneOf: - - type: object - additionalProperties: true - - type: array - items: - type: object - additionalProperties: true - order_amount: - type: - - integer - - number - order_remark: - type: string - -OrderDeleteRequest: - type: object - required: - - order_id - properties: - order_id: - type: string - description: 订单业务 ID - example: ORDER-1770000000000-abc123 - -OrderListResponse: - type: object - properties: - items: - type: array - items: - $ref: '../../openapi-wx.yaml#/components/schemas/OrderRecord' - -OrderDeleteResponse: - type: object - properties: - order_id: - type: string - description: 订单业务 ID - example: ORDER-1770000000000-abc123 - is_delete: - type: - - integer - - number - description: 目标软删除标记值;当前实现可能仍返回物理删除结果 - example: 1 diff --git a/pocket-base/spec/openapi-wx/schemas/order-native.yaml b/pocket-base/spec/openapi-wx/schemas/order-native.yaml deleted file mode 100644 index 52de03d..0000000 --- a/pocket-base/spec/openapi-wx/schemas/order-native.yaml +++ /dev/null @@ -1,154 +0,0 @@ -PocketBaseOrderFields: - type: object - properties: - order_id: - type: string - description: 订单业务 ID - example: ORDER-1770000000000-abc123 - order_number: - type: string - description: 订单编号 - example: wx-user-20260403153500 - order_create: - type: string - description: 订单创建时间,由数据库自动生成 - example: 2026-04-03 15:35:00.000Z - order_owner: - type: string - description: 订单所有者 openid - example: wx-openid-user-001 - order_source: - type: string - description: 订单来源 - example: 购物车 - order_status: - type: string - description: 订单状态 - example: 订单已生成 - order_source_id: - type: string - description: 来源关联业务 ID - example: CART-1770000000000-abc123 - order_snap: - description: 订单快照 JSON - oneOf: - - type: object - additionalProperties: true - - type: array - items: - type: object - additionalProperties: true - order_amount: - type: - - number - - integer - description: 订单金额 - example: 3998 - order_remark: - type: string - description: 备注 - example: 小程序订单示例 - -PocketBaseOrderRecord: - allOf: - - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseRecordBase' - - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseOrderFields' - -PocketBaseOrderCreateRequest: - type: object - required: - - order_id - - order_number - - order_owner - - order_source - - order_status - - order_source_id - - order_snap - - order_amount - properties: - order_id: - type: string - order_number: - type: string - order_owner: - type: string - description: 必须显式提交,且值必须等于当前 token 对应 openid - order_source: - type: string - order_status: - type: string - order_source_id: - type: string - order_snap: - oneOf: - - type: object - additionalProperties: true - - type: array - items: - type: object - additionalProperties: true - order_amount: - type: - - number - - integer - order_remark: - type: string - -PocketBaseOrderUpdateRequest: - type: object - properties: - order_number: - type: string - order_owner: - type: string - description: 若提交,必须仍等于当前 token 对应 openid - order_source: - type: string - order_status: - type: string - order_source_id: - type: string - order_snap: - oneOf: - - type: object - additionalProperties: true - - type: array - items: - type: object - additionalProperties: true - order_amount: - type: - - number - - integer - order_remark: - type: string - -PocketBaseOrderListResponse: - type: object - required: - - page - - perPage - - totalItems - - totalPages - - items - properties: - page: - type: - - integer - - string - perPage: - type: - - integer - - string - totalItems: - type: - - integer - - string - totalPages: - type: - - integer - - string - items: - type: array - items: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseOrderRecord' diff --git a/pocket-base/spec/openapi-wx/schemas/products.yaml b/pocket-base/spec/openapi-wx/schemas/products.yaml deleted file mode 100644 index e842800..0000000 --- a/pocket-base/spec/openapi-wx/schemas/products.yaml +++ /dev/null @@ -1,203 +0,0 @@ -PocketBaseProductListFields: - type: object - properties: - prod_list_id: - type: string - description: 产品列表业务 ID,唯一标识 - example: <产品列表业务ID>| - prod_list_name: - type: string - description: 产品名称 - example: <产品名称>| - prod_list_modelnumber: - type: string - description: 产品型号 - example: <产品型号>| - prod_list_icon: - type: string - description: 产品图标附件 ID,保存 `tbl_attachments.attachments_id` - example: <产品图标附件ID>| - prod_list_description: - type: string - description: 产品说明 - example: <产品说明>| - prod_list_feature: - type: string - description: 产品特色 - example: <产品特色>| - prod_list_parameters: - type: array - description: 产品参数数组,每项包含 name/value - items: - type: object - properties: - name: - type: string - example: <属性名>| - value: - type: string - example: <属性值>| - example: - - name: <属性名>| - value: <属性值>| - prod_list_plantype: - type: string - description: 产品方案 - example: <产品方案>| - prod_list_category: - type: string - description: 产品分类(必填,单选) - example: <产品分类>| - prod_list_sort: - type: - - number - - integer - description: 排序值(同分类内按升序) - example: 10 - prod_list_comm_type: - type: string - description: 通讯类型 - example: <通讯类型>| - prod_list_series: - type: string - description: 产品系列 - example: <产品系列>| - prod_list_power_supply: - type: string - description: 供电方式 - example: <供电方式>| - prod_list_tags: - type: string - description: 产品标签(辅助检索,以 `|` 聚合) - example: <产品标签>| - prod_list_status: - type: string - description: 产品状态(有效 / 过期 / 主推等) - example: <产品状态>| - prod_list_basic_price: - type: - - number - - integer - description: 基础价格 - example: 1999 - prod_list_vip_price: - type: array - description: 会员价数组,每项包含会员等级枚举值与价格 - items: - type: object - properties: - viplevel: - type: string - example: <会员等级枚举值>| - price: - type: - - number - - integer - example: 1899 - example: - - viplevel: VIP1 - price: 1899 - prod_list_remark: - type: string - description: 备注 - example: <备注>| - -PocketBaseProductListRecord: - allOf: - - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseRecordBase' - - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseProductListFields' - example: - id: | - collectionId: <集合ID>| - collectionName: <集合名称>| - created: <记录创建时间>| - updated: <记录更新时间>| - prod_list_id: <产品列表业务ID>| - prod_list_name: <产品名称>| - prod_list_modelnumber: <产品型号>| - prod_list_icon: <产品图标附件ID>| - prod_list_description: <产品说明>| - prod_list_feature: <产品特色>| - prod_list_parameters: - - name: <属性名>| - value: <属性值>| - prod_list_plantype: <产品方案>| - prod_list_category: <产品分类>| - prod_list_sort: 10 - prod_list_comm_type: <通讯类型>| - prod_list_series: <产品系列>| - prod_list_power_supply: <供电方式>| - prod_list_tags: <产品标签>| - prod_list_status: <产品状态>| - prod_list_basic_price: 1999 - prod_list_vip_price: - - viplevel: VIP1 - price: 1899 - prod_list_remark: <备注>| - -PocketBaseProductListListResponse: - type: object - required: - - page - - perPage - - totalItems - - totalPages - - items - properties: - page: - type: - - integer - - string - example: <页码>| - perPage: - type: - - integer - - string - example: <每页条数>| - totalItems: - type: - - integer - - string - example: <总记录数>| - totalPages: - type: - - integer - - string - example: <总页数>| - items: - type: array - items: - $ref: '../../openapi-wx.yaml#/components/schemas/PocketBaseProductListRecord' - example: - page: <页码>| - perPage: <每页条数>| - totalItems: <总记录数>| - totalPages: <总页数>| - items: - - id: | - collectionId: <集合ID>| - collectionName: <集合名称>| - created: <记录创建时间>| - updated: <记录更新时间>| - prod_list_id: <产品列表业务ID>| - prod_list_name: <产品名称>| - prod_list_modelnumber: <产品型号>| - prod_list_icon: <产品图标附件ID>| - prod_list_description: <产品说明>| - prod_list_feature: <产品特色>| - prod_list_parameters: - - name: <属性名>| - value: <属性值>| - prod_list_plantype: <产品方案>| - prod_list_category: <产品分类>| - prod_list_sort: 10 - prod_list_comm_type: <通讯类型>| - prod_list_series: <产品系列>| - prod_list_power_supply: <供电方式>| - prod_list_tags: <产品标签>| - prod_list_status: <产品状态>| - prod_list_basic_price: 1999 - prod_list_vip_price: - - viplevel: VIP1 - price: 1899 - prod_list_remark: <备注>| diff --git a/pocket-base/spec/openapi-wx/schemas/system.yaml b/pocket-base/spec/openapi-wx/schemas/system.yaml deleted file mode 100644 index ebeeb55..0000000 --- a/pocket-base/spec/openapi-wx/schemas/system.yaml +++ /dev/null @@ -1,55 +0,0 @@ -SystemRefreshTokenRequest: - type: object - properties: - users_wx_code: - type: - - string - - 'null' - description: | - 可选。 - 当前 token 失效时,可通过该 code 重新签发 token。 - example: 0a1b2c3d4e5f6g - -RefreshTokenResponse: - allOf: - - $ref: '../../openapi-wx.yaml#/components/schemas/ApiResponseBase' - - type: object - required: - - token - properties: - data: - type: object - additionalProperties: true - description: "业务响应数据" - example: {} - token: - type: string - description: 新签发的 PocketBase 原生 auth token - example: - statusCode: 业务状态码 | integer - errMsg: 刷新成功 | string - data: {} - token: 新签发的PocketBase原生auth token | string - -UsersCountData: - type: object - properties: - total_users: - type: - - integer - - string - example: 用户总数 | integer - -UsersCountResponse: - allOf: - - $ref: '../../openapi-wx.yaml#/components/schemas/ApiResponseBase' - - type: object - properties: - data: - description: "业务响应数据" - $ref: '../../openapi-wx.yaml#/components/schemas/UsersCountData' - example: - statusCode: 业务状态码 | integer - errMsg: 业务提示信息 | string - data: - total_users: 用户总数 | integer diff --git a/pocket-base/spec/openapi-wx/schemas/wechat-auth.yaml b/pocket-base/spec/openapi-wx/schemas/wechat-auth.yaml deleted file mode 100644 index d6bb510..0000000 --- a/pocket-base/spec/openapi-wx/schemas/wechat-auth.yaml +++ /dev/null @@ -1,389 +0,0 @@ -UserInfo: - type: object - properties: - pb_id: - description: "PocketBase 记录主键 id" - type: string - users_convers_id: - description: "会话侧用户 ID" - type: string - users_id: - description: "用户业务 ID" - type: string - users_idtype: - description: "身份来源类型或证件类型" - anyOf: - - type: string - enum: - - WeChat - - ManagePlatform - - type: string - users_id_number: - description: "证件号" - type: string - users_type: - description: "用户类型" - anyOf: - - type: string - enum: - - 游客 - - 注册用户 - - type: string - users_name: - description: "用户姓名 / 昵称" - type: string - users_status: - description: "用户状态" - type: - - string - - number - users_rank_level: - description: "用户星级数值" - type: - - number - - integer - - string - users_auth_type: - description: "账户类型" - type: - - number - - integer - - string - users_phone: - description: "手机号" - type: string - users_phone_masked: - type: string - users_level: - type: string - description: 用户等级 - users_level_name: - type: string - description: 用户等级名称,按 `users_level -> 数据-会员等级` 字典描述实时解析 - users_tag: - type: string - description: 用户标签 - users_picture: - type: string - description: 用户头像附件的 `attachments_id` - users_picture_url: - type: string - description: 根据 `users_picture -> tbl_attachments` 自动解析出的头像文件流链接 - users_id_pic_a: - type: string - description: 证件正面附件的 `attachments_id` - users_id_pic_a_url: - type: string - description: 根据 `users_id_pic_a -> tbl_attachments` 自动解析出的文件流链接 - users_id_pic_b: - type: string - description: 证件反面附件的 `attachments_id` - users_id_pic_b_url: - type: string - description: 根据 `users_id_pic_b -> tbl_attachments` 自动解析出的文件流链接 - users_title_picture: - type: string - description: 资质附件的 `attachments_id` - users_title_picture_url: - type: string - description: 根据 `users_title_picture -> tbl_attachments` 自动解析出的文件流链接 - openid: - type: string - description: 全平台统一身份标识 - company_id: - type: string - description: 公司业务 id,存储 `tbl_company.company_id` - users_parent_id: - type: string - description: 上级用户业务 id - users_promo_code: - type: string - description: 推广码 - usergroups_id: - type: string - description: 用户组业务 id - company: - $ref: '../../openapi-wx.yaml#/components/schemas/CompanyInfo' - created: - type: string - description: 用户创建时间 - updated: - type: string - description: 用户更新时间 - example: - pb_id: PocketBase记录主键id | string - users_convers_id: 会话侧用户ID | string - users_id: 用户业务ID | string - users_idtype: 用户身份来源类型 | string - users_id_number: 证件号 | string - users_type: 用户类型 | string - users_name: 用户姓名或昵称 | string - users_status: 用户状态 | string - users_rank_level: 用户星级数值 | number - users_auth_type: 账户类型 | number - users_phone: 手机号 | string - users_phone_masked: 手机号脱敏值 | string - users_level: 用户等级 | string - users_level_name: 用户等级名称 | string - users_tag: 用户标签 | string - users_picture: 用户头像附件ID | string - users_picture_url: 用户头像文件流链接 | string - users_id_pic_a: 证件正面附件ID | string - users_id_pic_a_url: 证件正面文件流链接 | string - users_id_pic_b: 证件反面附件ID | string - users_id_pic_b_url: 证件反面文件流链接 | string - users_title_picture: 资质附件ID | string - users_title_picture_url: 资质附件文件流链接 | string - openid: 全平台统一身份标识 | string - company_id: 公司业务id | string - users_parent_id: 上级用户业务id | string - users_promo_code: 推广码 | string - usergroups_id: 用户组业务id | string - company: - pb_id: PocketBase记录主键id | string - company_id: 公司业务id,由数据库自动生成 | string - company_name: 公司名称 | string - company_type: 公司类型 | string - company_entity: 公司法人 | string - company_usci: 统一社会信用代码 | string - company_nationality: 国家名称 | string - company_nationality_code: 国家编码 | string - company_province: 省份名称 | string - company_province_code: 省份编码 | string - company_city: 城市名称 | string - company_city_code: 城市编码 | string - company_district: 区县名称 | string - company_district_code: 区县编码 | string - company_postalcode: 邮政编码 | string - company_add: 公司地址 | string - company_status: 公司状态 | string - company_level: 公司等级 | string - company_owner_openid: 公司所有者openid | string - company_remark: 备注 | string - created: 记录创建时间 | string - updated: 记录更新时间 | string - created: 用户创建时间 | string - updated: 用户更新时间 | string - -WechatLoginRequest: - type: object - required: - - users_wx_code - properties: - users_wx_code: - type: string - description: 微信小程序登录临时凭证 code - example: 0a1b2c3d4e5f6g - -WechatProfileRequest: - type: object - properties: - users_name: - type: string - description: "用户姓名 / 昵称" - example: 张三 - users_phone_code: - type: string - description: 可选。若传入,服务端优先通过微信接口换取真实手机号并写入数据库 - example: 2b7d9f2e3c4a5b6d7e8f - users_phone: - type: string - description: 可选。未传 `users_phone_code` 时,可直接写入手机号 - example: '13800138000' - users_type: - type: string - description: 可选。用户类型;仅在传入非空值时更新 - example: 服务商 - company_id: - type: string - description: 可选。公司业务 id;仅在传入非空值时更新 - example: WX-COMPANY-10001 - users_tag: - type: string - description: 可选。用户标签;非空时才更新 - example: 核心客户 - users_picture: - type: string - description: 可选。用户头像附件的 `attachments_id` - example: ATT-1743123456789-abc123 - users_id_pic_a: - type: string - description: 可选。证件正面附件的 `attachments_id` - users_id_pic_b: - type: string - description: 可选。证件反面附件的 `attachments_id` - users_title_picture: - type: string - description: 可选。资质附件的 `attachments_id` - -AuthSuccessData: - type: object - properties: - status: - anyOf: - - type: string - enum: - - register_success - - login_success - - type: string - is_info_complete: - type: - - boolean - - string - user: - $ref: '../../openapi-wx.yaml#/components/schemas/UserInfo' - -AuthSuccessResponse: - allOf: - - $ref: '../../openapi-wx.yaml#/components/schemas/ApiResponseBase' - - type: object - required: - - token - properties: - data: - description: "业务响应数据" - $ref: '../../openapi-wx.yaml#/components/schemas/AuthSuccessData' - token: - type: string - description: PocketBase 原生 auth token - example: - statusCode: 业务状态码 | integer - errMsg: 业务提示信息 | string - data: - status: 登录或注册状态 | string - is_info_complete: 资料是否完整 | boolean - user: - pb_id: PocketBase记录主键id | string - users_convers_id: 会话侧用户ID | string - users_id: 用户业务ID | string - users_idtype: 用户身份来源类型 | string - users_id_number: 证件号 | string - users_type: 用户类型 | string - users_name: 用户姓名或昵称 | string - users_status: 用户状态 | string - users_rank_level: 用户星级数值 | number - users_auth_type: 账户类型 | number - users_phone: 手机号 | string - users_phone_masked: 手机号脱敏值 | string - users_level: 用户等级 | string - users_level_name: 用户等级名称 | string - users_tag: 用户标签 | string - users_picture: 用户头像附件ID | string - users_picture_url: 用户头像文件流链接 | string - users_id_pic_a: 证件正面附件ID | string - users_id_pic_a_url: 证件正面文件流链接 | string - users_id_pic_b: 证件反面附件ID | string - users_id_pic_b_url: 证件反面文件流链接 | string - users_title_picture: 资质附件ID | string - users_title_picture_url: 资质附件文件流链接 | string - openid: 全平台统一身份标识 | string - company_id: 公司业务id | string - users_parent_id: 上级用户业务id | string - users_promo_code: 推广码 | string - usergroups_id: 用户组业务id | string - company: - pb_id: PocketBase记录主键id | string - company_id: 公司业务id,由数据库自动生成 | string - company_name: 公司名称 | string - company_type: 公司类型 | string - company_entity: 公司法人 | string - company_usci: 统一社会信用代码 | string - company_nationality: 国家名称 | string - company_nationality_code: 国家编码 | string - company_province: 省份名称 | string - company_province_code: 省份编码 | string - company_city: 城市名称 | string - company_city_code: 城市编码 | string - company_district: 区县名称 | string - company_district_code: 区县编码 | string - company_postalcode: 邮政编码 | string - company_add: 公司地址 | string - company_status: 公司状态 | string - company_level: 公司等级 | string - company_owner_openid: 公司所有者openid | string - company_remark: 备注 | string - created: 记录创建时间 | string - updated: 记录更新时间 | string - created: 用户创建时间 | string - updated: 用户更新时间 | string - token: PocketBase原生认证token | string - -WechatProfileResponseData: - type: object - properties: - status: - anyOf: - - type: string - enum: - - update_success - - type: string - user: - $ref: '../../openapi-wx.yaml#/components/schemas/UserInfo' - -WechatProfileResponse: - allOf: - - $ref: '../../openapi-wx.yaml#/components/schemas/ApiResponseBase' - - type: object - properties: - data: - description: "业务响应数据" - $ref: '../../openapi-wx.yaml#/components/schemas/WechatProfileResponseData' - example: - statusCode: 业务状态码 | integer - errMsg: 业务提示信息 | string - data: - status: 资料更新状态 | string - user: - pb_id: PocketBase记录主键id | string - users_convers_id: 会话侧用户ID | string - users_id: 用户业务ID | string - users_idtype: 用户身份来源类型 | string - users_id_number: 证件号 | string - users_type: 用户类型 | string - users_name: 用户姓名或昵称 | string - users_status: 用户状态 | string - users_rank_level: 用户星级数值 | number - users_auth_type: 账户类型 | number - users_phone: 手机号 | string - users_phone_masked: 手机号脱敏值 | string - users_level: 用户等级 | string - users_level_name: 用户等级名称 | string - users_tag: 用户标签 | string - users_picture: 用户头像附件ID | string - users_picture_url: 用户头像文件流链接 | string - users_id_pic_a: 证件正面附件ID | string - users_id_pic_a_url: 证件正面文件流链接 | string - users_id_pic_b: 证件反面附件ID | string - users_id_pic_b_url: 证件反面文件流链接 | string - users_title_picture: 资质附件ID | string - users_title_picture_url: 资质附件文件流链接 | string - openid: 全平台统一身份标识 | string - company_id: 公司业务id | string - users_parent_id: 上级用户业务id | string - users_promo_code: 推广码 | string - usergroups_id: 用户组业务id | string - company: - pb_id: PocketBase记录主键id | string - company_id: 公司业务id,由数据库自动生成 | string - company_name: 公司名称 | string - company_type: 公司类型 | string - company_entity: 公司法人 | string - company_usci: 统一社会信用代码 | string - company_nationality: 国家名称 | string - company_nationality_code: 国家编码 | string - company_province: 省份名称 | string - company_province_code: 省份编码 | string - company_city: 城市名称 | string - company_city_code: 城市编码 | string - company_district: 区县名称 | string - company_district_code: 区县编码 | string - company_postalcode: 邮政编码 | string - company_add: 公司地址 | string - company_status: 公司状态 | string - company_level: 公司等级 | string - company_owner_openid: 公司所有者openid | string - company_remark: 备注 | string - created: 记录创建时间 | string - updated: 记录更新时间 | string - created: 用户创建时间 | string - updated: 用户更新时间 | string diff --git a/pocket-base/spec/openapi-wx/system.yaml b/pocket-base/spec/openapi-wx/system.yaml new file mode 100644 index 0000000..d632b55 --- /dev/null +++ b/pocket-base/spec/openapi-wx/system.yaml @@ -0,0 +1,253 @@ +paths: + usersCount: + post: + security: [] + operationId: postSystemUsersCount + tags: + - 系统 + summary: 查询用户总数 + description: 统计 `tbl_auth_users` 集合中的记录总数。 + responses: + "200": + description: 查询成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/UsersCountResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + total_users: total_users|integer + "400": + description: 请求参数错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + refreshToken: + post: + security: + - BearerAuth: [] + - {} + operationId: postSystemRefreshToken + tags: + - 系统 + summary: 刷新认证 token + description: | + 当当前 `Authorization` 仍有效时,直接基于当前 auth 用户续签。 + 当 token 失效时,可传入 `users_wx_code` 走微信 code 重新签发。 + requestBody: + required: false + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/SystemRefreshTokenRequest + example: + users_wx_code: 当前 token 失效时,可通过该 code 重新签发 token。|string + responses: + "200": + description: 刷新成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/RefreshTokenResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + token: 新签发的 PocketBase 原生 auth token|string + "400": + description: 参数错误或微信 code 换取失败 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "401": + description: token 无效,且未提供有效的 `users_wx_code` + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "404": + description: 当前用户不存在 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "415": + description: 请求体不是 JSON + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "429": + description: 请求过于频繁 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string +components: + schemas: + ApiResponseBase: + type: object + required: + - statusCode + - errMsg + - data + properties: + statusCode: + type: + - integer + - string + description: 业务状态码 + example: 业务状态码 | integer + errMsg: + type: string + description: 业务提示信息 + example: 业务提示信息 | string + data: + description: 业务响应数据 + type: object + additionalProperties: true + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + ErrorResponse: + type: object + required: + - statusCode + - errMsg + - data + properties: + statusCode: + type: + - integer + - string + description: 业务状态码 + example: 业务状态码 | integer + errMsg: + type: string + description: 业务提示信息 + example: 失败原因提示 | string + data: + description: 业务响应数据 + type: object + additionalProperties: true + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + SystemRefreshTokenRequest: + type: object + properties: + users_wx_code: + type: + - string + - "null" + description: | + 可选。 + 当前 token 失效时,可通过该 code 重新签发 token。 + example: 0a1b2c3d4e5f6g + example: + users_wx_code: 当前 token 失效时,可通过该 code 重新签发 token。|string + RefreshTokenResponse: + allOf: + - $ref: ../openapi-wx.yaml#/components/schemas/ApiResponseBase + - type: object + required: + - token + properties: + data: + type: object + additionalProperties: true + description: 业务响应数据 + example: {} + token: + type: string + description: 新签发的 PocketBase 原生 auth token + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + token: 新签发的 PocketBase 原生 auth token|string + UsersCountData: + type: object + properties: + total_users: + type: + - integer + - string + example: 用户总数 | integer + example: + total_users: total_users|integer + UsersCountResponse: + allOf: + - $ref: ../openapi-wx.yaml#/components/schemas/ApiResponseBase + - type: object + properties: + data: + description: 业务响应数据 + $ref: ../openapi-wx.yaml#/components/schemas/UsersCountData + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + total_users: total_users|integer diff --git a/pocket-base/spec/openapi-wx/wechat-auth.yaml b/pocket-base/spec/openapi-wx/wechat-auth.yaml new file mode 100644 index 0000000..2ab0732 --- /dev/null +++ b/pocket-base/spec/openapi-wx/wechat-auth.yaml @@ -0,0 +1,1003 @@ +paths: + wechatLogin: + post: + security: [] + operationId: postWechatLogin + tags: + - 微信认证 + summary: 微信登录或首次注册 + description: | + 使用微信 `users_wx_code` 换取微信 openid。 + 若 `tbl_auth_users` 中不存在对应用户,则自动创建新 auth 用户并返回 token。 + 首次注册时,`users_level` 默认保持为空,不自动写入会员等级。 + requestBody: + required: true + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/WechatLoginRequest + example: + users_wx_code: 微信小程序登录临时凭证 code|string + responses: + "200": + description: 登录或注册成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/AuthSuccessResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + status: status|string + is_info_complete: is_info_complete|boolean + user: + pb_id: PocketBase 记录主键 id|string + users_convers_id: 会话侧用户 ID|string + users_id: 用户业务 ID|string + users_idtype: users_idtype|string + users_id_number: 证件号|string + users_type: users_type|string + users_name: 用户姓名 / 昵称|string + users_status: 用户状态|string + users_rank_level: 用户星级数值|number + users_auth_type: 账户类型|number + users_phone: 手机号|string + users_phone_masked: users_phone_masked|string + users_level: 用户等级|string + users_level_name: 用户等级名称,按 users_level - 数据-会员等级 字典描述实时解析|string + users_tag: 用户标签|string + users_picture: 用户头像附件的 attachments_id|string + users_picture_url: 根据 users_picture - tbl_attachments 自动解析出的头像文件流链接|string + users_id_pic_a: 证件正面附件的 attachments_id|string + users_id_pic_a_url: 根据 users_id_pic_a - tbl_attachments 自动解析出的文件流链接|string + users_id_pic_b: 证件反面附件的 attachments_id|string + users_id_pic_b_url: 根据 users_id_pic_b - tbl_attachments 自动解析出的文件流链接|string + users_title_picture: 资质附件的 attachments_id|string + users_title_picture_url: 根据 users_title_picture - tbl_attachments 自动解析出的文件流链接|string + openid: 全平台统一身份标识|string + company_id: 公司业务 id,存储 tbl_company.company_id|string + users_parent_id: 上级用户业务 id|string + users_promo_code: 推广码|string + usergroups_id: 用户组业务 id|string + company: + pb_id: PocketBase 记录主键 id|string + company_id: 公司业务 id,由数据库自动生成|string + company_name: 公司名称|string + company_type: 公司类型|string + company_entity: 公司法人|string + company_usci: 统一社会信用代码|string + company_nationality: 国家名称|string + company_nationality_code: 国家编码|string + company_province: 省份名称|string + company_province_code: 省份编码|string + company_city: 城市名称|string + company_city_code: 城市编码|string + company_district: 区/县名称|string + company_district_code: 区/县编码|string + company_postalcode: 邮政编码|string + company_add: 公司地址|string + company_status: 公司状态|string + company_level: 公司等级|string + company_owner_openid: 公司所有者 openid|string + company_remark: 备注|string + created: 记录创建时间|string + updated: 记录更新时间|string + created: 用户创建时间|string + updated: 用户更新时间|string + token: PocketBase 原生 auth token|string + "400": + description: 参数错误或保存用户失败 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "401": + description: 认证失败 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "415": + description: 请求体不是 JSON + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "429": + description: 请求过于频繁 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + wechatProfile: + post: + security: + - BearerAuth: [] + operationId: postWechatProfile + tags: + - 微信认证 + summary: 更新微信用户资料 + description: | + 基于当前 `Authorization` 对应的 auth 用户按“非空字段增量更新”资料。 + + 更新规则: + - 所有字段都不是必填 + - 如果传了 `users_phone_code`,服务端优先调用微信接口换取真实手机号并写入 `users_phone` + - 如果没传 `users_phone_code`,但传了 `users_phone`,则直接将该手机号写入数据库 + - 如果上传了 `users_picture`、`users_id_pic_a`、`users_id_pic_b`、`users_title_picture`,会按附件 ID 进行关联校验并更新 + - 若当前用户类型为 `游客`,且本次未显式传 `users_type`,服务端会自动升级为 `注册用户` + - 如果某个字段未传或传空,则不会清空数据库中的已有值 + - 只有请求体里非空的字段才会更新到数据库 + requestBody: + required: true + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/WechatProfileRequest + example: + users_name: 用户姓名 / 昵称|string + users_phone_code: 可选。若传入,服务端优先通过微信接口换取真实手机号并写入数据库|string + users_phone: 可选。未传 users_phone_code 时,可直接写入手机号|string + users_type: 可选。用户类型;仅在传入非空值时更新|string + company_id: 可选。公司业务 id;仅在传入非空值时更新|string + users_tag: 可选。用户标签;非空时才更新|string + users_picture: 可选。用户头像附件的 attachments_id|string + users_id_pic_a: 可选。证件正面附件的 attachments_id|string + users_id_pic_b: 可选。证件反面附件的 attachments_id|string + users_title_picture: 可选。资质附件的 attachments_id|string + responses: + "200": + description: 更新成功 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/WechatProfileResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + status: status|string + user: + pb_id: PocketBase 记录主键 id|string + users_convers_id: 会话侧用户 ID|string + users_id: 用户业务 ID|string + users_idtype: users_idtype|string + users_id_number: 证件号|string + users_type: users_type|string + users_name: 用户姓名 / 昵称|string + users_status: 用户状态|string + users_rank_level: 用户星级数值|number + users_auth_type: 账户类型|number + users_phone: 手机号|string + users_phone_masked: users_phone_masked|string + users_level: 用户等级|string + users_level_name: 用户等级名称,按 users_level - 数据-会员等级 字典描述实时解析|string + users_tag: 用户标签|string + users_picture: 用户头像附件的 attachments_id|string + users_picture_url: 根据 users_picture - tbl_attachments 自动解析出的头像文件流链接|string + users_id_pic_a: 证件正面附件的 attachments_id|string + users_id_pic_a_url: 根据 users_id_pic_a - tbl_attachments 自动解析出的文件流链接|string + users_id_pic_b: 证件反面附件的 attachments_id|string + users_id_pic_b_url: 根据 users_id_pic_b - tbl_attachments 自动解析出的文件流链接|string + users_title_picture: 资质附件的 attachments_id|string + users_title_picture_url: 根据 users_title_picture - tbl_attachments 自动解析出的文件流链接|string + openid: 全平台统一身份标识|string + company_id: 公司业务 id,存储 tbl_company.company_id|string + users_parent_id: 上级用户业务 id|string + users_promo_code: 推广码|string + usergroups_id: 用户组业务 id|string + company: + pb_id: PocketBase 记录主键 id|string + company_id: 公司业务 id,由数据库自动生成|string + company_name: 公司名称|string + company_type: 公司类型|string + company_entity: 公司法人|string + company_usci: 统一社会信用代码|string + company_nationality: 国家名称|string + company_nationality_code: 国家编码|string + company_province: 省份名称|string + company_province_code: 省份编码|string + company_city: 城市名称|string + company_city_code: 城市编码|string + company_district: 区/县名称|string + company_district_code: 区/县编码|string + company_postalcode: 邮政编码|string + company_add: 公司地址|string + company_status: 公司状态|string + company_level: 公司等级|string + company_owner_openid: 公司所有者 openid|string + company_remark: 备注|string + created: 记录创建时间|string + updated: 记录更新时间|string + created: 用户创建时间|string + updated: 用户更新时间|string + "400": + description: 参数错误、手机号已被占用、附件 ID 无效、微信手机号换取失败或资料更新失败 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "401": + description: token 无效或缺少 openid + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "415": + description: 请求体不是 JSON + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "429": + description: 请求过于频繁 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + "500": + description: 服务端错误 + content: + application/json: + schema: + $ref: ../openapi-wx.yaml#/components/schemas/ErrorResponse + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string +components: + schemas: + ApiResponseBase: + type: object + required: + - statusCode + - errMsg + - data + properties: + statusCode: + type: + - integer + - string + description: 业务状态码 + example: 业务状态码 | integer + errMsg: + type: string + description: 业务提示信息 + example: 业务提示信息 | string + data: + description: 业务响应数据 + type: object + additionalProperties: true + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + ErrorResponse: + type: object + required: + - statusCode + - errMsg + - data + properties: + statusCode: + type: + - integer + - string + description: 业务状态码 + example: 业务状态码 | integer + errMsg: + type: string + description: 业务提示信息 + example: 失败原因提示 | string + data: + description: 业务响应数据 + type: object + additionalProperties: true + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + 业务响应数据字段|string: 业务响应数据值|string + UserInfo: + type: object + properties: + pb_id: + description: PocketBase 记录主键 id + type: string + users_convers_id: + description: 会话侧用户 ID + type: string + users_id: + description: 用户业务 ID + type: string + users_idtype: + description: 身份来源类型或证件类型 + anyOf: + - type: string + enum: + - WeChat + - ManagePlatform + - type: string + users_id_number: + description: 证件号 + type: string + users_type: + description: 用户类型 + anyOf: + - type: string + enum: + - 游客 + - 注册用户 + - type: string + users_name: + description: 用户姓名 / 昵称 + type: string + users_status: + description: 用户状态 + type: + - string + - number + users_rank_level: + description: 用户星级数值 + type: + - number + - integer + - string + users_auth_type: + description: 账户类型 + type: + - number + - integer + - string + users_phone: + description: 手机号 + type: string + users_phone_masked: + type: string + users_level: + type: string + description: 用户等级 + users_level_name: + type: string + description: 用户等级名称,按 `users_level -> 数据-会员等级` 字典描述实时解析 + users_tag: + type: string + description: 用户标签 + users_picture: + type: string + description: 用户头像附件的 `attachments_id` + users_picture_url: + type: string + description: 根据 `users_picture -> tbl_attachments` 自动解析出的头像文件流链接 + users_id_pic_a: + type: string + description: 证件正面附件的 `attachments_id` + users_id_pic_a_url: + type: string + description: 根据 `users_id_pic_a -> tbl_attachments` 自动解析出的文件流链接 + users_id_pic_b: + type: string + description: 证件反面附件的 `attachments_id` + users_id_pic_b_url: + type: string + description: 根据 `users_id_pic_b -> tbl_attachments` 自动解析出的文件流链接 + users_title_picture: + type: string + description: 资质附件的 `attachments_id` + users_title_picture_url: + type: string + description: 根据 `users_title_picture -> tbl_attachments` 自动解析出的文件流链接 + openid: + type: string + description: 全平台统一身份标识 + company_id: + type: string + description: 公司业务 id,存储 `tbl_company.company_id` + users_parent_id: + type: string + description: 上级用户业务 id + users_promo_code: + type: string + description: 推广码 + usergroups_id: + type: string + description: 用户组业务 id + company: + $ref: ../openapi-wx.yaml#/components/schemas/CompanyInfo + created: + type: string + description: 用户创建时间 + updated: + type: string + description: 用户更新时间 + example: + pb_id: PocketBase 记录主键 id|string + users_convers_id: 会话侧用户 ID|string + users_id: 用户业务 ID|string + users_idtype: users_idtype|string + users_id_number: 证件号|string + users_type: users_type|string + users_name: 用户姓名 / 昵称|string + users_status: 用户状态|string + users_rank_level: 用户星级数值|number + users_auth_type: 账户类型|number + users_phone: 手机号|string + users_phone_masked: users_phone_masked|string + users_level: 用户等级|string + users_level_name: 用户等级名称,按 users_level - 数据-会员等级 字典描述实时解析|string + users_tag: 用户标签|string + users_picture: 用户头像附件的 attachments_id|string + users_picture_url: 根据 users_picture - tbl_attachments 自动解析出的头像文件流链接|string + users_id_pic_a: 证件正面附件的 attachments_id|string + users_id_pic_a_url: 根据 users_id_pic_a - tbl_attachments 自动解析出的文件流链接|string + users_id_pic_b: 证件反面附件的 attachments_id|string + users_id_pic_b_url: 根据 users_id_pic_b - tbl_attachments 自动解析出的文件流链接|string + users_title_picture: 资质附件的 attachments_id|string + users_title_picture_url: 根据 users_title_picture - tbl_attachments 自动解析出的文件流链接|string + openid: 全平台统一身份标识|string + company_id: 公司业务 id,存储 tbl_company.company_id|string + users_parent_id: 上级用户业务 id|string + users_promo_code: 推广码|string + usergroups_id: 用户组业务 id|string + company: + pb_id: PocketBase 记录主键 id|string + company_id: 公司业务 id,由数据库自动生成|string + company_name: 公司名称|string + company_type: 公司类型|string + company_entity: 公司法人|string + company_usci: 统一社会信用代码|string + company_nationality: 国家名称|string + company_nationality_code: 国家编码|string + company_province: 省份名称|string + company_province_code: 省份编码|string + company_city: 城市名称|string + company_city_code: 城市编码|string + company_district: 区/县名称|string + company_district_code: 区/县编码|string + company_postalcode: 邮政编码|string + company_add: 公司地址|string + company_status: 公司状态|string + company_level: 公司等级|string + company_owner_openid: 公司所有者 openid|string + company_remark: 备注|string + created: 记录创建时间|string + updated: 记录更新时间|string + created: 用户创建时间|string + updated: 用户更新时间|string + WechatLoginRequest: + type: object + required: + - users_wx_code + properties: + users_wx_code: + type: string + description: 微信小程序登录临时凭证 code + example: 0a1b2c3d4e5f6g + example: + users_wx_code: 微信小程序登录临时凭证 code|string + WechatProfileRequest: + type: object + properties: + users_name: + type: string + description: 用户姓名 / 昵称 + example: 张三 + users_phone_code: + type: string + description: 可选。若传入,服务端优先通过微信接口换取真实手机号并写入数据库 + example: 2b7d9f2e3c4a5b6d7e8f + users_phone: + type: string + description: 可选。未传 `users_phone_code` 时,可直接写入手机号 + example: "13800138000" + users_type: + type: string + description: 可选。用户类型;仅在传入非空值时更新 + example: 服务商 + company_id: + type: string + description: 可选。公司业务 id;仅在传入非空值时更新 + example: WX-COMPANY-10001 + users_tag: + type: string + description: 可选。用户标签;非空时才更新 + example: 核心客户 + users_picture: + type: string + description: 可选。用户头像附件的 `attachments_id` + example: ATT-1743123456789-abc123 + users_id_pic_a: + type: string + description: 可选。证件正面附件的 `attachments_id` + users_id_pic_b: + type: string + description: 可选。证件反面附件的 `attachments_id` + users_title_picture: + type: string + description: 可选。资质附件的 `attachments_id` + example: + users_name: 用户姓名 / 昵称|string + users_phone_code: 可选。若传入,服务端优先通过微信接口换取真实手机号并写入数据库|string + users_phone: 可选。未传 users_phone_code 时,可直接写入手机号|string + users_type: 可选。用户类型;仅在传入非空值时更新|string + company_id: 可选。公司业务 id;仅在传入非空值时更新|string + users_tag: 可选。用户标签;非空时才更新|string + users_picture: 可选。用户头像附件的 attachments_id|string + users_id_pic_a: 可选。证件正面附件的 attachments_id|string + users_id_pic_b: 可选。证件反面附件的 attachments_id|string + users_title_picture: 可选。资质附件的 attachments_id|string + AuthSuccessData: + type: object + properties: + status: + anyOf: + - type: string + enum: + - register_success + - login_success + - type: string + is_info_complete: + type: + - boolean + - string + user: + $ref: ../openapi-wx.yaml#/components/schemas/UserInfo + example: + status: status|string + is_info_complete: is_info_complete|boolean + user: + pb_id: PocketBase 记录主键 id|string + users_convers_id: 会话侧用户 ID|string + users_id: 用户业务 ID|string + users_idtype: users_idtype|string + users_id_number: 证件号|string + users_type: users_type|string + users_name: 用户姓名 / 昵称|string + users_status: 用户状态|string + users_rank_level: 用户星级数值|number + users_auth_type: 账户类型|number + users_phone: 手机号|string + users_phone_masked: users_phone_masked|string + users_level: 用户等级|string + users_level_name: 用户等级名称,按 users_level - 数据-会员等级 字典描述实时解析|string + users_tag: 用户标签|string + users_picture: 用户头像附件的 attachments_id|string + users_picture_url: 根据 users_picture - tbl_attachments 自动解析出的头像文件流链接|string + users_id_pic_a: 证件正面附件的 attachments_id|string + users_id_pic_a_url: 根据 users_id_pic_a - tbl_attachments 自动解析出的文件流链接|string + users_id_pic_b: 证件反面附件的 attachments_id|string + users_id_pic_b_url: 根据 users_id_pic_b - tbl_attachments 自动解析出的文件流链接|string + users_title_picture: 资质附件的 attachments_id|string + users_title_picture_url: 根据 users_title_picture - tbl_attachments 自动解析出的文件流链接|string + openid: 全平台统一身份标识|string + company_id: 公司业务 id,存储 tbl_company.company_id|string + users_parent_id: 上级用户业务 id|string + users_promo_code: 推广码|string + usergroups_id: 用户组业务 id|string + company: + pb_id: PocketBase 记录主键 id|string + company_id: 公司业务 id,由数据库自动生成|string + company_name: 公司名称|string + company_type: 公司类型|string + company_entity: 公司法人|string + company_usci: 统一社会信用代码|string + company_nationality: 国家名称|string + company_nationality_code: 国家编码|string + company_province: 省份名称|string + company_province_code: 省份编码|string + company_city: 城市名称|string + company_city_code: 城市编码|string + company_district: 区/县名称|string + company_district_code: 区/县编码|string + company_postalcode: 邮政编码|string + company_add: 公司地址|string + company_status: 公司状态|string + company_level: 公司等级|string + company_owner_openid: 公司所有者 openid|string + company_remark: 备注|string + created: 记录创建时间|string + updated: 记录更新时间|string + created: 用户创建时间|string + updated: 用户更新时间|string + AuthSuccessResponse: + allOf: + - $ref: ../openapi-wx.yaml#/components/schemas/ApiResponseBase + - type: object + required: + - token + properties: + data: + description: 业务响应数据 + $ref: ../openapi-wx.yaml#/components/schemas/AuthSuccessData + token: + type: string + description: PocketBase 原生 auth token + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + status: status|string + is_info_complete: is_info_complete|boolean + user: + pb_id: PocketBase 记录主键 id|string + users_convers_id: 会话侧用户 ID|string + users_id: 用户业务 ID|string + users_idtype: users_idtype|string + users_id_number: 证件号|string + users_type: users_type|string + users_name: 用户姓名 / 昵称|string + users_status: 用户状态|string + users_rank_level: 用户星级数值|number + users_auth_type: 账户类型|number + users_phone: 手机号|string + users_phone_masked: users_phone_masked|string + users_level: 用户等级|string + users_level_name: 用户等级名称,按 users_level - 数据-会员等级 字典描述实时解析|string + users_tag: 用户标签|string + users_picture: 用户头像附件的 attachments_id|string + users_picture_url: 根据 users_picture - tbl_attachments 自动解析出的头像文件流链接|string + users_id_pic_a: 证件正面附件的 attachments_id|string + users_id_pic_a_url: 根据 users_id_pic_a - tbl_attachments 自动解析出的文件流链接|string + users_id_pic_b: 证件反面附件的 attachments_id|string + users_id_pic_b_url: 根据 users_id_pic_b - tbl_attachments 自动解析出的文件流链接|string + users_title_picture: 资质附件的 attachments_id|string + users_title_picture_url: 根据 users_title_picture - tbl_attachments 自动解析出的文件流链接|string + openid: 全平台统一身份标识|string + company_id: 公司业务 id,存储 tbl_company.company_id|string + users_parent_id: 上级用户业务 id|string + users_promo_code: 推广码|string + usergroups_id: 用户组业务 id|string + company: + pb_id: PocketBase 记录主键 id|string + company_id: 公司业务 id,由数据库自动生成|string + company_name: 公司名称|string + company_type: 公司类型|string + company_entity: 公司法人|string + company_usci: 统一社会信用代码|string + company_nationality: 国家名称|string + company_nationality_code: 国家编码|string + company_province: 省份名称|string + company_province_code: 省份编码|string + company_city: 城市名称|string + company_city_code: 城市编码|string + company_district: 区/县名称|string + company_district_code: 区/县编码|string + company_postalcode: 邮政编码|string + company_add: 公司地址|string + company_status: 公司状态|string + company_level: 公司等级|string + company_owner_openid: 公司所有者 openid|string + company_remark: 备注|string + created: 记录创建时间|string + updated: 记录更新时间|string + created: 用户创建时间|string + updated: 用户更新时间|string + token: PocketBase 原生 auth token|string + WechatProfileResponseData: + type: object + properties: + status: + anyOf: + - type: string + enum: + - update_success + - type: string + user: + $ref: ../openapi-wx.yaml#/components/schemas/UserInfo + example: + status: status|string + user: + pb_id: PocketBase 记录主键 id|string + users_convers_id: 会话侧用户 ID|string + users_id: 用户业务 ID|string + users_idtype: users_idtype|string + users_id_number: 证件号|string + users_type: users_type|string + users_name: 用户姓名 / 昵称|string + users_status: 用户状态|string + users_rank_level: 用户星级数值|number + users_auth_type: 账户类型|number + users_phone: 手机号|string + users_phone_masked: users_phone_masked|string + users_level: 用户等级|string + users_level_name: 用户等级名称,按 users_level - 数据-会员等级 字典描述实时解析|string + users_tag: 用户标签|string + users_picture: 用户头像附件的 attachments_id|string + users_picture_url: 根据 users_picture - tbl_attachments 自动解析出的头像文件流链接|string + users_id_pic_a: 证件正面附件的 attachments_id|string + users_id_pic_a_url: 根据 users_id_pic_a - tbl_attachments 自动解析出的文件流链接|string + users_id_pic_b: 证件反面附件的 attachments_id|string + users_id_pic_b_url: 根据 users_id_pic_b - tbl_attachments 自动解析出的文件流链接|string + users_title_picture: 资质附件的 attachments_id|string + users_title_picture_url: 根据 users_title_picture - tbl_attachments 自动解析出的文件流链接|string + openid: 全平台统一身份标识|string + company_id: 公司业务 id,存储 tbl_company.company_id|string + users_parent_id: 上级用户业务 id|string + users_promo_code: 推广码|string + usergroups_id: 用户组业务 id|string + company: + pb_id: PocketBase 记录主键 id|string + company_id: 公司业务 id,由数据库自动生成|string + company_name: 公司名称|string + company_type: 公司类型|string + company_entity: 公司法人|string + company_usci: 统一社会信用代码|string + company_nationality: 国家名称|string + company_nationality_code: 国家编码|string + company_province: 省份名称|string + company_province_code: 省份编码|string + company_city: 城市名称|string + company_city_code: 城市编码|string + company_district: 区/县名称|string + company_district_code: 区/县编码|string + company_postalcode: 邮政编码|string + company_add: 公司地址|string + company_status: 公司状态|string + company_level: 公司等级|string + company_owner_openid: 公司所有者 openid|string + company_remark: 备注|string + created: 记录创建时间|string + updated: 记录更新时间|string + created: 用户创建时间|string + updated: 用户更新时间|string + WechatProfileResponse: + allOf: + - $ref: ../openapi-wx.yaml#/components/schemas/ApiResponseBase + - type: object + properties: + data: + description: 业务响应数据 + $ref: ../openapi-wx.yaml#/components/schemas/WechatProfileResponseData + example: + statusCode: 业务状态码|integer + errMsg: 业务提示信息|string + data: + status: status|string + user: + pb_id: PocketBase 记录主键 id|string + users_convers_id: 会话侧用户 ID|string + users_id: 用户业务 ID|string + users_idtype: users_idtype|string + users_id_number: 证件号|string + users_type: users_type|string + users_name: 用户姓名 / 昵称|string + users_status: 用户状态|string + users_rank_level: 用户星级数值|number + users_auth_type: 账户类型|number + users_phone: 手机号|string + users_phone_masked: users_phone_masked|string + users_level: 用户等级|string + users_level_name: 用户等级名称,按 users_level - 数据-会员等级 字典描述实时解析|string + users_tag: 用户标签|string + users_picture: 用户头像附件的 attachments_id|string + users_picture_url: 根据 users_picture - tbl_attachments 自动解析出的头像文件流链接|string + users_id_pic_a: 证件正面附件的 attachments_id|string + users_id_pic_a_url: 根据 users_id_pic_a - tbl_attachments 自动解析出的文件流链接|string + users_id_pic_b: 证件反面附件的 attachments_id|string + users_id_pic_b_url: 根据 users_id_pic_b - tbl_attachments 自动解析出的文件流链接|string + users_title_picture: 资质附件的 attachments_id|string + users_title_picture_url: 根据 users_title_picture - tbl_attachments 自动解析出的文件流链接|string + openid: 全平台统一身份标识|string + company_id: 公司业务 id,存储 tbl_company.company_id|string + users_parent_id: 上级用户业务 id|string + users_promo_code: 推广码|string + usergroups_id: 用户组业务 id|string + company: + pb_id: PocketBase 记录主键 id|string + company_id: 公司业务 id,由数据库自动生成|string + company_name: 公司名称|string + company_type: 公司类型|string + company_entity: 公司法人|string + company_usci: 统一社会信用代码|string + company_nationality: 国家名称|string + company_nationality_code: 国家编码|string + company_province: 省份名称|string + company_province_code: 省份编码|string + company_city: 城市名称|string + company_city_code: 城市编码|string + company_district: 区/县名称|string + company_district_code: 区/县编码|string + company_postalcode: 邮政编码|string + company_add: 公司地址|string + company_status: 公司状态|string + company_level: 公司等级|string + company_owner_openid: 公司所有者 openid|string + company_remark: 备注|string + created: 记录创建时间|string + updated: 记录更新时间|string + created: 用户创建时间|string + updated: 用户更新时间|string + CompanyInfo: + anyOf: + - type: object + description: 用户所属公司信息;当用户尚未绑定公司时返回 `null` + properties: + pb_id: + type: string + description: PocketBase 记录主键 id + example: PocketBase记录主键id | string + company_id: + type: string + description: 公司业务 id,由数据库自动生成 + example: 公司业务id,由数据库自动生成 | string + company_name: + type: string + description: 公司名称 + example: 公司名称 | string + company_type: + type: string + description: 公司类型 + example: 公司类型 | string + company_entity: + type: string + description: 公司法人 + example: 公司法人 | string + company_usci: + type: string + description: 统一社会信用代码 + example: 统一社会信用代码 | string + company_nationality: + type: string + description: 国家名称 + example: 国家名称 | string + company_nationality_code: + type: string + description: 国家编码 + example: 国家编码 | string + company_province: + type: string + description: 省份名称 + example: 省份名称 | string + company_province_code: + type: string + description: 省份编码 + example: 省份编码 | string + company_city: + type: string + description: 城市名称 + example: 城市名称 | string + company_city_code: + type: string + description: 城市编码 + example: 城市编码 | string + company_district: + type: string + description: 区/县名称 + example: 区县名称 | string + company_district_code: + type: string + description: 区/县编码 + example: 区县编码 | string + company_postalcode: + type: string + description: 邮政编码 + example: 邮政编码 | string + company_add: + type: string + description: 公司地址 + example: 公司地址 | string + company_status: + type: string + description: 公司状态 + example: 公司状态 | string + company_level: + type: string + description: 公司等级 + example: 公司等级 | string + company_owner_openid: + type: string + description: 公司所有者 openid + example: 公司所有者openid | string + company_remark: + type: string + description: 备注 + example: 备注 | string + created: + type: string + description: 记录创建时间 + example: 记录创建时间 | string + updated: + type: string + description: 记录更新时间 + example: 记录更新时间 | string + example: + pb_id: PocketBase记录主键id | string + company_id: 公司业务id,由数据库自动生成 | string + company_name: 公司名称 | string + company_type: 公司类型 | string + company_entity: 公司法人 | string + company_usci: 统一社会信用代码 | string + company_nationality: 国家名称 | string + company_nationality_code: 国家编码 | string + company_province: 省份名称 | string + company_province_code: 省份编码 | string + company_city: 城市名称 | string + company_city_code: 城市编码 | string + company_district: 区县名称 | string + company_district_code: 区县编码 | string + company_postalcode: 邮政编码 | string + company_add: 公司地址 | string + company_status: 公司状态 | string + company_level: 公司等级 | string + company_owner_openid: 公司所有者openid | string + company_remark: 备注 | string + created: 记录创建时间 | string + updated: 记录更新时间 | string + - type: "null" + example: + pb_id: PocketBase 记录主键 id|string + company_id: 公司业务 id,由数据库自动生成|string + company_name: 公司名称|string + company_type: 公司类型|string + company_entity: 公司法人|string + company_usci: 统一社会信用代码|string + company_nationality: 国家名称|string + company_nationality_code: 国家编码|string + company_province: 省份名称|string + company_province_code: 省份编码|string + company_city: 城市名称|string + company_city_code: 城市编码|string + company_district: 区/县名称|string + company_district_code: 区/县编码|string + company_postalcode: 邮政编码|string + company_add: 公司地址|string + company_status: 公司状态|string + company_level: 公司等级|string + company_owner_openid: 公司所有者 openid|string + company_remark: 备注|string + created: 记录创建时间|string + updated: 记录更新时间|string