package com.persagy.meiku.controller

import com.persagy.meiku.models.entities.MeiKuState
import com.persagy.meiku.services.MeiKuStateService
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 = "003、状态")
@RestController
@RequestMapping("/state")
class MeiKuStateController {

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

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

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

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

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

}