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

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fjhx.victoriatourist.entity.jd.dto.JdSalesReturnsDetailDto;
import com.fjhx.victoriatourist.entity.jd.dto.JdSalesReturnsDetailSelectDto;
import com.fjhx.victoriatourist.entity.jd.po.JdSalesReturnsDetail;
import com.fjhx.victoriatourist.entity.jd.vo.JdSalesReturnsDetailVo;
import com.fjhx.victoriatourist.mapper.jd.JdSalesReturnsDetailMapper;
import com.fjhx.victoriatourist.service.jd.JdSalesReturnsDetailService;
import com.ruoyi.common.utils.wrapper.IWrapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 京东售后退货明细 服务实现类
 * </p>
 *
 * @author hj
 * @since 2023-12-12
 */
@Service
public class JdSalesReturnsDetailServiceImpl extends ServiceImpl<JdSalesReturnsDetailMapper, JdSalesReturnsDetail> implements JdSalesReturnsDetailService {

    @Override
    public List<JdSalesReturnsDetailVo> getList(JdSalesReturnsDetailSelectDto dto) {
        IWrapper<JdSalesReturnsDetail> wrapper = getWrapper();
        wrapper.orderByDesc("jsrd", JdSalesReturnsDetail::getId);
        List<JdSalesReturnsDetailVo> list = this.baseMapper.getList(wrapper);
        return list;
    }

    @Override
    public Page<JdSalesReturnsDetailVo> getPage(JdSalesReturnsDetailSelectDto dto) {
        IWrapper<JdSalesReturnsDetail> wrapper = getWrapper();
        wrapper.orderByDesc("jsrd", JdSalesReturnsDetail::getId);
        Page<JdSalesReturnsDetailVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(JdSalesReturnsDetailDto jdSalesReturnsDetailDto) {
        this.save(jdSalesReturnsDetailDto);
    }

    @Override
    public void edit(JdSalesReturnsDetailDto jdSalesReturnsDetailDto) {
        this.updateById(jdSalesReturnsDetailDto);
    }

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

}
