package com.steering.pss.judge.Bll;

import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;
import CoreFS.SC01.CoreConstantData;
import com.steering.comm.db.DBCommon;
import com.steering.comm.tools.EntityTool;
import com.steering.comm.tools.SqlBuilder;
import com.steering.pss.judge.model.QcmAutoJudgeEntity;
import java.util.ArrayList;

public class BllQcmAutoJudge extends DBCommon {

    public CoreReturnObject save(ArrayList<String> jsons, String userId){
        ArrayList<String> sqllist = new ArrayList<String>();
        for(String json : jsons){
            QcmAutoJudgeEntity auto = EntityTool.getEntityByJSONStr(json, QcmAutoJudgeEntity.class);
            auto.setOpUserId(userId);
            auto.setOpUserStatus("1");
            auto.setIsAuto(auto.getIsAuto().equals("True") ? "1" : "0");
            String sql = CoreXmlSqlParsersFactory.getSql("JdgQcmAutoJudge.setById");
            sql = EntityTool.fillSqlByEntity(sql, auto);
            sqllist.add(sql);
        }

        return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqllist);
    }

    public CoreReturnObject setLastOnlineTime(){
        SqlBuilder b = new SqlBuilder("JdgQcmAutoJudge.setLastOnlineTime");

        return this.setData(b.toString());
    }
}
