package com.persagy.legend.controller

import com.persagy.legend.models.entities.LegendIcon
import com.persagy.legend.services.LegendIconService
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 = "001、图标图例")
@RestController
@RequestMapping("/icon")
class LegendIconController {
    /**
     * 创建图标图例
     */
    @Operation(summary= "创建图标图例-批量")
    @PostMapping("/create")
    fun create(@RequestBody request: SCreateRequest<LegendIcon>): SCreateResponse<LegendIcon> {
        return LegendIconService.createList(request)
    }

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

    /**
     * 保存图例
     */
    @Operation(summary = "图标图例保存")
    @PostMapping(value = ["/save"])
    fun save(@RequestBody request: LegendIcon): SBaseResponse {
        return LegendIconService.save(request)
    }

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

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

    /**
     * 查询图标图例信息
     */
    @Operation(summary = "查询图标图例-默认状态图例", description = " 级联：类型信息（classInfo）")
    @PostMapping(value = ["/state/query"])
    fun query(@RequestBody request: SQueryRequest): SQueryResponse<LegendIcon> {
        return LegendIconService.statePageQuery(request)
    }


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