From 723907078326dd9c0a8558ba29cac2eb09047af9 Mon Sep 17 00:00:00 2001 From: lakshmikommalapati <lakshmi.kommalapati@tarento.com> Date: Wed, 2 Aug 2023 18:43:24 +0530 Subject: [PATCH] made changes for user creations --- .../grievance/dao/impl/SuperAdminDaoImpl.java | 4 ++-- .../org/upsmf/grievance/dao/impl/UserDaoImpl.java | 6 +++--- .../grievance/service/impl/UserServiceImpl.java | 2 +- src/main/java/org/upsmf/grievance/util/Sql.java | 14 ++++++++------ 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/upsmf/grievance/dao/impl/SuperAdminDaoImpl.java b/src/main/java/org/upsmf/grievance/dao/impl/SuperAdminDaoImpl.java index 10cae99..3bf900f 100644 --- a/src/main/java/org/upsmf/grievance/dao/impl/SuperAdminDaoImpl.java +++ b/src/main/java/org/upsmf/grievance/dao/impl/SuperAdminDaoImpl.java @@ -131,7 +131,7 @@ public class SuperAdminDaoImpl implements SuperAdminDao { return statement; } }, keyHolder); - organization.setId((Long) keyHolder.getKey()); + organization.setId(keyHolder.getKey().longValue()); MasterDataManager.getOrgIdAndOrgNameMap().put(organization.getId(), organization.getOrgName()); } catch (Exception e) { LOGGER.error( @@ -139,7 +139,7 @@ public class SuperAdminDaoImpl implements SuperAdminDao { } if (insertSuccessful > 0) { jdbcTemplate.update(Sql.UserQueries.NEW_ORG_AUTH, new Object[] { organization.getId(), - organization.getAuthId(), organization.getUrl(), organization.getEmailDomain() }); + Integer.valueOf(organization.getAuthId()), organization.getUrl(), organization.getEmailDomain() }); orgSetup(organization, userId); return organization; } diff --git a/src/main/java/org/upsmf/grievance/dao/impl/UserDaoImpl.java b/src/main/java/org/upsmf/grievance/dao/impl/UserDaoImpl.java index 1f2b581..b069f8d 100644 --- a/src/main/java/org/upsmf/grievance/dao/impl/UserDaoImpl.java +++ b/src/main/java/org/upsmf/grievance/dao/impl/UserDaoImpl.java @@ -446,7 +446,7 @@ public class UserDaoImpl implements UserDao { public Long checkUserNameExists(String username) { Long userId; try { - userId = jdbcTemplate.queryForObject("SELECT id FROM user WHERE username = ?", new Object[] { username }, + userId = jdbcTemplate.queryForObject("SELECT \"user\".id FROM \"user\" WHERE username =?", new Object[] { username }, Long.class); } catch (Exception e) { return 0l; @@ -609,7 +609,7 @@ public class UserDaoImpl implements UserDao { if (isPasswordMatch(changePasswordDto.getUserId(), changePasswordDto.getOldPass())) { int count = jdbcTemplate.update(Sql.Common.UPDATE_PSWRD, new Object[] { OneWayHashing.encryptVal(changePasswordDto.getNewPass()), - DateUtil.getFormattedDateInUTC(new Date()), changePasswordDto.getUserId(), + changePasswordDto.getUserId(), OneWayHashing.encryptVal(changePasswordDto.getOldPass()) }); if (count > 0) { resposne = true; @@ -654,7 +654,7 @@ public class UserDaoImpl implements UserDao { try { String encryptVal = OneWayHashing.encryptVal(password); count = jdbcTemplate.update(Sql.Common.SAVE_FORGOT_PSWRD, - new Object[] { encryptVal, DateUtil.getFormattedDateInUTC(new Date()), userId }); + new Object[] { encryptVal, userId }); LOGGER.info("Password : {}", encryptVal); } catch (Exception e) { LOGGER.error(String.format(ENCOUNTERED_AN_EXCEPTION_S, e.getMessage())); diff --git a/src/main/java/org/upsmf/grievance/service/impl/UserServiceImpl.java b/src/main/java/org/upsmf/grievance/service/impl/UserServiceImpl.java index 32153be..08e230d 100644 --- a/src/main/java/org/upsmf/grievance/service/impl/UserServiceImpl.java +++ b/src/main/java/org/upsmf/grievance/service/impl/UserServiceImpl.java @@ -336,7 +336,7 @@ public class UserServiceImpl implements UserDetailsService, UserService { LOGGER.info(randomPassword); userDao.saveForgotPassword(userId, randomPassword); keyValue.put(JsonKey.PSWRD, randomPassword); - SendMail.sendMail(keyValue, emails, Constants.PSWORD_REGENERATED, Constants.FORGOT_PSWORD_VM_FILE); + //SendMail.sendMail(keyValue, emails, Constants.PSWORD_REGENERATED, Constants.FORGOT_PSWORD_VM_FILE); } return response; } diff --git a/src/main/java/org/upsmf/grievance/util/Sql.java b/src/main/java/org/upsmf/grievance/util/Sql.java index 134a47c..3616af2 100644 --- a/src/main/java/org/upsmf/grievance/util/Sql.java +++ b/src/main/java/org/upsmf/grievance/util/Sql.java @@ -33,9 +33,9 @@ public final class Sql { public static final String CLOSE_BRACE = ")"; public static final String CHECK_EMAIL_IN_USE = "SELECT id FROM \"user\" WHERE username=? AND is_active IS TRUE"; public static final String CHECK_OLD_PSWRD = "SELECT pwd FROM password WHERE user_id=?"; - public static final String UPDATE_PSWRD = "UPDATE password SET pwd=?,updated_date=? WHERE user_id=? and pwd=?"; + public static final String UPDATE_PSWRD = "UPDATE password SET pwd=?,updated_date=NOW()::timestamp WHERE user_id=? and pwd=?"; public static final String CHECK_USER_BY_USERNAME = "SELECT id from \"user\" where username=?"; - public static final String SAVE_FORGOT_PSWRD = "UPDATE password SET pwd=? , updated_date=? WHERE user_id= ? "; + public static final String SAVE_FORGOT_PSWRD = "UPDATE password SET pwd=? , updated_date=NOW()::timestamp WHERE user_id= ? "; public static final String GET_USER_DETAIL_BY_EMAIL = "Select id, name, username, phone, is_active as isActive, created_date as createdDate, updated_date as updatedDate, img_path as imagePath from \"user\" where username=?"; public static final String GET_ORG_ID_BY_USER_ID = "SELECT org_id FROM \"user\",user_org where \"user\".id=user_org.user_id and \"user\".id=?"; public static final String GET_ALL_USERS_BY_ORG = "Select \"user\".id, name, username, phone, is_active, img_path, created_date, updated_date from \"user\",user_org where \"user\".id=user_org.user_id \n" + @@ -82,7 +82,7 @@ public final class Sql { public static final String OPEN_BRACE = "("; public static final String CLOSE_BRACE = ")"; public static final String ADD_NEW_ORG = "INSERT INTO organization (org_name, url, logo, created_by, updated_by, description, color, domain) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; - public static final String NEW_GRIEVANCE_ADMIN_USER = "INSERT INTO user (name, username, phone, img_path) VALUES (?,?,?,?)"; + public static final String NEW_GRIEVANCE_ADMIN_USER = "INSERT INTO \"user\" (name, username, phone, img_path) VALUES (?,?,?,?)"; public static final String DELETE_ORG = "UPDATE organization SET is_active = FALSE , updated_by = ? , updated_date = ? WHERE id = ?"; public static final String GET_ADMIN_BY_ORG = "SELECT DISTINCT a.id,a.name,a.username,a.phone FROM \"user\" a,organization b,roles c, user_org d, user_role e " + "WHERE a.id = d.user_id AND a.id = e.user_id " + "AND c.id = ? AND b.id = ? AND a.is_active IS TRUE"; @@ -256,7 +256,7 @@ public final class Sql { public static final String AND_CONDITION = " AND "; public static final String OR_CONDITION = " OR "; - public static final String UPDATE_USER = "UPDATE user SET name = ?,username = ?, phone = ?, is_active = ?, img_path = ? where id = ? "; + public static final String UPDATE_USER = "UPDATE \"user\" SET name = ?,username = ?, phone = ?, is_active = ?, img_path = ? where \"user\".id = ? "; public static final String GET_USER_COUNT = "SELECT count(*) FROM \"user\" usr"; public static final String GET_USER_COUNT_ON_ACTIVE_STATUS = "SELECT count(*) FROM \"user\" usr where usr.is_active = ? "; public static final String GET_USER_COUNT_FOR_ROLE = "SELECT count(*) FROM \"user\" usr LEFT JOIN user_role ur ON usr.id = ur.user_id where ur.role_id = ? and usr.is_active IS TRUE"; @@ -266,7 +266,7 @@ public final class Sql { public static final String FETCH_AUTH_TOKEN_REF = "SELECT id FROM user_authentication WHERE auth_token = ? "; public static final String CHECK_USER_DEVICE_TOKEN = "SELECT COUNT(*) FROM user_device WHERE user_id = ? AND device_token = ? "; public static final String INSERT_PD = "insert into password(pwd, user_id) values(?,?)"; - public static final String INSERT_ACTION = "INSERT INTO action(`id`,`name`,`display_name`,`url`) VALUES(?,?,?,?);"; + public static final String INSERT_ACTION = "INSERT INTO grievance_desk.action(id,name,display_name,url) VALUES(?,?,?,?)"; public static final String UPDATE_ACTION = "UPDATE action set name=?, display_name=?, url=? where id=?"; public static final String GET_AUTH_TYPE_ID = "select aut_id from organization_auth where org_id = ?"; public static final String CHECK_FIRST_ADMIN = "SELECT org_id FROM user_org WHERE user_id=?"; @@ -286,7 +286,9 @@ public final class Sql { public static final String ADD_ADMINS_TO_HELPDESK = "insert into helpdesk_admin(helpdesk_id,user_id) values (?,?)"; public static final String ADD_USERS_TO_HELPDESK = "insert into helpdesk_users(helpdesk_id,user_id) values (?,?)"; public static final String ADD_CC_TO_TICKET = "insert into ticket_cc(ticket_id,user_id) values (?,?)"; - public static final String GET_USER_ORG_MAP = "SELECT user_org.id as id , user_id as userId , org_id as orgId FROM \"user\", \"user_org\" where \"user\".id=user_org.user_id and \"user\".is_anonymous is false;"; + + public static final String GET_USER_ORG_MAP = "SELECT user_org.id as id , user_org.user_id as userId , user_org.org_id as orgId FROM \"user\", \"user_org\" where \"user\".id=user_org.user_id and \"user\".is_anonymous is false"; + //public static final String GET_USER_ORG_MAP = "SELECT * from grievance_desk.user_org"; public static final String GET_USER_ROLE_MAP = "SELECT id as id, user_id as userId, role_id as roleId FROM user_role "; public static final String GET_APP_ID_HELPDESK_ID = "select helpdesk_id as helpdeskId,app_id as appId from helpdesk_app where is_active is true;"; public static final String GET_APP_ID_APP_OBJECT = "SELECT id,app_name as name,logo,url FROM application;"; -- GitLab