Browse Source

Officer API service - getUserMenuItem group id added

master
KaNi-04 3 months ago
parent
commit
7d351931d8
  1. 247
      src/main/java/in/gov/chennaicorporation/mobileservice/service/OfficialAPIService.java

247
src/main/java/in/gov/chennaicorporation/mobileservice/service/OfficialAPIService.java

@ -32,6 +32,7 @@ public class OfficialAPIService {
private JdbcTemplate jdbcUserTemplate; private JdbcTemplate jdbcUserTemplate;
private JdbcTemplate jdbcOfficalTemplate; private JdbcTemplate jdbcOfficalTemplate;
private JdbcTemplate jdbcActivityTemplate; private JdbcTemplate jdbcActivityTemplate;
@Autowired @Autowired
public void setDataSource( public void setDataSource(
@Qualifier("oracleERPDataSource") DataSource erpDataSource, @Qualifier("oracleERPDataSource") DataSource erpDataSource,
@ -61,38 +62,37 @@ public class OfficialAPIService {
public List<Map<String, Object>> sendOTP(HttpServletRequest request, public List<Map<String, Object>> sendOTP(HttpServletRequest request,
String MobileNo, String MobileNo,
String OTP, String OTP,
String checkmobileno
) {
String checkmobileno) {
Boolean sendSMS = true; Boolean sendSMS = true;
Map<String, Object> successResponse =null;
Map<String, Object> successResponse = null;
if (!"false".equalsIgnoreCase(checkmobileno)) { if (!"false".equalsIgnoreCase(checkmobileno)) {
if(getUserListByMobileNumber(MobileNo).size()<=0)
{
if (getUserListByMobileNumber(MobileNo).size() <= 0) {
sendSMS = false; sendSMS = false;
successResponse = Map.of( successResponse = Map.of(
"status", 404, "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);
"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);
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
//System.out.println(getUserListByMobileNumber(MobileNo).size());
// System.out.println(getUserListByMobileNumber(MobileNo).size());
String Response = restTemplate.getForObject(urlString, String.class); String Response = restTemplate.getForObject(urlString, String.class);
//System.out.println(Response);
// System.out.println(Response);
// Add a success status and message to the result // Add a success status and message to the result
successResponse = Map.of( successResponse = Map.of(
"status", 200, "status", 200,
"message", "SMS Send successfully to Mobile No "+MobileNo+".",
//"data", Response,
"OTP", OTP
);
"message", "SMS Send successfully to Mobile No " + MobileNo + ".",
// "data", Response,
"OTP", OTP);
} }
return Collections.singletonList(successResponse); return Collections.singletonList(successResponse);
} }
@ -101,11 +101,12 @@ public class OfficialAPIService {
public List<Map<String, Object>> getloginList(String username, String password, String usertype) { public List<Map<String, Object>> getloginList(String username, String password, String usertype) {
// PIN added in response for session logout needed by vaibalan // PIN added in response for session logout needed by vaibalan
String sqlQuery = ""; String sqlQuery = "";
List<Map<String, Object>> result=null;
List<Map<String, Object>> result = null;
try { try {
switch (usertype) { switch (usertype) {
case "erp": case "erp":
//sqlQuery = "SELECT * FROM `EG_USER` WHERE `ISPORTALUSER` <> 1 AND `ISACTIVE` = 1 AND `EXTRAFIELD2` = ? AND `PIN` = ? LIMIT 1";
// 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"; 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 = jdbcOfficalTemplate.queryForList(sqlQuery, username, password);
break; break;
@ -117,22 +118,22 @@ public class OfficialAPIService {
default: default:
sqlQuery = "SELECT id, USER_NAME, EXTRAFIELD2, PIN FROM `EG_USER` WHERE `EXTRAFIELD2` = ? AND `PIN` = ? AND `ISACTIVE`=1 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); result = jdbcOfficalTemplate.queryForList(sqlQuery, username, password);
//result = Collections.emptyList();
// result = Collections.emptyList();
break; break;
} }
} catch (Exception e) { } catch (Exception e) {
// Log the error // Log the error
e.printStackTrace(); e.printStackTrace();
// Return an error message as part of the result list // Return an error message as part of the result list
return Collections.singletonList(Collections.singletonMap("error", "An error occurred while fetching data."));
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 no records found, return a status and message indicating no user found
if (result == null || result.isEmpty()) { if (result == null || result.isEmpty()) {
Map<String, Object> response = Map.of( Map<String, Object> response = Map.of(
"status", 404, "status", 404,
"message", "User not found."
);
"message", "User not found.");
return Collections.singletonList(response); return Collections.singletonList(response);
} }
@ -140,8 +141,7 @@ public class OfficialAPIService {
Map<String, Object> successResponse = Map.of( Map<String, Object> successResponse = Map.of(
"status", 200, "status", 200,
"message", "login successfuly.", "message", "login successfuly.",
"data", result
);
"data", result);
return Collections.singletonList(successResponse); return Collections.singletonList(successResponse);
} }
@ -154,7 +154,8 @@ public class OfficialAPIService {
// SQL query for updating the password // SQL query for updating the password
String sqlQuery = "UPDATE `EG_USER` SET `PIN` = ? WHERE `EXTRAFIELD2` = ?"; String sqlQuery = "UPDATE `EG_USER` SET `PIN` = ? WHERE `EXTRAFIELD2` = ?";
// Execute the update query using jdbcTemplate and prepared statements to prevent SQL injection
// Execute the update query using jdbcTemplate and prepared statements to
// prevent SQL injection
int rowsAffected = jdbcOfficalTemplate.update(sqlQuery, password, username); int rowsAffected = jdbcOfficalTemplate.update(sqlQuery, password, username);
// Check if any rows were updated // Check if any rows were updated
@ -176,7 +177,7 @@ public class OfficialAPIService {
public List<Map<String, Object>> getUserListByMobileNumber(String mobileNo) { public List<Map<String, Object>> getUserListByMobileNumber(String mobileNo) {
String sqlQuery = ""; String sqlQuery = "";
List<Map<String, Object>> result=null;
List<Map<String, Object>> result = null;
sqlQuery = "SELECT * FROM `EG_USER` WHERE `EXTRAFIELD2` = ? AND `ISACTIVE`=1"; sqlQuery = "SELECT * FROM `EG_USER` WHERE `EXTRAFIELD2` = ? AND `ISACTIVE`=1";
result = jdbcOfficalTemplate.queryForList(sqlQuery, mobileNo); result = jdbcOfficalTemplate.queryForList(sqlQuery, mobileNo);
@ -188,7 +189,7 @@ public class OfficialAPIService {
String SqlQuery = ""; String SqlQuery = "";
SqlQuery="SELECT * FROM `EG_USER` WHERE `ISACTIVE`=1";
SqlQuery = "SELECT * FROM `EG_USER` WHERE `ISACTIVE`=1";
List<Map<String, Object>> result = jdbcOfficalTemplate.queryForList(SqlQuery); List<Map<String, Object>> result = jdbcOfficalTemplate.queryForList(SqlQuery);
return result; return result;
@ -199,9 +200,9 @@ public class OfficialAPIService {
String SqlQuery = ""; String SqlQuery = "";
SqlQuery="SELECT * FROM `EG_USER` WHERE `USER_NAME`=? AND `ISACTIVE`=1";
SqlQuery = "SELECT * FROM `EG_USER` WHERE `USER_NAME`=? AND `ISACTIVE`=1";
List<Map<String, Object>> result = jdbcOfficalTemplate.queryForList(SqlQuery,USER_NAME);
List<Map<String, Object>> result = jdbcOfficalTemplate.queryForList(SqlQuery, USER_NAME);
return result; return result;
} }
@ -210,12 +211,12 @@ public class OfficialAPIService {
String SqlQuery = ""; String SqlQuery = "";
SqlQuery="SELECT `groups` FROM `user_mapping_details` WHERE `userid`=?";
SqlQuery = "SELECT `groups` FROM `user_mapping_details` WHERE `userid`=?";
//System.out.println(SqlQuery);
//System.out.println("loginId : "+loginId);
// System.out.println(SqlQuery);
// System.out.println("loginId : "+loginId);
List<Map<String, Object>> result = jdbcUserTemplate.queryForList(SqlQuery,loginId);
List<Map<String, Object>> result = jdbcUserTemplate.queryForList(SqlQuery, loginId);
return result; return result;
} }
@ -223,8 +224,8 @@ public class OfficialAPIService {
public List<Map<String, Object>> getUserMainMenu(String loginId) { public List<Map<String, Object>> getUserMainMenu(String loginId) {
String SqlQuery = ""; String SqlQuery = "";
String groups ="0";
List<Map<String, Object>> groupids=getUserGroups(loginId);
String groups = "0";
List<Map<String, Object>> groupids = getUserGroups(loginId);
// Check if the list is not empty // Check if the list is not empty
if (groupids != null && !groupids.isEmpty()) { if (groupids != null && !groupids.isEmpty()) {
@ -237,7 +238,7 @@ public class OfficialAPIService {
groups = (String) firstEntry.get("groups"); groups = (String) firstEntry.get("groups");
// Do something with the groups value // Do something with the groups value
//System.out.println("Groups: " + groups);
// System.out.println("Groups: " + groups);
} else { } else {
System.out.println("The 'groups' key is not present."); System.out.println("The 'groups' key is not present.");
} }
@ -245,10 +246,12 @@ public class OfficialAPIService {
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` " + "FROM `user_group_department_access` "
+ "WHERE `group_id` IN ("+groups+")";
+ "WHERE `group_id` IN (" + groups + ")";
List<Map<String, Object>> result = jdbcUserTemplate.queryForList(SqlQuery); List<Map<String, Object>> result = jdbcUserTemplate.queryForList(SqlQuery);
return result; return result;
} }
@ -257,8 +260,8 @@ public class OfficialAPIService {
public List<Map<String, Object>> getUserModules(String loginId) { public List<Map<String, Object>> getUserModules(String loginId) {
String SqlQuery = ""; String SqlQuery = "";
String groups ="0";
List<Map<String, Object>> groupids=getUserGroups(loginId);
String groups = "0";
List<Map<String, Object>> groupids = getUserGroups(loginId);
// Check if the list is not empty // Check if the list is not empty
if (groupids != null && !groupids.isEmpty()) { if (groupids != null && !groupids.isEmpty()) {
@ -271,7 +274,7 @@ public class OfficialAPIService {
groups = (String) firstEntry.get("groups"); groups = (String) firstEntry.get("groups");
// Do something with the groups value // Do something with the groups value
//System.out.println("Groups: " + groups);
// System.out.println("Groups: " + groups);
} else { } else {
System.out.println("The 'groups' key is not present."); System.out.println("The 'groups' key is not present.");
} }
@ -279,21 +282,82 @@ public class OfficialAPIService {
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` " + "FROM `user_group_module_access` "
+ "WHERE `group_id` IN ("+groups+")";
+ "WHERE `group_id` IN (" + groups + ")";
List<Map<String, Object>> result = jdbcUserTemplate.queryForList(SqlQuery); List<Map<String, Object>> result = jdbcUserTemplate.queryForList(SqlQuery);
return result; return result;
} }
/*
* @Transactional
* public List<Map<String, Object>> getUserMenuItem(String loginId) {
*
* String SqlQuery = "";
* String menus ="0";
* List<Map<String, Object>> moduleids=getUserModules(loginId);
*
* // Check if the list is not empty
* if (moduleids != null && !moduleids.isEmpty()) {
* // Retrieve the first map in the list
* Map<String, Object> 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<Map<String, Object>> result = jdbcUserTemplate.queryForList(SqlQuery);
* return result;
* }
*/
@Transactional @Transactional
public List<Map<String, Object>> getUserMenuItem(String loginId) { public List<Map<String, Object>> getUserMenuItem(String loginId) {
String SqlQuery = ""; String SqlQuery = "";
String menus ="0";
List<Map<String, Object>> moduleids=getUserModules(loginId);
String groups = "0";
String menus = "0";
List<Map<String, Object>> groupids = getUserGroups(loginId);
// Check if the list is not empty
if (groupids != null && !groupids.isEmpty()) {
// Retrieve the first map in the list
Map<String, Object> 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<Map<String, Object>> moduleids = getUserModules(loginId);
// Check if the list is not empty // Check if the list is not empty
if (moduleids != null && !moduleids.isEmpty()) { if (moduleids != null && !moduleids.isEmpty()) {
@ -306,7 +370,7 @@ public class OfficialAPIService {
menus = (String) firstEntry.get("module_ids"); menus = (String) firstEntry.get("module_ids");
// Do something with the groups value // Do something with the groups value
//System.out.println("Menus: " + menus);
// System.out.println("Menus: " + menus);
} else { } else {
System.out.println("The 'module_ids' key is not present."); System.out.println("The 'module_ids' key is not present.");
} }
@ -314,22 +378,25 @@ public class OfficialAPIService {
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<Map<String, Object>> result = jdbcUserTemplate.queryForList(SqlQuery); List<Map<String, Object>> result = jdbcUserTemplate.queryForList(SqlQuery);
return result; return result;
} }
@Transactional @Transactional
public List<Map<String, Object>> getMainMenu(String loginId) { public List<Map<String, Object>> getMainMenu(String loginId) {
//System.out.println("getMenu LoginID: " + loginId);
// System.out.println("getMenu LoginID: " + loginId);
String SqlQuery = ""; String SqlQuery = "";
String mainmenus ="0";
if(loginId.isBlank() || loginId.isEmpty() || loginId==null || loginId.equals(null) || loginId.equals("null")) {
loginId="11342";
String mainmenus = "0";
if (loginId.isBlank() || loginId.isEmpty() || loginId == null || loginId.equals(null)
|| loginId.equals("null")) {
loginId = "11342";
} }
List<Map<String, Object>> mainModuleids=getUserMainMenu(loginId);
List<Map<String, Object>> mainModuleids = getUserMainMenu(loginId);
// Check if the list is not empty // Check if the list is not empty
if (mainModuleids != null && !mainModuleids.isEmpty()) { if (mainModuleids != null && !mainModuleids.isEmpty()) {
@ -342,7 +409,7 @@ public class OfficialAPIService {
mainmenus = (String) firstEntry.get("department_ids"); mainmenus = (String) firstEntry.get("department_ids");
// Do something with the groups value // Do something with the groups value
//System.out.println("MainMenus: " + mainmenus);
// System.out.println("MainMenus: " + mainmenus);
} else { } else {
System.out.println("The 'department_ids' key is not present."); System.out.println("The 'department_ids' key is not present.");
} }
@ -350,22 +417,24 @@ public class OfficialAPIService {
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<Map<String, Object>> result = jdbcActivityTemplate.queryForList(SqlQuery); List<Map<String, Object>> result = jdbcActivityTemplate.queryForList(SqlQuery);
return result; return result;
} }
@Transactional @Transactional
public List<Map<String, Object>> getMenu(String loginId, String departmentId) { public List<Map<String, Object>> getMenu(String loginId, String departmentId) {
//System.out.println("getMenu LoginID: " + loginId);
//System.out.println("getMenu DepartmentID: " + departmentId);
// System.out.println("getMenu LoginID: " + loginId);
// System.out.println("getMenu DepartmentID: " + departmentId);
String SqlQuery = ""; String SqlQuery = "";
String menus ="0";
if(loginId.isBlank() || loginId.isEmpty() || loginId==null || loginId.equals(null) || loginId.equals("null")) {
loginId="11342";
String menus = "0";
if (loginId.isBlank() || loginId.isEmpty() || loginId == null || loginId.equals(null)
|| loginId.equals("null")) {
loginId = "11342";
} }
List<Map<String, Object>> moduleids=getUserModules(loginId);
List<Map<String, Object>> moduleids = getUserModules(loginId);
// Check if the list is not empty // Check if the list is not empty
if (moduleids != null && !moduleids.isEmpty()) { if (moduleids != null && !moduleids.isEmpty()) {
@ -378,7 +447,7 @@ public class OfficialAPIService {
menus = (String) firstEntry.get("module_ids"); menus = (String) firstEntry.get("module_ids");
// Do something with the groups value // Do something with the groups value
//System.out.println("Menus: " + menus);
// System.out.println("Menus: " + menus);
} else { } else {
System.out.println("The 'module_ids' key is not present."); System.out.println("The 'module_ids' key is not present.");
} }
@ -386,13 +455,13 @@ public class OfficialAPIService {
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<Map<String, Object>> result = jdbcActivityTemplate.queryForList(SqlQuery); List<Map<String, Object>> result = jdbcActivityTemplate.queryForList(SqlQuery);
return result; return result;
} }
@ -401,13 +470,14 @@ public class OfficialAPIService {
public List<Map<String, Object>> getSubMenu(String loginId, String menuId) { public List<Map<String, Object>> getSubMenu(String loginId, String menuId) {
String SqlQuery = ""; String SqlQuery = "";
String menuitem ="0";
String menuitem = "0";
if(loginId.isBlank() || loginId.isEmpty() || loginId==null || loginId.equals(null) || loginId.equals("null")) {
loginId="11342";
if (loginId.isBlank() || loginId.isEmpty() || loginId == null || loginId.equals(null)
|| loginId.equals("null")) {
loginId = "11342";
} }
List<Map<String, Object>> moduleids=getUserMenuItem(loginId);
List<Map<String, Object>> moduleids = getUserMenuItem(loginId);
// Check if the list is not empty // Check if the list is not empty
if (moduleids != null && !moduleids.isEmpty()) { if (moduleids != null && !moduleids.isEmpty()) {
@ -420,7 +490,7 @@ public class OfficialAPIService {
menuitem = (String) firstEntry.get("menuitem_ids"); menuitem = (String) firstEntry.get("menuitem_ids");
// Do something with the groups value // Do something with the groups value
//System.out.println("MenuItems: " + menuitem);
// System.out.println("MenuItems: " + menuitem);
} else { } else {
System.out.println("The 'menuitem_ids' key is not present."); System.out.println("The 'menuitem_ids' key is not present.");
} }
@ -428,22 +498,23 @@ public class OfficialAPIService {
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";
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<Map<String, Object>> result = jdbcActivityTemplate.queryForList(SqlQuery,menuId);
// System.out.println(SqlQuery);
List<Map<String, Object>> result = jdbcActivityTemplate.queryForList(SqlQuery, menuId);
return result; return result;
} }
@Transactional @Transactional
public List<Map<String, Object>> getSubSubMenu(String loginId, String menuId, String submenuId ) {
public List<Map<String, Object>> getSubSubMenu(String loginId, String menuId, String submenuId) {
String SqlQuery = ""; 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`=?";
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<Map<String, Object>> result = jdbcActivityTemplate.queryForList(SqlQuery,menuId,submenuId);
List<Map<String, Object>> result = jdbcActivityTemplate.queryForList(SqlQuery, menuId, submenuId);
return result; return result;
} }
} }
Loading…
Cancel
Save