mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-24 22:39:21 +00:00
43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
|
import { RequestHandler } from "../entities/RequestHandler";
|
||
|
import { UserHelper } from "../helpers/UserHelper";
|
||
|
import { User, UserPageStatus } from "../entities/User";
|
||
|
|
||
|
/**
|
||
|
* User information controller
|
||
|
*
|
||
|
* @author Pierre HUBERT
|
||
|
*/
|
||
|
|
||
|
export class UserController {
|
||
|
|
||
|
/**
|
||
|
* Get information about a single user
|
||
|
*/
|
||
|
public static async GetSingle(handler : RequestHandler) {
|
||
|
const userID = handler.postInt("userID");
|
||
|
const user = await UserHelper.GetUserInfo(userID);
|
||
|
|
||
|
if(!user)
|
||
|
handler.error(404, "Could not get user data!");
|
||
|
|
||
|
handler.send(UserController.UserToAPI(user));
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Get information about multiple users
|
||
|
*/
|
||
|
public static async GetMultiple(handler : RequestHandler) {
|
||
|
|
||
|
}
|
||
|
|
||
|
private static UserToAPI(user : User) : any {
|
||
|
return {
|
||
|
"userID": user.id,
|
||
|
"firstName": user.firstName,
|
||
|
"lastName": user.lastName,
|
||
|
"publicPage": user.pageStatus == UserPageStatus.PUBLIC,
|
||
|
"openPage": user.pageStatus == UserPageStatus.OPEN,
|
||
|
"virtualDirectory": user.virtualDirectory,
|
||
|
};
|
||
|
}
|
||
|
}
|