feat:完成下载检查

This commit is contained in:
fanxb 2022-11-24 23:16:47 +08:00
parent 797268b13a
commit 4c6e78d5f4
12 changed files with 107 additions and 29 deletions

View File

@ -31,3 +31,4 @@ build/
### VS Code ###
.vscode/
/src/main/resources/application-local.yml

View File

@ -2,6 +2,7 @@ package com.fanxb.backend.controller;
import com.fanxb.backend.entity.ResultObject;
import com.fanxb.backend.entity.dto.ApplicationSignDto;
import com.fanxb.backend.entity.vo.ApplicationSignVo;
import com.fanxb.backend.service.ApplicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
@ -49,4 +50,15 @@ public class ApplicationController {
, @NotBlank(message = "key不能为空") String key, @NotBlank(message = "path不能为空") String path, @RequestParam(defaultValue = "false") boolean notAdd) throws IOException {
applicationService.visit(request, response, callBack, key, path, notAdd);
}
/**
* 检查key,secret是否存在
*
* @author fanxb
* date 2022/2/16 15:24
*/
@PostMapping("/check")
public ResultObject check(@Validated @RequestBody ApplicationSignVo body) {
return ResultObject.success(applicationService.check(body));
}
}

View File

@ -22,6 +22,18 @@ public interface HostDao {
@Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
void insertOne(HostPo host);
/**
* 检查key,secret是否存在
*
* @param key key
* @param secret secret
* @return boolean
* @author fanxb
* date 2022-11-24 23:06
*/
@Select("select count(1) from host where `key`=#{key} and secret=#{secret}")
boolean exist(@Param("key") String key, @Param("secret") String secret);
/**
* 根据key获取id
*

View File

@ -4,6 +4,8 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
/**
* 应用注册vo
*
@ -14,6 +16,8 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@AllArgsConstructor
public class ApplicationSignVo {
@NotBlank(message = "key不能为空")
private String key;
@NotBlank(message = "secret不能为空")
private String secret;
}

View File

@ -38,4 +38,14 @@ public interface ApplicationService {
* date 2022/2/16 10:20
*/
void visit(HttpServletRequest request, HttpServletResponse response, String callBack, String key, String path, boolean notAdd) throws IOException;
/**
* 检查key,secret是否存在
*
* @param body body
* @return boolean
* @author fanxb
* date 2022-11-24 23:05
*/
boolean check(ApplicationSignVo body);
}

View File

@ -75,6 +75,11 @@ public class ApplicationServiceImpl implements ApplicationService {
return new ApplicationSignVo(po.getKey(), po.getSecret());
}
@Override
public boolean check(ApplicationSignVo body) {
return hostDao.exist(body.getKey(), body.getSecret());
}
private static Pattern PATTERN = Pattern.compile("googlebot|bingbot|yandex|baiduspider|360Spider|Sogou Spider|Bytespider|twitterbot|facebookexternalhit|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest\\/0\\.|pinterestbot|slackbot|vkShare|W3C_Validator|whatsapp");
@Override

View File

@ -15,9 +15,10 @@
>
</noscript>
<div id="app"></div>
<div id="app" style="padding-top: 20vh"></div>
<!-- 页面PV -->
<div style="position: fixed; width: 100%; bottom: 0">
<div style="text-align: center">
<div id="qieziStatisticHtmlPost" style="display: none">当前页面访问次数:<span id="qieziStatisticHtmlPostPv"></span>&nbsp;</div>
</div>
@ -26,6 +27,7 @@
<div id="qieziStatisticHtmlHostPv" style="display: none">总访问次数:<span id="qieziStatisticHtmlHostPvValue"></span>&nbsp;</div>
<div id="qieziStatisticHtmlHostUv" style="display: none">&nbsp;总访客数:<span id="qieziStatisticHtmlHostUvValue"></span></div>
</div>
</div>
<script>
//设置实际部署的host和key
//window.qieziStatisticHost = "http://localhost:8080";

View File

@ -1,11 +1,9 @@
<template>
<router-view />
</template>
<script setup>
import { onMounted } from "@vue/runtime-core";
</script>
<style lang="less">

View File

@ -12,6 +12,11 @@ const routes = [
name: "ApplicationSign",
component: () => import("../views/ApplicationSign"),
},
{
path: "/download",
name: "DataDownload",
component: () => import("../views/download"),
},
];
const router = createRouter({

View File

@ -1,7 +1,7 @@
<template>
<div class="home">
<router-link to="/application/sign">应用注册</router-link><br />
<router-link to="/manage">应用管理</router-link>
<router-link to="/download">数据下载</router-link>
</div>
</template>

View File

@ -0,0 +1,47 @@
<template>
<div class="title">数据下载</div>
<a-form :model="form" :label-col="{ span: 4 }" :wrapper-col="{ span: 14 }" style="width: 80%; margin: 0 auto">
<a-form-item label="key">
<a-input type="text" v-model:value="form.key" />
</a-form-item>
<a-form-item label="secret">
<a-input type="text" v-model:value="form.secret" />
</a-form-item>
<a-form-item :wrapper-col="{ span: 14, offset: 4 }">
<a-button type="primary" @click="onSubmit">下载</a-button>
</a-form-item>
</a-form>
<a id="download" :href="'/download?key=' + form.key + '&secret=' + form.secret" download class="download-a">download</a>
</template>
<script setup>
import { ref, reactive } from "vue";
import { get, post } from "../../util/HttpUtil";
import { message } from "ant-design-vue";
let form = reactive({
key: "",
secret: "",
});
let keySecret = ref({});
let onSubmit = async () => {
let exist = await post("/application/check", null, form);
if (exist) {
document.getElementById("download").click();
} else {
message.error("key,secret不存在");
}
};
</script>
<style lang="less" scoped>
.title {
font-size: 2em;
font-weight: 600;
margin-bottom: 2em;
}
.download-a {
position: fixed;
left: -1000px;
}
</style>

View File

@ -1,18 +0,0 @@
<template>
<div>应用管理</div>
</template>
<script setup>
import { onMounted, ref, reactive } from "vue";
import { get, post } from "../util/HttpUtil";
</script>
<style lang="less" scoped>
.title {
font-size: 2em;
font-weight: 600;
}
.captchaItem {
display: flex;
}
</style>