/*
 * Author: wangjian
 * 生成ServiceImpl
 */
package com.tofly.xrtymis.custom.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tofly.common.ftp.config.FtpUtil;
import com.tofly.pojo.message.Messagepush;
import com.tofly.pojo.message.Messagerecipient;
import com.tofly.xrtymis.custom.service.FileService;
import com.tofly.xrtymis.entity.File;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.tofly.xrtymis.mapper.FileMapper;

import java.util.List;

/**
 * 公共文件表： TF_YWPN_FILE_W
 *
 * @author fuchenlin
 * @date Mon Mar 22 00:00:00 CST 2021
 */
@Service("fileService")
public class FileServiceImpl extends ServiceImpl<FileMapper, File> implements FileService {
    @Autowired
    private FileMapper fileMapper;

    @Override
    public Boolean removeFileList(List<Long> fileIdList) {
        List<File> files = this.listByIds(fileIdList);
        // 删除远程文件
        files.forEach(k -> FtpUtil.deleteFile(k.getFilePath()));
        return true;
    }

    @Override
    public Long getPlanTempMaxId(String tableName) {
        return fileMapper.getTempMaxId(tableName);
    }

    @Override
    public void addMessageList(List<Messagepush> list) {
        fileMapper.addMessageList(list);
    }

    @Override
    public void addMessageRecipientList(List<Messagerecipient> list) {
        fileMapper.addMessageRecipientList(list);
    }
}
