优化应用权限初始化中的空集合检查
parent
8637771dca
commit
a09c51ba05
|
@ -18,6 +18,7 @@ import com.megatron.common.model.RequestContext;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -140,15 +141,17 @@ public class IndexServiceImpl implements IndexService {
|
||||||
User user = userRepository.query(requestContext.getTarget());
|
User user = userRepository.query(requestContext.getTarget());
|
||||||
log.info("user:{}", JSON.toJSONString(user));
|
log.info("user:{}", JSON.toJSONString(user));
|
||||||
List<AppPerm> permList = JSONArray.parseArray(qxUtils.queryApp(trxToken, user.getUserId()), AppPerm.class);
|
List<AppPerm> permList = JSONArray.parseArray(qxUtils.queryApp(trxToken, user.getUserId()), AppPerm.class);
|
||||||
List<String> appIdList = permList.stream()
|
if (!CollectionUtils.isEmpty(permList)) {
|
||||||
.map(AppPerm::getId)
|
List<String> appIdList = permList.stream()
|
||||||
.collect(Collectors.toList());
|
.map(AppPerm::getId)
|
||||||
log.info("appIdList:{}", JSON.toJSONString(appIdList));
|
.collect(Collectors.toList());
|
||||||
for (JSONObject data : allAppList) {
|
log.info("appIdList:{}", JSON.toJSONString(appIdList));
|
||||||
if (appIdList.contains(data.getString("appId"))) {
|
for (JSONObject data : allAppList) {
|
||||||
data.put("enable", "1");
|
if (appIdList.contains(data.getString("appId"))) {
|
||||||
} else {
|
data.put("enable", "1");
|
||||||
data.put("enable", "0");
|
} else {
|
||||||
|
data.put("enable", "0");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.info("allAppList:{}", JSON.toJSONString(allAppList));
|
log.info("allAppList:{}", JSON.toJSONString(allAppList));
|
||||||
|
|
Loading…
Reference in New Issue