|
|
@ -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,26 +62,26 @@ 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." |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
"message", "Given mobile number “" + MobileNo + "” is not registered."); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (sendSMS) { |
|
|
if (sendSMS) { |
|
|
// Integer OTP = OTP; |
|
|
// 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"; |
|
|
|
|
|
|
|
|
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); |
|
|
// System.out.println(urlString); |
|
|
RestTemplate restTemplate = new RestTemplate(); |
|
|
RestTemplate restTemplate = new RestTemplate(); |
|
|
// System.out.println(getUserListByMobileNumber(MobileNo).size()); |
|
|
// System.out.println(getUserListByMobileNumber(MobileNo).size()); |
|
|
@ -91,8 +92,7 @@ public class OfficialAPIService { |
|
|
"status", 200, |
|
|
"status", 200, |
|
|
"message", "SMS Send successfully to Mobile No " + MobileNo + ".", |
|
|
"message", "SMS Send successfully to Mobile No " + MobileNo + ".", |
|
|
// "data", Response, |
|
|
// "data", Response, |
|
|
"OTP", OTP |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
"OTP", OTP); |
|
|
} |
|
|
} |
|
|
return Collections.singletonList(successResponse); |
|
|
return Collections.singletonList(successResponse); |
|
|
} |
|
|
} |
|
|
@ -105,7 +105,8 @@ public class OfficialAPIService { |
|
|
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; |
|
|
@ -124,15 +125,15 @@ public class OfficialAPIService { |
|
|
// 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 |
|
|
@ -245,7 +246,9 @@ 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(`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(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 + ")"; |
|
|
@ -279,7 +282,9 @@ 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(`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(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 + ")"; |
|
|
@ -287,12 +292,71 @@ public class OfficialAPIService { |
|
|
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 groups = "0"; |
|
|
String menus = "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); |
|
|
List<Map<String, Object>> moduleids = getUserModules(loginId); |
|
|
|
|
|
|
|
|
// Check if the list is not empty |
|
|
// Check if the list is not empty |
|
|
@ -314,9 +378,11 @@ 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(`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 " |
|
|
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+")"; |
|
|
|
|
|
|
|
|
+ "`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; |
|
|
} |
|
|
} |
|
|
@ -326,7 +392,8 @@ public class OfficialAPIService { |
|
|
// System.out.println("getMenu LoginID: " + loginId); |
|
|
// System.out.println("getMenu LoginID: " + loginId); |
|
|
String SqlQuery = ""; |
|
|
String SqlQuery = ""; |
|
|
String mainmenus = "0"; |
|
|
String mainmenus = "0"; |
|
|
if(loginId.isBlank() || loginId.isEmpty() || loginId==null || loginId.equals(null) || loginId.equals("null")) { |
|
|
|
|
|
|
|
|
if (loginId.isBlank() || loginId.isEmpty() || loginId == null || loginId.equals(null) |
|
|
|
|
|
|| loginId.equals("null")) { |
|
|
loginId = "11342"; |
|
|
loginId = "11342"; |
|
|
} |
|
|
} |
|
|
List<Map<String, Object>> mainModuleids = getUserMainMenu(loginId); |
|
|
List<Map<String, Object>> mainModuleids = getUserMainMenu(loginId); |
|
|
@ -351,7 +418,8 @@ public class OfficialAPIService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
SqlQuery = "SELECT *,CONCAT('https://gccservices.in/gccofficialapp/files/app_icon/menu/', icon_url) " |
|
|
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"; |
|
|
|
|
|
|
|
|
+ "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; |
|
|
} |
|
|
} |
|
|
@ -362,7 +430,8 @@ public class OfficialAPIService { |
|
|
// System.out.println("getMenu DepartmentID: " + departmentId); |
|
|
// System.out.println("getMenu DepartmentID: " + departmentId); |
|
|
String SqlQuery = ""; |
|
|
String SqlQuery = ""; |
|
|
String menus = "0"; |
|
|
String menus = "0"; |
|
|
if(loginId.isBlank() || loginId.isEmpty() || loginId==null || loginId.equals(null) || loginId.equals("null")) { |
|
|
|
|
|
|
|
|
if (loginId.isBlank() || loginId.isEmpty() || loginId == null || loginId.equals(null) |
|
|
|
|
|
|| loginId.equals("null")) { |
|
|
loginId = "11342"; |
|
|
loginId = "11342"; |
|
|
} |
|
|
} |
|
|
List<Map<String, Object>> moduleids = getUserModules(loginId); |
|
|
List<Map<String, Object>> moduleids = getUserModules(loginId); |
|
|
@ -403,7 +472,8 @@ public class OfficialAPIService { |
|
|
String SqlQuery = ""; |
|
|
String SqlQuery = ""; |
|
|
String menuitem = "0"; |
|
|
String menuitem = "0"; |
|
|
|
|
|
|
|
|
if(loginId.isBlank() || loginId.isEmpty() || loginId==null || loginId.equals(null) || loginId.equals("null")) { |
|
|
|
|
|
|
|
|
if (loginId.isBlank() || loginId.isEmpty() || loginId == null || loginId.equals(null) |
|
|
|
|
|
|| loginId.equals("null")) { |
|
|
loginId = "11342"; |
|
|
loginId = "11342"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -429,7 +499,8 @@ public class OfficialAPIService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
SqlQuery = "SELECT *,CONCAT('https://gccservices.in/gccofficialapp/files/app_icon/menu/', icon_url) " |
|
|
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"; |
|
|
|
|
|
|
|
|
+ "AS iconUrl FROM `menuitem` WHERE `ISACTIVE`=1 AND `module_id`=? AND `id` IN (" + menuitem |
|
|
|
|
|
+ ") ORDER BY `orderby`, `name` ASC"; |
|
|
|
|
|
|
|
|
// System.out.println(SqlQuery); |
|
|
// System.out.println(SqlQuery); |
|
|
List<Map<String, Object>> result = jdbcActivityTemplate.queryForList(SqlQuery, menuId); |
|
|
List<Map<String, Object>> result = jdbcActivityTemplate.queryForList(SqlQuery, menuId); |
|
|
|