Pch5SwitchCtrl.java 3.54 KB
package com.ui.ctrl;

import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;

/**
 * pch5切换
 *
 * @author craig.qin 2018-3-6
 */
@Controller
@RequestMapping("/pch5Switch")
public class Pch5SwitchCtrl {

    @Autowired
    HttpRestClient httpRestClient;


    @RequestMapping(value = "/toDockerPch5Switch")
    public ModelAndView toDockerPch5Switch() {
        ModelAndView mdv = new ModelAndView("pch5Switch/pch5DockerSwitch");
        return mdv;
    }

    /**
     * 解析当前配置,绘图用
     *
     */
    @RequestMapping(value = "/getDockerElbStatus")
    @ResponseBody
    public BaseResponse getDockerElbStatus() {
        return  httpRestClient.defaultGet( "/pch5DockerSwitch/getDockerElbStatus", BaseResponse.class, null);
    }

    /**
     * az2切换
     * 直接修改权限
     */
    @RequestMapping(value = "/switchDockerAz2",method = RequestMethod.POST)
    @ResponseBody
    public BaseResponse switchDockerAz2(String projectType,String onlineOrGray) {
        Map<String, String> map=new HashMap<>();
        map.put("projectType",projectType);
        map.put("onlineOrGray",onlineOrGray);
        return  httpRestClient.defaultGet( "/pch5DockerSwitch/switchDockerAz2", BaseResponse.class, map);
    }


    /***********************************************************************************************************
     * 以下内容为原来的pch5切换,以上部分为docker pch5切换
     *********************************************************************************************************/


    @RequestMapping(value = "/toPch5Switch")
    public ModelAndView toPch5Switch() {
        ModelAndView mdv = new ModelAndView("pch5Switch/pch5switch");
        return mdv;
    }

    /**
     * 解析当前配置,绘图用
     *
     */
    @RequestMapping(value = "/getElbStatus")
    @ResponseBody
    public BaseResponse getElbStatus() {
        return  httpRestClient.defaultGet( "/pch5Switch/getElbStatus", BaseResponse.class, null);
    }

    /**
     * 可用区切换
     *
     */
    @RequestMapping(value = "/switchArea",method = RequestMethod.POST)
    @ResponseBody
    public BaseResponse switchArea(String area) {
        return  httpRestClient.defaultGet( "/pch5Switch/switchArea?area="+area, BaseResponse.class, null);
    }

    /**
     * az2切换
     *
     */
    @RequestMapping(value = "/switchAz2",method = RequestMethod.POST)
    @ResponseBody
    public BaseResponse switchAz2(String onlineOrGray) {
        return  httpRestClient.defaultGet( "/pch5Switch/switchAz2?onlineOrGray="+onlineOrGray, BaseResponse.class, null);
    }

    /**
     * az2-node host文件查询
     *
     */
    @RequestMapping(value = "/getAz2NodeHosts")
    @ResponseBody
    public BaseResponse getAz2NodeHosts() {
        return  httpRestClient.defaultGet( "/pch5Switch/getAz2NodeHosts", BaseResponse.class);
    }

    /**
     * 最近发布记录(success)
     *
     */
    @RequestMapping(value = "/getAzProjectLatestReleaseHistory")
    @ResponseBody
    public BaseResponse getAzProjectLatestReleaseHistory() {
        return  httpRestClient.defaultGet( "/pch5Switch/getAzProjectLatestReleaseHistory", BaseResponse.class);
    }

}