UNPKG

@opentiny/tiny-toolkit-pro

Version:

TinyPro Vue:开箱即用、前后端分离的 Vue 后台管理模板

33 lines (28 loc) 839 B
import { Injectable } from '@nestjs/common'; import { InjectModel } from '@nestjs/sequelize'; import { CreateEmployeeDto } from './dto/create-employee.dto'; import { Employee } from './models/employee.model'; @Injectable() export class EmployeesService { constructor( @InjectModel(Employee) private readonly employeeModel: typeof Employee ) {} async getEmployee(searchInfo): Promise<Employee[]> { try { const result = await this.employeeModel.findAll({ where: searchInfo }); return result; } catch (error) {} } findOne(id: string): Promise<Employee> { return this.employeeModel.findOne({ where: { id, }, }); } async remove(id: string): Promise<void> { const employee = await this.findOne(id); await employee.destroy(); } }