package me.zhengjie.serviceimpl;

import lombok.RequiredArgsConstructor;
import me.zhengjie.MybatisMapper.XxsysqlbMybatisMapper;
import me.zhengjie.domain.XxgxsqsqDeploy;
import me.zhengjie.domain.XxsysqlbDeploy;
import me.zhengjie.mapper.XxgxsqsqMapper;
import me.zhengjie.mapper.XxsysqlbMapper;
import me.zhengjie.repository.XxgxsqsqDeployRepository;
import me.zhengjie.repository.XxsysqlbDeployRepository;
import me.zhengjie.service.XxgxsqsqService;
import me.zhengjie.service.XxsysqlbService;
import me.zhengjie.service.dto.XxgxsqsqDeployQueryCriteria;
import me.zhengjie.service.dto.XxsysqlbDeployQueryCriteria;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author Jing Xiduo
 * @date 2021-10-18
 */
@Service
@RequiredArgsConstructor
public class XxsysqlbServiceImpl implements XxsysqlbService {

    private final XxsysqlbDeployRepository xxsysqlbDeployRepository;
    private final XxsysqlbMapper xxsysqlbMapper;
    private final XxsysqlbMybatisMapper xxsysqlbMybatisMapper;
    @Override
    public Object queryAll(XxsysqlbDeployQueryCriteria criteria, Pageable pageable){
        Page<XxsysqlbDeploy> page = xxsysqlbDeployRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
        return PageUtil.toPage(page.map(xxsysqlbMapper::toDto));
    }

    @Override
    public List<Map> QueryXxsysqlbFhmx(String id) {
        return xxsysqlbMybatisMapper.QueryXxsysqlbFhmx(id);
    }

}
