package cn.superdesk.uniorder.service.unified.impl;

import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.dao.entity.unified.UnifiedDrowMoney;
import cn.superdesk.uniorder.dao.mapper.unified.UnifiedDrowMoneyMapper;
import cn.superdesk.uniorder.dto.vo.unified.UnifiedDrowMoneyPage;
import cn.superdesk.uniorder.service.unified.UnifiedDrowMoneyService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class UnifiedDrowMoneyServiceImpl implements UnifiedDrowMoneyService {

    @Autowired
    private UnifiedDrowMoneyMapper unifiedDrowMoneyMapper;


    @Override
    public int insertSelective(UnifiedDrowMoney unifiedDrowMoney) {
        return unifiedDrowMoneyMapper.insertSelective(unifiedDrowMoney);
    }

    @Override
    public int updateByPrimaryKeySelective(UnifiedDrowMoney unifiedDrowMoney) {
        return unifiedDrowMoneyMapper.updateByPrimaryKeySelective(unifiedDrowMoney);
    }

    @Override
    public void deleteObj(Long id) {
        unifiedDrowMoneyMapper.deleteByPrimaryKey(id);
    }


    @Override
    public UnifiedDrowMoney findById(Long id) {
        return unifiedDrowMoneyMapper.selectByPrimaryKey(id);
    }


    @Override
    public List<UnifiedDrowMoney> findAll(Map<String, Object> queryMap) {
        return unifiedDrowMoneyMapper.findAll(queryMap);
    }

    @Override
    public PageInfo<UnifiedDrowMoney> findByPaging(Map<String, Object> params, Integer pageNo, Integer pageSize) {
        return null;
    }

    @Override
    public R<List<UnifiedDrowMoneyPage>> getPageProfit(Map<String, Object> params, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);

        List<UnifiedDrowMoneyPage> ls = unifiedDrowMoneyMapper.getPageData(params);

        PageInfo<UnifiedDrowMoneyPage> page = new PageInfo<UnifiedDrowMoneyPage>(ls);
        PageHelper.clearPage();
        return new R<List<UnifiedDrowMoneyPage>>(page.getPageNum(), page.getPageSize(), (int) page.getTotal(), ls);
    }
}
