29 lines
666 B
JavaScript
29 lines
666 B
JavaScript
/// modules/center/dto.js
|
|
const { toAbsoluteUrl } = require('../../utils/url');
|
|
|
|
const toDto = (row) => ({
|
|
id: row.id,
|
|
name: row.name,
|
|
slug: row.slug,
|
|
icon: row.icon || '',
|
|
iconImage: toAbsoluteUrl(row.icon_image || ''),
|
|
intro: row.intro || '',
|
|
image: toAbsoluteUrl(row.image || ''),
|
|
sort: Number(row.sort || 0),
|
|
enabled: row.enabled === 1 || row.enabled === true,
|
|
createdAt: row.created_at
|
|
});
|
|
|
|
const toCreateDto = (body) => ({
|
|
name: body.name,
|
|
slug: body.slug,
|
|
icon: body.icon,
|
|
iconImage: body.iconImage,
|
|
intro: body.intro,
|
|
image: body.image,
|
|
sort: body.sort,
|
|
enabled: body.enabled
|
|
});
|
|
|
|
module.exports = { toDto, toCreateDto };
|