api จัดการผู้ใช้งาน

This commit is contained in:
Bright 2024-11-11 18:13:11 +07:00
parent 6320f4d7db
commit 855639bd7f
6 changed files with 335 additions and 46 deletions

View file

@ -7874,47 +7874,4 @@ export class ProfileController extends Controller {
]);
return new HttpSuccess();
}
/**
* API
*
* @summary (USER)
*
*/
@Get("keycloak/user")
async listUserKeycloak(
@Request() request: RequestWithUser,
@Query("page") page: number = 1,
@Query("pageSize") pageSize: number = 10,
@Query() keyword: string = "",
) {
// sort by org
const [profiles, total] = await this.profileRepo
.createQueryBuilder("profile")
.leftJoinAndSelect("profile.roleKeycloaks", "roleKeycloaks")
.where("profile.citizenId LIKE :citizenId", {
citizenId: `%${keyword}%`,
})
.andWhere(keyword != null && keyword != "" ? `profile.citizenId like '%${keyword}%'` : "1=1")
.andWhere(
keyword != null && keyword != ""
? `CONCAT(profile.prefix, profile.firstName," ",profile.lastName) like '%${keyword}%'`
: "1=1",
)
.skip((page - 1) * pageSize)
.take(pageSize)
.getManyAndCount();
const _profiles = profiles.map((_data) => ({
id: _data.id,
firstname: _data.firstName,
lastname: _data.lastName,
email: _data.email,
username: _data.citizenId,
citizenId: _data.citizenId,
roles: _data.roleKeycloaks,
enabled: _data.isActive,
}));
return new HttpSuccess({ data: _profiles, total });
}
}