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

ibiz4j 发布系统代码

上级 2ec60a6e
...@@ -178,17 +178,33 @@ mock.onPut(new RegExp(/^\/dictcatalogs\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((conf ...@@ -178,17 +178,33 @@ mock.onPut(new RegExp(/^\/dictcatalogs\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((conf
console.groupEnd(); console.groupEnd();
return [status, data]; return [status, data];
}); });
// GetDraft
mock.onGet(new RegExp(/^\/dictcatalogs\/getdraft$/)).reply((config: any) => {
console.groupCollapsed("实体:dictcatalog 方法: GetDraft");
console.table({url:config.url, method: config.method, data:config.data});
// GetDraft
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table({});
console.groupEnd();
console.groupEnd();
return [status, {}];
});
// Save // CheckKey
mock.onPost(new RegExp(/^\/dictcatalogs\/?([a-zA-Z0-9\-\;]{0,35})\/save$/)).reply((config: any) => { mock.onPost(new RegExp(/^\/dictcatalogs\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).reply((config: any) => {
console.groupCollapsed("实体:dictcatalog 方法: Save"); console.groupCollapsed("实体:dictcatalog 方法: CheckKey");
console.table({url:config.url, method: config.method, data:config.data}); console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config); let status = MockAdapter.mockStatus(config);
if (status !== 200) { if (status !== 200) {
return [status, null]; return [status, null];
} }
const paramArray:Array<any> = ['id']; const paramArray:Array<any> = ['id'];
const matchArray:any = new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/save$/).exec(config.url); const matchArray:any = new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/checkkey$/).exec(config.url);
let tempValue: any = {}; let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){ if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => { paramArray.forEach((item: any, index: number) => {
...@@ -216,33 +232,17 @@ mock.onPost(new RegExp(/^\/dictcatalogs\/?([a-zA-Z0-9\-\;]{0,35})\/save$/)).repl ...@@ -216,33 +232,17 @@ mock.onPost(new RegExp(/^\/dictcatalogs\/?([a-zA-Z0-9\-\;]{0,35})\/save$/)).repl
console.groupEnd(); console.groupEnd();
return [status, data]; return [status, data];
}); });
// GetDraft
mock.onGet(new RegExp(/^\/dictcatalogs\/getdraft$/)).reply((config: any) => {
console.groupCollapsed("实体:dictcatalog 方法: GetDraft");
console.table({url:config.url, method: config.method, data:config.data});
// GetDraft
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table({});
console.groupEnd();
console.groupEnd();
return [status, {}];
});
// CheckKey // Save
mock.onPost(new RegExp(/^\/dictcatalogs\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).reply((config: any) => { mock.onPost(new RegExp(/^\/dictcatalogs\/?([a-zA-Z0-9\-\;]{0,35})\/save$/)).reply((config: any) => {
console.groupCollapsed("实体:dictcatalog 方法: CheckKey"); console.groupCollapsed("实体:dictcatalog 方法: Save");
console.table({url:config.url, method: config.method, data:config.data}); console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config); let status = MockAdapter.mockStatus(config);
if (status !== 200) { if (status !== 200) {
return [status, null]; return [status, null];
} }
const paramArray:Array<any> = ['id']; const paramArray:Array<any> = ['id'];
const matchArray:any = new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/checkkey$/).exec(config.url); const matchArray:any = new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/save$/).exec(config.url);
let tempValue: any = {}; let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){ if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => { paramArray.forEach((item: any, index: number) => {
...@@ -323,9 +323,9 @@ mock.onGet(new RegExp(/^\/dictcatalogs\/fetchdefault(\?[\w-./?%&=,]*)*$/)).reply ...@@ -323,9 +323,9 @@ mock.onGet(new RegExp(/^\/dictcatalogs\/fetchdefault(\?[\w-./?%&=,]*)*$/)).reply
// URI参数传递情况未实现 // URI参数传递情况未实现
// Get // Remove
mock.onGet(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => { mock.onDelete(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:dictcatalog 方法: Get"); console.groupCollapsed("实体:dictcatalog 方法: Remove");
console.table({url:config.url, method: config.method, data:config.data}); console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config); let status = MockAdapter.mockStatus(config);
if (status !== 200) { if (status !== 200) {
...@@ -351,9 +351,9 @@ mock.onGet(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((confi ...@@ -351,9 +351,9 @@ mock.onGet(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((confi
return [status, _items?_items:{}]; return [status, _items?_items:{}];
}); });
// Remove // Get
mock.onDelete(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => { mock.onGet(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:dictcatalog 方法: Remove"); console.groupCollapsed("实体:dictcatalog 方法: Get");
console.table({url:config.url, method: config.method, data:config.data}); console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config); let status = MockAdapter.mockStatus(config);
if (status !== 200) { if (status !== 200) {
......
...@@ -145,9 +145,9 @@ mock.onGet(new RegExp(/^\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})\/select$/)).reply ...@@ -145,9 +145,9 @@ mock.onGet(new RegExp(/^\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})\/select$/)).reply
}); });
// Update // Create
mock.onPut(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => { mock.onPost(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:dictoption 方法: Update"); console.groupCollapsed("实体:dictoption 方法: Create");
console.table({url:config.url, method: config.method, data:config.data}); console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config); let status = MockAdapter.mockStatus(config);
if (status !== 200) { if (status !== 200) {
...@@ -171,9 +171,9 @@ mock.onPut(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/([ ...@@ -171,9 +171,9 @@ mock.onPut(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/([
return [status, {}]; return [status, {}];
}); });
// Update // Create
mock.onPut(new RegExp(/^\/dictoptions\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((config: any) => { mock.onPost(new RegExp(/^\/dictoptions\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:dictoption 方法: Update"); console.groupCollapsed("实体:dictoption 方法: Create");
console.table({url:config.url, method: config.method, data:config.data}); console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config); let status = MockAdapter.mockStatus(config);
if (status !== 200) { if (status !== 200) {
...@@ -190,37 +190,24 @@ mock.onPut(new RegExp(/^\/dictoptions\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((confi ...@@ -190,37 +190,24 @@ mock.onPut(new RegExp(/^\/dictoptions\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((confi
}); });
}); });
} }
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.value_key, tempValue.value_key));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['value_key'] == tempValue['value_key'] ){
for(let value in data){
if(item.hasOwnProperty(value)){
item[value] = data[value];
}
}
}
})
console.groupCollapsed("response数据 status: "+status+" data: "); console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(data); console.table(mockDatas[0]);
console.groupEnd(); console.groupEnd();
console.groupEnd(); console.groupEnd();
return [status, data]; return [status, mockDatas[0]];
}); });
// CheckKey // Update
mock.onPost(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})\/checkkey$/)).reply((config: any) => { mock.onPut(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:dictoption 方法: CheckKey"); console.groupCollapsed("实体:dictoption 方法: Update");
console.table({url:config.url, method: config.method, data:config.data}); console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config); let status = MockAdapter.mockStatus(config);
if (status !== 200) { if (status !== 200) {
return [status, null]; return [status, null];
} }
const paramArray:Array<any> = ['id','value_key']; const paramArray:Array<any> = ['id','value_key'];
const matchArray:any = new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})\/checkkey$/).exec(config.url); const matchArray:any = new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})$/).exec(config.url);
let tempValue: any = {}; let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){ if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => { paramArray.forEach((item: any, index: number) => {
...@@ -237,16 +224,16 @@ mock.onPost(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/( ...@@ -237,16 +224,16 @@ mock.onPost(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/(
return [status, {}]; return [status, {}];
}); });
// CheckKey // Update
mock.onPost(new RegExp(/^\/dictoptions\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).reply((config: any) => { mock.onPut(new RegExp(/^\/dictoptions\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:dictoption 方法: CheckKey"); console.groupCollapsed("实体:dictoption 方法: Update");
console.table({url:config.url, method: config.method, data:config.data}); console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config); let status = MockAdapter.mockStatus(config);
if (status !== 200) { if (status !== 200) {
return [status, null]; return [status, null];
} }
const paramArray:Array<any> = ['value_key']; const paramArray:Array<any> = ['value_key'];
const matchArray:any = new RegExp(/^\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})\/checkkey$/).exec(config.url); const matchArray:any = new RegExp(/^\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})$/).exec(config.url);
let tempValue: any = {}; let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){ if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => { paramArray.forEach((item: any, index: number) => {
...@@ -276,6 +263,8 @@ mock.onPost(new RegExp(/^\/dictoptions\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).r ...@@ -276,6 +263,8 @@ mock.onPost(new RegExp(/^\/dictoptions\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).r
}); });
// GetDraft // GetDraft
mock.onGet(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/getdraft$/)).reply((config: any) => { mock.onGet(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/getdraft$/)).reply((config: any) => {
console.groupCollapsed("实体:dictoption 方法: GetDraft"); console.groupCollapsed("实体:dictoption 方法: GetDraft");
...@@ -308,18 +297,17 @@ mock.onGet(new RegExp(/^\/dictoptions\/getdraft$/)).reply((config: any) => { ...@@ -308,18 +297,17 @@ mock.onGet(new RegExp(/^\/dictoptions\/getdraft$/)).reply((config: any) => {
return [status, {}]; return [status, {}];
}); });
// Create // CheckKey
mock.onPost(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => { mock.onPost(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})\/checkkey$/)).reply((config: any) => {
console.groupCollapsed("实体:dictoption 方法: Create"); console.groupCollapsed("实体:dictoption 方法: CheckKey");
console.table({url:config.url, method: config.method, data:config.data}); console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config); let status = MockAdapter.mockStatus(config);
if (status !== 200) { if (status !== 200) {
return [status, null]; return [status, null];
} }
const paramArray:Array<any> = ['id','value_key']; const paramArray:Array<any> = ['id','value_key'];
const matchArray:any = new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})$/).exec(config.url); const matchArray:any = new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})\/checkkey$/).exec(config.url);
let tempValue: any = {}; let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){ if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => { paramArray.forEach((item: any, index: number) => {
...@@ -336,16 +324,16 @@ mock.onPost(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/( ...@@ -336,16 +324,16 @@ mock.onPost(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/(
return [status, {}]; return [status, {}];
}); });
// Create // CheckKey
mock.onPost(new RegExp(/^\/dictoptions\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((config: any) => { mock.onPost(new RegExp(/^\/dictoptions\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).reply((config: any) => {
console.groupCollapsed("实体:dictoption 方法: Create"); console.groupCollapsed("实体:dictoption 方法: CheckKey");
console.table({url:config.url, method: config.method, data:config.data}); console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config); let status = MockAdapter.mockStatus(config);
if (status !== 200) { if (status !== 200) {
return [status, null]; return [status, null];
} }
const paramArray:Array<any> = ['value_key']; const paramArray:Array<any> = ['value_key'];
const matchArray:any = new RegExp(/^\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})$/).exec(config.url); const matchArray:any = new RegExp(/^\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})\/checkkey$/).exec(config.url);
let tempValue: any = {}; let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){ if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => { paramArray.forEach((item: any, index: number) => {
...@@ -355,11 +343,23 @@ mock.onPost(new RegExp(/^\/dictoptions\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((conf ...@@ -355,11 +343,23 @@ mock.onPost(new RegExp(/^\/dictoptions\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((conf
}); });
}); });
} }
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.value_key, tempValue.value_key));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['value_key'] == tempValue['value_key'] ){
for(let value in data){
if(item.hasOwnProperty(value)){
item[value] = data[value];
}
}
}
})
console.groupCollapsed("response数据 status: "+status+" data: "); console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(mockDatas[0]); console.table(data);
console.groupEnd(); console.groupEnd();
console.groupEnd(); console.groupEnd();
return [status, mockDatas[0]]; return [status, data];
}); });
......
...@@ -1186,14 +1186,44 @@ export default class DictCatalogGridViewBase extends Vue { ...@@ -1186,14 +1186,44 @@ export default class DictCatalogGridViewBase extends Vue {
} }
!!!!模版产生代码错误:---- /**
Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? * 打开编辑数据视图
---- *
* @param {any[]} args
---- * @param {*} [params]
FTL stack trace ("~" means nesting-related): * @param {*} [fullargs]
- Failed at: #if ctrl.getPSControlContainer().getV... [in template "TEMPLCODE_zh_CN" at line 43, column 5] * @param {*} [$event]
---- * @param {*} [xData]
* @memberof DictCatalogGridView
*/
public opendata(args: any[],fullargs?:any[],params?: any, $event?: any, xData?: any) {
if(!this.viewDefaultUsage){
if(Object.is(this.navModel,"route")){
this.initNavDataWithRoute(this.viewCacheData, false, true);
}else{
this.initNavDataWithTab(this.viewCacheData, false, true);
}
}
let localContext:any = null;
let localViewParam:any =null;
const data: any = {};
let tempContext = JSON.parse(JSON.stringify(this.context));
if(args.length >0){
Object.assign(tempContext,args[0]);
}
const deResParameters: any[] = [];
const parameters: any[] = [
{ pathName: 'dictcatalogs', parameterName: 'dictcatalog' },
{ pathName: 'editview', parameterName: 'editview' },
];
const _this: any = this;
const openIndexViewTab = (data: any) => {
const routePath = this.$viewTool.buildUpRoutePath(this.$route, tempContext, deResParameters, parameters, args, data);
this.$router.push(routePath);
}
openIndexViewTab(data);
}
/** /**
* 新建 * 新建
......
...@@ -1159,14 +1159,63 @@ export default class DictOptionGridEditViewBase extends Vue { ...@@ -1159,14 +1159,63 @@ export default class DictOptionGridEditViewBase extends Vue {
} }
!!!!模版产生代码错误:---- /**
Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? * 打开编辑数据视图
---- *
* @param {any[]} args
---- * @param {*} [params]
FTL stack trace ("~" means nesting-related): * @param {*} [fullargs]
- Failed at: #if ctrl.getPSControlContainer().getV... [in template "TEMPLCODE_zh_CN" at line 43, column 5] * @param {*} [$event]
---- * @param {*} [xData]
* @memberof DictOptionGridEditView
*/
public opendata(args: any[],fullargs?:any[],params?: any, $event?: any, xData?: any) {
if(!this.viewDefaultUsage){
if(Object.is(this.navModel,"route")){
this.initNavDataWithRoute(this.viewCacheData, false, true);
}else{
this.initNavDataWithTab(this.viewCacheData, false, true);
}
}
let localContext:any = null;
let localViewParam:any =null;
const data: any = {};
let tempContext = JSON.parse(JSON.stringify(this.context));
if(args.length >0){
Object.assign(tempContext,args[0]);
}
let deResParameters: any[] = [];
if(tempContext.dictcatalog && true){
deResParameters = [
{ pathName: 'dictcatalogs', parameterName: 'dictcatalog' },
]
}
const parameters: any[] = [
{ pathName: 'dictoptions', parameterName: 'dictoption' },
];
const _this: any = this;
const openDrawer = (view: any, data: any) => {
let container: Subject<any> = this.$appdrawer.openDrawer(view, tempContext, data);
container.subscribe((result: any) => {
if (!result || !Object.is(result.ret, 'OK')) {
return;
}
if (!xData || !(xData.refresh instanceof Function)) {
return;
}
xData.refresh(result.datas);
});
}
const view: any = {
viewname: 'dict-option-edit-view',
height: 0,
width: 0,
title: this.$t('entities.dictoption.views.editview.title'),
placement: 'DRAWER_RIGHT',
};
openDrawer(view, data);
}
/** /**
* 新建 * 新建
......
...@@ -1159,14 +1159,63 @@ export default class DictOptionGridViewBase extends Vue { ...@@ -1159,14 +1159,63 @@ export default class DictOptionGridViewBase extends Vue {
} }
!!!!模版产生代码错误:---- /**
Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? * 打开编辑数据视图
---- *
* @param {any[]} args
---- * @param {*} [params]
FTL stack trace ("~" means nesting-related): * @param {*} [fullargs]
- Failed at: #if ctrl.getPSControlContainer().getV... [in template "TEMPLCODE_zh_CN" at line 43, column 5] * @param {*} [$event]
---- * @param {*} [xData]
* @memberof DictOptionGridView
*/
public opendata(args: any[],fullargs?:any[],params?: any, $event?: any, xData?: any) {
if(!this.viewDefaultUsage){
if(Object.is(this.navModel,"route")){
this.initNavDataWithRoute(this.viewCacheData, false, true);
}else{
this.initNavDataWithTab(this.viewCacheData, false, true);
}
}
let localContext:any = null;
let localViewParam:any =null;
const data: any = {};
let tempContext = JSON.parse(JSON.stringify(this.context));
if(args.length >0){
Object.assign(tempContext,args[0]);
}
let deResParameters: any[] = [];
if(tempContext.dictcatalog && true){
deResParameters = [
{ pathName: 'dictcatalogs', parameterName: 'dictcatalog' },
]
}
const parameters: any[] = [
{ pathName: 'dictoptions', parameterName: 'dictoption' },
];
const _this: any = this;
const openDrawer = (view: any, data: any) => {
let container: Subject<any> = this.$appdrawer.openDrawer(view, tempContext, data);
container.subscribe((result: any) => {
if (!result || !Object.is(result.ret, 'OK')) {
return;
}
if (!xData || !(xData.refresh instanceof Function)) {
return;
}
xData.refresh(result.datas);
});
}
const view: any = {
viewname: 'dict-option-edit-view',
height: 0,
width: 0,
title: this.$t('entities.dictoption.views.editview.title'),
placement: 'DRAWER_RIGHT',
};
openDrawer(view, data);
}
/** /**
* 新建 * 新建
......
...@@ -124,7 +124,7 @@ export default class DictCatalogServiceBase extends EntityService { ...@@ -124,7 +124,7 @@ export default class DictCatalogServiceBase extends EntityService {
} }
/** /**
* Save接口方法 * Remove接口方法
* *
* @param {*} [context={}] * @param {*} [context={}]
* @param {*} [data={}] * @param {*} [data={}]
...@@ -132,26 +132,8 @@ export default class DictCatalogServiceBase extends EntityService { ...@@ -132,26 +132,8 @@ export default class DictCatalogServiceBase extends EntityService {
* @returns {Promise<any>} * @returns {Promise<any>}
* @memberof DictCatalogServiceBase * @memberof DictCatalogServiceBase
*/ */
public async Save(context: any = {},data: any = {}, isloading?: boolean): Promise<any> { public async Remove(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let masterData:any = {}; let res:any = await Http.getInstance().delete(`/dictcatalogs/${context.dictcatalog}`,isloading);
let dictoptionsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_dictoptions'),'undefined')){
dictoptionsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_dictoptions') as any);
if(dictoptionsData && dictoptionsData.length && dictoptionsData.length > 0){
dictoptionsData.forEach((item:any) => {
if(item.srffrontuf){
if(Object.is(item.srffrontuf,"0")){
item.value_key = null;
}
delete item.srffrontuf;
}
});
}
}
masterData.dictoptions = dictoptionsData;
Object.assign(data,masterData);
let res:any = await Http.getInstance().post(`/dictcatalogs/${context.dictcatalog}/save`,data,isloading);
this.tempStorage.setItem(context.srfsessionkey+'_dictoptions',JSON.stringify(res.data.dictoptions));
return res; return res;
} }
...@@ -187,7 +169,7 @@ export default class DictCatalogServiceBase extends EntityService { ...@@ -187,7 +169,7 @@ export default class DictCatalogServiceBase extends EntityService {
} }
/** /**
* Remove接口方法 * CheckKey接口方法
* *
* @param {*} [context={}] * @param {*} [context={}]
* @param {*} [data={}] * @param {*} [data={}]
...@@ -195,13 +177,13 @@ export default class DictCatalogServiceBase extends EntityService { ...@@ -195,13 +177,13 @@ export default class DictCatalogServiceBase extends EntityService {
* @returns {Promise<any>} * @returns {Promise<any>}
* @memberof DictCatalogServiceBase * @memberof DictCatalogServiceBase
*/ */
public async Remove(context: any = {},data: any = {}, isloading?: boolean): Promise<any> { public async CheckKey(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = await Http.getInstance().delete(`/dictcatalogs/${context.dictcatalog}`,isloading); let res:any = await Http.getInstance().post(`/dictcatalogs/${context.dictcatalog}/checkkey`,data,isloading);
return res; return res;
} }
/** /**
* CheckKey接口方法 * Save接口方法
* *
* @param {*} [context={}] * @param {*} [context={}]
* @param {*} [data={}] * @param {*} [data={}]
...@@ -209,8 +191,26 @@ export default class DictCatalogServiceBase extends EntityService { ...@@ -209,8 +191,26 @@ export default class DictCatalogServiceBase extends EntityService {
* @returns {Promise<any>} * @returns {Promise<any>}
* @memberof DictCatalogServiceBase * @memberof DictCatalogServiceBase
*/ */
public async CheckKey(context: any = {},data: any = {}, isloading?: boolean): Promise<any> { public async Save(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = await Http.getInstance().post(`/dictcatalogs/${context.dictcatalog}/checkkey`,data,isloading); let masterData:any = {};
let dictoptionsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_dictoptions'),'undefined')){
dictoptionsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_dictoptions') as any);
if(dictoptionsData && dictoptionsData.length && dictoptionsData.length > 0){
dictoptionsData.forEach((item:any) => {
if(item.srffrontuf){
if(Object.is(item.srffrontuf,"0")){
item.value_key = null;
}
delete item.srffrontuf;
}
});
}
}
masterData.dictoptions = dictoptionsData;
Object.assign(data,masterData);
let res:any = await Http.getInstance().post(`/dictcatalogs/${context.dictcatalog}/save`,data,isloading);
this.tempStorage.setItem(context.srfsessionkey+'_dictoptions',JSON.stringify(res.data.dictoptions));
return res; return res;
} }
......
...@@ -55,6 +55,41 @@ export default class DictOptionServiceBase extends EntityService { ...@@ -55,6 +55,41 @@ export default class DictOptionServiceBase extends EntityService {
return res; return res;
} }
/**
* Create接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DictOptionServiceBase
*/
public async Create(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.dictcatalog && true){
let masterData:any = {};
Object.assign(data,masterData);
if(!data.srffrontuf || data.srffrontuf !== "1"){
data[this.APPDEKEY] = null;
}
if(data.srffrontuf){
delete data.srffrontuf;
}
let tempContext:any = JSON.parse(JSON.stringify(context));
let res:any = await Http.getInstance().post(`/dictcatalogs/${context.dictcatalog}/dictoptions`,data,isloading);
}
let masterData:any = {};
Object.assign(data,masterData);
if(!data.srffrontuf || data.srffrontuf !== "1"){
data[this.APPDEKEY] = null;
}
if(data.srffrontuf){
delete data.srffrontuf;
}
let tempContext:any = JSON.parse(JSON.stringify(context));
let res:any = await Http.getInstance().post(`/dictoptions`,data,isloading);
return res;
}
/** /**
* Update接口方法 * Update接口方法
* *
...@@ -94,7 +129,7 @@ export default class DictOptionServiceBase extends EntityService { ...@@ -94,7 +129,7 @@ export default class DictOptionServiceBase extends EntityService {
} }
/** /**
* CheckKey接口方法 * Get接口方法
* *
* @param {*} [context={}] * @param {*} [context={}]
* @param {*} [data={}] * @param {*} [data={}]
...@@ -102,13 +137,11 @@ export default class DictOptionServiceBase extends EntityService { ...@@ -102,13 +137,11 @@ export default class DictOptionServiceBase extends EntityService {
* @returns {Promise<any>} * @returns {Promise<any>}
* @memberof DictOptionServiceBase * @memberof DictOptionServiceBase
*/ */
public async CheckKey(context: any = {},data: any = {}, isloading?: boolean): Promise<any> { public async Get(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.dictcatalog && context.dictoption){ if(context.dictcatalog && context.dictoption){
let masterData:any = {}; let res:any = await Http.getInstance().get(`/dictcatalogs/${context.dictcatalog}/dictoptions/${context.dictoption}`,isloading);
Object.assign(data,masterData);
let res:any = await Http.getInstance().post(`/dictcatalogs/${context.dictcatalog}/dictoptions/${context.dictoption}/checkkey`,data,isloading);
} }
let res:any = await Http.getInstance().post(`/dictoptions/${context.dictoption}/checkkey`,data,isloading); let res:any = await Http.getInstance().get(`/dictoptions/${context.dictoption}`,isloading);
return res; return res;
} }
...@@ -132,7 +165,7 @@ export default class DictOptionServiceBase extends EntityService { ...@@ -132,7 +165,7 @@ export default class DictOptionServiceBase extends EntityService {
} }
/** /**
* Get接口方法 * CheckKey接口方法
* *
* @param {*} [context={}] * @param {*} [context={}]
* @param {*} [data={}] * @param {*} [data={}]
...@@ -140,46 +173,13 @@ export default class DictOptionServiceBase extends EntityService { ...@@ -140,46 +173,13 @@ export default class DictOptionServiceBase extends EntityService {
* @returns {Promise<any>} * @returns {Promise<any>}
* @memberof DictOptionServiceBase * @memberof DictOptionServiceBase
*/ */
public async Get(context: any = {},data: any = {}, isloading?: boolean): Promise<any> { public async CheckKey(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.dictcatalog && context.dictoption){ if(context.dictcatalog && context.dictoption){
let res:any = await Http.getInstance().get(`/dictcatalogs/${context.dictcatalog}/dictoptions/${context.dictoption}`,isloading);
}
let res:any = await Http.getInstance().get(`/dictoptions/${context.dictoption}`,isloading);
return res;
}
/**
* Create接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DictOptionServiceBase
*/
public async Create(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.dictcatalog && true){
let masterData:any = {}; let masterData:any = {};
Object.assign(data,masterData); Object.assign(data,masterData);
if(!data.srffrontuf || data.srffrontuf !== "1"){ let res:any = await Http.getInstance().post(`/dictcatalogs/${context.dictcatalog}/dictoptions/${context.dictoption}/checkkey`,data,isloading);
data[this.APPDEKEY] = null;
}
if(data.srffrontuf){
delete data.srffrontuf;
}
let tempContext:any = JSON.parse(JSON.stringify(context));
let res:any = await Http.getInstance().post(`/dictcatalogs/${context.dictcatalog}/dictoptions`,data,isloading);
}
let masterData:any = {};
Object.assign(data,masterData);
if(!data.srffrontuf || data.srffrontuf !== "1"){
data[this.APPDEKEY] = null;
}
if(data.srffrontuf){
delete data.srffrontuf;
} }
let tempContext:any = JSON.parse(JSON.stringify(context)); let res:any = await Http.getInstance().post(`/dictoptions/${context.dictoption}/checkkey`,data,isloading);
let res:any = await Http.getInstance().post(`/dictoptions`,data,isloading);
return res; return res;
} }
......
...@@ -29,13 +29,13 @@ public interface IDictCatalogService extends IService<DictCatalog>{ ...@@ -29,13 +29,13 @@ public interface IDictCatalogService extends IService<DictCatalog>{
void createBatch(List<DictCatalog> list) ; void createBatch(List<DictCatalog> list) ;
boolean update(DictCatalog et) ; boolean update(DictCatalog et) ;
void updateBatch(List<DictCatalog> list) ; void updateBatch(List<DictCatalog> list) ;
boolean save(DictCatalog et) ;
void saveBatch(List<DictCatalog> list) ;
DictCatalog get(String key) ;
DictCatalog getDraft(DictCatalog et) ;
boolean remove(String key) ; boolean remove(String key) ;
void removeBatch(Collection<String> idList) ; void removeBatch(Collection<String> idList) ;
DictCatalog get(String key) ;
DictCatalog getDraft(DictCatalog et) ;
boolean checkKey(DictCatalog et) ; boolean checkKey(DictCatalog et) ;
boolean save(DictCatalog et) ;
void saveBatch(List<DictCatalog> list) ;
Page<DictCatalog> searchDefault(DictCatalogSearchContext context) ; Page<DictCatalog> searchDefault(DictCatalogSearchContext context) ;
/** /**
*自定义查询SQL *自定义查询SQL
......
...@@ -25,15 +25,15 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -25,15 +25,15 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/ */
public interface IDictOptionService extends IService<DictOption>{ public interface IDictOptionService extends IService<DictOption>{
boolean create(DictOption et) ;
void createBatch(List<DictOption> list) ;
boolean update(DictOption et) ; boolean update(DictOption et) ;
void updateBatch(List<DictOption> list) ; void updateBatch(List<DictOption> list) ;
boolean remove(String key) ; boolean remove(String key) ;
void removeBatch(Collection<String> idList) ; void removeBatch(Collection<String> idList) ;
boolean checkKey(DictOption et) ;
DictOption getDraft(DictOption et) ;
DictOption get(String key) ; DictOption get(String key) ;
boolean create(DictOption et) ; DictOption getDraft(DictOption et) ;
void createBatch(List<DictOption> list) ; boolean checkKey(DictOption et) ;
boolean save(DictOption et) ; boolean save(DictOption et) ;
void saveBatch(List<DictOption> list) ; void saveBatch(List<DictOption> list) ;
Page<DictOption> searchDefault(DictOptionSearchContext context) ; Page<DictOption> searchDefault(DictOptionSearchContext context) ;
......
...@@ -80,33 +80,14 @@ public class DictCatalogServiceImpl extends ServiceImpl<DictCatalogMapper, DictC ...@@ -80,33 +80,14 @@ public class DictCatalogServiceImpl extends ServiceImpl<DictCatalogMapper, DictC
@Override @Override
@Transactional @Transactional
public boolean save(DictCatalog et) { public boolean remove(String key) {
if(!saveOrUpdate(et)) boolean result=removeById(key);
return false; return result ;
return true;
}
@Override
@Transactional(
rollbackFor = {Exception.class}
)
public boolean saveOrUpdate(DictCatalog et) {
if (null == et) {
return false;
} else {
return checkKey(et) ? this.update(et) : this.create(et);
}
}
@Override
public boolean saveBatch(Collection<DictCatalog> list) {
saveOrUpdateBatch(list,batchSize);
return true;
} }
@Override @Override
public void saveBatch(List<DictCatalog> list) { public void removeBatch(Collection<String> idList) {
saveOrUpdateBatch(list,batchSize); removeByIds(idList);
} }
@Override @Override
...@@ -127,23 +108,42 @@ public class DictCatalogServiceImpl extends ServiceImpl<DictCatalogMapper, DictC ...@@ -127,23 +108,42 @@ public class DictCatalogServiceImpl extends ServiceImpl<DictCatalogMapper, DictC
return et; return et;
} }
@Override
public boolean checkKey(DictCatalog et) {
return (!ObjectUtils.isEmpty(et.getId()))&&(!Objects.isNull(this.getById(et.getId())));
}
@Override @Override
@Transactional @Transactional
public boolean remove(String key) { public boolean save(DictCatalog et) {
boolean result=removeById(key); if(!saveOrUpdate(et))
return result ; return false;
return true;
} }
@Override @Override
public void removeBatch(Collection<String> idList) { @Transactional(
removeByIds(idList); rollbackFor = {Exception.class}
)
public boolean saveOrUpdate(DictCatalog et) {
if (null == et) {
return false;
} else {
return checkKey(et) ? this.update(et) : this.create(et);
}
} }
@Override @Override
public boolean checkKey(DictCatalog et) { public boolean saveBatch(Collection<DictCatalog> list) {
return (!ObjectUtils.isEmpty(et.getId()))&&(!Objects.isNull(this.getById(et.getId()))); saveOrUpdateBatch(list,batchSize);
return true;
} }
@Override
public void saveBatch(List<DictCatalog> list) {
saveOrUpdateBatch(list,batchSize);
}
/** /**
* 查询集合 DEFAULT * 查询集合 DEFAULT
......
...@@ -50,6 +50,22 @@ public class DictOptionServiceImpl extends ServiceImpl<DictOptionMapper, DictOpt ...@@ -50,6 +50,22 @@ public class DictOptionServiceImpl extends ServiceImpl<DictOptionMapper, DictOpt
protected int batchSize = 500; protected int batchSize = 500;
@Override
@Transactional
public boolean create(DictOption et) {
fillParentData(et);
if(!this.retBool(this.baseMapper.insert(et)))
return false;
CachedBeanCopier.copy(get(et.getValueKey()),et);
return true;
}
@Override
public void createBatch(List<DictOption> list) {
list.forEach(item->fillParentData(item));
this.saveOrUpdateBatch(list,batchSize);
}
@Override @Override
@Transactional @Transactional
public boolean update(DictOption et) { public boolean update(DictOption et) {
...@@ -78,16 +94,6 @@ public class DictOptionServiceImpl extends ServiceImpl<DictOptionMapper, DictOpt ...@@ -78,16 +94,6 @@ public class DictOptionServiceImpl extends ServiceImpl<DictOptionMapper, DictOpt
removeByIds(idList); removeByIds(idList);
} }
@Override
public boolean checkKey(DictOption et) {
return (!ObjectUtils.isEmpty(et.getValueKey()))&&(!Objects.isNull(this.getById(et.getValueKey())));
}
@Override
public DictOption getDraft(DictOption et) {
fillParentData(et);
return et;
}
@Override @Override
@Transactional @Transactional
public DictOption get(String key) { public DictOption get(String key) {
...@@ -102,21 +108,15 @@ public class DictOptionServiceImpl extends ServiceImpl<DictOptionMapper, DictOpt ...@@ -102,21 +108,15 @@ public class DictOptionServiceImpl extends ServiceImpl<DictOptionMapper, DictOpt
} }
@Override @Override
@Transactional public DictOption getDraft(DictOption et) {
public boolean create(DictOption et) {
fillParentData(et); fillParentData(et);
if(!this.retBool(this.baseMapper.insert(et))) return et;
return false;
CachedBeanCopier.copy(get(et.getValueKey()),et);
return true;
} }
@Override @Override
public void createBatch(List<DictOption> list) { public boolean checkKey(DictOption et) {
list.forEach(item->fillParentData(item)); return (!ObjectUtils.isEmpty(et.getValueKey()))&&(!Objects.isNull(this.getById(et.getValueKey())));
this.saveOrUpdateBatch(list,batchSize);
} }
@Override @Override
@Transactional @Transactional
public boolean save(DictOption et) { public boolean save(DictOption et) {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
"delogicname":"字典", "delogicname":"字典",
"sysmoudle":{"id":"DICT","name":"dict"}, "sysmoudle":{"id":"DICT","name":"dict"},
"dedataset":[{"id":"Default" , "name":"DEFAULT"}], "dedataset":[{"id":"Default" , "name":"DEFAULT"}],
"deaction":[{"id":"Create" , "name":"Create" , "type":"BUILTIN" },{"id":"Update" , "name":"Update" , "type":"BUILTIN" },{"id":"Save" , "name":"Save" , "type":"BUILTIN" },{"id":"Get" , "name":"Get" , "type":"BUILTIN" },{"id":"GetDraft" , "name":"GetDraft" , "type":"BUILTIN" },{"id":"Remove" , "name":"Remove" , "type":"BUILTIN" },{"id":"CheckKey" , "name":"CheckKey" , "type":"BUILTIN" }], "deaction":[{"id":"Create" , "name":"Create" , "type":"BUILTIN" },{"id":"Update" , "name":"Update" , "type":"BUILTIN" },{"id":"Remove" , "name":"Remove" , "type":"BUILTIN" },{"id":"Get" , "name":"Get" , "type":"BUILTIN" },{"id":"GetDraft" , "name":"GetDraft" , "type":"BUILTIN" },{"id":"CheckKey" , "name":"CheckKey" , "type":"BUILTIN" },{"id":"Save" , "name":"Save" , "type":"BUILTIN" }],
"datascope":[{"id":"all","name":"全部数据"}] "datascope":[{"id":"all","name":"全部数据"}]
} }
, { , {
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"delogicname":"字典项", "delogicname":"字典项",
"sysmoudle":{"id":"DICT","name":"dict"}, "sysmoudle":{"id":"DICT","name":"dict"},
"dedataset":[{"id":"Default" , "name":"DEFAULT"}], "dedataset":[{"id":"Default" , "name":"DEFAULT"}],
"deaction":[{"id":"Update" , "name":"Update" , "type":"BUILTIN" },{"id":"Remove" , "name":"Remove" , "type":"BUILTIN" },{"id":"CheckKey" , "name":"CheckKey" , "type":"BUILTIN" },{"id":"GetDraft" , "name":"GetDraft" , "type":"BUILTIN" },{"id":"Get" , "name":"Get" , "type":"BUILTIN" },{"id":"Create" , "name":"Create" , "type":"BUILTIN" },{"id":"Save" , "name":"Save" , "type":"BUILTIN" }], "deaction":[{"id":"Create" , "name":"Create" , "type":"BUILTIN" },{"id":"Update" , "name":"Update" , "type":"BUILTIN" },{"id":"Remove" , "name":"Remove" , "type":"BUILTIN" },{"id":"Get" , "name":"Get" , "type":"BUILTIN" },{"id":"GetDraft" , "name":"GetDraft" , "type":"BUILTIN" },{"id":"CheckKey" , "name":"CheckKey" , "type":"BUILTIN" },{"id":"Save" , "name":"Save" , "type":"BUILTIN" }],
"datascope":[{"id":"all","name":"全部数据"}] "datascope":[{"id":"all","name":"全部数据"}]
} }
], ],
......
...@@ -87,18 +87,19 @@ public class DictCatalogResource { ...@@ -87,18 +87,19 @@ public class DictCatalogResource {
return ResponseEntity.status(HttpStatus.OK).body(true); return ResponseEntity.status(HttpStatus.OK).body(true);
} }
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictCatalog-Save-all')") @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictCatalog-Remove-all')")
@ApiOperation(value = "保存字典", tags = {"字典" }, notes = "保存字典") @ApiOperation(value = "删除字典", tags = {"字典" }, notes = "删除字典")
@RequestMapping(method = RequestMethod.POST, value = "/dictcatalogs/save") @RequestMapping(method = RequestMethod.DELETE, value = "/dictcatalogs/{dictcatalog_id}")
public ResponseEntity<Boolean> save(@RequestBody DictCatalogDTO dictcatalogdto) { @Transactional
return ResponseEntity.status(HttpStatus.OK).body(dictcatalogService.save(dictcatalogMapping.toDomain(dictcatalogdto))); public ResponseEntity<Boolean> remove(@PathVariable("dictcatalog_id") String dictcatalog_id) {
return ResponseEntity.status(HttpStatus.OK).body(dictcatalogService.remove(dictcatalog_id));
} }
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictCatalog-Save-all')") @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictCatalog-Remove-all')")
@ApiOperation(value = "批量保存字典", tags = {"字典" }, notes = "批量保存字典") @ApiOperation(value = "批量删除字典", tags = {"字典" }, notes = "批量删除字典")
@RequestMapping(method = RequestMethod.POST, value = "/dictcatalogs/savebatch") @RequestMapping(method = RequestMethod.DELETE, value = "/dictcatalogs/batch")
public ResponseEntity<Boolean> saveBatch(@RequestBody List<DictCatalogDTO> dictcatalogdtos) { public ResponseEntity<Boolean> removeBatch(@RequestBody List<String> ids) {
dictcatalogService.saveBatch(dictcatalogMapping.toDomain(dictcatalogdtos)); dictcatalogService.removeBatch(ids);
return ResponseEntity.status(HttpStatus.OK).body(true); return ResponseEntity.status(HttpStatus.OK).body(true);
} }
...@@ -117,29 +118,28 @@ public class DictCatalogResource { ...@@ -117,29 +118,28 @@ public class DictCatalogResource {
return ResponseEntity.status(HttpStatus.OK).body(dictcatalogMapping.toDto(dictcatalogService.getDraft(new DictCatalog()))); return ResponseEntity.status(HttpStatus.OK).body(dictcatalogMapping.toDto(dictcatalogService.getDraft(new DictCatalog())));
} }
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictCatalog-Remove-all')")
@ApiOperation(value = "删除字典", tags = {"字典" }, notes = "删除字典")
@RequestMapping(method = RequestMethod.DELETE, value = "/dictcatalogs/{dictcatalog_id}")
@Transactional
public ResponseEntity<Boolean> remove(@PathVariable("dictcatalog_id") String dictcatalog_id) {
return ResponseEntity.status(HttpStatus.OK).body(dictcatalogService.remove(dictcatalog_id));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictCatalog-Remove-all')")
@ApiOperation(value = "批量删除字典", tags = {"字典" }, notes = "批量删除字典")
@RequestMapping(method = RequestMethod.DELETE, value = "/dictcatalogs/batch")
public ResponseEntity<Boolean> removeBatch(@RequestBody List<String> ids) {
dictcatalogService.removeBatch(ids);
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@ApiOperation(value = "检查字典", tags = {"字典" }, notes = "检查字典") @ApiOperation(value = "检查字典", tags = {"字典" }, notes = "检查字典")
@RequestMapping(method = RequestMethod.POST, value = "/dictcatalogs/checkkey") @RequestMapping(method = RequestMethod.POST, value = "/dictcatalogs/checkkey")
public ResponseEntity<Boolean> checkKey(@RequestBody DictCatalogDTO dictcatalogdto) { public ResponseEntity<Boolean> checkKey(@RequestBody DictCatalogDTO dictcatalogdto) {
return ResponseEntity.status(HttpStatus.OK).body(dictcatalogService.checkKey(dictcatalogMapping.toDomain(dictcatalogdto))); return ResponseEntity.status(HttpStatus.OK).body(dictcatalogService.checkKey(dictcatalogMapping.toDomain(dictcatalogdto)));
} }
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictCatalog-searchDefault-all')") @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictCatalog-Save-all')")
@ApiOperation(value = "保存字典", tags = {"字典" }, notes = "保存字典")
@RequestMapping(method = RequestMethod.POST, value = "/dictcatalogs/save")
public ResponseEntity<Boolean> save(@RequestBody DictCatalogDTO dictcatalogdto) {
return ResponseEntity.status(HttpStatus.OK).body(dictcatalogService.save(dictcatalogMapping.toDomain(dictcatalogdto)));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictCatalog-Save-all')")
@ApiOperation(value = "批量保存字典", tags = {"字典" }, notes = "批量保存字典")
@RequestMapping(method = RequestMethod.POST, value = "/dictcatalogs/savebatch")
public ResponseEntity<Boolean> saveBatch(@RequestBody List<DictCatalogDTO> dictcatalogdtos) {
dictcatalogService.saveBatch(dictcatalogMapping.toDomain(dictcatalogdtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictCatalog-searchDefault-all') and hasPermission(#context,'ibzdict-DictCatalog-Get')")
@ApiOperation(value = "获取DEFAULT", tags = {"字典" } ,notes = "获取DEFAULT") @ApiOperation(value = "获取DEFAULT", tags = {"字典" } ,notes = "获取DEFAULT")
@RequestMapping(method= RequestMethod.GET , value="/dictcatalogs/fetchdefault") @RequestMapping(method= RequestMethod.GET , value="/dictcatalogs/fetchdefault")
public ResponseEntity<List<DictCatalogDTO>> fetchDefault(DictCatalogSearchContext context) { public ResponseEntity<List<DictCatalogDTO>> fetchDefault(DictCatalogSearchContext context) {
...@@ -152,7 +152,7 @@ public class DictCatalogResource { ...@@ -152,7 +152,7 @@ public class DictCatalogResource {
.body(list); .body(list);
} }
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictCatalog-searchDefault-all')") @PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictCatalog-searchDefault-all') and hasPermission(#context,'ibzdict-DictCatalog-Get')")
@ApiOperation(value = "查询DEFAULT", tags = {"字典" } ,notes = "查询DEFAULT") @ApiOperation(value = "查询DEFAULT", tags = {"字典" } ,notes = "查询DEFAULT")
@RequestMapping(method= RequestMethod.POST , value="/dictcatalogs/searchdefault") @RequestMapping(method= RequestMethod.POST , value="/dictcatalogs/searchdefault")
public ResponseEntity<Page<DictCatalogDTO>> searchDefault(@RequestBody DictCatalogSearchContext context) { public ResponseEntity<Page<DictCatalogDTO>> searchDefault(@RequestBody DictCatalogSearchContext context) {
......
package cn.ibizlab.util.security; package cn.ibizlab.util.security;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.SneakyThrows;
import cn.ibizlab.util.annotation.DEField; import cn.ibizlab.util.annotation.DEField;
import cn.ibizlab.util.domain.EntityBase; import cn.ibizlab.util.domain.EntityBase;
import cn.ibizlab.util.enums.DEPredefinedFieldType; import cn.ibizlab.util.enums.DEPredefinedFieldType;
import cn.ibizlab.util.filter.QueryWrapperContext;
import cn.ibizlab.util.helper.DEFieldCacheMap; import cn.ibizlab.util.helper.DEFieldCacheMap;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.PermissionEvaluator; import org.springframework.security.access.PermissionEvaluator;
...@@ -11,7 +14,10 @@ import org.springframework.security.core.GrantedAuthority; ...@@ -11,7 +14,10 @@ import org.springframework.security.core.GrantedAuthority;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.*; import java.util.*;
import java.util.function.Consumer;
/** /**
* spring security 权限管理类 * spring security 权限管理类
...@@ -23,44 +29,144 @@ public class AuthPermissionEvaluator implements PermissionEvaluator { ...@@ -23,44 +29,144 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
@Value("${ibiz.enablePermissionValid:false}") @Value("${ibiz.enablePermissionValid:false}")
boolean enablePermissionValid; //是否开启权限校验 boolean enablePermissionValid; //是否开启权限校验
/** /**
* 实体行为鉴权 * 服务接口鉴权
* @param authentication * @param authentication 用户
* @param entity * @param entity 实体
* @param action * @param action 操作
* @return * @return
*/ */
@Override @Override
@SneakyThrows
public boolean hasPermission(Authentication authentication, Object entity, Object action) { public boolean hasPermission(Authentication authentication, Object entity, Object action) {
if(!enablePermissionValid)
//未开启权限校验、超级管理员则不进行权限检查 return true;
if(AuthenticationUser.getAuthenticationUser().getSuperuser()==1 || !enablePermissionValid) Object principal = authentication.getPrincipal();
if(ObjectUtils.isEmpty(principal))
return false;
AuthenticationUser authenticationUser= (AuthenticationUser) authentication.getPrincipal();
if(authenticationUser.getSuperuser()==1)
return true; return true;
String strAction=String.valueOf(action); String strAction=String.valueOf(action);
Set<String> userAuthorities = getAuthorities(authentication,strAction); Set<String> userAuthorities = getAuthorities(authentication,strAction);
if(userAuthorities.size()==0) if(userAuthorities.size()==0)
return false; return false;
//拥有全部数据访问权限时,则跳过权限检查
if(isAllData(strAction,userAuthorities)){ if(isAllData(strAction,userAuthorities)){
return true; return true;
} }
if(entity instanceof ArrayList){ if(entity instanceof ArrayList){
List<EntityBase> entities= (List<EntityBase>) entity; List<EntityBase> entities= (List<EntityBase>) entity;
for(EntityBase entityBase: entities){ for(EntityBase entityBase: entities){
boolean result=actionValid(entityBase, strAction ,userAuthorities); boolean result=actionValid(entityBase, strAction ,userAuthorities,authenticationUser);
if(!result){ if(!result){
return false; return false;
} }
} }
} }
else if (entity instanceof QueryWrapperContext){
QueryWrapperContext queryWrapperContext= (QueryWrapperContext) entity;
setPermissionCondToSearchContext(getEntity(queryWrapperContext),queryWrapperContext,userAuthorities,authenticationUser);
}
else{ else{
EntityBase entityBase= (EntityBase) entity; EntityBase entityBase= (EntityBase) entity;
return actionValid(entityBase , strAction ,userAuthorities); return actionValid(entityBase , strAction ,userAuthorities,authenticationUser);
} }
return true; return true;
} }
/**
* 获取实体信息
* @param qc
* @return
*/
@SneakyThrows
private EntityBase getEntity(QueryWrapperContext qc){
EntityBase entity=null;
Type type =qc.getClass().getGenericSuperclass();
if(type instanceof ParameterizedType){
ParameterizedType parameterizedType= (ParameterizedType) qc.getClass().getGenericSuperclass();
Type [] typeArr= parameterizedType.getActualTypeArguments();
if(typeArr.length>0){
Class<EntityBase> entityClass = (Class) typeArr[0];
return entityClass.newInstance();
}
}
return entity;
}
/**
* 在searchContext中拼接权限条件
* @param entity 实体
* @param qc 查询上下文
* @param userAuthorities 用户权限
* @param authenticationUser 当前用户
*/
@SneakyThrows
private void setPermissionCondToSearchContext(EntityBase entity, QueryWrapperContext qc , Set<String> userAuthorities ,AuthenticationUser authenticationUser){
if(entity==null)
return ;
Map<String,String> permissionField=getPermissionField(entity);//获取组织、部门预置属性
String orgField=permissionField.get("orgfield");
String orgDeptField=permissionField.get("orgsecfield");
String createManField=permissionField.get("createmanfield");
Map<String, Set<String>> userInfo = authenticationUser.getOrgInfo();
Set<String> orgParent = userInfo.get("parentorg");
Set<String> orgChild = userInfo.get("suborg");
Set<String> orgDeptParent = userInfo.get("parentdept");
Set<String> orgDeptChild = userInfo.get("subdept");
Set<String> userOrg = new HashSet<>();
Set<String> userOrgDept = new HashSet<>();
Set<String> userCreateMan = new HashSet<>();
for(String authority:userAuthorities){
if(authority.endsWith("curorg")){ //本单位
userOrg.add(authenticationUser.getOrgid());
}
else if(authority.endsWith("porg")){//上级单位
userOrg.addAll(orgParent);
}
else if(authority.endsWith("sorg")){//下级单位
userOrg.addAll(orgChild);
}
else if(authority.endsWith("curorgdept")){//本部门
userOrgDept.add(authenticationUser.getMdeptid());
}
else if(authority.endsWith("porgdept")){//上级部门
userOrgDept.addAll(orgDeptParent);
}
else if(authority.endsWith("sorgdept")){//下级部门
userOrgDept.addAll(orgDeptChild);
}
else if (authority.endsWith("createman")){
userCreateMan.add(authority);
}
}
if(userOrg.size()==0 && userOrgDept.size()==0 && userCreateMan.size()==0){
qc.getSelectCond().apply("1<>1");
}
else{
Consumer<QueryWrapper> consumer = qw -> {
if(userOrg.size()>0){
Consumer<QueryWrapper> org = orgQw -> {
orgQw.in(orgField,userOrg);
};
qw.or(org);
}
if(userOrgDept.size()>0){
Consumer<QueryWrapper> dept = deptQw -> {
deptQw.in(orgDeptField,userOrgDept);
};
qw.or(dept);
}
if(userCreateMan.size()>0){
Consumer<QueryWrapper> createMan = createManQw -> {
createManQw.eq(createManField,authenticationUser.getUserid());
};
qw.or(createMan);
}
};
qc.getSelectCond().and(consumer);
}
}
@Override @Override
public boolean hasPermission(Authentication authentication, Serializable id, String action, Object params) { public boolean hasPermission(Authentication authentication, Serializable id, String action, Object params) {
...@@ -106,13 +212,12 @@ public class AuthPermissionEvaluator implements PermissionEvaluator { ...@@ -106,13 +212,12 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
* @param userAuthorities * @param userAuthorities
* @return * @return
*/ */
private boolean actionValid(EntityBase entity, String action , Set<String> userAuthorities){ private boolean actionValid(EntityBase entity, String action , Set<String> userAuthorities ,AuthenticationUser authenticationUser){
Map<String,String> permissionField=getPermissionField(entity);//获取组织、部门预置属性 Map<String,String> permissionField=getPermissionField(entity);//获取组织、部门预置属性
String orgField=permissionField.get("orgfield"); String orgField=permissionField.get("orgfield");
String orgDeptField=permissionField.get("orgsecfield"); String orgDeptField=permissionField.get("orgsecfield");
String createManField=permissionField.get("createmanfield"); String createManField=permissionField.get("createmanfield");
AuthenticationUser authenticationUser = AuthenticationUser.getAuthenticationUser();
Map<String, Set<String>> userInfo = authenticationUser.getOrgInfo(); Map<String, Set<String>> userInfo = authenticationUser.getOrgInfo();
Set<String> orgParent = userInfo.get("parentorg"); Set<String> orgParent = userInfo.get("parentorg");
Set<String> orgChild = userInfo.get("suborg"); Set<String> orgChild = userInfo.get("suborg");
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册