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