CustomerServiceImpl.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package jnpf.service.impl;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.baomidou.mybatisplus.core.metadata.IPage;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import jnpf.base.Pagination;
  6. import jnpf.base.service.SuperServiceImpl;
  7. import jnpf.entity.CustomerEntity;
  8. import jnpf.mapper.CustomerMapper;
  9. import jnpf.service.CustomerService;
  10. import jnpf.util.RandomUtil;
  11. import jnpf.util.StringUtil;
  12. import jnpf.util.UserProvider;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.stereotype.Service;
  15. import java.util.Date;
  16. import java.util.List;
  17. /**
  18. * 客户信息
  19. * 版本: V3.1.0
  20. * 版权: 引迈信息技术有限公司(https://www.jnpfsoft.com)
  21. * 作者: JNPF开发平台组
  22. * 日期: 2021-07-10 14:09:05
  23. */
  24. @Service
  25. public class CustomerServiceImpl extends SuperServiceImpl<CustomerMapper, CustomerEntity> implements CustomerService {
  26. @Override
  27. public List<CustomerEntity> getList(Pagination pagination) {
  28. QueryWrapper<CustomerEntity> queryWrapper = new QueryWrapper<>();
  29. if (StringUtil.isNotEmpty(pagination.getKeyword())) {
  30. queryWrapper.lambda().and(
  31. t->t.like(CustomerEntity::getAddress, pagination.getKeyword())
  32. .or().like(CustomerEntity::getName, pagination.getKeyword())
  33. .or().like(CustomerEntity::getCode, pagination.getKeyword())
  34. );
  35. }
  36. Page<CustomerEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
  37. IPage<CustomerEntity> userIPage = this.page(page, queryWrapper);
  38. return pagination.setData(userIPage.getRecords(), userIPage.getTotal());
  39. }
  40. @Override
  41. public CustomerEntity getInfo(String id) {
  42. QueryWrapper<CustomerEntity> queryWrapper = new QueryWrapper<>();
  43. queryWrapper.lambda().eq(CustomerEntity::getId, id);
  44. return this.getOne(queryWrapper);
  45. }
  46. @Override
  47. public void create(CustomerEntity entity) {
  48. entity.setId(RandomUtil.uuId());
  49. entity.setCreatorUserId(UserProvider.getUser().getUserId());
  50. entity.setCreatorTime(new Date());
  51. this.save(entity);
  52. }
  53. @Override
  54. public boolean update(String id, CustomerEntity entity) {
  55. entity.setId(id);
  56. entity.setLastModifyUserId(UserProvider.getUser().getUserId());
  57. entity.setLastModifyTime(new Date());
  58. return this.updateById(entity);
  59. }
  60. @Override
  61. public void delete(CustomerEntity entity) {
  62. if (entity != null) {
  63. this.removeById(entity.getId());
  64. }
  65. }
  66. }