package com.fjhx.jushuitan.service.jst.impl;

import com.fjhx.jushuitan.entity.jst.po.JstOrderDetail;
import com.fjhx.jushuitan.mapper.jst.JstOrderDetailMapper;
import com.fjhx.jushuitan.service.jst.JstOrderDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.jushuitan.entity.jst.vo.JstOrderDetailVo;
import com.fjhx.jushuitan.entity.jst.dto.JstOrderDetailSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.jushuitan.entity.jst.dto.JstOrderDetailDto;
import cn.hutool.core.bean.BeanUtil;

import java.util.List;

/**
 * <p>
 * 聚水潭订单明细表 服务实现类
 * </p>
 *
 * @author 
 * @since 2024-01-20
 */
@Service
public class JstOrderDetailServiceImpl extends ServiceImpl<JstOrderDetailMapper, JstOrderDetail> implements JstOrderDetailService {

    @Override
    public List<JstOrderDetailVo> getList(JstOrderDetailSelectDto dto) {
        IWrapper<JstOrderDetail> wrapper = getWrapper();
        wrapper.orderByDesc("jod", JstOrderDetail::getId);
        List<JstOrderDetailVo> list = this.baseMapper.getList(wrapper);
        return list;
    }

    @Override
    public Page<JstOrderDetailVo> getPage(JstOrderDetailSelectDto dto) {
        IWrapper<JstOrderDetail> wrapper = getWrapper();
        wrapper.orderByDesc("jod", JstOrderDetail::getId);
        Page<JstOrderDetailVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(JstOrderDetailDto jstOrderDetailDto) {
        this.save(jstOrderDetailDto);
    }

    @Override
    public void edit(JstOrderDetailDto jstOrderDetailDto) {
        this.updateById(jstOrderDetailDto);
    }

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

}
