package com.ai.da.service.impl;

import com.ai.da.mapper.primary.DesignItemDetailPrintMapper;
import com.ai.da.mapper.primary.entity.DesignItemDetailPrint;
import com.ai.da.service.DesignItemDetailPrintService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DesignItemDetailPrintServiceImpl extends ServiceImpl<DesignItemDetailPrintMapper, DesignItemDetailPrint> implements DesignItemDetailPrintService {


    @Override
    public List<DesignItemDetailPrint> getByDesignItemDetailId(Long designItemDetailId, String printType) {
        QueryWrapper<DesignItemDetailPrint> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("design_item_detail_id", designItemDetailId);
        queryWrapper.eq("print_type", printType);
        queryWrapper.eq("is_deleted", 0);

        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public void deleteByDesignItemDetailId(Long designItemDetailId) {
        UpdateWrapper<DesignItemDetailPrint> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("design_item_detail_id", designItemDetailId);
        updateWrapper.set("is_deleted", (byte) 1);

        baseMapper.update(null, updateWrapper);
    }

}
