AccountService.java 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package com.yihu.jw.service;/**
  2. * Created by nature of king on 2018/5/10.
  3. */
  4. import com.yihu.base.mysql.query.BaseJpaService;
  5. import com.yihu.jw.dao.AccountDao;
  6. import com.yihu.jw.entity.health.bank.AccountDO;
  7. import com.yihu.jw.restmodel.common.Envelop;
  8. import com.yihu.jw.rm.health.bank.HealthBankMapping;
  9. import com.yihu.jw.util.ISqlUtils;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.jdbc.core.BeanPropertyRowMapper;
  12. import org.springframework.jdbc.core.JdbcTemplate;
  13. import org.springframework.stereotype.Service;
  14. import javax.transaction.Transactional;
  15. import java.text.ParseException;
  16. import java.util.List;
  17. import java.util.Map;
  18. /**
  19. * @author wangzhinan
  20. * @create 2018-05-10 11:26
  21. * @desc account service
  22. **/
  23. @Service
  24. @Transactional
  25. public class AccountService extends BaseJpaService<AccountDO,AccountDao> {
  26. @Autowired
  27. private AccountDao accountDao;
  28. @Autowired
  29. private JdbcTemplate jdbcTemplate;
  30. /**
  31. * 添加银行账户信息
  32. *
  33. * @param accountDO 银行账户对象
  34. * @return
  35. */
  36. public Envelop<Boolean> insert(AccountDO accountDO){
  37. accountDao.save(accountDO);
  38. Envelop<Boolean> envelop = new Envelop<>();
  39. envelop.setObj(true);
  40. return envelop;
  41. }
  42. /**
  43. * 获取银行账户信息
  44. *
  45. * @param accountDO 银行账户对象
  46. * @param page 页码
  47. * @param size 每页大小
  48. * @return
  49. * @throws ParseException
  50. */
  51. public Envelop<AccountDO> findByCondition(AccountDO accountDO, Integer page, Integer size) throws ParseException {
  52. String sql = new ISqlUtils().getSql(accountDO,page,size,"*");
  53. List<AccountDO> accountDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
  54. String sqlcount = new ISqlUtils().getSql(accountDO,0,0,"count");
  55. List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlcount);
  56. Long count = 0L;
  57. if(rstotal!=null&&rstotal.size()>0){
  58. count = (Long) rstotal.get(0).get("total");
  59. }
  60. return Envelop.getSuccessListWithPage(HealthBankMapping.api_success,accountDOS,page,size,count);
  61. }
  62. }