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.JdSalesReturnsDto;
import com.fjhx.victoriatourist.entity.jd.dto.JdSalesReturnsSelectDto;
import com.fjhx.victoriatourist.entity.jd.po.JdSalesReturns;
import com.fjhx.victoriatourist.entity.jd.vo.JdSalesReturnsVo;
import com.fjhx.victoriatourist.mapper.jd.JdSalesReturnsMapper;
import com.fjhx.victoriatourist.service.jd.JdSalesReturnsService;
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 JdSalesReturnsServiceImpl extends ServiceImpl<JdSalesReturnsMapper, JdSalesReturns> implements JdSalesReturnsService {

    @Override
    public List<JdSalesReturnsVo> getList(JdSalesReturnsSelectDto dto) {
        IWrapper<JdSalesReturns> wrapper = getWrapper();
        wrapper.orderByDesc("jsr", JdSalesReturns::getId);
        List<JdSalesReturnsVo> list = this.baseMapper.getList(wrapper);
        return list;
    }

    @Override
    public Page<JdSalesReturnsVo> getPage(JdSalesReturnsSelectDto dto) {
        IWrapper<JdSalesReturns> wrapper = getWrapper();
        wrapper.orderByDesc("jsr", JdSalesReturns::getId);
        Page<JdSalesReturnsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(JdSalesReturnsDto jdSalesReturnsDto) {
        this.save(jdSalesReturnsDto);
    }

    @Override
    public void edit(JdSalesReturnsDto jdSalesReturnsDto) {
        this.updateById(jdSalesReturnsDto);
    }

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

}
