RoleServiceImpl.java
1.21 KB
package vion.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseServiceImpl;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import vion.dto.RoleDTO;
import vion.mapper.RoleMapper;
import vion.model.Role;
import vion.service.IRoleService;
import vion.vo.RoleVO;
import java.util.List;
/**
* @author vion
* @date 2023/11/28
*/
@Service
@RequiredArgsConstructor
public class RoleServiceImpl extends MPJBaseServiceImpl<RoleMapper, Role> implements IRoleService {
private final Converter converter;
@Override
public Page<RoleVO> list(RoleDTO dto) {
Page<Role> rolePage = this
.lambdaQuery(converter.convert(dto, Role.class))
.between(dto.getStartDate() != null && dto.getEndDate() != null, Role::getCreateTime, dto.getStartDate(), dto.getEndDate())
.page(Page.of(dto.getPageNum(), dto.getPageSize()));
List<RoleVO> roleVOList = converter.convert(rolePage.getRecords(), RoleVO.class);
return Page.<RoleVO>of(rolePage.getCurrent(), rolePage.getSize(), rolePage.getTotal()).setRecords(roleVOList);
}
}