Merge remote-tracking branch 'origin/group5-dictTag'

pull/3/head
fengshuonan 2021-01-17 14:46:42 +08:00
commit 7e2cc5e652
3 changed files with 43 additions and 6 deletions

View File

@ -1,5 +1,6 @@
package cn.stylefeng.roses.kernel.file.modular.controller; package cn.stylefeng.roses.kernel.file.modular.controller;
import cn.stylefeng.roses.kernel.file.constants.FileConstants;
import cn.stylefeng.roses.kernel.file.modular.service.SysFileInfoService; import cn.stylefeng.roses.kernel.file.modular.service.SysFileInfoService;
import cn.stylefeng.roses.kernel.file.pojo.request.SysFileInfoRequest; import cn.stylefeng.roses.kernel.file.pojo.request.SysFileInfoRequest;
import cn.stylefeng.roses.kernel.file.pojo.response.SysFileInfoResponse; import cn.stylefeng.roses.kernel.file.pojo.response.SysFileInfoResponse;
@ -19,7 +20,9 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import static cn.stylefeng.roses.kernel.file.constants.FileConstants.*; import static cn.stylefeng.roses.kernel.file.constants.FileConstants.*;
@ -59,6 +62,25 @@ public class SysFileInfoController {
return new SuccessResponseData(fileUploadInfoResult); return new SuccessResponseData(fileUploadInfoResult);
} }
/**
* tinymce
*
* //json格式
* { "location": "folder/sub-folder/new-location.png" }
*
* @author liuhanqing
* @date 2021/1/17 11:17
*/
@PostResource(name = "上传文件", path = "/sysFileInfo/tinymceUpload")
public Map<String, String> tinymceUpload(@RequestPart("file") MultipartFile file, SysFileInfoRequest sysFileInfoRequest) {
Map<String, String> resultMap = new HashMap<>(1);
sysFileInfoRequest.setSecretFlag(YesOrNotEnum.N.getCode());
SysFileInfoResponse fileUploadInfoResult = this.sysFileInfoService.uploadFile(file, sysFileInfoRequest);
resultMap.put("location", FileConstants.FILE_PUBLIC_PREVIEW_URL + "?fileId=" + fileUploadInfoResult.getFileId());
return resultMap;
}
/** /**
* *
* *

View File

@ -21,6 +21,7 @@ import org.springframework.core.DefaultParameterNameDiscoverer;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.ParameterNameDiscoverer; import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.multipart.MultipartFile;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.HashMap; import java.util.HashMap;
@ -171,9 +172,11 @@ public class RequestApiLogRecordAop implements Ordered {
// 处理基本类型 // 处理基本类型
Class<?>[] classes = new Class[args.length]; Class<?>[] classes = new Class[args.length];
for (int k = 0; k < args.length; k++) { for (int k = 0; k < args.length; k++) {
if(args[k] instanceof Model){ if (args[k] instanceof Model) {
classes[k] = Model.class; classes[k] = Model.class;
}else{ } else if (args[k] instanceof MultipartFile) {
classes[k] = MultipartFile.class;
} else {
classes[k] = args[k].getClass(); classes[k] = args[k].getClass();
} }
@ -194,7 +197,14 @@ public class RequestApiLogRecordAop implements Ordered {
// 装载参数名称和参数值 // 装载参数名称和参数值
for (int i = 0; i < parameterNames.length; i++) { for (int i = 0; i < parameterNames.length; i++) {
paramMap.put(parameterNames[i], args[i]); // 解决上传文件接口aop记录日志报错
if (args[i] instanceof MultipartFile && args[i]!=null) {
// 根据参数名只记录文件名
paramMap.put(parameterNames[i], ((MultipartFile) args[i]).getOriginalFilename());
}else{
paramMap.put(parameterNames[i], args[i]);
}
} }
} catch (Exception e) { } catch (Exception e) {
@ -203,11 +213,16 @@ public class RequestApiLogRecordAop implements Ordered {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
e.printStackTrace(); e.printStackTrace();
} }
// log.error(e.getMessage()); log.error(e.getMessage());
// 有异常则不显示参数名称直接返回参数 // 有异常则不显示参数名称直接返回参数
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
paramMap.put("args" + i, args[i]); if (args[i] instanceof MultipartFile && args[i]!=null) {
// 根据参数名只记录文件名
paramMap.put("args" + i, ((MultipartFile) args[i]).getOriginalFilename());
}else {
paramMap.put("args" + i, args[i]);
}
} }
} }

View File

@ -47,7 +47,7 @@ public class XssFilterAutoConfiguration {
@Bean @Bean
public Jackson2ObjectMapperBuilderCustomizer xssJackson2ObjectMapperBuilderCustomizer() { public Jackson2ObjectMapperBuilderCustomizer xssJackson2ObjectMapperBuilderCustomizer() {
return jacksonObjectMapperBuilder -> return jacksonObjectMapperBuilder ->
jacksonObjectMapperBuilder.deserializerByType(String.class, new XssJacksonDeserializer(new XssProperties())); jacksonObjectMapperBuilder.deserializerByType(String.class, new XssJacksonDeserializer(createProperties()));
} }
/** /**