package com.bocloud.ims.booter.controller.resource.azure.db;

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.azure.db.DbVnetRule;
import com.bocloud.ims.interfaces.resource.azure.db.DbVnetRuleService;
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: DbVnetRuleController
 * @Description:
 * @author: zhenpingLi/李振平
 * @date: 2021/5/20 17:19
 */
@Api(value = "DbVnetRule", tags = "DbVnetRule管理")
@RestController
@RequestMapping("/v1/cloud/database/server/vnet/rules")
public class AzureDbVnetRuleController {

    @Autowired
    private DbVnetRuleService service;

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


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


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