package cn.com.countrygarden.bi.main.service.wcx.impl;

import cn.com.countrygarden.bi.main.dao.wcx.WcxFeedbackMapper;
import cn.com.countrygarden.bi.main.dao.wcx.WcxReviewMapper;
import cn.com.countrygarden.bi.main.dto.wcx.WcxFeedbackDto;
import cn.com.countrygarden.bi.main.dto.wcx.WcxInnovationDto;
import cn.com.countrygarden.bi.main.model.PageData;
import cn.com.countrygarden.bi.main.service.wcx.WcxFeedbackService;
import cn.com.countrygarden.bi.main.util.PageUtil;
import com.github.pagehelper.PageRowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WcxFeedbackServiceImp implements WcxFeedbackService {
    @Autowired
    private WcxFeedbackMapper wcxFeedbackMapper;

    @Override
    public PageData selectPageList(WcxFeedbackDto dto) {
        int pageOffset = PageUtil.getPageOffset(dto.getPageIndex(), dto.getPageSize());
        dto.setPageOffset(pageOffset);

        List<WcxFeedbackDto> data = wcxFeedbackMapper.selectPageData(dto);
        Long total = wcxFeedbackMapper.selectPageCount(dto);

        PageRowBounds pageRowBounds = new PageRowBounds(dto.getPageIndex(), dto.getPageSize());
        pageRowBounds.setTotal(total);
        pageRowBounds.setCount(true);

        PageData pageData = new PageData(data, pageRowBounds);
        return pageData;
    }
}
