CustomerInfoBasicService.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package com.ygj.yuemum.service.customer;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.github.pagehelper.PageHelper;
  4. import com.ygj.yuemum.dao.customer.CustomerInfoBasicDao;
  5. import com.ygj.yuemum.domain.admin.JlAdminUser;
  6. import com.ygj.yuemum.domain.customer.CustomerInfoBasic;
  7. import com.ygj.yuemum.domain.customer.CustomerInfoServiceLog;
  8. import com.ygj.yuemum.domain.customer.dto.CustomerInfoBasicCyDto;
  9. import com.ygj.yuemum.domain.customer.dto.CustomerInfoBasicDto;
  10. import com.ygj.yuemum.service.admin.JlAdminUserService;
  11. import org.apache.shiro.SecurityUtils;
  12. import org.springframework.stereotype.Service;
  13. import javax.annotation.Resource;
  14. import java.util.Date;
  15. import java.util.HashMap;
  16. import java.util.List;
  17. import java.util.Map;
  18. /**
  19. * customer_info_basic
  20. * @author zrz
  21. * @date 2020/06/17
  22. */
  23. @Service
  24. public class CustomerInfoBasicService {
  25. @Resource
  26. private CustomerInfoBasicDao customerInfoBasicDao;
  27. @Resource
  28. CustomerInfoServiceLogService customerInfoServiceLogService;
  29. @Resource
  30. JlAdminUserService jladminuserService;
  31. public int insert(CustomerInfoBasic customerInfoBasic) {
  32. int count = customerInfoBasicDao.insert(customerInfoBasic);
  33. if (count != 0) {
  34. this.insertServiceLog(customerInfoBasic.getId(), "新增", customerInfoBasic);
  35. return count;
  36. }
  37. return 0;
  38. }
  39. public int delete(int id) {
  40. int ret = customerInfoBasicDao.delete(id);
  41. return ret;
  42. }
  43. public int update(CustomerInfoBasic customerInfoBasic) {
  44. this.insertServiceLog(customerInfoBasic.getId(), "修改", customerInfoBasic);
  45. int ret = customerInfoBasicDao.update(customerInfoBasic);
  46. return ret;
  47. }
  48. public CustomerInfoBasic load(int id) {
  49. return customerInfoBasicDao.load(id);
  50. }
  51. public Map<String,Object> pageList(int offset, int pagesize) {
  52. List<CustomerInfoBasic> pageList = customerInfoBasicDao.pageList(offset, pagesize);
  53. int totalCount = customerInfoBasicDao.pageListCount(offset, pagesize);
  54. // result
  55. Map<String, Object> result = new HashMap<String, Object>();
  56. result.put("pageList", pageList);
  57. result.put("totalCount", totalCount);
  58. return result;
  59. }
  60. public List<CustomerInfoBasic> selectByPageNumSize(CustomerInfoBasicDto customerInfoBasic) {
  61. PageHelper.startPage(customerInfoBasic.getPage(), customerInfoBasic.getLimit(), true, false);
  62. return customerInfoBasicDao.selectByPageNumSize(customerInfoBasic);
  63. }
  64. public void insertInfoBasicList(List<CustomerInfoBasicCyDto> list) {
  65. customerInfoBasicDao.insertInfoBasicList(list);
  66. }
  67. private void insertServiceLog(Integer sl_no, String type, CustomerInfoBasic customerInfoBasic) {
  68. String principal = (String) SecurityUtils.getSubject().getPrincipal();
  69. JlAdminUser jlAdminUser = jladminuserService.getUserMkt(principal);
  70. CustomerInfoServiceLog customerInfoServiceLog = new CustomerInfoServiceLog();
  71. customerInfoServiceLog.setSl_userid(jlAdminUser.getId());
  72. customerInfoServiceLog.setSl_username(jlAdminUser.getName());
  73. customerInfoServiceLog.setSl_createdate(new Date());
  74. customerInfoServiceLog.setSl_no(sl_no);
  75. customerInfoServiceLog.setSl_table("customer_info_basic");
  76. customerInfoServiceLog.setSl_type(type);
  77. customerInfoServiceLog.setSl_comment(JSONObject.toJSONString(customerInfoBasic));
  78. customerInfoServiceLogService.insert(customerInfoServiceLog);
  79. }
  80. }