package com.gxwebsoft.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.shop.entity.ShopDealerRecord;
import com.gxwebsoft.shop.mapper.ShopDealerRecordMapper;
import com.gxwebsoft.shop.param.ShopDealerRecordParam;
import com.gxwebsoft.shop.service.ShopDealerRecordService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 客户跟进情况Service实现
 *
 * @author 科技小王子
 * @since 2025-10-02 12:21:50
 */
@Service
public class ShopDealerRecordServiceImpl extends ServiceImpl<ShopDealerRecordMapper, ShopDealerRecord> implements ShopDealerRecordService {

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

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

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

}
