Skip to content

Commit 74b801f

Browse files
committed
进行一些调整
1 parent f2bf55c commit 74b801f

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

src/main/java/com/ghostchu/tracker/sapling/dto/RegFormDTO.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ public class RegFormDTO {
1919
@Email(message = "邮箱格式不正确")
2020
private String email;
2121

22-
@Pattern(regexp = "^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,}$",
23-
message = "密码必须至少8个字符,包含字母和数字")
22+
@Size(min = 3, max = 64, message = "密码长度需在3-64个字符之间")
2423
private String password;
2524
private String confirmPassword;
2625
private String inviteCode;

src/main/java/com/ghostchu/tracker/sapling/service/impl/TorrentsServiceImpl.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,13 @@ public TorrentsVO toVO(Torrents torrent) {
9696

9797
@Override
9898
public boolean isTorrentExists(byte[] infoHash) {
99-
return baseMapper.selectCount(new QueryWrapper<Torrents>().eq("hash_v1", infoHash).or().eq("hash_v2", infoHash)) > 0;
99+
return baseMapper.selectCount(new QueryWrapper<Torrents>()
100+
.eq("hash_v1", infoHash)
101+
.and(q -> q.eq("deleted_at", null))
102+
.or()
103+
.eq("hash_v2", infoHash)
104+
.and(q -> q.eq("deleted_at", null))
105+
) > 0;
100106
}
101107

102108
@Override
@@ -185,8 +191,13 @@ public Torrents updateTorrent(Long id, Long userId, Long categoryId, String titl
185191
public Torrents getTorrentByInfoHash(byte[] infoHash) {
186192
return getOne(new QueryWrapper<Torrents>()
187193
.eq("hash_v1", infoHash)
194+
.and(q -> q.eq("deleted_at", null))
195+
.or()
196+
.eq("hash_v2_short", infoHash)
197+
.and(q -> q.eq("deleted_at", null))
188198
.or()
189-
.eq("hash_v2_short", infoHash));
199+
.eq("hash_v2", infoHash)
200+
.and(q -> q.eq("deleted_at", null)));
190201
}
191202

192203
@Override
@@ -211,6 +222,9 @@ public Torrents deleteTorrent(long id, long deleteBy) {
211222
})
212223
public Torrents unDeleteTorrent(long id) {
213224
Torrents torrents = baseMapper.selectById(id);
225+
if(isTorrentExists(torrents.getHashV1()) || isTorrentExists(torrents.getHashV2())) {
226+
throw new IllegalArgumentException("反删除操作失败,种子已经反删除或者已有相同 InfoHash 值的种子存在");
227+
}
214228
torrents.setDeletedAt(null);
215229
if (baseMapper.updateById(torrents) == 0) {
216230
throw new IllegalArgumentException("反删除操作失败,种子已经反删除或者已有相同 InfoHash 值的种子存在");

src/main/java/com/ghostchu/tracker/sapling/util/HtmlSanitizer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class HtmlSanitizer {
1515
.allowElements("ul", "ol", "li")
1616

1717
// 允许链接和图片
18-
.allowElements("mapper", "img")
18+
.allowElements("mapper", "img", "a")
1919
.allowAttributes("href", "title").onElements("mapper")
2020
.allowAttributes("src", "alt", "title", "width", "height").onElements("img")
2121
.allowUrlProtocols("http", "https", "mailto", "data")

0 commit comments

Comments
 (0)