api-server/src/modules/focus-items/focus-items.service.ts

27 lines
723 B
TypeScript
Raw Normal View History

import { Injectable, NotFoundException } from '@nestjs/common';
import { FocusItemsRepository } from './focus-items.repository';
@Injectable()
export class FocusItemsService {
constructor(private readonly repository: FocusItemsRepository) {}
async findAll(userId: string, pagination?: { page?: number; limit?: number }) {
return this.repository.findAll(userId, pagination);
}
async create(userId: string, dto: any) {
return this.repository.create({ userId, ...dto });
}
async update(id: string, dto: any) {
return this.repository.update(id, dto);
}
async complete(id: string) {
return this.repository.update(id, {
status: 'completed',
completedAt: new Date(),
});
}
}