package me.zhengjie.serviceimpl;

import lombok.RequiredArgsConstructor;
import me.zhengjie.MybatisMapper.DkzlcxMybatisMapper;
import me.zhengjie.MybatisMapper.GrdkjqjyMybatisMapper;
import me.zhengjie.domain.GrdkjqjyDeploy;
import me.zhengjie.mapper.GrdkjqjyMapper;
import me.zhengjie.repository.GrdkjqjyDeployRepository;
import me.zhengjie.service.GrdkjqjyService;
import me.zhengjie.service.dto.GrdkjqjyDeployQueryCriteria;
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 GrdkjqjyServiceImpl implements GrdkjqjyService {

    private final GrdkjqjyDeployRepository grdkjqjyDeployRepository;
    private final GrdkjqjyMapper grdkjqjyMapper;
    private final GrdkjqjyMybatisMapper grdkjqjyMybatisMapper;

    @Override
    public Object queryAll(GrdkjqjyDeployQueryCriteria criteria, Pageable pageable){
        Page<GrdkjqjyDeploy> page = grdkjqjyDeployRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
        return PageUtil.toPage(page.map(grdkjqjyMapper::toDto));
    }

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

}
