package com.liang.service.impl;

import com.liang.dao.StaExpertFeeDao;
import com.liang.entity.StaExpertFee;
import com.liang.entity.StaExpertFee;
import com.liang.service.StaExpertFeeService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

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

/**
 * 专家咨询费(StaExpertFee)表服务实现类
 */
@Service("staExpertFeeService")
public class StaExpertFeeServiceImpl implements StaExpertFeeService {
    @Resource
    private StaExpertFeeDao staExpertFeeDao;

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

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

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

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

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

    @Override
    public int deleteByZb(Integer zb) {
        return this.staExpertFeeDao.deleteByZb(zb);
    }

    @Override
    public int batchDeleteByZb(List<Integer> zbList) {
        return this.staExpertFeeDao.batchDeleteByZb(zbList);
    }

    @Override
    public int insertBatch(List<StaExpertFee> expenseList) {
        return this.staExpertFeeDao.insertBatch(expenseList);
    }

    @Override
    public List<StaExpertFee> getZjfList(Integer zb) {
        return this.staExpertFeeDao.getZjfList(zb);
    }

    @Override
    public List<StaExpertFee> queryByKyfh(String kyfh) {
        return this.staExpertFeeDao.queryByKyfh(kyfh);
    }

    @Override
    public List<HashMap<String, Object>> searchTemeMemberCost(Map map) {
        return this.staExpertFeeDao.searchExpertFeeCost(map);
    }

}
