package core.process;

import core.operation.UploadFile;
import error.GExcptInit;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

public class C_StudentUploadFinishedProduct extends C_UploadFile {

    File finishedProduct;
    String graduationDesignId;
    private static String buttonName ="提交定稿";
    private static String iconURL="../cssFile/images/upload.png";
    private static String targetURL="/home/student-upload-finished-product";
    private static String info = "";

    private static String table="graduation_design_finished_product";
    private static String fileds="finished_product_status";

    static String file_type = "finished_product";
    public void uploadOpeningReport() throws Exception{
        if(!check()) throw new GExcptInit("Upload FinishedProduct Attrs init error!");
        UploadFile uploadFile=new UploadFile();
        uploadFile.setOptions(new HashMap<>());
        uploadFile.addOptions("file",this.getFinishedProduct());
        uploadFile.addOptions("file_type",file_type);
        Map<String, String>limits = new HashMap<>();
        limits.put("id",this.getGraduationDesignId());
        uploadFile.addOptions("limits",limits);
        uploadFile.execute(null);
        updateStatus();
    }

    protected boolean check() {
        if(this.getFinishedProduct()==null||this.getGraduationDesignId()==null)
            return false;
        return true;
    }
    public File getFinishedProduct() {
        return finishedProduct;
    }

    public void setFinishedProduct(File finishedProduct) {
        this.finishedProduct = finishedProduct;
    }
    public String getGraduationDesignId() {
        return graduationDesignId;
    }

    public void setGraduationDesignId(String graduationDesignId) {
        this.graduationDesignId = graduationDesignId;
    }

    @Override
    public String getInfo() {
        return info;
    }

    @Override
    public String getTargetURL() {
        return targetURL;
    }

    @Override
    public String getIconURL() {
        return iconURL;
    }

    @Override
    public String getButtonName() {
        return buttonName;
    }

    @Override
    public String getFileType() {
        return "上传定稿";
    }
}
