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

package com.persagy.server.controller.task

import com.persagy.base.extensions.toJson
import com.persagy.database.SFilter
import com.persagy.server.datacenter.models.entities.task.ScanSchemeInfo
import com.persagy.server.services.task.ScanSchemeInfoService
import com.persagy.service.SPageContext
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.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  邓婷婷
 */
@Api(tags = ["006、任务-任务方案信息点接口"])
@RestController
@RequestMapping("/task/scheme-info")
open class ScanSchemeInfoController {

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

    /**
     * 查询任务方案信息点
     *
     * @author 邓婷婷
     */
    @ApiOperation(value = "查询任务方案信息点", notes = "级联查询对象：项目（project）、方案（scanScheme）")
    @PostMapping(value = ["/page-query"])
    fun pageQuery(@RequestBody request: SQueryRequest): SQueryResponse<ScanSchemeInfo> {
        logger.debug("ScanSchemeInfoQuery =${request.toJson()}")
        val withFilterList = ArrayList<SFilter>()
        withFilterList.add(SFilter.eq("projectId", SPageContext.getHeader("ProjectId").toString()))
        return ScanSchemeInfoService.pageQuery(request);
    } // Function pageQuery()

    /**
     * 创建任务方案信息点
     *
     * @author  邓婷婷
     */
    @ApiOperation(value = "创建任务方案信息点", notes = "")
    @PostMapping(value = ["/create"])
    fun create(@RequestBody request: SCreateRequest<ScanSchemeInfo>): SCreateResponse<ScanSchemeInfo> {
        logger.debug("ScanSchemeInfo =${request.toJson()}")
        return ScanSchemeInfoService.createList(request)
    } // Function create()

    /**
     * 更新任务方案信息点
     *
     * @author  邓婷婷
     */
    @ApiOperation(value = "更新任务方案信息点", notes = "")
    @PostMapping(value = ["/update"])
    fun update(@RequestBody request: SUpdateRequest<ScanSchemeInfo>): SBaseResponse {
        return ScanSchemeInfoService.updateList(request)
    } // Function update()

    /**
     * 根据id删除信息点
     *
     * @author  邓婷婷
     */
    @ApiOperation(value = "根据id删除信息点", notes = "")
    @PostMapping(value = ["/delete"])
    fun delete(@RequestBody idList: ArrayList<ScanSchemeInfo>): SBaseResponse {
        return ScanSchemeInfoService.deleteByKeysList(idList)
    } // Function delete()

} // Class ScanSchemeController