package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.DealerApplyMapper;
import com.gxwebsoft.shop.service.DealerApplyService;
import com.gxwebsoft.shop.entity.DealerApply;
import com.gxwebsoft.shop.param.DealerApplyParam;
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-07-28 11:57:41
 */
@Service
public class DealerApplyServiceImpl extends ServiceImpl<DealerApplyMapper, DealerApply> implements DealerApplyService {

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

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

    @Override
    public DealerApply getByIdRel(Integer applyId) {
        DealerApplyParam param = new DealerApplyParam();
        param.setApplyId(applyId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
