package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.ShopStoreRiderMapper;
import com.gxwebsoft.shop.service.ShopStoreRiderService;
import com.gxwebsoft.shop.entity.ShopStoreRider;
import com.gxwebsoft.shop.param.ShopStoreRiderParam;
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 2026-01-30 15:14:15
 */
@Service
public class ShopStoreRiderServiceImpl extends ServiceImpl<ShopStoreRiderMapper, ShopStoreRider> implements ShopStoreRiderService {

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

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

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

}
