From e23023b93f34286f5a807b0b85e9a0619a297ed7 Mon Sep 17 00:00:00 2001
From: Your Name <you@example.com>
Date: 星期二, 21 二月 2023 23:25:34 +0800
Subject: [PATCH] Merge branch 'master' of http://git.homecommunity.cn/supervip/MicroCommunity
---
service-api/src/main/java/com/java110/api/smo/file/impl/AddFileSMOImpl.java | 53 ++++++++++++++++++++++++++++++++++-------------------
1 files changed, 34 insertions(+), 19 deletions(-)
diff --git a/service-api/src/main/java/com/java110/api/smo/file/impl/AddFileSMOImpl.java b/service-api/src/main/java/com/java110/api/smo/file/impl/AddFileSMOImpl.java
index 42625f9..a40bf25 100644
--- a/service-api/src/main/java/com/java110/api/smo/file/impl/AddFileSMOImpl.java
+++ b/service-api/src/main/java/com/java110/api/smo/file/impl/AddFileSMOImpl.java
@@ -2,7 +2,6 @@
import com.alibaba.fastjson.JSONObject;
import com.java110.api.smo.DefaultAbstractComponentSMO;
-import com.java110.core.component.BaseComponentSMO;
import com.java110.core.context.IPageData;
import com.java110.core.factory.GenerateCodeFactory;
import com.java110.dto.file.FileDto;
@@ -10,13 +9,12 @@
import com.java110.api.smo.file.IAddFileSMO;
import com.java110.intf.common.IFileInnerServiceSMO;
import com.java110.utils.cache.MappingCache;
+import com.java110.utils.constant.MappingConstant;
import com.java110.utils.constant.PrivilegeCodeConstant;
-import com.java110.utils.constant.ServiceConstant;
import com.java110.utils.util.Assert;
import com.java110.utils.util.Base64Convert;
import com.java110.utils.util.BeanConvertUtil;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@@ -39,8 +37,6 @@
@Autowired
private IFileInnerServiceSMO fileInnerServiceSMOImpl;
-
-
@Override
public ResponseEntity<String> saveFile(IPageData pd, MultipartFile uploadFile) throws IOException {
@@ -48,44 +44,63 @@
if (uploadFile.getSize() > 2 * 1024 * 1024) {
throw new IllegalArgumentException("涓婁紶鏂囦欢瓒呰繃涓ゅ厗");
}
-
- Assert.hasKeyAndValue(paramIn, "communityId", "蹇呭~锛岃濉啓灏忓尯ID");
Assert.hasKeyAndValue(paramIn, "suffix", "蹇呭~锛岃濉啓鏂囦欢绫诲瀷");
- super.checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.SAVE_FILE);
-
- ComponentValidateResult result = this.validateStoreStaffCommunityRelationship(pd, restTemplate);
InputStream is = uploadFile.getInputStream();
String fileContext = Base64Convert.ioToBase64(is);
paramIn.put("context", fileContext);
paramIn.put("fileName", uploadFile.getOriginalFilename());
FileDto fileDto = BeanConvertUtil.covertBean(paramIn, FileDto.class);
-
+ fileDto.setCommunityId("-1");
fileDto.setFileId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_file_id));
String fileName = fileInnerServiceSMOImpl.saveFile(fileDto);
+ JSONObject outParam = new JSONObject();
+ outParam.put("fileId", fileName);
+ String imgUrl = MappingCache.getValue(MappingConstant.FILE_DOMAIN,"IMG_PATH");
+ outParam.put("url", imgUrl + fileName);
+ ResponseEntity<String> responseEntity = new ResponseEntity<String>(outParam.toJSONString(), HttpStatus.OK);
+ return responseEntity;
+ }
+
+ @Override
+ public ResponseEntity<String> savePhotoFile(IPageData pd) {
+
+ String images = pd.getReqData();
+ JSONObject imageObj=JSONObject.parseObject(images);
+ JSONObject paramIn = new JSONObject();
+ paramIn.put("context", imageObj.getString("uploadFile"));
+ paramIn.put("fileName", "upload.jpg");
+
+ FileDto fileDto = BeanConvertUtil.covertBean(paramIn, FileDto.class);
+
+ fileDto.setFileId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_file_id));
+// String file = paramIn.getString("fileName");
+// if (file.contains("mp4") || file.contains("MP4") || file.contains("AVI") || file.contains("avi")
+// || file.contains("WMV") || file.contains("wmv")) {
+// fileDto.setFlag("");
+// } else {
+// fileDto.setFlag("0");
+// }
+
+ String fileName = fileInnerServiceSMOImpl.saveFile(fileDto);
JSONObject outParam = new JSONObject();
outParam.put("fileId", fileName);
- String imgUrl = MappingCache.getValue("IMG_PATH");
- outParam.put("url",imgUrl+fileName);
+ String imgUrl = MappingCache.getValue(MappingConstant.FILE_DOMAIN,"IMG_PATH");
+ outParam.put("url", imgUrl + fileName);
ResponseEntity<String> responseEntity = new ResponseEntity<String>(outParam.toJSONString(), HttpStatus.OK);
-//
// String apiUrl = "file.saveFile" ;
-//
-//
+
// ResponseEntity<String> responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(),
// apiUrl,
// HttpMethod.POST);
return responseEntity;
-
}
-
-
public RestTemplate getRestTemplate() {
return restTemplate;
--
Gitblit v1.8.0