package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.OrderRefundAddressMapper;
import com.gxwebsoft.shop.service.OrderRefundAddressService;
import com.gxwebsoft.shop.entity.OrderRefundAddress;
import com.gxwebsoft.shop.param.OrderRefundAddressParam;
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-05-18 13:09:51
 */
@Service
public class OrderRefundAddressServiceImpl extends ServiceImpl<OrderRefundAddressMapper, OrderRefundAddress> implements OrderRefundAddressService {

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

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

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

}
