修改直链 Key 时检测是否重复功能

This commit is contained in:
zhaojun1998
2021-03-10 21:41:14 +08:00
parent 3c88659679
commit 50ce1bb6db

View File

@@ -74,10 +74,14 @@ public class ShortLinkController {
}
@GetMapping("admin/api/short-link/key")
@ResponseBody
public ResultBean updateShortKey(Integer id, String newKey) {
ShortLinkConfig newShortLinkConfig = shortLinkConfigService.findByKey(newKey);
if (newShortLinkConfig != null) {
throw new RuntimeException("您输入的 Key 已存在,请重新输入");
}
ShortLinkConfig shortLinkConfig = shortLinkConfigService.findById(id);
if (shortLinkConfig == null) {
throw new RuntimeException("此直链不存在或已失效.");