|
@@ -0,0 +1,30 @@
|
|
|
|
|
+import { Injectable } from '@nestjs/common';
|
|
|
|
|
+import { CreatePetRequest } from '@/pet-feeder/dto/create-pet.request';
|
|
|
|
|
+import { InjectRepository } from '@nestjs/typeorm';
|
|
|
|
|
+import { Pet } from '@/pet-feeder/entity/pet.entity';
|
|
|
|
|
+import { Repository } from 'typeorm';
|
|
|
|
|
+
|
|
|
|
|
+@Injectable()
|
|
|
|
|
+export class PetService {
|
|
|
|
|
+ constructor(
|
|
|
|
|
+ @InjectRepository(Pet)
|
|
|
|
|
+ private readonly petRepository: Repository<Pet>,
|
|
|
|
|
+ ) {}
|
|
|
|
|
+
|
|
|
|
|
+ async create(createPetRequest: CreatePetRequest): Promise<Pet> {
|
|
|
|
|
+ const pet = this.petRepository.create({
|
|
|
|
|
+ name: createPetRequest.name,
|
|
|
|
|
+ type: createPetRequest.type,
|
|
|
|
|
+ gender: createPetRequest.gender,
|
|
|
|
|
+ birthday: createPetRequest.birthday,
|
|
|
|
|
+ weight: createPetRequest.weight,
|
|
|
|
|
+ photo: createPetRequest.photo,
|
|
|
|
|
+ isActive: createPetRequest.isActive,
|
|
|
|
|
+ isPregnant: createPetRequest.isPregnant,
|
|
|
|
|
+ isSterilization: createPetRequest.isSterilization,
|
|
|
|
|
+ isLactation: createPetRequest.isLactation,
|
|
|
|
|
+ bodyType: createPetRequest.bodyType,
|
|
|
|
|
+ });
|
|
|
|
|
+ return this.petRepository.save(pet);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|