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

import com.fjhx.victoriatourist.entity.order.po.OrderDetails;
import com.fjhx.victoriatourist.mapper.order.OrderDetailsMapper;
import com.fjhx.victoriatourist.service.order.OrderDetailsService;
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.order.vo.OrderDetailsVo;
import com.fjhx.victoriatourist.entity.order.dto.OrderDetailsSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.victoriatourist.entity.order.dto.OrderDetailsDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 订单明细 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-04-17
 */
@Service
public class OrderDetailsServiceImpl extends ServiceImpl<OrderDetailsMapper, OrderDetails> implements OrderDetailsService {

    @Override
    public Page<OrderDetailsVo> getPage(OrderDetailsSelectDto dto) {
        IWrapper<OrderDetails> wrapper = getWrapper();
        wrapper.orderByDesc("od", OrderDetails::getId);
        Page<OrderDetailsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(OrderDetailsDto orderDetailsDto) {
        this.save(orderDetailsDto);
    }

    @Override
    public void edit(OrderDetailsDto orderDetailsDto) {
        this.updateById(orderDetailsDto);
    }

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

}
