package com.liang.service.impl;

import com.liang.entity.PrjUndertakecompany;
import com.liang.dao.PrjUndertakecompanyDao;
import com.liang.service.PrjUndertakecompanyService;
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;

/**
 * (PrjUndertakecompany)表服务实现类
 *
 * @author makejava
 * @since 2023-04-09 12:13:18
 */
@Service("prjUndertakecompanyService")
public class PrjUndertakecompanyServiceImpl implements PrjUndertakecompanyService {
    @Resource
    private PrjUndertakecompanyDao prjUndertakecompanyDao;

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

    @Override
    public int deleteByCzfa(Integer czfa) {
        return this.prjUndertakecompanyDao.deleteByCzfa(czfa);
    }

    @Override
    public int batchDeleteByCzfa(List<Integer> czfaList) {
        return this.prjUndertakecompanyDao.batchDeleteByCzfa(czfaList);
    }

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

    /**
     * 新增数据
     *
     * @param prjUndertakecompany 实例对象
     * @return 实例对象
     */
    @Override
    public PrjUndertakecompany insert(PrjUndertakecompany prjUndertakecompany) {
        this.prjUndertakecompanyDao.insert(prjUndertakecompany);
        return prjUndertakecompany;
    }

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

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

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

    @Override
    public List<PrjUndertakecompany> getUtCompanyList(Integer czfa) {
        return this.prjUndertakecompanyDao.getUtCompanyList(czfa);
    }

    @Override
    public List<PrjUndertakecompany> getXmUtCompanyList(Map map) {
        return this.prjUndertakecompanyDao.getXmUtCompanyList(map);
    }
}
