Compare commits
5 Commits
054191d53a
...
16d456130d
| Author | SHA1 | Date | |
|---|---|---|---|
| 16d456130d | |||
| 755fa6ae52 | |||
| 237b379a08 | |||
| 20612d0945 | |||
| 3b71b59f38 |
@@ -34,9 +34,3 @@ Redis:生成短链接后,通常在后续一段时间内此短链接的使用
|
||||
|
||||
本在线网站只用于项目展示,随时可能关闭,并不保证绝对的可用性,切勿用于商业用途或非法传播,因此产生的任何纠纷与本人无关。
|
||||
|
||||
|
||||
|
||||
被刷数据也快习惯了,几千条也就算了,这次的 80 万条是在帮我做压测吗😅
|
||||
|
||||
如果是的话,请把结果在 Issues 里分享一下,否则可能会变得不幸,甚至会变成猫猫🐱
|
||||
|
||||
|
||||
@@ -6,9 +6,10 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import top.naccl.dwz.annotation.AccessLimit;
|
||||
import top.naccl.dwz.entity.GenerateCmd;
|
||||
import top.naccl.dwz.entity.R;
|
||||
import top.naccl.dwz.service.UrlService;
|
||||
import top.naccl.dwz.util.HashUtils;
|
||||
@@ -27,7 +28,7 @@ public class IndexController {
|
||||
|
||||
@Value("${server.host}")
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
IndexController.host = host;
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
@@ -35,10 +36,11 @@ public class IndexController {
|
||||
return "index";
|
||||
}
|
||||
|
||||
@AccessLimit(seconds = 10, maxCount = 1, msg = "10秒内只能生成一次短链接")
|
||||
// @AccessLimit(seconds = 10, maxCount = 1, msg = "10秒内只能生成一次短链接")
|
||||
@PostMapping("/generate")
|
||||
@ResponseBody
|
||||
public R generateShortURL(@RequestParam String longURL) {
|
||||
public R generateShortURL(@RequestBody GenerateCmd cmd) {
|
||||
String longURL = cmd.getLongURL();
|
||||
if (UrlUtils.checkURL(longURL)) {
|
||||
if (!longURL.startsWith("http")) {
|
||||
longURL = "http://" + longURL;
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package top.naccl.dwz.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Naccl
|
||||
* @date 2023-07-16
|
||||
*/
|
||||
@Builder
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class GenerateCmd {
|
||||
private String longURL;
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
server.port=8060
|
||||
server.host=http://localhost:8060/
|
||||
server.host=http://localhost1:8060/
|
||||
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/dwz?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
|
||||
spring.datasource.url=jdbc:mysql://192.168.10.200:3306/dwz?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=root
|
||||
|
||||
spring.redis.host=192.168.17.132
|
||||
spring.redis.password=123456
|
||||
spring.redis.host=192.168.10.200
|
||||
spring.redis.password=
|
||||
spring.redis.port=6379
|
||||
spring.redis.database=1
|
||||
spring.redis.database=15
|
||||
spring.redis.timeout=10000ms
|
||||
|
||||
mybatis.mapper-locations=classpath:mapper/*.xml
|
||||
|
||||
File diff suppressed because one or more lines are too long
+2
File diff suppressed because one or more lines are too long
@@ -23,22 +23,30 @@
|
||||
<button type="button" id="copy" style="width:100px;" data-clipboard-action="copy" data-clipboard-target="#short">Copy</button>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js"></script>
|
||||
<script src="/js/jquery.min.js"></script>
|
||||
<script src="/js/clipboard.min.js"></script>
|
||||
<script>
|
||||
$('#generate').click(() => {
|
||||
let longURL = $('#long').val();
|
||||
if (longURL) {
|
||||
$.post("/generate", {
|
||||
longURL
|
||||
}, function (res) {
|
||||
$.ajax({
|
||||
url: "/generate",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({
|
||||
longURL: longURL
|
||||
}),
|
||||
dataType: "json",
|
||||
success: function (res) {
|
||||
if (res.code === 200) {
|
||||
$('#short').val(res.data);
|
||||
} else {
|
||||
alert(res.msg);
|
||||
}
|
||||
}, "json").fail(() => {
|
||||
},
|
||||
error: function () {
|
||||
alert('异常错误');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
alert('请输入原始链接');
|
||||
|
||||
Reference in New Issue
Block a user