AccountDetailServiceDaoImpl.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. package com.java110.acct.dao.impl;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.java110.acct.dao.IAccountDetailServiceDao;
  4. import com.java110.core.base.dao.BaseServiceDao;
  5. import com.java110.utils.constant.ResponseConstant;
  6. import com.java110.utils.exception.DAOException;
  7. import com.java110.utils.util.DateUtil;
  8. import org.slf4j.Logger;
  9. import org.slf4j.LoggerFactory;
  10. import org.springframework.stereotype.Service;
  11. import java.util.List;
  12. import java.util.Map;
  13. /**
  14. * 账户交易服务 与数据库交互
  15. * Created by wuxw on 2017/4/5.
  16. */
  17. @Service("accountDetailServiceDaoImpl")
  18. //@Transactional
  19. public class AccountDetailServiceDaoImpl extends BaseServiceDao implements IAccountDetailServiceDao {
  20. private static Logger logger = LoggerFactory.getLogger(AccountDetailServiceDaoImpl.class);
  21. /**
  22. * 账户交易信息封装
  23. *
  24. * @param businessAccountDetailInfo 账户交易信息 封装
  25. * @throws DAOException DAO异常
  26. */
  27. @Override
  28. public void saveBusinessAccountDetailInfo(Map businessAccountDetailInfo) throws DAOException {
  29. businessAccountDetailInfo.put("month", DateUtil.getCurrentMonth());
  30. // 查询business_user 数据是否已经存在
  31. logger.debug("保存账户交易信息 入参 businessAccountDetailInfo : {}", businessAccountDetailInfo);
  32. int saveFlag = sqlSessionTemplate.insert("accountDetailServiceDaoImpl.saveBusinessAccountDetailInfo", businessAccountDetailInfo);
  33. if (saveFlag < 1) {
  34. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存账户交易数据失败:" + JSONObject.toJSONString(businessAccountDetailInfo));
  35. }
  36. }
  37. /**
  38. * 查询账户交易信息
  39. *
  40. * @param info bId 信息
  41. * @return 账户交易信息
  42. * @throws DAOException DAO异常
  43. */
  44. @Override
  45. public List<Map> getBusinessAccountDetailInfo(Map info) throws DAOException {
  46. logger.debug("查询账户交易信息 入参 info : {}", info);
  47. List<Map> businessAccountDetailInfos = sqlSessionTemplate.selectList("accountDetailServiceDaoImpl.getBusinessAccountDetailInfo", info);
  48. return businessAccountDetailInfos;
  49. }
  50. /**
  51. * 保存账户交易信息 到 instance
  52. *
  53. * @param info bId 信息
  54. * @throws DAOException DAO异常
  55. */
  56. @Override
  57. public void saveAccountDetailInfoInstance(Map info) throws DAOException {
  58. logger.debug("保存账户交易信息Instance 入参 info : {}", info);
  59. int saveFlag = sqlSessionTemplate.insert("accountDetailServiceDaoImpl.saveAccountDetailInfoInstance", info);
  60. if (saveFlag < 1) {
  61. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存账户交易信息Instance数据失败:" + JSONObject.toJSONString(info));
  62. }
  63. }
  64. /**
  65. * 查询账户交易信息(instance)
  66. *
  67. * @param info bId 信息
  68. * @return List<Map>
  69. * @throws DAOException DAO异常
  70. */
  71. @Override
  72. public List<Map> getAccountDetailInfo(Map info) throws DAOException {
  73. logger.debug("查询账户交易信息 入参 info : {}", info);
  74. List<Map> businessAccountDetailInfos = sqlSessionTemplate.selectList("accountDetailServiceDaoImpl.getAccountDetailInfo", info);
  75. return businessAccountDetailInfos;
  76. }
  77. /**
  78. * 修改账户交易信息
  79. *
  80. * @param info 修改信息
  81. * @throws DAOException DAO异常
  82. */
  83. @Override
  84. public void updateAccountDetailInfoInstance(Map info) throws DAOException {
  85. logger.debug("修改账户交易信息Instance 入参 info : {}", info);
  86. int saveFlag = sqlSessionTemplate.update("accountDetailServiceDaoImpl.updateAccountDetailInfoInstance", info);
  87. if (saveFlag < 1) {
  88. throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "修改账户交易信息Instance数据失败:" + JSONObject.toJSONString(info));
  89. }
  90. }
  91. /**
  92. * 查询账户交易数量
  93. *
  94. * @param info 账户交易信息
  95. * @return 账户交易数量
  96. */
  97. @Override
  98. public int queryAccountDetailsCount(Map info) {
  99. logger.debug("查询账户交易数据 入参 info : {}", info);
  100. List<Map> businessAccountDetailInfos = sqlSessionTemplate.selectList("accountDetailServiceDaoImpl.queryAccountDetailsCount", info);
  101. if (businessAccountDetailInfos.size() < 1) {
  102. return 0;
  103. }
  104. return Integer.parseInt(businessAccountDetailInfos.get(0).get("count").toString());
  105. }
  106. @Override
  107. public int saveAccountDetails(Map info) {
  108. int saveFlag = sqlSessionTemplate.update("accountDetailServiceDaoImpl.saveAccountDetails", info);
  109. return saveFlag;
  110. }
  111. }