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 ); } }