package com.op.mes.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.domain.BaseFileData;
import com.op.common.core.utils.DateUtils;
import com.op.mes.domain.BaseFile;
import com.op.mes.mapper.BaseFileMapper;
import com.op.mes.service.IBaseFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 附件Service业务层处理
 *
 * @author Open Platform
 * @date 2023-07-10
 */
@Service
public class BaseFileServiceImpl implements IBaseFileService {
	@Autowired
	private BaseFileMapper baseFileMapper;

	/**
	 * 查询附件
	 *
	 * @param fileId 附件主键
	 * @return 附件
	 */
	@Override
	@DS("#header.poolName")
	public BaseFile selectBaseFileByFileId(String fileId) {
		return baseFileMapper.selectBaseFileByFileId(fileId);
	}

	/**
	 * 查询附件列表
	 *
	 * @param baseFile 附件
	 * @return 附件
	 */
	@Override
	@DS("#header.poolName")
	public List<BaseFile> selectBaseFileList(BaseFile baseFile) {
		return baseFileMapper.selectBaseFileList(baseFile);
	}

	/**
	 * 新增附件
	 *
	 * @param baseFile 附件
	 * @return 结果
	 */
	@Override
	@DS("#header.poolName")
	public int insertBaseFile(BaseFile baseFile) {
		baseFile.setCreateTime(DateUtils.getNowDate());
		return baseFileMapper.insertBaseFile(baseFile);
	}

	/**
	 * 修改附件
	 *
	 * @param baseFile 附件
	 * @return 结果
	 */
	@Override
	@DS("#header.poolName")
	public int updateBaseFile(BaseFile baseFile) {
		baseFile.setUpdateTime(DateUtils.getNowDate());
		return baseFileMapper.updateBaseFile(baseFile);
	}

	/**
	 * 批量删除附件
	 *
	 * @param fileIds 需要删除的附件主键
	 * @return 结果
	 */
	@Override
	@DS("#header.poolName")
	public int deleteBaseFileByFileIds(String[] fileIds) {
		return baseFileMapper.deleteBaseFileByFileIds(fileIds);
	}

	/**
	 * 删除附件信息
	 *
	 * @param fileId 附件主键
	 * @return 结果
	 */
	@Override
	@DS("#header.poolName")
	public int deleteBaseFileByFileId(String fileId) {
		return baseFileMapper.deleteBaseFileByFileId(fileId);
	}

	/**
	 * 新增附件
	 *
	 * @param baseFiles 附件
	 * @return 结果
	 */
	@Override
	@DS("#header.poolName")
	public Boolean insertBaseFileBatch(List<BaseFileData> baseFiles) {
		return baseFileMapper.insertBaseFileBatch(baseFiles);
	}
}
