package com.tmerclub.cloud.cuerecycle.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.tmerclub.cloud.common.database.dto.PageDTO;
import com.tmerclub.cloud.common.database.util.PageUtil;
import com.tmerclub.cloud.common.database.vo.PageVO;
import com.tmerclub.cloud.cuerecycle.mapper.CueOrderFlawMapper;
import com.tmerclub.cloud.cuerecycle.model.CueOrderFlaw;
import com.tmerclub.cloud.cuerecycle.model.dto.CueOrderFlawDTO;
import com.tmerclub.cloud.cuerecycle.model.vo.CueOrderFlawVO;
import com.tmerclub.cloud.cuerecycle.service.CueOrderFlawService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * 球杆商品瑕疵项Service实现类
 *
 * @author : frank
 * @create : 2025-04-15
 */
@Service
public class CueOrderFlawServiceImpl implements CueOrderFlawService {

    @Resource
    CueOrderFlawMapper cueOrderFlawMapper;

    @Override
    public PageVO<CueOrderFlawVO> page(PageDTO pageDTO, CueOrderFlawDTO cueOrderFlawDTO) {
        return PageUtil.doPage(pageDTO, () -> cueOrderFlawMapper.list(cueOrderFlawDTO));
    }

    @Override
    public int save(CueOrderFlawDTO cueOrderFlawDTO) {
        CueOrderFlaw cueOrderFlaw = BeanUtil.toBean(cueOrderFlawDTO, CueOrderFlaw.class);
        return cueOrderFlawMapper.save(cueOrderFlaw);
    }

    @Override
    public int deleteByOrderId(Long orderId) {
        return cueOrderFlawMapper.deleteByOrderId(orderId);
    }
}