package com.gxwebsoft.apps.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.apps.mapper.BcEquipmentMapper;
import com.gxwebsoft.apps.service.BcEquipmentService;
import com.gxwebsoft.apps.entity.BcEquipment;
import com.gxwebsoft.apps.param.BcEquipmentParam;
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-02 10:34:40
 */
@Service
public class BcEquipmentServiceImpl extends ServiceImpl<BcEquipmentMapper, BcEquipment> implements BcEquipmentService {

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

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

    @Override
    public BcEquipment getByIdRel(Integer bcEquipmentId) {
        BcEquipmentParam param = new BcEquipmentParam();
        param.setBcEquipmentId(bcEquipmentId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
