Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.wirecard.wms.bousermanagementservice.dao;
- import org.hibernate.Hibernate;
- import org.hibernate.SQLQuery;
- import org.hibernate.SessionFactory;
- import org.hibernate.type.StandardBasicTypes;
- import org.apache.commons.lang.exception.ExceptionUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Propagation;
- import org.springframework.transaction.annotation.Transactional;
- import com.wirecard.wms.utils.*;
- import java.util.List;
- import java.util.ArrayList;
- import java.util.Map;
- import java.util.HashMap;
- @Service
- public class BousermanagementserviceDaoImpl implements BousermanagementserviceDao {
- @Autowired
- private SessionFactory sessionFactory;
- @Override
- public Map baseGetUserByUserIdAndPasswordGetBackOfficeUser(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "SELECT bo_user_v_1_0.NPK NPK0, bo_user_v_1_0.USER_ID USER_ID1, bo_user_v_1_0.PHONE_NO PHONE_NO2, bo_user_v_1_0.EMAIL EMAIL3, bo_user_v_1_0.NAME NAME4, bo_user_v_1_0.FK_DIVISION FK_DIVISION5, bo_user_v_1_0.FK_BO_ROLE FK_BO_ROLE6, bo_user_v_1_0.FK_BRANCH FK_BRANCH7 FROM tbl_BASE_BO_USER_V_1_0 bo_user_v_1_0 WHERE ( bo_user_v_1_0.USER_ID = :USER_ID ) AND ( bo_user_v_1_0.PASSWORD_KEY = :PASSWORD_KEY )";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
- q.setParameter("PASSWORD_KEY", StringUtils.initObject(input.get("hashPassword")), StandardBasicTypes.STRING);
- List queryResult = q.list();
- if(queryResult.size()>0){
- Object[] arrs = (Object[])queryResult.get(0);
- Map detail = new HashMap();
- detail.put("npk", arrs[0]);
- detail.put("userId", arrs[1]);
- detail.put("phoneNo", arrs[2]);
- detail.put("email", arrs[3]);
- detail.put("name", arrs[4]);
- detail.put("division", arrs[5]);
- detail.put("role", arrs[6]);
- detail.put("branch", arrs[7]);
- return detail;
- } else {
- return new HashMap();
- }
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- public List baseGetSearchUserBOGetSearchUserBO(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "SELECT bo_user_v_1_0.USER_ID USER_ID0, bo_user_v_1_0.NAME NAME1, bo_user_v_1_0.STATUS STATUS2, channe1.NAME channe1_NAME3, tenant.NAME tenant_NAME4, divisi.NAME divisi_NAME5, branch.NAME branch_NAME6 FROM tbl_BASE_BO_USER_V_1_0 bo_user_v_1_0 INNER JOIN tbl_BASE_BO_USER_CHANNEL_TENANT_V_1_0 bo_use ON bo_user_v_1_0.USER_ID = bo_use.ID INNER JOIN tbl_BASE_CHANNEL_TENANT_V_1_0 channe ON bo_use.FK_CHANNEL_TENANT = channe.ID INNER JOIN tbl_BASE_CHANNEL_V_1_0 channe1 ON channe.FK_CHANNEL = channe1.CODE INNER JOIN tbl_BASE_TENANT_V_1_0 tenant ON tenant.CODE = channe.FK_TENANT INNER JOIN tbl_BASE_DIVISION_V_1_0 divisi ON bo_user_v_1_0.FK_DIVISION = divisi.CODE INNER JOIN tbl_BASE_BRANCH_V_1_0 branch ON bo_user_v_1_0.FK_BRANCH = branch.CODE WHERE ( bo_user_v_1_0.USER_ID ilike :USER_ID ) AND ( bo_user_v_1_0.NAME ilike :NAME ) AND ( divisi.CODE like :divisi.CODE ) AND ( branch.CODE like :branch.CODE ) AND ( bo_user_v_1_0.STATUS like :STATUS ) AND ( channe1.CODE like :channe1.CODE ) AND ( tenant.CODE like :tenant.CODE ) AND ( channe1.IS_ACTIVE = :channe1.IS_ACTIVE ) AND ( tenant.IS_ACTIVE = :tenant.IS_ACTIVE ) AND ( branch.IS_DELETE = :branch.IS_DELETE ) AND ( divisi.IS_DELETE = :divisi.IS_DELETE ) order by bo_user_v_1_0.USER_ID asc limit :paginationLimit offset :paginationOffset");
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
- q.setParameter("NAME", StringUtils.initObject(input.get("userName")), StandardBasicTypes.STRING);
- q.setParameter("divisi.CODE", StringUtils.initObject(input.get("divisionCd")), StandardBasicTypes.STRING);
- q.setParameter("branch.CODE", StringUtils.initObject(input.get("branchCd")), StandardBasicTypes.STRING);
- q.setParameter("STATUS", StringUtils.initObject(input.get("status")), StandardBasicTypes.STRING);
- q.setParameter("channe1.CODE", StringUtils.initObject("%"), StandardBasicTypes.STRING);
- q.setParameter("tenant.CODE", StringUtils.initObject("%"), StandardBasicTypes.STRING);
- q.setParameter("channe1.IS_ACTIVE", BooleanUtils.initObject("true"), StandardBasicTypes.BOOLEAN);
- q.setParameter("tenant.IS_ACTIVE", BooleanUtils.initObject("true"), StandardBasicTypes.BOOLEAN);
- q.setParameter("branch.IS_DELETE", BooleanUtils.initObject("false"), StandardBasicTypes.BOOLEAN);
- q.setParameter("divisi.IS_DELETE", BooleanUtils.initObject("false"), StandardBasicTypes.BOOLEAN);
- q.setParameter("paginationLimit",input.get("pageSize"),StandardBasicTypes.INTEGER);
- q.setParameter("paginationOffset",input.get("currentPage"),StandardBasicTypes.INTEGER);
- List queryResult = q.list();
- List result = new ArrayList();
- for(int i=0; i<queryResult.size(); i++){
- Object[] arrs = (Object[])queryResult.get(i);
- Map detail = new HashMap();
- detail.put("userId", arrs[0]);
- detail.put("userName", arrs[1]);
- detail.put("status", arrs[2]);
- detail.put("channelName", arrs[3]);
- detail.put("tenantName", arrs[4]);
- detail.put("divisionName", arrs[5]);
- detail.put("branchName", arrs[6]);
- result.add(detail);
- }
- return result;
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- public Map baseGetDetailUserBOGetUserDetail(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "SELECT bo_user_v_1_0.IS_PWD_NEVER_EXPIRE IS_PWD_NEVER_EXPIRE0, bo_user_v_1_0.NPK NPK1, bo_user_v_1_0.USER_ID USER_ID2, bo_user_v_1_0.PHONE_NO PHONE_NO3, bo_user_v_1_0.EMAIL EMAIL4, bo_user_v_1_0.NAME NAME5, bo_user_v_1_0.STATUS STATUS6, bo_user_v_1_0.FK_USER_MAIN_TENANT FK_USER_MAIN_TENANT7, branch.NAME branch_NAME8, branch.CODE branch_CODE9, divisi.CODE divisi_CODE10, divisi.NAME divisi_NAME11, bo_rol.CODE bo_rol_CODE12, bo_rol.NAME bo_rol_NAME13, tenant.NAME tenant_NAME14 FROM tbl_BASE_BO_USER_V_1_0 bo_user_v_1_0 INNER JOIN tbl_BASE_BRANCH_V_1_0 branch ON bo_user_v_1_0.FK_BRANCH = branch.CODE INNER JOIN tbl_BASE_DIVISION_V_1_0 divisi ON bo_user_v_1_0.FK_DIVISION = divisi.CODE INNER JOIN tbl_BASE_BO_ROLE_V_1_0 bo_rol ON bo_user_v_1_0.FK_BO_ROLE = bo_rol.CODE INNER JOIN tbl_BASE_TENANT_V_1_0 tenant ON bo_user_v_1_0.FK_USER_MAIN_TENANT = tenant.CODE WHERE ( bo_user_v_1_0.USER_ID = :USER_ID )";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
- List queryResult = q.list();
- if(queryResult.size()>0){
- Object[] arrs = (Object[])queryResult.get(0);
- Map detail = new HashMap();
- detail.put("isPwdNeveerExp", arrs[0]);
- detail.put("npk", arrs[1]);
- detail.put("userId", arrs[2]);
- detail.put("phoneNumber", arrs[3]);
- detail.put("email", arrs[4]);
- detail.put("userName", arrs[5]);
- detail.put("status", arrs[6]);
- detail.put("mainTenantCd", arrs[7]);
- detail.put("branchDisplay", arrs[8]);
- detail.put("branchCd", arrs[9]);
- detail.put("divisionCd", arrs[10]);
- detail.put("divisionDisplay", arrs[11]);
- detail.put("roleCd", arrs[12]);
- detail.put("roleName", arrs[13]);
- detail.put("mainTenantName", arrs[14]);
- return detail;
- } else {
- return new HashMap();
- }
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- public Map baseCheckUserExistCheckUserAlreadyExist(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "SELECT bo_user_v_1_0.USER_ID USER_ID0 FROM tbl_BASE_BO_USER_V_1_0 bo_user_v_1_0 WHERE ( bo_user_v_1_0.USER_ID = :USER_ID )";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
- List queryResult = q.list();
- if(queryResult.size()>0){
- Object arrs = (Object)queryResult.get(0);
- Map detail = new HashMap();
- detail.put("user_id", arrs);
- return detail;
- } else {
- return new HashMap();
- }
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- public List baseGetListTenantFromUserGroupGetChannelTenantList(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "SELECT bo_user_group_v_1_0.NAME NAME0, channe.ID channe_ID1, channe1.CODE channe1_CODE2, tenant.CODE tenant_CODE3 FROM tbl_BASE_BO_USER_GROUP_V_1_0 bo_user_group_v_1_0 INNER JOIN tbl_BASE_BO_UG_CHANNEL_TENANT_V_1_0 bo_ug_ ON bo_user_group_v_1_0.CODE = bo_ug_.FK_BO_USER_GROUP INNER JOIN tbl_BASE_CHANNEL_TENANT_V_1_0 channe ON channe.ID = bo_ug_.FK_CHANNEL_TENANT INNER JOIN tbl_BASE_CHANNEL_V_1_0 channe1 ON channe1.CODE = channe.FK_CHANNEL INNER JOIN tbl_BASE_TENANT_V_1_0 tenant ON tenant.CODE = channe.FK_TENANT WHERE ( bo_user_group_v_1_0.CODE in :CODE ) AND ( channe.ID in :channe.ID )";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameterList("CODE", (List) input.get("userGroupList"));
- q.setParameterList("channe.ID", (List) input.get("channelTenantList"));
- List queryResult = q.list();
- List result = new ArrayList();
- for(int i=0; i<queryResult.size(); i++){
- Object[] arrs = (Object[])queryResult.get(i);
- Map detail = new HashMap();
- detail.put("name", arrs[0]);
- detail.put("channelTenantId", arrs[1]);
- detail.put("channelCode", arrs[2]);
- detail.put("tenantCode", arrs[3]);
- result.add(detail);
- }
- return result;
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- public List baseGetUserLeaveDateListGetBOUserLeaveDateList(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "SELECT bo_use.FINISH_LEAVE_DATE bo_use_FINISH_LEAVE_DATE0, bo_use.START_LEAVE_DATE bo_use_START_LEAVE_DATE1 FROM tbl_BASE_BO_USER_V_1_0 bo_user_v_1_0 INNER JOIN tbl_BASE_BO_USER_LEAVE_V_1_0 bo_use ON bo_user_v_1_0.USER_ID = bo_use.FK_BO_USER WHERE ( bo_user_v_1_0.USER_ID = :USER_ID )";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
- List queryResult = q.list();
- List result = new ArrayList();
- for(int i=0; i<queryResult.size(); i++){
- Object[] arrs = (Object[])queryResult.get(i);
- Map detail = new HashMap();
- detail.put("finishLeaveDate", DateUtils.convertToLong(arrs[0]));
- detail.put("startLeaveDate", DateUtils.convertToLong(arrs[1]));
- result.add(detail);
- }
- return result;
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- @Transactional(propagation=Propagation.REQUIRED)
- public void baseDeleteUserBOUpdateIsDeleteUserBO(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "UPDATE tbl_BASE_BO_USER_V_1_0 SET IS_DELETE = :IS_DELETE WHERE ( USER_ID = :USER_ID )";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
- q.setParameter("IS_DELETE", BooleanUtils.initObject("true"), StandardBasicTypes.BOOLEAN);
- q.executeUpdate();
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- @Transactional(propagation=Propagation.REQUIRED)
- public void baseUpdateStatusUserBOUpdateStatusUserBO(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "UPDATE tbl_BASE_BO_USER_V_1_0 SET STATUS = :STATUS WHERE ( USER_ID = :USER_ID )";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
- q.setParameter("STATUS", StringUtils.initObject(input.get("status")), StandardBasicTypes.STRING);
- q.executeUpdate();
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- @Transactional(propagation=Propagation.REQUIRED)
- public void baseAddNewUserBOSaveNewUser(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "INSERT INTO tbl_BASE_BO_USER_V_1_0 (IS_PWD_NEVER_EXPIRE, CREATED_BY, PASSWORD_KEY, CREATED_DATE, NPK, USER_ID, PHONE_NO, EMAIL, IS_DELETE, NAME, FK_DIVISION, STATUS, FK_BO_ROLE, PASSWORD, UPDATED_BY, FK_USER_MAIN_TENANT, UPDATED_DATE, FK_BRANCH) VALUES (:IS_PWD_NEVER_EXPIRE, :CREATED_BY, :PASSWORD_KEY, :CREATED_DATE, :NPK, :USER_ID, :PHONE_NO, :EMAIL, :IS_DELETE, :NAME, :FK_DIVISION, :STATUS, :FK_BO_ROLE, :PASSWORD, :UPDATED_BY, :FK_USER_MAIN_TENANT, :UPDATED_DATE, :FK_BRANCH);";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("IS_PWD_NEVER_EXPIRE", BooleanUtils.initObject(input.get("isPassNeverExp")), StandardBasicTypes.BOOLEAN);
- q.setParameter("CREATED_BY", StringUtils.initObject(input.get("createdBy")), StandardBasicTypes.STRING);
- q.setParameter("PASSWORD_KEY", StringUtils.initObject(input.get("hashPassword")), StandardBasicTypes.STRING);
- q.setParameter("CREATED_DATE", DateUtils.initObject(input.get("createdDate")), StandardBasicTypes.TIMESTAMP);
- q.setParameter("NPK", StringUtils.initObject(input.get("npk")), StandardBasicTypes.STRING);
- q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
- q.setParameter("PHONE_NO", StringUtils.initObject(input.get("phoneNo")), StandardBasicTypes.STRING);
- q.setParameter("EMAIL", StringUtils.initObject(input.get("email")), StandardBasicTypes.STRING);
- q.setParameter("IS_DELETE", BooleanUtils.initObject("false"), StandardBasicTypes.BOOLEAN);
- q.setParameter("NAME", StringUtils.initObject(input.get("userName")), StandardBasicTypes.STRING);
- q.setParameter("FK_DIVISION", StringUtils.initObject(input.get("divisionCd")), StandardBasicTypes.STRING);
- q.setParameter("STATUS", StringUtils.initObject(input.get("status")), StandardBasicTypes.STRING);
- q.setParameter("FK_BO_ROLE", StringUtils.initObject(input.get("roleCd")), StandardBasicTypes.STRING);
- q.setParameter("PASSWORD", StringUtils.initObject(input.get("encryptPassword")), StandardBasicTypes.STRING);
- q.setParameter("UPDATED_BY", StringUtils.initObject(input.get("updatedBy")), StandardBasicTypes.STRING);
- q.setParameter("FK_USER_MAIN_TENANT", StringUtils.initObject(input.get("mainTenantId")), StandardBasicTypes.STRING);
- q.setParameter("UPDATED_DATE", DateUtils.initObject(input.get("updatedDate")), StandardBasicTypes.TIMESTAMP);
- q.setParameter("FK_BRANCH", StringUtils.initObject(input.get("branchCd")), StandardBasicTypes.STRING);
- q.executeUpdate();
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- @Transactional(propagation=Propagation.REQUIRED)
- public void baseAddNewUserBOSaveUserUG(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "INSERT INTO tbl_BASE_BO_USER_UG_V_1_0 (ID, FK_BO_USER_GROUP, FK_BO_USER) VALUES (:ID, :FK_BO_USER_GROUP, :FK_BO_USER);";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("ID", StringUtils.initObject(input.get("uuid")), StandardBasicTypes.STRING);
- q.setParameter("FK_BO_USER_GROUP", StringUtils.initObject(input.get("userGrooupCd")), StandardBasicTypes.STRING);
- q.setParameter("FK_BO_USER", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
- q.executeUpdate();
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- @Transactional(propagation=Propagation.REQUIRED)
- public void baseAddNewUserBOSaveBO(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "INSERT INTO tbl_BASE_BO_USER_CHANNEL_TENANT_V_1_0 (ID, FK_CHANNEL_TENANT, FK_BO_USER) VALUES (:ID, :FK_CHANNEL_TENANT, :FK_BO_USER);";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("ID", StringUtils.initObject(input.get("uuidChannelTenant")), StandardBasicTypes.STRING);
- q.setParameter("FK_CHANNEL_TENANT", StringUtils.initObject(input.get("channelTenantId")), StandardBasicTypes.STRING);
- q.setParameter("FK_BO_USER", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
- q.executeUpdate();
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- @Transactional(propagation=Propagation.REQUIRED)
- public void baseResetUserPasswordUpdateUserToReset(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "UPDATE tbl_BASE_BO_USER_V_1_0 SET PASSWORD_KEY = :PASSWORD_KEY, STATUS = :STATUS, PASSWORD = :PASSWORD WHERE ( USER_ID = :USER_ID )";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
- q.setParameter("PASSWORD_KEY", StringUtils.initObject(input.get("hashPassword")), StandardBasicTypes.STRING);
- q.setParameter("STATUS", StringUtils.initObject(input.get("status")), StandardBasicTypes.STRING);
- q.setParameter("PASSWORD", StringUtils.initObject(input.get("encryptPassword")), StandardBasicTypes.STRING);
- q.executeUpdate();
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- @Transactional(propagation=Propagation.REQUIRED)
- public void baseDeleteLeaveDataDeleteLeaveData(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "DELETE FROM tbl_BASE_BO_USER_LEAVE_V_1_0 WHERE ( ID = :ID )";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("ID", StringUtils.initObject(input.get("id")), StandardBasicTypes.STRING);
- q.executeUpdate();
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- public List baseGetUserChannelAndTenantAccesGetBOUserChannelTenantAccess(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "SELECT bo_user_channel_tenant_v_1_0.FK_CHANNEL_TENANT FK_CHANNEL_TENANT0, channe1.CODE channe1_CODE1, channe1.NAME channe1_NAME2, tenant.CODE tenant_CODE3, tenant.NAME tenant_NAME4 FROM tbl_BASE_BO_USER_CHANNEL_TENANT_V_1_0 bo_user_channel_tenant_v_1_0 INNER JOIN tbl_BASE_CHANNEL_TENANT_V_1_0 channe ON bo_user_channel_tenant_v_1_0.FK_CHANNEL_TENANT = channe.ID INNER JOIN tbl_BASE_CHANNEL_V_1_0 channe1 ON channe1.CODE = channe.FK_CHANNEL INNER JOIN tbl_BASE_TENANT_V_1_0 tenant ON tenant.CODE = channe.FK_TENANT WHERE ( bo_user_channel_tenant_v_1_0.FK_BO_USER = :FK_BO_USER ) order by bo_user_channel_tenant_v_1_0.FK_CHANNEL_TENANT asc";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("FK_BO_USER", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
- List queryResult = q.list();
- List result = new ArrayList();
- for(int i=0; i<queryResult.size(); i++){
- Object[] arrs = (Object[])queryResult.get(i);
- Map detail = new HashMap();
- detail.put("channelTenantId", arrs[0]);
- detail.put("channelCode", arrs[1]);
- detail.put("channelName", arrs[2]);
- detail.put("tenantCode", arrs[3]);
- detail.put("tenantName", arrs[4]);
- result.add(detail);
- }
- return result;
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- @Transactional(propagation=Propagation.REQUIRED)
- public void baseEditBOUserUpdateBOUser(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "UPDATE tbl_BASE_BO_USER_V_1_0 SET IS_PWD_NEVER_EXPIRE = :IS_PWD_NEVER_EXPIRE, NPK = :NPK, PHONE_NO = :PHONE_NO, EMAIL = :EMAIL, FK_DIVISION = :FK_DIVISION, FK_BO_ROLE = :FK_BO_ROLE, UPDATED_BY = :UPDATED_BY, FK_USER_MAIN_TENANT = :FK_USER_MAIN_TENANT, UPDATED_DATE = :UPDATED_DATE, FK_BRANCH = :FK_BRANCH WHERE ( USER_ID = :USER_ID )";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
- q.setParameter("IS_PWD_NEVER_EXPIRE", BooleanUtils.initObject(input.get("isPwdNeverExp")), StandardBasicTypes.BOOLEAN);
- q.setParameter("NPK", StringUtils.initObject(input.get("npk")), StandardBasicTypes.STRING);
- q.setParameter("PHONE_NO", StringUtils.initObject(input.get("phoneNo")), StandardBasicTypes.STRING);
- q.setParameter("EMAIL", StringUtils.initObject(input.get("email")), StandardBasicTypes.STRING);
- q.setParameter("FK_DIVISION", StringUtils.initObject(input.get("divisionCd")), StandardBasicTypes.STRING);
- q.setParameter("FK_BO_ROLE", StringUtils.initObject(input.get("roleCd")), StandardBasicTypes.STRING);
- q.setParameter("UPDATED_BY", StringUtils.initObject(input.get("updatedBy")), StandardBasicTypes.STRING);
- q.setParameter("FK_USER_MAIN_TENANT", StringUtils.initObject(input.get("mainTenantId")), StandardBasicTypes.STRING);
- q.setParameter("UPDATED_DATE", DateUtils.initObject(input.get("updatedDate")), StandardBasicTypes.TIMESTAMP);
- q.setParameter("FK_BRANCH", StringUtils.initObject(input.get("branchCd")), StandardBasicTypes.STRING);
- q.executeUpdate();
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- @Transactional(propagation=Propagation.REQUIRED)
- public void baseEditBOUserDeleteBOUserUG(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "DELETE FROM tbl_BASE_BO_USER_UG_V_1_0 WHERE ( FK_BO_USER = :FK_BO_USER )";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("FK_BO_USER", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
- q.executeUpdate();
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- @Transactional(propagation=Propagation.REQUIRED)
- public void baseEditBOUserDeleteBOUserChannelTenant(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "DELETE FROM tbl_BASE_BO_USER_CHANNEL_TENANT_V_1_0 WHERE ( FK_BO_USER = :FK_BO_USER )";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("FK_BO_USER", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
- q.executeUpdate();
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- @Transactional(propagation=Propagation.REQUIRED)
- public void baseEditBOUserSaveNewUserGroup(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "INSERT INTO tbl_BASE_BO_USER_UG_V_1_0 (ID, FK_BO_USER_GROUP, FK_BO_USER) VALUES (:ID, :FK_BO_USER_GROUP, :FK_BO_USER);";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("ID", StringUtils.initObject(input.get("uuidUserGroup")), StandardBasicTypes.STRING);
- q.setParameter("FK_BO_USER_GROUP", StringUtils.initObject(input.get("userGroupCd")), StandardBasicTypes.STRING);
- q.setParameter("FK_BO_USER", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
- q.executeUpdate();
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- @Transactional(propagation=Propagation.REQUIRED)
- public void baseEditBOUserSaveBOUserChannelTenant(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "INSERT INTO tbl_BASE_BO_USER_CHANNEL_TENANT_V_1_0 (ID, FK_CHANNEL_TENANT, FK_BO_USER) VALUES (:ID, :FK_CHANNEL_TENANT, :FK_BO_USER);";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("ID", StringUtils.initObject(input.get("uuidChannelTenant")), StandardBasicTypes.STRING);
- q.setParameter("FK_CHANNEL_TENANT", StringUtils.initObject(input.get("channelTenantId")), StandardBasicTypes.STRING);
- q.setParameter("FK_BO_USER", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
- q.executeUpdate();
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- public Map baseForceChangePasswordGetPasswordBO(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "SELECT bo_user_v_1_0.PASSWORD PASSWORD0 FROM tbl_BASE_BO_USER_V_1_0 bo_user_v_1_0 WHERE ( bo_user_v_1_0.USER_ID = :USER_ID )";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("USER_ID", StringUtils.initObject(input.get("user_id")), StandardBasicTypes.STRING);
- List queryResult = q.list();
- if(queryResult.size()>0){
- Object arrs = (Object)queryResult.get(0);
- Map detail = new HashMap();
- detail.put("passwordUser", arrs);
- return detail;
- } else {
- return new HashMap();
- }
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- @Override
- @Transactional(propagation=Propagation.SUPPORTS)
- public void baseForceChangePasswordUpdateBO(Map input) throws Exception{
- if(!ValidationUtils.getInstance().validateTimeout(input)){
- throw new Exception("Timeout violation");
- }
- try{
- String query = "UPDATE tbl_BASE_BO_USER_V_1_0 SET PASSWORD = :PASSWORD";
- SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
- q.setParameter("PASSWORD", StringUtils.initObject(input.get("userInputPassword")), StandardBasicTypes.STRING);
- q.executeUpdate();
- } catch (org.hibernate.exception.ConstraintViolationException | org.hibernate.exception.SQLGrammarException | org.hibernate.exception.LockAcquisitionException | org.hibernate.exception.DataException | org.hibernate.exception.GenericJDBCException | org.hibernate.exception.JDBCConnectionException se){
- se.printStackTrace();
- throw new Exception(se.getSQLException().getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement