fix: 修复附件配置属性构造器冲突
This commit is contained in:
@@ -1,18 +1,16 @@
|
|||||||
package com.bruce.common.config;
|
package com.bruce.common.config;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Getter
|
@Data
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@ConfigurationProperties(prefix = "common.attachment")
|
@ConfigurationProperties(prefix = "common.attachment")
|
||||||
public class AttachmentProperties {
|
public class AttachmentProperties {
|
||||||
|
|
||||||
private final String BASE_PATH = "data/attachments";
|
private String basePath = "data/attachments";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.bruce.common.domain.entity.SysAttachment;
|
|||||||
import com.bruce.common.dto.request.SysAttachmentUploadRequest;
|
import com.bruce.common.dto.request.SysAttachmentUploadRequest;
|
||||||
import com.bruce.common.mapper.SysAttachmentMapper;
|
import com.bruce.common.mapper.SysAttachmentMapper;
|
||||||
import com.bruce.common.service.ISysAttachmentService;
|
import com.bruce.common.service.ISysAttachmentService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@@ -23,11 +24,8 @@ public class SysAttachmentServiceImpl extends ServiceImpl<SysAttachmentMapper, S
|
|||||||
|
|
||||||
private static final String STORAGE_TYPE_LOCAL = "LOCAL";
|
private static final String STORAGE_TYPE_LOCAL = "LOCAL";
|
||||||
|
|
||||||
private final AttachmentProperties attachmentProperties;
|
@Autowired
|
||||||
|
private AttachmentProperties attachmentProperties;
|
||||||
public SysAttachmentServiceImpl(AttachmentProperties attachmentProperties) {
|
|
||||||
this.attachmentProperties = attachmentProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SysAttachment upload(SysAttachmentUploadRequest request) {
|
public SysAttachment upload(SysAttachmentUploadRequest request) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.bruce.common.attachment;
|
|||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.bruce.common.config.AttachmentProperties;
|
||||||
import com.bruce.common.controller.SysAttachmentController;
|
import com.bruce.common.controller.SysAttachmentController;
|
||||||
import com.bruce.common.domain.model.RequestResult;
|
import com.bruce.common.domain.model.RequestResult;
|
||||||
import com.bruce.common.dto.request.SysAttachmentUploadRequest;
|
import com.bruce.common.dto.request.SysAttachmentUploadRequest;
|
||||||
@@ -45,4 +46,15 @@ class SysAttachmentComponentStructureTests {
|
|||||||
assertEquals(SysAttachment.class, serviceMethod.getReturnType());
|
assertEquals(SysAttachment.class, serviceMethod.getReturnType());
|
||||||
assertEquals(RequestResult.class, controllerMethod.getReturnType());
|
assertEquals(RequestResult.class, controllerMethod.getReturnType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void attachmentPropertiesShouldExposeBindableBasePath() {
|
||||||
|
AttachmentProperties properties = new AttachmentProperties();
|
||||||
|
|
||||||
|
assertEquals("data/attachments", properties.getBasePath());
|
||||||
|
|
||||||
|
properties.setBasePath("custom/attachments");
|
||||||
|
|
||||||
|
assertEquals("custom/attachments", properties.getBasePath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user