import { Service } from 'typedi' ; import { OrmRepository } from 'typeorm-typedi-extensions' ; import { Logger , LoggerInterface } from '../../decorators/Logger' ; import { CustomerWishlist } from '../models/CustomerWishlist' ; import { CustomerWishlistRepository } from '../repositories/CustomerWishlistRepository' ; @ Service ( ) export class CustomerWishlistService { constructor ( @ OrmRepository ( ) private customerWishlistRepository , @ Logger ( __filename ) private log ) { } public async create ( productdata ) { this . log . info ( 'create a wishlist product' ) ; return this . customerWishlistRepository . save ( productdata ) ; } public findOne ( customer ) { return this . customerWishlistRepository . findOne ( customer ) ; } public async delete ( id ) { this . log . info ( 'delete a wishlist product' ) ; return await this . customerWishlistRepository . delete ( id ) ; } public list ( limit , offset , select = [ ] , whereConditions = [ ] , count ) { const condition = { } ; if ( select && select . length > 0 ) { condition . select = select ; } if ( whereConditions && whereConditions . length > 0 ) { condition . where = whereConditions ; } if ( limit && limit > 0 ) { condition . take = limit ; condition . skip = offset ; } console . log ( condition ) ; if ( count ) { return this . customerWishlistRepository . count ( condition ) ; } return this . customerWishlistRepository . find ( condition ) ; } public async find ( customerId ) { this . log . info ( 'Find a customer' ) ; return this . customerWishlistRepository . find ( customerId ) ; } }