Service interface bu controller frontenddan olgan so‘rovlar ustida ishlash va unga mos javob qaytarish uchun foydalaniladi




Download 2,32 Mb.
bet32/32
Sana08.07.2024
Hajmi2,32 Mb.
#267039
1   ...   24   25   26   27   28   29   30   31   32
Bog'liq
Miraxmedov Xusanboy BMI

Service interface bu controller frontenddan olgan so‘rovlar ustida ishlash va unga mos javob qaytarish uchun foydalaniladi.
import ErrorResponse from '../shared/utils/errorResponse';
import OrdersDao from './dao/orders.dao';
import { IOrder } from './interface/orders.interface';
export default class OrdersService {
private dao = new OrdersDao();
async create(values: IOrder) {
return await this.dao.create(values);
}
async getAll(page: number, limit: number, search?: string) {
return await this.dao.getAll(page, limit, search);
}
async findOne(uid: number) {
const order = await this.dao.findOne(uid);
if (!order[0]) throw new ErrorResponse(404, 'Order not found');
return order[0];
}
async update(uid: number, status: string) {
const order = await this.dao.findOne(uid);
if (!order) throw new ErrorResponse(404, 'Order not found');
return await this.dao.update(uid, status);
}
async delete(id: string) {
return await this.dao.delete(id);
}
}



Download 2,32 Mb.
1   ...   24   25   26   27   28   29   30   31   32




Download 2,32 Mb.

Bosh sahifa
Aloqalar

    Bosh sahifa



Service interface bu controller frontenddan olgan so‘rovlar ustida ishlash va unga mos javob qaytarish uchun foydalaniladi

Download 2,32 Mb.