提交 750fdaae 编写于 作者: ibizdev's avatar ibizdev

ibizdev提交

上级 a96b989b
{
"unires":[
],
"predefineddatarange":[{"id":"ALL","name":"全部数据"},{"id":"CURORG","name":"当前单位"},{"id":"PORG","name":"上级单位"},{"id":"SORG","name":"下级单位"},{"id":"CURORGDEPT","name":"当前部门"},{"id":"PORGDEPT","name":"上级部门"},{"id":"SORGDEPT","name":"下级部门"}],
"entities":[
],
"appmenus":[
{
"appid":"web",
"appname":"UAA鉴权",
"appmenu":[{"menuid":"Main", "menuname":"MAIN", "menuitem":[{ "id":"menuitem3" , "name":"用户管理" },{ "id":"menuitem6" , "name":"角色" },{ "id":"menuitem7" , "name":"用户角色" },{ "id":"menuitem10" , "name":"权限" },{ "id":"menuitem1" , "name":"角色权限" }] }]
}
]
}
......@@ -3,13 +3,14 @@ package cn.ibizlab.util.client;
import cn.ibizlab.util.security.AuthenticationUser;
import cn.ibizlab.util.security.AuthorizationLogin;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import java.util.Map;
@Component
public class IBZUAAFallback implements IBZUAAFeignClient {
@Override
public Map<String, Object> pushSystemPermissionData(Map<String, Object> systemPermissionData, String systemId) {
public JSONObject pushSystemPermissionData(Map<String, Object> systemPermissionData, String systemId) {
return null;
}
......
......@@ -4,6 +4,7 @@ import cn.ibizlab.util.security.AuthenticationUser;
import cn.ibizlab.util.security.AuthorizationLogin;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import com.alibaba.fastjson.JSONObject;
import java.util.Map;
@FeignClient(value = "ibzuaa-api",fallback = IBZUAAFallback.class)
......@@ -16,7 +17,7 @@ public interface IBZUAAFeignClient
* @return
*/
@PostMapping("/uaa/permission/save")
Map<String,Object> pushSystemPermissionData(@RequestBody Map<String, Object> systemPermissionData, @RequestParam("systemid") String systemId);
JSONObject pushSystemPermissionData(@RequestBody Map<String, Object> systemPermissionData, @RequestParam("systemid") String systemId);
/**
* 用户登录
......
......@@ -39,15 +39,20 @@ public class PermissionSyncJob implements ApplicationRunner {
public void run(ApplicationArguments args) {
if(enablePermissionValid){
try {
InputStream permission= this.getClass().getResourceAsStream("/deprivs/DEPrivs.json"); //获取当前系统所有实体资源能力
InputStream permission= this.getClass().getResourceAsStream("/permission/systemResource.json"); //获取当前系统所有实体资源能力
String permissionResult = IOUtils.toString(permission,"UTF-8");
JSONObject jsonNodePermission = JSONObject.parseObject(permissionResult);
Map<String,Object> map=new HashMap<>();
map.put("permission",jsonNodePermission);
client.pushSystemPermissionData(map,systemId);
JSONObject syncResult=client.pushSystemPermissionData(map,systemId);
if(syncResult.getInteger("code")==1){
log.info("向[UAA]同步系统资源成功");
}else{
log.info(String.format("向[UAA]同步系统资源失败,失败原因为[%s]",syncResult.getString("msg")));
}
}
catch (Exception ex) {
log.error(String.format("向UAA同步数据发生错误,请检查UAA服务是否正常! [%s]",ex));
log.error(String.format("向[UAA]同步系统资源失败,请检查[UAA]服务是否正常! [%s]",ex));
}
}
}
......
......@@ -23,13 +23,16 @@ public class AppController {
JSONObject appData = new JSONObject() ;
JSONArray uniRes=new JSONArray();
JSONArray appMenu=new JSONArray();
if(enablePermissionValid){
JSONObject userPermission=AuthenticationUser.getAuthenticationUser().getPermissionList();
if(!ObjectUtils.isEmpty(userPermission)){
uniRes = userPermission.getJSONArray("unires");
appMenu = userPermission.getJSONArray("appmenu");
}
}
appData.put("unires",uniRes);
appData.put("appmenu",appMenu);
appData.put("enablepermissionvalid",enablePermissionValid);
return ResponseEntity.status(HttpStatus.OK).body(appData);
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册