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

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.model.RequestContext;
import com.bocloud.common.utils.Common;
import com.bocloud.ims.entity.SangforServerGroupSim;
import com.bocloud.ims.entity.resource.SangforServerGroup;
import com.bocloud.ims.interfaces.resource.sangfor.SangforGroupServerService;
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.*;

@RestController
@RequestMapping("/v1/sangfor/groupServer")
@Api(value = "深信服SCP虚拟机分组管理", tags = "深信服SCP虚拟机分组管理")
public class SangforGroupServerController {
    @Autowired
    private SangforGroupServerService groupServerService;

    @ApiOperation(tags = {"CMC",
            "CSC"}, value = "深信服SCP虚拟机分组列表查询管理",  httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "深信服SCP虚拟机分组列表查询管理", operation = "查询深信服SCP虚拟机分组列表")
    @GetMapping
    public BocloudResult<GridBean<SangforServerGroup>> list(Pager pager, @Value(Common.REQ_CONTEXT) RequestContext context) {
        return groupServerService.list(pager, context);
    }


    @ApiOperation(tags = {"CMC",
            "CSC"}, value = "深信服SCP虚拟机分组层级关系列表",  httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "深信服SCP虚拟机分组层级关系列表查询管理", operation = "深信服SCP虚拟机分组层级关系列表查询管理")
        @GetMapping("/listGroup")
    public BocloudResult<GridBean<SangforServerGroupSim>> listGroup(Pager pager, @Value(Common.REQ_CONTEXT) RequestContext context) {
        return groupServerService.listGroup(pager, context);
    }

    @ApiOperation(tags = {"CMC",
            "CSC"}, value = "深信服SCP虚拟机分组创建管理",  httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "深信服SCP虚拟机分组创建管理", operation = "深信服SCP虚拟机分组创建管理")
    @PostMapping
    public BocloudResult<GridBean<SangforServerGroup>> create(Pager pager, @Value(Common.REQ_CONTEXT) RequestContext context,
                                                              @RequestBody SangforServerGroup serverGroup) {
        return groupServerService.create(pager, context,serverGroup);
    }

    @ApiOperation(tags = {"CMC",
            "CSC"}, value = "深信服SCP虚拟机分组更新",  httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "深信服SCP虚拟机分组更新", operation = "深信服SCP虚拟机分组更新")
    @PutMapping("/{id}")
    public BocloudResult<GridBean<SangforServerGroup>> upDate(Pager pager, @Value(Common.REQ_CONTEXT) RequestContext context,
                                                              @PathVariable(value = Common.ID) Long id,@RequestBody SangforServerGroup serverGroup) {
        return groupServerService.update(pager, context,id,serverGroup);
    }


    @ApiOperation(tags = {"CMC",
            "CSC"}, value = "深信服SCP虚拟机分组删除",  httpMethod = "GET")
    @Log(module = BoCloudService.IMS, target = "深信服SCP虚拟机分组删除", operation = "深信服SCP虚拟机分组删除")
    @DeleteMapping("/{id}")
    public BocloudResult<GridBean<SangforServerGroup>> delete(Pager pager, @Value(Common.REQ_CONTEXT) RequestContext context,
                                                              @PathVariable(value = Common.ID) Long id) {
        return groupServerService.delete(pager, context,id);
    }

}
