/*
 * ********************************************************************************************************************
 *
 *                      :*$@@%$*:                         ;:                ;;    ;;
 *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
 *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
 *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
 *                   =@*                                  %!              @ $= % %@=   =%@!      %=
 *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
 *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
 *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
 *          $@*   ;@@@%=!:                *@*
 *          =@$    ;;;!=%@@@@=!           =@!
 *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
 *            ;%@@$=$@@%*       *@@@$=%@@%;
 *               ::;::             ::;::                                              All rights reserved.
 *
 * ********************************************************************************************************************
 */


package com.persagy.revit.controllers.modelEntity

import com.persagy.mybatis.SMybatisDao
import com.persagy.revit.models.entities.Duct
import com.persagy.service.SObjectService
import com.persagy.service.models.requests.SCountRequest
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.SCountResponse
import com.persagy.service.models.responses.SCreateResponse
import com.persagy.service.models.responses.SQueryResponse
import io.swagger.v3.oas.annotations.tags.Tag
import io.swagger.v3.oas.annotations.Operation
import org.slf4j.LoggerFactory
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 jxing
 */
@Tag(name = "构件-风管接口")
@RestController
@RequestMapping("/duct")
class DuctController {

    companion object {
        // 日志
        private val logger = LoggerFactory.getLogger(DuctController::class.java)
    } // Companion object

    private var ductService = SObjectService(SMybatisDao(Duct::class.java))

    /**
     * 创建风管
     *
     * @param   entity     风管实体
     * @return  创建结果应答信息
     */
    @Operation(summary = "创建风管", description =  "")
    @PostMapping(value = ["/create"])
    fun create(@RequestBody entity: SCreateRequest<Duct>): SCreateResponse<Duct> {
        return ductService.createList(entity)
    } // Function create()

    /**
     * 删除风管
     *
     * @param   idList      风管ID列表
     * @return  删除结果应答信息
     */
    @Operation(summary = "删除风管", description =  "")
    @PostMapping(value = ["/delete"])
    fun delete(@RequestBody idList: ArrayList<Duct>): SBaseResponse {
        return ductService.deleteByKeysList(idList)
    } // Function delete()

    /**
     * 更新风管
     *
     * @param   request     更新请求
     * @return  更新结果应答信息
     */
    @Operation(summary = "更新风管", description =  "")
    @PostMapping(value = ["/update"])
    fun update(@RequestBody request: SUpdateRequest<Duct>): SBaseResponse {
        return ductService.updateList(request)
    } // Function update()

    /**
     * 查询风管
     *
     * @param   request     查询请求
     * @return  查询结果应答信息
     */
    @Operation(summary = "查询风管", description =  "")
    @PostMapping(value = ["/query"])
    fun query(@RequestBody request: SQueryRequest): SQueryResponse<Duct> {
        return ductService.pageQuery(request)
    } // Function query()

    /**
     * 根据条件查询统计数量
     */
    @Operation(summary = "根据条件查询统计数量", description =  "")
    @PostMapping(value = ["/count"])
    fun count(@RequestBody request: SCountRequest): SCountResponse {
        return ductService.count(request)
    } // Function count()
}