package com.gxwebsoft.hjm.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.hjm.mapper.HjmBxLogMapper;
import com.gxwebsoft.hjm.service.HjmBxLogService;
import com.gxwebsoft.hjm.entity.HjmBxLog;
import com.gxwebsoft.hjm.param.HjmBxLogParam;
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-06-06 13:08:29
 */
@Service
public class HjmBxLogServiceImpl extends ServiceImpl<HjmBxLogMapper, HjmBxLog> implements HjmBxLogService {

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

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

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

}
