package com.fjhx.victoriatourist.service.logistics.impl;

import com.fjhx.victoriatourist.entity.logistics.po.LogisticsDetails;
import com.fjhx.victoriatourist.mapper.logistics.LogisticsDetailsMapper;
import com.fjhx.victoriatourist.service.logistics.LogisticsDetailsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.victoriatourist.entity.logistics.vo.LogisticsDetailsVo;
import com.fjhx.victoriatourist.entity.logistics.dto.LogisticsDetailsSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.victoriatourist.entity.logistics.dto.LogisticsDetailsDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 物流明细 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-04-17
 */
@Service
public class LogisticsDetailsServiceImpl extends ServiceImpl<LogisticsDetailsMapper, LogisticsDetails> implements LogisticsDetailsService {

    @Override
    public Page<LogisticsDetailsVo> getPage(LogisticsDetailsSelectDto dto) {
        IWrapper<LogisticsDetails> wrapper = getWrapper();
        wrapper.orderByDesc("ld", LogisticsDetails::getId);
        Page<LogisticsDetailsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

    @Override
    public LogisticsDetailsVo detail(Long id) {
        LogisticsDetails LogisticsDetails = this.getById(id);
        LogisticsDetailsVo result = BeanUtil.toBean(LogisticsDetails, LogisticsDetailsVo.class);
        return result;
    }

    @Override
    public void add(LogisticsDetailsDto logisticsDetailsDto) {
        this.save(logisticsDetailsDto);
    }

    @Override
    public void edit(LogisticsDetailsDto logisticsDetailsDto) {
        this.updateById(logisticsDetailsDto);
    }

    @Override
    public void delete(Long id) {
        this.removeById(id);
    }

}
