package com.persagy.legend.controller

import com.persagy.legend.models.entities.LegendPipe
import com.persagy.legend.services.LegendPipeService
import com.sybotan.service.models.requests.SCountRequest
import com.sybotan.service.models.requests.SCreateRequest
import com.sybotan.service.models.requests.SQueryRequest
import com.sybotan.service.models.requests.SUpdateRequest
import com.sybotan.service.models.responses.SBaseResponse
import com.sybotan.service.models.responses.SCountResponse
import com.sybotan.service.models.responses.SCreateResponse
import com.sybotan.service.models.responses.SQueryResponse
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
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  zy
 */
@Tag(name = "002、管线图例")
@RestController
@RequestMapping("/pipe")
class LegendPipeController {
    /**
     * 创建管线图例
     */
    @Operation(summary= "创建管线图例-批量")
    @PostMapping("/create")
    fun create(@RequestBody request: SCreateRequest<LegendPipe>): SCreateResponse<LegendPipe> {
        return LegendPipeService.createList(request)
    }

    /**
     * 更新管线图例
     */
    @Operation(summary = "管线图例修改-批量")
    @PostMapping(value = ["/update"])
    fun update(@RequestBody request: SUpdateRequest<LegendPipe>): SBaseResponse {
        return LegendPipeService.updateList(request)
    }

    /**
     * 保存图例
     */
    @Operation(summary = "管线图例保存")
    @PostMapping(value = ["/save"])
    fun save(@RequestBody request: LegendPipe): SBaseResponse {
        return LegendPipeService.save(request)
    }

    /**
     * 根据id删除管线图例
     */
    @Operation(summary = "管线图例删除", description = "")
    @PostMapping(value = ["/delete"])
    fun delete(@RequestBody idList: ArrayList<LegendPipe>): SBaseResponse {
        return LegendPipeService.deleteByKeysList(idList)
    }

    /**
     * 查询管线图例信息
     */
    @Operation(summary = "查询管线图例-批量", description = " 级联：类型信息（classInfo） 状态信息（stateList）")
    @PostMapping(value = ["/query"])
    fun query(@RequestBody request: SQueryRequest): SQueryResponse<LegendPipe> {
        return LegendPipeService.pageQuery(request)
    }

    /**
     * 统计管线图例
     */
    @Operation(summary = "统计管线图例")
    @PostMapping(value = ["/count"])
    fun count(@RequestBody request: SCountRequest): SCountResponse {
        return LegendPipeService.count(request)
    }
}