com.github.rexsheng.springboot.faster.system.file.domain.SysFile Maven / Gradle / Ivy
The newest version!
package com.github.rexsheng.springboot.faster.system.file.domain;
import com.github.rexsheng.springboot.faster.common.constant.CommonConstant;
import com.github.rexsheng.springboot.faster.system.utils.AuthenticationUtil;
import com.github.rexsheng.springboot.faster.util.DateUtil;
import com.github.rexsheng.springboot.faster.util.PasswordUtils;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;
public class SysFile {
private Long fileId;
private String fileName;
private String serviceName;
private String bucketName;
private String objectKey;
private String originalFileName;
private Long fileSize;
private String businessType;
private String businessId;
private byte[] fileContent;
private Boolean isDel;
private LocalDateTime createTime;
private Long createUserId;
private LocalDateTime updateTime;
private Long updateUserId;
public static String encryptFileId(Long fileId){
return PasswordUtils.encodeAES(fileId.toString(), CommonConstant.AES_KEY_INNER);
}
public static Long decryptFileId(String fileId){
String value=PasswordUtils.decodeAES(fileId, CommonConstant.AES_KEY_INNER);
if(value==null){
throw new IllegalArgumentException("参数错误");
}
return Long.valueOf(value);
}
public static SysFile of(Long fileId, Boolean isDel){
SysFile sysFile=new SysFile();
sysFile.setFileId(fileId);
sysFile.setDel(isDel);
sysFile.setUpdateTime(DateUtil.currentDateTime());
sysFile.setUpdateUserId(AuthenticationUtil.currentUserId());
return sysFile;
}
public static SysFile of(String fileId, Boolean isDel){
return of(decryptFileId(fileId),isDel);
}
public static List of(List fileIds, Boolean isDel){
return fileIds.stream().map(fileId->of(fileId,isDel)).collect(Collectors.toList());
}
public String getEncryptFileId(){
return encryptFileId(fileId);
}
public Long getFileId() {
return fileId;
}
public void setFileId(Long fileId) {
this.fileId = fileId;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public String getBucketName() {
return bucketName;
}
public void setBucketName(String bucketName) {
this.bucketName = bucketName;
}
public String getObjectKey() {
return objectKey;
}
public void setObjectKey(String objectKey) {
this.objectKey = objectKey;
}
public String getOriginalFileName() {
return originalFileName;
}
public void setOriginalFileName(String originalFileName) {
this.originalFileName = originalFileName;
}
public Long getFileSize() {
return fileSize;
}
public void setFileSize(Long fileSize) {
this.fileSize = fileSize;
}
public String getBusinessType() {
return businessType;
}
public void setBusinessType(String businessType) {
this.businessType = businessType;
}
public String getBusinessId() {
return businessId;
}
public void setBusinessId(String businessId) {
this.businessId = businessId;
}
public byte[] getFileContent() {
return fileContent;
}
public void setFileContent(byte[] fileContent) {
this.fileContent = fileContent;
}
public Boolean getDel() {
return isDel;
}
public void setDel(Boolean del) {
isDel = del;
}
public LocalDateTime getCreateTime() {
return createTime;
}
public void setCreateTime(LocalDateTime createTime) {
this.createTime = createTime;
}
public Long getCreateUserId() {
return createUserId;
}
public void setCreateUserId(Long createUserId) {
this.createUserId = createUserId;
}
public LocalDateTime getUpdateTime() {
return updateTime;
}
public void setUpdateTime(LocalDateTime updateTime) {
this.updateTime = updateTime;
}
public Long getUpdateUserId() {
return updateUserId;
}
public void setUpdateUserId(Long updateUserId) {
this.updateUserId = updateUserId;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy