package com.ho.business.controller;

import com.ho.business.entity.TopologyJumpConfig;
import com.ho.business.service.TopologyJumpConfigService;
import com.ho.business.vo.req.topologyJumpConfig.TopologyJumpConfigReq;
import com.ho.business.vo.resp.colCount.ColCountResp;
import com.ho.common.tools.annotation.LogAnnotation;
import com.ho.common.tools.constant.ContextConstant;
import com.ho.common.tools.exception.DataResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * @Description 拓扑跳转配置
 * @Author xwz
 * @Date 2024/5/14
 */
@RestController
@RequestMapping(ContextConstant.BUSINESS + "topologyJumpConfig")
@Api(tags = "拓扑跳转配置")
public class TopologyJumpConfigController {

    @Autowired
    TopologyJumpConfigService topologyJumpConfigService;

    @PostMapping("list")
    @ApiOperation(value = "查询拓扑跳转配置")
    public DataResult<TopologyJumpConfig> list(@RequestBody TopologyJumpConfigReq vo) {
        List<TopologyJumpConfig> list = topologyJumpConfigService.selectByParam(vo);
        return DataResult.success(list);
    }

    @PostMapping("add")
    @ApiOperation(value = "新增拓扑跳转配置")
    @LogAnnotation(title = "拓扑跳转配置", action = "新增/更新拓扑跳转配置")
    public DataResult add(@RequestBody TopologyJumpConfig vo) {
        int count = topologyJumpConfigService.saveOrUpdateTopologyJumpConfig(vo);
        return DataResult.success(count);
    }

    @PostMapping("delete")
    @ApiOperation(value = "删除拓扑跳转配置")
    @LogAnnotation(title = "拓扑跳转配置", action = "删除拓扑跳转配置")
    public DataResult<ColCountResp> delte(@RequestBody List<Integer> ids) {
        int count = topologyJumpConfigService.deleteByList(ids);
        return DataResult.success(count);
    }
}
