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

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.DataStore;
import com.bocloud.ims.interfaces.resource.fusionsphere.FusionSphereDataStoreService;
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: FusionSphereDataStoreController
 * @Description:数据存储
 * @author: zhenpingLi/李振平
 * @date: 2021/10/20 17:54
 */
@Api(value = "FusionSphereDataStore", tags = "FusionSphereDataStore管理")
@RestController
@RequestMapping("/v1/fc/datastores")
public class FusionSphereDataStoreController {
    @Autowired
    private FusionSphereDataStoreService service;

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

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

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

    /**
     * 查询详情
     *
     * @param id
     * @return
     */
    @ApiOperation(tags = {"CMC", "CSC"}, value = "FusionSphereDataStore文件", httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "FusionSphereDataStore", operation = "FusionSphereDataStore文件")
    @GetMapping("/{id}/files")
    public BocloudResult listFile(@PathVariable(value = Common.ID) Long id,
                                  @Value(Common.REQ_CONTEXT) RequestContext context) {
        return service.listFile(id, context);
    }

}