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

import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.dao.entity.unified.UnifiedWarning;
import cn.superdesk.uniorder.dao.mapper.unified.UnifiedWarningMapper;
import cn.superdesk.uniorder.dao.mapper.unified.UnifiedWarningMapperEx;
import cn.superdesk.uniorder.dto.vo.unified.UnifiedWarningVo;
import cn.superdesk.uniorder.dto.vo.unified.WarningOrderAmountVo;
import cn.superdesk.uniorder.dto.vo.unified.WarningOrderInvoiceVo;
import cn.superdesk.uniorder.service.unified.UnifiedWarningService;
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 UnifiedWarningServiceImpl implements UnifiedWarningService {

    @Autowired
    private UnifiedWarningMapper   unifiedWarningMapper;
    @Autowired
    private UnifiedWarningMapperEx unifiedWarningMapperEx;


    @Override
    public int insertSelective(UnifiedWarning t) {

        return unifiedWarningMapper.insertSelective(t);
    }

    @Override
    public int updateByPrimaryKeySelective(UnifiedWarning t) {

        return unifiedWarningMapper.updateByPrimaryKeySelective(t);
    }

    @Override
    public void deleteObj(Long id) {

        unifiedWarningMapper.deleteByPrimaryKey(id);
    }

    @Override
    public UnifiedWarning findById(Long id) {

        return unifiedWarningMapper.selectByPrimaryKey(id);
    }


    @Override
    public List<UnifiedWarning> findAll(Map<String, Object> queryMap) {

        return null;
    }

    @Override
    public PageInfo<UnifiedWarning> findByPaging(Map<String, Object> params, Integer pageNo, Integer pageSize) {

        return null;
    }

    @Override
    public R<List<UnifiedWarningVo>> getDataByPage(Map<String, Object> params, int pageNo, int pageSize) {

        PageHelper.startPage(pageNo, pageSize);
        List<UnifiedWarningVo>     unifiedWarningVoList = unifiedWarningMapperEx.getData(params);
        PageInfo<UnifiedWarningVo> page                 = new PageInfo<UnifiedWarningVo>(unifiedWarningVoList);
        PageHelper.clearPage();
        return new R<List<UnifiedWarningVo>>(page.getPageNum(), page.getPageSize(), (int) page.getTotal(), unifiedWarningVoList);

    }

    @Override
    public List<WarningOrderAmountVo> getWarningOrderAmount(Map<String, Object> queryMap) {

        return unifiedWarningMapperEx.getWarningOrderAmount(queryMap);
    }

    @Override
    public List<WarningOrderInvoiceVo> getWarningOrderInv(Map<String, Object> queryMap) {

        return unifiedWarningMapperEx.getWarningOrderInv(queryMap);
    }

}
