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

ibiz4j 发布系统代码

上级 2ec60a6e
......@@ -179,16 +179,32 @@ mock.onPut(new RegExp(/^\/dictcatalogs\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((conf
return [status, data];
});
// Save
mock.onPost(new RegExp(/^\/dictcatalogs\/?([a-zA-Z0-9\-\;]{0,35})\/save$/)).reply((config: any) => {
console.groupCollapsed("实体:dictcatalog 方法: Save");
// 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
mock.onPost(new RegExp(/^\/dictcatalogs\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).reply((config: any) => {
console.groupCollapsed("实体:dictcatalog 方法: CheckKey");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
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 = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
......@@ -217,32 +233,16 @@ mock.onPost(new RegExp(/^\/dictcatalogs\/?([a-zA-Z0-9\-\;]{0,35})\/save$/)).repl
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
mock.onPost(new RegExp(/^\/dictcatalogs\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).reply((config: any) => {
console.groupCollapsed("实体:dictcatalog 方法: CheckKey");
// Save
mock.onPost(new RegExp(/^\/dictcatalogs\/?([a-zA-Z0-9\-\;]{0,35})\/save$/)).reply((config: any) => {
console.groupCollapsed("实体:dictcatalog 方法: Save");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
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 = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
......@@ -323,9 +323,9 @@ mock.onGet(new RegExp(/^\/dictcatalogs\/fetchdefault(\?[\w-./?%&=,]*)*$/)).reply
// URI参数传递情况未实现
// Get
mock.onGet(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:dictcatalog 方法: Get");
// Remove
mock.onDelete(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:dictcatalog 方法: Remove");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
......@@ -351,9 +351,9 @@ mock.onGet(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((confi
return [status, _items?_items:{}];
});
// Remove
mock.onDelete(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:dictcatalog 方法: Remove");
// Get
mock.onGet(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:dictcatalog 方法: Get");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
......
......@@ -145,9 +145,9 @@ mock.onGet(new RegExp(/^\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})\/select$/)).reply
});
// Update
mock.onPut(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:dictoption 方法: Update");
// Create
mock.onPost(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:dictoption 方法: Create");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
......@@ -171,9 +171,9 @@ mock.onPut(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/([
return [status, {}];
});
// Update
mock.onPut(new RegExp(/^\/dictoptions\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:dictoption 方法: Update");
// Create
mock.onPost(new RegExp(/^\/dictoptions\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:dictoption 方法: Create");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
......@@ -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.table(data);
console.table(mockDatas[0]);
console.groupEnd();
console.groupEnd();
return [status, data];
return [status, mockDatas[0]];
});
// CheckKey
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 方法: CheckKey");
// Update
mock.onPut(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:dictoption 方法: Update");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
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 = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
......@@ -237,16 +224,16 @@ mock.onPost(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/(
return [status, {}];
});
// CheckKey
mock.onPost(new RegExp(/^\/dictoptions\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).reply((config: any) => {
console.groupCollapsed("实体:dictoption 方法: CheckKey");
// Update
mock.onPut(new RegExp(/^\/dictoptions\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:dictoption 方法: Update");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
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 = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
......@@ -276,6 +263,8 @@ mock.onPost(new RegExp(/^\/dictoptions\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).r
});
// GetDraft
mock.onGet(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/getdraft$/)).reply((config: any) => {
console.groupCollapsed("实体:dictoption 方法: GetDraft");
......@@ -309,17 +298,16 @@ mock.onGet(new RegExp(/^\/dictoptions\/getdraft$/)).reply((config: any) => {
});
// Create
mock.onPost(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:dictoption 方法: Create");
// CheckKey
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 方法: CheckKey");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
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 = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
......@@ -336,16 +324,16 @@ mock.onPost(new RegExp(/^\/dictcatalogs\/([a-zA-Z0-9\-\;]{1,35})\/dictoptions\/(
return [status, {}];
});
// Create
mock.onPost(new RegExp(/^\/dictoptions\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:dictoption 方法: Create");
// CheckKey
mock.onPost(new RegExp(/^\/dictoptions\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).reply((config: any) => {
console.groupCollapsed("实体:dictoption 方法: CheckKey");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
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 = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
......@@ -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.table(mockDatas[0]);
console.table(data);
console.groupEnd();
console.groupEnd();
return [status, mockDatas[0]];
return [status, data];
});
......
......@@ -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)??
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: #if ctrl.getPSControlContainer().getV... [in template "TEMPLCODE_zh_CN" at line 43, column 5]
----
/**
* 打开编辑数据视图
*
* @param {any[]} args
* @param {*} [params]
* @param {*} [fullargs]
* @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 {
}
!!!!模版产生代码错误:----
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)??
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: #if ctrl.getPSControlContainer().getV... [in template "TEMPLCODE_zh_CN" at line 43, column 5]
----
/**
* 打开编辑数据视图
*
* @param {any[]} args
* @param {*} [params]
* @param {*} [fullargs]
* @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 {
}
!!!!模版产生代码错误:----
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)??
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: #if ctrl.getPSControlContainer().getV... [in template "TEMPLCODE_zh_CN" at line 43, column 5]
----
/**
* 打开编辑数据视图
*
* @param {any[]} args
* @param {*} [params]
* @param {*} [fullargs]
* @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 {
}
/**
* Save接口方法
* Remove接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
......@@ -132,26 +132,8 @@ export default class DictCatalogServiceBase extends EntityService {
* @returns {Promise<any>}
* @memberof DictCatalogServiceBase
*/
public async Save(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
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));
public async Remove(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = await Http.getInstance().delete(`/dictcatalogs/${context.dictcatalog}`,isloading);
return res;
}
......@@ -187,7 +169,7 @@ export default class DictCatalogServiceBase extends EntityService {
}
/**
* Remove接口方法
* CheckKey接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
......@@ -195,13 +177,13 @@ export default class DictCatalogServiceBase extends EntityService {
* @returns {Promise<any>}
* @memberof DictCatalogServiceBase
*/
public async Remove(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = await Http.getInstance().delete(`/dictcatalogs/${context.dictcatalog}`,isloading);
public async CheckKey(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = await Http.getInstance().post(`/dictcatalogs/${context.dictcatalog}/checkkey`,data,isloading);
return res;
}
/**
* CheckKey接口方法
* Save接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
......@@ -209,8 +191,26 @@ export default class DictCatalogServiceBase extends EntityService {
* @returns {Promise<any>}
* @memberof DictCatalogServiceBase
*/
public async CheckKey(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = await Http.getInstance().post(`/dictcatalogs/${context.dictcatalog}/checkkey`,data,isloading);
public async Save(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
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;
}
......
......@@ -55,6 +55,41 @@ export default class DictOptionServiceBase extends EntityService {
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接口方法
*
......@@ -94,7 +129,7 @@ export default class DictOptionServiceBase extends EntityService {
}
/**
* CheckKey接口方法
* Get接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
......@@ -102,13 +137,11 @@ export default class DictOptionServiceBase extends EntityService {
* @returns {Promise<any>}
* @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){
let masterData:any = {};
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().get(`/dictcatalogs/${context.dictcatalog}/dictoptions/${context.dictoption}`,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;
}
......@@ -132,7 +165,7 @@ export default class DictOptionServiceBase extends EntityService {
}
/**
* Get接口方法
* CheckKey接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
......@@ -140,46 +173,13 @@ export default class DictOptionServiceBase extends EntityService {
* @returns {Promise<any>}
* @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){
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 = {};
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 res:any = await Http.getInstance().post(`/dictcatalogs/${context.dictcatalog}/dictoptions/${context.dictoption}/checkkey`,data,isloading);
}
let tempContext:any = JSON.parse(JSON.stringify(context));
let res:any = await Http.getInstance().post(`/dictoptions`,data,isloading);
let res:any = await Http.getInstance().post(`/dictoptions/${context.dictoption}/checkkey`,data,isloading);
return res;
}
......
......@@ -29,13 +29,13 @@ public interface IDictCatalogService extends IService<DictCatalog>{
void createBatch(List<DictCatalog> list) ;
boolean update(DictCatalog et) ;
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) ;
void removeBatch(Collection<String> idList) ;
DictCatalog get(String key) ;
DictCatalog getDraft(DictCatalog et) ;
boolean checkKey(DictCatalog et) ;
boolean save(DictCatalog et) ;
void saveBatch(List<DictCatalog> list) ;
Page<DictCatalog> searchDefault(DictCatalogSearchContext context) ;
/**
*自定义查询SQL
......
......@@ -25,15 +25,15 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface IDictOptionService extends IService<DictOption>{
boolean create(DictOption et) ;
void createBatch(List<DictOption> list) ;
boolean update(DictOption et) ;
void updateBatch(List<DictOption> list) ;
boolean remove(String key) ;
void removeBatch(Collection<String> idList) ;
boolean checkKey(DictOption et) ;
DictOption getDraft(DictOption et) ;
DictOption get(String key) ;
boolean create(DictOption et) ;
void createBatch(List<DictOption> list) ;
DictOption getDraft(DictOption et) ;
boolean checkKey(DictOption et) ;
boolean save(DictOption et) ;
void saveBatch(List<DictOption> list) ;
Page<DictOption> searchDefault(DictOptionSearchContext context) ;
......
......@@ -80,33 +80,14 @@ public class DictCatalogServiceImpl extends ServiceImpl<DictCatalogMapper, DictC
@Override
@Transactional
public boolean save(DictCatalog et) {
if(!saveOrUpdate(et))
return false;
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;
public boolean remove(String key) {
boolean result=removeById(key);
return result ;
}
@Override
public void saveBatch(List<DictCatalog> list) {
saveOrUpdateBatch(list,batchSize);
public void removeBatch(Collection<String> idList) {
removeByIds(idList);
}
@Override
......@@ -127,23 +108,42 @@ public class DictCatalogServiceImpl extends ServiceImpl<DictCatalogMapper, DictC
return et;
}
@Override
public boolean checkKey(DictCatalog et) {
return (!ObjectUtils.isEmpty(et.getId()))&&(!Objects.isNull(this.getById(et.getId())));
}
@Override
@Transactional
public boolean remove(String key) {
boolean result=removeById(key);
return result ;
public boolean save(DictCatalog et) {
if(!saveOrUpdate(et))
return false;
return true;
}
@Override
public void removeBatch(Collection<String> idList) {
removeByIds(idList);
@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 checkKey(DictCatalog et) {
return (!ObjectUtils.isEmpty(et.getId()))&&(!Objects.isNull(this.getById(et.getId())));
public boolean saveBatch(Collection<DictCatalog> list) {
saveOrUpdateBatch(list,batchSize);
return true;
}
@Override
public void saveBatch(List<DictCatalog> list) {
saveOrUpdateBatch(list,batchSize);
}
/**
* 查询集合 DEFAULT
......
......@@ -50,6 +50,22 @@ public class DictOptionServiceImpl extends ServiceImpl<DictOptionMapper, DictOpt
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
@Transactional
public boolean update(DictOption et) {
......@@ -78,16 +94,6 @@ public class DictOptionServiceImpl extends ServiceImpl<DictOptionMapper, DictOpt
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
@Transactional
public DictOption get(String key) {
......@@ -102,21 +108,15 @@ public class DictOptionServiceImpl extends ServiceImpl<DictOptionMapper, DictOpt
}
@Override
@Transactional
public boolean create(DictOption et) {
public DictOption getDraft(DictOption et) {
fillParentData(et);
if(!this.retBool(this.baseMapper.insert(et)))
return false;
CachedBeanCopier.copy(get(et.getValueKey()),et);
return true;
return et;
}
@Override
public void createBatch(List<DictOption> list) {
list.forEach(item->fillParentData(item));
this.saveOrUpdateBatch(list,batchSize);
public boolean checkKey(DictOption et) {
return (!ObjectUtils.isEmpty(et.getValueKey()))&&(!Objects.isNull(this.getById(et.getValueKey())));
}
@Override
@Transactional
public boolean save(DictOption et) {
......
......@@ -8,7 +8,7 @@
"delogicname":"字典",
"sysmoudle":{"id":"DICT","name":"dict"},
"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":"全部数据"}]
}
, {
......@@ -16,7 +16,7 @@
"delogicname":"字典项",
"sysmoudle":{"id":"DICT","name":"dict"},
"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":"全部数据"}]
}
],
......
......@@ -87,18 +87,19 @@ public class DictCatalogResource {
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@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-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-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));
@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);
}
......@@ -117,29 +118,28 @@ public class DictCatalogResource {
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 = "检查字典")
@RequestMapping(method = RequestMethod.POST, value = "/dictcatalogs/checkkey")
public ResponseEntity<Boolean> checkKey(@RequestBody DictCatalogDTO 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")
@RequestMapping(method= RequestMethod.GET , value="/dictcatalogs/fetchdefault")
public ResponseEntity<List<DictCatalogDTO>> fetchDefault(DictCatalogSearchContext context) {
......@@ -152,7 +152,7 @@ public class DictCatalogResource {
.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")
@RequestMapping(method= RequestMethod.POST , value="/dictcatalogs/searchdefault")
public ResponseEntity<Page<DictCatalogDTO>> searchDefault(@RequestBody DictCatalogSearchContext context) {
......
......@@ -47,6 +47,25 @@ public class DictOptionResource {
@Lazy
public DictOptionMapping dictoptionMapping;
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-Create-all')")
@ApiOperation(value = "新建字典项", tags = {"字典项" }, notes = "新建字典项")
@RequestMapping(method = RequestMethod.POST, value = "/dictoptions")
@Transactional
public ResponseEntity<DictOptionDTO> create(@RequestBody DictOptionDTO dictoptiondto) {
DictOption domain = dictoptionMapping.toDomain(dictoptiondto);
dictoptionService.create(domain);
DictOptionDTO dto = dictoptionMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-Create-all')")
@ApiOperation(value = "批量新建字典项", tags = {"字典项" }, notes = "批量新建字典项")
@RequestMapping(method = RequestMethod.POST, value = "/dictoptions/batch")
public ResponseEntity<Boolean> createBatch(@RequestBody List<DictOptionDTO> dictoptiondtos) {
dictoptionService.createBatch(dictoptionMapping.toDomain(dictoptiondtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@VersionCheck(entity = "dictoption" , versionfield = "updatedate")
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-Update-all')")
@ApiOperation(value = "更新字典项", tags = {"字典项" }, notes = "更新字典项")
......@@ -84,18 +103,6 @@ public class DictOptionResource {
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@ApiOperation(value = "检查字典项", tags = {"字典项" }, notes = "检查字典项")
@RequestMapping(method = RequestMethod.POST, value = "/dictoptions/checkkey")
public ResponseEntity<Boolean> checkKey(@RequestBody DictOptionDTO dictoptiondto) {
return ResponseEntity.status(HttpStatus.OK).body(dictoptionService.checkKey(dictoptionMapping.toDomain(dictoptiondto)));
}
@ApiOperation(value = "获取字典项草稿", tags = {"字典项" }, notes = "获取字典项草稿")
@RequestMapping(method = RequestMethod.GET, value = "/dictoptions/getdraft")
public ResponseEntity<DictOptionDTO> getDraft() {
return ResponseEntity.status(HttpStatus.OK).body(dictoptionMapping.toDto(dictoptionService.getDraft(new DictOption())));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-Get-all')")
@ApiOperation(value = "获取字典项", tags = {"字典项" }, notes = "获取字典项")
@RequestMapping(method = RequestMethod.GET, value = "/dictoptions/{dictoption_id}")
......@@ -105,23 +112,16 @@ public class DictOptionResource {
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-Create-all')")
@ApiOperation(value = "新建字典项", tags = {"字典项" }, notes = "新建字典项")
@RequestMapping(method = RequestMethod.POST, value = "/dictoptions")
@Transactional
public ResponseEntity<DictOptionDTO> create(@RequestBody DictOptionDTO dictoptiondto) {
DictOption domain = dictoptionMapping.toDomain(dictoptiondto);
dictoptionService.create(domain);
DictOptionDTO dto = dictoptionMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
@ApiOperation(value = "获取字典项草稿", tags = {"字典项" }, notes = "获取字典项草稿")
@RequestMapping(method = RequestMethod.GET, value = "/dictoptions/getdraft")
public ResponseEntity<DictOptionDTO> getDraft() {
return ResponseEntity.status(HttpStatus.OK).body(dictoptionMapping.toDto(dictoptionService.getDraft(new DictOption())));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-Create-all')")
@ApiOperation(value = "批量新建字典项", tags = {"字典项" }, notes = "批量新建字典项")
@RequestMapping(method = RequestMethod.POST, value = "/dictoptions/batch")
public ResponseEntity<Boolean> createBatch(@RequestBody List<DictOptionDTO> dictoptiondtos) {
dictoptionService.createBatch(dictoptionMapping.toDomain(dictoptiondtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
@ApiOperation(value = "检查字典项", tags = {"字典项" }, notes = "检查字典项")
@RequestMapping(method = RequestMethod.POST, value = "/dictoptions/checkkey")
public ResponseEntity<Boolean> checkKey(@RequestBody DictOptionDTO dictoptiondto) {
return ResponseEntity.status(HttpStatus.OK).body(dictoptionService.checkKey(dictoptionMapping.toDomain(dictoptiondto)));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-Save-all')")
......@@ -139,7 +139,7 @@ public class DictOptionResource {
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-searchDefault-all')")
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-searchDefault-all') and hasPermission(#context,'ibzdict-DictOption-Get')")
@ApiOperation(value = "获取DEFAULT", tags = {"字典项" } ,notes = "获取DEFAULT")
@RequestMapping(method= RequestMethod.GET , value="/dictoptions/fetchdefault")
public ResponseEntity<List<DictOptionDTO>> fetchDefault(DictOptionSearchContext context) {
......@@ -152,7 +152,7 @@ public class DictOptionResource {
.body(list);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-searchDefault-all')")
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-searchDefault-all') and hasPermission(#context,'ibzdict-DictOption-Get')")
@ApiOperation(value = "查询DEFAULT", tags = {"字典项" } ,notes = "查询DEFAULT")
@RequestMapping(method= RequestMethod.POST , value="/dictoptions/searchdefault")
public ResponseEntity<Page<DictOptionDTO>> searchDefault(@RequestBody DictOptionSearchContext context) {
......@@ -160,6 +160,30 @@ public class DictOptionResource {
return ResponseEntity.status(HttpStatus.OK)
.body(new PageImpl(dictoptionMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-Create-all')")
@ApiOperation(value = "根据字典建立字典项", tags = {"字典项" }, notes = "根据字典建立字典项")
@RequestMapping(method = RequestMethod.POST, value = "/dictcatalogs/{dictcatalog_id}/dictoptions")
@Transactional
public ResponseEntity<DictOptionDTO> createByDictCatalog(@PathVariable("dictcatalog_id") String dictcatalog_id, @RequestBody DictOptionDTO dictoptiondto) {
DictOption domain = dictoptionMapping.toDomain(dictoptiondto);
domain.setCatalogId(dictcatalog_id);
dictoptionService.create(domain);
DictOptionDTO dto = dictoptionMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-Create-all')")
@ApiOperation(value = "根据字典批量建立字典项", tags = {"字典项" }, notes = "根据字典批量建立字典项")
@RequestMapping(method = RequestMethod.POST, value = "/dictcatalogs/{dictcatalog_id}/dictoptions/batch")
public ResponseEntity<Boolean> createBatchByDictCatalog(@PathVariable("dictcatalog_id") String dictcatalog_id, @RequestBody List<DictOptionDTO> dictoptiondtos) {
List<DictOption> domainlist=dictoptionMapping.toDomain(dictoptiondtos);
for(DictOption domain:domainlist){
domain.setCatalogId(dictcatalog_id);
}
dictoptionService.createBatch(domainlist);
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@VersionCheck(entity = "dictoption" , versionfield = "updatedate")
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-Update-all')")
@ApiOperation(value = "根据字典更新字典项", tags = {"字典项" }, notes = "根据字典更新字典项")
......@@ -202,20 +226,6 @@ public class DictOptionResource {
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@ApiOperation(value = "根据字典检查字典项", tags = {"字典项" }, notes = "根据字典检查字典项")
@RequestMapping(method = RequestMethod.POST, value = "/dictcatalogs/{dictcatalog_id}/dictoptions/checkkey")
public ResponseEntity<Boolean> checkKeyByDictCatalog(@PathVariable("dictcatalog_id") String dictcatalog_id, @RequestBody DictOptionDTO dictoptiondto) {
return ResponseEntity.status(HttpStatus.OK).body(dictoptionService.checkKey(dictoptionMapping.toDomain(dictoptiondto)));
}
@ApiOperation(value = "根据字典获取字典项草稿", tags = {"字典项" }, notes = "根据字典获取字典项草稿")
@RequestMapping(method = RequestMethod.GET, value = "/dictcatalogs/{dictcatalog_id}/dictoptions/getdraft")
public ResponseEntity<DictOptionDTO> getDraftByDictCatalog(@PathVariable("dictcatalog_id") String dictcatalog_id) {
DictOption domain = new DictOption();
domain.setCatalogId(dictcatalog_id);
return ResponseEntity.status(HttpStatus.OK).body(dictoptionMapping.toDto(dictoptionService.getDraft(domain)));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-Get-all')")
@ApiOperation(value = "根据字典获取字典项", tags = {"字典项" }, notes = "根据字典获取字典项")
@RequestMapping(method = RequestMethod.GET, value = "/dictcatalogs/{dictcatalog_id}/dictoptions/{dictoption_id}")
......@@ -225,28 +235,18 @@ public class DictOptionResource {
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-Create-all')")
@ApiOperation(value = "根据字典建立字典项", tags = {"字典项" }, notes = "根据字典建立字典项")
@RequestMapping(method = RequestMethod.POST, value = "/dictcatalogs/{dictcatalog_id}/dictoptions")
@Transactional
public ResponseEntity<DictOptionDTO> createByDictCatalog(@PathVariable("dictcatalog_id") String dictcatalog_id, @RequestBody DictOptionDTO dictoptiondto) {
DictOption domain = dictoptionMapping.toDomain(dictoptiondto);
@ApiOperation(value = "根据字典获取字典项草稿", tags = {"字典项" }, notes = "根据字典获取字典项草稿")
@RequestMapping(method = RequestMethod.GET, value = "/dictcatalogs/{dictcatalog_id}/dictoptions/getdraft")
public ResponseEntity<DictOptionDTO> getDraftByDictCatalog(@PathVariable("dictcatalog_id") String dictcatalog_id) {
DictOption domain = new DictOption();
domain.setCatalogId(dictcatalog_id);
dictoptionService.create(domain);
DictOptionDTO dto = dictoptionMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
return ResponseEntity.status(HttpStatus.OK).body(dictoptionMapping.toDto(dictoptionService.getDraft(domain)));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-Create-all')")
@ApiOperation(value = "根据字典批量建立字典项", tags = {"字典项" }, notes = "根据字典批量建立字典项")
@RequestMapping(method = RequestMethod.POST, value = "/dictcatalogs/{dictcatalog_id}/dictoptions/batch")
public ResponseEntity<Boolean> createBatchByDictCatalog(@PathVariable("dictcatalog_id") String dictcatalog_id, @RequestBody List<DictOptionDTO> dictoptiondtos) {
List<DictOption> domainlist=dictoptionMapping.toDomain(dictoptiondtos);
for(DictOption domain:domainlist){
domain.setCatalogId(dictcatalog_id);
}
dictoptionService.createBatch(domainlist);
return ResponseEntity.status(HttpStatus.OK).body(true);
@ApiOperation(value = "根据字典检查字典项", tags = {"字典项" }, notes = "根据字典检查字典项")
@RequestMapping(method = RequestMethod.POST, value = "/dictcatalogs/{dictcatalog_id}/dictoptions/checkkey")
public ResponseEntity<Boolean> checkKeyByDictCatalog(@PathVariable("dictcatalog_id") String dictcatalog_id, @RequestBody DictOptionDTO dictoptiondto) {
return ResponseEntity.status(HttpStatus.OK).body(dictoptionService.checkKey(dictoptionMapping.toDomain(dictoptiondto)));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-Save-all')")
......@@ -270,7 +270,7 @@ public class DictOptionResource {
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-searchDefault-all')")
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-searchDefault-all') and hasPermission(#context,'ibzdict-DictOption-Get')")
@ApiOperation(value = "根据字典获取DEFAULT", tags = {"字典项" } ,notes = "根据字典获取DEFAULT")
@RequestMapping(method= RequestMethod.GET , value="/dictcatalogs/{dictcatalog_id}/dictoptions/fetchdefault")
public ResponseEntity<List<DictOptionDTO>> fetchDictOptionDefaultByDictCatalog(@PathVariable("dictcatalog_id") String dictcatalog_id,DictOptionSearchContext context) {
......@@ -284,7 +284,7 @@ public class DictOptionResource {
.body(list);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-searchDefault-all')")
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdict-DictOption-searchDefault-all') and hasPermission(#context,'ibzdict-DictOption-Get')")
@ApiOperation(value = "根据字典查询DEFAULT", tags = {"字典项" } ,notes = "根据字典查询DEFAULT")
@RequestMapping(method= RequestMethod.POST , value="/dictcatalogs/{dictcatalog_id}/dictoptions/searchdefault")
public ResponseEntity<Page<DictOptionDTO>> searchDictOptionDefaultByDictCatalog(@PathVariable("dictcatalog_id") String dictcatalog_id, @RequestBody DictOptionSearchContext context) {
......
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.domain.EntityBase;
import cn.ibizlab.util.enums.DEPredefinedFieldType;
import cn.ibizlab.util.filter.QueryWrapperContext;
import cn.ibizlab.util.helper.DEFieldCacheMap;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.PermissionEvaluator;
......@@ -11,7 +14,10 @@ import org.springframework.security.core.GrantedAuthority;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.*;
import java.util.function.Consumer;
/**
* spring security 权限管理类
......@@ -23,44 +29,144 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
@Value("${ibiz.enablePermissionValid:false}")
boolean enablePermissionValid; //是否开启权限校验
/**
* 实体行为鉴权
* @param authentication
* @param entity
* @param action
* 服务接口鉴权
* @param authentication 用户
* @param entity 实体
* @param action 操作
* @return
*/
@Override
@SneakyThrows
public boolean hasPermission(Authentication authentication, Object entity, Object action) {
//未开启权限校验、超级管理员则不进行权限检查
if(AuthenticationUser.getAuthenticationUser().getSuperuser()==1 || !enablePermissionValid)
if(!enablePermissionValid)
return true;
Object principal = authentication.getPrincipal();
if(ObjectUtils.isEmpty(principal))
return false;
AuthenticationUser authenticationUser= (AuthenticationUser) authentication.getPrincipal();
if(authenticationUser.getSuperuser()==1)
return true;
String strAction=String.valueOf(action);
Set<String> userAuthorities = getAuthorities(authentication,strAction);
if(userAuthorities.size()==0)
return false;
//拥有全部数据访问权限时,则跳过权限检查
if(isAllData(strAction,userAuthorities)){
return true;
}
if(entity instanceof ArrayList){
List<EntityBase> entities= (List<EntityBase>) entity;
for(EntityBase entityBase: entities){
boolean result=actionValid(entityBase, strAction ,userAuthorities);
boolean result=actionValid(entityBase, strAction ,userAuthorities,authenticationUser);
if(!result){
return false;
}
}
}
else if (entity instanceof QueryWrapperContext){
QueryWrapperContext queryWrapperContext= (QueryWrapperContext) entity;
setPermissionCondToSearchContext(getEntity(queryWrapperContext),queryWrapperContext,userAuthorities,authenticationUser);
}
else{
EntityBase entityBase= (EntityBase) entity;
return actionValid(entityBase , strAction ,userAuthorities);
return actionValid(entityBase , strAction ,userAuthorities,authenticationUser);
}
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
public boolean hasPermission(Authentication authentication, Serializable id, String action, Object params) {
......@@ -106,13 +212,12 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
* @param userAuthorities
* @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);//获取组织、部门预置属性
String orgField=permissionField.get("orgfield");
String orgDeptField=permissionField.get("orgsecfield");
String createManField=permissionField.get("createmanfield");
AuthenticationUser authenticationUser = AuthenticationUser.getAuthenticationUser();
Map<String, Set<String>> userInfo = authenticationUser.getOrgInfo();
Set<String> orgParent = userInfo.get("parentorg");
Set<String> orgChild = userInfo.get("suborg");
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册