role เมนู ลูกจ้างประจำ กทม.
This commit is contained in:
parent
359d22beec
commit
7237c68cb8
23 changed files with 327 additions and 155 deletions
|
|
@ -49,7 +49,8 @@ export class ProfileChildrenEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Get("{profileEmployeeId}")
|
||||
public async getChildren(@Path() profileEmployeeId: string) {
|
||||
public async getChildren(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||
const lists = await this.childrenRepository.find({
|
||||
where: { profileEmployeeId: profileEmployeeId },
|
||||
});
|
||||
|
|
@ -57,7 +58,12 @@ export class ProfileChildrenEmployeeController 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_EMP", _record.profileEmployeeId,
|
||||
);
|
||||
}
|
||||
const record = await this.childrenHistoryRepository.find({
|
||||
where: { profileChildrenId: childrenId },
|
||||
order: { createdAt: "DESC" },
|
||||
|
|
@ -70,12 +76,11 @@ export class ProfileChildrenEmployeeController extends Controller {
|
|||
@Request() req: RequestWithUser,
|
||||
@Body() body: CreateProfileChildrenEmployee,
|
||||
) {
|
||||
await new permission().PermissionCreate(req, "SYS_REGISTRY_EMP");
|
||||
const profile = await this.profileRepository.findOneBy({ id: body.profileEmployeeId });
|
||||
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id);
|
||||
|
||||
const data = new ProfileChildren();
|
||||
|
||||
|
|
@ -105,10 +110,10 @@ export class ProfileChildrenEmployeeController extends Controller {
|
|||
@Body() body: UpdateProfileChildren,
|
||||
@Path() childrenId: string,
|
||||
) {
|
||||
await new permission().PermissionUpdate(req, "SYS_REGISTRY_EMP");
|
||||
const record = await this.childrenRepository.findOneBy({ id: childrenId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId);
|
||||
|
||||
const history = new ProfileChildrenHistory();
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, body);
|
||||
|
|
@ -132,7 +137,10 @@ export class ProfileChildrenEmployeeController extends Controller {
|
|||
|
||||
@Delete("{childrenId}")
|
||||
public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_EMP");
|
||||
const _record = await this.childrenRepository.findOneBy({ id: childrenId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
||||
}
|
||||
await this.childrenHistoryRepository.delete({
|
||||
profileChildrenId: childrenId,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue