remove AttachmentRequest and AttachmentView
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
package com.imyeyu.api.modules.mirror;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.imyeyu.api.TimiServerAPI;
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.api.modules.common.vo.attachment.AttachmentRequest;
|
||||
import com.imyeyu.api.modules.mirror.entity.Mirror;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -42,7 +41,7 @@ public abstract class AttachmentMirror extends AbstractMirror {
|
||||
* @return 新增附件
|
||||
* @throws Exception 处理异常
|
||||
*/
|
||||
protected abstract List<AttachmentRequest> diffAdd(List<Attachment> dbFiles) throws Exception;
|
||||
protected abstract List<Attachment> diffAdd(List<Attachment> dbFiles) throws Exception;
|
||||
|
||||
/**
|
||||
* 差分移除附件
|
||||
@@ -70,10 +69,10 @@ public abstract class AttachmentMirror extends AbstractMirror {
|
||||
attachmentService.destroy(diffRemoveList.get(i).getId());
|
||||
}
|
||||
|
||||
List<AttachmentRequest> diffAddList = diffAdd(dbFiles);
|
||||
List<Attachment> diffAddList = diffAdd(dbFiles);
|
||||
syncAdded = diffAddList.size();
|
||||
for (int i = 0; i < diffAddList.size(); i++) {
|
||||
AttachmentRequest request = diffAddList.get(i);
|
||||
Attachment request = diffAddList.get(i);
|
||||
request.setBizType(Attachment.BizType.MIRROR);
|
||||
request.setBizId(mirror.getId());
|
||||
attachmentService.create(request);
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.imyeyu.api.modules.mirror;
|
||||
import com.google.gson.Gson;
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.api.modules.common.vo.attachment.AttachmentRequest;
|
||||
import com.imyeyu.api.modules.mirror.bean.AttachType;
|
||||
import com.imyeyu.api.modules.mirror.data.FabricAPI;
|
||||
import com.imyeyu.api.modules.mirror.entity.Mirror;
|
||||
@@ -106,10 +105,10 @@ public class FabricAPIMirror extends AttachmentMirror {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<AttachmentRequest> diffAdd(List<Attachment> dbFiles) throws Exception {
|
||||
protected List<Attachment> diffAdd(List<Attachment> dbFiles) throws Exception {
|
||||
Set<String> dbNameSet = dbFiles.stream().map(Attachment::getName).collect(Collectors.toSet());
|
||||
|
||||
List<AttachmentRequest> result = new ArrayList<>();
|
||||
List<Attachment> result = new ArrayList<>();
|
||||
for (Map.Entry<String, String> item : versionMap.entrySet()) {
|
||||
String version = "%s+%s".formatted(item.getValue(), item.getKey());
|
||||
String name = "fabric-api-%s.jar".formatted(version);
|
||||
@@ -119,7 +118,7 @@ public class FabricAPIMirror extends AttachmentMirror {
|
||||
|
||||
byte[] bytes = Request.get(url).viaProxy(proxy).execute().returnContent().asBytes();
|
||||
|
||||
AttachmentRequest attachment = new AttachmentRequest();
|
||||
Attachment attachment = new Attachment();
|
||||
attachment.setAttachTypeValue(AttachType.FABRIC_API);
|
||||
attachment.setName(name);
|
||||
attachment.setSize((long) bytes.length);
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.imyeyu.api.modules.mirror;
|
||||
import com.google.gson.Gson;
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.api.modules.common.vo.attachment.AttachmentRequest;
|
||||
import com.imyeyu.api.modules.mirror.bean.AttachType;
|
||||
import com.imyeyu.api.modules.mirror.data.OpenJDK;
|
||||
import com.imyeyu.api.modules.mirror.entity.Mirror;
|
||||
@@ -70,11 +69,11 @@ public class OpenJDKMirror extends AttachmentMirror {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<AttachmentRequest> diffAdd(List<Attachment> dbFiles) throws Exception {
|
||||
protected List<Attachment> diffAdd(List<Attachment> dbFiles) throws Exception {
|
||||
Map<String, OpenJDK> githubNameMap = githubMirrorResult.stream().collect(Collectors.toMap(OpenJDK::getName, item -> item));
|
||||
Set<String> dbNameSet = dbFiles.stream().map(Attachment::getName).collect(Collectors.toSet());
|
||||
|
||||
List<AttachmentRequest> result = new ArrayList<>();
|
||||
List<Attachment> result = new ArrayList<>();
|
||||
for (Map.Entry<String, OpenJDK> item : githubNameMap.entrySet()) {
|
||||
if (!dbNameSet.contains(item.getKey())) {
|
||||
String url = item.getValue().getData();
|
||||
@@ -82,7 +81,7 @@ public class OpenJDKMirror extends AttachmentMirror {
|
||||
|
||||
byte[] bytes = Request.get(url).viaProxy(proxy).execute().returnContent().asBytes();
|
||||
|
||||
AttachmentRequest attachment = new AttachmentRequest();
|
||||
Attachment attachment = new Attachment();
|
||||
attachment.setAttachTypeValue(AttachType.OPEN_JDK);
|
||||
attachment.setName(item.getKey());
|
||||
attachment.setSize((long) bytes.length);
|
||||
|
||||
Reference in New Issue
Block a user