package com.persagy.meiku.controller

import com.persagy.meiku.models.entities.MeiKuAnchor
import com.persagy.meiku.services.MeiKuAnchorService
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  wx
 * @date  2020/9/21 14:50
 */
@Tag(name = "002、锚点")
@RestController
@RequestMapping("/anchor")
class MeiKuAnchorController {

    /**
     * 创建图例
     */
    @Operation(summary = "创建锚点-批量", description= "")
    @PostMapping("/create")
    fun create(@RequestBody request: SCreateRequest<MeiKuAnchor>): SCreateResponse<MeiKuAnchor> {
        return MeiKuAnchorService.createList(request)
    }

    /**
     * 更新锚点
     */
    @Operation(summary = "锚点修改-批量", description = "")
    @PostMapping(value = ["/update"])
    fun update(@RequestBody request: SUpdateRequest<MeiKuAnchor>): SBaseResponse {
        return MeiKuAnchorService.updateList(request)
    }

    /**
     * 根据id删除锚点
     */
    @Operation(summary = "锚点删除", description = "")
    @PostMapping(value = ["/delete"])
    fun delete(@RequestBody idList: ArrayList<MeiKuAnchor>): SBaseResponse {
        return MeiKuAnchorService.deleteByKeysList(idList)
    }

    /**
     * 查询锚点信息
     */
    @Operation(summary = "查询锚点-批量", description = "")
    @PostMapping(value = ["/query"])
    fun query(@RequestBody request: SQueryRequest): SQueryResponse<MeiKuAnchor> {
        return MeiKuAnchorService.pageQuery(request)
    }

    @Operation(summary = "查询锚点统计", description = "")
    @PostMapping(value = ["/count"])
    fun count(@RequestBody request: SCountRequest): SCountResponse {
        return MeiKuAnchorService.count(request)
    }
}