|
@@ -51,6 +51,7 @@ import cn.com.qmth.examcloud.commons.exception.ExamCloudRuntimeException;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.helpers.DynamicEnum;
|
|
import cn.com.qmth.examcloud.commons.helpers.DynamicEnum;
|
|
import cn.com.qmth.examcloud.commons.helpers.DynamicEnumManager;
|
|
import cn.com.qmth.examcloud.commons.helpers.DynamicEnumManager;
|
|
|
|
+import cn.com.qmth.examcloud.commons.util.JsonUtil;
|
|
import cn.com.qmth.examcloud.commons.util.PathUtil;
|
|
import cn.com.qmth.examcloud.commons.util.PathUtil;
|
|
import cn.com.qmth.examcloud.commons.util.RegExpUtil;
|
|
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.OrgDomain;
|
|
@@ -102,10 +103,10 @@ public class OrgController extends ControllerSupport {
|
|
OrgServiceImpl orgService;
|
|
OrgServiceImpl orgService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- OrgPropertyRepo orgPropertyRepo;
|
|
|
|
|
|
+ SystemConfig systemConfig;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- SystemConfig systemConfig;
|
|
|
|
|
|
+ OrgPropertyRepo orgPropertyRepo;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
DataSyncCloudService dataSyncCloudService;
|
|
DataSyncCloudService dataSyncCloudService;
|
|
@@ -609,10 +610,71 @@ public class OrgController extends ControllerSupport {
|
|
}
|
|
}
|
|
|
|
|
|
@Naked
|
|
@Naked
|
|
- @ApiOperation(value = "按属性组查询机构属性集合")
|
|
|
|
- @GetMapping("orgPropertiesByGroup/{orgId}/{propertyGroupId}")
|
|
|
|
- public Map<String, String> getOrgPropertiesByGroup(@PathVariable Long orgId,
|
|
|
|
|
|
+ @ApiOperation(value = "按属性组查询机构属性集合(无缓存)")
|
|
|
|
+ @GetMapping("getOrgPropertiesByGroupWithoutCache/{orgId}/{propertyGroupId}")
|
|
|
|
+ public Map<String, String> getOrgPropertiesByGroupWithoutCache(@PathVariable Long orgId,
|
|
|
|
+ @PathVariable String propertyGroupId) {
|
|
|
|
+
|
|
|
|
+ Map<String, String> properties = getOrgPropertiesByGroup(orgId, propertyGroupId);
|
|
|
|
+ return properties;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Naked
|
|
|
|
+ @ApiOperation(value = "按属性组查询机构属性集合(有缓存)")
|
|
|
|
+ @GetMapping("getOrgPropertiesByGroupWithoutCache/{orgId}/{propertyGroupId}")
|
|
|
|
+ public Map<String, String> getOrgPropertiesByGroupWithCache(@PathVariable Long orgId,
|
|
|
|
+ @PathVariable String propertyGroupId) {
|
|
|
|
+
|
|
|
|
+ String redisKey = "PROPERTIES_BY_GROUP:" + orgId + ":" + propertyGroupId;
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
|
+ Map<String, String> properties = redisClient.get(redisKey, Map.class);
|
|
|
|
+ if (null != properties) {
|
|
|
|
+ return properties;
|
|
|
|
+ }
|
|
|
|
+ properties = getOrgPropertiesByGroup(orgId, propertyGroupId);
|
|
|
|
+
|
|
|
|
+ redisClient.set(redisKey, properties, 120);
|
|
|
|
+ return properties;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Naked
|
|
|
|
+ @ApiOperation(value = "上传机构属性集合至upyun")
|
|
|
|
+ @GetMapping("uploadOrgProperties2Upyun/{orgId}/{propertyGroupId}")
|
|
|
|
+ public String uploadOrgProperties2Upyun(@PathVariable Long orgId,
|
|
@PathVariable String propertyGroupId) {
|
|
@PathVariable String propertyGroupId) {
|
|
|
|
+ Map<String, String> properties = getOrgPropertiesByGroup(orgId, propertyGroupId);
|
|
|
|
+
|
|
|
|
+ String fileSuffix = ".json";
|
|
|
|
+
|
|
|
|
+ String filePath = systemConfig.getTempDataDir() + File.separator + "orgProperties"
|
|
|
|
+ + File.separator + orgId + fileSuffix;
|
|
|
|
+ File file = new File(filePath);
|
|
|
|
+ String prettyJson = JsonUtil.toPrettyJson(properties);
|
|
|
|
+ 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.setSiteId("orgProperties");
|
|
|
|
+ req.setFileSuffix(".json");
|
|
|
|
+ req.setRootOrgId(orgId);
|
|
|
|
+ req.setExt1(propertyGroupId);
|
|
|
|
+ PutFileResp putFileResp = upyunCloudService.putFile(req);
|
|
|
|
+ String url = putFileResp.getUrl();
|
|
|
|
+ return url;
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new ExamCloudRuntimeException(e);
|
|
|
|
+ } finally {
|
|
|
|
+ FileUtils.deleteQuietly(file);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Map<String, String> getOrgPropertiesByGroup(Long orgId, String propertyGroupId) {
|
|
|
|
|
|
OrgEntity orgEntity = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
|
|
OrgEntity orgEntity = GlobalHelper.getEntity(orgRepo, orgId, OrgEntity.class);
|
|
if (null == orgEntity) {
|
|
if (null == orgEntity) {
|
|
@@ -621,12 +683,6 @@ public class OrgController extends ControllerSupport {
|
|
validateRootOrgIsolation(orgEntity.getRootId());
|
|
validateRootOrgIsolation(orgEntity.getRootId());
|
|
|
|
|
|
String key = SystemProps.ORG_PROPERTY_GROUP_PREFIX + propertyGroupId;
|
|
String key = SystemProps.ORG_PROPERTY_GROUP_PREFIX + propertyGroupId;
|
|
- String redisKey = "ORG_PROPS_BY_GROUP:" + orgId + ":" + key;
|
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
|
- Map<String, String> properties = redisClient.get(redisKey, Map.class);
|
|
|
|
- if (null != properties) {
|
|
|
|
- return properties;
|
|
|
|
- }
|
|
|
|
|
|
|
|
SysPropertyCacheBean groupCacheBean = systemPropertyCache.get(key);
|
|
SysPropertyCacheBean groupCacheBean = systemPropertyCache.get(key);
|
|
|
|
|
|
@@ -640,9 +696,8 @@ public class OrgController extends ControllerSupport {
|
|
}
|
|
}
|
|
|
|
|
|
List<String> keys = RegExpUtil.findAll(String.valueOf(value), "[^\\,]+");
|
|
List<String> keys = RegExpUtil.findAll(String.valueOf(value), "[^\\,]+");
|
|
- properties = getProperties(orgEntity.getId(), keys);
|
|
|
|
|
|
+ Map<String, String> properties = getProperties(orgEntity.getId(), keys);
|
|
|
|
|
|
- redisClient.set(redisKey, properties, 120);
|
|
|
|
return properties;
|
|
return properties;
|
|
}
|
|
}
|
|
|
|
|