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

import com.bocloud.cmp.params.azure.RouterTableOperationParams;
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.network.RouterTable;
import com.bocloud.ims.interfaces.resource.azure.network.RouterTableService;
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: RouterTableController
 * @Description:
 * @author: zhenpingLi/李振平
 * @date: 2021/1/5 10:11
 */
@Api(value = "routerTable", tags = "routerTable管理")
@RestController
@RequestMapping("/v1/router/tables")
public class RouterTableController {

    @Autowired
    private RouterTableService service;

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

    /**
     * 修改
     *
     * @param entityParams
     * @param context
     * @return
     */

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

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


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

}