package top.continew.admin.business.service.Impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import top.continew.admin.business.mapper.TgUserMapper;
import top.continew.admin.business.model.entity.TgUser;
import top.continew.admin.business.model.req.TgUserReq;
import top.continew.admin.business.service.ITgUserService;
import top.continew.starter.extension.crud.model.resp.PageResp;

import java.util.List;

/**
 * <p>
 * tg用户 服务实现类
 * </p>
 *
 * @author xudm
 * @since 2024-12-14
 */
@Service
public class TgUserServiceImpl extends ServiceImpl<TgUserMapper, TgUser> implements ITgUserService {
    @Override
    public PageResp<TgUser> pageQuery(TgUserReq queryVo) {
        Page<TgUser> page = new Page<>();
        page.setCurrent(queryVo.getPage() != 0 ? queryVo.getPage() : 1);
        page.setSize(queryVo.getSize() != 0 ? queryVo.getSize() : 10);

        List<TgUser> tgUserOfPage = getBaseMapper().getTgUserOfPage(queryVo, page);
        page.setRecords(tgUserOfPage);
        return PageResp.build(page, TgUser.class);
    }
}
