package com.mortals.xhx.module.window.dao.ibatis;


import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.ParamDto;
import com.mortals.framework.model.Result;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.window.dao.WindowWorkmanPerformDetailDao;
import com.mortals.xhx.module.window.model.WindowWorkmanPerformDetailEntity;

import java.util.ArrayList;
import java.util.Date;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import java.util.List;
/**
* 窗口人员考核汇总明细DaoImpl DAO接口
*
* @author zxfei
* @date 2024-01-17
*/
@Repository("windowWorkmanPerformDetailDao")
public class WindowWorkmanPerformDetailDaoImpl extends BaseCRUDDaoMybatis<WindowWorkmanPerformDetailEntity,Long> implements WindowWorkmanPerformDetailDao {

    @Override
    public Result<WindowWorkmanPerformDetailEntity> getListExt(WindowWorkmanPerformDetailEntity params, PageInfo pageInfo) {
        ParamDto paramDto = this.getQueryParam(params);
        Result result = new Result();
        List<WindowWorkmanPerformDetailEntity> list = null;
        if (pageInfo.isCountPage()) {
            int count = this.getCountExt(paramDto);
            if (count == 0) {
                list = new ArrayList();
            } else if (pageInfo.getPrePageResult() == -1) {
                list = this.getSqlSession().selectList(this.getSqlId("getListExt"), paramDto);
            } else {
                RowBounds rowBounds = new RowBounds(pageInfo.getBeginIndex(), pageInfo.getPrePageResult());
                list = this.getSqlSession().selectList(this.getSqlId("getListExt"), this.cpyQueryParamDto(paramDto), rowBounds);
            }

            pageInfo.setTotalResult(count);
            result.setPageInfo(pageInfo);
            result.setList((List)list);
        } else {
            if (pageInfo.getPrePageResult() == -1) {
                list = this.getSqlSession().selectList(this.getSqlId("getListExt"), paramDto);
            } else {
                RowBounds rowBounds = new RowBounds(pageInfo.getBeginIndex(), pageInfo.getPrePageResult());
                list = this.getSqlSession().selectList(this.getSqlId("getListExt"), this.cpyQueryParamDto(paramDto), rowBounds);
            }

            pageInfo.setTotalResult(-1);
            result.setPageInfo(pageInfo);
            result.setList(list);
        }

        return result;
    }

    private int getCountExt(ParamDto paramDto) {
        return (Integer)this.getSqlSession().selectOne(this.getSqlId("getListCountExt"), this.cpyQueryParamDto(paramDto));
    }

}
