package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.SelfTakeUserMapper;
import com.gxwebsoft.shop.service.SelfTakeUserService;
import com.gxwebsoft.shop.entity.SelfTakeUser;
import com.gxwebsoft.shop.param.SelfTakeUserParam;
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 2025-12-03 14:22:38
 */
@Service
public class SelfTakeUserServiceImpl extends ServiceImpl<SelfTakeUserMapper, SelfTakeUser> implements SelfTakeUserService {

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

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

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

}
