package com.hotent.project.manager.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hotent.project.manager.CostProjectDocumentManager;
import com.hotent.project.model.CostProjectDocument;
import com.hotent.project.model.CostProjectDocumentFile;
import com.hotent.project.dao.CostProjectDocumentFileDao;
import com.hotent.project.manager.CostProjectDocumentFileManager;
import com.hotent.base.manager.impl.BaseManagerImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;


/**
 * 监审项目文书内容表 服务实现类
 *
 * @company 山西清众科技股份有限公司
 * @author 超级管理员
 * @since 2025-10-16
 */
@Service
public class CostProjectDocumentFileManagerImpl extends BaseManagerImpl<CostProjectDocumentFileDao, CostProjectDocumentFile> implements CostProjectDocumentFileManager {

	@Resource
	private CostProjectDocumentManager costProjectDocumentManager;

	@Override
	public CostProjectDocumentFile getDetail(String id) {
    	CostProjectDocumentFile costProjectDocumentFile = this.get(id);
    	

		return costProjectDocumentFile;
	}


	@Override
	@Transactional
	public void createOrUpdate(CostProjectDocumentFile costProjectDocumentFile) {
		//新建或更新
		this.saveOrUpdate(costProjectDocumentFile);
	}


	@Override
	public List<CostProjectDocumentFile> getCostProjectDocumentFiles(String projectId, String documentId) {
		LambdaQueryWrapper<CostProjectDocumentFile> wrapper = new LambdaQueryWrapper<>();
		wrapper.eq(CostProjectDocumentFile::getProjectId,projectId);
		wrapper.eq(CostProjectDocumentFile::getDocumentId,documentId);
		return  this.list(wrapper);
	}

	@Override
	public List<CostProjectDocumentFile> getInfo(String id) {
		//CostProjectDocument costProjectDocument = costProjectDocumentManager.getDetail(id);
		//return this.getCostProjectDocumentFiles(costProjectDocument.getProjectId(),costProjectDocument.getDocumentId());
		QueryWrapper<CostProjectDocumentFile> wrapper = new QueryWrapper<>();
		wrapper.eq("project_document_id",id);
		return this.list(wrapper);
	}
}
