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

package cn.sagacloud.server.algorithm.controllers.log

import cn.sagacloud.server.algorithm.models.entities.Wall
import cn.sagacloud.server.algorithm.models.log.SyncLogEntity
import cn.sagacloud.server.algorithm.services.BaseDataService
import com.sybotan.mybatis.SMybatisDao
import com.sybotan.service.SObjectService
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.annotations.Api
import io.swagger.annotations.ApiOperation
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
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
 */
@Api(tags = ["同步日志接口"])
@RestController
@RequestMapping("/sync-log")
class SyncLogController {

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

    val dataService = BaseDataService

    /**
     * 创建同步日志
     *
     * @param   entity     实体
     * @return  创建结果应答信息
     */
    @ApiOperation(value = "创建同步日志", notes = "")
    @PostMapping(value = ["/create"])
    fun create(@RequestBody entity: SCreateRequest<SyncLogEntity>): SCreateResponse<SyncLogEntity> {
        return dataService.syncLogService.createList(entity)
    } // Function create()

    /**
     * 删除同步日志
     *
     * @param   idList      同步日志ID列表
     * @return  删除结果应答信息
     */
    @ApiOperation(value = "删除同步日志", notes = "")
    @PostMapping(value = ["/delete"])
    fun delete(@RequestBody idList: ArrayList<SyncLogEntity>): SBaseResponse {
        return dataService.syncLogService.deleteByKeysList(idList)
    } // Function delete()

    /**
     * 更新同步日志
     *
     * @param   request     更新请求
     * @return  更新结果应答信息
     */
    @ApiOperation(value = "更新同步日志", notes = "")
    @PostMapping(value = ["/update"])
    fun update(@RequestBody request: SUpdateRequest<SyncLogEntity>): SBaseResponse {
        return dataService.syncLogService.updateList(request)
    } // Function update()

    /**
     * 查询同步日志
     *
     * @param   request     查询请求
     * @return  查询结果应答信息
     */
    @ApiOperation(value = "查询同步日志", notes = "")
    @PostMapping(value = ["/query"])
    fun query(@RequestBody request: SQueryRequest): SQueryResponse<SyncLogEntity> {
        return dataService.syncLogService.pageQuery(request)
    } // Function query()

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