package com.liang.service.impl;

import com.liang.entity.PrjCompletecompany;
import com.liang.dao.PrjCompletecompanyDao;
import com.liang.service.PrjCompletecompanyService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 完成单位(PrjCompletecompany)表服务实现类
 *
 * @author makejava
 * @since 2023-03-10 11:21:40
 */
@Service("prjCompletecompanyService")
public class PrjCompletecompanyServiceImpl implements PrjCompletecompanyService {
    @Resource
    private PrjCompletecompanyDao prjCompletecompanyDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PrjCompletecompany queryById(Integer id) {
        return this.prjCompletecompanyDao.queryById(id);
    }

    @Override
    public List<PrjCompletecompany> queryByXM(Integer xm) {
        return this.prjCompletecompanyDao.queryByXM(xm);
    }

    /**
     * 分页查询
     *
     * @param prjCompletecompany 筛选条件
     * @param pageRequest        分页对象
     * @return 查询结果
     */
    @Override
    public Page<PrjCompletecompany> queryByPage(PrjCompletecompany prjCompletecompany, PageRequest pageRequest) {
        long total = this.prjCompletecompanyDao.count(prjCompletecompany);
        return new PageImpl<>(this.prjCompletecompanyDao.queryAllByLimit(prjCompletecompany, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param prjCompletecompany 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(PrjCompletecompany prjCompletecompany) {
        return this.prjCompletecompanyDao.insert(prjCompletecompany);
    }

    /**
     * 修改数据
     *
     * @param prjCompletecompany 实例对象
     * @return 实例对象
     */
    @Override
    public PrjCompletecompany update(PrjCompletecompany prjCompletecompany) {
        this.prjCompletecompanyDao.update(prjCompletecompany);
        return this.queryById(prjCompletecompany.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.prjCompletecompanyDao.deleteById(id) > 0;
    }

    @Override
    public int deleteByXm(Integer xm) {
        return this.prjCompletecompanyDao.deleteByXm(xm);
    }

    @Override
    public int insertBatch(List<PrjCompletecompany> companyList) {
        return this.prjCompletecompanyDao.insertBatch(companyList);
    }

    @Override
    public List<PrjCompletecompany> getCompanyList(Map map) {
        return this.prjCompletecompanyDao.getCompanyList(map);
    }

    @Override
    public int batchDeleteByXm(List<Integer> xmList) {
        return this.prjCompletecompanyDao.batchDeleteByXm(xmList);
    }

    @Override
    public List<PrjCompletecompany> getCompanyListFy(Integer xm) {
        return this.prjCompletecompanyDao.getCompanyListFy(xm);
    }
}
