update
This commit is contained in:
@ -18,18 +18,33 @@ export class ResponsiblePartyConsentController {
|
||||
/*
|
||||
#swagger.tags = ['Responsible Party Consent']
|
||||
#swagger.security = [{ "bearerAuth": [] }]
|
||||
#swagger.parameters['type'] = { in: 'query', required: false, type: 'string' }
|
||||
*/
|
||||
try {
|
||||
const data = await OrmHelper.DB.getRepository(ResponsiblePartyConsent)
|
||||
.createQueryBuilder("ResponsiblePartyConsent")
|
||||
.getMany();
|
||||
const schema = Joi.object({
|
||||
type: Joi.string().optional().allow("").label("Type"),
|
||||
});
|
||||
|
||||
const count_data = data.length;
|
||||
const current_page = 1;
|
||||
const total_count_data = count_data;
|
||||
const mapped_data = data;
|
||||
const { type } = await schema.validateAsync(req.query);
|
||||
|
||||
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, current_page, total_count_data, mapped_data);
|
||||
let query = OrmHelper.DB.getRepository(ResponsiblePartyConsent)
|
||||
.createQueryBuilder("ResponsiblePartyConsent");
|
||||
|
||||
if (type && type !== "") {
|
||||
query = query.where("ResponsiblePartyConsent.type = :type", { type });
|
||||
}
|
||||
|
||||
const data = await query.getMany();
|
||||
|
||||
return ReturnHelper.successResponselist(
|
||||
res,
|
||||
200,
|
||||
Language.lang.success_view,
|
||||
data.length,
|
||||
1,
|
||||
data.length,
|
||||
data
|
||||
);
|
||||
} catch (e: unknown) {
|
||||
log.error(e);
|
||||
const err = e as Error;
|
||||
|
||||
Reference in New Issue
Block a user