CustomerServiceImpl.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package com.loan.system.service.Impl;
  2. import cn.hutool.core.bean.BeanUtil;
  3. import com.loan.system.domain.entity.Customer;
  4. import com.loan.system.domain.vo.CustomerVO;
  5. import com.loan.system.repository.CustomerRepository;
  6. import com.loan.system.service.CustomerService;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Service;
  9. import java.util.List;
  10. @Service
  11. public class CustomerServiceImpl implements CustomerService {
  12. @Autowired
  13. private CustomerRepository customerRepository;
  14. @Override
  15. public Customer addCustomer(Customer customer) {
  16. // 可以在这里添加业务逻辑,如校验等
  17. return customerRepository.save(customer);
  18. }
  19. @Override
  20. public void updateMarriedStatusById(Long customerId, String marriedStatus) {
  21. customerRepository.updateMarriedStatusById(customerId,marriedStatus);
  22. }
  23. @Override
  24. public CustomerVO findByCustomerIdAndIsDelete(Long customerId, Boolean isDelete) {
  25. return BeanUtil.copyProperties(customerRepository.findByCustomerId(customerId,isDelete),CustomerVO.class);
  26. }
  27. @Override
  28. public List<CustomerVO> getAllCustomers(boolean b) {
  29. return BeanUtil.copyToList(customerRepository.findByIsDelete(b),CustomerVO.class);
  30. }
  31. @Override
  32. public CustomerVO getCustomerByKey(String key, boolean b) {
  33. return BeanUtil.copyProperties(customerRepository.findByKey(key,b),CustomerVO.class);
  34. }
  35. @Override
  36. public CustomerVO getCustomerByMobile(String tel) {
  37. return BeanUtil.copyProperties(customerRepository.findByMobile(tel, false),CustomerVO.class);
  38. }
  39. @Override
  40. public boolean existsBymobileAndIsDelete(String phoneNumber){
  41. return customerRepository.existsByMobileAndIsDelete(phoneNumber,false);
  42. }
  43. @Override
  44. public Customer findBymobileAndIsDelete(String phoneNumber){
  45. return customerRepository.findByMobile(phoneNumber,false);
  46. }
  47. @Override
  48. public Customer findByIdAndIsDelete(Long id){
  49. return customerRepository.findByIdAndIsDelete(id,false);
  50. }
  51. }