package cn.lihongjie.coal.dataCollector.controller;

import cn.lihongjie.coal.annotation.OrgScope;
import cn.lihongjie.coal.annotation.SysLog;
import cn.lihongjie.coal.base.dto.CommonQuery;
import cn.lihongjie.coal.base.dto.IdRequest;
import cn.lihongjie.coal.dataCollector.dto.*;
import cn.lihongjie.coal.dataCollector.service.DataCollectorService;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
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;

@RestController
@RequestMapping("/dataCollector")
@SysLog(module = "数据采集器")
@Slf4j
@OrgScope
public class DataCollectorController {
    @Autowired private DataCollectorService service;

    @PostMapping("/create")
    public DataCollectorDto create(@RequestBody CreateDataCollectorDto request) {
        return this.service.create(request);
    }




    @PostMapping("/update")
    public DataCollectorDto update(@RequestBody UpdateDataCollectorDto request) {
        return this.service.update(request);
    }

    @PostMapping("/delete")
    public Object delete(@RequestBody IdRequest request) {
        this.service.delete(request);
        return true;
    }

    @PostMapping("/createQueue")
    public Object createQueue(@RequestBody IdRequest request) {
        this.service.createQueue(request);
        return true;
    }

    @PostMapping("/getById")
    public DataCollectorDto getById(@RequestBody IdRequest request) {
        return this.service.getById(request.getId());
    }

    @PostMapping("/list")
    public Page<DataCollectorDto> list(@RequestBody CommonQuery request) {
        return this.service.list(request);
    }





    @PostMapping("/deleteLocalStatus")
    public Object deleteLocalStatus(@RequestBody DeleteLocalStatusRequest request) {
        return this.service.deleteLocalStatus(request);
    }


    @PostMapping("/updateLocalStatus")
    public Object updateLocalStatus(@RequestBody UpdateLocalStatus request) {
        return this.service.updateLocalStatus(request);
    }


    @PostMapping("/getLocalStatus")
    public Object getLocalStatus(@RequestBody GetLocalStatusRequest request) {
        return this.service.getLocalStatus(request);
    }


    @PostMapping("/getXml")
    public Object getXml(@RequestBody GetXmlRequest request) {
        return this.service.getXml(request);
    }


    @PostMapping("/getVersion")
    public Object getVersion(@RequestBody GetXmlRequest request) {
        return this.service.getVersion(request);
    }


    @PostMapping("/restart")
    public Object restart(@RequestBody GetXmlRequest request) {
        return this.service.restart(request);
    }

}
