Merge branch 'main' of https://git.shiblysolution.id/SAUDE-TL/service-master-data
This commit is contained in:
@ -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']
|
||||||
@ -110,7 +131,7 @@ export class ItemMasterController {
|
|||||||
|
|
||||||
var query = await ItemMasterModel.list(filter);
|
var query = await ItemMasterModel.list(filter);
|
||||||
const data = await query.getMany();
|
const data = await query.getMany();
|
||||||
|
|
||||||
const filename = "item_master.csv";
|
const filename = "item_master.csv";
|
||||||
|
|
||||||
res.setHeader('Content-Type', 'text/csv');
|
res.setHeader('Content-Type', 'text/csv');
|
||||||
|
|||||||
@ -110,7 +110,7 @@ export class UnitController {
|
|||||||
|
|
||||||
var query = await UnitModel.list(filter);
|
var query = await UnitModel.list(filter);
|
||||||
const data = await query.getMany();
|
const data = await query.getMany();
|
||||||
|
|
||||||
const filename = "unit.csv";
|
const filename = "unit.csv";
|
||||||
|
|
||||||
res.setHeader('Content-Type', 'text/csv');
|
res.setHeader('Content-Type', 'text/csv');
|
||||||
@ -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'];
|
||||||
|
|||||||
@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user