package com.persagy.server.labsl.controller

import com.persagy.server.labsl.models.entities.Node
import com.persagy.server.labsl.services.NodeService
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 = ["002、图例节点"])
@RestController
@RequestMapping("/node")
class NodeController {


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

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

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

    /**
     * 查询图例节点信息
     *
     * @param   request        查询条件
     * @return                 查询结果
     */
    @ApiOperation(value = "查询图例节点信息", notes = "")
    @PostMapping(value = ["/query"])
    fun query(@RequestBody request: SQueryRequest): SQueryResponse<Node> {
        return NodeService.pageQuery(request)
    } // Function query()


} // Class NodeController