package com.bocloud.ims.booter.controller.resource.network;

import com.bocloud.common.model.BocloudResult;
import com.bocloud.common.model.GridBean;
import com.bocloud.common.model.Pager;
import com.bocloud.common.model.RequestContext;
import com.bocloud.common.utils.Common;
import com.bocloud.ims.entity.resource.Switcher;
import com.bocloud.ims.interfaces.resource.SwitcherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@Api(value = "交换机", tags = "H3c网络")
@RestController
@RequestMapping("/v1/switchers")
public class SwitcherController {

    @Autowired
    private SwitcherService switcherService;

    @ApiOperation(tags = { "CMC", "CSC" }, value = "交换机列表查询",  httpMethod = "GET")
    @GetMapping
    public BocloudResult<GridBean<Switcher>> list(Pager pager, @Value(Common.REQ_CONTEXT) RequestContext context) {
        return switcherService.list(pager, context);
    }

    @ApiOperation(tags = { "CMC", "CSC" }, value = "创建交换机",  httpMethod = "POST")
    @PostMapping
    public BocloudResult<Void> create(@RequestBody Switcher switcher, @Value(Common.REQ_CONTEXT) RequestContext context) {
        return switcherService.create(switcher, context);
    }

    @ApiOperation(tags = { "CMC", "CSC" }, value = "编辑交换机",  httpMethod = "POST")
    @PutMapping("/{id}")
    public BocloudResult<Void> modify(@PathVariable(Common.ID) Long id,
                                      @RequestBody Switcher switcher,
                                      @Value(Common.REQ_CONTEXT) RequestContext context) {
        switcher.setId(id);
        return switcherService.modify(switcher, context);
    }

    @ApiOperation(tags = { "CMC", "CSC" }, value = "删除交换机",  httpMethod = "POST")
    @DeleteMapping("/{id}")
    public BocloudResult<Void> remove(@PathVariable(Common.ID) Long id, @Value(Common.REQ_CONTEXT) RequestContext context) {
        return switcherService.remove(id, context);
    }


}
