role เมนู ลูกจ้างประจำ กทม.
This commit is contained in:
parent
359d22beec
commit
7237c68cb8
23 changed files with 327 additions and 155 deletions
|
|
@ -48,7 +48,8 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Get("{profileId}")
|
||||
public async getSalaryEmployee(@Path() profileId: string) {
|
||||
public async getSalaryEmployee(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileId);
|
||||
const record = await this.salaryRepo.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
order: { order: "ASC" },
|
||||
|
|
@ -57,7 +58,11 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Get("history/{salaryId}")
|
||||
public async salaryHistory(@Path() salaryId: string) {
|
||||
public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
||||
}
|
||||
const record = await this.salaryHistoryRepo.findBy({
|
||||
profileSalaryId: salaryId,
|
||||
});
|
||||
|
|
@ -69,16 +74,15 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
@Request() req: RequestWithUser,
|
||||
@Body() body: CreateProfileSalaryEmployee,
|
||||
) {
|
||||
await new permission().PermissionCreate(req, "SYS_REGISTRY_EMP");
|
||||
if (!body.profileEmployeeId) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
|
||||
}
|
||||
|
||||
const profile = await this.profileRepo.findOneBy({ id: body.profileEmployeeId });
|
||||
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id);
|
||||
|
||||
const dest_item = await this.salaryRepo.findOne({
|
||||
where: { profileEmployeeId: body.profileEmployeeId },
|
||||
|
|
@ -112,10 +116,10 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
@Body() body: UpdateProfileSalaryEmployee,
|
||||
@Path() salaryId: string,
|
||||
) {
|
||||
await new permission().PermissionUpdate(req, "SYS_REGISTRY_EMP");
|
||||
|
||||
const record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId)
|
||||
|
||||
const history = new ProfileSalaryHistory();
|
||||
|
||||
|
|
@ -137,7 +141,11 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
|
||||
@Delete("{salaryId}")
|
||||
public async deleteSalaryEmployee(@Path() salaryId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_EMP");
|
||||
const _record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
||||
}
|
||||
|
||||
await this.salaryHistoryRepo.delete({
|
||||
profileSalaryId: salaryId,
|
||||
});
|
||||
|
|
@ -152,7 +160,11 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Get("swap/{direction}/{salaryId}")
|
||||
public async swapSalaryEmployee(@Path() direction: string, salaryId: string) {
|
||||
public async swapSalaryEmployee(@Path() direction: string, salaryId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
|
||||
}
|
||||
const source_item = await this.salaryRepo.findOne({ where: { id: salaryId } });
|
||||
if (source_item == null) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
const sourceOrder = source_item.order;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue