package com.gxwebsoft.hjm.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.hjm.mapper.HjmGpsLogMapper;
import com.gxwebsoft.hjm.service.HjmGpsLogService;
import com.gxwebsoft.hjm.entity.HjmGpsLog;
import com.gxwebsoft.hjm.param.HjmGpsLogParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 黄家明_gps轨迹Service实现
 *
 * @author 科技小王子
 * @since 2025-06-11 12:03:50
 */
@Service
public class HjmGpsLogServiceImpl extends ServiceImpl<HjmGpsLogMapper, HjmGpsLog> implements HjmGpsLogService {

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

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

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

}
