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.AzureDatabase;
import com.bocloud.ims.interfaces.resource.azure.db.CloudDatabaseService;
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: CloudDatabaseController
 * @Description:
 * @author: zhenpingLi/李振平
 * @date: 2021/2/4 13:57
 */
@Api(value = "CloudDatabase", tags = "CloudDatabase管理")
@RestController
@RequestMapping("/v1/cloud/database/server/databases")
public class CloudDatabaseController {

    @Autowired
    private CloudDatabaseService service;

    /**
     * 查询列表
     *
     * @param pager
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "列表CloudDatabase", httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "CloudDatabase", operation = "列表CloudDatabase")
    @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 = "创建CloudDatabase", httpMethod = "POST")
    @Log(module = BoCloudService.IMS, target = "CloudDatabase", operation = "创建CloudDatabase")
    @PostMapping
    public BocloudResult create(@RequestBody AzureDatabase params,
                                @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.create(params, context);
    }

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

}