From 7ad99d597f2a56f74a8081d9d8242b16d4bf39aa Mon Sep 17 00:00:00 2001 From: samisa-abeysinghe Date: Fri, 2 Sep 2022 12:21:05 +0530 Subject: [PATCH] Adding the entity records, DB CRUD and REST CRUD --- Address.bal | 96 ++++ Applicant.bal | 133 +++++ ApplicantAddress.bal | 90 ++++ ApplicantApplicationStatus.bal | 98 ++++ ApplicantEvaluation.bal | 98 ++++ ApplicantInterview.bal | 118 +++++ ApplicantQualification.bal | 93 ++++ ApplicantSkill.bal | 98 ++++ ApplicationStatus.bal | 81 +++ AttendanceType.bal | 81 +++ Branch.bal | 91 ++++ BranchAddress.bal | 90 ++++ Dependencies.toml | 4 + Employee.bal | 133 +++++ EmployeeAddress.bal | 90 ++++ EmployeeAttendance.bal | 88 ++++ EmployeeEmploymentStatus.bal | 93 ++++ EmployeeEmploymentType.bal | 93 ++++ EmployeeEvaluation.bal | 103 ++++ EmployeeLeave.bal | 103 ++++ EmployeeQualification.bal | 98 ++++ EmployeeSkill.bal | 98 ++++ EmploymentStatus.bal | 81 +++ EmploymentType.bal | 76 +++ EvaluationCriteriaCategory.bal | 76 +++ EvaluationCycle.bal | 98 ++++ Job.bal | 86 +++ JobBand.bal | 91 ++++ JobDescription.bal | 81 +++ JobEvaluationCriteria.bal | 86 +++ JobOffer.bal | 113 ++++ JobQualification.bal | 86 +++ JobRoleResponsibility.bal | 86 +++ JobSkill.bal | 86 +++ LeaveType.bal | 86 +++ Office.bal | 91 ++++ OfficeAddress.bal | 90 ++++ OfficeEmployee.bal | 108 ++++ Organization.bal | 86 +++ OrganizationAddress.bal | 90 ++++ PositionsVacant.bal | 103 ++++ QualificationCategory.bal | 76 +++ RoleResponsibilityCategory.bal | 76 +++ SkillCategory.bal | 76 +++ Team.bal | 81 +++ TeamLead.bal | 108 ++++ service.bal | 922 +++++++++++++++++++++++++++++++++ 47 files changed, 5109 insertions(+) create mode 100644 Address.bal create mode 100644 Applicant.bal create mode 100644 ApplicantAddress.bal create mode 100644 ApplicantApplicationStatus.bal create mode 100644 ApplicantEvaluation.bal create mode 100644 ApplicantInterview.bal create mode 100644 ApplicantQualification.bal create mode 100644 ApplicantSkill.bal create mode 100644 ApplicationStatus.bal create mode 100644 AttendanceType.bal create mode 100644 Branch.bal create mode 100644 BranchAddress.bal create mode 100644 Employee.bal create mode 100644 EmployeeAddress.bal create mode 100644 EmployeeAttendance.bal create mode 100644 EmployeeEmploymentStatus.bal create mode 100644 EmployeeEmploymentType.bal create mode 100644 EmployeeEvaluation.bal create mode 100644 EmployeeLeave.bal create mode 100644 EmployeeQualification.bal create mode 100644 EmployeeSkill.bal create mode 100644 EmploymentStatus.bal create mode 100644 EmploymentType.bal create mode 100644 EvaluationCriteriaCategory.bal create mode 100644 EvaluationCycle.bal create mode 100644 Job.bal create mode 100644 JobBand.bal create mode 100644 JobDescription.bal create mode 100644 JobEvaluationCriteria.bal create mode 100644 JobOffer.bal create mode 100644 JobQualification.bal create mode 100644 JobRoleResponsibility.bal create mode 100644 JobSkill.bal create mode 100644 LeaveType.bal create mode 100644 Office.bal create mode 100644 OfficeAddress.bal create mode 100644 OfficeEmployee.bal create mode 100644 Organization.bal create mode 100644 OrganizationAddress.bal create mode 100644 PositionsVacant.bal create mode 100644 QualificationCategory.bal create mode 100644 RoleResponsibilityCategory.bal create mode 100644 SkillCategory.bal create mode 100644 Team.bal create mode 100644 TeamLead.bal diff --git a/Address.bal b/Address.bal new file mode 100644 index 0000000..157f96a --- /dev/null +++ b/Address.bal @@ -0,0 +1,96 @@ +import ballerina/sql; + +public type Address record { + int? id = (); + string line1; + string line2; + string line3; + int city_id; + int address_type_id; + string notes; +}; + +public isolated function getAddresses() returns Address[]|error { + Address[] addresses = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + line1 , + line2 , + line3 , + city_id , + address_type_id , + notes + FROM address` + ); + check from Address address in resultStream + do { + addresses.push(address); + }; + check resultStream.close(); + return addresses; +} + +public isolated function getAddress(int id) returns Address|error { + Address address = check smsDBClient->queryRow( + `SELECT * FROM address WHERE id = ${id}` + ); + return address; +} + +public isolated function addAddress(Address address) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO address ( + line1 , + line2 , + line3 , + city_id , + address_type_id , + notes ) + VALUES ( + ${address.line1}, + ${address.line2}, + ${address.line3}, + ${address.city_id}, + ${address.address_type_id}, + ${address.notes} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for address"); + } +} + +public isolated function updateAddress(Address address) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE address SET + line1 = ${address.line1}, + line2 = ${address.line2}, + line3 = ${address.line3}, + city_id = ${address.city_id}, + address_type_id = ${address.address_type_id}, + notes = ${address.notes} + WHERE id = ${address.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for address update"); + } +} + +isolated function deleteAddress(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM address WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for address delete"); + } +} diff --git a/Applicant.bal b/Applicant.bal new file mode 100644 index 0000000..bc2cd35 --- /dev/null +++ b/Applicant.bal @@ -0,0 +1,133 @@ +import ballerina/sql; + +import ballerina/time; + +public type Applicant record { + int? id = (); + string positions_vacant_id; + string first_name; + string last_name; + string name_with_initials; + string full_name; + string gender; + string applied_date; + string id_number; + string phone_number1; + string? phone_number2 = (); + string? email = (); + string? cv_location = (); + time:Utc last_updated = time:utcNow(); +}; + +public isolated function getApplicants() returns Applicant[]|error { + Applicant[] applicants = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + positions_vacant_id , + first_name , + last_name , + name_with_initials , + full_name , + gender , + applied_date , + id_number , + phone_number1 , + phone_number2 , + email , + cv_location , + last_updated + FROM applicant` + ); + check from Applicant applicant in resultStream + do { + applicants.push(applicant); + }; + check resultStream.close(); + return applicants; +} + +public isolated function getApplicant(int id) returns Applicant|error { + Applicant applicant = check smsDBClient->queryRow( + `SELECT * FROM applicant WHERE id = ${id}` + ); + return applicant; +} + +public isolated function addApplicant(Applicant applicant) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO applicant ( + positions_vacant_id , + first_name , + last_name , + name_with_initials , + full_name , + gender , + applied_date , + id_number , + phone_number1 , + phone_number2 , + email , + cv_location , + last_updated ) + VALUES ( + ${applicant.positions_vacant_id}, + ${applicant.first_name}, + ${applicant.last_name}, + ${applicant.name_with_initials}, + ${applicant.full_name}, + ${applicant.gender}, + ${applicant.applied_date}, + ${applicant.id_number}, + ${applicant.phone_number1}, + ${applicant.phone_number2}, + ${applicant.email}, + ${applicant.cv_location}, + ${applicant.last_updated} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for applicant"); + } +} + +public isolated function updateApplicant(Applicant applicant) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE applicant SET + positions_vacant_id = ${applicant.positions_vacant_id}, + first_name = ${applicant.first_name}, + last_name = ${applicant.last_name}, + name_with_initials = ${applicant.name_with_initials}, + full_name = ${applicant.full_name}, + gender = ${applicant.gender}, + applied_date = ${applicant.applied_date}, + id_number = ${applicant.id_number}, + phone_number1 = ${applicant.phone_number1}, + phone_number2 = ${applicant.phone_number2}, + email = ${applicant.email}, + cv_location = ${applicant.cv_location}, + last_updated = ${applicant.last_updated} + WHERE id = ${applicant.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for applicant update"); + } +} + +isolated function deleteApplicant(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM applicant WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for applicant delete"); + } +} diff --git a/ApplicantAddress.bal b/ApplicantAddress.bal new file mode 100644 index 0000000..453e0f5 --- /dev/null +++ b/ApplicantAddress.bal @@ -0,0 +1,90 @@ +import ballerina/sql; + +public type ApplicantAddress record { + int applicant_id; + int address_id; +}; + +public isolated function getApplicantAddresses() returns ApplicantAddress[]|error { + ApplicantAddress[] applicantAddresses = []; + stream resultStream = smsDBClient->query( + `SELECT + applicant_id , + address_id + FROM applicant_address` + ); + check from ApplicantAddress applicantAddress in resultStream + do { + applicantAddresses.push(applicantAddress); + }; + check resultStream.close(); + return applicantAddresses; +} + +public isolated function getApplicantAddress(int applicant_id, int address_id) returns ApplicantAddress|error { + ApplicantAddress applicantAddress = check smsDBClient->queryRow( + `SELECT * FROM applicant_address WHERE applicant_id = ${applicant_id} AND address_id = ${address_id}` + ); + return applicantAddress; +} + +public isolated function getAddressesForApplicant(int applicant_id) returns ApplicantAddress[]|error { + ApplicantAddress[] applicantAddresses = []; + stream resultStream = smsDBClient->query( + `SELECT + applicant_id , + address_id + FROM applicant_address WHERE applicant_id = ${applicant_id}` + ); + check from ApplicantAddress applicantAddress in resultStream + do { + applicantAddresses.push(applicantAddress); + }; + check resultStream.close(); + return applicantAddresses; +} + +public isolated function addApplicantAddress(ApplicantAddress applicantAddress) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO applicant_address ( + applicant_id , + address_id ) + VALUES ( + ${applicantAddress.applicant_id}, + ${applicantAddress.address_id} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for applicant_address"); + } +} + +public isolated function updateApplicantAddress(ApplicantAddress applicantAddress) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE applicant_address SET + applicant_id = ${applicantAddress.applicant_id}, + address_id = ${applicantAddress.address_id} + WHERE applicant_address = ${applicantAddress.applicant_id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for applicant_address update"); + } +} + +isolated function deleteApplicantAddress(int applicant_id, int address_id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM applicant_address WHERE applicant_id = ${applicant_id} AND address_id = ${address_id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for applicant_address delete"); + } +} diff --git a/ApplicantApplicationStatus.bal b/ApplicantApplicationStatus.bal new file mode 100644 index 0000000..0dbe066 --- /dev/null +++ b/ApplicantApplicationStatus.bal @@ -0,0 +1,98 @@ +import ballerina/sql; + +import ballerina/time; + +public type ApplicantApplicationStatus record { + int? id = (); + int applicant_id; + int application_status_id; + string start_date; + string? end_date = (); + time:Utc last_updated = time:utcNow(); + string notes; +}; + +public isolated function getApplicantApplicationStatuses() returns ApplicantApplicationStatus[]|error { + ApplicantApplicationStatus[] applicantApplicationStatuses = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + applicant_id , + application_status_id , + start_date , + end_date , + last_updated , + notes + FROM applicant_application_status` + ); + check from ApplicantApplicationStatus applicantApplicationStatus in resultStream + do { + applicantApplicationStatuses.push(applicantApplicationStatus); + }; + check resultStream.close(); + return applicantApplicationStatuses; +} + +public isolated function getApplicantApplicationStatus(int id) returns ApplicantApplicationStatus|error { + ApplicantApplicationStatus applicantApplicationStatus = check smsDBClient->queryRow( + `SELECT * FROM applicant_application_status WHERE id = ${id}` + ); + return applicantApplicationStatus; +} + +public isolated function addApplicantApplicationStatus(ApplicantApplicationStatus applicantApplicationStatus) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO applicant_application_status ( + applicant_id , + application_status_id , + start_date , + end_date , + last_updated , + notes ) + VALUES ( + ${applicantApplicationStatus.applicant_id}, + ${applicantApplicationStatus.application_status_id}, + ${applicantApplicationStatus.start_date}, + ${applicantApplicationStatus.end_date}, + ${applicantApplicationStatus.last_updated}, + ${applicantApplicationStatus.notes} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for applicant_application_status"); + } +} + +public isolated function updateApplicantApplicationStatus(ApplicantApplicationStatus applicantApplicationStatus) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE applicant_application_status SET + applicant_id = ${applicantApplicationStatus.applicant_id}, + application_status_id = ${applicantApplicationStatus.application_status_id}, + start_date = ${applicantApplicationStatus.start_date}, + end_date = ${applicantApplicationStatus.end_date}, + last_updated = ${applicantApplicationStatus.last_updated}, + notes = ${applicantApplicationStatus.notes} + WHERE id = ${applicantApplicationStatus.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for applicant_application_status update"); + } +} + +isolated function deleteApplicantApplicationStatus(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM applicant_application_status WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for applicant_application_status delete"); + } +} diff --git a/ApplicantEvaluation.bal b/ApplicantEvaluation.bal new file mode 100644 index 0000000..12210b6 --- /dev/null +++ b/ApplicantEvaluation.bal @@ -0,0 +1,98 @@ +import ballerina/sql; + +import ballerina/time; + +public type ApplicantEvaluation record { + int? id = (); + int applicant_id; + int job_evaluation_criteria_id; + int interviewer_id; + int rating; + string description; + time:Utc last_updated = time:utcNow(); +}; + +public isolated function getApplicantEvaluations() returns ApplicantEvaluation[]|error { + ApplicantEvaluation[] applicantEvaluations = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + applicant_id , + job_evaluation_criteria_id , + interviewer_id , + rating , + description , + last_updated + FROM applicant_evaluation` + ); + check from ApplicantEvaluation applicantEvaluation in resultStream + do { + applicantEvaluations.push(applicantEvaluation); + }; + check resultStream.close(); + return applicantEvaluations; +} + +public isolated function getApplicantEvaluation(int id) returns ApplicantEvaluation|error { + ApplicantEvaluation applicantEvaluation = check smsDBClient->queryRow( + `SELECT * FROM applicant_evaluation WHERE id = ${id}` + ); + return applicantEvaluation; +} + +public isolated function addApplicantEvaluation(ApplicantEvaluation applicantEvaluation) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO applicant_evaluation ( + applicant_id , + job_evaluation_criteria_id , + interviewer_id , + rating , + description , + last_updated ) + VALUES ( + ${applicantEvaluation.applicant_id}, + ${applicantEvaluation.job_evaluation_criteria_id}, + ${applicantEvaluation.interviewer_id}, + ${applicantEvaluation.rating}, + ${applicantEvaluation.description}, + ${applicantEvaluation.last_updated} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for applicant_evaluation"); + } +} + +public isolated function updateApplicantEvaluation(ApplicantEvaluation applicantEvaluation) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE applicant_evaluation SET + applicant_id = ${applicantEvaluation.applicant_id}, + job_evaluation_criteria_id = ${applicantEvaluation.job_evaluation_criteria_id}, + interviewer_id = ${applicantEvaluation.interviewer_id}, + rating = ${applicantEvaluation.rating}, + description = ${applicantEvaluation.description}, + last_updated = ${applicantEvaluation.last_updated} + WHERE id = ${applicantEvaluation.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for applicant_evaluation update"); + } +} + +isolated function deleteApplicantEvaluation(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM applicant_evaluation WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for applicant_evaluation delete"); + } +} diff --git a/ApplicantInterview.bal b/ApplicantInterview.bal new file mode 100644 index 0000000..939776e --- /dev/null +++ b/ApplicantInterview.bal @@ -0,0 +1,118 @@ +import ballerina/sql; + +import ballerina/time; + +public type ApplicantInterview record { + int? id = (); + int applicant_id; + int interviewer_id; + time:Utc date_time; + string description; + string current_status; + string outcome; + int rating; + string? comments = (); # ENUM ('Pending', 'Done', 'Cancelled', 'Postponed', 'No show') NOT NULL DEFAULT 'Pending' + string? notes = (); # ENUM ('Selected', 'Rejected', 'On hold', 'Short List', 'Cross-check', 'Maybe', 'TBD') NOT NULL DEFAULT 'TBD', + time:Utc last_updated = time:utcNow(); +}; + +public isolated function getApplicantInterviews() returns ApplicantInterview[]|error { + ApplicantInterview[] applicantInterviews = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + applicant_id , + interviewer_id , + date_time , + description , + current_status , + outcome , + rating , + comments , + notes , + last_updated + FROM applicant_interview` + ); + check from ApplicantInterview applicantInterview in resultStream + do { + applicantInterviews.push(applicantInterview); + }; + check resultStream.close(); + return applicantInterviews; +} + +public isolated function getApplicantInterview(int id) returns ApplicantInterview|error { + ApplicantInterview applicantInterview = check smsDBClient->queryRow( + `SELECT * FROM applicant_interview WHERE id = ${id}` + ); + return applicantInterview; +} + +public isolated function addApplicantInterview(ApplicantInterview applicantInterview) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO applicant_interview ( + applicant_id , + interviewer_id , + date_time , + description , + current_status , + outcome , + rating , + comments , + notes , + last_updated ) + VALUES ( + ${applicantInterview.applicant_id}, + ${applicantInterview.interviewer_id}, + ${applicantInterview.date_time}, + ${applicantInterview.description}, + ${applicantInterview.current_status}, + ${applicantInterview.outcome}, + ${applicantInterview.rating}, + ${applicantInterview.comments}, + ${applicantInterview.notes}, + ${applicantInterview.last_updated} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for applicant_interview"); + } +} + +public isolated function updateApplicantInterview(ApplicantInterview applicantInterview) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE applicant_interview SET + applicant_id = ${applicantInterview.applicant_id}, + interviewer_id = ${applicantInterview.interviewer_id}, + date_time = ${applicantInterview.date_time}, + description = ${applicantInterview.description}, + current_status = ${applicantInterview.current_status}, + outcome = ${applicantInterview.outcome}, + rating = ${applicantInterview.rating}, + comments = ${applicantInterview.comments}, + notes = ${applicantInterview.notes}, + last_updated = ${applicantInterview.last_updated} + WHERE id = ${applicantInterview.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for applicant_interview update"); + } +} + +isolated function deleteApplicantInterview(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM applicant_interview WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for applicant_interview delete"); + } +} diff --git a/ApplicantQualification.bal b/ApplicantQualification.bal new file mode 100644 index 0000000..be18eb0 --- /dev/null +++ b/ApplicantQualification.bal @@ -0,0 +1,93 @@ +import ballerina/sql; + +import ballerina/time; + +public type ApplicantQualification record { + int? id = (); + int applicant_id; + int job_qualification_id; + int rating; + string description; + time:Utc last_updated = time:utcNow(); +}; + +public isolated function getApplicantQualifications() returns ApplicantQualification[]|error { + ApplicantQualification[] applicantQualifications = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + applicant_id , + job_qualification_id , + rating , + description , + last_updated + FROM applicant_qualification` + ); + check from ApplicantQualification applicantQualification in resultStream + do { + applicantQualifications.push(applicantQualification); + }; + check resultStream.close(); + return applicantQualifications; +} + +public isolated function getApplicantQualification(int id) returns ApplicantQualification|error { + ApplicantQualification applicantQualification = check smsDBClient->queryRow( + `SELECT * FROM applicant_qualification WHERE id = ${id}` + ); + return applicantQualification; +} + +public isolated function addApplicantQualification(ApplicantQualification applicantQualification) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO applicant_qualification ( + applicant_id , + job_qualification_id , + rating , + description , + last_updated ) + VALUES ( + ${applicantQualification.applicant_id}, + ${applicantQualification.job_qualification_id}, + ${applicantQualification.rating}, + ${applicantQualification.description}, + ${applicantQualification.last_updated} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for applicant_qualification"); + } +} + +public isolated function updateApplicantQualification(ApplicantQualification applicantQualification) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE applicant_qualification SET + applicant_id = ${applicantQualification.applicant_id}, + job_qualification_id = ${applicantQualification.job_qualification_id}, + rating = ${applicantQualification.rating}, + description = ${applicantQualification.description}, + last_updated = ${applicantQualification.last_updated} + WHERE id = ${applicantQualification.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for applicant_qualification update"); + } +} + +isolated function deleteApplicantQualification(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM applicant_qualification WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for applicant_qualification delete"); + } +} diff --git a/ApplicantSkill.bal b/ApplicantSkill.bal new file mode 100644 index 0000000..9dd800c --- /dev/null +++ b/ApplicantSkill.bal @@ -0,0 +1,98 @@ +import ballerina/sql; + +import ballerina/time; + +public type ApplicantSkill record { + int? id = (); + int applicant_id; + int job_skill_id; + int evaluator_id; + int rating; + string description; + time:Utc last_updated = time:utcNow(); +}; + +public isolated function getApplicantSkills() returns ApplicantSkill[]|error { + ApplicantSkill[] applicantSkills = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + applicant_id , + job_skill_id , + evaluator_id , + rating , + description , + last_updated + FROM applicant_skill` + ); + check from ApplicantSkill applicantSkill in resultStream + do { + applicantSkills.push(applicantSkill); + }; + check resultStream.close(); + return applicantSkills; +} + +public isolated function getApplicantSkill(int id) returns ApplicantSkill|error { + ApplicantSkill applicantSkill = check smsDBClient->queryRow( + `SELECT * FROM applicant_skill WHERE id = ${id}` + ); + return applicantSkill; +} + +public isolated function addApplicantSkill(ApplicantSkill applicantSkill) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO applicant_skill ( + applicant_id , + job_skill_id , + evaluator_id , + rating , + description , + last_updated ) + VALUES ( + ${applicantSkill.applicant_id}, + ${applicantSkill.job_skill_id}, + ${applicantSkill.evaluator_id}, + ${applicantSkill.rating}, + ${applicantSkill.description}, + ${applicantSkill.last_updated} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for applicant_skill"); + } +} + +public isolated function updateApplicantSkill(ApplicantSkill applicantSkill) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE applicant_skill SET + applicant_id = ${applicantSkill.applicant_id}, + job_skill_id = ${applicantSkill.job_skill_id}, + evaluator_id = ${applicantSkill.evaluator_id}, + rating = ${applicantSkill.rating}, + description = ${applicantSkill.description}, + last_updated = ${applicantSkill.last_updated} + WHERE id = ${applicantSkill.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for applicant_skill update"); + } +} + +isolated function deleteApplicantSkill(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM applicant_skill WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for applicant_skill delete"); + } +} diff --git a/ApplicationStatus.bal b/ApplicationStatus.bal new file mode 100644 index 0000000..09364c4 --- /dev/null +++ b/ApplicationStatus.bal @@ -0,0 +1,81 @@ +import ballerina/sql; + +public type ApplicationStatus record { + int? id = (); + string name; + int sequence_no; + string description; +}; + +public isolated function getApplicationStatuses() returns ApplicationStatus[]|error { + ApplicationStatus[] applicationStatuses = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + name , + sequence_no , + description + FROM application_status` + ); + check from ApplicationStatus applicationStatus in resultStream + do { + applicationStatuses.push(applicationStatus); + }; + check resultStream.close(); + return applicationStatuses; +} + +public isolated function getApplicationStatus(int id) returns ApplicationStatus|error { + ApplicationStatus applicationStatus = check smsDBClient->queryRow( + `SELECT * FROM application_status WHERE id = ${id}` + ); + return applicationStatus; +} + +public isolated function addApplicationStatus(ApplicationStatus applicationStatus) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO application_status ( + name , + sequence_no , + description ) + VALUES ( + ${applicationStatus.name}, + ${applicationStatus.sequence_no}, + ${applicationStatus.description} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for application_status"); + } +} + +public isolated function updateApplicationStatus(ApplicationStatus applicationStatus) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE application_status SET + name = ${applicationStatus.name}, + sequence_no = ${applicationStatus.sequence_no}, + description = ${applicationStatus.description} + WHERE id = ${applicationStatus.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for application_status update"); + } +} + +isolated function deleteApplicationStatus(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM application_status WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for application_status delete"); + } +} diff --git a/AttendanceType.bal b/AttendanceType.bal new file mode 100644 index 0000000..087b78e --- /dev/null +++ b/AttendanceType.bal @@ -0,0 +1,81 @@ +import ballerina/sql; + +public type AttendanceType record { + int? id = (); + int employment_type_id; + string name; + string description; +}; + +public isolated function getAttendanceTypes() returns AttendanceType[]|error { + AttendanceType[] attendanceTypes = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + employment_type_id , + name , + description + FROM attendance_type` + ); + check from AttendanceType attendanceType in resultStream + do { + attendanceTypes.push(attendanceType); + }; + check resultStream.close(); + return attendanceTypes; +} + +public isolated function getAttendanceType(int id) returns AttendanceType|error { + AttendanceType attendanceType = check smsDBClient->queryRow( + `SELECT * FROM attendance_type WHERE id = ${id}` + ); + return attendanceType; +} + +public isolated function addAttendanceType(AttendanceType attendanceType) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO attendance_type ( + employment_type_id , + name , + description ) + VALUES ( + ${attendanceType.employment_type_id}, + ${attendanceType.name}, + ${attendanceType.description} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for attendance_type"); + } +} + +public isolated function updateAttendanceType(AttendanceType attendanceType) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE attendance_type SET + employment_type_id = ${attendanceType.employment_type_id}, + name = ${attendanceType.name}, + description = ${attendanceType.description} + WHERE id = ${attendanceType.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for attendance_type update"); + } +} + +isolated function deleteAttendanceType(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM attendance_type WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for attendance_type delete"); + } +} diff --git a/Branch.bal b/Branch.bal new file mode 100644 index 0000000..b621007 --- /dev/null +++ b/Branch.bal @@ -0,0 +1,91 @@ +import ballerina/sql; + +public type Branch record { + int? id = (); + int organization_id; + string name; + string description; + string phone_number1; + string phone_number2; +}; + +public isolated function getBranches() returns Branch[]|error { + Branch[] branches = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + organization_id , + name , + description , + phone_number1 , + phone_number2 + FROM branch` + ); + check from Branch branch in resultStream + do { + branches.push(branch); + }; + check resultStream.close(); + return branches; +} + +public isolated function getBranch(int id) returns Branch|error { + Branch branch = check smsDBClient->queryRow( + `SELECT * FROM branch WHERE id = ${id}` + ); + return branch; +} + +public isolated function addBranch(Branch branch) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO branch ( + organization_id , + name , + description , + phone_number1 , + phone_number2 ) + VALUES ( + ${branch.organization_id}, + ${branch.name}, + ${branch.description}, + ${branch.phone_number1}, + ${branch.phone_number2} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for branch"); + } +} + +public isolated function updateBranch(Branch branch) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE branch SET + organization_id = ${branch.organization_id}, + name = ${branch.name}, + description = ${branch.description}, + phone_number1 = ${branch.phone_number1}, + phone_number2 = ${branch.phone_number2} + WHERE id = ${branch.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for branch update"); + } +} + +isolated function deleteBranch(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM branch WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for branch delete"); + } +} diff --git a/BranchAddress.bal b/BranchAddress.bal new file mode 100644 index 0000000..f78dac3 --- /dev/null +++ b/BranchAddress.bal @@ -0,0 +1,90 @@ +import ballerina/sql; + +public type BranchAddress record { + int branch_id; + int address_id; +}; + +public isolated function getBranchAddresses() returns BranchAddress[]|error { + BranchAddress[] branchAddresses = []; + stream resultStream = smsDBClient->query( + `SELECT + branch_id , + address_id + FROM branch_address` + ); + check from BranchAddress branchAddress in resultStream + do { + branchAddresses.push(branchAddress); + }; + check resultStream.close(); + return branchAddresses; +} + +public isolated function getBranchAddress(int branch_id, int address_id) returns BranchAddress|error { + BranchAddress branchAddress = check smsDBClient->queryRow( + `SELECT * FROM branch_address WHERE branch_id = ${branch_id} AND address_id = ${address_id}` + ); + return branchAddress; +} + +public isolated function getAddressesForBranch(int branch_id) returns BranchAddress[]|error { + BranchAddress[] branchAddresses = []; + stream resultStream = smsDBClient->query( + `SELECT + branch_id , + address_id + FROM branch_address WHERE branch_id = ${branch_id}` + ); + check from BranchAddress branchAddress in resultStream + do { + branchAddresses.push(branchAddress); + }; + check resultStream.close(); + return branchAddresses; +} + +public isolated function addBranchAddress(BranchAddress branchAddress) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO branch_address ( + branch_id , + address_id ) + VALUES ( + ${branchAddress.branch_id}, + ${branchAddress.address_id} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for branch_address"); + } +} + +public isolated function updateBranchAddress(BranchAddress branchAddress) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE branch_address SET + branch_id = ${branchAddress.branch_id}, + address_id = ${branchAddress.address_id} + WHERE branch_address = ${branchAddress.branch_id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for branch_address update"); + } +} + +isolated function deleteBranchAddress(int branch_id, int address_id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM branch_address WHERE branch_id = ${branch_id} AND address_id = ${address_id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for branch_address delete"); + } +} diff --git a/Dependencies.toml b/Dependencies.toml index 043ea6f..a79c911 100644 --- a/Dependencies.toml +++ b/Dependencies.toml @@ -13,6 +13,7 @@ version = "0.1.0" dependencies = [ {org = "ballerina", name = "http"}, {org = "ballerina", name = "sql"}, + {org = "ballerina", name = "time"}, {org = "ballerinai", name = "observe"}, {org = "ballerinax", name = "mysql"}, {org = "ballerinax", name = "mysql.driver"} @@ -276,6 +277,9 @@ version = "2.2.2" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] +modules = [ + {org = "ballerina", packageName = "time", moduleName = "time"} +] [[package]] org = "ballerina" diff --git a/Employee.bal b/Employee.bal new file mode 100644 index 0000000..c5dd4d1 --- /dev/null +++ b/Employee.bal @@ -0,0 +1,133 @@ +import ballerina/sql; + +import ballerina/time; + +public type Employee record { + int? id = (); + string employee_id; + string first_name; + string last_name; + string name_with_initials; + string full_name; + string gender; + string hire_date; + string id_number; + string phone_number1; + string? phone_number2 = (); + string? email = (); + string? cv_location = (); + time:Utc last_updated = time:utcNow(); +}; + +public isolated function getEmployees() returns Employee[]|error { + Employee[] employees = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + employee_id , + first_name , + last_name , + name_with_initials , + full_name , + gender , + hire_date , + id_number , + phone_number1 , + phone_number2 , + email , + cv_location , + last_updated + FROM employee` + ); + check from Employee employee in resultStream + do { + employees.push(employee); + }; + check resultStream.close(); + return employees; +} + +public isolated function getEmployee(int id) returns Employee|error { + Employee employee = check smsDBClient->queryRow( + `SELECT * FROM employee WHERE id = ${id}` + ); + return employee; +} + +public isolated function addEmployee(Employee employee) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO employee ( + employee_id , + first_name , + last_name , + name_with_initials , + full_name , + gender , + hire_date , + id_number , + phone_number1 , + phone_number2 , + email , + cv_location , + last_updated ) + VALUES ( + ${employee.employee_id}, + ${employee.first_name}, + ${employee.last_name}, + ${employee.name_with_initials}, + ${employee.full_name}, + ${employee.gender}, + ${employee.hire_date}, + ${employee.id_number}, + ${employee.phone_number1}, + ${employee.phone_number2}, + ${employee.email}, + ${employee.cv_location}, + ${employee.last_updated} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for employee"); + } +} + +public isolated function updateEmployee(Employee employee) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE employee SET + employee_id = ${employee.employee_id}, + first_name = ${employee.first_name}, + last_name = ${employee.last_name}, + name_with_initials = ${employee.name_with_initials}, + full_name = ${employee.full_name}, + gender = ${employee.gender}, + hire_date = ${employee.hire_date}, + id_number = ${employee.id_number}, + phone_number1 = ${employee.phone_number1}, + phone_number2 = ${employee.phone_number2}, + email = ${employee.email}, + cv_location = ${employee.cv_location}, + last_updated = ${employee.last_updated} + WHERE id = ${employee.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for employee update"); + } +} + +isolated function deleteEmployee(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM employee WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for employee delete"); + } +} diff --git a/EmployeeAddress.bal b/EmployeeAddress.bal new file mode 100644 index 0000000..7870936 --- /dev/null +++ b/EmployeeAddress.bal @@ -0,0 +1,90 @@ +import ballerina/sql; + +public type EmployeeAddress record { + int employee_id; + int address_id; +}; + +public isolated function getEmployeeAddresses() returns EmployeeAddress[]|error { + EmployeeAddress[] employeeAddresses = []; + stream resultStream = smsDBClient->query( + `SELECT + employee_id , + address_id + FROM employee_address` + ); + check from EmployeeAddress employeeAddress in resultStream + do { + employeeAddresses.push(employeeAddress); + }; + check resultStream.close(); + return employeeAddresses; +} + +public isolated function getEmployeeAddress(int employee_id, int address_id) returns EmployeeAddress|error { + EmployeeAddress employeeAddress = check smsDBClient->queryRow( + `SELECT * FROM employee_address WHERE employee_id = ${employee_id} AND address_id = ${address_id}` + ); + return employeeAddress; +} + +public isolated function getAddressesForEmployee(int employee_id) returns EmployeeAddress[]|error { + EmployeeAddress[] employeeAddresses = []; + stream resultStream = smsDBClient->query( + `SELECT + employee_id , + address_id + FROM employee_address WHERE employee_id = ${employee_id}` + ); + check from EmployeeAddress employeeAddress in resultStream + do { + employeeAddresses.push(employeeAddress); + }; + check resultStream.close(); + return employeeAddresses; +} + +public isolated function addEmployeeAddress(EmployeeAddress employeeAddress) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO employee_address ( + employee_id , + address_id ) + VALUES ( + ${employeeAddress.employee_id}, + ${employeeAddress.address_id} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for employee_address"); + } +} + +public isolated function updateEmployeeAddress(EmployeeAddress employeeAddress) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE employee_address SET + employee_id = ${employeeAddress.employee_id}, + address_id = ${employeeAddress.address_id} + WHERE employee_address = ${employeeAddress.employee_id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for employee_address update"); + } +} + +isolated function deleteEmployeeAddress(int employee_id, int address_id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM employee_address WHERE employee_id = ${employee_id} AND address_id = ${address_id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for employee_address delete"); + } +} diff --git a/EmployeeAttendance.bal b/EmployeeAttendance.bal new file mode 100644 index 0000000..91fe3b3 --- /dev/null +++ b/EmployeeAttendance.bal @@ -0,0 +1,88 @@ +import ballerina/sql; + +import ballerina/time; + +public type EmployeeAttendance record { + int? id = (); + int employee_id; + int attendance_type_id; + time:Utc time_stamp = time:utcNow(); + time:Utc last_updated = time:utcNow(); +}; + +public isolated function getEmployeeAttendances() returns EmployeeAttendance[]|error { + EmployeeAttendance[] employeeAttendances = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + employee_id , + attendance_type_id , + time_stamp , + last_updated + FROM employee_attendance` + ); + check from EmployeeAttendance employeeAttendance in resultStream + do { + employeeAttendances.push(employeeAttendance); + }; + check resultStream.close(); + return employeeAttendances; +} + +public isolated function getEmployeeAttendance(int id) returns EmployeeAttendance|error { + EmployeeAttendance employeeAttendance = check smsDBClient->queryRow( + `SELECT * FROM employee_attendance WHERE id = ${id}` + ); + return employeeAttendance; +} + +public isolated function addEmployeeAttendance(EmployeeAttendance employeeAttendance) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO employee_attendance ( + employee_id , + attendance_type_id , + time_stamp , + last_updated ) + VALUES ( + ${employeeAttendance.employee_id}, + ${employeeAttendance.attendance_type_id}, + ${employeeAttendance.time_stamp}, + ${employeeAttendance.last_updated} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for employee_attendance"); + } +} + +public isolated function updateEmployeeAttendance(EmployeeAttendance employeeAttendance) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE employee_attendance SET + employee_id = ${employeeAttendance.employee_id}, + attendance_type_id = ${employeeAttendance.attendance_type_id}, + time_stamp = ${employeeAttendance.time_stamp}, + last_updated = ${employeeAttendance.last_updated} + WHERE id = ${employeeAttendance.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for employee_attendance update"); + } +} + +isolated function deleteEmployeeAttendance(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM employee_attendance WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for employee_attendance delete"); + } +} diff --git a/EmployeeEmploymentStatus.bal b/EmployeeEmploymentStatus.bal new file mode 100644 index 0000000..3bd8c3e --- /dev/null +++ b/EmployeeEmploymentStatus.bal @@ -0,0 +1,93 @@ +import ballerina/sql; + +import ballerina/time; + +public type EmployeeEmploymentStatus record { + int? id = (); + int employee_id; + int employment_status_id; + string start_date; + string? end_date = (); + time:Utc last_updated = time:utcNow(); +}; + +public isolated function getEmployeeEmploymentStatuses() returns EmployeeEmploymentStatus[]|error { + EmployeeEmploymentStatus[] employeeEmploymentStatuses = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + employee_id , + employment_status_id , + start_date , + end_date , + last_updated + FROM employee_employment_status` + ); + check from EmployeeEmploymentStatus employeeEmploymentStatus in resultStream + do { + employeeEmploymentStatuses.push(employeeEmploymentStatus); + }; + check resultStream.close(); + return employeeEmploymentStatuses; +} + +public isolated function getEmployeeEmploymentStatus(int id) returns EmployeeEmploymentStatus|error { + EmployeeEmploymentStatus employeeEmploymentStatus = check smsDBClient->queryRow( + `SELECT * FROM employee_employment_status WHERE id = ${id}` + ); + return employeeEmploymentStatus; +} + +public isolated function addEmployeeEmploymentStatus(EmployeeEmploymentStatus employeeEmploymentStatus) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO employee_employment_status ( + employee_id , + employment_status_id , + start_date , + end_date , + last_updated ) + VALUES ( + ${employeeEmploymentStatus.employee_id}, + ${employeeEmploymentStatus.employment_status_id}, + ${employeeEmploymentStatus.start_date}, + ${employeeEmploymentStatus.end_date}, + ${employeeEmploymentStatus.last_updated} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for employee_employment_status"); + } +} + +public isolated function updateEmployeeEmploymentStatus(EmployeeEmploymentStatus employeeEmploymentStatus) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE employee_employment_status SET + employee_id = ${employeeEmploymentStatus.employee_id}, + employment_status_id = ${employeeEmploymentStatus.employment_status_id}, + start_date = ${employeeEmploymentStatus.start_date}, + end_date = ${employeeEmploymentStatus.end_date}, + last_updated = ${employeeEmploymentStatus.last_updated} + WHERE id = ${employeeEmploymentStatus.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for employee_employment_status update"); + } +} + +isolated function deleteEmployeeEmploymentStatus(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM employee_employment_status WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for employee_employment_status delete"); + } +} diff --git a/EmployeeEmploymentType.bal b/EmployeeEmploymentType.bal new file mode 100644 index 0000000..09424f6 --- /dev/null +++ b/EmployeeEmploymentType.bal @@ -0,0 +1,93 @@ +import ballerina/sql; + +import ballerina/time; + +public type EmployeeEmploymentType record { + int? id = (); + int employee_id; + int employment_type_id; + string start_date; + string? end_date = (); + time:Utc last_updated = time:utcNow(); +}; + +public isolated function getEmployeeEmploymentTypes() returns EmployeeEmploymentType[]|error { + EmployeeEmploymentType[] employeeEmploymentTypes = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + employee_id , + employment_type_id , + start_date , + end_date , + last_updated + FROM employee_employment_type` + ); + check from EmployeeEmploymentType employeeEmploymentType in resultStream + do { + employeeEmploymentTypes.push(employeeEmploymentType); + }; + check resultStream.close(); + return employeeEmploymentTypes; +} + +public isolated function getEmployeeEmploymentType(int id) returns EmployeeEmploymentType|error { + EmployeeEmploymentType employeeEmploymentType = check smsDBClient->queryRow( + `SELECT * FROM employee_employment_type WHERE id = ${id}` + ); + return employeeEmploymentType; +} + +public isolated function addEmployeeEmploymentType(EmployeeEmploymentType employeeEmploymentType) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO employee_employment_type ( + employee_id , + employment_type_id , + start_date , + end_date , + last_updated ) + VALUES ( + ${employeeEmploymentType.employee_id}, + ${employeeEmploymentType.employment_type_id}, + ${employeeEmploymentType.start_date}, + ${employeeEmploymentType.end_date}, + ${employeeEmploymentType.last_updated} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for employee_employment_type"); + } +} + +public isolated function updateEmployeeEmploymentType(EmployeeEmploymentType employeeEmploymentType) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE employee_employment_type SET + employee_id = ${employeeEmploymentType.employee_id}, + employment_type_id = ${employeeEmploymentType.employment_type_id}, + start_date = ${employeeEmploymentType.start_date}, + end_date = ${employeeEmploymentType.end_date}, + last_updated = ${employeeEmploymentType.last_updated} + WHERE id = ${employeeEmploymentType.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for employee_employment_type update"); + } +} + +isolated function deleteEmployeeEmploymentType(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM employee_employment_type WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for employee_employment_type delete"); + } +} diff --git a/EmployeeEvaluation.bal b/EmployeeEvaluation.bal new file mode 100644 index 0000000..04d739d --- /dev/null +++ b/EmployeeEvaluation.bal @@ -0,0 +1,103 @@ +import ballerina/sql; + +import ballerina/time; + +public type EmployeeEvaluation record { + int? id = (); + int employee_id; + int job_evaluation_criteria_id; + int evaluator_id; + int evaluation_cycle_id; + int rating; + string description; + time:Utc last_updated = time:utcNow(); +}; + +public isolated function getEmployeeEvaluations() returns EmployeeEvaluation[]|error { + EmployeeEvaluation[] employeeEvaluations = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + employee_id , + job_evaluation_criteria_id , + evaluator_id , + evaluation_cycle_id , + rating , + description , + last_updated + FROM employee_evaluation` + ); + check from EmployeeEvaluation employeeEvaluation in resultStream + do { + employeeEvaluations.push(employeeEvaluation); + }; + check resultStream.close(); + return employeeEvaluations; +} + +public isolated function getEmployeeEvaluation(int id) returns EmployeeEvaluation|error { + EmployeeEvaluation employeeEvaluation = check smsDBClient->queryRow( + `SELECT * FROM employee_evaluation WHERE id = ${id}` + ); + return employeeEvaluation; +} + +public isolated function addEmployeeEvaluation(EmployeeEvaluation employeeEvaluation) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO employee_evaluation ( + employee_id , + job_evaluation_criteria_id , + evaluator_id , + evaluation_cycle_id , + rating , + description , + last_updated ) + VALUES ( + ${employeeEvaluation.employee_id}, + ${employeeEvaluation.job_evaluation_criteria_id}, + ${employeeEvaluation.evaluator_id}, + ${employeeEvaluation.evaluation_cycle_id}, + ${employeeEvaluation.rating}, + ${employeeEvaluation.description}, + ${employeeEvaluation.last_updated} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for employee_evaluation"); + } +} + +public isolated function updateEmployeeEvaluation(EmployeeEvaluation employeeEvaluation) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE employee_evaluation SET + employee_id = ${employeeEvaluation.employee_id}, + job_evaluation_criteria_id = ${employeeEvaluation.job_evaluation_criteria_id}, + evaluator_id = ${employeeEvaluation.evaluator_id}, + evaluation_cycle_id = ${employeeEvaluation.evaluation_cycle_id}, + rating = ${employeeEvaluation.rating}, + description = ${employeeEvaluation.description}, + last_updated = ${employeeEvaluation.last_updated} + WHERE id = ${employeeEvaluation.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for employee_evaluation update"); + } +} + +isolated function deleteEmployeeEvaluation(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM employee_evaluation WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for employee_evaluation delete"); + } +} diff --git a/EmployeeLeave.bal b/EmployeeLeave.bal new file mode 100644 index 0000000..f9a9b3c --- /dev/null +++ b/EmployeeLeave.bal @@ -0,0 +1,103 @@ +import ballerina/sql; + +import ballerina/time; + +public type EmployeeLeave record { + int? id = (); + int employee_id; + int leave_type_id; + time:Utc applied_on = time:utcNow(); + string start_date; + string? end_date = (); + int approved_by; + time:Utc last_updated = time:utcNow(); +}; + +public isolated function getEmployeeLeaves() returns EmployeeLeave[]|error { + EmployeeLeave[] employeeLeaves = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + employee_id , + leave_type_id , + applied_on , + start_date , + end_date , + approved_by , + last_updated + FROM employee_leave` + ); + check from EmployeeLeave employeeLeave in resultStream + do { + employeeLeaves.push(employeeLeave); + }; + check resultStream.close(); + return employeeLeaves; +} + +public isolated function getEmployeeLeave(int id) returns EmployeeLeave|error { + EmployeeLeave employeeLeave = check smsDBClient->queryRow( + `SELECT * FROM employee_leave WHERE id = ${id}` + ); + return employeeLeave; +} + +public isolated function addEmployeeLeave(EmployeeLeave employeeLeave) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO employee_leave ( + employee_id , + leave_type_id , + applied_on , + start_date , + end_date , + approved_by , + last_updated ) + VALUES ( + ${employeeLeave.employee_id}, + ${employeeLeave.leave_type_id}, + ${employeeLeave.applied_on}, + ${employeeLeave.start_date}, + ${employeeLeave.end_date}, + ${employeeLeave.approved_by}, + ${employeeLeave.last_updated} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for employee_leave"); + } +} + +public isolated function updateEmployeeLeave(EmployeeLeave employeeLeave) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE employee_leave SET + employee_id = ${employeeLeave.employee_id}, + leave_type_id = ${employeeLeave.leave_type_id}, + applied_on = ${employeeLeave.applied_on}, + start_date = ${employeeLeave.start_date}, + end_date = ${employeeLeave.end_date}, + approved_by = ${employeeLeave.approved_by}, + last_updated = ${employeeLeave.last_updated} + WHERE id = ${employeeLeave.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for employee_leave update"); + } +} + +isolated function deleteEmployeeLeave(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM employee_leave WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for employee_leave delete"); + } +} diff --git a/EmployeeQualification.bal b/EmployeeQualification.bal new file mode 100644 index 0000000..55e7833 --- /dev/null +++ b/EmployeeQualification.bal @@ -0,0 +1,98 @@ +import ballerina/sql; + +import ballerina/time; + +public type EmployeeQualification record { + int? id = (); + int employee_id; + int job_qualification_id; + int verified_by; + int rating; + string description; + time:Utc last_updated = time:utcNow(); +}; + +public isolated function getEmployeeQualifications() returns EmployeeQualification[]|error { + EmployeeQualification[] employeeQualifications = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + employee_id , + job_qualification_id , + verified_by , + rating , + description , + last_updated + FROM employee_qualification` + ); + check from EmployeeQualification employeeQualification in resultStream + do { + employeeQualifications.push(employeeQualification); + }; + check resultStream.close(); + return employeeQualifications; +} + +public isolated function getEmployeeQualification(int id) returns EmployeeQualification|error { + EmployeeQualification employeeQualification = check smsDBClient->queryRow( + `SELECT * FROM employee_qualification WHERE id = ${id}` + ); + return employeeQualification; +} + +public isolated function addEmployeeQualification(EmployeeQualification employeeQualification) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO employee_qualification ( + employee_id , + job_qualification_id , + verified_by , + rating , + description , + last_updated ) + VALUES ( + ${employeeQualification.employee_id}, + ${employeeQualification.job_qualification_id}, + ${employeeQualification.verified_by}, + ${employeeQualification.rating}, + ${employeeQualification.description}, + ${employeeQualification.last_updated} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for employee_qualification"); + } +} + +public isolated function updateEmployeeQualification(EmployeeQualification employeeQualification) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE employee_qualification SET + employee_id = ${employeeQualification.employee_id}, + job_qualification_id = ${employeeQualification.job_qualification_id}, + verified_by = ${employeeQualification.verified_by}, + rating = ${employeeQualification.rating}, + description = ${employeeQualification.description}, + last_updated = ${employeeQualification.last_updated} + WHERE id = ${employeeQualification.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for employee_qualification update"); + } +} + +isolated function deleteEmployeeQualification(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM employee_qualification WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for employee_qualification delete"); + } +} diff --git a/EmployeeSkill.bal b/EmployeeSkill.bal new file mode 100644 index 0000000..3f0b4c4 --- /dev/null +++ b/EmployeeSkill.bal @@ -0,0 +1,98 @@ +import ballerina/sql; + +import ballerina/time; + +public type EmployeeSkill record { + int? id = (); + int employee_id; + int job_skill_id; + int evaluator_id; + int rating; + string description; + time:Utc last_updated = time:utcNow(); +}; + +public isolated function getEmployeeSkills() returns EmployeeSkill[]|error { + EmployeeSkill[] employeeSkills = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + employee_id , + job_skill_id , + evaluator_id , + rating , + description , + last_updated + FROM employee_skill` + ); + check from EmployeeSkill employeeSkill in resultStream + do { + employeeSkills.push(employeeSkill); + }; + check resultStream.close(); + return employeeSkills; +} + +public isolated function getEmployeeSkill(int id) returns EmployeeSkill|error { + EmployeeSkill employeeSkill = check smsDBClient->queryRow( + `SELECT * FROM employee_skill WHERE id = ${id}` + ); + return employeeSkill; +} + +public isolated function addEmployeeSkill(EmployeeSkill employeeSkill) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO employee_skill ( + employee_id , + job_skill_id , + evaluator_id , + rating , + description , + last_updated ) + VALUES ( + ${employeeSkill.employee_id}, + ${employeeSkill.job_skill_id}, + ${employeeSkill.evaluator_id}, + ${employeeSkill.rating}, + ${employeeSkill.description}, + ${employeeSkill.last_updated} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for employee_skill"); + } +} + +public isolated function updateEmployeeSkill(EmployeeSkill employeeSkill) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE employee_skill SET + employee_id = ${employeeSkill.employee_id}, + job_skill_id = ${employeeSkill.job_skill_id}, + evaluator_id = ${employeeSkill.evaluator_id}, + rating = ${employeeSkill.rating}, + description = ${employeeSkill.description}, + last_updated = ${employeeSkill.last_updated} + WHERE id = ${employeeSkill.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for employee_skill update"); + } +} + +isolated function deleteEmployeeSkill(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM employee_skill WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for employee_skill delete"); + } +} diff --git a/EmploymentStatus.bal b/EmploymentStatus.bal new file mode 100644 index 0000000..565be7d --- /dev/null +++ b/EmploymentStatus.bal @@ -0,0 +1,81 @@ +import ballerina/sql; + +public type EmploymentStatus record { + int? id = (); + string name; + int sequence_no; + string description; +}; + +public isolated function getEmploymentStatuses() returns EmploymentStatus[]|error { + EmploymentStatus[] employmentStatuses = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + name , + sequence_no , + description + FROM employment_status` + ); + check from EmploymentStatus employmentStatus in resultStream + do { + employmentStatuses.push(employmentStatus); + }; + check resultStream.close(); + return employmentStatuses; +} + +public isolated function getEmploymentStatus(int id) returns EmploymentStatus|error { + EmploymentStatus employmentStatus = check smsDBClient->queryRow( + `SELECT * FROM employment_status WHERE id = ${id}` + ); + return employmentStatus; +} + +public isolated function addEmploymentStatus(EmploymentStatus employmentStatus) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO employment_status ( + name , + sequence_no , + description ) + VALUES ( + ${employmentStatus.name}, + ${employmentStatus.sequence_no}, + ${employmentStatus.description} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for employment_status"); + } +} + +public isolated function updateEmploymentStatus(EmploymentStatus employmentStatus) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE employment_status SET + name = ${employmentStatus.name}, + sequence_no = ${employmentStatus.sequence_no}, + description = ${employmentStatus.description} + WHERE id = ${employmentStatus.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for employment_status update"); + } +} + +isolated function deleteEmploymentStatus(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM employment_status WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for employment_status delete"); + } +} diff --git a/EmploymentType.bal b/EmploymentType.bal new file mode 100644 index 0000000..780e512 --- /dev/null +++ b/EmploymentType.bal @@ -0,0 +1,76 @@ +import ballerina/sql; + +public type EmploymentType record { + int? id = (); + string name; + string description; +}; + +public isolated function getEmploymentTypes() returns EmploymentType[]|error { + EmploymentType[] employmentTypes = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + name , + description + FROM employment_type` + ); + check from EmploymentType employmentType in resultStream + do { + employmentTypes.push(employmentType); + }; + check resultStream.close(); + return employmentTypes; +} + +public isolated function getEmploymentType(int id) returns EmploymentType|error { + EmploymentType employmentType = check smsDBClient->queryRow( + `SELECT * FROM employment_type WHERE id = ${id}` + ); + return employmentType; +} + +public isolated function addEmploymentType(EmploymentType employmentType) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO employment_type ( + name , + description ) + VALUES ( + ${employmentType.name}, + ${employmentType.description} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for employment_type"); + } +} + +public isolated function updateEmploymentType(EmploymentType employmentType) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE employment_type SET + name = ${employmentType.name}, + description = ${employmentType.description} + WHERE id = ${employmentType.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for employment_type update"); + } +} + +isolated function deleteEmploymentType(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM employment_type WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for employment_type delete"); + } +} diff --git a/EvaluationCriteriaCategory.bal b/EvaluationCriteriaCategory.bal new file mode 100644 index 0000000..ee6a821 --- /dev/null +++ b/EvaluationCriteriaCategory.bal @@ -0,0 +1,76 @@ +import ballerina/sql; + +public type EvaluationCriteriaCategory record { + int? id = (); + string name; + string description; +}; + +public isolated function getEvaluationCriteriaCategories() returns EvaluationCriteriaCategory[]|error { + EvaluationCriteriaCategory[] evaluationCriteriaCategories = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + name , + description + FROM evaluation_criteria_category` + ); + check from EvaluationCriteriaCategory evaluationCriteriaCategory in resultStream + do { + evaluationCriteriaCategories.push(evaluationCriteriaCategory); + }; + check resultStream.close(); + return evaluationCriteriaCategories; +} + +public isolated function getEvaluationCriteriaCategory(int id) returns EvaluationCriteriaCategory|error { + EvaluationCriteriaCategory evaluationCriteriaCategory = check smsDBClient->queryRow( + `SELECT * FROM evaluation_criteria_category WHERE id = ${id}` + ); + return evaluationCriteriaCategory; +} + +public isolated function addEvaluationCriteriaCategory(EvaluationCriteriaCategory evaluationCriteriaCategory) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO evaluation_criteria_category ( + name , + description ) + VALUES ( + ${evaluationCriteriaCategory.name}, + ${evaluationCriteriaCategory.description} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for evaluation_criteria_category"); + } +} + +public isolated function updateEvaluationCriteriaCategory(EvaluationCriteriaCategory evaluationCriteriaCategory) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE evaluation_criteria_category SET + name = ${evaluationCriteriaCategory.name}, + description = ${evaluationCriteriaCategory.description} + WHERE id = ${evaluationCriteriaCategory.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for evaluation_criteria_category update"); + } +} + +isolated function deleteEvaluationCriteriaCategory(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM evaluation_criteria_category WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for evaluation_criteria_category delete"); + } +} diff --git a/EvaluationCycle.bal b/EvaluationCycle.bal new file mode 100644 index 0000000..b2238ee --- /dev/null +++ b/EvaluationCycle.bal @@ -0,0 +1,98 @@ +import ballerina/sql; + +import ballerina/time; + +public type EvaluationCycle record { + int? id = (); + string name; + string description; + string start_date; + string? end_date = (); + time:Utc last_updated = time:utcNow(); + string notes; +}; + +public isolated function getEvaluationCycles() returns EvaluationCycle[]|error { + EvaluationCycle[] evaluationCycles = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + name , + description , + start_date , + end_date , + last_updated , + notes + FROM evaluation_cycle` + ); + check from EvaluationCycle evaluationCycle in resultStream + do { + evaluationCycles.push(evaluationCycle); + }; + check resultStream.close(); + return evaluationCycles; +} + +public isolated function getEvaluationCycle(int id) returns EvaluationCycle|error { + EvaluationCycle evaluationCycle = check smsDBClient->queryRow( + `SELECT * FROM evaluation_cycle WHERE id = ${id}` + ); + return evaluationCycle; +} + +public isolated function addEvaluationCycle(EvaluationCycle evaluationCycle) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO evaluation_cycle ( + name , + description , + start_date , + end_date , + last_updated , + notes ) + VALUES ( + ${evaluationCycle.name}, + ${evaluationCycle.description}, + ${evaluationCycle.start_date}, + ${evaluationCycle.end_date}, + ${evaluationCycle.last_updated}, + ${evaluationCycle.notes} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for evaluation_cycle"); + } +} + +public isolated function updateEvaluationCycle(EvaluationCycle evaluationCycle) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE evaluation_cycle SET + name = ${evaluationCycle.name}, + description = ${evaluationCycle.description}, + start_date = ${evaluationCycle.start_date}, + end_date = ${evaluationCycle.end_date}, + last_updated = ${evaluationCycle.last_updated}, + notes = ${evaluationCycle.notes} + WHERE id = ${evaluationCycle.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for evaluation_cycle update"); + } +} + +isolated function deleteEvaluationCycle(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM evaluation_cycle WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for evaluation_cycle delete"); + } +} diff --git a/Job.bal b/Job.bal new file mode 100644 index 0000000..e7996b1 --- /dev/null +++ b/Job.bal @@ -0,0 +1,86 @@ +import ballerina/sql; + +public type Job record { + int? id = (); + string name; + string description; + int team_id; + int job_band_id; +}; + +public isolated function getJobs() returns Job[]|error { + Job[] jobs = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + name , + description , + team_id , + job_band_id + FROM job` + ); + check from Job job in resultStream + do { + jobs.push(job); + }; + check resultStream.close(); + return jobs; +} + +public isolated function getJob(int id) returns Job|error { + Job job = check smsDBClient->queryRow( + `SELECT * FROM job WHERE id = ${id}` + ); + return job; +} + +public isolated function addJob(Job job) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO job ( + name , + description , + team_id , + job_band_id ) + VALUES ( + ${job.name}, + ${job.description}, + ${job.team_id}, + ${job.job_band_id} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for job"); + } +} + +public isolated function updateJob(Job job) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE job SET + name = ${job.name}, + description = ${job.description}, + team_id = ${job.team_id}, + job_band_id = ${job.job_band_id} + WHERE id = ${job.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for job update"); + } +} + +isolated function deleteJob(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM job WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for job delete"); + } +} diff --git a/JobBand.bal b/JobBand.bal new file mode 100644 index 0000000..055aae7 --- /dev/null +++ b/JobBand.bal @@ -0,0 +1,91 @@ +import ballerina/sql; + +public type JobBand record { + int? id = (); + string name; + string description; + int level; + decimal min_salary; + decimal max_salary; +}; + +public isolated function getJobBands() returns JobBand[]|error { + JobBand[] jobBands = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + name , + description , + level , + min_salary , + max_salary + FROM job_band` + ); + check from JobBand jobBand in resultStream + do { + jobBands.push(jobBand); + }; + check resultStream.close(); + return jobBands; +} + +public isolated function getJobBand(int id) returns JobBand|error { + JobBand jobBand = check smsDBClient->queryRow( + `SELECT * FROM job_band WHERE id = ${id}` + ); + return jobBand; +} + +public isolated function addJobBand(JobBand jobBand) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO job_band ( + name , + description , + level , + min_salary , + max_salary ) + VALUES ( + ${jobBand.name}, + ${jobBand.description}, + ${jobBand.level}, + ${jobBand.min_salary}, + ${jobBand.max_salary} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for job_band"); + } +} + +public isolated function updateJobBand(JobBand jobBand) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE job_band SET + name = ${jobBand.name}, + description = ${jobBand.description}, + level = ${jobBand.level}, + min_salary = ${jobBand.min_salary}, + max_salary = ${jobBand.max_salary} + WHERE id = ${jobBand.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for job_band update"); + } +} + +isolated function deleteJobBand(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM job_band WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for job_band delete"); + } +} diff --git a/JobDescription.bal b/JobDescription.bal new file mode 100644 index 0000000..00bc30d --- /dev/null +++ b/JobDescription.bal @@ -0,0 +1,81 @@ +import ballerina/sql; + +public type JobDescription record { + int? id = (); + int job_id; + int sequence_no; + string description; +}; + +public isolated function getJobDescriptions() returns JobDescription[]|error { + JobDescription[] jobDescriptions = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + job_id , + sequence_no , + description + FROM job_description` + ); + check from JobDescription jobDescription in resultStream + do { + jobDescriptions.push(jobDescription); + }; + check resultStream.close(); + return jobDescriptions; +} + +public isolated function getJobDescription(int id) returns JobDescription|error { + JobDescription jobDescription = check smsDBClient->queryRow( + `SELECT * FROM job_description WHERE id = ${id}` + ); + return jobDescription; +} + +public isolated function addJobDescription(JobDescription jobDescription) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO job_description ( + job_id , + sequence_no , + description ) + VALUES ( + ${jobDescription.job_id}, + ${jobDescription.sequence_no}, + ${jobDescription.description} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for job_description"); + } +} + +public isolated function updateJobDescription(JobDescription jobDescription) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE job_description SET + job_id = ${jobDescription.job_id}, + sequence_no = ${jobDescription.sequence_no}, + description = ${jobDescription.description} + WHERE id = ${jobDescription.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for job_description update"); + } +} + +isolated function deleteJobDescription(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM job_description WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for job_description delete"); + } +} diff --git a/JobEvaluationCriteria.bal b/JobEvaluationCriteria.bal new file mode 100644 index 0000000..73170ad --- /dev/null +++ b/JobEvaluationCriteria.bal @@ -0,0 +1,86 @@ +import ballerina/sql; + +public type JobEvaluationCriteria record { + int? id = (); + int job_id; + int evaluation_criteria_category_id; + int sequence_no; + string description; +}; + +public isolated function getJobEvaluationCriterias() returns JobEvaluationCriteria[]|error { + JobEvaluationCriteria[] jobEvaluationCriterias = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + job_id , + evaluation_criteria_category_id , + sequence_no , + description + FROM job_evaluation_criteria` + ); + check from JobEvaluationCriteria jobEvaluationCriteria in resultStream + do { + jobEvaluationCriterias.push(jobEvaluationCriteria); + }; + check resultStream.close(); + return jobEvaluationCriterias; +} + +public isolated function getJobEvaluationCriteria(int id) returns JobEvaluationCriteria|error { + JobEvaluationCriteria jobEvaluationCriteria = check smsDBClient->queryRow( + `SELECT * FROM job_evaluation_criteria WHERE id = ${id}` + ); + return jobEvaluationCriteria; +} + +public isolated function addJobEvaluationCriteria(JobEvaluationCriteria jobEvaluationCriteria) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO job_evaluation_criteria ( + job_id , + evaluation_criteria_category_id , + sequence_no , + description ) + VALUES ( + ${jobEvaluationCriteria.job_id}, + ${jobEvaluationCriteria.evaluation_criteria_category_id}, + ${jobEvaluationCriteria.sequence_no}, + ${jobEvaluationCriteria.description} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for job_evaluation_criteria"); + } +} + +public isolated function updateJobEvaluationCriteria(JobEvaluationCriteria jobEvaluationCriteria) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE job_evaluation_criteria SET + job_id = ${jobEvaluationCriteria.job_id}, + evaluation_criteria_category_id = ${jobEvaluationCriteria.evaluation_criteria_category_id}, + sequence_no = ${jobEvaluationCriteria.sequence_no}, + description = ${jobEvaluationCriteria.description} + WHERE id = ${jobEvaluationCriteria.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for job_evaluation_criteria update"); + } +} + +isolated function deleteJobEvaluationCriteria(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM job_evaluation_criteria WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for job_evaluation_criteria delete"); + } +} diff --git a/JobOffer.bal b/JobOffer.bal new file mode 100644 index 0000000..59f1936 --- /dev/null +++ b/JobOffer.bal @@ -0,0 +1,113 @@ +import ballerina/sql; + +import ballerina/time; + +public type JobOffer record { + int? id = (); + int applicant_id; + string offer_status; + int approved_by; + string start_date; + string? end_date = (); + time:Utc last_updated = time:utcNow(); + decimal salary; + string description; + string notes; +}; + +public isolated function getJobOffers() returns JobOffer[]|error { + JobOffer[] jobOffers = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + applicant_id , + offer_status , + approved_by , + start_date , + end_date , + last_updated , + salary , + description , + notes + FROM job_offer` + ); + check from JobOffer jobOffer in resultStream + do { + jobOffers.push(jobOffer); + }; + check resultStream.close(); + return jobOffers; +} + +public isolated function getJobOffer(int id) returns JobOffer|error { + JobOffer jobOffer = check smsDBClient->queryRow( + `SELECT * FROM job_offer WHERE id = ${id}` + ); + return jobOffer; +} + +public isolated function addJobOffer(JobOffer jobOffer) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO job_offer ( + applicant_id , + offer_status , + approved_by , + start_date , + end_date , + last_updated , + salary , + description , + notes ) + VALUES ( + ${jobOffer.applicant_id}, + ${jobOffer.offer_status}, + ${jobOffer.approved_by}, + ${jobOffer.start_date}, + ${jobOffer.end_date}, + ${jobOffer.last_updated}, + ${jobOffer.salary}, + ${jobOffer.description}, + ${jobOffer.notes} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for job_offer"); + } +} + +public isolated function updateJobOffer(JobOffer jobOffer) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE job_offer SET + applicant_id = ${jobOffer.applicant_id}, + offer_status = ${jobOffer.offer_status}, + approved_by = ${jobOffer.approved_by}, + start_date = ${jobOffer.start_date}, + end_date = ${jobOffer.end_date}, + last_updated = ${jobOffer.last_updated}, + salary = ${jobOffer.salary}, + description = ${jobOffer.description}, + notes = ${jobOffer.notes} + WHERE id = ${jobOffer.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for job_offer update"); + } +} + +isolated function deleteJobOffer(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM job_offer WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for job_offer delete"); + } +} diff --git a/JobQualification.bal b/JobQualification.bal new file mode 100644 index 0000000..67c94fd --- /dev/null +++ b/JobQualification.bal @@ -0,0 +1,86 @@ +import ballerina/sql; + +public type JobQualification record { + int? id = (); + int job_id; + int qualification_category_id; + int sequence_no; + string description; +}; + +public isolated function getJobQualifications() returns JobQualification[]|error { + JobQualification[] jobQualifications = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + job_id , + qualification_category_id , + sequence_no , + description + FROM job_qualification` + ); + check from JobQualification jobQualification in resultStream + do { + jobQualifications.push(jobQualification); + }; + check resultStream.close(); + return jobQualifications; +} + +public isolated function getJobQualification(int id) returns JobQualification|error { + JobQualification jobQualification = check smsDBClient->queryRow( + `SELECT * FROM job_qualification WHERE id = ${id}` + ); + return jobQualification; +} + +public isolated function addJobQualification(JobQualification jobQualification) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO job_qualification ( + job_id , + qualification_category_id , + sequence_no , + description ) + VALUES ( + ${jobQualification.job_id}, + ${jobQualification.qualification_category_id}, + ${jobQualification.sequence_no}, + ${jobQualification.description} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for job_qualification"); + } +} + +public isolated function updateJobQualification(JobQualification jobQualification) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE job_qualification SET + job_id = ${jobQualification.job_id}, + qualification_category_id = ${jobQualification.qualification_category_id}, + sequence_no = ${jobQualification.sequence_no}, + description = ${jobQualification.description} + WHERE id = ${jobQualification.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for job_qualification update"); + } +} + +isolated function deleteJobQualification(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM job_qualification WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for job_qualification delete"); + } +} diff --git a/JobRoleResponsibility.bal b/JobRoleResponsibility.bal new file mode 100644 index 0000000..c87db40 --- /dev/null +++ b/JobRoleResponsibility.bal @@ -0,0 +1,86 @@ +import ballerina/sql; + +public type JobRoleResponsibility record { + int? id = (); + int job_id; + int role_responsibility_category_id; + int sequence_no; + string description; +}; + +public isolated function getJobRoleResponsibilities() returns JobRoleResponsibility[]|error { + JobRoleResponsibility[] jobRoleResponsibilities = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + job_id , + role_responsibility_category_id , + sequence_no , + description + FROM job_role_responsibility` + ); + check from JobRoleResponsibility jobRoleResponsibility in resultStream + do { + jobRoleResponsibilities.push(jobRoleResponsibility); + }; + check resultStream.close(); + return jobRoleResponsibilities; +} + +public isolated function getJobRoleResponsibility(int id) returns JobRoleResponsibility|error { + JobRoleResponsibility jobRoleResponsibility = check smsDBClient->queryRow( + `SELECT * FROM job_role_responsibility WHERE id = ${id}` + ); + return jobRoleResponsibility; +} + +public isolated function addJobRoleResponsibility(JobRoleResponsibility jobRoleResponsibility) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO job_role_responsibility ( + job_id , + role_responsibility_category_id , + sequence_no , + description ) + VALUES ( + ${jobRoleResponsibility.job_id}, + ${jobRoleResponsibility.role_responsibility_category_id}, + ${jobRoleResponsibility.sequence_no}, + ${jobRoleResponsibility.description} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for job_role_responsibility"); + } +} + +public isolated function updateJobRoleResponsibility(JobRoleResponsibility jobRoleResponsibility) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE job_role_responsibility SET + job_id = ${jobRoleResponsibility.job_id}, + role_responsibility_category_id = ${jobRoleResponsibility.role_responsibility_category_id}, + sequence_no = ${jobRoleResponsibility.sequence_no}, + description = ${jobRoleResponsibility.description} + WHERE id = ${jobRoleResponsibility.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for job_role_responsibility update"); + } +} + +isolated function deleteJobRoleResponsibility(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM job_role_responsibility WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for job_role_responsibility delete"); + } +} diff --git a/JobSkill.bal b/JobSkill.bal new file mode 100644 index 0000000..874fe7c --- /dev/null +++ b/JobSkill.bal @@ -0,0 +1,86 @@ +import ballerina/sql; + +public type JobSkill record { + int? id = (); + int job_id; + int skill_category_id; + int sequence_no; + string description; +}; + +public isolated function getJobSkills() returns JobSkill[]|error { + JobSkill[] jobSkills = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + job_id , + skill_category_id , + sequence_no , + description + FROM job_skill` + ); + check from JobSkill jobSkill in resultStream + do { + jobSkills.push(jobSkill); + }; + check resultStream.close(); + return jobSkills; +} + +public isolated function getJobSkill(int id) returns JobSkill|error { + JobSkill jobSkill = check smsDBClient->queryRow( + `SELECT * FROM job_skill WHERE id = ${id}` + ); + return jobSkill; +} + +public isolated function addJobSkill(JobSkill jobSkill) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO job_skill ( + job_id , + skill_category_id , + sequence_no , + description ) + VALUES ( + ${jobSkill.job_id}, + ${jobSkill.skill_category_id}, + ${jobSkill.sequence_no}, + ${jobSkill.description} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for job_skill"); + } +} + +public isolated function updateJobSkill(JobSkill jobSkill) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE job_skill SET + job_id = ${jobSkill.job_id}, + skill_category_id = ${jobSkill.skill_category_id}, + sequence_no = ${jobSkill.sequence_no}, + description = ${jobSkill.description} + WHERE id = ${jobSkill.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for job_skill update"); + } +} + +isolated function deleteJobSkill(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM job_skill WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for job_skill delete"); + } +} diff --git a/LeaveType.bal b/LeaveType.bal new file mode 100644 index 0000000..a5ca775 --- /dev/null +++ b/LeaveType.bal @@ -0,0 +1,86 @@ +import ballerina/sql; + +public type LeaveType record { + int? id = (); + int employment_type_id; + string name; + int allocation; + string description; +}; + +public isolated function getLeaveTypes() returns LeaveType[]|error { + LeaveType[] leaveTypes = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + employment_type_id , + name , + allocation , + description + FROM leave_type` + ); + check from LeaveType leaveType in resultStream + do { + leaveTypes.push(leaveType); + }; + check resultStream.close(); + return leaveTypes; +} + +public isolated function getLeaveType(int id) returns LeaveType|error { + LeaveType leaveType = check smsDBClient->queryRow( + `SELECT * FROM leave_type WHERE id = ${id}` + ); + return leaveType; +} + +public isolated function addLeaveType(LeaveType leaveType) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO leave_type ( + employment_type_id , + name , + allocation , + description ) + VALUES ( + ${leaveType.employment_type_id}, + ${leaveType.name}, + ${leaveType.allocation}, + ${leaveType.description} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for leave_type"); + } +} + +public isolated function updateLeaveType(LeaveType leaveType) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE leave_type SET + employment_type_id = ${leaveType.employment_type_id}, + name = ${leaveType.name}, + allocation = ${leaveType.allocation}, + description = ${leaveType.description} + WHERE id = ${leaveType.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for leave_type update"); + } +} + +isolated function deleteLeaveType(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM leave_type WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for leave_type delete"); + } +} diff --git a/Office.bal b/Office.bal new file mode 100644 index 0000000..a804802 --- /dev/null +++ b/Office.bal @@ -0,0 +1,91 @@ +import ballerina/sql; + +public type Office record { + int? id = (); + int branch_id; + string name; + string description; + string phone_number1; + string phone_number2; +}; + +public isolated function getOffices() returns Office[]|error { + Office[] offices = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + branch_id , + name , + description , + phone_number1 , + phone_number2 + FROM office` + ); + check from Office office in resultStream + do { + offices.push(office); + }; + check resultStream.close(); + return offices; +} + +public isolated function getOffice(int id) returns Office|error { + Office office = check smsDBClient->queryRow( + `SELECT * FROM office WHERE id = ${id}` + ); + return office; +} + +public isolated function addOffice(Office office) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO office ( + branch_id , + name , + description , + phone_number1 , + phone_number2 ) + VALUES ( + ${office.branch_id}, + ${office.name}, + ${office.description}, + ${office.phone_number1}, + ${office.phone_number2} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for office"); + } +} + +public isolated function updateOffice(Office office) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE office SET + branch_id = ${office.branch_id}, + name = ${office.name}, + description = ${office.description}, + phone_number1 = ${office.phone_number1}, + phone_number2 = ${office.phone_number2} + WHERE id = ${office.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for office update"); + } +} + +isolated function deleteOffice(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM office WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for office delete"); + } +} diff --git a/OfficeAddress.bal b/OfficeAddress.bal new file mode 100644 index 0000000..4acb768 --- /dev/null +++ b/OfficeAddress.bal @@ -0,0 +1,90 @@ +import ballerina/sql; + +public type OfficeAddress record { + int office_id; + int address_id; +}; + +public isolated function getOfficeAddresses() returns OfficeAddress[]|error { + OfficeAddress[] officeAddresses = []; + stream resultStream = smsDBClient->query( + `SELECT + office_id , + address_id + FROM office_address` + ); + check from OfficeAddress officeAddress in resultStream + do { + officeAddresses.push(officeAddress); + }; + check resultStream.close(); + return officeAddresses; +} + +public isolated function getOfficeAddress(int office_id, int address_id) returns OfficeAddress|error { + OfficeAddress officeAddress = check smsDBClient->queryRow( + `SELECT * FROM office_address WHERE office_id = ${office_id} AND address_id = ${address_id}` + ); + return officeAddress; +} + +public isolated function getAddressesForOffice(int office_id) returns OfficeAddress[]|error { + OfficeAddress[] officeAddresses = []; + stream resultStream = smsDBClient->query( + `SELECT + office_id , + address_id + FROM office_address WHERE office_id = ${office_id}` + ); + check from OfficeAddress officeAddress in resultStream + do { + officeAddresses.push(officeAddress); + }; + check resultStream.close(); + return officeAddresses; +} + +public isolated function addOfficeAddress(OfficeAddress officeAddress) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO office_address ( + office_id , + address_id ) + VALUES ( + ${officeAddress.office_id}, + ${officeAddress.address_id} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for office_address"); + } +} + +public isolated function updateOfficeAddress(OfficeAddress officeAddress) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE office_address SET + office_id = ${officeAddress.office_id}, + address_id = ${officeAddress.address_id} + WHERE office_address = ${officeAddress.office_id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for office_address update"); + } +} + +isolated function deleteOfficeAddress(int office_id, int address_id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM office_address WHERE office_id = ${office_id} AND address_id = ${address_id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for office_address delete"); + } +} diff --git a/OfficeEmployee.bal b/OfficeEmployee.bal new file mode 100644 index 0000000..377c1f7 --- /dev/null +++ b/OfficeEmployee.bal @@ -0,0 +1,108 @@ +import ballerina/sql; + +import ballerina/time; + +public type OfficeEmployee record { + int? id = (); + int office_id; + int job_id; + int employee_id; + string start_date; + string? end_date = (); + time:Utc last_updated = time:utcNow(); + string title; + string notes; +}; + +public isolated function getOfficeEmployees() returns OfficeEmployee[]|error { + OfficeEmployee[] officeEmployees = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + office_id , + job_id , + employee_id , + start_date , + end_date , + last_updated , + title , + notes + FROM office_employee` + ); + check from OfficeEmployee officeEmployee in resultStream + do { + officeEmployees.push(officeEmployee); + }; + check resultStream.close(); + return officeEmployees; +} + +public isolated function getOfficeEmployee(int id) returns OfficeEmployee|error { + OfficeEmployee officeEmployee = check smsDBClient->queryRow( + `SELECT * FROM office_employee WHERE id = ${id}` + ); + return officeEmployee; +} + +public isolated function addOfficeEmployee(OfficeEmployee officeEmployee) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO office_employee ( + office_id , + job_id , + employee_id , + start_date , + end_date , + last_updated , + title , + notes ) + VALUES ( + ${officeEmployee.office_id}, + ${officeEmployee.job_id}, + ${officeEmployee.employee_id}, + ${officeEmployee.start_date}, + ${officeEmployee.end_date}, + ${officeEmployee.last_updated}, + ${officeEmployee.title}, + ${officeEmployee.notes} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for office_employee"); + } +} + +public isolated function updateOfficeEmployee(OfficeEmployee officeEmployee) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE office_employee SET + office_id = ${officeEmployee.office_id}, + job_id = ${officeEmployee.job_id}, + employee_id = ${officeEmployee.employee_id}, + start_date = ${officeEmployee.start_date}, + end_date = ${officeEmployee.end_date}, + last_updated = ${officeEmployee.last_updated}, + title = ${officeEmployee.title}, + notes = ${officeEmployee.notes} + WHERE id = ${officeEmployee.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for office_employee update"); + } +} + +isolated function deleteOfficeEmployee(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM office_employee WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for office_employee delete"); + } +} diff --git a/Organization.bal b/Organization.bal new file mode 100644 index 0000000..6834c76 --- /dev/null +++ b/Organization.bal @@ -0,0 +1,86 @@ +import ballerina/sql; + +public type Organization record { + int? id = (); + string name; + string description; + string phone_number1; + string phone_number2; +}; + +public isolated function getOrganizations() returns Organization[]|error { + Organization[] organizations = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + name , + description , + phone_number1 , + phone_number2 + FROM organization` + ); + check from Organization organization in resultStream + do { + organizations.push(organization); + }; + check resultStream.close(); + return organizations; +} + +public isolated function getOrganization(int id) returns Organization|error { + Organization organization = check smsDBClient->queryRow( + `SELECT * FROM organization WHERE id = ${id}` + ); + return organization; +} + +public isolated function addOrganization(Organization organization) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO organization ( + name , + description , + phone_number1 , + phone_number2 ) + VALUES ( + ${organization.name}, + ${organization.description}, + ${organization.phone_number1}, + ${organization.phone_number2} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for organization"); + } +} + +public isolated function updateOrganization(Organization organization) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE organization SET + name = ${organization.name}, + description = ${organization.description}, + phone_number1 = ${organization.phone_number1}, + phone_number2 = ${organization.phone_number2} + WHERE id = ${organization.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for organization update"); + } +} + +isolated function deleteOrganization(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM organization WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for organization delete"); + } +} diff --git a/OrganizationAddress.bal b/OrganizationAddress.bal new file mode 100644 index 0000000..1b1c5c4 --- /dev/null +++ b/OrganizationAddress.bal @@ -0,0 +1,90 @@ +import ballerina/sql; + +public type OrganizationAddress record { + int organization_id; + int address_id; +}; + +public isolated function getOrganizationAddresses() returns OrganizationAddress[]|error { + OrganizationAddress[] organizationAddresses = []; + stream resultStream = smsDBClient->query( + `SELECT + organization_id , + address_id + FROM organization_address` + ); + check from OrganizationAddress organizationAddress in resultStream + do { + organizationAddresses.push(organizationAddress); + }; + check resultStream.close(); + return organizationAddresses; +} + +public isolated function getOrganizationAddress(int organization_id, int address_id) returns OrganizationAddress|error { + OrganizationAddress organizationAddress = check smsDBClient->queryRow( + `SELECT * FROM organization_address WHERE organization_id = ${organization_id} AND address_id = ${address_id}` + ); + return organizationAddress; +} + +public isolated function getAddressesForOrganization(int organization_id) returns OrganizationAddress[]|error { + OrganizationAddress[] organizationAddresses = []; + stream resultStream = smsDBClient->query( + `SELECT + organization_id , + address_id + FROM organization_address WHERE organization_id = ${organization_id}` + ); + check from OrganizationAddress organizationAddress in resultStream + do { + organizationAddresses.push(organizationAddress); + }; + check resultStream.close(); + return organizationAddresses; +} + +public isolated function addOrganizationAddress(OrganizationAddress organizationAddress) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO organization_address ( + organization_id , + address_id ) + VALUES ( + ${organizationAddress.organization_id}, + ${organizationAddress.address_id} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for organization_address"); + } +} + +public isolated function updateOrganizationAddress(OrganizationAddress organizationAddress) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE organization_address SET + organization_id = ${organizationAddress.organization_id}, + address_id = ${organizationAddress.address_id} + WHERE organization_address = ${organizationAddress.organization_id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for organization_address update"); + } +} + +isolated function deleteOrganizationAddress(int organization_id, int address_id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM organization_address WHERE organization_id = ${organization_id} AND address_id = ${address_id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for organization_address delete"); + } +} diff --git a/PositionsVacant.bal b/PositionsVacant.bal new file mode 100644 index 0000000..343cf0e --- /dev/null +++ b/PositionsVacant.bal @@ -0,0 +1,103 @@ +import ballerina/sql; + +import ballerina/time; + +public type PositionsVacant record { + int? id = (); + int office_id; + int job_id; + int amount; + string start_date; + string? end_date = (); + time:Utc last_updated = time:utcNow(); + string notes; +}; + +public isolated function getPositionsVacants() returns PositionsVacant[]|error { + PositionsVacant[] positionsVacants = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + office_id , + job_id , + amount , + start_date , + end_date , + last_updated , + notes + FROM positions_vacant` + ); + check from PositionsVacant positionsVacant in resultStream + do { + positionsVacants.push(positionsVacant); + }; + check resultStream.close(); + return positionsVacants; +} + +public isolated function getPositionsVacant(int id) returns PositionsVacant|error { + PositionsVacant positionsVacant = check smsDBClient->queryRow( + `SELECT * FROM positions_vacant WHERE id = ${id}` + ); + return positionsVacant; +} + +public isolated function addPositionsVacant(PositionsVacant positionsVacant) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO positions_vacant ( + office_id , + job_id , + amount , + start_date , + end_date , + last_updated , + notes ) + VALUES ( + ${positionsVacant.office_id}, + ${positionsVacant.job_id}, + ${positionsVacant.amount}, + ${positionsVacant.start_date}, + ${positionsVacant.end_date}, + ${positionsVacant.last_updated}, + ${positionsVacant.notes} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for positions_vacant"); + } +} + +public isolated function updatePositionsVacant(PositionsVacant positionsVacant) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE positions_vacant SET + office_id = ${positionsVacant.office_id}, + job_id = ${positionsVacant.job_id}, + amount = ${positionsVacant.amount}, + start_date = ${positionsVacant.start_date}, + end_date = ${positionsVacant.end_date}, + last_updated = ${positionsVacant.last_updated}, + notes = ${positionsVacant.notes} + WHERE id = ${positionsVacant.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for positions_vacant update"); + } +} + +isolated function deletePositionsVacant(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM positions_vacant WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for positions_vacant delete"); + } +} diff --git a/QualificationCategory.bal b/QualificationCategory.bal new file mode 100644 index 0000000..1ba9c1d --- /dev/null +++ b/QualificationCategory.bal @@ -0,0 +1,76 @@ +import ballerina/sql; + +public type QualificationCategory record { + int? id = (); + string name; + string description; +}; + +public isolated function getQualificationCategories() returns QualificationCategory[]|error { + QualificationCategory[] qualificationCategories = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + name , + description + FROM qualification_category` + ); + check from QualificationCategory qualificationCategory in resultStream + do { + qualificationCategories.push(qualificationCategory); + }; + check resultStream.close(); + return qualificationCategories; +} + +public isolated function getQualificationCategory(int id) returns QualificationCategory|error { + QualificationCategory qualificationCategory = check smsDBClient->queryRow( + `SELECT * FROM qualification_category WHERE id = ${id}` + ); + return qualificationCategory; +} + +public isolated function addQualificationCategory(QualificationCategory qualificationCategory) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO qualification_category ( + name , + description ) + VALUES ( + ${qualificationCategory.name}, + ${qualificationCategory.description} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for qualification_category"); + } +} + +public isolated function updateQualificationCategory(QualificationCategory qualificationCategory) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE qualification_category SET + name = ${qualificationCategory.name}, + description = ${qualificationCategory.description} + WHERE id = ${qualificationCategory.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for qualification_category update"); + } +} + +isolated function deleteQualificationCategory(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM qualification_category WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for qualification_category delete"); + } +} diff --git a/RoleResponsibilityCategory.bal b/RoleResponsibilityCategory.bal new file mode 100644 index 0000000..5fec243 --- /dev/null +++ b/RoleResponsibilityCategory.bal @@ -0,0 +1,76 @@ +import ballerina/sql; + +public type RoleResponsibilityCategory record { + int? id = (); + string name; + string description; +}; + +public isolated function getRoleResponsibilityCategories() returns RoleResponsibilityCategory[]|error { + RoleResponsibilityCategory[] roleResponsibilityCategories = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + name , + description + FROM role_responsibility_category` + ); + check from RoleResponsibilityCategory roleResponsibilityCategory in resultStream + do { + roleResponsibilityCategories.push(roleResponsibilityCategory); + }; + check resultStream.close(); + return roleResponsibilityCategories; +} + +public isolated function getRoleResponsibilityCategory(int id) returns RoleResponsibilityCategory|error { + RoleResponsibilityCategory roleResponsibilityCategory = check smsDBClient->queryRow( + `SELECT * FROM role_responsibility_category WHERE id = ${id}` + ); + return roleResponsibilityCategory; +} + +public isolated function addRoleResponsibilityCategory(RoleResponsibilityCategory roleResponsibilityCategory) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO role_responsibility_category ( + name , + description ) + VALUES ( + ${roleResponsibilityCategory.name}, + ${roleResponsibilityCategory.description} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for role_responsibility_category"); + } +} + +public isolated function updateRoleResponsibilityCategory(RoleResponsibilityCategory roleResponsibilityCategory) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE role_responsibility_category SET + name = ${roleResponsibilityCategory.name}, + description = ${roleResponsibilityCategory.description} + WHERE id = ${roleResponsibilityCategory.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for role_responsibility_category update"); + } +} + +isolated function deleteRoleResponsibilityCategory(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM role_responsibility_category WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for role_responsibility_category delete"); + } +} diff --git a/SkillCategory.bal b/SkillCategory.bal new file mode 100644 index 0000000..da8bbc5 --- /dev/null +++ b/SkillCategory.bal @@ -0,0 +1,76 @@ +import ballerina/sql; + +public type SkillCategory record { + int? id = (); + string name; + string description; +}; + +public isolated function getSkillCategories() returns SkillCategory[]|error { + SkillCategory[] skillCategories = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + name , + description + FROM skill_category` + ); + check from SkillCategory skillCategory in resultStream + do { + skillCategories.push(skillCategory); + }; + check resultStream.close(); + return skillCategories; +} + +public isolated function getSkillCategory(int id) returns SkillCategory|error { + SkillCategory skillCategory = check smsDBClient->queryRow( + `SELECT * FROM skill_category WHERE id = ${id}` + ); + return skillCategory; +} + +public isolated function addSkillCategory(SkillCategory skillCategory) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO skill_category ( + name , + description ) + VALUES ( + ${skillCategory.name}, + ${skillCategory.description} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for skill_category"); + } +} + +public isolated function updateSkillCategory(SkillCategory skillCategory) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE skill_category SET + name = ${skillCategory.name}, + description = ${skillCategory.description} + WHERE id = ${skillCategory.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for skill_category update"); + } +} + +isolated function deleteSkillCategory(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM skill_category WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for skill_category delete"); + } +} diff --git a/Team.bal b/Team.bal new file mode 100644 index 0000000..1f10f87 --- /dev/null +++ b/Team.bal @@ -0,0 +1,81 @@ +import ballerina/sql; + +public type Team record { + int? id = (); + int? parent_id = (); + string name; + string description; +}; + +public isolated function getTeams() returns Team[]|error { + Team[] teams = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + parent_id , + name , + description + FROM team` + ); + check from Team team in resultStream + do { + teams.push(team); + }; + check resultStream.close(); + return teams; +} + +public isolated function getTeam(int id) returns Team|error { + Team team = check smsDBClient->queryRow( + `SELECT * FROM team WHERE id = ${id}` + ); + return team; +} + +public isolated function addTeam(Team team) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO team ( + parent_id , + name , + description ) + VALUES ( + ${team.parent_id}, + ${team.name}, + ${team.description} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for team"); + } +} + +public isolated function updateTeam(Team team) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE team SET + parent_id = ${team.parent_id}, + name = ${team.name}, + description = ${team.description} + WHERE id = ${team.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for team update"); + } +} + +isolated function deleteTeam(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM team WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for team delete"); + } +} diff --git a/TeamLead.bal b/TeamLead.bal new file mode 100644 index 0000000..e32bbd5 --- /dev/null +++ b/TeamLead.bal @@ -0,0 +1,108 @@ +import ballerina/sql; + +import ballerina/time; + +public type TeamLead record { + int? id = (); + int team_id; + int employee_id; + int lead_order; + string title; + string start_date; + string? end_date = (); + time:Utc last_updated = time:utcNow(); + string description; +}; + +public isolated function getTeamLeads() returns TeamLead[]|error { + TeamLead[] teamLeads = []; + stream resultStream = smsDBClient->query( + `SELECT + id , + team_id , + employee_id , + lead_order , + title , + start_date , + end_date , + last_updated , + description + FROM team_lead` + ); + check from TeamLead teamLead in resultStream + do { + teamLeads.push(teamLead); + }; + check resultStream.close(); + return teamLeads; +} + +public isolated function getTeamLead(int id) returns TeamLead|error { + TeamLead teamLead = check smsDBClient->queryRow( + `SELECT * FROM team_lead WHERE id = ${id}` + ); + return teamLead; +} + +public isolated function addTeamLead(TeamLead teamLead) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + INSERT INTO team_lead ( + team_id , + employee_id , + lead_order , + title , + start_date , + end_date , + last_updated , + description ) + VALUES ( + ${teamLead.team_id}, + ${teamLead.employee_id}, + ${teamLead.lead_order}, + ${teamLead.title}, + ${teamLead.start_date}, + ${teamLead.end_date}, + ${teamLead.last_updated}, + ${teamLead.description} + ) + `); + int|string? lastInsertId = result.lastInsertId; + if lastInsertId is int { + return lastInsertId; + } else { + return error("Unable to obtain last insert ID for team_lead"); + } +} + +public isolated function updateTeamLead(TeamLead teamLead) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + UPDATE team_lead SET + team_id = ${teamLead.team_id}, + employee_id = ${teamLead.employee_id}, + lead_order = ${teamLead.lead_order}, + title = ${teamLead.title}, + start_date = ${teamLead.start_date}, + end_date = ${teamLead.end_date}, + last_updated = ${teamLead.last_updated}, + description = ${teamLead.description} + WHERE id = ${teamLead.id} + `); + int|string? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain last affected count for team_lead update"); + } +} + +isolated function deleteTeamLead(int id) returns int|error { + sql:ExecutionResult result = check smsDBClient->execute(` + DELETE FROM team_lead WHERE id = ${id} + `); + int? affectedRowCount = result.affectedRowCount; + if affectedRowCount is int { + return affectedRowCount; + } else { + return error("Unable to obtain the affected row count for team_lead delete"); + } +} diff --git a/service.bal b/service.bal index 9d4b92a..a15ae5e 100644 --- a/service.bal +++ b/service.bal @@ -84,5 +84,927 @@ service / on smsEP { isolated resource function delete sms/util/addresstypes/[int id]() returns int|error? { return deleteAddressType(id); } + + isolated resource function get sms/util/addresses() returns Address[]|error? { + return getAddresses(); + } + + isolated resource function get sms/util/addresses/[int id]() returns Address|error? { + return getAddress(id); + } + + isolated resource function post sms/util/addresses(@http:Payload Address address) returns int|error? { + return addAddress(address); + } + + isolated resource function put sms/util/addresses(@http:Payload Address address) returns int|error? { + return updateAddress(address); + } + + isolated resource function delete sms/util/addresses/[int id]() returns int|error? { + return deleteAddress(id); + } + + isolated resource function get sms/hrm/employees() returns Employee[]|error? { + return getEmployees(); + } + + isolated resource function get sms/hrm/employees/[int id]() returns Employee|error? { + return getEmployee(id); + } + + isolated resource function post sms/hrm/employees(@http:Payload Employee employee) returns int|error? { + return addEmployee(employee); + } + + isolated resource function put sms/hrm/employees(@http:Payload Employee employee) returns int|error? { + return updateEmployee(employee); + } + + isolated resource function delete sms/hrm/employees/[int id]() returns int|error? { + return deleteEmployee(id); + } + + isolated resource function get sms/hrm/employee_addresse() returns EmployeeAddress[]|error? { + return getEmployeeAddresses(); + } + + isolated resource function get sms/hrm/employee_addresse/[int employee_id]/[int address_id]() returns EmployeeAddress|error? { + return getEmployeeAddress(employee_id, address_id); + } + + isolated resource function get sms/hrm/employee_addresse/[int employee_id]() returns EmployeeAddress[]|error? { + return getAddressesForEmployee(employee_id); + } + + isolated resource function post sms/hrm/employee_addresse(@http:Payload EmployeeAddress employeeAddress) returns int|error? { + return addEmployeeAddress(employeeAddress); + } + + isolated resource function put sms/hrm/employee_addresse(@http:Payload EmployeeAddress employeeAddress) returns int|error? { + return updateEmployeeAddress(employeeAddress); + } + + isolated resource function delete sms/hrm/employee_addresse/[int employee_id]/[int address_id]() returns int|error? { + return deleteEmployeeAddress(employee_id, address_id); + } + + isolated resource function get sms/hrm/employment_types() returns EmploymentType[]|error? { + return getEmploymentTypes(); + } + + isolated resource function get sms/hrm/employment_types/[int id]() returns EmploymentType|error? { + return getEmploymentType(id); + } + + isolated resource function post sms/hrm/employment_types(@http:Payload EmploymentType employmentType) returns int|error? { + return addEmploymentType(employmentType); + } + + isolated resource function put sms/hrm/employment_types(@http:Payload EmploymentType employmentType) returns int|error? { + return updateEmploymentType(employmentType); + } + + isolated resource function delete sms/hrm/employment_types/[int id]() returns int|error? { + return deleteEmploymentType(id); + } + + isolated resource function get sms/hrm/employee_employment_types() returns EmployeeEmploymentType[]|error? { + return getEmployeeEmploymentTypes(); + } + + isolated resource function get sms/hrm/employee_employment_types/[int id]() returns EmployeeEmploymentType|error? { + return getEmployeeEmploymentType(id); + } + + isolated resource function post sms/hrm/employee_employment_types(@http:Payload EmployeeEmploymentType employeeEmploymentType) returns int|error? { + return addEmployeeEmploymentType(employeeEmploymentType); + } + + isolated resource function put sms/hrm/employee_employment_types(@http:Payload EmployeeEmploymentType employeeEmploymentType) returns int|error? { + return updateEmployeeEmploymentType(employeeEmploymentType); + } + + isolated resource function delete sms/hrm/employee_employment_types/[int id]() returns int|error? { + return deleteEmployeeEmploymentType(id); + } + + isolated resource function get sms/hrm/employment_statuses() returns EmploymentStatus[]|error? { + return getEmploymentStatuses(); + } + + isolated resource function get sms/hrm/employment_statuses/[int id]() returns EmploymentStatus|error? { + return getEmploymentStatus(id); + } + + isolated resource function post sms/hrm/employment_statuses(@http:Payload EmploymentStatus employmentStatus) returns int|error? { + return addEmploymentStatus(employmentStatus); + } + + isolated resource function put sms/hrm/employment_statuses(@http:Payload EmploymentStatus employmentStatus) returns int|error? { + return updateEmploymentStatus(employmentStatus); + } + + isolated resource function delete sms/hrm/employment_statuses/[int id]() returns int|error? { + return deleteEmploymentStatus(id); + } + + + isolated resource function get sms/hrm/employee_employment_statuses() returns EmployeeEmploymentStatus[]|error? { + return getEmployeeEmploymentStatuses(); + } + + isolated resource function get sms/hrm/employee_employment_statuses/[int id]() returns EmployeeEmploymentStatus|error? { + return getEmployeeEmploymentStatus(id); + } + + isolated resource function post sms/hrm/employee_employment_statuses(@http:Payload EmployeeEmploymentStatus employeeEmploymentStatus) returns int|error? { + return addEmployeeEmploymentStatus(employeeEmploymentStatus); + } + + isolated resource function put sms/hrm/employee_employment_statuses(@http:Payload EmployeeEmploymentStatus employeeEmploymentStatus) returns int|error? { + return updateEmployeeEmploymentStatus(employeeEmploymentStatus); + } + + isolated resource function delete sms/hrm/employee_employment_statuses/[int id]() returns int|error? { + return deleteEmployeeEmploymentStatus(id); + } + + isolated resource function get sms/hrm/organizations() returns Organization[]|error? { + return getOrganizations(); + } + + isolated resource function get sms/hrm/organizations/[int id]() returns Organization|error? { + return getOrganization(id); + } + + isolated resource function post sms/hrm/organizations(@http:Payload Organization organization) returns int|error? { + return addOrganization(organization); + } + + isolated resource function put sms/hrm/organizations(@http:Payload Organization organization) returns int|error? { + return updateOrganization(organization); + } + + isolated resource function delete sms/hrm/organizations/[int id]() returns int|error? { + return deleteOrganization(id); + } + + isolated resource function get sms/hrm/organization_addresses() returns OrganizationAddress[]|error? { + return getOrganizationAddresses(); + } + + isolated resource function get sms/hrm/organization_addresses/[int organization_id]/[int address_id]() returns OrganizationAddress|error? { + return getOrganizationAddress(organization_id, address_id); + } + + isolated resource function get sms/hrm/organization_addresses/[int organization_id]() returns OrganizationAddress[]|error? { + return getAddressesForOrganization(organization_id); + } + + isolated resource function post sms/hrm/organization_addresses(@http:Payload OrganizationAddress organizationAddress) returns int|error? { + return addOrganizationAddress(organizationAddress); + } + + isolated resource function put sms/hrm/organization_addresses(@http:Payload OrganizationAddress organizationAddress) returns int|error? { + return updateOrganizationAddress(organizationAddress); + } + + isolated resource function delete sms/hrm/organization_addresses/[int organization_id]/[int address_id]() returns int|error? { + return deleteOrganizationAddress(organization_id, address_id); + } + + isolated resource function get sms/hrm/branches() returns Branch[]|error? { + return getBranches(); + } + + isolated resource function get sms/hrm/branches/[int id]() returns Branch|error? { + return getBranch(id); + } + + isolated resource function post sms/hrm/branches(@http:Payload Branch branch) returns int|error? { + return addBranch(branch); + } + + isolated resource function put sms/hrm/branches(@http:Payload Branch branch) returns int|error? { + return updateBranch(branch); + } + + isolated resource function delete sms/hrm/branches/[int id]() returns int|error? { + return deleteBranch(id); + } + + isolated resource function get sms/hrm/branch_addresses() returns BranchAddress[]|error? { + return getBranchAddresses(); + } + + isolated resource function get sms/hrm/branch_addresses/[int branch_id]/[int address_id]() returns BranchAddress|error? { + return getBranchAddress(branch_id, address_id); + } + + isolated resource function get sms/hrm/branch_addresses/[int branch_id]() returns BranchAddress[]|error? { + return getAddressesForBranch(branch_id); + } + + isolated resource function post sms/hrm/branch_addresses(@http:Payload BranchAddress branchAddress) returns int|error? { + return addBranchAddress(branchAddress); + } + + isolated resource function put sms/hrm/branch_addresses(@http:Payload BranchAddress branchAddress) returns int|error? { + return updateBranchAddress(branchAddress); + } + + isolated resource function delete sms/hrm/branch_addresses/[int branch_id]/[int address_id]() returns int|error? { + return deleteBranchAddress(branch_id, address_id); + } + + isolated resource function get sms/hrm/offices() returns Office[]|error? { + return getOffices(); + } + + isolated resource function get sms/hrm/offices/[int id]() returns Office|error? { + return getOffice(id); + } + + isolated resource function post sms/hrm/offices(@http:Payload Office office) returns int|error? { + return addOffice(office); + } + + isolated resource function put sms/hrm/offices(@http:Payload Office office) returns int|error? { + return updateOffice(office); + } + + isolated resource function delete sms/hrm/offices/[int id]() returns int|error? { + return deleteOffice(id); + } + + isolated resource function get sms/hrm/office_addresses() returns OfficeAddress[]|error? { + return getOfficeAddresses(); + } + + isolated resource function get sms/hrm/office_addresses/[int office_id]/[int address_id]() returns OfficeAddress|error? { + return getOfficeAddress(office_id, address_id); + } + + isolated resource function get sms/hrm/office_addresses/[int office_id]() returns OfficeAddress[]|error? { + return getAddressesForOffice(office_id); + } + + isolated resource function post sms/hrm/office_addresses(@http:Payload OfficeAddress officeAddress) returns int|error? { + return addOfficeAddress(officeAddress); + } + + isolated resource function put sms/hrm/office_addresses(@http:Payload OfficeAddress officeAddress) returns int|error? { + return updateOfficeAddress(officeAddress); + } + + isolated resource function delete sms/hrm/office_addresses/[int office_id]/[int address_id]() returns int|error? { + return deleteOfficeAddress(office_id, address_id); + } + + isolated resource function get sms/hrm/team() returns Team[]|error? { + return getTeams(); + } + + isolated resource function get sms/hrm/team/[int id]() returns Team|error? { + return getTeam(id); + } + + isolated resource function post sms/hrm/team(@http:Payload Team team) returns int|error? { + return addTeam(team); + } + + isolated resource function put sms/hrm/team(@http:Payload Team team) returns int|error? { + return updateTeam(team); + } + + isolated resource function delete sms/hrm/team/[int id]() returns int|error? { + return deleteTeam(id); + } + + isolated resource function get sms/hrm/team_leads() returns TeamLead[]|error? { + return getTeamLeads(); + } + + isolated resource function get sms/hrm/team_leads/[int id]() returns TeamLead|error? { + return getTeamLead(id); + } + + isolated resource function post sms/hrm/team_leads(@http:Payload TeamLead teamLead) returns int|error? { + return addTeamLead(teamLead); + } + + isolated resource function put sms/hrm/team_leads(@http:Payload TeamLead teamLead) returns int|error? { + return updateTeamLead(teamLead); + } + + isolated resource function delete sms/hrm/team_leads/[int id]() returns int|error? { + return deleteTeamLead(id); + } + + isolated resource function get sms/hrm/job_band() returns JobBand[]|error? { + return getJobBands(); + } + + isolated resource function get sms/hrm/job_band/[int id]() returns JobBand|error? { + return getJobBand(id); + } + + isolated resource function post sms/hrm/job_band(@http:Payload JobBand jobBand) returns int|error? { + return addJobBand(jobBand); + } + + isolated resource function put sms/hrm/job_band(@http:Payload JobBand jobBand) returns int|error? { + return updateJobBand(jobBand); + } + + isolated resource function delete sms/hrm/job_band/[int id]() returns int|error? { + return deleteJobBand(id); + } + + isolated resource function get sms/hrm/jobs() returns Job[]|error? { + return getJobs(); + } + + isolated resource function get sms/hrm/jobs/[int id]() returns Job|error? { + return getJob(id); + } + + isolated resource function post sms/hrm/jobs(@http:Payload Job job) returns int|error? { + return addJob(job); + } + + isolated resource function put sms/hrm/jobs(@http:Payload Job job) returns int|error? { + return updateJob(job); + } + + isolated resource function delete sms/hrm/jobs/[int id]() returns int|error? { + return deleteJob(id); + } + + isolated resource function get sms/hrm/job_descriptions() returns JobDescription[]|error? { + return getJobDescriptions(); + } + + isolated resource function get sms/hrm/job_descriptions/[int id]() returns JobDescription|error? { + return getJobDescription(id); + } + + isolated resource function post sms/hrm/job_descriptions(@http:Payload JobDescription jobDescription) returns int|error? { + return addJobDescription(jobDescription); + } + + isolated resource function put sms/hrm/job_descriptions(@http:Payload JobDescription jobDescription) returns int|error? { + return updateJobDescription(jobDescription); + } + + isolated resource function delete sms/hrm/job_descriptions/[int id]() returns int|error? { + return deleteJobDescription(id); + } + + isolated resource function get sms/hrm/role_responsibility_categories() returns RoleResponsibilityCategory[]|error? { + return getRoleResponsibilityCategories(); + } + + isolated resource function get sms/hrm/role_responsibility_categories/[int id]() returns RoleResponsibilityCategory|error? { + return getRoleResponsibilityCategory(id); + } + + isolated resource function post sms/hrm/role_responsibility_categories(@http:Payload RoleResponsibilityCategory roleResponsibilityCategory) returns int|error? { + return addRoleResponsibilityCategory(roleResponsibilityCategory); + } + + isolated resource function put sms/hrm/role_responsibility_categories(@http:Payload RoleResponsibilityCategory roleResponsibilityCategory) returns int|error? { + return updateRoleResponsibilityCategory(roleResponsibilityCategory); + } + + isolated resource function delete sms/hrm/role_responsibility_categories/[int id]() returns int|error? { + return deleteRoleResponsibilityCategory(id); + } + + isolated resource function get sms/hrm/job_role_responsibilities() returns JobRoleResponsibility[]|error? { + return getJobRoleResponsibilities(); + } + + isolated resource function get sms/hrm/job_role_responsibilities/[int id]() returns JobRoleResponsibility|error? { + return getJobRoleResponsibility(id); + } + + isolated resource function post sms/hrm/job_role_responsibilities(@http:Payload JobRoleResponsibility jobRoleResponsibility) returns int|error? { + return addJobRoleResponsibility(jobRoleResponsibility); + } + + isolated resource function put sms/hrm/job_role_responsibilities(@http:Payload JobRoleResponsibility jobRoleResponsibility) returns int|error? { + return updateJobRoleResponsibility(jobRoleResponsibility); + } + + isolated resource function delete sms/hrm/job_role_responsibilities/[int id]() returns int|error? { + return deleteJobRoleResponsibility(id); + } + + isolated resource function get sms/hrm/qualification_categories() returns QualificationCategory[]|error? { + return getQualificationCategories(); + } + + isolated resource function get sms/hrm/qualification_categories/[int id]() returns QualificationCategory|error? { + return getQualificationCategory(id); + } + + isolated resource function post sms/hrm/qualification_categories(@http:Payload QualificationCategory qualificationCategory) returns int|error? { + return addQualificationCategory(qualificationCategory); + } + + isolated resource function put sms/hrm/qualification_categories(@http:Payload QualificationCategory qualificationCategory) returns int|error? { + return updateQualificationCategory(qualificationCategory); + } + + isolated resource function delete sms/hrm/qualification_categories/[int id]() returns int|error? { + return deleteQualificationCategory(id); + } + + isolated resource function get sms/hrm/job_qualifications() returns JobQualification[]|error? { + return getJobQualifications(); + } + + isolated resource function get sms/hrm/job_qualifications/[int id]() returns JobQualification|error? { + return getJobQualification(id); + } + + isolated resource function post sms/hrm/job_qualifications(@http:Payload JobQualification jobQualification) returns int|error? { + return addJobQualification(jobQualification); + } + + isolated resource function put sms/hrm/job_qualifications(@http:Payload JobQualification jobQualification) returns int|error? { + return updateJobQualification(jobQualification); + } + + isolated resource function delete sms/hrm/job_qualifications/[int id]() returns int|error? { + return deleteJobQualification(id); + } + + isolated resource function get sms/hrm/skill_categories() returns SkillCategory[]|error? { + return getSkillCategories(); + } + + isolated resource function get sms/hrm/skill_categories/[int id]() returns SkillCategory|error? { + return getSkillCategory(id); + } + + isolated resource function post sms/hrm/skill_categories(@http:Payload SkillCategory skillCategory) returns int|error? { + return addSkillCategory(skillCategory); + } + + isolated resource function put sms/hrm/skill_categories(@http:Payload SkillCategory skillCategory) returns int|error? { + return updateSkillCategory(skillCategory); + } + + isolated resource function delete sms/hrm/skill_categories/[int id]() returns int|error? { + return deleteSkillCategory(id); + } + + isolated resource function get sms/hrm/job_skills() returns JobSkill[]|error? { + return getJobSkills(); + } + + isolated resource function get sms/hrm/job_skills/[int id]() returns JobSkill|error? { + return getJobSkill(id); + } + + isolated resource function post sms/hrm/job_skills(@http:Payload JobSkill jobSkill) returns int|error? { + return addJobSkill(jobSkill); + } + + isolated resource function put sms/hrm/job_skills(@http:Payload JobSkill jobSkill) returns int|error? { + return updateJobSkill(jobSkill); + } + + isolated resource function delete sms/hrm/job_skills/[int id]() returns int|error? { + return deleteJobSkill(id); + } + + isolated resource function get sms/hrm/evaluation_criteria_categories() returns EvaluationCriteriaCategory[]|error? { + return getEvaluationCriteriaCategories(); + } + + isolated resource function get sms/hrm/evaluation_criteria_categories/[int id]() returns EvaluationCriteriaCategory|error? { + return getEvaluationCriteriaCategory(id); + } + + isolated resource function post sms/hrm/evaluation_criteria_categories(@http:Payload EvaluationCriteriaCategory evaluationCriteriaCategory) returns int|error? { + return addEvaluationCriteriaCategory(evaluationCriteriaCategory); + } + + isolated resource function put sms/hrm/evaluation_criteria_categories(@http:Payload EvaluationCriteriaCategory evaluationCriteriaCategory) returns int|error? { + return updateEvaluationCriteriaCategory(evaluationCriteriaCategory); + } + + isolated resource function delete sms/hrm/evaluation_criteria_categories/[int id]() returns int|error? { + return deleteEvaluationCriteriaCategory(id); + } + + isolated resource function get sms/hrm/job_evaluation_criterias() returns JobEvaluationCriteria[]|error? { + return getJobEvaluationCriterias(); + } + + isolated resource function get sms/hrm/job_evaluation_criterias/[int id]() returns JobEvaluationCriteria|error? { + return getJobEvaluationCriteria(id); + } + + isolated resource function post sms/hrm/job_evaluation_criterias(@http:Payload JobEvaluationCriteria jobEvaluationCriteria) returns int|error? { + return addJobEvaluationCriteria(jobEvaluationCriteria); + } + + isolated resource function put sms/hrm/job_evaluation_criterias(@http:Payload JobEvaluationCriteria jobEvaluationCriteria) returns int|error? { + return updateJobEvaluationCriteria(jobEvaluationCriteria); + } + + isolated resource function delete sms/hrm/job_evaluation_criterias/[int id]() returns int|error? { + return deleteJobEvaluationCriteria(id); + } + + isolated resource function get sms/hrm/office_employees() returns OfficeEmployee[]|error? { + return getOfficeEmployees(); + } + + isolated resource function get sms/hrm/office_employees/[int id]() returns OfficeEmployee|error? { + return getOfficeEmployee(id); + } + + isolated resource function post sms/hrm/office_employees(@http:Payload OfficeEmployee officeEmployee) returns int|error? { + return addOfficeEmployee(officeEmployee); + } + + isolated resource function put sms/hrm/office_employees(@http:Payload OfficeEmployee officeEmployee) returns int|error? { + return updateOfficeEmployee(officeEmployee); + } + + isolated resource function delete sms/hrm/office_employees/[int id]() returns int|error? { + return deleteOfficeEmployee(id); + } + + isolated resource function get sms/hrm/positions_vacant() returns PositionsVacant[]|error? { + return getPositionsVacants(); + } + + isolated resource function get sms/hrm/positions_vacant/[int id]() returns PositionsVacant|error? { + return getPositionsVacant(id); + } + + isolated resource function post sms/hrm/positions_vacant(@http:Payload PositionsVacant positionsVacant) returns int|error? { + return addPositionsVacant(positionsVacant); + } + + isolated resource function put sms/hrm/positions_vacant(@http:Payload PositionsVacant positionsVacant) returns int|error? { + return updatePositionsVacant(positionsVacant); + } + + isolated resource function delete sms/hrm/positions_vacant/[int id]() returns int|error? { + return deletePositionsVacant(id); + } + + isolated resource function get sms/hrm/applicants() returns Applicant[]|error? { + return getApplicants(); + } + + isolated resource function get sms/hrm/applicants/[int id]() returns Applicant|error? { + return getApplicant(id); + } + + isolated resource function post sms/hrm/applicants(@http:Payload Applicant applicant) returns int|error? { + return addApplicant(applicant); + } + + isolated resource function put sms/hrm/applicants(@http:Payload Applicant applicant) returns int|error? { + return updateApplicant(applicant); + } + + isolated resource function delete sms/hrm/applicants/[int id]() returns int|error? { + return deleteApplicant(id); + } + + isolated resource function get sms/hrm/applicant_addresses() returns ApplicantAddress[]|error? { + return getApplicantAddresses(); + } + + isolated resource function get sms/hrm/applicant_addresses/[int applicant_id]/[int address_id]() returns ApplicantAddress|error? { + return getApplicantAddress(applicant_id, address_id); + } + + isolated resource function get sms/hrm/applicant_addresses/[int applicant_id]() returns ApplicantAddress[]|error? { + return getAddressesForApplicant(applicant_id); + } + + isolated resource function post sms/hrm/applicant_addresses(@http:Payload ApplicantAddress applicantAddress) returns int|error? { + return addApplicantAddress(applicantAddress); + } + + isolated resource function put sms/hrm/applicant_addresses(@http:Payload ApplicantAddress applicantAddress) returns int|error? { + return updateApplicantAddress(applicantAddress); + } + + isolated resource function delete sms/hrm/applicant_addresses/[int applicant_id]/[int address_id]() returns int|error? { + return deleteApplicantAddress(applicant_id, address_id); + } + + isolated resource function get sms/hrm/application_statuses() returns ApplicationStatus[]|error? { + return getApplicationStatuses(); + } + + isolated resource function get sms/hrm/application_statuses/[int id]() returns ApplicationStatus|error? { + return getApplicationStatus(id); + } + + isolated resource function post sms/hrm/application_statuses(@http:Payload ApplicationStatus applicationStatus) returns int|error? { + return addApplicationStatus(applicationStatus); + } + + isolated resource function put sms/hrm/application_statuses(@http:Payload ApplicationStatus applicationStatus) returns int|error? { + return updateApplicationStatus(applicationStatus); + } + + isolated resource function delete sms/hrm/application_statuses/[int id]() returns int|error? { + return deleteApplicationStatus(id); + } + + isolated resource function get sms/hrm/applicant_application_statuses() returns ApplicantApplicationStatus[]|error? { + return getApplicantApplicationStatuses(); + } + + isolated resource function get sms/hrm/applicant_application_statuses/[int id]() returns ApplicantApplicationStatus|error? { + return getApplicantApplicationStatus(id); + } + + isolated resource function post sms/hrm/applicant_application_statuses(@http:Payload ApplicantApplicationStatus applicantApplicationStatus) returns int|error? { + return addApplicantApplicationStatus(applicantApplicationStatus); + } + + isolated resource function put sms/hrm/applicant_application_statuses(@http:Payload ApplicantApplicationStatus applicantApplicationStatus) returns int|error? { + return updateApplicantApplicationStatus(applicantApplicationStatus); + } + + isolated resource function delete sms/hrm/applicant_application_statuses/[int id]() returns int|error? { + return deleteApplicantApplicationStatus(id); + } + + isolated resource function get sms/hrm/applicant_qualifications() returns ApplicantQualification[]|error? { + return getApplicantQualifications(); + } + + isolated resource function get sms/hrm/applicant_qualifications/[int id]() returns ApplicantQualification|error? { + return getApplicantQualification(id); + } + + isolated resource function post sms/hrm/applicant_qualifications(@http:Payload ApplicantQualification applicantQualification) returns int|error? { + return addApplicantQualification(applicantQualification); + } + + isolated resource function put sms/hrm/applicant_qualifications(@http:Payload ApplicantQualification applicantQualification) returns int|error? { + return updateApplicantQualification(applicantQualification); + } + + isolated resource function delete sms/hrm/applicant_qualifications/[int id]() returns int|error? { + return deleteApplicantQualification(id); + } + + isolated resource function get sms/hrm/applicant_skills() returns ApplicantSkill[]|error? { + return getApplicantSkills(); + } + + isolated resource function get sms/hrm/applicant_skills/[int id]() returns ApplicantSkill|error? { + return getApplicantSkill(id); + } + + isolated resource function post sms/hrm/applicant_skills(@http:Payload ApplicantSkill applicantSkill) returns int|error? { + return addApplicantSkill(applicantSkill); + } + + isolated resource function put sms/hrm/applicant_skills(@http:Payload ApplicantSkill applicantSkill) returns int|error? { + return updateApplicantSkill(applicantSkill); + } + + isolated resource function delete sms/hrm/applicant_skills/[int id]() returns int|error? { + return deleteApplicantSkill(id); + } + + isolated resource function get sms/hrm/applicant_evaluations() returns ApplicantEvaluation[]|error? { + return getApplicantEvaluations(); + } + + isolated resource function get sms/hrm/applicant_evaluations/[int id]() returns ApplicantEvaluation|error? { + return getApplicantEvaluation(id); + } + + isolated resource function post sms/hrm/applicant_evaluations(@http:Payload ApplicantEvaluation applicantEvaluation) returns int|error? { + return addApplicantEvaluation(applicantEvaluation); + } + + isolated resource function put sms/hrm/applicant_evaluations(@http:Payload ApplicantEvaluation applicantEvaluation) returns int|error? { + return updateApplicantEvaluation(applicantEvaluation); + } + + isolated resource function delete sms/hrm/applicant_evaluations/[int id]() returns int|error? { + return deleteApplicantEvaluation(id); + } + + isolated resource function get sms/hrm/applicant_interviews() returns ApplicantInterview[]|error? { + return getApplicantInterviews(); + } + + isolated resource function get sms/hrm/applicant_interviews/[int id]() returns ApplicantInterview|error? { + return getApplicantInterview(id); + } + + isolated resource function post sms/hrm/applicant_interviews(@http:Payload ApplicantInterview applicantInterview) returns int|error? { + return addApplicantInterview(applicantInterview); + } + + isolated resource function put sms/hrm/applicant_interviews(@http:Payload ApplicantInterview applicantInterview) returns int|error? { + return updateApplicantInterview(applicantInterview); + } + + isolated resource function delete sms/hrm/applicant_interviews/[int id]() returns int|error? { + return deleteApplicantInterview(id); + } + + isolated resource function get sms/hrm/job_offers() returns JobOffer[]|error? { + return getJobOffers(); + } + + isolated resource function get sms/hrm/job_offers/[int id]() returns JobOffer|error? { + return getJobOffer(id); + } + + isolated resource function post sms/hrm/job_offers(@http:Payload JobOffer jobOffer) returns int|error? { + return addJobOffer(jobOffer); + } + + isolated resource function put sms/hrm/job_offers(@http:Payload JobOffer jobOffer) returns int|error? { + return updateJobOffer(jobOffer); + } + + isolated resource function delete sms/hrm/job_offers/[int id]() returns int|error? { + return deleteJobOffer(id); + } + + isolated resource function get sms/hrm/employee_qualifications() returns EmployeeQualification[]|error? { + return getEmployeeQualifications(); + } + + isolated resource function get sms/hrm/employee_qualifications/[int id]() returns EmployeeQualification|error? { + return getEmployeeQualification(id); + } + + isolated resource function post sms/hrm/employee_qualifications(@http:Payload EmployeeQualification employeeQualification) returns int|error? { + return addEmployeeQualification(employeeQualification); + } + + isolated resource function put sms/hrm/employee_qualifications(@http:Payload EmployeeQualification employeeQualification) returns int|error? { + return updateEmployeeQualification(employeeQualification); + } + + isolated resource function delete sms/hrm/employee_qualifications/[int id]() returns int|error? { + return deleteEmployeeQualification(id); + } + + isolated resource function get sms/hrm/employee_skills() returns EmployeeSkill[]|error? { + return getEmployeeSkills(); + } + + isolated resource function get sms/hrm/employee_skills/[int id]() returns EmployeeSkill|error? { + return getEmployeeSkill(id); + } + + isolated resource function post sms/hrm/employee_skills(@http:Payload EmployeeSkill employeeSkill) returns int|error? { + return addEmployeeSkill(employeeSkill); + } + + isolated resource function put sms/hrm/employee_skills(@http:Payload EmployeeSkill employeeSkill) returns int|error? { + return updateEmployeeSkill(employeeSkill); + } + + isolated resource function delete sms/hrm/employee_skills/[int id]() returns int|error? { + return deleteEmployeeSkill(id); + } + + isolated resource function get sms/hrm/evaluation_cycles() returns EvaluationCycle[]|error? { + return getEvaluationCycles(); + } + + isolated resource function get sms/hrm/evaluation_cycles/[int id]() returns EvaluationCycle|error? { + return getEvaluationCycle(id); + } + + isolated resource function post sms/hrm/evaluation_cycles(@http:Payload EvaluationCycle evaluationCycle) returns int|error? { + return addEvaluationCycle(evaluationCycle); + } + + isolated resource function put sms/hrm/evaluation_cycles(@http:Payload EvaluationCycle evaluationCycle) returns int|error? { + return updateEvaluationCycle(evaluationCycle); + } + + isolated resource function delete sms/hrm/evaluation_cycles/[int id]() returns int|error? { + return deleteEvaluationCycle(id); + } + + isolated resource function get sms/hrm/employee_evaluations() returns EmployeeEvaluation[]|error? { + return getEmployeeEvaluations(); + } + + isolated resource function get sms/hrm/employee_evaluations/[int id]() returns EmployeeEvaluation|error? { + return getEmployeeEvaluation(id); + } + + isolated resource function post sms/hrm/employee_evaluations(@http:Payload EmployeeEvaluation employeeEvaluation) returns int|error? { + return addEmployeeEvaluation(employeeEvaluation); + } + + isolated resource function put sms/hrm/employee_evaluations(@http:Payload EmployeeEvaluation employeeEvaluation) returns int|error? { + return updateEmployeeEvaluation(employeeEvaluation); + } + + isolated resource function delete sms/hrm/employee_evaluations/[int id]() returns int|error? { + return deleteEmployeeEvaluation(id); + } + + isolated resource function get sms/hrm/attendance_types() returns AttendanceType[]|error? { + return getAttendanceTypes(); + } + + isolated resource function get sms/hrm/attendance_types/[int id]() returns AttendanceType|error? { + return getAttendanceType(id); + } + + isolated resource function post sms/hrm/attendance_types(@http:Payload AttendanceType attendanceType) returns int|error? { + return addAttendanceType(attendanceType); + } + + isolated resource function put sms/hrm/attendance_types(@http:Payload AttendanceType attendanceType) returns int|error? { + return updateAttendanceType(attendanceType); + } + + isolated resource function delete sms/hrm/attendance_types/[int id]() returns int|error? { + return deleteAttendanceType(id); + } + + isolated resource function get sms/hrm/employee_attendances() returns EmployeeAttendance[]|error? { + return getEmployeeAttendances(); + } + + isolated resource function get sms/hrm/employee_attendances/[int id]() returns EmployeeAttendance|error? { + return getEmployeeAttendance(id); + } + + isolated resource function post sms/hrm/employee_attendances(@http:Payload EmployeeAttendance employeeAttendance) returns int|error? { + return addEmployeeAttendance(employeeAttendance); + } + + isolated resource function put sms/hrm/employee_attendances(@http:Payload EmployeeAttendance employeeAttendance) returns int|error? { + return updateEmployeeAttendance(employeeAttendance); + } + + isolated resource function delete sms/hrm/employee_attendances/[int id]() returns int|error? { + return deleteEmployeeAttendance(id); + } + + isolated resource function get sms/hrm/leave_types() returns LeaveType[]|error? { + return getLeaveTypes(); + } + + isolated resource function get sms/hrm/leave_types/[int id]() returns LeaveType|error? { + return getLeaveType(id); + } + + isolated resource function post sms/hrm/leave_types(@http:Payload LeaveType leaveType) returns int|error? { + return addLeaveType(leaveType); + } + + isolated resource function put sms/hrm/leave_types(@http:Payload LeaveType leaveType) returns int|error? { + return updateLeaveType(leaveType); + } + + isolated resource function delete sms/hrm/leave_types/[int id]() returns int|error? { + return deleteLeaveType(id); + } + + isolated resource function get sms/hrm/employee_leaves() returns EmployeeLeave[]|error? { + return getEmployeeLeaves(); + } + + isolated resource function get sms/hrm/employee_leaves/[int id]() returns EmployeeLeave|error? { + return getEmployeeLeave(id); + } + + isolated resource function post sms/hrm/employee_leaves(@http:Payload EmployeeLeave employeeLeave) returns int|error? { + return addEmployeeLeave(employeeLeave); + } + + isolated resource function put sms/hrm/employee_leaves(@http:Payload EmployeeLeave employeeLeave) returns int|error? { + return updateEmployeeLeave(employeeLeave); + } + + isolated resource function delete sms/hrm/employee_leaves/[int id]() returns int|error? { + return deleteEmployeeLeave(id); + } + }