package com.fjhx.purchase.service.refund.impl;

import com.fjhx.purchase.entity.refund.po.RefundDetail;
import com.fjhx.purchase.mapper.refund.RefundDetailMapper;
import com.fjhx.purchase.service.refund.RefundDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.purchase.entity.refund.vo.RefundDetailVo;
import com.fjhx.purchase.entity.refund.dto.RefundDetailSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.purchase.entity.refund.dto.RefundDetailDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 退款明细 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-04-13
 */
@Service
public class RefundDetailServiceImpl extends ServiceImpl<RefundDetailMapper, RefundDetail> implements RefundDetailService {

    @Override
    public Page<RefundDetailVo> getPage(RefundDetailSelectDto dto) {
        IWrapper<RefundDetail> wrapper = getWrapper();
        wrapper.orderByDesc("rd", RefundDetail::getId);
        Page<RefundDetailVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(RefundDetailDto refundDetailDto) {
        this.save(refundDetailDto);
    }

    @Override
    public void edit(RefundDetailDto refundDetailDto) {
        this.updateById(refundDetailDto);
    }

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

}
