package com.cretin.webapi.controller.log

import com.cretin.entity.common.Resp
import com.cretin.entity.log.*
import com.cretin.webservices.service.api.log.LogService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*
import javax.servlet.http.HttpServletRequest

@RestController
@RequestMapping("/log_remote")
@ResponseBody
class RemoteLogController {

    @Autowired
    private var logService: LogService? = null

    @PostMapping("/add_logcat")
    fun addLogcat(
        @RequestBody data: AddLogcatReq,
        httpServletRequest: HttpServletRequest
    ): Resp<*> {
        return  Resp(logService?.addLogcat(data,httpServletRequest))
    }

    @PostMapping("/logcat_list")
    fun logcatList(
        @RequestBody data: LogcatListReq,
        httpServletRequest: HttpServletRequest
    ): Resp<*> {
        return  Resp(logService?.logcatList(data,httpServletRequest))
    }

    @PostMapping("/device/create")
    fun addDeviceInfo(
        @RequestBody data: AddDeviceReq,
        httpServletRequest: HttpServletRequest
    ): Resp<*> {
        logService?.addDeviceInfo(data,httpServletRequest)
        return  Resp.createSuccess()
    }

    @PostMapping("/device/info")
    fun getDeviceInfo(
        @RequestBody data: DeviceConfigReq,
        httpServletRequest: HttpServletRequest
    ): Resp<*> {
        return  Resp(logService?.getDeviceInfo(data,httpServletRequest))
    }

    @PostMapping("/device/status")
    fun updateDeviceStatus(
        @RequestBody data: DeviceStatusReq,
        httpServletRequest: HttpServletRequest
    ): Resp<*> {
        return  Resp(logService?.updateDeviceStatus(data,httpServletRequest))
    }

    @PostMapping("/device/list")
    fun deviceList(
        @RequestBody data: DeviceListReq,
        httpServletRequest: HttpServletRequest
    ): Resp<*> {
        return  Resp(logService?.deviceList(data,httpServletRequest))
    }

    @PostMapping("/device/force-stop")
    fun deviceForceStop(
        @RequestBody data: DeviceForceStopReq,
        httpServletRequest: HttpServletRequest
    ): Resp<*> {
        logService?.deviceForceStop(data,httpServletRequest)
        return Resp.createSuccess()
    }

    @PostMapping("/logcat_details")
    fun logcatDetails(
        @RequestBody data: LogcatDetailsReq,
        httpServletRequest: HttpServletRequest
    ): Resp<*> {
        return  Resp(logService?.logcatDetails(data,httpServletRequest))
    }
}
