update
Some checks failed
Deploy Backend / deploy (push) Has been cancelled

This commit is contained in:
wayanrivan
2026-07-07 11:40:33 +07:00
parent 68edf04a4b
commit fa08e2d552
2 changed files with 44 additions and 0 deletions

View File

@ -674,6 +674,49 @@ export class UserController {
} }
} }
static async profile(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: any = await schema.validateAsync({ id: req.params["id"] });
const userRepository = OrmHelper.DB.getRepository(User);
const data = await userRepository.findOneBy({ id: param.id });
if (data != null) {
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_view, data);
} else {
return ReturnHelper.errorResponse(res, 404, 401, Language.lang.failed_not_found, "");
}
} catch (e: unknown) {
if (e instanceof Error) {
log.error(e.message, e.stack);
} else {
log.error(JSON.stringify(e));
}
const err = e as Error;
return ReturnHelper.errorResponse(res, 500, 402, Language.lang.failed_view, err.message);
}
}
static async delete(req: Request, res: Response, next: NextFunction): Promise<Response> { static async delete(req: Request, res: Response, next: NextFunction): Promise<Response> {
/* /*
#swagger.tags = ['User'] #swagger.tags = ['User']

View File

@ -21,6 +21,7 @@ export class RoutePrivate {
app.put('/api/user/update_password', UserController.updatePassword) app.put('/api/user/update_password', UserController.updatePassword)
app.delete('/api/user/delete/:id/:hard', UserController.delete) app.delete('/api/user/delete/:id/:hard', UserController.delete)
app.put('/api/user/restore/:id', UserController.restore) app.put('/api/user/restore/:id', UserController.restore)
app.get('/api/user/profile/:id', UserController.profile)
// app.get('/api/user_role/list', UserRoleController.list) // app.get('/api/user_role/list', UserRoleController.list)
// app.get('/api/user_role/export', UserRoleController.export) // app.get('/api/user_role/export', UserRoleController.export)