import java.io.File;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.fastjson.annotation.JSONField;
public class FileInfo extends BaseDto {
private static final long serialVersionUID = ;
//名称
@JSONField(name="imageName")
public String name;
//类型
@JSONField(name="type")
private String type;
@JSONField(name="documentType")
private String documentType;
//文件小类别
@JSONField(name="fileType")
private String fileType;
//订单号
@JSONField(name="idOrder")
private String idOrder;
//文件后缀
@JSONField(name="ext")
private String ext;
//文件id
@JSONField(name="fileId")
private String fileId;
//文件资源路径
@JSONField(name="fileUri")
private String fileUri;
@JSONField(name="fileUrl")
private String fileUrl;
//父级文件夹位置
@JSONField(name="fileParentPath")
private String fileParentPath="";
//子目录
@JSONField(name="children")
private List<FileInfo> children;
public FileInfo(){
this.children = new ArrayList<FileInfo>();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getIdOrder() {
return idOrder;
}
public void setIdOrder(String idOrder) {
this.idOrder = idOrder;
}
public String getExt() {
return ext;
}
public void setExt(String ext) {
this.ext = ext;
}
public String getFileId() {
return fileId;
}
public void setFileId(String fileId) {
this.fileId = fileId;
}
public String getFileUri() {
return fileUri;
}
public void setFileUri(String fileUri) {
this.fileUri = fileUri;
}
public String getFilePath() {
StringBuffer path = new StringBuffer( (null != this.fileParentPath) ? this.fileParentPath:"" );
path.append(File.separator);
path.append(this.name);
if( this.ext != null && !this.ext.isEmpty()){
path.append(".");
path.append( this.ext );
}
return path.toString();
}
public List<FileInfo> getChildren() {
return children;
}
public void setChildren(List<FileInfo> children) {
if(children != null && !children.isEmpty()){
for(FileInfo child : children){
child.idOrder = this.idOrder;
fixPath(child, this.fileParentPath, this.name);
}
this.children = children;
}
}
public void addChild(FileInfo child){
if(child==null){
return;
}
child.idOrder = this.idOrder;
fixPath(child, this.fileParentPath, this.name);
this.children.add(child);
}
public void fixPath(FileInfo child, String baseParentPath, String baseName){
if(child == null || baseParentPath == null || baseName == null){
return;
}
child.fileParentPath = baseParentPath + File.separator + baseName;
if(child.getChildren() != null){
for(FileInfo innerChild : child.getChildren()){
fixPath(innerChild, child.fileParentPath, child.name);
}
}
}
public String getFileParentPath() {
return fileParentPath;
}
public void setFileParentPath(String fileParentPath) {
this.fileParentPath = fileParentPath;
}
public String getDocumentType() {
return documentType;
}
public void setDocumentType(String documentType) {
this.documentType = documentType;
}
public String getFileType() {
return fileType;
}
public void setFileType(String fileType) {
this.fileType = fileType;
}
public String getFileUrl() {
return fileUrl;
}
public void setFileUrl(String fileUrl) {
this.fileUrl = fileUrl;
}
@Override
public boolean equals(Object object){
if(object == null){
return false;
}
if(! ( object instanceof FileInfo)){
return false;
}
FileInfo fileObj = (FileInfo)object;
if(fileObj.fileId == null || fileObj.fileId.isEmpty() || this.fileId == null || this.fileId.isEmpty()){
return false;
}else if(this.fileId.equals(fileObj.fileId)){
return true;
}
return false;
}
@Override
public int hashCode(){
return 0;
}
}