From 7d351931d8f3971ae49d50b2df883e5c5e4ec4ea Mon Sep 17 00:00:00 2001 From: KaNi-04 <136799210+KaNi-04@users.noreply.github.com> Date: Fri, 24 Jul 2026 15:31:53 +0530 Subject: [PATCH] Officer API service - getUserMenuItem group id added --- .../service/OfficialAPIService.java | 657 ++++++++++-------- 1 file changed, 364 insertions(+), 293 deletions(-) diff --git a/src/main/java/in/gov/chennaicorporation/mobileservice/service/OfficialAPIService.java b/src/main/java/in/gov/chennaicorporation/mobileservice/service/OfficialAPIService.java index f284e729..d332d7a0 100644 --- a/src/main/java/in/gov/chennaicorporation/mobileservice/service/OfficialAPIService.java +++ b/src/main/java/in/gov/chennaicorporation/mobileservice/service/OfficialAPIService.java @@ -32,6 +32,7 @@ public class OfficialAPIService { private JdbcTemplate jdbcUserTemplate; private JdbcTemplate jdbcOfficalTemplate; private JdbcTemplate jdbcActivityTemplate; + @Autowired public void setDataSource( @Qualifier("oracleERPDataSource") DataSource erpDataSource, @@ -43,407 +44,477 @@ public class OfficialAPIService { this.jdbcOfficalTemplate = new JdbcTemplate(officialDataSource); this.jdbcActivityTemplate = new JdbcTemplate(activityDataSource); } - + @Transactional public List> versionCheck() { - String sqlQuery = "SELECT * FROM `app_version` WHERE `isactive`=1 LIMIT 1"; + String sqlQuery = "SELECT * FROM `app_version` WHERE `isactive`=1 LIMIT 1"; List> result = jdbcActivityTemplate.queryForList(sqlQuery); return result; } - + @Transactional public List> nammaVersionCheck() { - String sqlQuery = "SELECT * FROM `nammachennai_app_version` WHERE `isactive`=1 LIMIT 1"; + String sqlQuery = "SELECT * FROM `nammachennai_app_version` WHERE `isactive`=1 LIMIT 1"; List> result = jdbcActivityTemplate.queryForList(sqlQuery); return result; } - + public List> sendOTP(HttpServletRequest request, - String MobileNo, - String OTP, - String checkmobileno - ) { + String MobileNo, + String OTP, + String checkmobileno) { Boolean sendSMS = true; - Map successResponse =null; + Map successResponse = null; if (!"false".equalsIgnoreCase(checkmobileno)) { - if(getUserListByMobileNumber(MobileNo).size()<=0) - { + if (getUserListByMobileNumber(MobileNo).size() <= 0) { sendSMS = false; successResponse = Map.of( - "status", 404, - "message", "Given mobile number “"+MobileNo+"” is not registered." - ); + "status", 404, + "message", "Given mobile number “" + MobileNo + "” is not registered."); } } - if(sendSMS) { - //Integer OTP = OTP; - String generatedToken = "Your OTP is " + OTP + ".OTP is valid for the next 5 minutes.\nBy\nGreater Chennai Corporation."; - //String urlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to="+MobileNo+"&from=GCCCRP&body="+generatedToken+"&entityid=1401572690000011081&templateid=1407165856492044436"; - String urlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to=" + MobileNo + "&from=GCCCRP&body=" + generatedToken + "&entityid=1401572690000011081&templateid=1407165856492044436"; - //System.out.println(urlString); + if (sendSMS) { + // Integer OTP = OTP; + String generatedToken = "Your OTP is " + OTP + + ".OTP is valid for the next 5 minutes.\nBy\nGreater Chennai Corporation."; + // String urlString = + // "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to="+MobileNo+"&from=GCCCRP&body="+generatedToken+"&entityid=1401572690000011081&templateid=1407165856492044436"; + String urlString = "https://tmegov.onex-aura.com/api/sms?key=pfTEYN6H&to=" + MobileNo + "&from=GCCCRP&body=" + + generatedToken + "&entityid=1401572690000011081&templateid=1407165856492044436"; + // System.out.println(urlString); RestTemplate restTemplate = new RestTemplate(); - //System.out.println(getUserListByMobileNumber(MobileNo).size()); + // System.out.println(getUserListByMobileNumber(MobileNo).size()); String Response = restTemplate.getForObject(urlString, String.class); - //System.out.println(Response); + // System.out.println(Response); // Add a success status and message to the result - successResponse = Map.of( - "status", 200, - "message", "SMS Send successfully to Mobile No "+MobileNo+".", - //"data", Response, - "OTP", OTP - ); + successResponse = Map.of( + "status", 200, + "message", "SMS Send successfully to Mobile No " + MobileNo + ".", + // "data", Response, + "OTP", OTP); } - return Collections.singletonList(successResponse); + return Collections.singletonList(successResponse); } - + @Transactional public List> getloginList(String username, String password, String usertype) { - // PIN added in response for session logout needed by vaibalan - String sqlQuery = ""; - List> result=null; + // PIN added in response for session logout needed by vaibalan + String sqlQuery = ""; + List> result = null; try { - switch (usertype) { - case "erp": - //sqlQuery = "SELECT * FROM `EG_USER` WHERE `ISPORTALUSER` <> 1 AND `ISACTIVE` = 1 AND `EXTRAFIELD2` = ? AND `PIN` = ? LIMIT 1"; - sqlQuery = "SELECT id, USER_NAME, EXTRAFIELD2, PIN FROM `EG_USER` WHERE `EXTRAFIELD2` = ? AND `PIN` = ? AND `ISACTIVE`=1 LIMIT 1"; - result = jdbcOfficalTemplate.queryForList(sqlQuery, username, password); - break; - case "nonerp": - sqlQuery = "SELECT id, USER_NAME, EXTRAFIELD2, PIN FROM `EG_USER` WHERE `EXTRAFIELD2` = ? AND `PIN` = ? AND `ISACTIVE`=1 LIMIT 1"; - result = jdbcOfficalTemplate.queryForList(sqlQuery, username, password); - break; - // additional cases can be added here - default: - sqlQuery = "SELECT id, USER_NAME, EXTRAFIELD2, PIN FROM `EG_USER` WHERE `EXTRAFIELD2` = ? AND `PIN` = ? AND `ISACTIVE`=1 LIMIT 1"; - result = jdbcOfficalTemplate.queryForList(sqlQuery, username, password); - //result = Collections.emptyList(); - break; - } - } catch (Exception e) { - // Log the error - e.printStackTrace(); - // Return an error message as part of the result list - return Collections.singletonList(Collections.singletonMap("error", "An error occurred while fetching data.")); - } - - // If no records found, return a status and message indicating no user found - if (result == null || result.isEmpty()) { - Map response = Map.of( - "status", 404, - "message", "User not found." - ); - return Collections.singletonList(response); - } - - // Add a success status and message to the result - Map successResponse = Map.of( - "status", 200, - "message", "login successfuly.", - "data", result - ); - return Collections.singletonList(successResponse); - } - + switch (usertype) { + case "erp": + // sqlQuery = "SELECT * FROM `EG_USER` WHERE `ISPORTALUSER` <> 1 AND `ISACTIVE` + // = 1 AND `EXTRAFIELD2` = ? AND `PIN` = ? LIMIT 1"; + sqlQuery = "SELECT id, USER_NAME, EXTRAFIELD2, PIN FROM `EG_USER` WHERE `EXTRAFIELD2` = ? AND `PIN` = ? AND `ISACTIVE`=1 LIMIT 1"; + result = jdbcOfficalTemplate.queryForList(sqlQuery, username, password); + break; + case "nonerp": + sqlQuery = "SELECT id, USER_NAME, EXTRAFIELD2, PIN FROM `EG_USER` WHERE `EXTRAFIELD2` = ? AND `PIN` = ? AND `ISACTIVE`=1 LIMIT 1"; + result = jdbcOfficalTemplate.queryForList(sqlQuery, username, password); + break; + // additional cases can be added here + default: + sqlQuery = "SELECT id, USER_NAME, EXTRAFIELD2, PIN FROM `EG_USER` WHERE `EXTRAFIELD2` = ? AND `PIN` = ? AND `ISACTIVE`=1 LIMIT 1"; + result = jdbcOfficalTemplate.queryForList(sqlQuery, username, password); + // result = Collections.emptyList(); + break; + } + } catch (Exception e) { + // Log the error + e.printStackTrace(); + // Return an error message as part of the result list + return Collections + .singletonList(Collections.singletonMap("error", "An error occurred while fetching data.")); + } + + // If no records found, return a status and message indicating no user found + if (result == null || result.isEmpty()) { + Map response = Map.of( + "status", 404, + "message", "User not found."); + return Collections.singletonList(response); + } + + // Add a success status and message to the result + Map successResponse = Map.of( + "status", 200, + "message", "login successfuly.", + "data", result); + return Collections.singletonList(successResponse); + } + @Transactional public List updatePassword(String username, String password) { - // Initialize the list to hold the result message + // Initialize the list to hold the result message List responseList = new ArrayList<>(); - - try { - // SQL query for updating the password - String sqlQuery = "UPDATE `EG_USER` SET `PIN` = ? WHERE `EXTRAFIELD2` = ?"; - - // Execute the update query using jdbcTemplate and prepared statements to prevent SQL injection - int rowsAffected = jdbcOfficalTemplate.update(sqlQuery, password, username); - - // Check if any rows were updated - if (rowsAffected > 0) { - responseList.add(new UpdateResponse(200, "Password or Pin updated successfully.")); - } else { - responseList.add(new UpdateResponse(404, "Password or Pin not updated.")); - } - } catch (Exception e) { - // Handle any exceptions that occur during the update process - responseList.add(new UpdateResponse(500, "Error updating Password or Pin: " + e.getMessage())); - } - - // Return the list containing the update message - return responseList; + + try { + // SQL query for updating the password + String sqlQuery = "UPDATE `EG_USER` SET `PIN` = ? WHERE `EXTRAFIELD2` = ?"; + + // Execute the update query using jdbcTemplate and prepared statements to + // prevent SQL injection + int rowsAffected = jdbcOfficalTemplate.update(sqlQuery, password, username); + + // Check if any rows were updated + if (rowsAffected > 0) { + responseList.add(new UpdateResponse(200, "Password or Pin updated successfully.")); + } else { + responseList.add(new UpdateResponse(404, "Password or Pin not updated.")); + } + } catch (Exception e) { + // Handle any exceptions that occur during the update process + responseList.add(new UpdateResponse(500, "Error updating Password or Pin: " + e.getMessage())); + } + + // Return the list containing the update message + return responseList; } - + @Transactional public List> getUserListByMobileNumber(String mobileNo) { - - String sqlQuery = ""; - List> result=null; + + String sqlQuery = ""; + List> result = null; sqlQuery = "SELECT * FROM `EG_USER` WHERE `EXTRAFIELD2` = ? AND `ISACTIVE`=1"; - result = jdbcOfficalTemplate.queryForList(sqlQuery, mobileNo); - + result = jdbcOfficalTemplate.queryForList(sqlQuery, mobileNo); + return result; } - + @Transactional public List> getUserList() { - - String SqlQuery = ""; - - SqlQuery="SELECT * FROM `EG_USER` WHERE `ISACTIVE`=1"; - + + String SqlQuery = ""; + + SqlQuery = "SELECT * FROM `EG_USER` WHERE `ISACTIVE`=1"; + List> result = jdbcOfficalTemplate.queryForList(SqlQuery); return result; } - + @Transactional public List> getUserinfo(String USER_NAME) { - - String SqlQuery = ""; - - SqlQuery="SELECT * FROM `EG_USER` WHERE `USER_NAME`=? AND `ISACTIVE`=1"; - - List> result = jdbcOfficalTemplate.queryForList(SqlQuery,USER_NAME); + + String SqlQuery = ""; + + SqlQuery = "SELECT * FROM `EG_USER` WHERE `USER_NAME`=? AND `ISACTIVE`=1"; + + List> result = jdbcOfficalTemplate.queryForList(SqlQuery, USER_NAME); return result; } - + @Transactional public List> getUserGroups(String loginId) { - - String SqlQuery = ""; - - SqlQuery="SELECT `groups` FROM `user_mapping_details` WHERE `userid`=?"; - - //System.out.println(SqlQuery); - //System.out.println("loginId : "+loginId); - - List> result = jdbcUserTemplate.queryForList(SqlQuery,loginId); + + String SqlQuery = ""; + + SqlQuery = "SELECT `groups` FROM `user_mapping_details` WHERE `userid`=?"; + + // System.out.println(SqlQuery); + // System.out.println("loginId : "+loginId); + + List> result = jdbcUserTemplate.queryForList(SqlQuery, loginId); return result; } - + @Transactional public List> getUserMainMenu(String loginId) { - - String SqlQuery = ""; - String groups ="0"; - List> groupids=getUserGroups(loginId); - + + String SqlQuery = ""; + String groups = "0"; + List> groupids = getUserGroups(loginId); + // Check if the list is not empty if (groupids != null && !groupids.isEmpty()) { - // Retrieve the first map in the list - Map firstEntry = groupids.get(0); - - // Check if the map contains the "groups" key - if (firstEntry.containsKey("groups")) { - // Get the "groups" value - groups = (String) firstEntry.get("groups"); - - // Do something with the groups value - //System.out.println("Groups: " + groups); - } else { - System.out.println("The 'groups' key is not present."); - } + // Retrieve the first map in the list + Map firstEntry = groupids.get(0); + + // Check if the map contains the "groups" key + if (firstEntry.containsKey("groups")) { + // Get the "groups" value + groups = (String) firstEntry.get("groups"); + + // Do something with the groups value + // System.out.println("Groups: " + groups); + } else { + System.out.println("The 'groups' key is not present."); + } } else { - System.out.println("No data found in groupids."); + System.out.println("No data found in groupids."); } - - //SqlQuery="SELECT GROUP_CONCAT(`module_id`) AS module_ids FROM `user_group_module_access` WHERE `group_id` IN ("+groups+") GROUP by `group_id`"; - SqlQuery="SELECT GROUP_CONCAT(DISTINCT `department_id` ORDER BY `department_id` ASC) AS department_ids " + + // SqlQuery="SELECT GROUP_CONCAT(`module_id`) AS module_ids FROM + // `user_group_module_access` WHERE `group_id` IN ("+groups+") GROUP by + // `group_id`"; + SqlQuery = "SELECT GROUP_CONCAT(DISTINCT `department_id` ORDER BY `department_id` ASC) AS department_ids " + "FROM `user_group_department_access` " - + "WHERE `group_id` IN ("+groups+")"; + + "WHERE `group_id` IN (" + groups + ")"; List> result = jdbcUserTemplate.queryForList(SqlQuery); return result; } - + @Transactional public List> getUserModules(String loginId) { - - String SqlQuery = ""; - String groups ="0"; - List> groupids=getUserGroups(loginId); - + + String SqlQuery = ""; + String groups = "0"; + List> groupids = getUserGroups(loginId); + // Check if the list is not empty if (groupids != null && !groupids.isEmpty()) { - // Retrieve the first map in the list - Map firstEntry = groupids.get(0); - - // Check if the map contains the "groups" key - if (firstEntry.containsKey("groups")) { - // Get the "groups" value - groups = (String) firstEntry.get("groups"); - - // Do something with the groups value - //System.out.println("Groups: " + groups); - } else { - System.out.println("The 'groups' key is not present."); - } + // Retrieve the first map in the list + Map firstEntry = groupids.get(0); + + // Check if the map contains the "groups" key + if (firstEntry.containsKey("groups")) { + // Get the "groups" value + groups = (String) firstEntry.get("groups"); + + // Do something with the groups value + // System.out.println("Groups: " + groups); + } else { + System.out.println("The 'groups' key is not present."); + } } else { - System.out.println("No data found in groupids."); + System.out.println("No data found in groupids."); } - - //SqlQuery="SELECT GROUP_CONCAT(`module_id`) AS module_ids FROM `user_group_module_access` WHERE `group_id` IN ("+groups+") GROUP by `group_id`"; - SqlQuery="SELECT GROUP_CONCAT(DISTINCT `module_id` ORDER BY `module_id` ASC) AS module_ids " + + // SqlQuery="SELECT GROUP_CONCAT(`module_id`) AS module_ids FROM + // `user_group_module_access` WHERE `group_id` IN ("+groups+") GROUP by + // `group_id`"; + SqlQuery = "SELECT GROUP_CONCAT(DISTINCT `module_id` ORDER BY `module_id` ASC) AS module_ids " + "FROM `user_group_module_access` " - + "WHERE `group_id` IN ("+groups+")"; + + "WHERE `group_id` IN (" + groups + ")"; List> result = jdbcUserTemplate.queryForList(SqlQuery); return result; } - - + + /* + * @Transactional + * public List> getUserMenuItem(String loginId) { + * + * String SqlQuery = ""; + * String menus ="0"; + * List> moduleids=getUserModules(loginId); + * + * // Check if the list is not empty + * if (moduleids != null && !moduleids.isEmpty()) { + * // Retrieve the first map in the list + * Map firstEntry = moduleids.get(0); + * + * // Check if the map contains the "groups" key + * if (firstEntry.containsKey("module_ids")) { + * // Get the "groups" value + * menus = (String) firstEntry.get("module_ids"); + * + * // Do something with the groups value + * //System.out.println("Menus: " + menus); + * } else { + * System.out.println("The 'module_ids' key is not present."); + * } + * } else { + * System.out.println("No data found in moduleids."); + * } + * + * // + * SqlQuery="SELECT GROUP_CONCAT(`menuitem_id`) AS menuitem_ids FROM `user_group_menu_access` WHERE `module_id` IN (" + * +menus+") GROUP by `module_id`"; + * SqlQuery="SELECT GROUP_CONCAT(DISTINCT `menuitem_id` ORDER BY `menuitem_id` ASC) AS menuitem_ids FROM " + * + "`user_group_menu_access` WHERE `module_id` IN ("+menus+")"; + * List> result = jdbcUserTemplate.queryForList(SqlQuery); + * return result; + * } + */ + @Transactional public List> getUserMenuItem(String loginId) { - - String SqlQuery = ""; - String menus ="0"; - List> moduleids=getUserModules(loginId); - + + String SqlQuery = ""; + String groups = "0"; + String menus = "0"; + + List> groupids = getUserGroups(loginId); + + // Check if the list is not empty + if (groupids != null && !groupids.isEmpty()) { + // Retrieve the first map in the list + Map firstEntry = groupids.get(0); + + // Check if the map contains the "groups" key + if (firstEntry.containsKey("groups")) { + // Get the "groups" value + groups = (String) firstEntry.get("groups"); + + // Do something with the groups value + // System.out.println("Groups: " + groups); + } else { + System.out.println("The 'groups' key is not present."); + } + } else { + System.out.println("No data found in groupids."); + } + + List> moduleids = getUserModules(loginId); + // Check if the list is not empty if (moduleids != null && !moduleids.isEmpty()) { - // Retrieve the first map in the list - Map firstEntry = moduleids.get(0); - - // Check if the map contains the "groups" key - if (firstEntry.containsKey("module_ids")) { - // Get the "groups" value - menus = (String) firstEntry.get("module_ids"); - - // Do something with the groups value - //System.out.println("Menus: " + menus); - } else { - System.out.println("The 'module_ids' key is not present."); - } + // Retrieve the first map in the list + Map firstEntry = moduleids.get(0); + + // Check if the map contains the "groups" key + if (firstEntry.containsKey("module_ids")) { + // Get the "groups" value + menus = (String) firstEntry.get("module_ids"); + + // Do something with the groups value + // System.out.println("Menus: " + menus); + } else { + System.out.println("The 'module_ids' key is not present."); + } } else { - System.out.println("No data found in moduleids."); + System.out.println("No data found in moduleids."); } - - //SqlQuery="SELECT GROUP_CONCAT(`menuitem_id`) AS menuitem_ids FROM `user_group_menu_access` WHERE `module_id` IN ("+menus+") GROUP by `module_id`"; - SqlQuery="SELECT GROUP_CONCAT(DISTINCT `menuitem_id` ORDER BY `menuitem_id` ASC) AS menuitem_ids FROM " - + "`user_group_menu_access` WHERE `module_id` IN ("+menus+")"; + + // SqlQuery="SELECT GROUP_CONCAT(`menuitem_id`) AS menuitem_ids FROM + // `user_group_menu_access` WHERE `module_id` IN ("+menus+") GROUP by + // `module_id`"; + SqlQuery = "SELECT GROUP_CONCAT(DISTINCT `menuitem_id` ORDER BY `menuitem_id` ASC) AS menuitem_ids FROM " + + "`user_group_menu_access` WHERE `module_id` IN (" + menus + ") AND `group_id` IN (" + groups + ")"; List> result = jdbcUserTemplate.queryForList(SqlQuery); return result; } - + @Transactional public List> getMainMenu(String loginId) { - //System.out.println("getMenu LoginID: " + loginId); - String SqlQuery = ""; - String mainmenus ="0"; - if(loginId.isBlank() || loginId.isEmpty() || loginId==null || loginId.equals(null) || loginId.equals("null")) { - loginId="11342"; + // System.out.println("getMenu LoginID: " + loginId); + String SqlQuery = ""; + String mainmenus = "0"; + if (loginId.isBlank() || loginId.isEmpty() || loginId == null || loginId.equals(null) + || loginId.equals("null")) { + loginId = "11342"; } - List> mainModuleids=getUserMainMenu(loginId); - + List> mainModuleids = getUserMainMenu(loginId); + // Check if the list is not empty if (mainModuleids != null && !mainModuleids.isEmpty()) { - // Retrieve the first map in the list - Map firstEntry = mainModuleids.get(0); - - // Check if the map contains the "groups" key - if (firstEntry.containsKey("department_ids")) { - // Get the "groups" value - mainmenus = (String) firstEntry.get("department_ids"); - - // Do something with the groups value - //System.out.println("MainMenus: " + mainmenus); - } else { - System.out.println("The 'department_ids' key is not present."); - } + // Retrieve the first map in the list + Map firstEntry = mainModuleids.get(0); + + // Check if the map contains the "groups" key + if (firstEntry.containsKey("department_ids")) { + // Get the "groups" value + mainmenus = (String) firstEntry.get("department_ids"); + + // Do something with the groups value + // System.out.println("MainMenus: " + mainmenus); + } else { + System.out.println("The 'department_ids' key is not present."); + } } else { - System.out.println("No data found in moduleids."); + System.out.println("No data found in moduleids."); } - - SqlQuery="SELECT *,CONCAT('https://gccservices.in/gccofficialapp/files/app_icon/menu/', icon_url) " - + "AS iconUrl FROM `department` WHERE `ISACTIVE`=1 AND `id` IN ("+mainmenus+") ORDER BY `orderby`, `name` ASC"; + + SqlQuery = "SELECT *,CONCAT('https://gccservices.in/gccofficialapp/files/app_icon/menu/', icon_url) " + + "AS iconUrl FROM `department` WHERE `ISACTIVE`=1 AND `id` IN (" + mainmenus + + ") ORDER BY `orderby`, `name` ASC"; List> result = jdbcActivityTemplate.queryForList(SqlQuery); return result; } - + @Transactional public List> getMenu(String loginId, String departmentId) { - //System.out.println("getMenu LoginID: " + loginId); - //System.out.println("getMenu DepartmentID: " + departmentId); - String SqlQuery = ""; - String menus ="0"; - if(loginId.isBlank() || loginId.isEmpty() || loginId==null || loginId.equals(null) || loginId.equals("null")) { - loginId="11342"; + // System.out.println("getMenu LoginID: " + loginId); + // System.out.println("getMenu DepartmentID: " + departmentId); + String SqlQuery = ""; + String menus = "0"; + if (loginId.isBlank() || loginId.isEmpty() || loginId == null || loginId.equals(null) + || loginId.equals("null")) { + loginId = "11342"; } - List> moduleids=getUserModules(loginId); - + List> moduleids = getUserModules(loginId); + // Check if the list is not empty if (moduleids != null && !moduleids.isEmpty()) { - // Retrieve the first map in the list - Map firstEntry = moduleids.get(0); - - // Check if the map contains the "groups" key - if (firstEntry.containsKey("module_ids")) { - // Get the "groups" value - menus = (String) firstEntry.get("module_ids"); - - // Do something with the groups value - //System.out.println("Menus: " + menus); - } else { - System.out.println("The 'module_ids' key is not present."); - } + // Retrieve the first map in the list + Map firstEntry = moduleids.get(0); + + // Check if the map contains the "groups" key + if (firstEntry.containsKey("module_ids")) { + // Get the "groups" value + menus = (String) firstEntry.get("module_ids"); + + // Do something with the groups value + // System.out.println("Menus: " + menus); + } else { + System.out.println("The 'module_ids' key is not present."); + } } else { - System.out.println("No data found in moduleids."); + System.out.println("No data found in moduleids."); } - - SqlQuery="SELECT *,CONCAT('https://gccservices.in/gccofficialapp/files/app_icon/menu/', icon_url) " - + "AS iconUrl FROM `modules` WHERE `ISACTIVE`=1 AND `id` IN ("+menus+") "; - if(departmentId!=null && !departmentId.isEmpty() && !departmentId.isBlank()) { - SqlQuery=SqlQuery+" AND `departmentId_id`='"+departmentId+"' "; + + SqlQuery = "SELECT *,CONCAT('https://gccservices.in/gccofficialapp/files/app_icon/menu/', icon_url) " + + "AS iconUrl FROM `modules` WHERE `ISACTIVE`=1 AND `id` IN (" + menus + ") "; + if (departmentId != null && !departmentId.isEmpty() && !departmentId.isBlank()) { + SqlQuery = SqlQuery + " AND `departmentId_id`='" + departmentId + "' "; } - - SqlQuery = SqlQuery+" ORDER BY `orderby`, `name` ASC"; + + SqlQuery = SqlQuery + " ORDER BY `orderby`, `name` ASC"; List> result = jdbcActivityTemplate.queryForList(SqlQuery); return result; } - + @Transactional public List> getSubMenu(String loginId, String menuId) { - - String SqlQuery = ""; - String menuitem ="0"; - - if(loginId.isBlank() || loginId.isEmpty() || loginId==null || loginId.equals(null) || loginId.equals("null")) { - loginId="11342"; + + String SqlQuery = ""; + String menuitem = "0"; + + if (loginId.isBlank() || loginId.isEmpty() || loginId == null || loginId.equals(null) + || loginId.equals("null")) { + loginId = "11342"; } - - List> moduleids=getUserMenuItem(loginId); - + + List> moduleids = getUserMenuItem(loginId); + // Check if the list is not empty if (moduleids != null && !moduleids.isEmpty()) { - // Retrieve the first map in the list - Map firstEntry = moduleids.get(0); - - // Check if the map contains the "groups" key - if (firstEntry.containsKey("menuitem_ids")) { - // Get the "groups" value - menuitem = (String) firstEntry.get("menuitem_ids"); - - // Do something with the groups value - //System.out.println("MenuItems: " + menuitem); - } else { - System.out.println("The 'menuitem_ids' key is not present."); - } + // Retrieve the first map in the list + Map firstEntry = moduleids.get(0); + + // Check if the map contains the "groups" key + if (firstEntry.containsKey("menuitem_ids")) { + // Get the "groups" value + menuitem = (String) firstEntry.get("menuitem_ids"); + + // Do something with the groups value + // System.out.println("MenuItems: " + menuitem); + } else { + System.out.println("The 'menuitem_ids' key is not present."); + } } else { - System.out.println("No data found in menuitem_ids."); + System.out.println("No data found in menuitem_ids."); } - - SqlQuery="SELECT *,CONCAT('https://gccservices.in/gccofficialapp/files/app_icon/menu/', icon_url) " - + "AS iconUrl FROM `menuitem` WHERE `ISACTIVE`=1 AND `module_id`=? AND `id` IN ("+menuitem+") ORDER BY `orderby`, `name` ASC"; - - //System.out.println(SqlQuery); - List> result = jdbcActivityTemplate.queryForList(SqlQuery,menuId); + + SqlQuery = "SELECT *,CONCAT('https://gccservices.in/gccofficialapp/files/app_icon/menu/', icon_url) " + + "AS iconUrl FROM `menuitem` WHERE `ISACTIVE`=1 AND `module_id`=? AND `id` IN (" + menuitem + + ") ORDER BY `orderby`, `name` ASC"; + + // System.out.println(SqlQuery); + List> result = jdbcActivityTemplate.queryForList(SqlQuery, menuId); return result; } - + @Transactional - public List> getSubSubMenu(String loginId, String menuId, String submenuId ) { - - String SqlQuery = ""; - - SqlQuery="SELECT *,CONCAT('https://gccservices.in/gccofficialapp/files/app_icon/menu/', icon_url) AS iconUrl FROM `submenuitem` WHERE `ISACTIVE`=1 AND `module_id`=? AND `menuitem_id`=?"; - - List> result = jdbcActivityTemplate.queryForList(SqlQuery,menuId,submenuId); + public List> getSubSubMenu(String loginId, String menuId, String submenuId) { + + String SqlQuery = ""; + + SqlQuery = "SELECT *,CONCAT('https://gccservices.in/gccofficialapp/files/app_icon/menu/', icon_url) AS iconUrl FROM `submenuitem` WHERE `ISACTIVE`=1 AND `module_id`=? AND `menuitem_id`=?"; + + List> result = jdbcActivityTemplate.queryForList(SqlQuery, menuId, submenuId); return result; } }