package com.gxwebsoft.common.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.system.mapper.OrderInfoMapper;
import com.gxwebsoft.common.system.service.OrderInfoService;
import com.gxwebsoft.common.system.entity.OrderInfo;
import com.gxwebsoft.common.system.param.OrderInfoParam;
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-05-10 18:02:54
 */
@Service
public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo> implements OrderInfoService {

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

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

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

}
