deploy:部署

This commit is contained in:
fanxb 2022-02-28 15:53:55 +08:00
parent 13898e190f
commit 55f7e7c84f
4 changed files with 47 additions and 43 deletions

View File

@ -84,21 +84,20 @@ public class ApplicationServiceImpl implements ApplicationService {
}
int hostId = getHostId(key);
HostPo uvPvData = hostDao.getUvPvById(hostId);
DetailPagePo detailUvPvData = detailPageDao.getUvPvById(hostId, path);
if (detailUvPvData == null) {
detailUvPvData = new DetailPagePo().setHostId(hostId).setPath(path).setUv(1).setPv(1);
HostPo hostData = hostDao.getUvPvById(hostId);
DetailPagePo detailData = detailPageDao.getUvPvById(hostId, path);
if (detailData == null) {
detailData = new DetailPagePo().setHostId(hostId).setPath(path).setUv(0).setPv(0);
}
UvPvVo uvPvVo = new UvPvVo(uvPvData.getUv(), uvPvData.getPv(), detailUvPvData.getUv(), detailUvPvData.getPv());
//数据计算更新
updateData(NetUtil.getClientIp(request), hostData, detailData);
//写出
UvPvVo uvPvVo = new UvPvVo(hostData.getUv(), hostData.getPv(), detailData.getUv(), detailData.getPv());
String uvPvVoStr = JSON.toJSONString(uvPvVo);
String res = String.format("try{%s(%s);}catch(e){console.error(e);console.log(%s)}", callBack, uvPvVoStr, uvPvVoStr);
response.setHeader(Header.CONTENT_TYPE.getValue(), ContentType.JSON.getValue());
response.getOutputStream().write(res.getBytes(StandardCharsets.UTF_8));
response.getOutputStream().flush();
//异步数据更新
DetailPagePo finalDetailUvPvData = detailUvPvData;
ThreadPoolUtil.execute(() -> updateData(NetUtil.getClientIp(request), uvPvData, finalDetailUvPvData));
}
/**
@ -111,24 +110,30 @@ public class ApplicationServiceImpl implements ApplicationService {
* date 2022/2/16 15:40
*/
private void updateData(String ip, HostPo hostPo, DetailPagePo detailPagePo) {
String hostKey = RedisConstant.HOST_UV_PRE + hostPo.getId() + ip;
String hostKey = RedisConstant.HOST_UV_PRE + hostPo.getId() + "_" + ip;
String hostVal = stringRedisTemplate.opsForValue().get(hostKey);
hostDao.updateUvPv(hostPo.getId(), hostVal == null ? 1 : 0);
hostPo.setPv(hostPo.getPv() + 1);
long tomorrowZero = LocalDate.now().plusDays(1).atStartOfDay().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
if (hostVal == null) {
stringRedisTemplate.opsForValue().set(hostKey, "", tomorrowZero - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
hostPo.setUv(hostPo.getUv() + 1);
}
String pageKey = RedisConstant.PAGE_UV_PRE + hostPo.getId() + ip + detailPagePo.getPath();
String pageVal = stringRedisTemplate.opsForValue().get(pageKey);
if (detailPagePo.getId() == null) {
detailPageDao.insertOne(detailPagePo);
} else {
detailPageDao.updateUvPv(detailPagePo.getId(), pageVal == null ? 1 : 0);
}
detailPagePo.setPv(detailPagePo.getPv() + 1);
if (pageVal == null) {
stringRedisTemplate.opsForValue().set(pageKey, "", tomorrowZero - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
detailPagePo.setUv(detailPagePo.getUv() + 1);
}
//异步更新sql
ThreadPoolUtil.execute(() -> {
hostDao.updateUvPv(hostPo.getId(), hostVal == null ? 1 : 0);
if (detailPagePo.getId() == null) {
detailPageDao.insertOne(detailPagePo);
} else {
detailPageDao.updateUvPv(detailPagePo.getId(), pageVal == null ? 1 : 0);
}
});
}
/**

View File

@ -4,15 +4,15 @@
var callback = name + "CallBack";
window[callback] = function (a) {
var hostPvNode = document.getElementById(name + "HostPv");
if (hostNode != null) {
if (hostPvNode != null) {
document.getElementById(name + "HostPvValue").innerText = a.totalPv;
hostNode.style.display = "inline";
hostPvNode.style.display = "inline";
}
var hostUvNode = document.getElementById(name + "HostUv");
if (hostNode != null) {
document.getElementById(name + "HostUvValue").innerText = a.totalPv;
hostNode.style.display = "inline";
if (hostUvNode != null) {
document.getElementById(name + "HostUvValue").innerText = a.totalUv;
hostUvNode.style.display = "inline";
}
var postNode = document.getElementById(name + "Post");
@ -37,14 +37,14 @@
}
var key = null;
if (window.qieziStatisticKey && window.qieziStatisticKey.trim().length > 0) {
requestHost = window.qieziStatisticKey;
key = window.qieziStatisticKey;
} else if (window.CONFIG && window.CONFIG.web_analytics.qieziStatistics.app_key) {
var temp = window.CONFIG.web_analytics.qieziStatistics.app_key;
if (temp.trim().length > 0) {
key = temp;
}
}
console.Console(requestHost, key);
console.log(requestHost, key);
if (!key) {
return;
}

View File

@ -1,2 +1 @@
eval(function(e,f,a,d,c,g){c=function(b){return(b<f?"":c(parseInt(b/f)))+(35<(b%=f)?String.fromCharCode(b+29):b.toString(36))};if(!"".replace(/^/,String)){for(;a--;)g[c(a)]=d[a]||c(a);d=[function(b){return g[b]}];c=function(){return"\\w+"};a=1}for(;a--;)d[a]&&(e=e.replace(new RegExp("\\b"+c(a)+"\\b","g"),d[a]));return e}('(6(){3 d="m";3 e=d+"n";4[e]=6(a){3 b=2.5(d+"o");8(b!=9){2.5(d+"p").7=a.q;2.5(d+"r").7=a.s;b.f.g="h"}3 c=2.5(d+"t");8(c!=9){2.5(d+"u").7=a.v;c.f.g="h"}};w(6(){3 a=2.x("y");a.z="A/B";a.C=D;a.E=(4.i==j?"F://k.G.H":4.i)+"/k/I/J/K?L="+e+"&M="+4.l;2.N("O")[0].P(a)},4.l==j?Q:1,)})();',
53,53," document var window getElementById function innerText if null style display inline qieziStatisticHost undefined qiezi qieziStatisticKey qieziStatistic9527 CallBack Host HostPv totalPv HostUv totalUv Post PostPv pagePv setTimeout createElement script type text javascript defer true src https fleyx com api application visit callBack key getElementsByTagName head appendChild 1000".split(" "),0,{}));
(function(){var name="qieziStatisticHtml";var callback=name+"CallBack";window[callback]=function(a){var hostPvNode=document.getElementById(name+"HostPv");if(hostPvNode!=null){document.getElementById(name+"HostPvValue").innerText=a.totalPv;hostPvNode.style.display="inline"}var hostUvNode=document.getElementById(name+"HostUv");if(hostUvNode!=null){document.getElementById(name+"HostUvValue").innerText=a.totalUv;hostUvNode.style.display="inline"}var postNode=document.getElementById(name+"Post");if(postNode!=null){document.getElementById(name+"PostPv").innerText=a.pagePv;postNode.style.display="inline"}};setTimeout(function(){var script=document.createElement("script");script.type="text/javascript";script.defer=true;var requestHost="https://qiezi.fleyx.com";if(window.qieziStatisticHost!=undefined&&window.qieziStatisticHost.trim().length>0){requestHost=window.qieziStatisticHost}else if(window.CONFIG&&window.CONFIG.web_analytics.qieziStatistics.app_host){var temp=window.CONFIG.web_analytics.qieziStatistics.app_host;if(temp.trim().length>0){requestHost=temp}}var key=null;if(window.qieziStatisticKey&&window.qieziStatisticKey.trim().length>0){key=window.qieziStatisticKey}else if(window.CONFIG&&window.CONFIG.web_analytics.qieziStatistics.app_key){var temp=window.CONFIG.web_analytics.qieziStatistics.app_key;if(temp.trim().length>0){key=temp}}console.log(requestHost,key);if(!key){return}script.src=requestHost+"/qiezi/api/application/visit?callBack="+callback+"&key="+window.qieziStatisticKey;document.getElementsByTagName("head")[0].appendChild(script)},window.qieziStatisticKey==undefined?1000:1,)})();

View File

@ -1,20 +1,20 @@
//本地开发时使用,打包部署时请使用环境变量配置
//process.env.VUE_APP_QIEZI_HOST = "http://localhost:8080";
//process.env.VUE_APP_QIEZI_KEY = "aab3cad381f54ca5b7b9abeb2e09320a";
// process.env.VUE_APP_QIEZI_HOST = "http://localhost:8081";
// process.env.VUE_APP_QIEZI_KEY = "d862c12a68ad4d579c6066ac2f064a07";
module.exports = {
publicPath:"/manage",
devServer: {
proxy: {
"/qiezi/api": {
//这里最好有一个 /
target: "http://localhost:8088", // 服务器端接口地址
ws: true, //如果要代理 websockets配置这个参数
// 如果是https接口需要配置这个参数
changeOrigin: true, //是否跨域
pathRewrite: {
"^/qiezi/api": "/qiezi/api",
},
},
},
},
publicPath: "/manage",
devServer: {
proxy: {
"/qiezi/api": {
//这里最好有一个 /
target: "http://localhost:8088", // 服务器端接口地址
ws: true, //如果要代理 websockets配置这个参数
// 如果是https接口需要配置这个参数
changeOrigin: true, //是否跨域
pathRewrite: {
"^/qiezi/api": "/qiezi/api",
},
},
},
},
};