pom文件:
com.alibaba
fastjson
1.2.47
//从配置文件获取机构允许创建的试听课次数
private Integer getAuditionLessonCount(Long platformId){
String config = nacosConfig.getConfig(“auditionLessonCount”);
JSONObject object = JSONObject.parseObject(config);
Boolean flag = false;
Integer auditionCount = null;
if(object.containsKey(“exception”) && object.getJSONArray(“exception”).size()>0){
JSONArray exception = object.getJSONArray(“exception”);
Iterator iterator = exception.iterator();
while(iterator.hasNext()){
JSONObject sonObject = (JSONObject)iterator.next();
if(sonObject.containsKey(“platformId”) && sonObject.getLongValue(“platformId”)>0){
if(platformId==sonObject.getLongValue(“platformId”)){
auditionCount= sonObject.getInteger(“auditionCount”);
flag = true;
break;
}
}
}
}
//存存在某个机构配置
if(!flag){
if(object.containsKey("auditionCount")) {
auditionCount = object.getIntValue("auditionCount");
}
}
if(auditionCount<0){
auditionCount = null;
}
return auditionCount;
}