PrintLogServiceImpl.java 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package jnpf.base.service.impl;
  2. import cn.hutool.core.util.ObjectUtil;
  3. import com.baomidou.mybatisplus.core.metadata.IPage;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.github.yulichang.wrapper.MPJLambdaWrapper;
  6. import jnpf.base.PaginationTime;
  7. import jnpf.base.entity.PrintLogEntity;
  8. import jnpf.base.mapper.PrintLogMapper;
  9. import jnpf.base.model.vo.PrintLogVO;
  10. import jnpf.base.service.PrintLogService;
  11. import jnpf.base.service.SuperServiceImpl;
  12. import jnpf.permission.entity.UserEntity;
  13. import org.springframework.stereotype.Service;
  14. import java.util.Date;
  15. import java.util.List;
  16. @Service
  17. public class PrintLogServiceImpl extends SuperServiceImpl<PrintLogMapper, PrintLogEntity> implements PrintLogService {
  18. @Override
  19. public List<PrintLogVO> list(String printId, PaginationTime paginationTime) {
  20. MPJLambdaWrapper<PrintLogEntity> wrapper = new MPJLambdaWrapper<>(PrintLogEntity.class)
  21. .leftJoin(UserEntity.class, UserEntity::getId, PrintLogEntity::getCreatorUserId)
  22. .selectAll(PrintLogEntity.class)
  23. .select(UserEntity::getAccount, UserEntity::getRealName)
  24. .selectAs(PrintLogEntity::getCreatorTime, PrintLogVO::getCreatorTime);
  25. if (!ObjectUtil.isEmpty(paginationTime.getStartTime()) && !ObjectUtil.isEmpty(paginationTime.getEndTime())) {
  26. wrapper.between(PrintLogEntity::getCreatorTime, new Date(paginationTime.getStartTime()), new Date(paginationTime.getEndTime()));
  27. }
  28. if (!ObjectUtil.isEmpty(printId)) {
  29. wrapper.eq(PrintLogEntity::getPrintId, printId);
  30. }
  31. if (!ObjectUtil.isEmpty(paginationTime.getKeyword())) {
  32. wrapper.and(
  33. t -> t.like(UserEntity::getRealName, paginationTime.getKeyword())
  34. .or().like(UserEntity::getAccount, paginationTime.getKeyword())
  35. .or().like(PrintLogEntity::getPrintTitle, paginationTime.getKeyword())
  36. );
  37. }
  38. Page<PrintLogVO> page = new Page<>(paginationTime.getCurrentPage(), paginationTime.getPageSize());
  39. IPage<PrintLogVO> userPage = this.selectJoinListPage(page, PrintLogVO.class, wrapper);
  40. List<PrintLogVO> printLogModels = paginationTime.setData(userPage.getRecords(), page.getTotal());
  41. return printLogModels;
  42. }
  43. }