update hard delete service user
This commit is contained in:
@ -30,7 +30,7 @@
|
||||
"auth": {
|
||||
"refresh_token_lifetime_day": 30,
|
||||
"access_token_lifetime": 86400,
|
||||
"reset_password_url": "https://bri-dev.shiblysolution.id/reset-password/"
|
||||
"reset_password_url": "https://bri-dev.shiblysolution.id/auth/reset-password/"
|
||||
},
|
||||
"service": {
|
||||
"notification": "http://127.0.0.1:4008/"
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
"auth": {
|
||||
"refresh_token_lifetime_day": 30,
|
||||
"access_token_lifetime": 86400,
|
||||
"reset_password_url": "https://bri-dev.shiblysolution.id/reset-password/"
|
||||
"reset_password_url": "https://bri-dev.shiblysolution.id/auth/reset-password/"
|
||||
},
|
||||
"service": {
|
||||
"notification": "http://127.0.0.1:4008/"
|
||||
|
||||
@ -459,17 +459,24 @@ export class UserController {
|
||||
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: User = await schema.validateAsync(req.params);
|
||||
const param: { id: string, hard: boolean } = await schema.validateAsync(req.params);
|
||||
|
||||
const userRepository = OrmHelper.DB.getRepository(User);
|
||||
|
||||
const affected = (await userRepository.softDelete({ id: param.id })).affected;
|
||||
const affected = (!param.hard ? await userRepository.softDelete({ id: param.id }) : await userRepository.delete({ id: param.id })).affected;
|
||||
|
||||
if (affected > 0) {
|
||||
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_delete, {});
|
||||
|
||||
@ -350,13 +350,20 @@ export class UserRoleController {
|
||||
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: UserRole = await schema.validateAsync(req.params);
|
||||
const param: { id: string, hard: boolean } = await schema.validateAsync(req.params);
|
||||
|
||||
const repo_role = OrmHelper.DB.getRepository(UserRole);
|
||||
const repo_user = OrmHelper.DB.getRepository(User);
|
||||
@ -364,7 +371,7 @@ export class UserRoleController {
|
||||
const check_used = await repo_user.findOneBy({ id_role: param.id })
|
||||
|
||||
if (check_used == null) {
|
||||
const affected = (await repo_role.softDelete({ id: param.id })).affected;
|
||||
const affected = (!param.hard ? await repo_role.softDelete({ id: param.id }) : await repo_role.delete({ id: param.id })).affected;
|
||||
|
||||
if (affected > 0) {
|
||||
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_delete, {});
|
||||
|
||||
@ -20,7 +20,7 @@ export class RoutePrivate {
|
||||
app.put('/api/user/update_profile', UserController.updateProfile)
|
||||
app.put('/api/user/update_password', UserController.updatePassword)
|
||||
app.get('/api/user/detail/:id', UserController.detail)
|
||||
app.delete('/api/user/delete/:id', UserController.delete)
|
||||
app.delete('/api/user/delete/:id/:hard', UserController.delete)
|
||||
app.put('/api/user/restore/:id', UserController.restore)
|
||||
|
||||
app.get('/api/user_role/list', UserRoleController.list)
|
||||
@ -28,7 +28,7 @@ export class RoutePrivate {
|
||||
// app.get('/api/user_role/role', UserRoleController.role)
|
||||
app.post('/api/user_role/create', UserRoleController.create)
|
||||
app.put('/api/user_role/update/:id', UserRoleController.update)
|
||||
app.delete('/api/user_role/delete/:id', UserRoleController.delete)
|
||||
app.delete('/api/user_role/delete/:id/:hard', UserRoleController.delete)
|
||||
app.put('/api/user_role/restore/:id', UserRoleController.restore)
|
||||
|
||||
app.get('/api/user_activity/list', UserActivityController.list)
|
||||
|
||||
@ -20,11 +20,17 @@ const doc = {
|
||||
$password: "123456"
|
||||
},
|
||||
user: {
|
||||
$nik: "123456789",
|
||||
$email: "admin@gmail.com",
|
||||
$username: "admin",
|
||||
$password: "123456",
|
||||
$retype_password: "123456",
|
||||
$name: "Administrator",
|
||||
$phone: "08123456789",
|
||||
$jabatan: "4a6991b6-78a0-4b3b-bf5c-fa0af5f69be8",
|
||||
$organisasi: "4a6991b6-78a0-4b3b-bf5c-fa0af5f69be8",
|
||||
$divisi: "4a6991b6-78a0-4b3b-bf5c-fa0af5f69be8",
|
||||
$unit: "4a6991b6-78a0-4b3b-bf5c-fa0af5f69be8",
|
||||
$id_role: "4a6991b6-78a0-4b3b-bf5c-fa0af5f69be8",
|
||||
$status: "Y"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user