package com.njcn.csdevice.controller.project;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.pojo.param.AppTopologyDiagramAddParm;
import com.njcn.csdevice.pojo.param.AppTopologyDiagramAuditParm;
import com.njcn.csdevice.pojo.param.AppTopologyDiagramQueryPageParm;
import com.njcn.csdevice.pojo.param.AppTopologyDiagramQueryParm;
import com.njcn.csdevice.pojo.vo.AppTopologyDiagramVO;
import com.njcn.csdevice.service.AppTopologyDiagramService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Description:
 * 接口文档访问地址：http://serverIP:port/swagger-ui.html
 * Date: 2023/3/27  15:31【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/topologyDiagram")
@Api(tags = " 项目拓扑图")
@AllArgsConstructor
public class AppTopologyController extends BaseController {

    private final AppTopologyDiagramService appTopologyDiagramService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/addAppTopologyDiagram")
    @ApiOperation("新增拓扑图")
//    @ApiImplicitParam(name = "appTopologyDiagramAddParm", value = "新增项目参数", required = true)
    public HttpResult<AppTopologyDiagramVO> addAppTopologyDiagram(@Validated AppTopologyDiagramAddParm appTopologyDiagramAddParm){
        String methodDescribe = getMethodDescribe("addAppTopologyDiagram");

        AppTopologyDiagramVO vo = appTopologyDiagramService.addAppTopologyDiagram(appTopologyDiagramAddParm);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
    }


    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/AuditAppTopologyDiagram")
    @ApiOperation("修改拓扑图")
    public HttpResult<Boolean> AuditAppTopologyDiagram(@Validated AppTopologyDiagramAuditParm appTopologyDiagramAuditParm){
        String methodDescribe = getMethodDescribe("addAppProject");

        Boolean flag = appTopologyDiagramService.AuditAppTopologyDiagram(appTopologyDiagramAuditParm);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/checkCanDelete")
    @ApiOperation("检查是否能删除拓扑图")
    public HttpResult<Boolean> AuditAppTopologyDiagram(@RequestParam("id") String id){
        String methodDescribe = getMethodDescribe("checkCanDelete");

        Boolean flag = appTopologyDiagramService.checkCanDelete(id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/queryAppTopologyDiagram")
    @ApiOperation("查询拓扑图")
    @ApiImplicitParam(name = "appTopologyDiagramQueryParm", value = "拓扑图查询参数", required = true)
    public HttpResult<List<AppTopologyDiagramVO>> queryAppTopologyDiagram(@Validated @RequestBody AppTopologyDiagramQueryParm appTopologyDiagramQueryParm){
        String methodDescribe = getMethodDescribe("queryAppTopologyDiagram");

        List<AppTopologyDiagramVO> appTopologyDiagramVOList = appTopologyDiagramService.queryAppTopologyDiagram(appTopologyDiagramQueryParm);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, appTopologyDiagramVOList, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/queryTopologyDiagramPage")
    @ApiOperation("查询拓扑图分页")
    @ApiImplicitParam(name = "appTopologyDiagramQueryPageParm", value = "拓扑图查询参数", required = true)
    public HttpResult<IPage<AppTopologyDiagramVO>> queryTopologyDiagramPage(@Validated @RequestBody AppTopologyDiagramQueryPageParm  appTopologyDiagramQueryPageParm){
        String methodDescribe = getMethodDescribe("queryTopologyDiagramPage");

        IPage<AppTopologyDiagramVO> appTopologyDiagramVOList = appTopologyDiagramService.queryTopologyDiagramPage(appTopologyDiagramQueryPageParm);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, appTopologyDiagramVOList, methodDescribe);
    }

}
