Compare commits
5 Commits
054191d53a
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| b31082f5b5 | |||
| 755fa6ae52 | |||
| 237b379a08 | |||
| 20612d0945 | |||
| 3b71b59f38 |
@@ -33,4 +33,3 @@ build/
|
|||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
log
|
log
|
||||||
application-prod.properties
|
|
||||||
@@ -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.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
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 org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import top.naccl.dwz.annotation.AccessLimit;
|
import top.naccl.dwz.annotation.AccessLimit;
|
||||||
|
import top.naccl.dwz.entity.GenerateCmd;
|
||||||
import top.naccl.dwz.entity.R;
|
import top.naccl.dwz.entity.R;
|
||||||
import top.naccl.dwz.service.UrlService;
|
import top.naccl.dwz.service.UrlService;
|
||||||
import top.naccl.dwz.util.HashUtils;
|
import top.naccl.dwz.util.HashUtils;
|
||||||
@@ -27,7 +28,7 @@ public class IndexController {
|
|||||||
|
|
||||||
@Value("${server.host}")
|
@Value("${server.host}")
|
||||||
public void setHost(String host) {
|
public void setHost(String host) {
|
||||||
this.host = host;
|
IndexController.host = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
@@ -35,10 +36,11 @@ public class IndexController {
|
|||||||
return "index";
|
return "index";
|
||||||
}
|
}
|
||||||
|
|
||||||
@AccessLimit(seconds = 10, maxCount = 1, msg = "10秒内只能生成一次短链接")
|
// @AccessLimit(seconds = 10, maxCount = 1, msg = "10秒内只能生成一次短链接")
|
||||||
@PostMapping("/generate")
|
@PostMapping("/generate")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public R generateShortURL(@RequestParam String longURL) {
|
public R generateShortURL(@RequestBody GenerateCmd cmd) {
|
||||||
|
String longURL = cmd.getLongURL();
|
||||||
if (UrlUtils.checkURL(longURL)) {
|
if (UrlUtils.checkURL(longURL)) {
|
||||||
if (!longURL.startsWith("http")) {
|
if (!longURL.startsWith("http")) {
|
||||||
longURL = "http://" + longURL;
|
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.port=8060
|
||||||
server.host=http://localhost:8060/
|
server.host=http://localhost1:8060/
|
||||||
|
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
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.username=root
|
||||||
spring.datasource.password=root
|
spring.datasource.password=root
|
||||||
|
|
||||||
spring.redis.host=192.168.17.132
|
spring.redis.host=192.168.10.200
|
||||||
spring.redis.password=123456
|
spring.redis.password=
|
||||||
spring.redis.port=6379
|
spring.redis.port=6379
|
||||||
spring.redis.database=1
|
spring.redis.database=15
|
||||||
spring.redis.timeout=10000ms
|
spring.redis.timeout=10000ms
|
||||||
|
|
||||||
mybatis.mapper-locations=classpath:mapper/*.xml
|
mybatis.mapper-locations=classpath:mapper/*.xml
|
||||||
@@ -17,4 +17,4 @@ mybatis.configuration.map-underscore-to-camel-case=true
|
|||||||
|
|
||||||
logging.level.root=info
|
logging.level.root=info
|
||||||
logging.level.top.naccl.dwz=debug
|
logging.level.top.naccl.dwz=debug
|
||||||
logging.file.name=./log/dwz
|
logging.file.name=./log/dwz
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
server.port=8060
|
||||||
|
server.host=http://123bs.top/
|
||||||
|
|
||||||
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
|
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/dwz?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
|
||||||
|
spring.datasource.username=root
|
||||||
|
spring.datasource.password=4730da9b
|
||||||
|
|
||||||
|
spring.redis.host=127.0.0.1
|
||||||
|
spring.redis.password=guozinengliang
|
||||||
|
spring.redis.port=6379
|
||||||
|
spring.redis.database=15
|
||||||
|
spring.redis.timeout=10000ms
|
||||||
|
|
||||||
|
mybatis.mapper-locations=classpath:mapper/*.xml
|
||||||
|
mybatis.configuration.map-underscore-to-camel-case=true
|
||||||
|
|
||||||
|
logging.level.root=info
|
||||||
|
logging.level.top.naccl.dwz=debug
|
||||||
|
logging.file.name=./log/dwz
|
||||||
File diff suppressed because one or more lines are too long
+2
File diff suppressed because one or more lines are too long
@@ -23,23 +23,31 @@
|
|||||||
<button type="button" id="copy" style="width:100px;" data-clipboard-action="copy" data-clipboard-target="#short">Copy</button>
|
<button type="button" id="copy" style="width:100px;" data-clipboard-action="copy" data-clipboard-target="#short">Copy</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script>
|
<script src="/js/jquery.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js"></script>
|
<script src="/js/clipboard.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$('#generate').click(() => {
|
$('#generate').click(() => {
|
||||||
let longURL = $('#long').val();
|
let longURL = $('#long').val();
|
||||||
if (longURL) {
|
if (longURL) {
|
||||||
$.post("/generate", {
|
$.ajax({
|
||||||
longURL
|
url: "/generate",
|
||||||
}, function (res) {
|
type: "POST",
|
||||||
if (res.code === 200) {
|
contentType: "application/json",
|
||||||
$('#short').val(res.data);
|
data: JSON.stringify({
|
||||||
} else {
|
longURL: longURL
|
||||||
alert(res.msg);
|
}),
|
||||||
}
|
dataType: "json",
|
||||||
}, "json").fail(() => {
|
success: function (res) {
|
||||||
alert('异常错误');
|
if (res.code === 200) {
|
||||||
});
|
$('#short').val(res.data);
|
||||||
|
} else {
|
||||||
|
alert(res.msg);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
alert('异常错误');
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
alert('请输入原始链接');
|
alert('请输入原始链接');
|
||||||
}
|
}
|
||||||
@@ -54,4 +62,4 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user