package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.OrderExtractMapper;
import com.gxwebsoft.shop.service.OrderExtractService;
import com.gxwebsoft.shop.entity.OrderExtract;
import com.gxwebsoft.shop.param.OrderExtractParam;
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-24 01:39:23
 */
@Service
public class OrderExtractServiceImpl extends ServiceImpl<OrderExtractMapper, OrderExtract> implements OrderExtractService {

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

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

    @Override
    public OrderExtract getByIdRel(Integer id) {
        OrderExtractParam param = new OrderExtractParam();
        param.setId(id);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
