|
@@ -10,6 +10,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
|
import cn.com.qmth.examcloud.api.commons.CloudService;
|
|
|
+import cn.com.qmth.examcloud.api.commons.enums.BasicDataType;
|
|
|
+import cn.com.qmth.examcloud.commons.exception.ExamCloudRuntimeException;
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.logging.ExamCloudLog;
|
|
|
import cn.com.qmth.examcloud.commons.logging.ExamCloudLogFactory;
|
|
@@ -38,7 +40,24 @@ public class CacheCloudServiceProvider implements CloudService {
|
|
|
public String refresh(@RequestBody RefreshCacheReq req) {
|
|
|
|
|
|
String className = req.getClassName();
|
|
|
- Object[] keys = req.getKeys();
|
|
|
+ String[] keys = req.getKeys();
|
|
|
+ BasicDataType[] typeArray = req.getTypeArray();
|
|
|
+
|
|
|
+ Object[] expectedKeys = new Object[keys.length];
|
|
|
+
|
|
|
+ for (int i = 0; i < keys.length; i++) {
|
|
|
+ String key = keys[i];
|
|
|
+ BasicDataType type = typeArray[i];
|
|
|
+ if (type.equals(BasicDataType.LONG)) {
|
|
|
+ expectedKeys[i] = Long.parseLong(key);
|
|
|
+ } else if (type.equals(BasicDataType.STRING)) {
|
|
|
+ expectedKeys[i] = key;
|
|
|
+ } else if (type.equals(BasicDataType.INTEGER)) {
|
|
|
+ expectedKeys[i] = Integer.parseInt(key);
|
|
|
+ } else {
|
|
|
+ throw new ExamCloudRuntimeException("key type is not supported");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
ObjectCache<?> objectCache = map.get(className);
|
|
|
if (null == objectCache) {
|
|
@@ -51,8 +70,8 @@ public class CacheCloudServiceProvider implements CloudService {
|
|
|
throw new StatusException("008001", "class not found");
|
|
|
}
|
|
|
}
|
|
|
- objectCache.refresh(keys);
|
|
|
- Object object = objectCache.get(keys);
|
|
|
+ objectCache.refresh(expectedKeys);
|
|
|
+ Object object = objectCache.get(expectedKeys);
|
|
|
return JsonUtil.toJson(object);
|
|
|
}
|
|
|
|