role เมนู ข้าราชการ กทม. สามัญ
This commit is contained in:
parent
edad154826
commit
4b42b896fa
22 changed files with 307 additions and 157 deletions
|
|
@ -47,7 +47,8 @@ export class ProfileChildrenController extends Controller {
|
|||
}
|
||||
|
||||
@Get("{profileId}")
|
||||
public async getChildren(@Path() profileId: string) {
|
||||
public async getChildren(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const lists = await this.childrenRepository.find({
|
||||
where: { profileId: profileId },
|
||||
});
|
||||
|
|
@ -55,7 +56,11 @@ export class ProfileChildrenController extends Controller {
|
|||
}
|
||||
|
||||
@Get("history/{childrenId}")
|
||||
public async childrenHistory(@Path() childrenId: string) {
|
||||
public async childrenHistory(@Path() childrenId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.childrenRepository.findOneBy({ id: childrenId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
const record = await this.childrenHistoryRepository.find({
|
||||
where: { profileChildrenId: childrenId },
|
||||
order: { createdAt: "DESC" },
|
||||
|
|
@ -65,12 +70,11 @@ export class ProfileChildrenController extends Controller {
|
|||
|
||||
@Post()
|
||||
public async newChildren(@Request() req: RequestWithUser, @Body() body: CreateProfileChildren) {
|
||||
await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER");
|
||||
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 ProfileChildren();
|
||||
const meta = {
|
||||
|
|
@ -99,9 +103,9 @@ export class ProfileChildrenController extends Controller {
|
|||
@Body() body: UpdateProfileChildren,
|
||||
@Path() childrenId: string,
|
||||
) {
|
||||
await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER");
|
||||
const record = await this.childrenRepository.findOneBy({ id: childrenId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
|
||||
const history = new ProfileChildrenHistory();
|
||||
Object.assign(record, body);
|
||||
|
|
@ -125,7 +129,10 @@ export class ProfileChildrenController extends Controller {
|
|||
|
||||
@Delete("{childrenId}")
|
||||
public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER");
|
||||
const _record = await this.childrenRepository.findOneBy({ id: childrenId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
await this.childrenHistoryRepository.delete({
|
||||
profileChildrenId: childrenId,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue