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

ibizdev提交

上级 da7097fb
......@@ -51,38 +51,13 @@ export default class CodeListService {
*/
public getItems(tag: string,context:any = {}, data?: any, isloading?: boolean,): Promise<any[]> {
let _this: any = this;
let isEnableCache:boolean = _this[tag].isEnableCache;
let cacheTimeout:any = _this[tag].cacheTimeout;
return new Promise((resolve:any,reject:any) =>{
if(!data){
if(this.$store && _this.$store.getters){
let items:any = _this.$store.getters.getCodeListItems(tag);
if(items.length >0){
return resolve(items);
}
}
if (_this[tag]) {
const callback:Function = (tag:string,promise:Promise<any>) =>{
promise.then((result:any) =>{
if(result.length > 0){
_this.$store.commit('updateCodeList',{srfkey:tag,items:result});
return resolve(result);
}else{
return resolve([]);
}
}).catch((result:any) =>{
return reject(result);
})
}
if(CodeListService.codelistCache.get(tag)){
callback(tag,CodeListService.codelistCache.get(tag));
}else{
let result:Promise<any> = _this[tag].getItems(context,data,isloading);
CodeListService.codelistCache.set(tag,result);
callback(tag,result);
}
}
}else{
// 如有查询参数传递过来,需直接加载,不能使用缓存
if(data && Object.keys(data).length >0){
if (_this[tag]) {
_this[tag].getItems(context,data,isloading).then((result:any) =>{
_this[tag].getItems(context,JSON.parse(JSON.stringify(data)),isloading).then((result:any) =>{
resolve(result);
}).catch((error:any) =>{
Promise.reject([]);
......@@ -90,6 +65,66 @@ export default class CodeListService {
}else{
return Promise.reject([]);
}
}else{
// 启用缓存
if(isEnableCache){
// 加载完成,从store获取
if(this.$store && _this.$store.getters){
let items:any = _this.$store.getters.getCodeListItems(tag);
if(items.length >0){
if(cacheTimeout !== -1){
if(new Date().getTime() > _this[tag].expirationTime){
_this[tag].getItems(context,data,isloading).then((result:any) =>{
_this.$store.commit('updateCodeList',{srfkey:tag,items:result});
_this[tag].expirationTime = new Date().getTime() + cacheTimeout;
resolve(result);
}).catch((error:any) =>{
Promise.reject([]);
})
}else{
return resolve(items);
}
}else{
return resolve(items);
}
}
}
if (_this[tag]) {
const callback:Function = (tag:string,promise:Promise<any>) =>{
promise.then((result:any) =>{
if(result.length > 0){
_this.$store.commit('updateCodeList',{srfkey:tag,items:result});
return resolve(result);
}else{
return resolve([]);
}
}).catch((result:any) =>{
return reject(result);
})
}
// 加载中,UI又需要数据,解决连续加载同一代码表问题
if(CodeListService.codelistCache.get(tag)){
callback(tag,CodeListService.codelistCache.get(tag));
}else{
let result:Promise<any> = _this[tag].getItems(context,data,isloading);
CodeListService.codelistCache.set(tag,result);
if(cacheTimeout !== -1){
_this[tag].expirationTime = new Date().getTime() + cacheTimeout;
}
callback(tag,result);
}
}
}else{
if (_this[tag]) {
_this[tag].getItems(context,data,isloading).then((result:any) =>{
resolve(result);
}).catch((error:any) =>{
Promise.reject([]);
})
}else{
return Promise.reject([]);
}
}
}
})
}
......
FROM openjdk:8-jre-alpine
ENV SPRING_OUTPUT_ANSI_ENABLED=ALWAYS \
......@@ -6,8 +7,8 @@ ENV SPRING_OUTPUT_ANSI_ENABLED=ALWAYS \
CMD echo "The application will start in ${IBZ_SLEEP}s..." && \
sleep ${IBZ_SLEEP} && \
java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /ibzuaa.jar
java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /ibzuaa-app-web.jar
EXPOSE 8080
ADD ibzuaa.jar /ibzuaa.jar
ADD ibzuaa-app-web.jar /ibzuaa-app-web.jar
......@@ -112,7 +112,7 @@
</createTable>
</changeSet>
<!--输出实体[SYS_PERMISSION]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-sys_permission-30-6">
<changeSet author="a_A_5d9d78509" id="tab-sys_permission-31-6">
<createTable tableName="IBZPERMISSION">
<column name="SYS_PERMISSIONID" remarks="" type="VARCHAR(200)">
<constraints primaryKey="true" primaryKeyName="PK_SYS_PERMISSION_SYS_PERMISSI"/>
......
......@@ -8,12 +8,12 @@ import java.util.Map;
public class UAAFallback implements UAAFeignClient {
@Override
public JSONObject getPermission(String userid, String systemid) {
public JSONObject getUserPermissionData(String userId, String systemId) {
return null;
}
@Override
public Map<String, Object> pushPermissionData(Map<String, Object> map, String systemid) {
public Map<String, Object> pushSystemPermissionData(Map<String, Object> systemPermissionData, String systemId) {
return null;
}
......
......@@ -2,20 +2,29 @@ package cn.ibizlab.util.client.uaa;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@FeignClient(value = "ibzuaa",fallback = UAAFallback.class)
public interface UAAFeignClient
{
@GetMapping(value = "/uaa/getpermission")
JSONObject getPermission( @RequestParam("userid") String userid, @RequestParam("systemid") String systemid);
/**
* 从uaa中获取当前用户权限
* @param userId
* @param systemId
* @return
*/
@GetMapping(value = "/uaa/permission/{userid}")
JSONObject getUserPermissionData(@PathVariable("userid") String userId, @RequestParam("systemid") String systemId);
@PostMapping("/uaa/pushpermissiondata")
Map<String,Object> pushPermissionData(@RequestBody Map<String, Object> map, @RequestParam("systemid") String systemid);
/**
* 推送系统权限数据到uaa
* @param systemPermissionData
* @param systemId
* @return
*/
@PostMapping("/uaa/permission/save")
Map<String,Object> pushSystemPermissionData(@RequestBody Map<String, Object> systemPermissionData, @RequestParam("systemid") String systemId);
}
......@@ -45,7 +45,7 @@ public class PermissionSyncJob implements ApplicationRunner {
Map<String,Object> map=new HashMap<String,Object>();
map.put("menu",new JSONArray());
map.put("permission",jsonNodePermission);
client.pushPermissionData(map,systemId);
client.pushSystemPermissionData(map,systemId);
}
catch (Exception ex) {
log.error(String.format("向UAA同步数据发生错误,请检查UAA服务是否正常! [%s]",ex));
......
......@@ -90,7 +90,7 @@ public class SimpleUserService implements AuthenticationUserService{
String userid=curUser.getUserid();
//String userid="4fb71d8997d4505d2748ad2bdc471969";
//String systemid="2C40DFCD-0DF5-47BF-91A5-C45F810B0001";
JSONObject permission= client.getPermission(userid,systemid);
JSONObject permission= client.getUserPermissionData(userid,systemid);
curUser.setPermisionList(permission);
}
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册