From e1211ce7482706934ba33722b1d114fa2d3a72b9 Mon Sep 17 00:00:00 2001 From: lahirulakruwan Date: Mon, 23 Sep 2024 19:38:36 +0530 Subject: [PATCH] persons data fetch api changes added --- api/Dependencies.toml | 2 +- api/main.bal | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/api/Dependencies.toml b/api/Dependencies.toml index 6723246..16c10e1 100644 --- a/api/Dependencies.toml +++ b/api/Dependencies.toml @@ -420,7 +420,7 @@ modules = [ [[package]] org = "ballerinax" name = "mysql.driver" -version = "1.6.0" +version = "1.7.0" modules = [ {org = "ballerinax", packageName = "mysql.driver", moduleName = "mysql.driver"} ] diff --git a/api/main.bal b/api/main.bal index e8dff4e..d343a45 100644 --- a/api/main.bal +++ b/api/main.bal @@ -5495,6 +5495,44 @@ AND p.organization_id IN ( return vehicleReasonDatas; } + + isolated resource function get persons(int? organization_id,int? avinya_type_id) returns PersonData[]|error? { + stream persons_data; + + if(organization_id !=null && avinya_type_id !=null){ + + lock { + persons_data = db_client->query( + `SELECT * + from person p + where + p.avinya_type_id = ${avinya_type_id} and + p.organization_id IN( + Select child_org_id + from parent_child_organization pco + where pco.parent_org_id = ${organization_id} + );`); + } + + + PersonData[] personDatas = []; + + check from Person person_data_record in persons_data + do { + PersonData|error personData = new PersonData(null,0,person_data_record); + if !(personData is error) { + personDatas.push(personData); + } + }; + + check persons_data.close(); + return personDatas; + }else { + return error("Provide non-null values for both 'organization_id' and 'avinya_type_id'."); + } + + } + } isolated function calculateWeekdays(time:Utc toDate, time:Utc fromDate) returns int {