Compare commits

...

5 Commits

Author SHA1 Message Date
Loki 16d456130d 🔥 init 2025-02-25 18:27:15 +08:00
Naccl 755fa6ae52 fix 2023-07-16 00:45:05 +08:00
Naccl 237b379a08 Merge branch 'remote' 2023-07-04 16:59:13 +08:00
Naccl Lu 20612d0945 Update README.md 2022-11-06 20:09:06 +08:00
Naccl 3b71b59f38 refactor: cdn.jsdelivr.net -> local 2022-06-08 20:43:45 +08:00
7 changed files with 61 additions and 30 deletions
-6
View File
@@ -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
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+14 -6
View File
@@ -23,22 +23,30 @@
<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",
contentType: "application/json",
data: JSON.stringify({
longURL: longURL
}),
dataType: "json",
success: function (res) {
if (res.code === 200) { if (res.code === 200) {
$('#short').val(res.data); $('#short').val(res.data);
} else { } else {
alert(res.msg); alert(res.msg);
} }
}, "json").fail(() => { },
error: function () {
alert('异常错误'); alert('异常错误');
}
}); });
} else { } else {
alert('请输入原始链接'); alert('请输入原始链接');