package com.ruoyi.ehsNoticeMessageFile.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.ruoyi.common.utils.StringUtils;
import java.util.List;
import java.util.Map;
import com.ruoyi.ehsNoticeMessageFile.mapper.EhsNoticeMessageFileMapper;
import com.ruoyi.ehsNoticeMessageFile.domain.EhsNoticeMessageFile;
import com.ruoyi.ehsNoticeMessageFile.service.IEhsNoticeMessageFileService;

/**
 * 通知公告附件Service业务层处理
 *
 * @author ruoyi
 * @date 2023-12-07
 */
@Service
public class EhsNoticeMessageFileServiceImpl extends ServiceImpl<EhsNoticeMessageFileMapper, EhsNoticeMessageFile> implements IEhsNoticeMessageFileService {

	@Autowired
	private EhsNoticeMessageFileMapper ehsNoticeMessageFileMapper;

	/**
	 * 查询通知公告附件
	 *
	 * @param id 通知公告附件主键
	 * @return 通知公告附件
	 */
	@Override
	public EhsNoticeMessageFile selectEhsNoticeMessageFileById(String id)
	{
		return ehsNoticeMessageFileMapper.selectEhsNoticeMessageFileById(id);
	}

	/**
	 * 查询通知公告附件列表
	 *
	 * @param ehsNoticeMessageFile 通知公告附件
	 * @return 通知公告附件
	 */
	@Override
	public List<EhsNoticeMessageFile> selectEhsNoticeMessageFileList(EhsNoticeMessageFile ehsNoticeMessageFile)
	{
		return ehsNoticeMessageFileMapper.selectEhsNoticeMessageFileList(ehsNoticeMessageFile);
	}


	private LambdaQueryWrapper<EhsNoticeMessageFile> buildQueryWrapper(EhsNoticeMessageFile query) {
		Map<String, Object> params = query.getParams();
		LambdaQueryWrapper<EhsNoticeMessageFile> lqw = Wrappers.lambdaQuery();
					lqw.like(StringUtils.isNotBlank(query.getFileName()), EhsNoticeMessageFile::getFileName, query.getFileName());
					lqw.eq(query.getState() != null, EhsNoticeMessageFile::getState, query.getState());
					lqw.like(StringUtils.isNotBlank(query.getOriginalName()), EhsNoticeMessageFile::getOriginalName, query.getOriginalName());
					lqw.eq(StringUtils.isNotBlank(query.getFileSize()), EhsNoticeMessageFile::getFileSize, query.getFileSize());
					lqw.eq(query.getSubmitTime() != null, EhsNoticeMessageFile::getSubmitTime, query.getSubmitTime());
				lqw.orderByDesc(EhsNoticeMessageFile::getCreateTime);
					lqw.eq(query.getDeptId() != null, EhsNoticeMessageFile::getDeptId, query.getDeptId());
					lqw.eq(query.getCreateUserId() != null, EhsNoticeMessageFile::getCreateUserId, query.getCreateUserId());
					lqw.eq(query.getUpdateUserId() != null, EhsNoticeMessageFile::getUpdateUserId, query.getUpdateUserId());
		return lqw;
	}

}
