แก้ create เป็น update เมนูทะเบียนประวัติ

This commit is contained in:
AdisakKanthawilang 2024-08-27 12:11:31 +07:00
parent fde5f8d90a
commit f281ea0bc2
61 changed files with 193 additions and 147 deletions

View file

@ -148,12 +148,12 @@ export class ProfileAbilityController extends Controller {
if (!body.profileId) { if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
const profile = await this.profileRepo.findOneBy({ id: body.profileId }); const profile = await this.profileRepo.findOneBy({ id: body.profileId });
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id);//ตส await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
const data = new ProfileAbility(); const data = new ProfileAbility();
const meta = { const meta = {
@ -209,7 +209,11 @@ export class ProfileAbilityController extends Controller {
public async deleteProfileAbility(@Path() abilityId: string, @Request() req: RequestWithUser) { public async deleteProfileAbility(@Path() abilityId: string, @Request() req: RequestWithUser) {
const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId }); const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req,"SYS_REGISTRY_OFFICER",_record.profileId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_OFFICER",
_record.profileId,
);
} }
await this.profileAbilityHistoryRepo.delete({ await this.profileAbilityHistoryRepo.delete({
profileAbilityId: abilityId, profileAbilityId: abilityId,

View file

@ -152,7 +152,7 @@ export class ProfileAbilityEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
const data = new ProfileAbility(); const data = new ProfileAbility();
const meta = { const meta = {

View file

@ -149,7 +149,7 @@ export class ProfileAbilityEmployeeTempController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
const data = new ProfileAbility(); const data = new ProfileAbility();
const meta = { const meta = {

View file

@ -69,7 +69,10 @@ export class ProfileAddressEmployeeTempController extends Controller {
* *
*/ */
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
public async detailProfileAddress(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async detailProfileAddress(
@Path() profileEmployeeId: string,
@Request() req: RequestWithUser,
) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const getProfileAddress = await this.profileEmployeeRepo.findOne({ const getProfileAddress = await this.profileEmployeeRepo.findOne({
where: { id: profileEmployeeId }, where: { id: profileEmployeeId },
@ -100,7 +103,7 @@ export class ProfileAddressEmployeeTempController extends Controller {
*/ */
@Get("history/user") @Get("history/user")
public async getProfileAddressHistoryUser(@Request() request: RequestWithUser) { public async getProfileAddressHistoryUser(@Request() request: RequestWithUser) {
// await new permission().PermissionGet(request, "SYS_REGISTRY_TEMP");//ตสTEMP // await new permission().PermissionGet(request, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub }); const profile = await this.profileEmployeeRepo.findOneBy({ keycloak: request.user.sub });
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
@ -142,7 +145,10 @@ export class ProfileAddressEmployeeTempController extends Controller {
* *
*/ */
@Get("history/{profileId}") @Get("history/{profileId}")
public async getProfileAddressHistory(@Path() profileId: string, @Request() req: RequestWithUser) { public async getProfileAddressHistory(
@Path() profileId: string,
@Request() req: RequestWithUser,
) {
await new permission().PermissionList(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");
const record = await this.profileAddressHistoryRepo.find({ const record = await this.profileAddressHistoryRepo.find({
where: { profileEmployeeId: profileId }, where: { profileEmployeeId: profileId },

View file

@ -163,12 +163,12 @@ export class ProfileAssessmentsController extends Controller {
if (!body.profileId) { if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
const profile = await this.profileRepo.findOneBy({ id: body.profileId }); const profile = await this.profileRepo.findOneBy({ id: body.profileId });
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id);//ตส await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id);
const data = new ProfileAssessment(); const data = new ProfileAssessment();
const meta = { const meta = {
@ -194,11 +194,10 @@ export class ProfileAssessmentsController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Path() assessmentId: string, @Path() assessmentId: string,
) { ) {
const record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId }); const record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId);
const history = new ProfileAssessmentHistory(); const history = new ProfileAssessmentHistory();
Object.assign(record, body); Object.assign(record, body);
@ -227,7 +226,11 @@ export class ProfileAssessmentsController extends Controller {
) { ) {
const _record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId }); const _record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_OFFICER",
_record.profileId,
);
} }
await this.profileAssessmentsHistoryRepository.delete({ await this.profileAssessmentsHistoryRepository.delete({
profileAssessmentId: assessmentId, profileAssessmentId: assessmentId,

View file

@ -160,7 +160,7 @@ export class ProfileAssessmentsEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
const data = new ProfileAssessment(); const data = new ProfileAssessment();
const meta = { const meta = {

View file

@ -150,7 +150,7 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeAssessment, @Body() body: CreateProfileEmployeeAssessment,
) { ) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
} }

View file

@ -73,7 +73,7 @@ export class ProfileAvatarController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
const data = new ProfileAvatar(); const data = new ProfileAvatar();

View file

@ -69,7 +69,7 @@ export class ProfileAvatarEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
const data = new ProfileAvatar(); const data = new ProfileAvatar();

View file

@ -15,7 +15,10 @@ export class ProfileAvatarEmployeeTempController extends Controller {
private avatarRepository = AppDataSource.getRepository(ProfileAvatar); private avatarRepository = AppDataSource.getRepository(ProfileAvatar);
@Get("{profileEmployeeId}") @Get("{profileEmployeeId}")
public async getAvatarEmployee(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { public async getAvatarEmployee(
@Path() profileEmployeeId: string,
@Request() req: RequestWithUser,
) {
await new permission().PermissionList(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");
const lists = await this.avatarRepository.find({ const lists = await this.avatarRepository.find({
where: { profileEmployeeId }, where: { profileEmployeeId },
@ -24,8 +27,12 @@ export class ProfileAvatarEmployeeTempController extends Controller {
} }
@Get("select/{profileEmployeeId}/{id}") @Get("select/{profileEmployeeId}/{id}")
public async selectAvatarEmployee(@Path() profileEmployeeId: string, @Path() id: string, @Request() req: RequestWithUser) { public async selectAvatarEmployee(
// await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");//ตสTEMP @Path() profileEmployeeId: string,
@Path() id: string,
@Request() req: RequestWithUser,
) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); //ไม่แน่ใจTEMP
const result = await this.avatarRepository.findOneBy({ id: id }); const result = await this.avatarRepository.findOneBy({ id: id });
if (!result) { if (!result) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -56,7 +63,7 @@ export class ProfileAvatarEmployeeTempController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeAvatar, @Body() body: CreateProfileEmployeeAvatar,
) { ) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
const profile = await this.profileRepository.findOne({ const profile = await this.profileRepository.findOne({
where: { id: body.profileEmployeeId }, where: { id: body.profileEmployeeId },
}); });

View file

@ -136,7 +136,7 @@ export class ProfileCertificateController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
const data = new ProfileCertificate(); const data = new ProfileCertificate();

View file

@ -134,7 +134,7 @@ export class ProfileCertificateEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
const data = new ProfileCertificate(); const data = new ProfileCertificate();

View file

@ -123,7 +123,7 @@ export class ProfileCertificateEmployeeTempController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeCertificate, @Body() body: CreateProfileEmployeeCertificate,
) { ) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
} }

View file

@ -132,7 +132,7 @@ export class ProfileChangeNameController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
const data = new ProfileChangeName(); const data = new ProfileChangeName();

View file

@ -134,7 +134,7 @@ export class ProfileChangeNameEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
const data = new ProfileChangeName(); const data = new ProfileChangeName();

View file

@ -122,7 +122,7 @@ export class ProfileChangeNameEmployeeTempController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileChangeNameEmployee, @Body() body: CreateProfileChangeNameEmployee,
) { ) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
} }

View file

@ -74,7 +74,7 @@ export class ProfileChildrenController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
const data = new ProfileChildren(); const data = new ProfileChildren();
const meta = { const meta = {

View file

@ -80,7 +80,7 @@ export class ProfileChildrenEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
const data = new ProfileChildren(); const data = new ProfileChildren();

View file

@ -72,7 +72,7 @@ export class ProfileChildrenEmployeeTempController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileChildrenEmployee, @Body() body: CreateProfileChildrenEmployee,
) { ) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
const profile = await this.profileRepository.findOneBy({ id: body.profileEmployeeId }); const profile = await this.profileRepository.findOneBy({ id: body.profileEmployeeId });
if (!profile) { if (!profile) {

View file

@ -2285,7 +2285,7 @@ export class ProfileController extends Controller {
) { ) {
const _record = await this.profileRepo.findOneBy({ id: id }); const _record = await this.profileRepo.findOneBy({ id: id });
if (_record) { if (_record) {
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_OFFICER", id);//ตส await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_OFFICER", _record.id); //ไม่แน่ใจOFF
} }
const exists = const exists =
!!body.citizenId && !!body.citizenId &&
@ -3159,10 +3159,7 @@ export class ProfileController extends Controller {
* *
*/ */
@Get("profileid/position/{id}") @Get("profileid/position/{id}")
async getProfileByProfileid( async getProfileByProfileid(@Request() request: RequestWithUser, @Path() id: string) {
@Request() request: RequestWithUser,
@Path() id: string,
) {
await new permission().PermissionOrgUserGet(request, "SYS_REGISTRY_OFFICER", id); await new permission().PermissionOrgUserGet(request, "SYS_REGISTRY_OFFICER", id);
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { id: id }, where: { id: id },
@ -3376,10 +3373,7 @@ export class ProfileController extends Controller {
* *
*/ */
@Get("keycloakid/position/{id}") @Get("keycloakid/position/{id}")
async getProfileByKeycloakid( async getProfileByKeycloakid(@Request() request: RequestWithUser, @Path() id: string) {
@Request() request: RequestWithUser,
@Path() id: string,
) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { keycloak: id }, where: { keycloak: id },
select: ["id"], select: ["id"],
@ -3399,10 +3393,7 @@ export class ProfileController extends Controller {
* @param id (citizenId) * @param id (citizenId)
*/ */
@Get("citizenid/position/{id}") @Get("citizenid/position/{id}")
async getProfileByCitizenId( async getProfileByCitizenId(@Request() request: RequestWithUser, @Path() id: string) {
@Request() request: RequestWithUser,
@Path() id: string,
) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { citizenId: id }, where: { citizenId: id },
relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"], relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"],
@ -3410,7 +3401,7 @@ export class ProfileController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
} }
await new permission().PermissionOrgUserList(request, "SYS_REGISTRY_OFFICER", profile.id); await new permission().PermissionOrgUserList(request, "SYS_REGISTRY_OFFICER", profile.id);
const orgRevisionPublish = await this.orgRevisionRepo const orgRevisionPublish = await this.orgRevisionRepo
.createQueryBuilder("orgRevision") .createQueryBuilder("orgRevision")
@ -3524,10 +3515,7 @@ export class ProfileController extends Controller {
* *
*/ */
@Get("profileempid/position/{id}") @Get("profileempid/position/{id}")
async getProfileByProfileempid( async getProfileByProfileempid(@Request() request: RequestWithUser, @Path() id: string) {
@Request() request: RequestWithUser,
@Path() id: string,
) {
await new permission().PermissionOrgUserList(request, "SYS_REGISTRY_OFFICER", id); await new permission().PermissionOrgUserList(request, "SYS_REGISTRY_OFFICER", id);
const profile = await this.profileEmpRepo.findOne({ const profile = await this.profileEmpRepo.findOne({
where: { id: id }, where: { id: id },
@ -4848,8 +4836,9 @@ export class ProfileController extends Controller {
* @summary * @summary
* *
*/ */
@Get("profileid/retire/{year}") //ตส @Get("profileid/retire/{year}")
async getProfileByRetireYear(@Path() year: number) { async getProfileByRetireYear(@Path() year: number, @Request() req: RequestWithUser) {
// await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_OFFICER", id);//ไม่แน่ใจOFF
const profiles = await this.profileRepo const profiles = await this.profileRepo
.createQueryBuilder("profile") .createQueryBuilder("profile")
.leftJoinAndSelect("profile.posLevel", "posLevel") .leftJoinAndSelect("profile.posLevel", "posLevel")

View file

@ -138,7 +138,7 @@ export class ProfileDisciplineController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
const data = new ProfileDiscipline(); const data = new ProfileDiscipline();

View file

@ -128,7 +128,7 @@ export class ProfileDisciplineEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
const data = new ProfileDiscipline(); const data = new ProfileDiscipline();

View file

@ -117,7 +117,7 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeDiscipline, @Body() body: CreateProfileEmployeeDiscipline,
) { ) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }

View file

@ -136,12 +136,12 @@ export class ProfileDutyController extends Controller {
if (!body.profileId) { if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
const profile = await this.profileRepository.findOneBy({ id: body.profileId }); const profile = await this.profileRepository.findOneBy({ id: body.profileId });
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id);//ตส await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id); //ไม่แน่ใจOFF
const data = new ProfileDuty(); const data = new ProfileDuty();
@ -195,7 +195,11 @@ export class ProfileDutyController extends Controller {
public async deleteDuty(@Path() dutyId: string, @Request() req: RequestWithUser) { public async deleteDuty(@Path() dutyId: string, @Request() req: RequestWithUser) {
const _record = await this.dutyRepository.findOneBy({ id: dutyId }); const _record = await this.dutyRepository.findOneBy({ id: dutyId });
if (_record) { if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); await new permission().PermissionOrgUserDelete(
req,
"SYS_REGISTRY_OFFICER",
_record.profileId,
);
} }
await this.dutyHistoryRepository.delete({ await this.dutyHistoryRepository.delete({
profileDutyId: dutyId, profileDutyId: dutyId,

View file

@ -102,7 +102,7 @@ export class ProfileDutyEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
const data = new ProfileDuty(); const data = new ProfileDuty();

View file

@ -91,7 +91,7 @@ export class ProfileDutyEmployeeTempController extends Controller {
@Post() @Post()
public async newDuty(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeDuty) { public async newDuty(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeDuty) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }

View file

@ -194,7 +194,7 @@ export class ProfileEducationsController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
const data = new ProfileEducation(); const data = new ProfileEducation();
const meta = { const meta = {

View file

@ -197,7 +197,7 @@ export class ProfileEducationsEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
const data = new ProfileEducation(); const data = new ProfileEducation();
const meta = { const meta = {

View file

@ -185,7 +185,7 @@ export class ProfileEducationsEmployeeTempController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEducationEmployee, @Body() body: CreateProfileEducationEmployee,
) { ) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
} }

View file

@ -258,7 +258,7 @@ export class ProfileEmployeeController extends Controller {
relations: ["currentSubDistrict", "currentDistrict", "currentProvince"], relations: ["currentSubDistrict", "currentDistrict", "currentProvince"],
where: { id: id }, where: { id: id },
}); });
if(profiles){ if (profiles) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profiles.id); await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profiles.id);
} }
const profileOc = await this.profileRepo.findOne({ const profileOc = await this.profileRepo.findOne({
@ -580,7 +580,7 @@ export class ProfileEmployeeController extends Controller {
* *
*/ */
@Post() @Post()
async createProfile(@Body() body: CreateProfileEmployee, @Request() request: RequestWithUser) { //ตส async createProfile(@Body() body: CreateProfileEmployee, @Request() request: RequestWithUser) { //ไม่แน่ใจEMP
if (await this.profileRepo.findOneBy({ citizenId: body.citizenId })) { if (await this.profileRepo.findOneBy({ citizenId: body.citizenId })) {
throw new HttpError( throw new HttpError(
HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR,
@ -633,7 +633,7 @@ export class ProfileEmployeeController extends Controller {
@Path() id: string, @Path() id: string,
@Body() body: UpdateProfileEmployee, @Body() body: UpdateProfileEmployee,
) { ) {
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", id) await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", id);
const exists = const exists =
!!body.citizenId && !!body.citizenId &&
(await this.profileRepo.findOne({ (await this.profileRepo.findOne({
@ -1058,7 +1058,7 @@ export class ProfileEmployeeController extends Controller {
*/ */
@Get("{id}") @Get("{id}")
async detailProfile(@Path() id: string, @Request() req: RequestWithUser) { async detailProfile(@Path() id: string, @Request() req: RequestWithUser) {
// await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id);//ตส await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id); //ไม่แน่ใจEMP
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
relations: { relations: {
posLevel: true, posLevel: true,
@ -2077,7 +2077,7 @@ export class ProfileEmployeeController extends Controller {
@Path() id: string, @Path() id: string,
@Body() body: UpdatePositionTempProfileEmployee, @Body() body: UpdatePositionTempProfileEmployee,
) { ) {
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", id) await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", id);
if (body.posLevelId === "") body.posLevelId = null; if (body.posLevelId === "") body.posLevelId = null;
if (body.posTypeId === "") body.posTypeId = null; if (body.posTypeId === "") body.posTypeId = null;
@ -2211,7 +2211,7 @@ export class ProfileEmployeeController extends Controller {
@Body() @Body()
requestBody: { citizenId: string }, requestBody: { citizenId: string },
) { ) {
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", id) await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", id);
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { id: Not(id), citizenId: requestBody.citizenId }, where: { id: Not(id), citizenId: requestBody.citizenId },
}); });
@ -2657,8 +2657,9 @@ export class ProfileEmployeeController extends Controller {
* @summary * @summary
* *
*/ */
@Get("profileid/retire/{year}") //ตส @Get("profileid/retire/{year}")
async getProfileByRetireYear(@Path() year: number) { async getProfileByRetireYear(@Path() year: number, @Request() req: RequestWithUser) {
// await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", id);//ไม่แน่ใจEMP
const profiles = await this.profileRepo const profiles = await this.profileRepo
.createQueryBuilder("profileEmployee") .createQueryBuilder("profileEmployee")
.leftJoinAndSelect("profileEmployee.posLevel", "posLevel") .leftJoinAndSelect("profileEmployee.posLevel", "posLevel")
@ -2861,7 +2862,7 @@ export class ProfileEmployeeController extends Controller {
where: { id: id }, where: { id: id },
}); });
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserCreate(request, "SYS_REGISTRY_EMP", profile.id) await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", profile.id);
profile.isLeave = requestBody.isLeave; profile.isLeave = requestBody.isLeave;
profile.leaveReason = requestBody.leaveReason; profile.leaveReason = requestBody.leaveReason;
@ -2892,8 +2893,7 @@ export class ProfileEmployeeController extends Controller {
@Path() profileEmployeeId: string, @Path() profileEmployeeId: string,
@Body() body: UpdateInformationProfileEmployee, @Body() body: UpdateInformationProfileEmployee,
) { ) {
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", profileEmployeeId);
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", profileEmployeeId)
const profileEmp = await this.profileRepo.findOneBy({ id: profileEmployeeId }); const profileEmp = await this.profileRepo.findOneBy({ id: profileEmployeeId });
if (!profileEmp) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้"); if (!profileEmp) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
@ -2922,7 +2922,7 @@ export class ProfileEmployeeController extends Controller {
*/ */
@Get("information/{profileEmployeeId}") @Get("information/{profileEmployeeId}")
async getInformationById(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { async getInformationById(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId) await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const profileInformation = await this.profileRepo.findOne({ const profileInformation = await this.profileRepo.findOne({
where: { id: profileEmployeeId }, where: { id: profileEmployeeId },
}); });
@ -2953,7 +2953,7 @@ export class ProfileEmployeeController extends Controller {
*/ */
@Get("information/history/{profileEmployeeId}") @Get("information/history/{profileEmployeeId}")
async getInformationHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { async getInformationHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileEmployeeId) await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const profileInformation = await this.profileRepo.find({ const profileInformation = await this.profileRepo.find({
relations: { relations: {
information_histories: true, information_histories: true,
@ -2994,8 +2994,11 @@ export class ProfileEmployeeController extends Controller {
* @param {string} profileEmployeeId profileEmployeeId * @param {string} profileEmployeeId profileEmployeeId
*/ */
@Get("employment/{profileEmployeeId}") @Get("employment/{profileEmployeeId}")
async ProfileEmployeeEmployment(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { async ProfileEmployeeEmployment(
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileEmployeeId) @Path() profileEmployeeId: string,
@Request() req: RequestWithUser,
) {
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const employment = await this.employmentRepository.find({ const employment = await this.employmentRepository.find({
where: { profileEmployeeId: profileEmployeeId }, where: { profileEmployeeId: profileEmployeeId },
order: { createdAt: "ASC" }, order: { createdAt: "ASC" },
@ -3021,7 +3024,11 @@ export class ProfileEmployeeController extends Controller {
where: { id: id }, where: { id: id },
}); });
if (employment) { if (employment) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", employment.profileEmployeeId) await new permission().PermissionOrgUserGet(
req,
"SYS_REGISTRY_EMP",
employment.profileEmployeeId,
);
} }
return new HttpSuccess(employment); return new HttpSuccess(employment);
} }
@ -3039,7 +3046,11 @@ export class ProfileEmployeeController extends Controller {
where: { id: id }, where: { id: id },
}); });
if (employment) { if (employment) {
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", employment.profileEmployeeId) await new permission().PermissionOrgUserList(
req,
"SYS_REGISTRY_EMP",
employment.profileEmployeeId,
);
} }
const employmentHistory = await this.employmentHistoryRepository.find({ const employmentHistory = await this.employmentHistoryRepository.find({
where: { profileEmployeeEmploymentId: id }, where: { profileEmployeeEmploymentId: id },
@ -3065,7 +3076,7 @@ export class ProfileEmployeeController extends Controller {
where: { id: profileEmployeeId }, where: { id: profileEmployeeId },
}); });
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserList(request, "SYS_REGISTRY_EMP", profile.id) await new permission().PermissionOrgUserList(request, "SYS_REGISTRY_EMP", profile.id);
const employment = new ProfileEmployeeEmployment(); const employment = new ProfileEmployeeEmployment();
// const history = new ProfileEmployeeEmploymentHistory(); // const history = new ProfileEmployeeEmploymentHistory();
@ -3101,7 +3112,11 @@ export class ProfileEmployeeController extends Controller {
where: { id: id }, where: { id: id },
}); });
if (employment) { if (employment) {
await new permission().PermissionOrgUserDelete(request, "SYS_REGISTRY_EMP", employment.profileEmployeeId) await new permission().PermissionOrgUserDelete(
request,
"SYS_REGISTRY_EMP",
employment.profileEmployeeId,
);
} }
await this.employmentHistoryRepository.delete({ await this.employmentHistoryRepository.delete({
profileEmployeeEmploymentId: id, profileEmployeeEmploymentId: id,
@ -3127,10 +3142,13 @@ export class ProfileEmployeeController extends Controller {
@Path() id: string, @Path() id: string,
@Body() body: UpdateEmploymentProfileEmployee, @Body() body: UpdateEmploymentProfileEmployee,
) { ) {
const employment = await this.employmentRepository.findOneBy({ id }); const employment = await this.employmentRepository.findOneBy({ id });
if (!employment) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!employment) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", employment.profileEmployeeId) await new permission().PermissionOrgUserUpdate(
request,
"SYS_REGISTRY_EMP",
employment.profileEmployeeId,
);
const history = new ProfileEmployeeEmploymentHistory(); const history = new ProfileEmployeeEmploymentHistory();
Object.assign(history, { ...employment, id: undefined }); Object.assign(history, { ...employment, id: undefined });
@ -3412,10 +3430,7 @@ export class ProfileEmployeeController extends Controller {
* *
*/ */
@Get("profileid/position/{id}") @Get("profileid/position/{id}")
async getProfileByProfileid( async getProfileByProfileid(@Request() request: RequestWithUser, @Path() id: string) {
@Request() request: RequestWithUser,
@Path() id: string,
) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { id: id }, where: { id: id },
relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"], relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"],

View file

@ -1055,7 +1055,8 @@ export class ProfileEmployeeTempController extends Controller {
* @param {string} id Id * @param {string} id Id
*/ */
@Get("{id}") @Get("{id}")
async detailProfile(@Path() id: string) {//ตสTEMP async detailProfile(@Path() id: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); //ไม่แน่ใจTEMP
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
relations: { relations: {
posLevel: true, posLevel: true,
@ -2069,11 +2070,12 @@ export class ProfileEmployeeTempController extends Controller {
* @param {string} id Id * @param {string} id Id
*/ */
@Put("position/{id}") @Put("position/{id}")
async positionProfileEmployee(//ตสTEMP async positionProfileEmployee(
@Request() request: RequestWithUser, @Request() request: RequestWithUser,
@Path() id: string, @Path() id: string,
@Body() body: UpdatePositionTempProfileEmployee, @Body() body: UpdatePositionTempProfileEmployee,
) { ) {
// await new permission().PermissionUpdate(request, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
if (body.posLevelId === "") body.posLevelId = null; if (body.posLevelId === "") body.posLevelId = null;
if (body.posTypeId === "") body.posTypeId = null; if (body.posTypeId === "") body.posTypeId = null;
@ -2201,7 +2203,7 @@ export class ProfileEmployeeTempController extends Controller {
* @param {string} id Id * @param {string} id Id
*/ */
@Put("citizenId/{id}") @Put("citizenId/{id}")
async checkCitizenIdProfile(//ตสTEMP async checkCitizenIdProfile(
@Path() id: string, @Path() id: string,
@Body() @Body()
requestBody: { citizenId: string }, requestBody: { citizenId: string },
@ -2552,7 +2554,8 @@ export class ProfileEmployeeTempController extends Controller {
* *
*/ */
@Get("keycloak/position/{revisionId}") @Get("keycloak/position/{revisionId}")
async getProfileByKeycloakByRevision(//ตสTEMP async getProfileByKeycloakByRevision(
//ไม่แน่ใจTEMP
@Path() revisionId: string, @Path() revisionId: string,
@Request() request: { user: Record<string, any> }, @Request() request: { user: Record<string, any> },
) { ) {
@ -2652,8 +2655,9 @@ export class ProfileEmployeeTempController extends Controller {
* @summary * @summary
* *
*/ */
@Get("profileid/retire/{year}")//ตสTEMP @Get("profileid/retire/{year}")
async getProfileByRetireYear(@Path() year: number) { async getProfileByRetireYear(@Path() year: number, @Request() req: RequestWithUser) {
// await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
const profiles = await this.profileRepo const profiles = await this.profileRepo
.createQueryBuilder("profileEmployee") .createQueryBuilder("profileEmployee")
.leftJoinAndSelect("profileEmployee.posLevel", "posLevel") .leftJoinAndSelect("profileEmployee.posLevel", "posLevel")
@ -2845,13 +2849,14 @@ export class ProfileEmployeeTempController extends Controller {
* *
* @param {string} id Id * @param {string} id Id
*/ */
@Post("leave/{id}")//ตสTEMP @Post("leave/{id}")
async updateLeaveUser( async updateLeaveUser(
@Path() id: string, @Path() id: string,
@Body() @Body()
requestBody: { isLeave: boolean; leaveReason: string; dateLeave: Date }, requestBody: { isLeave: boolean; leaveReason: string; dateLeave: Date },
@Request() request: { user: Record<string, any> }, @Request() request: { user: Record<string, any> },
) { ) {
// await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { id: id }, where: { id: id },
}); });
@ -2880,12 +2885,13 @@ export class ProfileEmployeeTempController extends Controller {
* *
* @param {string} profileEmployeeId profileEmployeeId * @param {string} profileEmployeeId profileEmployeeId
*/ */
@Put("information/{profileEmployeeId}")//ตสTEMP @Put("information/{profileEmployeeId}")
async ProfileEmployeeInformation( async ProfileEmployeeInformation(
@Request() request: RequestWithUser, @Request() request: RequestWithUser,
@Path() profileEmployeeId: string, @Path() profileEmployeeId: string,
@Body() body: UpdateInformationProfileEmployee, @Body() body: UpdateInformationProfileEmployee,
) { ) {
// await new permission().PermissionUpdate(request, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
const profileEmp = await this.profileRepo.findOneBy({ id: profileEmployeeId }); const profileEmp = await this.profileRepo.findOneBy({ id: profileEmployeeId });
if (!profileEmp) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้"); if (!profileEmp) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
@ -2912,8 +2918,9 @@ export class ProfileEmployeeTempController extends Controller {
* *
* @param {string} profileEmployeeId profileEmployeeId * @param {string} profileEmployeeId profileEmployeeId
*/ */
@Get("information/{profileEmployeeId}")//ตสTEMP @Get("information/{profileEmployeeId}")
async getInformationById(@Path() profileEmployeeId: string) { async getInformationById(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
// await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
const profileInformation = await this.profileRepo.findOne({ const profileInformation = await this.profileRepo.findOne({
where: { id: profileEmployeeId }, where: { id: profileEmployeeId },
}); });
@ -2942,8 +2949,9 @@ export class ProfileEmployeeTempController extends Controller {
* *
* @param {string} profileEmployeeId profileEmployeeId * @param {string} profileEmployeeId profileEmployeeId
*/ */
@Get("information/history/{profileEmployeeId}")//ตสTEMP @Get("information/history/{profileEmployeeId}")
async getInformationHistory(@Path() profileEmployeeId: string) { async getInformationHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
// await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
const profileInformation = await this.profileRepo.find({ const profileInformation = await this.profileRepo.find({
relations: { relations: {
information_histories: true, information_histories: true,
@ -2983,8 +2991,12 @@ export class ProfileEmployeeTempController extends Controller {
* *
* @param {string} profileEmployeeId profileEmployeeId * @param {string} profileEmployeeId profileEmployeeId
*/ */
@Get("employment/{profileEmployeeId}")//ตสTEMP @Get("employment/{profileEmployeeId}")
async ProfileEmployeeEmployment(@Path() profileEmployeeId: string) { async ProfileEmployeeEmployment(
@Path() profileEmployeeId: string,
@Request() req: RequestWithUser,
) {
// await new permission().PermissionList(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
const employment = await this.employmentRepository.find({ const employment = await this.employmentRepository.find({
where: { profileEmployeeId: profileEmployeeId }, where: { profileEmployeeId: profileEmployeeId },
order: { createdAt: "ASC" }, order: { createdAt: "ASC" },
@ -3004,8 +3016,9 @@ export class ProfileEmployeeTempController extends Controller {
* *
* @param {string} id Id * @param {string} id Id
*/ */
@Get("employment/id/{id}")//ตสTEMP @Get("employment/id/{id}")
async GetEmploymentById(@Path() id: string) { async GetEmploymentById(@Path() id: string, @Request() req: RequestWithUser) {
// await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
const employment = await this.employmentRepository.findOne({ const employment = await this.employmentRepository.findOne({
where: { id: id }, where: { id: id },
}); });
@ -3019,8 +3032,9 @@ export class ProfileEmployeeTempController extends Controller {
* *
* @param {string} id Id * @param {string} id Id
*/ */
@Get("employment/history/{id}")//ตสTEMP @Get("employment/history/{id}")
async GetHistoryEmploymentById(@Path() id: string) { async GetHistoryEmploymentById(@Path() id: string, @Request() req: RequestWithUser) {
// await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
const employmentHistory = await this.employmentHistoryRepository.find({ const employmentHistory = await this.employmentHistoryRepository.find({
where: { profileEmployeeEmploymentId: id }, where: { profileEmployeeEmploymentId: id },
order: { lastUpdatedAt: "ASC" }, order: { lastUpdatedAt: "ASC" },
@ -3035,12 +3049,13 @@ export class ProfileEmployeeTempController extends Controller {
* *
* @param {string} profileEmployeeId profileEmployeeId * @param {string} profileEmployeeId profileEmployeeId
*/ */
@Post("employment/{profileEmployeeId}")//ตสTEMP @Post("employment/{profileEmployeeId}")
async CreateEmployment( async CreateEmployment(
@Path() profileEmployeeId: string, @Path() profileEmployeeId: string,
@Body() body: CreateEmploymentProfileEmployee, @Body() body: CreateEmploymentProfileEmployee,
@Request() request: RequestWithUser, @Request() request: RequestWithUser,
) { ) {
// await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { id: profileEmployeeId }, where: { id: profileEmployeeId },
}); });
@ -3074,8 +3089,9 @@ export class ProfileEmployeeTempController extends Controller {
* *
* @param {string} id Id * @param {string} id Id
*/ */
@Delete("employment/{id}")//ตสTEMP @Delete("employment/{id}")
async DeleteEmployment(@Path() id: string) { async DeleteEmployment(@Path() id: string) {
// await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
await this.employmentHistoryRepository.delete({ await this.employmentHistoryRepository.delete({
profileEmployeeEmploymentId: id, profileEmployeeEmploymentId: id,
}); });
@ -3094,12 +3110,13 @@ export class ProfileEmployeeTempController extends Controller {
* *
* @param {string} id Id * @param {string} id Id
*/ */
@Put("employment/{id}")//ตสTEMP @Put("employment/{id}")
async UpdateEmployment( async UpdateEmployment(
@Request() request: RequestWithUser, @Request() request: RequestWithUser,
@Path() id: string, @Path() id: string,
@Body() body: UpdateEmploymentProfileEmployee, @Body() body: UpdateEmploymentProfileEmployee,
) { ) {
// await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
const employment = await this.employmentRepository.findOneBy({ id }); const employment = await this.employmentRepository.findOneBy({ id });
if (!employment) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!employment) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -3127,8 +3144,9 @@ export class ProfileEmployeeTempController extends Controller {
* @summary ORG_038 - (ADMIN) # * @summary ORG_038 - (ADMIN) #
* *
*/ */
@Post("report")//ตสTEMP @Post("report")
async sendReport(@Request() request: RequestWithUser, @Body() requestBody: { id: string[] }) { async sendReport(@Request() request: RequestWithUser, @Body() requestBody: { id: string[] }) {
// await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
const profiles = await this.profileRepo.find({ where: { id: In(requestBody.id) } }); const profiles = await this.profileRepo.find({ where: { id: In(requestBody.id) } });
const _profiles = await Promise.all( const _profiles = await Promise.all(
@ -3151,7 +3169,7 @@ export class ProfileEmployeeTempController extends Controller {
* @summary ORG_038 - (ADMIN) # * @summary ORG_038 - (ADMIN) #
* *
*/ */
@Post("report/resume")//ตสTEMP @Post("report/resume")
async doneReport( async doneReport(
@Body() @Body()
body: { body: {
@ -3167,6 +3185,7 @@ export class ProfileEmployeeTempController extends Controller {
}, },
@Request() request: { user: Record<string, any> }, @Request() request: { user: Record<string, any> },
) { ) {
// await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
await Promise.all( await Promise.all(
body.result.map(async (v) => { body.result.map(async (v) => {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
@ -3216,7 +3235,7 @@ export class ProfileEmployeeTempController extends Controller {
* @summary keycloak * @summary keycloak
* *
*/ */
@Post("search-personal-no-keycloak")//ตสTEMP @Post("search-personal-no-keycloak")
async getProfileBySearchKeywordNoKeyCloak( async getProfileBySearchKeywordNoKeyCloak(
@Query("page") page: number = 1, @Query("page") page: number = 1,
@Query("pageSize") pageSize: number = 10, @Query("pageSize") pageSize: number = 10,
@ -3226,6 +3245,7 @@ export class ProfileEmployeeTempController extends Controller {
keyword?: string; keyword?: string;
}, },
) { ) {
// await new permission().PermissionPost(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
let findProfile: any; let findProfile: any;
let total: any; let total: any;
const skip = (page - 1) * pageSize; const skip = (page - 1) * pageSize;
@ -3382,11 +3402,9 @@ export class ProfileEmployeeTempController extends Controller {
* @summary ORG_065 - profileid (ADMIN) #70 * @summary ORG_065 - profileid (ADMIN) #70
* *
*/ */
@Get("profileid/position/{id}")//ตสTEMP @Get("profileid/position/{id}")
async getProfileByProfileid( async getProfileByProfileid(@Request() req: RequestWithUser, @Path() id: string) {
@Request() request: { user: Record<string, any> }, // await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMP
@Path() id: string,
) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { id: id }, where: { id: id },
relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"], relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"],

View file

@ -230,7 +230,7 @@ export class ProfileFamilyCoupleController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id);//ตส await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id); //ไม่แน่ใจOFF
familyCouple.coupleCitizenId = Extension.CheckCitizen(String(body.coupleCitizenId)); familyCouple.coupleCitizenId = Extension.CheckCitizen(String(body.coupleCitizenId));
familyCouple.createdUserId = req.user.sub; familyCouple.createdUserId = req.user.sub;
familyCouple.createdFullName = req.user.name; familyCouple.createdFullName = req.user.name;

View file

@ -230,7 +230,7 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
familyCouple.coupleCitizenId = Extension.CheckCitizen(String(body.coupleCitizenId)); familyCouple.coupleCitizenId = Extension.CheckCitizen(String(body.coupleCitizenId));
familyCouple.createdUserId = req.user.sub; familyCouple.createdUserId = req.user.sub;

View file

@ -223,7 +223,7 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeFamilyCouple, @Body() body: CreateProfileEmployeeFamilyCouple,
) { ) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
const familyCouple = Object.assign(new ProfileFamilyCouple(), body); const familyCouple = Object.assign(new ProfileFamilyCouple(), body);
if (!familyCouple) { if (!familyCouple) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");

View file

@ -216,7 +216,7 @@ export class ProfileFamilyFatherController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id);//ตส await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id); //ไม่แน่ใจOFF
familyFather.fatherCitizenId = Extension.CheckCitizen(String(body.fatherCitizenId)); familyFather.fatherCitizenId = Extension.CheckCitizen(String(body.fatherCitizenId));
familyFather.createdUserId = req.user.sub; familyFather.createdUserId = req.user.sub;
familyFather.createdFullName = req.user.name; familyFather.createdFullName = req.user.name;
@ -239,7 +239,7 @@ export class ProfileFamilyFatherController extends Controller {
@Body() body: UpdateProfileFamilyFather, @Body() body: UpdateProfileFamilyFather,
@Path() profileId: string, @Path() profileId: string,
) { ) {
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profileId);//ตส await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profileId); //ไม่แน่ใจOFF
const familyFather = await this.ProfileFamilyFather.findOneBy({ profileId: profileId }); const familyFather = await this.ProfileFamilyFather.findOneBy({ profileId: profileId });
if (!familyFather) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!familyFather) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");

View file

@ -215,7 +215,7 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
familyFather.fatherCitizenId = Extension.CheckCitizen(String(body.fatherCitizenId)); familyFather.fatherCitizenId = Extension.CheckCitizen(String(body.fatherCitizenId));
familyFather.createdUserId = req.user.sub; familyFather.createdUserId = req.user.sub;
familyFather.createdFullName = req.user.name; familyFather.createdFullName = req.user.name;

View file

@ -208,7 +208,7 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeFamilyFather, @Body() body: CreateProfileEmployeeFamilyFather,
) { ) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
const familyFather = Object.assign(new ProfileFamilyFather(), body); const familyFather = Object.assign(new ProfileFamilyFather(), body);
if (!familyFather) { if (!familyFather) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");

View file

@ -215,7 +215,7 @@ export class ProfileFamilyMotherController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER",profile.id);//ตส await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id); //ไม่แน่ใจOFF
familyMother.motherCitizenId = Extension.CheckCitizen(String(body.motherCitizenId)); familyMother.motherCitizenId = Extension.CheckCitizen(String(body.motherCitizenId));
familyMother.createdUserId = req.user.sub; familyMother.createdUserId = req.user.sub;
familyMother.createdFullName = req.user.name; familyMother.createdFullName = req.user.name;
@ -238,7 +238,7 @@ export class ProfileFamilyMotherController extends Controller {
@Body() body: UpdateProfileFamilyMother, @Body() body: UpdateProfileFamilyMother,
@Path() profileId: string, @Path() profileId: string,
) { ) {
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER",profileId);//ตส await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profileId); //ไม่แน่ใจOFF
const familyMother = await this.ProfileFamilyMother.findOneBy({ profileId: profileId }); const familyMother = await this.ProfileFamilyMother.findOneBy({ profileId: profileId });
if (!familyMother) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!familyMother) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");

View file

@ -215,7 +215,7 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
familyMother.motherCitizenId = Extension.CheckCitizen(String(body.motherCitizenId)); familyMother.motherCitizenId = Extension.CheckCitizen(String(body.motherCitizenId));
familyMother.createdUserId = req.user.sub; familyMother.createdUserId = req.user.sub;
familyMother.createdFullName = req.user.name; familyMother.createdFullName = req.user.name;

View file

@ -208,7 +208,7 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeFamilyMother, @Body() body: CreateProfileEmployeeFamilyMother,
) { ) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
const familyMother = Object.assign(new ProfileFamilyMother(), body); const familyMother = Object.assign(new ProfileFamilyMother(), body);
if (!familyMother) { if (!familyMother) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");

View file

@ -152,7 +152,7 @@ export class ProfileHonorController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
const data = new ProfileHonor(); const data = new ProfileHonor();

View file

@ -156,7 +156,7 @@ export class ProfileHonorEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
const data = new ProfileHonor(); const data = new ProfileHonor();

View file

@ -145,7 +145,7 @@ export class ProfileHonorEmployeeTempController extends Controller {
@Post() @Post()
public async newHonor(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeHonor) { public async newHonor(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeHonor) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
} }

View file

@ -179,7 +179,7 @@ export class ProfileInsigniaController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
const insignia = await this.insigniaMetaRepo.findOne({ const insignia = await this.insigniaMetaRepo.findOne({
where: { id: body.insigniaId }, where: { id: body.insigniaId },

View file

@ -182,7 +182,7 @@ export class ProfileInsigniaEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id) await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id)
const insignia = await this.insigniaMetaRepo.findOne({ const insignia = await this.insigniaMetaRepo.findOne({
where: { id: body.insigniaId }, where: { id: body.insigniaId },

View file

@ -171,7 +171,7 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeInsignia, @Body() body: CreateProfileEmployeeInsignia,
) { ) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
} }

View file

@ -260,7 +260,7 @@ export class ProfileLeaveController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
const leaveType = await this.leaveTypeRepository.findOne({ const leaveType = await this.leaveTypeRepository.findOne({
where: { id: body.leaveTypeId }, where: { id: body.leaveTypeId },

View file

@ -82,7 +82,7 @@ export class ProfileLeaveEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
const leaveType = await this.leaveTypeRepository.findOne({ const leaveType = await this.leaveTypeRepository.findOne({
where: { id: body.leaveTypeId }, where: { id: body.leaveTypeId },

View file

@ -70,7 +70,7 @@ export class ProfileLeaveEmployeeTempController extends Controller {
@Post() @Post()
public async newLeave(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeLeave) { public async newLeave(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeLeave) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }

View file

@ -109,7 +109,7 @@ export class ProfileNopaidController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
const data = new ProfileNopaid(); const data = new ProfileNopaid();

View file

@ -76,7 +76,7 @@ export class ProfileNopaidEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
const data = new ProfileNopaid(); const data = new ProfileNopaid();

View file

@ -69,7 +69,7 @@ export class ProfileNopaidEmployeeTempController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeNopaid, @Body() body: CreateProfileEmployeeNopaid,
) { ) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }

View file

@ -106,7 +106,7 @@ export class ProfileOtherController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
const data = new ProfileOther(); const data = new ProfileOther();

View file

@ -77,7 +77,7 @@ export class ProfileOtherEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
const data = new ProfileOther(); const data = new ProfileOther();

View file

@ -66,7 +66,7 @@ export class ProfileOtherEmployeeTempController extends Controller {
@Post() @Post()
public async newOther(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeOther) { public async newOther(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeOther) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }

View file

@ -153,7 +153,7 @@ export class ProfileSalaryController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
const dest_item = await this.salaryRepo.findOne({ const dest_item = await this.salaryRepo.findOne({
where: { profileId: body.profileId }, where: { profileId: body.profileId },

View file

@ -85,7 +85,7 @@ export class ProfileSalaryEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
const dest_item = await this.salaryRepo.findOne({ const dest_item = await this.salaryRepo.findOne({
where: { profileEmployeeId: body.profileEmployeeId }, where: { profileEmployeeId: body.profileEmployeeId },

View file

@ -71,7 +71,7 @@ export class ProfileSalaryEmployeeTempController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileSalaryEmployee, @Body() body: CreateProfileSalaryEmployee,
) { ) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
} }

View file

@ -152,7 +152,7 @@ export class ProfileTrainingController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
const data = new ProfileTraining(); const data = new ProfileTraining();

View file

@ -156,7 +156,7 @@ export class ProfileTrainingEmployeeController extends Controller {
if (!profile) { if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
} }
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
const data = new ProfileTraining(); const data = new ProfileTraining();

View file

@ -144,7 +144,7 @@ export class ProfileTrainingEmployeeTempController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeTraining, @Body() body: CreateProfileEmployeeTraining,
) { ) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_TEMP"); await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
} }