upload 的方法创建多态版本 long 和 String类型id

This commit is contained in:
ajaxfan
2021-01-18 19:38:03 +08:00
parent 39df783b5d
commit db3d3275e5
3 changed files with 16 additions and 3 deletions

View File

@ -18,7 +18,7 @@ public interface AttachmentClient {
/** /**
* @return 创建业务ID * @return 创建业务ID
*/ */
Optional<Long> getBusinessId(); Optional<String> getBusinessId();
/** /**
* 查询业务ID下的所有附件信息 * 查询业务ID下的所有附件信息
@ -61,6 +61,8 @@ public interface AttachmentClient {
* @return * @return
*/ */
Optional<UploadObject> upload(String businessId, File file); Optional<UploadObject> upload(String businessId, File file);
Optional<UploadObject> upload(Long businessId, File file);
/** /**
* 上传资源文件 * 上传资源文件
@ -70,5 +72,6 @@ public interface AttachmentClient {
* @return * @return
*/ */
Optional<UploadObject> upload(String businessId, String filename, byte[] array); Optional<UploadObject> upload(String businessId, String filename, byte[] array);
Optional<UploadObject> upload(Long businessId, String filename, byte[] array);
} }

View File

@ -34,7 +34,7 @@ public class DefaultAttachmentClient implements AttachmentClient {
* 获取业务ID * 获取业务ID
*/ */
@Override @Override
public Optional<Long> getBusinessId() { public Optional<String> getBusinessId() {
Snowflake snowflake = queryService.getSnokflakId(); Snowflake snowflake = queryService.getSnokflakId();
if (Objects.isNull(snowflake)) { if (Objects.isNull(snowflake)) {
@ -108,6 +108,11 @@ public class DefaultAttachmentClient implements AttachmentClient {
return Optional.ofNullable(new UploadObject().setId(feedback.getOid())); return Optional.ofNullable(new UploadObject().setId(feedback.getOid()));
} }
@Override
public Optional<UploadObject> upload(Long businessId, File file) {
return upload(businessId.toString(), file);
}
/** /**
* 上传附件 * 上传附件
* *
@ -127,4 +132,9 @@ public class DefaultAttachmentClient implements AttachmentClient {
return Optional.ofNullable(new UploadObject().setId(feedback.getOid())); return Optional.ofNullable(new UploadObject().setId(feedback.getOid()));
} }
@Override
public Optional<UploadObject> upload(Long businessId, String filename, byte[] array) {
return upload(businessId.toString(), filename, array);
}
} }

View File

@ -5,6 +5,6 @@ import lombok.Data;
@Data @Data
public class Snowflake { public class Snowflake {
private Long id; private String id;
} }