Advertisement
Guest User

Untitled

a guest
Apr 29th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.19 KB | None | 0 0
  1. package com.wirecard.wms.bousermanagementservice.dao;
  2.  
  3. import org.hibernate.Hibernate;
  4. import org.hibernate.SQLQuery;
  5. import org.hibernate.SessionFactory;
  6. import org.hibernate.type.StandardBasicTypes;
  7.  
  8. import org.apache.commons.lang.exception.ExceptionUtils;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.stereotype.Service;
  11. import org.springframework.transaction.annotation.Propagation;
  12. import org.springframework.transaction.annotation.Transactional;
  13. import com.wirecard.wms.utils.*;
  14.  
  15. import java.util.List;
  16. import java.util.ArrayList;
  17. import java.util.Map;
  18. import java.util.HashMap;
  19.  
  20. @Service
  21. public class BousermanagementserviceDaoImpl implements BousermanagementserviceDao {
  22.  
  23. @Autowired
  24. private SessionFactory sessionFactory;
  25.  
  26.  
  27. @Override
  28.  
  29. public Map baseGetUserByUserIdAndPasswordGetBackOfficeUser(Map input) throws Exception{
  30. if(!ValidationUtils.getInstance().validateTimeout(input)){
  31. throw new Exception("Timeout violation");
  32. }
  33. try{
  34. 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 )";
  35. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  36. q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
  37. q.setParameter("PASSWORD_KEY", StringUtils.initObject(input.get("hashPassword")), StandardBasicTypes.STRING);
  38. List queryResult = q.list();
  39. if(queryResult.size()>0){
  40. Object[] arrs = (Object[])queryResult.get(0);
  41. Map detail = new HashMap();
  42. detail.put("npk", arrs[0]);
  43. detail.put("userId", arrs[1]);
  44. detail.put("phoneNo", arrs[2]);
  45. detail.put("email", arrs[3]);
  46. detail.put("name", arrs[4]);
  47. detail.put("division", arrs[5]);
  48. detail.put("role", arrs[6]);
  49. detail.put("branch", arrs[7]);
  50. return detail;
  51. } else {
  52. return new HashMap();
  53. }
  54.  
  55. } 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){
  56. se.printStackTrace();
  57. throw new Exception(se.getSQLException().getMessage());
  58. }
  59. }
  60.  
  61. @Override
  62.  
  63. public List baseGetSearchUserBOGetSearchUserBO(Map input) throws Exception{
  64. if(!ValidationUtils.getInstance().validateTimeout(input)){
  65. throw new Exception("Timeout violation");
  66. }
  67. try{
  68. 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");
  69. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  70. q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
  71. q.setParameter("NAME", StringUtils.initObject(input.get("userName")), StandardBasicTypes.STRING);
  72. q.setParameter("divisi.CODE", StringUtils.initObject(input.get("divisionCd")), StandardBasicTypes.STRING);
  73. q.setParameter("branch.CODE", StringUtils.initObject(input.get("branchCd")), StandardBasicTypes.STRING);
  74. q.setParameter("STATUS", StringUtils.initObject(input.get("status")), StandardBasicTypes.STRING);
  75. q.setParameter("channe1.CODE", StringUtils.initObject("%"), StandardBasicTypes.STRING);
  76. q.setParameter("tenant.CODE", StringUtils.initObject("%"), StandardBasicTypes.STRING);
  77. q.setParameter("channe1.IS_ACTIVE", BooleanUtils.initObject("true"), StandardBasicTypes.BOOLEAN);
  78. q.setParameter("tenant.IS_ACTIVE", BooleanUtils.initObject("true"), StandardBasicTypes.BOOLEAN);
  79. q.setParameter("branch.IS_DELETE", BooleanUtils.initObject("false"), StandardBasicTypes.BOOLEAN);
  80. q.setParameter("divisi.IS_DELETE", BooleanUtils.initObject("false"), StandardBasicTypes.BOOLEAN);
  81. q.setParameter("paginationLimit",input.get("pageSize"),StandardBasicTypes.INTEGER);
  82. q.setParameter("paginationOffset",input.get("currentPage"),StandardBasicTypes.INTEGER);
  83. List queryResult = q.list();
  84. List result = new ArrayList();
  85. for(int i=0; i<queryResult.size(); i++){
  86. Object[] arrs = (Object[])queryResult.get(i);
  87. Map detail = new HashMap();
  88. detail.put("userId", arrs[0]);
  89. detail.put("userName", arrs[1]);
  90. detail.put("status", arrs[2]);
  91. detail.put("channelName", arrs[3]);
  92. detail.put("tenantName", arrs[4]);
  93. detail.put("divisionName", arrs[5]);
  94. detail.put("branchName", arrs[6]);
  95. result.add(detail);
  96. }
  97. return result;
  98.  
  99. } 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){
  100. se.printStackTrace();
  101. throw new Exception(se.getSQLException().getMessage());
  102. }
  103. }
  104.  
  105. @Override
  106.  
  107. public Map baseGetDetailUserBOGetUserDetail(Map input) throws Exception{
  108. if(!ValidationUtils.getInstance().validateTimeout(input)){
  109. throw new Exception("Timeout violation");
  110. }
  111. try{
  112. 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 )";
  113. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  114. q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
  115. List queryResult = q.list();
  116. if(queryResult.size()>0){
  117. Object[] arrs = (Object[])queryResult.get(0);
  118. Map detail = new HashMap();
  119. detail.put("isPwdNeveerExp", arrs[0]);
  120. detail.put("npk", arrs[1]);
  121. detail.put("userId", arrs[2]);
  122. detail.put("phoneNumber", arrs[3]);
  123. detail.put("email", arrs[4]);
  124. detail.put("userName", arrs[5]);
  125. detail.put("status", arrs[6]);
  126. detail.put("mainTenantCd", arrs[7]);
  127. detail.put("branchDisplay", arrs[8]);
  128. detail.put("branchCd", arrs[9]);
  129. detail.put("divisionCd", arrs[10]);
  130. detail.put("divisionDisplay", arrs[11]);
  131. detail.put("roleCd", arrs[12]);
  132. detail.put("roleName", arrs[13]);
  133. detail.put("mainTenantName", arrs[14]);
  134. return detail;
  135. } else {
  136. return new HashMap();
  137. }
  138.  
  139. } 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){
  140. se.printStackTrace();
  141. throw new Exception(se.getSQLException().getMessage());
  142. }
  143. }
  144.  
  145. @Override
  146.  
  147. public Map baseCheckUserExistCheckUserAlreadyExist(Map input) throws Exception{
  148. if(!ValidationUtils.getInstance().validateTimeout(input)){
  149. throw new Exception("Timeout violation");
  150. }
  151. try{
  152. 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 )";
  153. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  154. q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
  155. List queryResult = q.list();
  156. if(queryResult.size()>0){
  157. Object arrs = (Object)queryResult.get(0);
  158. Map detail = new HashMap();
  159. detail.put("user_id", arrs);
  160. return detail;
  161. } else {
  162. return new HashMap();
  163. }
  164.  
  165. } 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){
  166. se.printStackTrace();
  167. throw new Exception(se.getSQLException().getMessage());
  168. }
  169. }
  170.  
  171. @Override
  172.  
  173. public List baseGetListTenantFromUserGroupGetChannelTenantList(Map input) throws Exception{
  174. if(!ValidationUtils.getInstance().validateTimeout(input)){
  175. throw new Exception("Timeout violation");
  176. }
  177. try{
  178. 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 )";
  179. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  180. q.setParameterList("CODE", (List) input.get("userGroupList"));
  181. q.setParameterList("channe.ID", (List) input.get("channelTenantList"));
  182. List queryResult = q.list();
  183. List result = new ArrayList();
  184. for(int i=0; i<queryResult.size(); i++){
  185. Object[] arrs = (Object[])queryResult.get(i);
  186. Map detail = new HashMap();
  187. detail.put("name", arrs[0]);
  188. detail.put("channelTenantId", arrs[1]);
  189. detail.put("channelCode", arrs[2]);
  190. detail.put("tenantCode", arrs[3]);
  191. result.add(detail);
  192. }
  193. return result;
  194.  
  195. } 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){
  196. se.printStackTrace();
  197. throw new Exception(se.getSQLException().getMessage());
  198. }
  199. }
  200.  
  201. @Override
  202.  
  203. public List baseGetUserLeaveDateListGetBOUserLeaveDateList(Map input) throws Exception{
  204. if(!ValidationUtils.getInstance().validateTimeout(input)){
  205. throw new Exception("Timeout violation");
  206. }
  207. try{
  208. 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 )";
  209. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  210. q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
  211. List queryResult = q.list();
  212. List result = new ArrayList();
  213. for(int i=0; i<queryResult.size(); i++){
  214. Object[] arrs = (Object[])queryResult.get(i);
  215. Map detail = new HashMap();
  216. detail.put("finishLeaveDate", DateUtils.convertToLong(arrs[0]));
  217. detail.put("startLeaveDate", DateUtils.convertToLong(arrs[1]));
  218. result.add(detail);
  219. }
  220. return result;
  221.  
  222. } 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){
  223. se.printStackTrace();
  224. throw new Exception(se.getSQLException().getMessage());
  225. }
  226. }
  227.  
  228. @Override
  229. @Transactional(propagation=Propagation.REQUIRED)
  230. public void baseDeleteUserBOUpdateIsDeleteUserBO(Map input) throws Exception{
  231. if(!ValidationUtils.getInstance().validateTimeout(input)){
  232. throw new Exception("Timeout violation");
  233. }
  234. try{
  235. String query = "UPDATE tbl_BASE_BO_USER_V_1_0 SET IS_DELETE = :IS_DELETE WHERE ( USER_ID = :USER_ID )";
  236. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  237. q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
  238. q.setParameter("IS_DELETE", BooleanUtils.initObject("true"), StandardBasicTypes.BOOLEAN);
  239. q.executeUpdate();
  240.  
  241. } 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){
  242. se.printStackTrace();
  243. throw new Exception(se.getSQLException().getMessage());
  244. }
  245. }
  246.  
  247. @Override
  248. @Transactional(propagation=Propagation.REQUIRED)
  249. public void baseUpdateStatusUserBOUpdateStatusUserBO(Map input) throws Exception{
  250. if(!ValidationUtils.getInstance().validateTimeout(input)){
  251. throw new Exception("Timeout violation");
  252. }
  253. try{
  254. String query = "UPDATE tbl_BASE_BO_USER_V_1_0 SET STATUS = :STATUS WHERE ( USER_ID = :USER_ID )";
  255. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  256. q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
  257. q.setParameter("STATUS", StringUtils.initObject(input.get("status")), StandardBasicTypes.STRING);
  258. q.executeUpdate();
  259.  
  260. } 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){
  261. se.printStackTrace();
  262. throw new Exception(se.getSQLException().getMessage());
  263. }
  264. }
  265.  
  266. @Override
  267. @Transactional(propagation=Propagation.REQUIRED)
  268. public void baseAddNewUserBOSaveNewUser(Map input) throws Exception{
  269. if(!ValidationUtils.getInstance().validateTimeout(input)){
  270. throw new Exception("Timeout violation");
  271. }
  272. try{
  273. 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);";
  274. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  275. q.setParameter("IS_PWD_NEVER_EXPIRE", BooleanUtils.initObject(input.get("isPassNeverExp")), StandardBasicTypes.BOOLEAN);
  276. q.setParameter("CREATED_BY", StringUtils.initObject(input.get("createdBy")), StandardBasicTypes.STRING);
  277. q.setParameter("PASSWORD_KEY", StringUtils.initObject(input.get("hashPassword")), StandardBasicTypes.STRING);
  278. q.setParameter("CREATED_DATE", DateUtils.initObject(input.get("createdDate")), StandardBasicTypes.TIMESTAMP);
  279. q.setParameter("NPK", StringUtils.initObject(input.get("npk")), StandardBasicTypes.STRING);
  280. q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
  281. q.setParameter("PHONE_NO", StringUtils.initObject(input.get("phoneNo")), StandardBasicTypes.STRING);
  282. q.setParameter("EMAIL", StringUtils.initObject(input.get("email")), StandardBasicTypes.STRING);
  283. q.setParameter("IS_DELETE", BooleanUtils.initObject("false"), StandardBasicTypes.BOOLEAN);
  284. q.setParameter("NAME", StringUtils.initObject(input.get("userName")), StandardBasicTypes.STRING);
  285. q.setParameter("FK_DIVISION", StringUtils.initObject(input.get("divisionCd")), StandardBasicTypes.STRING);
  286. q.setParameter("STATUS", StringUtils.initObject(input.get("status")), StandardBasicTypes.STRING);
  287. q.setParameter("FK_BO_ROLE", StringUtils.initObject(input.get("roleCd")), StandardBasicTypes.STRING);
  288. q.setParameter("PASSWORD", StringUtils.initObject(input.get("encryptPassword")), StandardBasicTypes.STRING);
  289. q.setParameter("UPDATED_BY", StringUtils.initObject(input.get("updatedBy")), StandardBasicTypes.STRING);
  290. q.setParameter("FK_USER_MAIN_TENANT", StringUtils.initObject(input.get("mainTenantId")), StandardBasicTypes.STRING);
  291. q.setParameter("UPDATED_DATE", DateUtils.initObject(input.get("updatedDate")), StandardBasicTypes.TIMESTAMP);
  292. q.setParameter("FK_BRANCH", StringUtils.initObject(input.get("branchCd")), StandardBasicTypes.STRING);
  293. q.executeUpdate();
  294.  
  295. } 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){
  296. se.printStackTrace();
  297. throw new Exception(se.getSQLException().getMessage());
  298. }
  299. }
  300.  
  301. @Override
  302. @Transactional(propagation=Propagation.REQUIRED)
  303. public void baseAddNewUserBOSaveUserUG(Map input) throws Exception{
  304. if(!ValidationUtils.getInstance().validateTimeout(input)){
  305. throw new Exception("Timeout violation");
  306. }
  307. try{
  308. 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);";
  309. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  310. q.setParameter("ID", StringUtils.initObject(input.get("uuid")), StandardBasicTypes.STRING);
  311. q.setParameter("FK_BO_USER_GROUP", StringUtils.initObject(input.get("userGrooupCd")), StandardBasicTypes.STRING);
  312. q.setParameter("FK_BO_USER", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
  313. q.executeUpdate();
  314.  
  315. } 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){
  316. se.printStackTrace();
  317. throw new Exception(se.getSQLException().getMessage());
  318. }
  319. }
  320.  
  321. @Override
  322. @Transactional(propagation=Propagation.REQUIRED)
  323. public void baseAddNewUserBOSaveBO(Map input) throws Exception{
  324. if(!ValidationUtils.getInstance().validateTimeout(input)){
  325. throw new Exception("Timeout violation");
  326. }
  327. try{
  328. 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);";
  329. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  330. q.setParameter("ID", StringUtils.initObject(input.get("uuidChannelTenant")), StandardBasicTypes.STRING);
  331. q.setParameter("FK_CHANNEL_TENANT", StringUtils.initObject(input.get("channelTenantId")), StandardBasicTypes.STRING);
  332. q.setParameter("FK_BO_USER", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
  333. q.executeUpdate();
  334.  
  335. } 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){
  336. se.printStackTrace();
  337. throw new Exception(se.getSQLException().getMessage());
  338. }
  339. }
  340.  
  341. @Override
  342. @Transactional(propagation=Propagation.REQUIRED)
  343. public void baseResetUserPasswordUpdateUserToReset(Map input) throws Exception{
  344. if(!ValidationUtils.getInstance().validateTimeout(input)){
  345. throw new Exception("Timeout violation");
  346. }
  347. try{
  348. String query = "UPDATE tbl_BASE_BO_USER_V_1_0 SET PASSWORD_KEY = :PASSWORD_KEY, STATUS = :STATUS, PASSWORD = :PASSWORD WHERE ( USER_ID = :USER_ID )";
  349. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  350. q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
  351. q.setParameter("PASSWORD_KEY", StringUtils.initObject(input.get("hashPassword")), StandardBasicTypes.STRING);
  352. q.setParameter("STATUS", StringUtils.initObject(input.get("status")), StandardBasicTypes.STRING);
  353. q.setParameter("PASSWORD", StringUtils.initObject(input.get("encryptPassword")), StandardBasicTypes.STRING);
  354. q.executeUpdate();
  355.  
  356. } 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){
  357. se.printStackTrace();
  358. throw new Exception(se.getSQLException().getMessage());
  359. }
  360. }
  361.  
  362. @Override
  363. @Transactional(propagation=Propagation.REQUIRED)
  364. public void baseDeleteLeaveDataDeleteLeaveData(Map input) throws Exception{
  365. if(!ValidationUtils.getInstance().validateTimeout(input)){
  366. throw new Exception("Timeout violation");
  367. }
  368. try{
  369. String query = "DELETE FROM tbl_BASE_BO_USER_LEAVE_V_1_0 WHERE ( ID = :ID )";
  370. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  371. q.setParameter("ID", StringUtils.initObject(input.get("id")), StandardBasicTypes.STRING);
  372. q.executeUpdate();
  373.  
  374. } 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){
  375. se.printStackTrace();
  376. throw new Exception(se.getSQLException().getMessage());
  377. }
  378. }
  379.  
  380. @Override
  381.  
  382. public List baseGetUserChannelAndTenantAccesGetBOUserChannelTenantAccess(Map input) throws Exception{
  383. if(!ValidationUtils.getInstance().validateTimeout(input)){
  384. throw new Exception("Timeout violation");
  385. }
  386. try{
  387. 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";
  388. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  389. q.setParameter("FK_BO_USER", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
  390. List queryResult = q.list();
  391. List result = new ArrayList();
  392. for(int i=0; i<queryResult.size(); i++){
  393. Object[] arrs = (Object[])queryResult.get(i);
  394. Map detail = new HashMap();
  395. detail.put("channelTenantId", arrs[0]);
  396. detail.put("channelCode", arrs[1]);
  397. detail.put("channelName", arrs[2]);
  398. detail.put("tenantCode", arrs[3]);
  399. detail.put("tenantName", arrs[4]);
  400. result.add(detail);
  401. }
  402. return result;
  403.  
  404. } 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){
  405. se.printStackTrace();
  406. throw new Exception(se.getSQLException().getMessage());
  407. }
  408. }
  409.  
  410. @Override
  411. @Transactional(propagation=Propagation.REQUIRED)
  412. public void baseEditBOUserUpdateBOUser(Map input) throws Exception{
  413. if(!ValidationUtils.getInstance().validateTimeout(input)){
  414. throw new Exception("Timeout violation");
  415. }
  416. try{
  417. 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 )";
  418. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  419. q.setParameter("USER_ID", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
  420. q.setParameter("IS_PWD_NEVER_EXPIRE", BooleanUtils.initObject(input.get("isPwdNeverExp")), StandardBasicTypes.BOOLEAN);
  421. q.setParameter("NPK", StringUtils.initObject(input.get("npk")), StandardBasicTypes.STRING);
  422. q.setParameter("PHONE_NO", StringUtils.initObject(input.get("phoneNo")), StandardBasicTypes.STRING);
  423. q.setParameter("EMAIL", StringUtils.initObject(input.get("email")), StandardBasicTypes.STRING);
  424. q.setParameter("FK_DIVISION", StringUtils.initObject(input.get("divisionCd")), StandardBasicTypes.STRING);
  425. q.setParameter("FK_BO_ROLE", StringUtils.initObject(input.get("roleCd")), StandardBasicTypes.STRING);
  426. q.setParameter("UPDATED_BY", StringUtils.initObject(input.get("updatedBy")), StandardBasicTypes.STRING);
  427. q.setParameter("FK_USER_MAIN_TENANT", StringUtils.initObject(input.get("mainTenantId")), StandardBasicTypes.STRING);
  428. q.setParameter("UPDATED_DATE", DateUtils.initObject(input.get("updatedDate")), StandardBasicTypes.TIMESTAMP);
  429. q.setParameter("FK_BRANCH", StringUtils.initObject(input.get("branchCd")), StandardBasicTypes.STRING);
  430. q.executeUpdate();
  431.  
  432. } 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){
  433. se.printStackTrace();
  434. throw new Exception(se.getSQLException().getMessage());
  435. }
  436. }
  437.  
  438. @Override
  439. @Transactional(propagation=Propagation.REQUIRED)
  440. public void baseEditBOUserDeleteBOUserUG(Map input) throws Exception{
  441. if(!ValidationUtils.getInstance().validateTimeout(input)){
  442. throw new Exception("Timeout violation");
  443. }
  444. try{
  445. String query = "DELETE FROM tbl_BASE_BO_USER_UG_V_1_0 WHERE ( FK_BO_USER = :FK_BO_USER )";
  446. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  447. q.setParameter("FK_BO_USER", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
  448. q.executeUpdate();
  449.  
  450. } 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){
  451. se.printStackTrace();
  452. throw new Exception(se.getSQLException().getMessage());
  453. }
  454. }
  455.  
  456. @Override
  457. @Transactional(propagation=Propagation.REQUIRED)
  458. public void baseEditBOUserDeleteBOUserChannelTenant(Map input) throws Exception{
  459. if(!ValidationUtils.getInstance().validateTimeout(input)){
  460. throw new Exception("Timeout violation");
  461. }
  462. try{
  463. String query = "DELETE FROM tbl_BASE_BO_USER_CHANNEL_TENANT_V_1_0 WHERE ( FK_BO_USER = :FK_BO_USER )";
  464. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  465. q.setParameter("FK_BO_USER", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
  466. q.executeUpdate();
  467.  
  468. } 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){
  469. se.printStackTrace();
  470. throw new Exception(se.getSQLException().getMessage());
  471. }
  472. }
  473.  
  474. @Override
  475. @Transactional(propagation=Propagation.REQUIRED)
  476. public void baseEditBOUserSaveNewUserGroup(Map input) throws Exception{
  477. if(!ValidationUtils.getInstance().validateTimeout(input)){
  478. throw new Exception("Timeout violation");
  479. }
  480. try{
  481. 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);";
  482. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  483. q.setParameter("ID", StringUtils.initObject(input.get("uuidUserGroup")), StandardBasicTypes.STRING);
  484. q.setParameter("FK_BO_USER_GROUP", StringUtils.initObject(input.get("userGroupCd")), StandardBasicTypes.STRING);
  485. q.setParameter("FK_BO_USER", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
  486. q.executeUpdate();
  487.  
  488. } 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){
  489. se.printStackTrace();
  490. throw new Exception(se.getSQLException().getMessage());
  491. }
  492. }
  493.  
  494. @Override
  495. @Transactional(propagation=Propagation.REQUIRED)
  496. public void baseEditBOUserSaveBOUserChannelTenant(Map input) throws Exception{
  497. if(!ValidationUtils.getInstance().validateTimeout(input)){
  498. throw new Exception("Timeout violation");
  499. }
  500. try{
  501. 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);";
  502. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  503. q.setParameter("ID", StringUtils.initObject(input.get("uuidChannelTenant")), StandardBasicTypes.STRING);
  504. q.setParameter("FK_CHANNEL_TENANT", StringUtils.initObject(input.get("channelTenantId")), StandardBasicTypes.STRING);
  505. q.setParameter("FK_BO_USER", StringUtils.initObject(input.get("userId")), StandardBasicTypes.STRING);
  506. q.executeUpdate();
  507.  
  508. } 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){
  509. se.printStackTrace();
  510. throw new Exception(se.getSQLException().getMessage());
  511. }
  512. }
  513.  
  514. @Override
  515.  
  516. public Map baseForceChangePasswordGetPasswordBO(Map input) throws Exception{
  517. if(!ValidationUtils.getInstance().validateTimeout(input)){
  518. throw new Exception("Timeout violation");
  519. }
  520. try{
  521. 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 )";
  522. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  523. q.setParameter("USER_ID", StringUtils.initObject(input.get("user_id")), StandardBasicTypes.STRING);
  524. List queryResult = q.list();
  525. if(queryResult.size()>0){
  526. Object arrs = (Object)queryResult.get(0);
  527. Map detail = new HashMap();
  528. detail.put("passwordUser", arrs);
  529. return detail;
  530. } else {
  531. return new HashMap();
  532. }
  533.  
  534. } 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){
  535. se.printStackTrace();
  536. throw new Exception(se.getSQLException().getMessage());
  537. }
  538. }
  539.  
  540. @Override
  541. @Transactional(propagation=Propagation.SUPPORTS)
  542. public void baseForceChangePasswordUpdateBO(Map input) throws Exception{
  543. if(!ValidationUtils.getInstance().validateTimeout(input)){
  544. throw new Exception("Timeout violation");
  545. }
  546. try{
  547. String query = "UPDATE tbl_BASE_BO_USER_V_1_0 SET PASSWORD = :PASSWORD";
  548. SQLQuery q = sessionFactory.getCurrentSession().createSQLQuery(query);
  549. q.setParameter("PASSWORD", StringUtils.initObject(input.get("userInputPassword")), StandardBasicTypes.STRING);
  550. q.executeUpdate();
  551.  
  552. } 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){
  553. se.printStackTrace();
  554. throw new Exception(se.getSQLException().getMessage());
  555. }
  556. }
  557.  
  558. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement