package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.ShopCashierMapper;
import com.gxwebsoft.shop.service.ShopCashierService;
import com.gxwebsoft.shop.entity.ShopCashier;
import com.gxwebsoft.shop.param.ShopCashierParam;
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 2024-09-10 21:05:06
 */
@Service
public class ShopCashierServiceImpl extends ServiceImpl<ShopCashierMapper, ShopCashier> implements ShopCashierService {

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

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

    @Override
    public ShopCashier getByIdRel(Long id) {
        ShopCashierParam param = new ShopCashierParam();
        param.setId(id);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
