package com.aucma.base.service.impl;

import com.aucma.base.domain.ProcessDocument;
import com.aucma.base.mapper.ProcessDocumentMapper;
import com.aucma.base.service.IProcessDocumentService;
import com.aucma.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 工艺文档Service业务层处理
 *
 * @author Yinq
 * @date 2025-12-30
 */
@Service
public class ProcessDocumentServiceImpl implements IProcessDocumentService {
    @Autowired
    private ProcessDocumentMapper processDocumentMapper;

    @Override
    public ProcessDocument selectProcessDocumentByDocId(Long docId) {
        return processDocumentMapper.selectProcessDocumentByDocId(docId);
    }

    @Override
    public List<ProcessDocument> selectProcessDocumentList(ProcessDocument processDocument) {
        return processDocumentMapper.selectProcessDocumentList(processDocument);
    }

    @Override
    public int insertProcessDocument(ProcessDocument processDocument) {
        processDocument.setCreateTime(DateUtils.getNowDate());
        if (processDocument.getIsFlag() == null || processDocument.getIsFlag().isEmpty()) {
            processDocument.setIsFlag("1");
        }
        return processDocumentMapper.insertProcessDocument(processDocument);
    }

    @Override
    public int updateProcessDocument(ProcessDocument processDocument) {
        processDocument.setUpdateTime(DateUtils.getNowDate());
        return processDocumentMapper.updateProcessDocument(processDocument);
    }

    @Override
    public int deleteProcessDocumentByDocIds(Long[] docIds) {
        return processDocumentMapper.deleteProcessDocumentByDocIds(docIds);
    }

    @Override
    public int deleteProcessDocumentByDocId(Long docId) {
        return processDocumentMapper.deleteProcessDocumentByDocId(docId);
    }
}
