role เมนู ลูกจ้างประจำ กทม.

This commit is contained in:
AdisakKanthawilang 2024-08-23 16:28:31 +07:00
parent 359d22beec
commit 7237c68cb8
23 changed files with 327 additions and 155 deletions

View file

@ -77,14 +77,15 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyCouple(@Path() profileEmployeeId: string) {
public async getFamilyCouple(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
const profile = await this.profileRepo.findOne({
where: { id: profileEmployeeId },
});
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profile.id);
const familyCouple = await this.ProfileFamilyCouple.findOne({
select: [
"id",
@ -176,13 +177,14 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
},
],
})
public async familyCoupleHistory(@Path() profileEmployeeId: string) {
public async familyCoupleHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
const profile = await this.profileRepo.findOne({
where: { id: profileEmployeeId },
});
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profile.id);
const familyCouple = await this.ProfileFamilyCouple.find({
relations: ["histories"],
@ -220,7 +222,6 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
@Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeFamilyCouple,
) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_EMP");
const familyCouple = Object.assign(new ProfileFamilyCouple(), body);
if (!familyCouple) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -229,6 +230,8 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id);
familyCouple.coupleCitizenId = Extension.CheckCitizen(String(body.coupleCitizenId));
familyCouple.createdUserId = req.user.sub;
familyCouple.createdFullName = req.user.name;
@ -253,7 +256,7 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
@Body() body: UpdateProfileFamilyCouple,
@Path() profileEmployeeId: string,
) {
await new permission().PermissionUpdate(req, "SYS_REGISTRY_EMP");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profileEmployeeId)
const familyCouple = await this.ProfileFamilyCouple.findOneBy({
profileEmployeeId: profileEmployeeId,
});