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

import com.bocloud.cmp.params.fusionsphere.NetworkCardOperationParams;
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.NetworkCard;
import com.bocloud.ims.interfaces.resource.fusionsphere.FusionSphereNetworkCardService;
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.*;

/**
 * @ClassName: FusionSphereNetworkCardController
 * @Description: 网卡操作
 * @Author lxy
 * @Date 2021/10/27 16:29
 */
@Api(value = "FusionSphereNetworkCard", tags = "FusionSphereNetworkCard管理")
@RestController
@RequestMapping("/v1/fc/nics")
public class FusionSphereNetworkCardController {
    @Autowired
    private FusionSphereNetworkCardService service;
    /**
     * FusionSphereNetworkCard相关操作，
     *
     * @param id
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "FusionSphereNetworkCard", httpMethod = "PATCH")
    @Log(module = BoCloudService.IMS, target = "FusionSphereNetworkCard", operation = "FusionSphereNetworkCard")
    @PatchMapping("/{id}")
    public BocloudResult operations(@PathVariable(value = Common.ID) Long id,
                                    @Value(Common.REQ_CONTEXT) RequestContext context,
                                    @RequestBody NetworkCardOperationParams params) {
        return service.operations(params, context);
    }

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

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

    /**
     * 查询列表
     *
     * @param pager
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "列表FusionSphereNetworkCard", httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "FusionSphereNetworkCard", operation = "列表FusionSphereNetworkCard")
    @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 = "详情FusionSphereNetworkCard", httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "FusionSphereNetworkCard", operation = "详情FusionSphereNetworkCard")
    @GetMapping("/{id}")
    public BocloudResult detail(@PathVariable(value = Common.ID) Long id,
                                @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.detail(id, context);
    }
}
