Authored by zhengyouwei

udid 和 开关

... ... @@ -224,6 +224,10 @@ public class HttpUriContants {
public static final String ABTEST_TOTAL_GETALLTYPES= "/abtestTotal/getAllTypes";
public static final String ABTEST_TOTAL_FLUSH= "/abtestTotal/flush";
public static final String ABTEST_TOTAL_GETZOOKEEPJSON= "/abtestTotal/getZookeepConfig";
public static final String ABTEST_TOTAL_TESTUDID= "/abtestTotal/testUdid";
public static final String ABTEST_TOTAL_GETSWITCHSTATUS= "/abtestTotal/getSwitchStatus";
public static final String ABTEST_TOTAL_SWITCHSTATUS= "/abtestTotal/switchStatus";
public static final String INTERNAL_DOMAIN_INSERT = "/internalDns/insert";
public static final String INTERNAL_DOMAIN_UPDATE = "/internalDns/update";
... ...
... ... @@ -34,7 +34,8 @@ public class ABTestTotalCtrl {
@RequestMapping("/toABTestTotal")
@ResponseBody
public ModelAndView toABTets(Model model) {
BaseResponse response = httpRestClient.defaultPost(HttpUriContants.ABTEST_TOTAL_GETSWITCHSTATUS, null, BaseResponse.class);
model.addAttribute("switchStatus",response.getData());
return new ModelAndView("abtest/abtestTotal");
}
... ... @@ -90,7 +91,7 @@ public class ABTestTotalCtrl {
@RequestMapping("/getTotal")
@ResponseBody
public BaseResponse get(int id) {
BaseResponse response = httpRestClient.defaultPost(HttpUriContants.ABTEST_TOTAL_GETBYID+"?id="+id, null, BaseResponse.class);
BaseResponse response = httpRestClient.defaultPost(HttpUriContants.ABTEST_TOTAL_GETBYID + "?id=" + id, null, BaseResponse.class);
return response;
}
... ... @@ -102,9 +103,23 @@ public class ABTestTotalCtrl {
}
@RequestMapping("/getZookeepConfig")
public ModelAndView getZookeepConfig(String type,Model model) {
BaseResponse response = httpRestClient.defaultPost(HttpUriContants.ABTEST_TOTAL_GETZOOKEEPJSON+"?type="+type, null, BaseResponse.class);
model.addAttribute("bodyString",response.getData());
public ModelAndView getZookeepConfig(String type, Model model) {
BaseResponse response = httpRestClient.defaultPost(HttpUriContants.ABTEST_TOTAL_GETZOOKEEPJSON + "?type=" + type, null, BaseResponse.class);
model.addAttribute("bodyString", response.getData());
return new ModelAndView("abtest/abtest_json");
}
@RequestMapping("/testUdid")
@ResponseBody
public BaseResponse testUdid(String udid) {
BaseResponse response = httpRestClient.defaultPost(HttpUriContants.ABTEST_TOTAL_TESTUDID + "?udid=" + udid, null, BaseResponse.class);
return response;
}
@RequestMapping("/switchStatus")
@ResponseBody
public BaseResponse switchStatus(String operate) {
BaseResponse response = httpRestClient.defaultPost(HttpUriContants.ABTEST_TOTAL_SWITCHSTATUS + "?operate=" + operate, null, BaseResponse.class);
return response;
}
}
... ...
... ... @@ -80,9 +80,25 @@
  
<a href="#" id="addABConfig" class="btn btn-success" style="margin-top: 12px;margin-left: 0px;"
onclick="editConfig(0)">新增配置</a>
&nbsp;&nbsp; &nbsp;&nbsp;
<a href="#" id="flushConfig" class="btn btn-success" style="margin-top: 12px;margin-left: 0px;"
onclick="flushConfig()">刷新配置到zookeeper</a></div>
&nbsp;&nbsp; &nbsp;&nbsp;
<a href="#" id="flushConfig" class="btn btn-success" style="margin-top: 12px;margin-left: 0px;"
onclick="flushConfig()">刷新配置到zookeeper</a>
&nbsp;&nbsp; &nbsp;&nbsp;
<a href="#" id="testUdidButton" class="btn btn-success"
style="margin-top: 12px;margin-left: 0px;"
onclick="testUdidBefore()">查看udid所属版本</a>
&nbsp;&nbsp; &nbsp;&nbsp;
<c:if test="${switchStatus == 'true'}">
<a href="#" class="btn btn-warning"
style="margin-top: 12px;margin-left: 0px;"
onclick="switchStatus('close')">关闭B版本</a>
</c:if>
<c:if test="${switchStatus == 'false'}">
<a href="#" class="btn btn-primary"
style="margin-top: 12px;margin-left: 0px;"
onclick="switchStatus('open')">开启B版本</a>
</c:if>
</div>
</div>
</div>
<div id="abtestTable">
... ... @@ -135,29 +151,29 @@
<label class="col-sm-2 control-label"> <span style="color:red">*</span>是否使用:</label>
<div class="col-sm-8">
<input type="radio" name="inUse" value="1"/> 使用
<input type="radio" name="inUse" value="0"/> 禁止
<input type="radio" name="inUse" value="1"/> 使用
<input type="radio" name="inUse" value="0"/> 禁止
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"> <span style="color:red">*</span>适用客户端:</label>
<div class="col-sm-8">
<input type="checkbox" name="appType" value="iphone"/> iphone
<input type="checkbox" name="appType" value="android"/> android
<input type="checkbox" name="appType" value="h5"/> H5
<input type="checkbox" name="appType" value="pc"/> PC
<input type="checkbox" name="appType" value="iphone"/> iphone
<input type="checkbox" name="appType" value="android"/> android
<input type="checkbox" name="appType" value="h5"/> H5
<input type="checkbox" name="appType" value="pc"/> PC
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"> <span style="color:red">*</span>最低APP版本:</label>
<label class="col-sm-2 control-label"> <span style="color:red">*</span>最低APP版本:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="appVersion" name="appVersion"
placeholder="5.2.0" maxlength="30" size="40"/>
<div class="col-sm-8">
<input type="text" class="form-control" id="appVersion" name="appVersion"
placeholder="5.2.0" maxlength="30" size="40"/>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"> </label>
... ... @@ -175,6 +191,44 @@
</div>
<!-- /.modal -->
</div>
<div class="modal fade" id="testUdidmyModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">&times;</button>
<h4 class="modal-title" id="testUdidmyModalLabel"></h4>
</div>
<div class="modal-body">
<form id="testUdidconfigForm" class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label"> <span style="color:red">*</span>UDID:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="testudid" name="testudid" size="40"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"> </label>
<div class="col-sm-8" id="testUdidmessageAlert"></div>
</div>
<input type="hidden" name="editId"/>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-success" value="Validate" onclick="testUdid()">提交</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->
</div>
<script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
<script type="text/javascript">
$("#li_appConfig").addClass("active open");
... ... @@ -212,30 +266,30 @@
title: "取模开始值",
field: "moduloNumStart",
width: "10%"
}, {
}, {
title: "取模结束值",
field: "moduloNumEnd",
width: "10%"
}, {
title: "是否使用",
field: "inUse",
formatter : function(value, rowData, rowIndex) {
if(value == 1){
formatter: function (value, rowData, rowIndex) {
if (value == 1) {
return '是';
}else{
} else {
return '否';
}
},
width: "10%"
},{
}, {
title: "APP类型",
field: "appType",
width: "15%"
},{
}, {
title: "操作",
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
if(rowData.type != 'A'){
if (rowData.type != 'A') {
$("<button onclick=\"editConfig(\'" + rowData.id + "\')\">").addClass("btn btn-xs btn-success").html("修改").appendTo(div);
div.append("&nbsp;");
$("<button onclick=\"deleteConfig(\'" + rowData.id + "\')\">").addClass("btn btn-xs btn-danger").html("删除").appendTo(div);
... ... @@ -253,7 +307,7 @@
function editConfig(id) {
$("#configForm #messageAlert").hide();
if (id == 0) {//新增页面
$("input[name='type']").attr("readonly",false);
$("input[name='type']").attr("readonly", false);
$("input[name='editId']").val(0);
$("input[name='type']").val("");
... ... @@ -264,11 +318,11 @@
$("input[name='appVersion']").val("");
$("#myModalLabel").text("新增");
} else {
$("input[name='type']").attr("readonly",true);
$("input[name='type']").attr("readonly", true);
$("#myModalLabel").text("修改");
$.ajax({
type: 'post',
url: contextPath + "/abtestTotal/getTotal?id="+id,
url: contextPath + "/abtestTotal/getTotal?id=" + id,
dataType: 'json',
success: function (data) {
if (!data || data.code != 200) {
... ... @@ -278,12 +332,12 @@
$("input[name='type']").val(data.data.type);
$("input[name='moduloNumStart']").val(data.data.moduloNumStart);
$("input[name='moduloNumEnd']").val(data.data.moduloNumEnd);
$("input[name='inUse'][value='"+data.data.inUse+"']").prop("checked", true);
$("input[name='inUse'][value='" + data.data.inUse + "']").prop("checked", true);
$("input[name='appType']").attr("checked", false);
var appTypes = data.data.appType.split(",");
for(i=0;i<appTypes.length;i++){
$("input[name='appType'][value='"+appTypes[i]+"']").prop("checked",true);
for (i = 0; i < appTypes.length; i++) {
$("input[name='appType'][value='" + appTypes[i] + "']").prop("checked", true);
}
$("input[name='appVersion']").val(data.data.appVersion);
... ... @@ -305,7 +359,7 @@
var inUse = $("input[name='inUse']:checked").val();
var appTypes = "";
$('input[name="appType"]:checked').each(function () {
appTypes= appTypes + $(this).val() +",";
appTypes = appTypes + $(this).val() + ",";
});
var appVersion = $("#appVersion").val();
... ... @@ -356,7 +410,7 @@
id: id,
type: type,
inUse: inUse,
appType: appTypes.substr(0,appTypes.length-1),
appType: appTypes.substr(0, appTypes.length - 1),
appVersion: appVersion,
moduloNumStart: moduloNumStart,
moduloNumEnd: moduloNumEnd
... ... @@ -439,7 +493,7 @@
async: false,
dataType: "json",
success: function (data) {
localAlert('刷新结果', '刷新成功');
localAlert('刷新结果', '刷新成功');
}
});
}
... ... @@ -448,13 +502,72 @@
}
function aHref(abtype) {
var iWidth=800; //弹出窗口的宽度;
var iHeight=600; //弹出窗口的高度;
var iTop = (window.screen.availHeight-30-iHeight)/2; //获得窗口的垂直位置;
var iLeft = (window.screen.availWidth-10-iWidth)/2; //获得窗口的水平位置;
window.open(contextPath + "/abtestTotal/getZookeepConfig?type="+abtype,"","height="+iHeight+", width="+iWidth+", top="+iTop+", left="+iLeft);
var iWidth = 800; //弹出窗口的宽度;
var iHeight = 600; //弹出窗口的高度;
var iTop = (window.screen.availHeight - 30 - iHeight) / 2; //获得窗口的垂直位置;
var iLeft = (window.screen.availWidth - 10 - iWidth) / 2; //获得窗口的水平位置;
window.open(contextPath + "/abtestTotal/getZookeepConfig?type=" + abtype, "", "height=" + iHeight + ", width=" + iWidth + ", top=" + iTop + ", left=" + iLeft);
}
function testUdidBefore() {
$("#testudid").val("");
$("#testUdidmyModal").modal('show');
}
function testUdid() {
var udid = $("#testudid").val();
if (udid == null || udid == "") {
$("#testUdidconfigForm #testUdidmessageAlert").alerts({
content: "请填写UDID!",
type: "danger"
});
return;
}
$.ajax({
type: 'post',
url: contextPath + "/abtestTotal/testUdid?udid=" + udid,
dataType: 'json',
success: function (data) {
$("#testUdidmyModal").modal('hide');
localAlert('测试结果', data.data);
},
error: function (data) {
$("#testUdidmyModal").modal('hide');
localAlert('系统异常', data.message);
}
});
}
function switchStatus(operate) {
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
title: "confirm",
backdrop: "static",
content: "你确定要切换开关吗",
buttons: [{
text: "否",
className: "btn-danger",
onclick: function () {
$(dialog).dialog("hide");
}
}, {
text: "是",
className: "btn-success",
onclick: function () {
$(dialog).dialog("hide");
$.ajax({
url: contextPath + "/abtestTotal/switchStatus?operate=" + operate,
type: 'post',
async: false,
dataType: "json",
success: function (data) {
window.location.reload();
}
});
}
}]
});
}
</script>
 
\ No newline at end of file
... ...