FastGPT/src/utils/adapt.ts
2023-03-25 23:02:55 +08:00

18 lines
492 B
TypeScript

import { formatPrice } from './user';
import dayjs from 'dayjs';
import type { BillSchema } from '../types/mongoSchema';
import type { UserBillType } from '@/types/user';
export const adaptBill = (bill: BillSchema): UserBillType => {
return {
id: bill._id,
type: bill.type,
userId: bill.userId,
chatId: bill.chatId,
time: dayjs(bill.time).format('YYYY/MM/DD HH:mm:ss'),
textLen: bill.textLen,
tokenLen: bill.tokenLen,
price: formatPrice(bill.price)
};
};