import { Injectable } from '@nestjs/common' ; import { InjectRepository } from '@nestjs/typeorm' ; import { Goods } from './goods.entity' ; import { Repository , Equal , Like } from 'typeorm' ; import { CreateGoodDto } from './dto/create-good_dto' ; @ Injectable ( ) export class GoodsService { constructor ( @ InjectRepository ( Goods ) private readonly goodsRepository ) { } async findAll ( ) { return await this . goodsRepository . find ( { relations : [ 'type' ] , } ) ; } async searchGood ( val ) { const value = `%${ val }%` ; return await this . goodsRepository . findOne ( { relations : [ 'type' , 'type.details' ] , where : { title : Like ( value ) } , } ) ; } }