|
@@ -15,6 +15,7 @@ import cn.com.qmth.examcloud.commons.util.PathUtil;
|
|
|
import cn.com.qmth.examcloud.commons.util.RegExpUtil;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.controller.bean.OrgDomain;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.controller.bean.SaveOrgPropertiesDomain;
|
|
|
+import cn.com.qmth.examcloud.core.basic.base.constants.FileConstants;
|
|
|
import cn.com.qmth.examcloud.core.basic.base.constants.SystemProps;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.OrgPropertyRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
|
|
@@ -36,12 +37,11 @@ import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
|
import cn.com.qmth.examcloud.support.cache.bean.OrgCacheBean;
|
|
|
import cn.com.qmth.examcloud.support.cache.bean.OrgPropertyCacheBean;
|
|
|
import cn.com.qmth.examcloud.support.cache.bean.SysPropertyCacheBean;
|
|
|
-import cn.com.qmth.examcloud.support.filestorage.FileStorageUtil;
|
|
|
+import cn.com.qmth.examcloud.support.fss.FssFactory;
|
|
|
+import cn.com.qmth.examcloud.support.fss.model.FssFileInfo;
|
|
|
import cn.com.qmth.examcloud.task.api.DataSyncCloudService;
|
|
|
import cn.com.qmth.examcloud.task.api.request.SyncOrgReq;
|
|
|
import cn.com.qmth.examcloud.web.config.SystemProperties;
|
|
|
-import cn.com.qmth.examcloud.web.filestorage.FileStoragePathEnvInfo;
|
|
|
-import cn.com.qmth.examcloud.web.filestorage.YunPathInfo;
|
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
import cn.com.qmth.examcloud.web.jpa.PageUtils;
|
|
|
import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
@@ -689,7 +689,7 @@ public class OrgController extends ControllerSupport {
|
|
|
return properties;
|
|
|
}
|
|
|
|
|
|
- private List<String> uploadOrgProperties2Upyun(Long orgId, String propertyGroupId) {
|
|
|
+ private List<String> uploadOrgProperties(Long orgId, String propertyGroupId) {
|
|
|
Map<String, String> properties = getOrgPropertiesByGroup(orgId, propertyGroupId);
|
|
|
|
|
|
OrgCacheBean org = CacheHelper.getOrg(orgId);
|
|
@@ -720,49 +720,26 @@ public class OrgController extends ControllerSupport {
|
|
|
try {
|
|
|
FileUtils.write(file, prettyJson, "UTF-8");
|
|
|
|
|
|
- // PutFileReq req = new PutFileReq();
|
|
|
- // List<FormFilePart> formFilePartList = new ArrayList<FormFilePart>();
|
|
|
- // FormFilePart part = new FormFilePart("file", orgId + fileSuffix, file);
|
|
|
- // formFilePartList.add(part);
|
|
|
- //
|
|
|
- // req.setFormFilePartList(formFilePartList);
|
|
|
- //
|
|
|
- // req.setFileSuffix(fileSuffix);
|
|
|
- // req.setRootOrgId(orgEntity.getId());
|
|
|
- // req.setRootOrgDomain(orgEntity.getDomainName());
|
|
|
- // req.setExt1(propertyGroupId);
|
|
|
- //
|
|
|
- // PutFileResp putFileResp = null;
|
|
|
- //
|
|
|
- // req.setSiteId("orgPropertiesByOrgId");
|
|
|
- // putFileResp = upyunCloudService.putFile(req);
|
|
|
- // urlList.add(putFileResp.getUrl());
|
|
|
- //
|
|
|
- // req.setSiteId("orgPropertiesByOrgDomain");
|
|
|
- // putFileResp = upyunCloudService.putFile(req);
|
|
|
- // urlList.add(putFileResp.getUrl());
|
|
|
-
|
|
|
- //通用存储
|
|
|
- YunPathInfo pi = null;
|
|
|
- FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
|
- env.setFileSuffix(fileSuffix);
|
|
|
- env.setRootOrgId(orgEntity.getId().toString());
|
|
|
- env.setRootOrgDomain(orgEntity.getDomainName());
|
|
|
- env.setExt1(propertyGroupId);
|
|
|
- pi = FileStorageUtil.saveFile("orgPropertiesByOrgId", env, file, null, 0L);
|
|
|
-
|
|
|
- urlList.add(pi.getUrl());
|
|
|
- pi = FileStorageUtil.saveFile("orgPropertiesByOrgDomain", env, file, null, 0L);
|
|
|
- urlList.add(pi.getUrl());
|
|
|
+ // 示例:/org_properties/byOrgId/0/studentClientConfig.json
|
|
|
+ String filePath1 = String.format(FileConstants.ORG_PROPERTIES_BY_ORG_ID, orgId, propertyGroupId + fileSuffix);
|
|
|
+ FssFileInfo result1 = FssFactory.getInstance().writeFile(filePath1, file, null);
|
|
|
+ urlList.add(result1.getFileUrl());
|
|
|
|
|
|
- return urlList;
|
|
|
+ // 示例:/org_properties/byOrgDomain/0/studentClientConfig.json
|
|
|
+ String filePath2 = String.format(FileConstants.ORG_PROPERTIES_BY_ORG_DOMAIN, orgEntity.getDomainName(), propertyGroupId + fileSuffix);
|
|
|
+ FssFileInfo result2 = FssFactory.getInstance().writeFile(filePath2, file, null);
|
|
|
+ urlList.add(result2.getFileUrl());
|
|
|
+
|
|
|
+ // 刷新CDN缓存
|
|
|
+ FssFactory.getInstance().refreshFile(result1.getFileUrl());
|
|
|
+ FssFactory.getInstance().refreshFile(result2.getFileUrl());
|
|
|
|
|
|
+ return urlList;
|
|
|
} catch (IOException e) {
|
|
|
throw new ExamCloudRuntimeException(e);
|
|
|
} finally {
|
|
|
FileUtils.deleteQuietly(file);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public Map<String, String> getOrgPropertiesByGroup(Long orgId, String propertyGroupId) {
|
|
@@ -1154,8 +1131,8 @@ public class OrgController extends ControllerSupport {
|
|
|
String redisKey = CacheConstants.CACHE_B_ORG_PROP_LIST + orgId + ":" + propertyGroupId;
|
|
|
redisClient.delete(redisKey);
|
|
|
|
|
|
- // 上传upyun
|
|
|
- uploadOrgProperties2Upyun(orgId, propertyGroupId);
|
|
|
+ // 上传
|
|
|
+ uploadOrgProperties(orgId, propertyGroupId);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1369,24 +1346,10 @@ public class OrgController extends ControllerSupport {
|
|
|
|
|
|
FileUtils.copyFile(storeLocation, new File(path));
|
|
|
|
|
|
- // PutFileReq req = new PutFileReq();
|
|
|
- // List<FormFilePart> formFilePartList = new ArrayList<FormFilePart>();
|
|
|
- // FormFilePart part = new FormFilePart("file", orgId + fileSuffix, storeLocation);
|
|
|
- // formFilePartList.add(part);
|
|
|
- //
|
|
|
- // req.setFormFilePartList(formFilePartList);
|
|
|
- // req.setSiteId("orgLogo");
|
|
|
- // req.setFileSuffix(fileSuffix);
|
|
|
- // req.setRootOrgId(orgEntity.getRootId());
|
|
|
- // PutFileResp putFileResp = upyunCloudService.putFile(req);
|
|
|
- // String url = putFileResp.getUrl();
|
|
|
-
|
|
|
- //通用存储
|
|
|
- FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
|
- env.setFileSuffix(fileSuffix);
|
|
|
- env.setRootOrgId(orgEntity.getRootId().toString());
|
|
|
- YunPathInfo pi = FileStorageUtil.saveFile("orgLogo", env, storeLocation, null, LOG_FILE_CACHE_AGE);
|
|
|
- String url = pi.getUrl();
|
|
|
+ // 示例:/org_logo/0/xxx.png
|
|
|
+ String filePath = String.format(FileConstants.ORG_LOGO, orgId, System.currentTimeMillis(), fileSuffix);
|
|
|
+ FssFileInfo result = FssFactory.getInstance().writeFile(filePath, storeLocation, null);
|
|
|
+ String url = result.getFileUrl();
|
|
|
|
|
|
OrgPropertyEntity logoFileUrlEntity = orgPropertyRepo.findByOrgIdAndKeyId(orgId,
|
|
|
logoFileUrl.getId());
|
|
@@ -1434,7 +1397,7 @@ public class OrgController extends ControllerSupport {
|
|
|
File storeLocation = fileItem.getStoreLocation();
|
|
|
String name = file.getOriginalFilename();
|
|
|
|
|
|
- if (1 * 1024 * 1024 < storeLocation.length()) {
|
|
|
+ if (1024 * 1024 < storeLocation.length()) {
|
|
|
throw new StatusException("140082", "文件过大");
|
|
|
}
|
|
|
|
|
@@ -1453,13 +1416,10 @@ public class OrgController extends ControllerSupport {
|
|
|
DynamicEnumManager manager = OrgProperty.getDynamicEnumManager();
|
|
|
DynamicEnum logoFileUrl = manager.getByName("STUDENT_CLIENT_BG_PICTURE_URL");
|
|
|
|
|
|
-
|
|
|
- //通用存储
|
|
|
- FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
|
- env.setFileSuffix(fileSuffix);
|
|
|
- env.setRootOrgId(orgEntity.getRootId().toString());
|
|
|
- YunPathInfo pi = FileStorageUtil.saveFile("client_bg_picture", env, storeLocation, null, LOG_FILE_CACHE_AGE);
|
|
|
- String url = pi.getUrl();
|
|
|
+ // 示例:/client_bg_picture/0/xxx.png
|
|
|
+ String filePath = String.format(FileConstants.CLIENT_BG_PICTURE, orgId, System.currentTimeMillis(), fileSuffix);
|
|
|
+ FssFileInfo result = FssFactory.getInstance().writeFile(filePath, storeLocation, null);
|
|
|
+ String url = result.getFileUrl();
|
|
|
|
|
|
OrgPropertyEntity logoFileUrlEntity = orgPropertyRepo.findByOrgIdAndKeyId(orgId,
|
|
|
logoFileUrl.getId());
|
|
@@ -1502,12 +1462,10 @@ public class OrgController extends ControllerSupport {
|
|
|
throw new StatusException("101001", "文件格式错误");
|
|
|
}
|
|
|
|
|
|
- //通用存储
|
|
|
- FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
|
- env.setFileSuffix(fileSuffix);
|
|
|
- env.setRootOrgId(orgEntity.getRootId().toString());
|
|
|
- YunPathInfo pi = FileStorageUtil.saveFile("orgAnswers", env, storeLocation, null);
|
|
|
- String url = pi.getUrl();
|
|
|
+ // 示例:/org_answers/0/xxx.zip
|
|
|
+ String filePath = String.format(FileConstants.ORG_ANSWER_TEMPLATE, orgId, System.currentTimeMillis(), fileSuffix);
|
|
|
+ FssFileInfo result = FssFactory.getInstance().writeFile(filePath, storeLocation, null);
|
|
|
+ String url = result.getFileUrl();
|
|
|
|
|
|
User accessUser = getAccessUser();
|
|
|
ReportsUtil.report(new AdminOperateReport(accessUser.getRootOrgId(), accessUser.getUserId(), AdminOperateType.TYPE4.getDesc(), null));
|
|
@@ -1635,12 +1593,10 @@ public class OrgController extends ControllerSupport {
|
|
|
|
|
|
FileUtils.copyFile(storeLocation, new File(path));
|
|
|
|
|
|
- //通用存储
|
|
|
- FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
|
- env.setFileSuffix(fileSuffix);
|
|
|
- env.setRootOrgId(orgEntity.getRootId().toString());
|
|
|
- YunPathInfo pi = FileStorageUtil.saveFile("orgLogo", env, storeLocation, null, LOG_FILE_CACHE_AGE);
|
|
|
- String url = pi.getUrl();
|
|
|
+ // 示例:/org_logo/0/xxx.png
|
|
|
+ String filePath = String.format(FileConstants.ORG_LOGO, orgId, System.currentTimeMillis(), fileSuffix);
|
|
|
+ FssFileInfo result = FssFactory.getInstance().writeFile(filePath, storeLocation, null);
|
|
|
+ String url = result.getFileUrl();
|
|
|
|
|
|
OrgPropertyEntity logoFileUrlEntity = orgPropertyRepo.findByOrgIdAndKeyId(orgId,
|
|
|
logoFileUrl.getId());
|