35 lines
1003 B
TypeScript
Executable File
35 lines
1003 B
TypeScript
Executable File
import { db, getRandomElement, getRandomIntInRange, getRandomTimeInterval, } from '@nice/common';
|
|
import dayjs from 'dayjs';
|
|
export interface DevDataCounts {
|
|
deptCount: number;
|
|
|
|
staffCount: number
|
|
termCount: number
|
|
}
|
|
export async function getCounts(): Promise<DevDataCounts> {
|
|
const counts = {
|
|
deptCount: await db.department.count(),
|
|
|
|
staffCount: await db.staff.count(),
|
|
termCount: await db.term.count(),
|
|
};
|
|
return counts;
|
|
}
|
|
export function capitalizeFirstLetter(string: string) {
|
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
}
|
|
export function getRandomImageLinks(count: number = 5): string[] {
|
|
const baseUrl = 'https://picsum.photos/200/300?random=';
|
|
const imageLinks: string[] = [];
|
|
|
|
for (let i = 0; i < count; i++) {
|
|
// 生成随机数以确保每个链接都是唯一的
|
|
const randomId = Math.floor(Math.random() * 1000);
|
|
imageLinks.push(`${baseUrl}${randomId}`);
|
|
}
|
|
|
|
return imageLinks;
|
|
}
|
|
|
|
|