remove AttachmentRequest and AttachmentView
This commit is contained in:
@@ -20,7 +20,6 @@ import com.imyeyu.api.modules.common.service.TemplateService;
|
||||
import com.imyeyu.api.modules.common.service.VersionService;
|
||||
import com.imyeyu.api.modules.common.vo.FeedbackRequest;
|
||||
import com.imyeyu.api.modules.common.vo.TempFileResponse;
|
||||
import com.imyeyu.api.modules.common.vo.attachment.AttachmentView;
|
||||
import com.imyeyu.api.modules.system.util.ResourceHandler;
|
||||
import com.imyeyu.api.util.CaptchaManager;
|
||||
import com.imyeyu.io.IO;
|
||||
@@ -264,8 +263,8 @@ public class CommonController {
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@GetMapping("/attachment/{mongoId}")
|
||||
public AttachmentView getAttachment(@PathVariable String mongoId) {
|
||||
return attachmentService.viewByMongoId(mongoId);
|
||||
public Attachment getAttachment(@PathVariable String mongoId) {
|
||||
return attachmentService.getByMongoId(mongoId);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.imyeyu.api.modules.common.service;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.vo.attachment.AttachmentRequest;
|
||||
import com.imyeyu.api.modules.common.vo.attachment.AttachmentView;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.service.BaseService;
|
||||
import com.mongodb.client.gridfs.model.GridFSFile;
|
||||
@@ -22,27 +20,6 @@ public interface AttachmentService extends BaseService<Attachment, Long> {
|
||||
|
||||
Attachment createMedia(Attachment attachment);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
*/
|
||||
@Deprecated
|
||||
default void create(AttachmentRequest request) {
|
||||
create((Attachment) request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建媒体附件,同步创建缩略图
|
||||
*
|
||||
* @param request 附件请求
|
||||
* @return 缩略图附件
|
||||
*/
|
||||
@Deprecated
|
||||
default Attachment createMedia(AttachmentRequest request) throws TimiException {
|
||||
return createMedia((Attachment) request);
|
||||
}
|
||||
|
||||
void deleteMedia(Long thumbId) throws TimiException;
|
||||
|
||||
Attachment getByBizId(Attachment.BizType bizType, long bizId);
|
||||
@@ -51,8 +28,6 @@ public interface AttachmentService extends BaseService<Attachment, Long> {
|
||||
|
||||
Attachment getByMongoId(String mongoId);
|
||||
|
||||
AttachmentView viewByMongoId(String mongoId);
|
||||
|
||||
GridFSFile readByMongoId(String mongoId);
|
||||
|
||||
InputStream getInputStreamByMongoId(String mongoId);
|
||||
|
||||
-13
@@ -9,7 +9,6 @@ import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.mapper.AttachmentMapper;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.api.modules.common.service.SettingService;
|
||||
import com.imyeyu.api.modules.common.vo.attachment.AttachmentView;
|
||||
import com.imyeyu.api.util.JavaCV;
|
||||
import com.imyeyu.io.IO;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
@@ -25,7 +24,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.coobird.thumbnailator.Thumbnails;
|
||||
import org.apache.tika.Tika;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.data.mongodb.gridfs.GridFsTemplate;
|
||||
@@ -201,17 +199,6 @@ public class AttachmentServiceImplement extends AbstractEntityService<Attachment
|
||||
return mapper.selectByMongoId(mongoId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttachmentView viewByMongoId(String mongoId) {
|
||||
Attachment attachment = getByMongoId(mongoId);
|
||||
if (attachment == null) {
|
||||
throw new TimiException(TimiCode.RESULT_NULL).msgKey("TODO not found attachment");
|
||||
}
|
||||
AttachmentView view = new AttachmentView();
|
||||
BeanUtils.copyProperties(attachment, view);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GridFSFile readByMongoId(String mongoId) {
|
||||
Attachment view = mapper.selectByMongoId(mongoId);
|
||||
|
||||
+6
-7
@@ -1,9 +1,5 @@
|
||||
package com.imyeyu.api.modules.common.service.implement;
|
||||
|
||||
import com.imyeyu.io.IOSize;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.entity.User;
|
||||
@@ -12,8 +8,11 @@ import com.imyeyu.api.modules.common.mapper.UserProfileMapper;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.api.modules.common.service.UserProfileService;
|
||||
import com.imyeyu.api.modules.common.service.UserService;
|
||||
import com.imyeyu.api.modules.common.vo.attachment.AttachmentRequest;
|
||||
import com.imyeyu.api.modules.common.vo.user.UserRequest;
|
||||
import com.imyeyu.io.IOSize;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import com.imyeyu.spring.service.AbstractEntityService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -73,7 +72,7 @@ public class UserProfileServiceImplement extends AbstractEntityService<UserProfi
|
||||
if (IOSize.MB < bytes.length) {
|
||||
throw new TimiException(TimiCode.ARG_BAD).msgKey("限制上传文件大小 1 MB");
|
||||
}
|
||||
AttachmentRequest wrapperAttach = new AttachmentRequest();
|
||||
Attachment wrapperAttach = new Attachment();
|
||||
wrapperAttach.setName(request.getId() + ".png");
|
||||
wrapperAttach.setBizType(Attachment.BizType.USER);
|
||||
wrapperAttach.setBizId(request.getId());
|
||||
@@ -88,7 +87,7 @@ public class UserProfileServiceImplement extends AbstractEntityService<UserProfi
|
||||
attachmentService.delete(dbAvatar.getId());
|
||||
}
|
||||
MultipartFile avatar = request.getProfile().getAvatar();
|
||||
AttachmentRequest avatarAttach = new AttachmentRequest();
|
||||
Attachment avatarAttach = new Attachment();
|
||||
avatarAttach.setName(request.getId() + ".png");
|
||||
avatarAttach.setBizType(Attachment.BizType.USER);
|
||||
avatarAttach.setBizId(request.getId());
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.imyeyu.api.modules.common.vo.attachment;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.spring.annotation.table.Transient;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @since 2024-02-21 10:58
|
||||
*/
|
||||
@Data
|
||||
@Transient
|
||||
@Deprecated
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class AttachmentRequest extends Attachment {
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.imyeyu.api.modules.common.vo.attachment;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.imyeyu.api.bean.MultilingualHandler;
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
|
||||
/**
|
||||
* @author 夜雨
|
||||
* @since 2024-02-21 10:55
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class AttachmentView extends Attachment implements MultilingualHandler {
|
||||
}
|
||||
Reference in New Issue
Block a user