role เมนู ลูกจ้างประจำ กทม.
This commit is contained in:
parent
359d22beec
commit
7237c68cb8
23 changed files with 327 additions and 155 deletions
|
|
@ -83,7 +83,8 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
|||
},
|
||||
],
|
||||
})
|
||||
public async getInsignia(@Path() profileEmployeeId: string) {
|
||||
public async getInsignia(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||
const record = await this.insigniaRepo.find({
|
||||
relations: {
|
||||
insignia: {
|
||||
|
|
@ -150,7 +151,11 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
|||
},
|
||||
],
|
||||
})
|
||||
public async getInsigniaHistory(@Path() InsigniaId: string) {
|
||||
public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
||||
}
|
||||
const record = await this.insigniaHistoryRepo.find({
|
||||
relations: {
|
||||
insignia: {
|
||||
|
|
@ -169,16 +174,15 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
|||
@Request() req: RequestWithUser,
|
||||
@Body() body: CreateProfileEmployeeInsignia,
|
||||
) {
|
||||
await new permission().PermissionCreate(req, "SYS_REGISTRY_EMP");
|
||||
if (!body.profileEmployeeId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
|
||||
}
|
||||
|
||||
const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId });
|
||||
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id)
|
||||
|
||||
const insignia = await this.insigniaMetaRepo.findOne({
|
||||
where: { id: body.insigniaId },
|
||||
|
|
@ -213,10 +217,9 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
|||
@Body() body: UpdateProfileInsignia,
|
||||
@Path() insigniaId: string,
|
||||
) {
|
||||
await new permission().PermissionUpdate(req, "SYS_REGISTRY_EMP");
|
||||
const record = await this.insigniaRepo.findOneBy({ id: insigniaId });
|
||||
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId)
|
||||
|
||||
const insignia = await this.insigniaMetaRepo.findOne({
|
||||
where: { id: body.insigniaId },
|
||||
|
|
@ -245,7 +248,11 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
|||
|
||||
@Delete("{insigniaId}")
|
||||
public async deleteInsignia(@Path() insigniaId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_EMP");
|
||||
const _record = await this.insigniaRepo.findOneBy({ id: insigniaId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
||||
}
|
||||
|
||||
await this.insigniaHistoryRepo.delete({
|
||||
profileInsigniaId: insigniaId,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue