RoleServiceImpl.java
1.21 KB
package vion.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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 HlQ
* @date 2023/11/28
*/
@Service
@RequiredArgsConstructor
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {
private final Converter converter;
@Override
public Page<RoleVO> list(RoleDTO dto) {
Page<Role> rolePage = this
.lambdaQuery(converter.convert(dto, new Role()))
.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);
}
}