package com.gxwebsoft.apps.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.apps.mapper.EquipmentOrderGoodsMapper;
import com.gxwebsoft.apps.service.EquipmentOrderGoodsService;
import com.gxwebsoft.apps.entity.EquipmentOrderGoods;
import com.gxwebsoft.apps.param.EquipmentOrderGoodsParam;
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 2023-05-11 19:10:13
 */
@Service
public class EquipmentOrderGoodsServiceImpl extends ServiceImpl<EquipmentOrderGoodsMapper, EquipmentOrderGoods> implements EquipmentOrderGoodsService {

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

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

    @Override
    public EquipmentOrderGoods getByIdRel(Integer orderGoodsId) {
        EquipmentOrderGoodsParam param = new EquipmentOrderGoodsParam();
        param.setOrderGoodsId(orderGoodsId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
