Authored by qinchao

线下店nginx切换

... ... @@ -8,6 +8,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import java.util.HashMap;
import java.util.Map;
/**
* 线下店的nginx切换
*
... ... @@ -46,4 +49,30 @@ public class StoreSwitchCtrl {
return httpRestClient.defaultGet( "/storeSwitch/getStoreNginxStatus", BaseResponse.class, null);
}
/**
* 切换结果预览
*
*/
@RequestMapping(value = "viewStoreNginxToChangeConf")
@ResponseBody
public BaseResponse viewStoreNginxToChangeConf(String serviceType, String onlineOrGray) {
Map<String, String> map=new HashMap<>();
map.put("serviceType",serviceType);
map.put("onlineOrGray",onlineOrGray);
return httpRestClient.defaultGet( "/storeSwitch/viewStoreNginxToChangeConf", BaseResponse.class, map);
}
/**
* 确定切换
*
*/
@RequestMapping(value = "switchStoreNginx")
@ResponseBody
public BaseResponse switchStoreNginx(String confContent) {
Map<String, String> map=new HashMap<>();
map.put("confContent",confContent);
return httpRestClient.defaultPost("/storeSwitch/switchStoreNginx",map,BaseResponse.class);
}
}
... ...
... ... @@ -180,8 +180,6 @@
* @param resp 切换后的响应数据
*/
function viewCurrentConf(data) {
/* console.log(resp);
var data = JSON.parse(resp);*/
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
size:"modal-lg",
... ... @@ -201,17 +199,103 @@
}
//线下店服务切换
function storeServiceSwitch(switchTarget) {
alert(switchTarget+"开发中");
function storeServiceSwitch(onlineOrGray) {
serviceSwitch("store","线下店服务",onlineOrGray);
}
//延展服务切换
function extendServiceSwitch(switchTarget) {
alert(switchTarget+"开发中");
function extendServiceSwitch(onlineOrGray) {
serviceSwitch("extend","延展服务",onlineOrGray);
}
function serviceSwitch(serviceType,serviceName,onlineOrGray){
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
title: "你确定切换吗",
backdrop: "static",
content: "你确定要将 "+serviceName+" 流量切向" + onlineOrGray + "吗?",
buttons: [{
text: "否",
className: "btn-danger",
onclick: function () {
dialog.dialog("hide");
}
}, {
text: "是",
className: "btn-success",
onclick: function () {
var param = {
serviceType: serviceType,
onlineOrGray: onlineOrGray
};
storeNginxConfToChangeView(param);
dialog.dialog("hide");
}
}]
});
}
//线下店服务,切换预览
function storeNginxConfToChangeView(paramFront) {
$.ajax({
type: "post",
url: contextPath+"/storeSwitch/viewStoreNginxToChangeConf",
data: paramFront,
dataType: "json",
success: function(resp){
nginxViewToChangeSuccess(resp);
},
error: function(){
layer.msg("获取线下店nginx配置信息异常", {icon: 2});
}
});
}
/**
* 打开对话框,展示切换后的配置
* @param resp 切换后的响应数据
*/
function nginxViewToChangeSuccess(resp) {
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
size:"modal-lg",
title: "切换结果预览",
backdrop: "static",
content: "<pre>" + resp.data + "</pre>",
buttons: [{
text: "否",
className: "btn-danger",
onclick: function () {
dialog.dialog("hide");
}
}, {
text: "再次确认",
className: "btn-success",
onclick: function () {
alert("开始切换");
$.ajax({
type: "post",
url: contextPath+"/storeSwitch/switchStoreNginx",
data: {
confContent:resp.data
},
dataType: "json",
success: function(resp){
},
error: function(){
layer.msg("切换nginx异常", {icon: 2});
}
});
}
}]
}).find(".modal-body").css({
height: "650px"
});
}
/**
* 展示画布 和 数据
* @param resp
... ...