1.问题描述
点击恢复调用的js代码:
$('.shopauth-wrap')
.on(
'click',
'a',
function(e) {
var target = $(e.currentTarget);
if (target.hasClass('edit')) {
window.location.href = '/o2o/shopadmin/shopauthedit?shopAuthId='
+ e.currentTarget.dataset.authId;
} else if (target.hasClass('status')) {
changeStatus(e.currentTarget.dataset.authId,
e.currentTarget.dataset.status);
}
});
function changeStatus(id, status) {
var shopAuth = {};
shopAuth.shopAuthId = id;
shopAuth.enableStatus = status
$.confirm('确定么?', function() {
$.ajax({
url : modifyUrl,
type : 'POST',
data : {
// 将json参数转化为字符串
shopAuthMapStr : JSON.stringify(shopAuth),
statusChange : true
},
dataType : 'json',
success : function(data) {
if (data.success) {
$.toast('操作成功!');
getList();
} else {
$.toast('操作失败!');
}
}
});
});
}
这里的流程是:
- step1.修改后会修改数据,使用的主库
- step2.成功后,会调用getList()重新读取新的状态,使用的是从库
2019-11-25 23:40:21.110 [http-apr-8080-exec-5] DEBUG c.imooc.o2o.dao.split.DynamicDataSourceInterceptor 设置方法[com.imooc.o2o.dao.ShopAuthMapDao.updateShopAuthMap] use [master] Strategy, SqlCommanType [UPDATE]..
2019-11-25 23:40:21.110 [http-apr-8080-exec-5] DEBUG com.imooc.o2o.dao.split.DynamicDataSourceHolder 所使用的数据源为:master
2019-11-25 23:40:21.190 [http-apr-8080-exec-6] DEBUG c.imooc.o2o.dao.split.DynamicDataSourceInterceptor 设置方法[com.imooc.o2o.dao.ShopAuthMapDao.queryShopAuthMapListByShopId] use [slave] Strategy, SqlCommanType [SELECT]..
2019-11-25 23:40:21.191 [http-apr-8080-exec-6] DEBUG com.imooc.o2o.dao.split.DynamicDataSourceHolder 所使用的数据源为:slave
问题:这是从库的状态还未与主库状态一致,所以会导致页面出现错误!
2.验证
将从库改为主库一致会发现页面能即使改变











网友评论