package cn.sagacloud.server.algorithm.services.endpoint

import cn.sagacloud.server.algorithm.models.floor.FloorExpr
import cn.sagacloud.server.algorithm.models.modelFile.FloorModelView
import com.sybotan.database.SQueryBuilder
import com.sybotan.mybatis.SMybatisDao
import com.sybotan.service.SObjectService
import com.sybotan.service.SPageContext
import java.lang.StringBuilder
import java.util.regex.Pattern
import kotlin.math.absoluteValue

/**
 *
 *
 * @author jxing
 */
object FloorModelService : SObjectService<FloorModelView>(SMybatisDao(FloorModelView::class.java)) {

    override fun onQueryBefore(queryBuilder: SQueryBuilder<FloorModelView>) {
        val tableName = StringBuilder();
        tableName.append("(SELECT floor.id, floor.floor_name, floor.project_id, floor.folder_id,");
        tableName.append("  file.id AS fid, file.accept_time, file.version, file.note,");
        tableName.append("  file.user_id, file.user_name, file.log, file.url, file.md5,");
        tableName.append("  file.status, file.plan_name, file.level, file.scheduler_info, ");
        tableName.append("  file.data_check_result, file.size, file.original_name, file.revit_version ");
        tableName.append("FROM revit.model_floor floor INNER JOIN revit.model_file file ");
        tableName.append("  ON floor.current_model_id = file.id ");
        tableName.append("WHERE file.removed != true) model_floor_file ");
        queryBuilder.tableName = tableName.toString()
    }
}