package cn.sagacloud.server.algorithm.controllers.relation

import cn.sagacloud.server.algorithm.models.request.VerticalPipeCheckRequest
import cn.sagacloud.server.algorithm.services.BaseDataService
import com.sybotan.database.SFilter
import com.sybotan.service.models.enums.SResponseType
import com.sybotan.service.models.responses.SBaseResponse
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.slf4j.LoggerFactory
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

/**
 *
 *
 * @author jxing
 */
@Api(tags = ["关系检查接口"])
@RestController
@RequestMapping("/rel-check")
class RelationCheckController {
    companion object {
        // 日志
        private val logger = LoggerFactory.getLogger(RelationCheckController::class.java)
    } // Companion object

    var dataService = BaseDataService

    /**
     * 立管完整性(是否对齐)检查
     */
    @ApiOperation(value = "立管完整性(是否对齐)检查", notes = "")
    @PostMapping(value = ["/vertical-pipe"])
    fun verticalPipe(@RequestBody request : VerticalPipeCheckRequest): SBaseResponse {
        val ret = SBaseResponse()
        if(request.folderId == null || request.folderId!!.isEmpty()){
            return SBaseResponse(SResponseType.failure, "folderId不能为空")
        }
        val count = dataService.folderService.select(SFilter.eq("id", request.folderId!!)).count
        if(count == null || count <= 0){
            return SBaseResponse(SResponseType.failure, "指定文件夹不存在")
        }
        // 判断文件夹下的所有当前模型, 立管是否对齐
        return SBaseResponse()
    } // Function verticalPipe()
}