feat: add content management feature for superadmin

- Implemented API endpoint for fetching content list with filtering, sorting, and pagination.
- Added DTOs for content items and tenant information.
- Created frontend components for content management, including search and data table functionalities.
- Updated routing to include content management page.
- Enhanced the superadmin menu to navigate to the new content management section.
- Included necessary styles and scripts for the new content management interface.
This commit is contained in:
2025-12-24 16:24:50 +08:00
parent 568f5cda43
commit d60c1e9312
14 changed files with 1373 additions and 8 deletions

View File

@@ -7,6 +7,66 @@ function normalizeItems(items) {
}
export const ContentService = {
async listContents({
page,
limit,
id,
tenant_id,
tenant_code,
tenant_name,
user_id,
username,
keyword,
status,
visibility,
published_at_from,
published_at_to,
created_at_from,
created_at_to,
price_amount_min,
price_amount_max,
sortField,
sortOrder
} = {}) {
const iso = (d) => {
if (!d) return undefined;
const date = d instanceof Date ? d : new Date(d);
if (Number.isNaN(date.getTime())) return undefined;
return date.toISOString();
};
const query = {
page,
limit,
id,
tenant_id,
tenant_code,
tenant_name,
user_id,
username,
keyword,
status,
visibility,
published_at_from: iso(published_at_from),
published_at_to: iso(published_at_to),
created_at_from: iso(created_at_from),
created_at_to: iso(created_at_to),
price_amount_min,
price_amount_max
};
if (sortField && sortOrder) {
if (sortOrder === 1) query.asc = sortField;
if (sortOrder === -1) query.desc = sortField;
}
const data = await requestJson('/super/v1/contents', { query });
return {
page: data?.page ?? page ?? 1,
limit: data?.limit ?? limit ?? 10,
total: data?.total ?? 0,
items: normalizeItems(data?.items)
};
},
async listTenantContents(
tenantID,
{