update hard delete to all module
This commit is contained in:
@ -325,17 +325,24 @@ export class AldeiaController {
|
||||
required: true,
|
||||
type: 'string'
|
||||
}
|
||||
#swagger.parameters['hard'] = {
|
||||
in: 'path',
|
||||
description: 'Is Hard Delete',
|
||||
required: false,
|
||||
type: 'boolean'
|
||||
}
|
||||
*/
|
||||
try {
|
||||
const schema = Joi.object().keys({
|
||||
id: Joi.string().uuid().required().label('ID')
|
||||
id: Joi.string().uuid().required().label('ID'),
|
||||
hard: Joi.bool().optional().allow('').label('Is hard delete?')
|
||||
});
|
||||
|
||||
const param: Aldeia = await schema.validateAsync(req.params);
|
||||
const param: { id: string, hard: boolean } = await schema.validateAsync(req.params);
|
||||
|
||||
const repo = OrmHelper.DB.getRepository(Aldeia);
|
||||
|
||||
const affected = (await repo.softDelete({ id: param.id })).affected;
|
||||
const affected = (!param.hard ? await repo.softDelete({ id: param.id }) : await repo.delete({ id: param.id })).affected;
|
||||
|
||||
if (affected > 0) {
|
||||
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_delete, {});
|
||||
|
||||
Reference in New Issue
Block a user