package com.liang.service.impl;

import com.liang.entity.PrjFeescheme;
import com.liang.dao.PrjFeeschemeDao;
import com.liang.service.PrjFeeschemeService;
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;

/**
 * 出资方案(PrjFeescheme)表服务实现类
 *
 * @author makejava
 * @since 2023-04-09 13:54:38
 */
@Service("prjFeeschemeService")
public class PrjFeeschemeServiceImpl implements PrjFeeschemeService {
    @Resource
    private PrjFeeschemeDao prjFeeschemeDao;
    @Resource
    private PrjUndertakecompanyService undertakecompanyService;

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

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

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

    /**
     * 修改数据
     *
     * @param prjFeescheme 实例对象
     * @return 实例对象
     */
    @Override
    public int update(PrjFeescheme prjFeescheme) {
        return this.prjFeeschemeDao.update(prjFeescheme);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        //删除出资方案承担单位
        undertakecompanyService.deleteByCzfa(id);
        return this.prjFeeschemeDao.deleteById(id) > 0;
    }

    @Override
    public int batchDelete(List<Integer> idList) {
        //删除出资方案承担单位
        undertakecompanyService.batchDeleteByCzfa(idList);
        return this.prjFeeschemeDao.batchDelete(idList);
    }

    @Override
    public List<PrjFeescheme> getFeeSchemeList(Map map) {
        return this.prjFeeschemeDao.getFeeSchemeList(map);
    }

    @Override
    public List<Integer> getYearList(Integer zb) {
        return this.prjFeeschemeDao.getYearList(zb);
    }

    @Override
    public Double getNdFeeScheme(Map map) {
        return this.prjFeeschemeDao.getNdFeeScheme(map);
    }

    @Override
    public Double getNdFeeSchemeofDKY(Map<String, String> paraMap) {

        return this.prjFeeschemeDao.getNdFeeSchemeofDKY(paraMap);
    }


}
