update user detail api
This commit is contained in:
@ -484,6 +484,43 @@ export class UserController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async detail(req: Request, res: Response, next: NextFunction): Promise<Response> {
|
||||||
|
/*
|
||||||
|
#swagger.tags = ['User']
|
||||||
|
#swagger.security = [{
|
||||||
|
"bearerAuth": []
|
||||||
|
}]
|
||||||
|
#swagger.parameters['id'] = {
|
||||||
|
in: 'path',
|
||||||
|
description: 'User ID.',
|
||||||
|
required: true,
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
try {
|
||||||
|
const schema = Joi.object().keys({
|
||||||
|
id: Joi.string().uuid().required().label('ID')
|
||||||
|
});
|
||||||
|
|
||||||
|
const param: User = await schema.validateAsync(req.params);
|
||||||
|
|
||||||
|
const userRepository = OrmHelper.DB.getRepository(User);
|
||||||
|
|
||||||
|
const detail = (await userRepository.findOneBy({ id: param.id }));
|
||||||
|
|
||||||
|
if (detail != null) {
|
||||||
|
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_view, detail);
|
||||||
|
} else {
|
||||||
|
return ReturnHelper.errorResponse(res, 404, 401, Language.lang.failed_not_found, "");
|
||||||
|
}
|
||||||
|
} catch (e: unknown) {
|
||||||
|
log.error(e);
|
||||||
|
const err = e as Error;
|
||||||
|
|
||||||
|
return ReturnHelper.errorResponse(res, 500, 402, Language.lang.failed_view, err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static async restore(req: Request, res: Response, next: NextFunction): Promise<Response> {
|
static async restore(req: Request, res: Response, next: NextFunction): Promise<Response> {
|
||||||
/*
|
/*
|
||||||
#swagger.tags = ['User']
|
#swagger.tags = ['User']
|
||||||
|
|||||||
@ -19,6 +19,7 @@ export class RoutePrivate {
|
|||||||
app.put('/api/user/update/:id', UserController.update)
|
app.put('/api/user/update/:id', UserController.update)
|
||||||
app.put('/api/user/update_profile', UserController.updateProfile)
|
app.put('/api/user/update_profile', UserController.updateProfile)
|
||||||
app.put('/api/user/update_password', UserController.updatePassword)
|
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', UserController.delete)
|
||||||
app.put('/api/user/restore/:id', UserController.restore)
|
app.put('/api/user/restore/:id', UserController.restore)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user