package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.ExpressMapper;
import com.gxwebsoft.shop.service.ExpressService;
import com.gxwebsoft.shop.entity.Express;
import com.gxwebsoft.shop.param.ExpressParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import lombok.val;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 物流公司记录表Service实现
 *
 * @author 科技小王子
 * @since 2022-11-22 00:21:07
 */
@Service
public class ExpressServiceImpl extends ServiceImpl<ExpressMapper, Express> implements ExpressService {

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

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

    @Override
    public Express getByIdRel(Integer expressId) {
      ExpressParam param = new ExpressParam();
        param.setExpressId(expressId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
