package com.liang.service.impl;

import com.liang.dao.StaIntellectualPropertyDao;
import com.liang.entity.StaIntellectualProperty;
import com.liang.service.StaIntellectualPropertyService;
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;

/**
 * 知识产权费(StaIntellectualProperty)表服务实现类
 */
@Service("staIntellectualPropertyService")
public class StaIntellectualPropertyServiceImpl implements StaIntellectualPropertyService {
    @Resource
    private StaIntellectualPropertyDao staIntellectualPropertyDao;

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

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

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

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

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

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

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

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

    @Override
    public List<StaIntellectualProperty> getZscqfList(Integer zb) {
        return this.staIntellectualPropertyDao.getZscqfList(zb);
    }

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

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