This commit is contained in:
wayanrivan
2026-03-11 15:35:35 +07:00
parent 5bae9e56f1
commit 143c80ef52
3 changed files with 52 additions and 26 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> {
/*
#swagger.tags = ['Pharmacy - ItemMaster']

View File

@ -173,6 +173,8 @@ export class UnitController {
try {
const schema = Joi.object().keys({
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);
@ -223,6 +225,8 @@ export class UnitController {
const schema = Joi.object().keys({
id: Joi.string().uuid().required().label('ID'),
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'];

View File

@ -345,6 +345,7 @@ export class RoutePrivate {
// 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/option', ItemMasterController.option)
app.get('/api/pharmacy/item-master/export', ItemMasterController.export)
app.post('/api/pharmacy/item-master/create', ItemMasterController.create)
app.put('/api/pharmacy/item-master/update/:id', ItemMasterController.update)