package com.persagy.meiku.controller

import com.persagy.meiku.models.entities.MeiKu
import com.persagy.meiku.models.response.SCommonResponse
import com.persagy.meiku.services.MeiKuService
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.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
 * @date  2020/9/18 21:53
 */
@Tag(name = "001、图例库")
@RestController
@RequestMapping("/legend")
class MeiKuController {

    /**
     * 创建图例
     */
    @Operation(summary= "创建图例-批量", description = "不包含状态和锚点")
    @PostMapping("/create")
    fun create(@RequestBody request: SCreateRequest<MeiKu>): SCreateResponse<MeiKu> {
        return MeiKuService.createList(request)
    }

    /**
     * 创建图例-单个
     */
    @Operation(summary="创建图例-单个", description ="包含状态和锚点")
    @PostMapping("/save")
    fun save(@RequestBody meiku: MeiKu): SCreateResponse<MeiKu> {
        return MeiKuService.save(meiku)
    }

    /**
     * 更新图例
     */
    @Operation(summary = "图例修改-批量", description = "不包含状态和锚点")
    @PostMapping(value = ["/update"])
    fun update(@RequestBody request: SUpdateRequest<MeiKu>): SBaseResponse {
        return MeiKuService.updateList(request)
    }

    @Operation(summary = "图例修改-单个", description = "包含状态和锚点")
    @PostMapping(value = ["/revise"])
    fun revise(@RequestBody meiku: MeiKu): SBaseResponse{
        return MeiKuService.revise(meiku)
    }

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

    /**
     * 查询图形信息
     */
    @Operation(summary = "查询图例-批量", description = " 类型：category   级联：锚点（anchorList）状态：（state）  ")
    @PostMapping(value = ["/query"])
    fun query(@RequestBody request: SQueryRequest): SQueryResponse<MeiKu> {
        return MeiKuService.pageQuery(request)
    }

    @Operation(summary = "查询图例-单量", description = "包含状态和锚点")
    @PostMapping(value = ["/read"])
    fun read(@RequestBody meiku: MeiKu): SCommonResponse<MeiKu> {
        return  MeiKuService.read(meiku)
    }
}