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

import com.bocloud.cmp.params.fusionsphere.SwitcherOperationParams;
import com.bocloud.common.annotations.Log;
import com.bocloud.common.enums.BoCloudService;
import com.bocloud.common.model.BocloudResult;
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.fusionsphere.FusionSphereSwitcherService;
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.*;

/**
 * @Company: 博云 www.bocloud.com
 * @ClassName: FusionSphereSwitchController
 * @Description:交换机
 * @author: zhenpingLi/李振平
 * @date: 2021/10/25 14:27
 */
@Api(value = "FusionSphereSwitcher", tags = "FusionSphereSwitcher管理")
@RestController
@RequestMapping("/v1/fc/switchers")
public class FusionSphereSwitcherController {

    @Autowired
    private FusionSphereSwitcherService service;

    /**
     * 查询列表
     *
     * @param pager
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "列表FusionSphereSwitcher", httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "FusionSphereSwitcher", operation = "列表FusionSphereSwitcher")
    @GetMapping
    public BocloudResult list(Pager pager,
                              @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.list(pager, context);
    }


    /**
     * 查询详情
     *
     * @param id
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "详情FusionSphereSwitcher", httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "FusionSphereSwitcher", operation = "详情FusionSphereSwitcher")
    @GetMapping("/{id}")
    public BocloudResult detail(@PathVariable(value = Common.ID) Long id,
                                @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.detail(id, context);
    }

    /**
     * 创建
     *
     * @param entityParams
     * @param context
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "创建FusionSphereSwitcher", httpMethod = "POST")
    @Log(module = BoCloudService.IMS, target = "FusionSphereSwitcher", operation = "创建FusionSphereSwitcher")
    @PostMapping
    public BocloudResult create(@RequestBody Switcher entityParams,
                                @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.create(entityParams, context);
    }

    /**
     * 更新
     *
     * @param entityParams
     * @param context
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "更新FusionSphereSwitcher", httpMethod = "PUT")
    @Log(module = BoCloudService.IMS, target = "FusionSphereSwitcher", operation = "更新FusionSphereSwitcher")
    @PutMapping(value = "/{id}")
    public BocloudResult modify(@PathVariable(value = Common.ID) Long id,
                                @RequestBody Switcher entityParams,
                                @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.modify(entityParams, context);
    }

    /**
     * 删除
     *
     * @param id
     * @param context
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "删除FusionSphereSwitcher", httpMethod = "DELETE")
    @Log(module = BoCloudService.IMS, target = "FusionSphereSwitcher", operation = "删除FusionSphereSwitcher")
    @DeleteMapping("/{id}")
    public BocloudResult remove(@PathVariable(value = Common.ID) Long id,
                                @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.remove(id, context);
    }


    /**
     * FusionSphereSwitcher相关操作
     *
     * @param id
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "操作CloudFusionSphereSwitcher", httpMethod = "PATCH")
    @Log(module = BoCloudService.IMS, target = "CloudFusionSphereSwitcher", operation = "操作CloudFusionSphereSwitcher")
    @PatchMapping("/{id}")
    public BocloudResult operations(@PathVariable(value = Common.ID) Long id,
                                    @Value(Common.REQ_CONTEXT) RequestContext context,
                                    @RequestBody SwitcherOperationParams params) {
        return service.operations(params, context);
    }

    /**
     * 根据switcherId查询vlan列表
     *
     * @param pager
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "根据switcherId查询vlan列表", httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "FusionSphereSwitcher", operation = "根据switcherId查询vlan列表")
    @GetMapping("/listVlan")
    public BocloudResult listVlan(Pager pager,
                                  @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.listVlan(pager, context);
    }

    /**
     * 根据switcherId查询uplink列表
     *
     * @param pager
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "根据switcherId查询vlan列表", httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "FusionSphereSwitcher", operation = "根据switcherId查询vlan列表")
    @GetMapping("/listUplink")
    public BocloudResult listUplink(Pager pager,
                                    @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.listUplink(pager, context);
    }
}