37 lines
1022 B
TypeScript
37 lines
1022 B
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
import { Repository } from 'typeorm';
|
|
import { CreateChickenDto } from './dto/create-chicken.dto';
|
|
import { UpdateChickenDto } from './dto/update-chicken.dto';
|
|
import { ChickenEntity } from './entities/chicken.entity';
|
|
|
|
@Injectable()
|
|
export class ChickensService {
|
|
constructor(
|
|
@InjectRepository(ChickenEntity)
|
|
private readonly chickensRepository: Repository<ChickenEntity>
|
|
) { }
|
|
|
|
/**插入数据 */
|
|
async create(createChickenDto: CreateChickenDto) {
|
|
createChickenDto.create_time = new Date();
|
|
return await this.chickensRepository.save(createChickenDto);
|
|
}
|
|
|
|
findAll() {
|
|
return `This action returns all chickens`;
|
|
}
|
|
|
|
findOne(id: number) {
|
|
return `This action returns a #${id} chicken`;
|
|
}
|
|
|
|
update(id: number, updateChickenDto: UpdateChickenDto) {
|
|
return `This action updates a #${id} chicken`;
|
|
}
|
|
|
|
remove(id: number) {
|
|
return `This action removes a #${id} chicken`;
|
|
}
|
|
}
|