package com.gxwebsoft.apps.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.apps.mapper.BcExportMapper;
import com.gxwebsoft.apps.service.BcExportService;
import com.gxwebsoft.apps.entity.BcExport;
import com.gxwebsoft.apps.param.BcExportParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 报餐统计导出Service实现
 *
 * @author 科技小王子
 * @since 2023-06-01 21:47:02
 */
@Service
public class BcExportServiceImpl extends ServiceImpl<BcExportMapper, BcExport> implements BcExportService {

    @Override
    public PageResult<BcExport> pageRel(BcExportParam param) {
        PageParam<BcExport, BcExportParam> page = new PageParam<>(param);
        //page.setDefaultOrder("create_time desc");
        List<BcExport> list = baseMapper.selectPageRel(page, param);
        return new PageResult<>(list, page.getTotal());
    }

    @Override
    public List<BcExport> listRel(BcExportParam param) {
        List<BcExport> list = baseMapper.selectListRel(param);
        // 排序
        PageParam<BcExport, BcExportParam> page = new PageParam<>();
        //page.setDefaultOrder("create_time desc");
        return page.sortRecords(list);
    }

    @Override
    public BcExport getByIdRel(Integer exportId) {
        BcExportParam param = new BcExportParam();
        param.setExportId(exportId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
