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

ibiz4j 发布系统代码

上级 42fda8c6
...@@ -4,14 +4,13 @@ import cn.ibizlab.util.security.AuthenticationUser; ...@@ -4,14 +4,13 @@ import cn.ibizlab.util.security.AuthenticationUser;
import cn.ibizlab.util.security.AuthorizationLogin; import cn.ibizlab.util.security.AuthorizationLogin;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import java.util.Map;
@Component @Component
public class IBZUAAFallback implements IBZUAAFeignClient { public class IBZUAAFallback implements IBZUAAFeignClient {
@Override @Override
public JSONObject pushSystemPermissionData(Map<String, Object> systemPermissionData, String systemId) { public boolean pushSystemPermissionData(String systemid,JSONObject systemPermissionData) {
return null; return false;
} }
@Override @Override
......
...@@ -5,19 +5,18 @@ import cn.ibizlab.util.security.AuthorizationLogin; ...@@ -5,19 +5,18 @@ import cn.ibizlab.util.security.AuthorizationLogin;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import java.util.Map;
@FeignClient(value = "ibzuaa-api",fallback = IBZUAAFallback.class) @FeignClient(value = "ibzuaa-api",fallback = IBZUAAFallback.class)
public interface IBZUAAFeignClient public interface IBZUAAFeignClient
{ {
/** /**
* 推送系统权限数据到uaa * 推送系统权限数据到uaa
* @param systemid
* @param systemPermissionData * @param systemPermissionData
* @param systemId
* @return * @return
*/ */
@PostMapping("/uaa/permission/save") @PostMapping("/syspssystems/{systemid}/permissiondata")
JSONObject pushSystemPermissionData(@RequestBody Map<String, Object> systemPermissionData, @RequestParam("systemid") String systemId); boolean pushSystemPermissionData(@PathVariable("systemid") String systemid,@RequestBody JSONObject systemPermissionData);
/** /**
* 用户登录 * 用户登录
......
package cn.ibizlab.util.job; package cn.ibizlab.util.job;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import cn.ibizlab.util.client.IBZUAAFeignClient; import cn.ibizlab.util.client.IBZUAAFeignClient;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner; import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.InputStream; import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import java.io.IOException;
/** /**
* 权限:向uaa同步当前系统菜单、权限资源任务类 * 权限:向uaa同步当前系统菜单、权限资源任务类
*/ */
//@Component //开启此类需要保证Main中开启了feign :EnableFeignClients @Slf4j
@Component
@ConditionalOnProperty( name = "ibiz.enablePermissionValid", havingValue = "true")
public class PermissionSyncJob implements ApplicationRunner { public class PermissionSyncJob implements ApplicationRunner {
private Log log = LogFactory.getLog(PermissionSyncJob.class);
@Autowired @Autowired
@Lazy
private IBZUAAFeignClient client; private IBZUAAFeignClient client;
@Value("${ibiz.enablePermissionValid:false}")
boolean enablePermissionValid; //是否开启权限校验
@Value("${ibiz.systemid:ibzou}") @Value("${ibiz.systemid:ibzou}")
private String systemId; private String systemId;
@Override @Override
public void run(ApplicationArguments args) { public void run(ApplicationArguments args) {
if(enablePermissionValid){
try { try {
Thread.sleep(10000);
InputStream permission= this.getClass().getResourceAsStream("/permission/systemResource.json"); //获取当前系统所有实体资源能力 InputStream permission= this.getClass().getResourceAsStream("/permission/systemResource.json"); //获取当前系统所有实体资源能力
String permissionResult = IOUtils.toString(permission,"UTF-8"); String permissionResult = IOUtils.toString(permission,"UTF-8");
JSONObject jsonNodePermission = JSONObject.parseObject(permissionResult); if(client.pushSystemPermissionData(systemId,JSONObject.parseObject(permissionResult))){
Map<String,Object> map=new HashMap<>();
map.put("permission",jsonNodePermission);
JSONObject syncResult=client.pushSystemPermissionData(map,systemId);
if(syncResult.getInteger("code")==1){
log.info("向[UAA]同步系统资源成功"); log.info("向[UAA]同步系统资源成功");
}else{ }else{
log.info(String.format("向[UAA]同步系统资源失败,失败原因为[%s]",syncResult.getString("msg"))); log.info(String.format("向[UAA]同步系统资源失败"));
} }
} }
catch (Exception ex) { catch (Exception ex) {
log.error(String.format("向[UAA]同步系统资源失败,请检查[UAA]服务是否正常! [%s]",ex)); log.error(String.format("向[UAA]同步系统资源失败,请检查[UAA]服务是否正常! [%s]",ex));
} }
} }
}
} }
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册