/*
 * ********************************************************************************************************************
 *
 *                     :*$@@%$*:                         ;:                ;;    ;;
 *                   :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
 *                  :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
 *                  =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
 *                  =@*                                  %!              @ $= % %@=   =%@!      %=
 *             *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
 *           %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
 *         ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
 *         $@*   ;@@@%=!:                *@*
 *         =@$    ;;;!=%@@@@=!           =@!
 *          %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
 *           ;%@@$=$@@%*       *@@@$=%@@%;
 *              ::;::             ::;::                                              All rights reserved.
 *
 * ********************************************************************************************************************
 */

package com.persagy.server.controllers.objects

import com.persagy.server.datacenter.models.entities.objects.ZoneIspace
import com.persagy.server.datacenter.models.requests.DCSQueryRequest
import com.persagy.server.services.objects.SpaceService
import com.persagy.base.extensions.toJson
import com.persagy.service.models.requests.SCreateRequest
import com.persagy.service.models.requests.SUpdateRequest
import com.persagy.service.models.responses.SBaseResponse
import com.persagy.service.models.responses.SCreateResponse
import com.persagy.service.models.responses.SQueryResponse
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 = ["010、模型空间"])
@RestController
@RequestMapping("/object/ispace")
open class ISpaceController {
    companion object {
        /** 日志 */
        private val logger = LoggerFactory.getLogger(ISpaceController::class.java)
    } // Companion object

    /**
     * 创建元空间
     *
     * @param   request     元空间对象
     * @return              创建结果信息
     */
    @ApiOperation(value = "创建元空间", notes = "")
    @PostMapping(value = ["/create"])
    fun create(@RequestBody request: SCreateRequest<ZoneIspace>): SCreateResponse<ZoneIspace> {
        logger.debug("space =${request.toJson()}")
        return SpaceService.createList(request)
    } // Function create()

    /**
     * 根据id删除元空间
     *
     * @param   idList      id数组
     * @return              删除的结果信息
     */
    @ApiOperation(value = "根据id删除元空间", notes = "")
    @PostMapping(value = ["/delete"])
    fun delete(@RequestBody idList: ArrayList<ZoneIspace>): SBaseResponse {
        return SpaceService.deleteByKeysList(idList)
    } // Function delete()

    /**
     * 更新元空间信息
     *
     * @param   request     更新的内容对象
     * @return              更新的结果
     */
    @ApiOperation(value = "更新元空间信息", notes = "")
    @PostMapping(value = ["/update"])
    fun update(@RequestBody request: SUpdateRequest<ZoneIspace>): SBaseResponse {
        logger.debug("spaceUpdate =${request.toJson()}")
        return SpaceService.updateList(request)
    } // Function update()

    /**
     * 查询元空间信息
     *
     * @param   request     查询信息条件
     * @return              查询结果
     */
    @ApiOperation(value = "查询元空间信息", notes = "")
    @PostMapping(value = ["/query"])
    fun query(@RequestBody request: DCSQueryRequest): SQueryResponse<ZoneIspace> {
        logger.debug("spaceQuery =${request.toJson()}")
        return SpaceService.queryIspace(request)
    } // Function query()

} // Class ISpaceController