role เมนู ข้าราชการ กทม. สามัญ

This commit is contained in:
AdisakKanthawilang 2024-08-22 17:25:25 +07:00
parent edad154826
commit 4b42b896fa
22 changed files with 307 additions and 157 deletions

View file

@ -56,7 +56,8 @@ export class ProfileNopaidController extends Controller {
},
],
})
public async getNopaid(@Path() profileId: string) {
public async getNopaid(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const lists = await this.nopaidRepository.find({
where: { profileId },
});
@ -86,7 +87,11 @@ export class ProfileNopaidController extends Controller {
},
],
})
public async nopaidHistory(@Path() nopaidId: string) {
public async nopaidHistory(@Path() nopaidId: string, @Request() req: RequestWithUser) {
const _record = await this.nopaidRepository.findOneBy({ id: nopaidId });
if (_record) {
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_OFFICER", _record.profileId);
};
const record = await this.nopaidHistoryRepository.find({
where: { profileNopaidId: nopaidId },
order: { createdAt: "DESC" },
@ -96,16 +101,15 @@ export class ProfileNopaidController extends Controller {
@Post()
public async newNopaid(@Request() req: RequestWithUser, @Body() body: CreateProfileNopaid) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER");
if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
}
const profile = await this.profileRepository.findOneBy({ id: body.profileId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id);
const data = new ProfileNopaid();
@ -133,10 +137,9 @@ export class ProfileNopaidController extends Controller {
@Body() body: UpdateProfileNopaid,
@Path() nopaidId: string,
) {
await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER");
const record = await this.nopaidRepository.findOneBy({ id: nopaidId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId);
const history = new ProfileNopaidHistory();
@ -161,7 +164,10 @@ export class ProfileNopaidController extends Controller {
@Delete("{nopaidId}")
public async deleteNopaid(@Path() nopaidId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER");
const _record = await this.nopaidRepository.findOneBy({ id: nopaidId });
if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
}
await this.nopaidHistoryRepository.delete({
profileNopaidId: nopaidId,
});