package com.persagy.server.controllers.rel

import com.persagy.server.datacenter.models.entities.rel.RShaftThroughShaft
import com.persagy.server.datacenter.models.entities.rel.RShaftThroughShaftOtherList
import com.persagy.server.services.rel.RShaftThroughShaftService
import com.persagy.base.extensions.toJson
import com.persagy.service.models.responses.SBaseResponse
import com.persagy.service.models.responses.SCreateResponse
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 张维新
 */
@Api(tags = ["022、关系-竖井的贯通关系"])
@RestController
@RequestMapping("/rel/sh-through-sh")
class RShaftThroughShaftController {
    companion object {
        /** 日志 */
        private val logger = LoggerFactory.getLogger(RShaftThroughShaftController::class.java)
    } // Companion object

    /**
     * 创建竖井的贯通关系
     *
     * @param   rFlThroughFl    竖井和竖井的关系对象
     * @return                  创建的结果信息
     */
    @ApiOperation(value = "创建竖井的贯通关系", notes = "必填项：ShaftId（竖井id）、ShaftOtherId（其他竖井id）")
    @PostMapping(value = ["/link"])
    fun create(@RequestBody rFlThroughFl: RShaftThroughShaft): SCreateResponse<RShaftThroughShaft>{
        logger.debug("build = ${rFlThroughFl.toJson()}")
        return RShaftThroughShaftService.create(rFlThroughFl)
    } // Function create()

    /**
     * 根据对象删除关系
     *
     * @param   rFlThroughFl    对象
     * @return                  删除的结果信息
     */
    @ApiOperation(value = "根据对象删除竖井的贯通关系，只针对一个对象", notes = "必填项：ShaftId（竖井id）、ShaftOtherId(其他数据竖井id)")
    @PostMapping(value = ["/unlink"])
    fun delete(@RequestBody rFlThroughFl: RShaftThroughShaft): SBaseResponse {
        return RShaftThroughShaftService.deletes(rFlThroughFl)
    } // Function delete()

    /**
     * 创建竖井的贯通关系
     *
     * @param   rFlThroughFl    竖井和其他竖井列表关系对象r
     * @return                  创建的结果信息
     */
    @ApiOperation(value = "竖井的贯通，竖井一对多，此方法会覆盖以前的记录", notes = "必填项：ShaftId（竖井id）、ShaftOtherIdList（其他竖井id列表）,此方法会覆盖以前的记录")
    @PostMapping(value = ["link-or"])
    fun createOr(@RequestBody rFlThroughFl: RShaftThroughShaftOtherList): SCreateResponse<RShaftThroughShaft>{
        logger.debug("Shaft =${rFlThroughFl.toJson()}")
        return RShaftThroughShaftService.createShaft(rFlThroughFl)
    } // Function createOr()

    /**
     * 创建竖井的贯通关系
     *
     * @param   rFlThroughFl    竖井和其他竖井列表关系对象r
     * @return                  创建的结果信息
     */
    @ApiOperation(value = "竖井的贯通，竖井一对多，此方法不会覆盖以前的记录", notes = "必填项：ShaftId（竖井id）、ShaftOtherIdList（其他竖井id列表）")
    @PostMapping(value = ["link-shaft"])
    fun createShaft(@RequestBody rFlThroughFl: RShaftThroughShaftOtherList): SCreateResponse<RShaftThroughShaft>{
        logger.debug("Shaft =${rFlThroughFl.toJson()}")
        return RShaftThroughShaftService.createShaftAll(rFlThroughFl)
    } // Function createOr()

//    /**
//     * 创建楼层的贯通关系
//     *
//     * @param   rFlThroughFl    其他楼层和楼层列表关系对象
//     * @return                  创建的结果信息
//     */
//    @ApiOperation(value = "楼层的贯通，其他楼层一对多",notes = "必填项：FloorIdList（楼层id列表）、FloorOtherId（其他楼层id），测方法会覆盖以前的记录")
//    @PostMapping(value = ["link-fl"])
//    fun createFl(@RequestBody rFlThroughFl: RFloorOtherThroughFloorList): SCreateResponse<RFlThroughFl>{
//        logger.debug("floor =${rFlThroughFl.toJson()}")
//        return RFlThroughFlService.createsFl(rFlThroughFl)
//    } // Function createFl()

} // Class RFlThroughFlController