package com.gxwebsoft.apps.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.apps.mapper.CashierMapper;
import com.gxwebsoft.apps.service.CashierService;
import com.gxwebsoft.apps.entity.Cashier;
import com.gxwebsoft.apps.param.CashierParam;
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 WebSoft
 * @since 2022-11-18 11:47:09
 */
@Service
public class CashierServiceImpl extends ServiceImpl<CashierMapper, Cashier> implements CashierService {

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

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

    @Override
    public Cashier getByIdRel(Integer cashierId) {
        CashierParam param = new CashierParam();
        param.setCashierId(cashierId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
