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

import com.bocloud.cmp.model.VmTagParam;
import com.bocloud.common.annotations.Log;
import com.bocloud.common.enums.BoCloudService;
import com.bocloud.common.model.BocloudResult;
import com.bocloud.common.model.GridBean;
import com.bocloud.common.model.Pager;
import com.bocloud.common.utils.Common;
import com.bocloud.ims.entity.resource.Tag;
import com.bocloud.ims.interfaces.resource.TagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/tag")
@Api(value = "标签", tags = "标签")
public class TagController {

    @Autowired
    private TagService tagService;

    @ApiOperation(tags = {"CMC", "CSC"}, value = "查询标签列表",  httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "查询标签列表", operation = "查询标签列表")
    @GetMapping
    public BocloudResult<GridBean<Tag>> list(Pager pager) {
        return tagService.list(pager);
    }

    /**
     * 创建标签
     *
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "创建标签",  httpMethod = "POST")
    @Log(module = BoCloudService.IMS, target = "标签", operation = "创建标签")
    @PostMapping
    public BocloudResult create(@RequestBody VmTagParam vmTagParam) {
        return tagService.create(vmTagParam);
    }

    /**
     * 删除标签
     *
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "删除标签",  httpMethod = "DELETE")
    @Log(module = BoCloudService.IMS, target = "标签", operation = "删除标签")
    @DeleteMapping("/{id}")
    public BocloudResult remove(@PathVariable(value = Common.ID) Long id) {
        return tagService.remove(id);
    }
}
