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> {
|
||||
/*
|
||||
#swagger.tags = ['Pharmacy - ItemMaster']
|
||||
@ -110,7 +131,7 @@ export class ItemMasterController {
|
||||
|
||||
var query = await ItemMasterModel.list(filter);
|
||||
const data = await query.getMany();
|
||||
|
||||
|
||||
const filename = "item_master.csv";
|
||||
|
||||
res.setHeader('Content-Type', 'text/csv');
|
||||
|
||||
@ -110,7 +110,7 @@ export class UnitController {
|
||||
|
||||
var query = await UnitModel.list(filter);
|
||||
const data = await query.getMany();
|
||||
|
||||
|
||||
const filename = "unit.csv";
|
||||
|
||||
res.setHeader('Content-Type', 'text/csv');
|
||||
@ -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'];
|
||||
|
||||
Reference in New Issue
Block a user