package com.persagy.server.labsl.controller

import com.persagy.server.labsl.models.entities.Relation
import com.persagy.server.labsl.services.RelationService
import com.persagy.service.models.requests.SCreateRequest
import com.persagy.service.models.requests.SQueryRequest
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.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 wx
 */
@Api(tags = ["004、管线对象"])
@RestController
@RequestMapping("/relation")
class RelationController {


    /**
     * 管线创建
     *
     * @param   request     待创建管线对象列表
     * @return  创建完成图例节点对象列表
     */
    @ApiOperation(value="管线创建", notes="")
    @PostMapping("/create")
    fun create(@RequestBody request: SCreateRequest<Relation>): SCreateResponse<Relation> {
        return RelationService.createList(request)
    } // Function create()

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

    /**
     * 更新管线信息
     *
     * @param   request        更新的内容对象
     * @return                  更新的结果
     */
    @ApiOperation(value = "更新管线信息", notes = "")
    @PostMapping(value = ["/update"])
    fun update(@RequestBody request: SUpdateRequest<Relation>): SBaseResponse {
        return RelationService.updateList(request)
    } // Function update()

    /**
     * 查询管线信息
     *
     * @param   request        查询条件
     * @return                 查询结果
     */
    @ApiOperation(value = "查询管线信息", notes = "")
    @PostMapping(value = ["/query"])
    fun query(@RequestBody request: SQueryRequest): SQueryResponse<Relation> {
        return RelationService.pageQuery(request)
    } // Function query()


} // Class NodeController