package com.persagy.server.meiku.controller

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

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

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

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

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

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

    /**
     * 查询图形信息
     */
    @ApiOperation(value = "查询图例-批量", notes = "不包含状态和锚点")
    @PostMapping(value = ["/query"])
    fun query(@RequestBody request: SQueryRequest): SQueryResponse<MeiKu> {
        return MeiKuService.pageQuery(request)
    } // Function query()

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


} // Class MeiKuController