package com.persagy.legend.controller

import com.persagy.legend.models.entities.PipelineCategory
import com.persagy.legend.services.PipelineCategoryService
import com.sybotan.service.models.requests.SCreateRequest
import com.sybotan.service.models.requests.SUpdateRequest
import com.sybotan.service.models.responses.SBaseResponse
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 wx  <zhangweixin@sagacloud.com>
 * @date  2020/11/5 10:12
 */
@Tag(name = "005、管线类型")
@RestController
@RequestMapping("/pipeCategory")
class LegendPipelineController {

    /**
     * 管线
     *
     * @param request   待创建管线
     * @return  创建完成管线
     */
    @Operation(summary="创建管线", description ="id 为 32 位 uuid")
    @PostMapping("/create")
    fun create(@RequestBody request: SCreateRequest<PipelineCategory>): SCreateResponse<PipelineCategory> {
        return PipelineCategoryService.createList(request)
    }

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

    /**
     * 更新管线
     *
     * @param  request   更新的内容对象
     * @return 更新的结果
     */
    @Operation(summary = "更新管线", description = "")
    @PostMapping(value = ["/update"])
    fun update(@RequestBody request: SUpdateRequest<PipelineCategory>): SBaseResponse {
        return PipelineCategoryService.updateList(request)
    }

    /**
     * 查询管线
     *
     * @return 查询结果
     */
    @Operation(summary = "查询管线", description = "")
    @PostMapping(value = ["/query"])
    fun query(): SQueryResponse<PipelineCategory> {
        return PipelineCategoryService.categoryQuery()
    }

}