Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed issues in student profile #435

Merged
merged 16 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions campus/bffs/enrollment/api/client.bal
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public isolated client class GraphqlClient {
return <GetPersonsResponse>check performDataBinding(graphqlResponse, GetPersonsResponse);
}
remote isolated function getPersonById(int id) returns GetPersonByIdResponse|graphql:ClientError {
string query = string `query getPersonById($id:Int!) {person_by_id(id:$id) {id preferred_name full_name date_of_birth sex asgardeo_id jwt_sub_id created updated jwt_email permanent_address {city {id name {name_en name_si name_ta}} street_address phone id} mailing_address {city {id name {name_en name_si name_ta}} street_address phone id} phone organization {id description notes address {id} avinya_type {id name} name {name_en} parent_organizations {id name {name_en}}} avinya_type_id notes nic_no passport_no id_no email street_address digital_id avinya_phone bank_name bank_account_number bank_account_name academy_org_id bank_branch created_by updated_by current_job}}`;
string query = string `query getPersonById($id:Int!) {person_by_id(id:$id) {id preferred_name full_name date_of_birth sex asgardeo_id jwt_sub_id created updated jwt_email mailing_address {city {id name {name_en name_si name_ta} district {id name {name_en}}} street_address phone id} phone organization {id description notes address {id} avinya_type {id name} name {name_en} parent_organizations {id name {name_en}}} avinya_type_id notes nic_no passport_no id_no email street_address digital_id avinya_phone bank_name bank_account_number bank_account_name academy_org_id bank_branch created_by updated_by current_job}}`;
map<anydata> variables = {"id": id};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetPersonByIdResponse>check performDataBinding(graphqlResponse, GetPersonByIdResponse);
Expand All @@ -47,11 +47,17 @@ public isolated client class GraphqlClient {
return <UpdatePersonResponse>check performDataBinding(graphqlResponse, UpdatePersonResponse);
}
remote isolated function getDistricts() returns GetDistrictsResponse|graphql:ClientError {
string query = string `query getDistricts {districts {id province {id name {name_en}} name {name_en} cities {id name {name_en}}}}`;
string query = string `query getDistricts {districts {id province {id name {name_en}} name {name_en}}}`;
map<anydata> variables = {};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetDistrictsResponse>check performDataBinding(graphqlResponse, GetDistrictsResponse);
}
remote isolated function getCities(int district_id) returns GetCitiesResponse|graphql:ClientError {
string query = string `query getCities($district_id:Int!) {cities(district_id:$district_id) {id name {name_en}}}`;
map<anydata> variables = {"district_id": district_id};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetCitiesResponse>check performDataBinding(graphqlResponse, GetCitiesResponse);
}
remote isolated function getAllOrganizations() returns GetAllOrganizationsResponse|graphql:ClientError {
string query = string `query getAllOrganizations {all_organizations {id name {name_en} address {id street_address} avinya_type {id name} description phone notes}}`;
map<anydata> variables = {};
Expand Down
24 changes: 24 additions & 0 deletions campus/bffs/enrollment/api/service.bal
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,30 @@ service / on new http:Listener(9095) {
}
}

resource function get cities/[int district_id]() returns City[]|error {
GetCitiesResponse|graphql:ClientError getCitiesResponse = globalDataClient->getCities(district_id);
if (getCitiesResponse is GetCitiesResponse) {
City[] citiesData = [];
foreach var city in getCitiesResponse.cities {
City|error cityData = city.cloneWithType(City);
if (cityData is City) {
citiesData.push(cityData);
} else {
log:printError("Error while processing Application record received", cityData);
return error("Error while processing Application record received: " + cityData.message() +
":: Detail: " + cityData.detail().toString());
}
}

return citiesData;

} else {
log:printError("Error while getting application", getCitiesResponse);
return error("Error while getting application: " + getCitiesResponse.message() +
":: Detail: " + getCitiesResponse.detail().toString());
}
}

resource function get all_organizations() returns Organization[]|error {
GetAllOrganizationsResponse|graphql:ClientError getAllOrganizationsResponse = globalDataClient->getAllOrganizations();
if (getAllOrganizationsResponse is GetAllOrganizationsResponse) {
Expand Down
32 changes: 14 additions & 18 deletions campus/bffs/enrollment/api/types.bal
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,12 @@ public type GetPersonByIdResponse record {|
string? name_si;
string? name_ta;
|} name;
|} city;
string? street_address;
int? phone;
int? id;
|}? permanent_address;
record {|
record {|
int? id;
record {|
string? name_en;
string? name_si;
string? name_ta;
|} name;
int? id;
record {|
string? name_en;
|} name;
|} district;
|} city;
string? street_address;
int? phone;
Expand Down Expand Up @@ -371,15 +364,18 @@ public type GetDistrictsResponse record {|
record {|
string? name_en;
|} name;
record {|
int? id;
record {|
string? name_en;
|} name;
|}[] cities;
|}[] districts;
|};

public type GetCitiesResponse record {|
map<json?> __extensions?;
record {|
int? id;
record {|
string? name_en;
|} name;
|}[] cities;
|};
public type GetAvinyaTypesResponse record {|
map<json?> __extensions?;
record {|
Expand Down
139 changes: 75 additions & 64 deletions campus/bffs/enrollment/graphql_client/enrollment.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,6 @@ query getPersonById($id: Int!) {
created
updated
jwt_email
permanent_address {
city {
id
name {
name_en
name_si
name_ta
}
}
street_address
phone
id
}
mailing_address {
city {
id
Expand All @@ -111,6 +98,12 @@ query getPersonById($id: Int!) {
name_si
name_ta
}
district {
id
name {
name_en
}
}
}
street_address
phone
Expand Down Expand Up @@ -158,11 +151,20 @@ query getPersonById($id: Int!) {
}
}

mutation updatePerson($person: Person!,$permanent_address: Address,$permanent_address_city: City,
$mailing_address: Address,$mailing_address_city: City) {
update_person(person: $person,permanent_address: $permanent_address,
permanent_address_city: $permanent_address_city,mailing_address: $mailing_address,
mailing_address_city: $mailing_address_city) {
mutation updatePerson(
$person: Person!
$permanent_address: Address
$permanent_address_city: City
$mailing_address: Address
$mailing_address_city: City
) {
update_person(
person: $person
permanent_address: $permanent_address
permanent_address_city: $permanent_address_city
mailing_address: $mailing_address
mailing_address_city: $mailing_address_city
) {
id
preferred_name
full_name
Expand Down Expand Up @@ -241,62 +243,72 @@ mutation updatePerson($person: Person!,$permanent_address: Address,$permanent_ad
}
}


query getDistricts {
districts {
id
province{
id
name{
name_en
}
}
name{
name_en
}
cities{
id
name{
name_en
}
}
districts {
id
province {
id
name {
name_en
}
}
name {
name_en
}
}
}

query getCities($district_id: Int!) {
cities(district_id: $district_id) {
id
name {
name_en
}
}
}

query getAvinyaTypes {
avinya_types {
id
active
name
global_type
foundation_type
focus
level
}
avinya_types {
id
active
name
global_type
foundation_type
focus
level
}
}

query getAllOrganizations {
all_organizations {
id
name{
name_en
}
address{
id
street_address
}
avinya_type{
id
name
}
description
phone
notes
all_organizations {
id
name {
name_en
}
address {
id
street_address
}
avinya_type {
id
name
}
description
phone
notes
}
}

mutation insertPerson($person: Person!,$mailing_address: Address,$mailing_address_city: City) {
insert_person(person: $person,mailing_address: $mailing_address,mailing_address_city: $mailing_address_city) {
mutation insertPerson(
$person: Person!
$mailing_address: Address
$mailing_address_city: City
) {
insert_person(
person: $person
mailing_address: $mailing_address
mailing_address_city: $mailing_address_city
) {
id
preferred_name
full_name
Expand Down Expand Up @@ -374,4 +386,3 @@ mutation insertPerson($person: Person!,$mailing_address: Address,$mailing_addres
current_job
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public isolated client class GraphqlClient {
return <GetPersonsResponse> check performDataBinding(graphqlResponse, GetPersonsResponse);
}
remote isolated function getPersonById(int id) returns GetPersonByIdResponse|graphql:ClientError {
string query = string `query getPersonById($id:Int!) {person_by_id(id:$id) {id preferred_name full_name date_of_birth sex asgardeo_id jwt_sub_id created updated jwt_email permanent_address {city {id name {name_en name_si name_ta}} street_address phone id} mailing_address {city {id name {name_en name_si name_ta}} street_address phone id} phone organization {id description notes address {id} avinya_type {id name} name {name_en} parent_organizations {id name {name_en}}} avinya_type_id notes nic_no passport_no id_no email street_address digital_id avinya_phone bank_name bank_account_number bank_account_name academy_org_id bank_branch created_by updated_by current_job}}`;
string query = string `query getPersonById($id:Int!) {person_by_id(id:$id) {id preferred_name full_name date_of_birth sex asgardeo_id jwt_sub_id created updated jwt_email mailing_address {city {id name {name_en name_si name_ta} district {id name {name_en}}} street_address phone id} phone organization {id description notes address {id} avinya_type {id name} name {name_en} parent_organizations {id name {name_en}}} avinya_type_id notes nic_no passport_no id_no email street_address digital_id avinya_phone bank_name bank_account_number bank_account_name academy_org_id bank_branch created_by updated_by current_job}}`;
map<anydata> variables = {"id": id};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetPersonByIdResponse> check performDataBinding(graphqlResponse, GetPersonByIdResponse);
Expand All @@ -46,11 +46,17 @@ public isolated client class GraphqlClient {
return <UpdatePersonResponse> check performDataBinding(graphqlResponse, UpdatePersonResponse);
}
remote isolated function getDistricts() returns GetDistrictsResponse|graphql:ClientError {
string query = string `query getDistricts {districts {id province {id name {name_en}} name {name_en} cities {id name {name_en}}}}`;
string query = string `query getDistricts {districts {id province {id name {name_en}} name {name_en}}}`;
map<anydata> variables = {};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetDistrictsResponse> check performDataBinding(graphqlResponse, GetDistrictsResponse);
}
remote isolated function getCities(int district_id) returns GetCitiesResponse|graphql:ClientError {
string query = string `query getCities($district_id:Int!) {cities(district_id:$district_id) {id name {name_en}}}`;
map<anydata> variables = {"district_id": district_id};
json graphqlResponse = check self.graphqlClient->executeWithType(query, variables);
return <GetCitiesResponse> check performDataBinding(graphqlResponse, GetCitiesResponse);
}
remote isolated function getAvinyaTypes() returns GetAvinyaTypesResponse|graphql:ClientError {
string query = string `query getAvinyaTypes {avinya_types {id active name global_type foundation_type focus level}}`;
map<anydata> variables = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,19 +529,12 @@ public type GetPersonByIdResponse record {|
string? name_si;
string? name_ta;
|} name;
|} city;
string? street_address;
int? phone;
int? id;
|}? permanent_address;
record {|
record {|
int? id;
record {|
string? name_en;
string? name_si;
string? name_ta;
|} name;
int? id;
record {|
string? name_en;
|} name;
|} district;
|} city;
string? street_address;
int? phone;
Expand Down Expand Up @@ -683,15 +676,19 @@ public type GetDistrictsResponse record {|
record {|
string? name_en;
|} name;
record {|
int? id;
record {|
string? name_en;
|} name;
|}[] cities;
|}[]? districts;
|};

public type GetCitiesResponse record {|
map<json?> __extensions?;
record {|
int? id;
record {|
string? name_en;
|} name;
|}[]? cities;
|};

public type GetAvinyaTypesResponse record {|
map<json?> __extensions?;
record {|
Expand Down
1 change: 1 addition & 0 deletions campus/bffs/enrollment/graphql_client/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ type Query {
persons(organization_id: Int, avinya_type_id: Int): [PersonData!]
person_by_id(id: Int): PersonData
districts: [DistrictData!]
cities(district_id: Int): [CityData!]
all_organizations: [OrganizationData!]
}

Expand Down
Loading
Loading