HandleJsonFile.java 1005 字节
Newer Older
jianglw's avatar
jianglw committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
package com.ruoyi.common.handlefile;

import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.common.utils.sign.RsaUtils;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author jianglw
 * @version 1.0
 * @date 2021/1/28 18:59
 */
public class HandleJsonFile implements HandleFile{
    private String data;
    @Override
    public HandleFile readFile(MultipartFile file) throws IOException {
        data=FileUtils.readFileJson(file);
        return this;
    }

    @Override
    public HandleFile encryptionFile() throws Exception{
        data= RsaUtils.encryptByPrivateKey( data );
        return this;
    }

    @Override
    public HandleFile decryptFile() throws Exception{
        data=RsaUtils.decryptByPublicKey( data );
        return this;
    }

    @Override
    public void createFile(String fileName,String userName,String createdPath) throws IOException{
        FileUtils.createdFile( fileName,userName,createdPath, data  );
    }
}