This commit is contained in:
Muhammad Rayhan Ardiansyah
2026-03-11 16:13:55 +07:00
3 changed files with 28 additions and 2 deletions

View File

@ -68,6 +68,27 @@ export class ItemMasterController {
} }
} }
static async option(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
/*
#swagger.tags = ['Pharmacy - ItemMaster']
#swagger.security = [{ "bearerAuth": [] }]
*/
try {
const query = await ItemMasterModel.list(); // ← hapus await disini, karena list() return QueryBuilder
const total_count_data = await query.getCount();
const list_data = await query.getMany();
const count_data = CommonHelper.countObject(list_data);
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, 1, total_count_data, list_data);
} catch (e: unknown) {
log.error(e);
const err = e as Error;
return ReturnHelper.errorResponse(res, 400, 401, Language.lang.failed_view, err.message);
}
}
static async export(req: Request, res: Response, next: NextFunction): Promise<void | Response> { static async export(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
/* /*
#swagger.tags = ['Pharmacy - ItemMaster'] #swagger.tags = ['Pharmacy - ItemMaster']

View File

@ -173,6 +173,8 @@ export class UnitController {
try { try {
const schema = Joi.object().keys({ const schema = Joi.object().keys({
unit_name: Joi.string().max(256).required().label('Name'), unit_name: Joi.string().max(256).required().label('Name'),
small_unit: Joi.string().max(256).optional().allow('').label('Small Unit'),
large_unit: Joi.string().max(256).optional().allow('').label('Large Unit'),
}); });
const param: any = await schema.validateAsync(req.body); const param: any = await schema.validateAsync(req.body);
@ -223,6 +225,8 @@ export class UnitController {
const schema = Joi.object().keys({ const schema = Joi.object().keys({
id: Joi.string().uuid().required().label('ID'), id: Joi.string().uuid().required().label('ID'),
unit_name: Joi.string().max(256).required().label('Name'), unit_name: Joi.string().max(256).required().label('Name'),
small_unit: Joi.string().max(256).optional().allow('').label('Small Unit'),
large_unit: Joi.string().max(256).optional().allow('').label('Large Unit'),
}); });
req.body.id = req.params['id']; req.body.id = req.params['id'];

View File

@ -345,6 +345,7 @@ export class RoutePrivate {
// app.put('/api/pharmacy/factory-to-supplier/restore/:supplier_id', FactorytoSupplierController.restore) // app.put('/api/pharmacy/factory-to-supplier/restore/:supplier_id', FactorytoSupplierController.restore)
app.get('/api/pharmacy/item-master/list', ItemMasterController.list) app.get('/api/pharmacy/item-master/list', ItemMasterController.list)
app.get('/api/pharmacy/item-master/option', ItemMasterController.option)
app.get('/api/pharmacy/item-master/export', ItemMasterController.export) app.get('/api/pharmacy/item-master/export', ItemMasterController.export)
app.post('/api/pharmacy/item-master/create', ItemMasterController.create) app.post('/api/pharmacy/item-master/create', ItemMasterController.create)
app.put('/api/pharmacy/item-master/update/:id', ItemMasterController.update) app.put('/api/pharmacy/item-master/update/:id', ItemMasterController.update)