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

ibizdev提交

上级 74432f1d
...@@ -13,6 +13,7 @@ export default { ...@@ -13,6 +13,7 @@ export default {
enable: '逻辑有效', enable: '逻辑有效',
createdate: '创建时间', createdate: '创建时间',
updatedate: '最后修改时间', updatedate: '最后修改时间',
orgname: '单位',
}, },
views: { views: {
editview: { editview: {
...@@ -46,6 +47,7 @@ export default { ...@@ -46,6 +47,7 @@ export default {
deptid: "部门标识", deptid: "部门标识",
deptcode: "部门代码", deptcode: "部门代码",
deptname: "部门名称", deptname: "部门名称",
orgname: "单位",
orgid: "单位", orgid: "单位",
pdeptid: "上级部门", pdeptid: "上级部门",
shortname: "部门简称", shortname: "部门简称",
......
...@@ -12,6 +12,7 @@ export default { ...@@ -12,6 +12,7 @@ export default {
enable: '逻辑有效', enable: '逻辑有效',
createdate: '创建时间', createdate: '创建时间',
updatedate: '最后修改时间', updatedate: '最后修改时间',
orgname: '单位',
}, },
views: { views: {
editview: { editview: {
...@@ -45,6 +46,7 @@ export default { ...@@ -45,6 +46,7 @@ export default {
deptid: '部门标识', deptid: '部门标识',
deptcode: '部门代码', deptcode: '部门代码',
deptname: '部门名称', deptname: '部门名称',
orgname: '单位',
orgid: '单位', orgid: '单位',
pdeptid: '上级部门', pdeptid: '上级部门',
shortname: '部门简称', shortname: '部门简称',
......
...@@ -6,6 +6,39 @@ const mock = MockAdapter.getInstance(); ...@@ -6,6 +6,39 @@ const mock = MockAdapter.getInstance();
const mockDatas: Array<any> = [ const mockDatas: Array<any> = [
]; ];
// createBatch
mock.onPost(new RegExp(/^\/ibzdepartments\/batch$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdepartment 方法: createBatch");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, {}];
}
return [status, {}];
});
// updateBatch
mock.onPut(new RegExp(/^\/ibzdepartments\/batch$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdepartment 方法: updateBatch");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, {}];
}
return [status, {}];
});
// removeBatch
mock.onDelete(new RegExp(/^\/ibzdepartments\/batch$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdepartment 方法: removeBatch");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, {}];
}
return [status, {}];
});
// Select // Select
......
...@@ -6,6 +6,39 @@ const mock = MockAdapter.getInstance(); ...@@ -6,6 +6,39 @@ const mock = MockAdapter.getInstance();
const mockDatas: Array<any> = [ const mockDatas: Array<any> = [
]; ];
// createBatch
mock.onPost(new RegExp(/^\/ibzemployees\/batch$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzemployee 方法: createBatch");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, {}];
}
return [status, {}];
});
// updateBatch
mock.onPut(new RegExp(/^\/ibzemployees\/batch$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzemployee 方法: updateBatch");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, {}];
}
return [status, {}];
});
// removeBatch
mock.onDelete(new RegExp(/^\/ibzemployees\/batch$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzemployee 方法: removeBatch");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, {}];
}
return [status, {}];
});
// Select // Select
......
...@@ -6,6 +6,39 @@ const mock = MockAdapter.getInstance(); ...@@ -6,6 +6,39 @@ const mock = MockAdapter.getInstance();
const mockDatas: Array<any> = [ const mockDatas: Array<any> = [
]; ];
// createBatch
mock.onPost(new RegExp(/^\/ibzorganizations\/batch$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzorganization 方法: createBatch");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, {}];
}
return [status, {}];
});
// updateBatch
mock.onPut(new RegExp(/^\/ibzorganizations\/batch$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzorganization 方法: updateBatch");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, {}];
}
return [status, {}];
});
// removeBatch
mock.onDelete(new RegExp(/^\/ibzorganizations\/batch$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzorganization 方法: removeBatch");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, {}];
}
return [status, {}];
});
// Select // Select
mock.onGet(new RegExp(/^\/ibzorganizations\/([a-zA-Z0-9\-\;]{1,35})\/select$/)).reply((config: any) => { mock.onGet(new RegExp(/^\/ibzorganizations\/([a-zA-Z0-9\-\;]{1,35})\/select$/)).reply((config: any) => {
......
...@@ -565,6 +565,45 @@ export default class EntityService { ...@@ -565,6 +565,45 @@ export default class EntityService {
return Http.getInstance().post(`/${this.APPDENAME}/import`,data,isloading); return Http.getInstance().post(`/${this.APPDENAME}/import`,data,isloading);
} }
/**
* createBatch接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof EntityService
*/
public async createBatch(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/${this.APPDENAME}/batch`,data,isloading);
}
/**
* updateBatch接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof EntityService
*/
public async updateBatch(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().put(`/${this.APPDENAME}/batch`,data,isloading);
}
/**
* removeBatch接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof EntityService
*/
public async removeBatch(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().delete(`/${this.APPDENAME}/batch`,isloading,data);
}
/** /**
* WFStart接口方法 * WFStart接口方法
* *
......
...@@ -30,6 +30,7 @@ export const viewstate: any = { ...@@ -30,6 +30,7 @@ export const viewstate: any = {
viewaction: '', viewaction: '',
viewdatachange: false, viewdatachange: false,
refviews: [ refviews: [
'9e25d15d43ff644fa008c9cf7d063ac3',
], ],
}, },
{ {
......
...@@ -150,16 +150,24 @@ export class Http { ...@@ -150,16 +150,24 @@ export class Http {
* @returns {Promise<any>} * @returns {Promise<any>}
* @memberof Http * @memberof Http
*/ */
public delete(url: string, isloading?: boolean, serialnumber?: number): Promise<any> { public delete(url: string, isloading?: boolean,data?:any, serialnumber?: number): Promise<any> {
if (isloading) { if (isloading) {
this.beginLoading(); this.beginLoading();
} }
return new Promise((resolve: any, reject: any) => { return new Promise((resolve: any, reject: any) => {
axios.delete(url).then((response: any) => { if(!data){
this.doResponseRresult(response, resolve, isloading, serialnumber); axios.delete(url).then((response: any) => {
}).catch((response: any) => { this.doResponseRresult(response, resolve, isloading, serialnumber);
this.doResponseRresult(response, reject, isloading, serialnumber); }).catch((response: any) => {
}); this.doResponseRresult(response, reject, isloading, serialnumber);
});
}else{
axios.delete(url,{data:data}).then((response: any) => {
this.doResponseRresult(response, resolve, isloading, serialnumber);
}).catch((response: any) => {
this.doResponseRresult(response, reject, isloading, serialnumber);
});
}
}); });
} }
......
...@@ -20,6 +20,31 @@ ...@@ -20,6 +20,31 @@
<input-box v-model="data.deptname" @enter="onEnter($event)" unit="" :disabled="detailsModel.deptname.disabled" type='text' style=""></input-box> <input-box v-model="data.deptname" @enter="onEnter($event)" unit="" :disabled="detailsModel.deptname.disabled" type='text' style=""></input-box>
</app-form-item> </app-form-item>
</i-col>
<i-col v-show="detailsModel.orgname.visible" :style="{}" :lg="{ span: 24, offset: 0 }">
<app-form-item name='orgname' :itemRules="this.rules.orgname" class='' :caption="$t('entities.ibzdepartment.main_form.details.orgname')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.orgname.error" :isEmptyCaption="false" labelPos="LEFT">
<app-picker
:formState="formState"
:data="data"
:context="context"
:viewparams="viewparams"
:itemParam='{ }'
:disabled="detailsModel.orgname.disabled"
name='orgname'
deMajorField='orgname'
deKeyField='ibzorganization'
:service="service"
:acParams="{ serviceName: 'IBZOrganizationService', interfaceName: 'FetchDefault'}"
valueitem='orgid'
:value="data.orgname"
editortype=""
:pickupView="{ viewname: 'ibzorganization-pickup-view', title: $t('entities.ibzorganization.views.pickupview.title'), deResParameters: [], parameters: [{ pathName: 'ibzorganizations', parameterName: 'ibzorganization' }, { pathName: 'pickupview', parameterName: 'pickupview' } ], placement:'' }"
style=""
@formitemvaluechange="onFormItemValueChange">
</app-picker>
</app-form-item>
</i-col> </i-col>
<i-col v-show="detailsModel.shortname.visible" :style="{}" :lg="{ span: 24, offset: 0 }"> <i-col v-show="detailsModel.shortname.visible" :style="{}" :lg="{ span: 24, offset: 0 }">
<app-form-item name='shortname' :itemRules="this.rules.shortname" class='' :caption="$t('entities.ibzdepartment.main_form.details.shortname')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.shortname.error" :isEmptyCaption="false" labelPos="LEFT"> <app-form-item name='shortname' :itemRules="this.rules.shortname" class='' :caption="$t('entities.ibzdepartment.main_form.details.shortname')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.shortname.error" :isEmptyCaption="false" labelPos="LEFT">
...@@ -360,6 +385,7 @@ export default class MainBase extends Vue implements ControlInterface { ...@@ -360,6 +385,7 @@ export default class MainBase extends Vue implements ControlInterface {
deptid: null, deptid: null,
deptcode: null, deptcode: null,
deptname: null, deptname: null,
orgname: null,
orgid: null, orgid: null,
pdeptid: null, pdeptid: null,
shortname: null, shortname: null,
...@@ -476,6 +502,12 @@ export default class MainBase extends Vue implements ControlInterface { ...@@ -476,6 +502,12 @@ export default class MainBase extends Vue implements ControlInterface {
{ required: true, type: 'string', message: '部门名称 值不能为空', trigger: 'change' }, { required: true, type: 'string', message: '部门名称 值不能为空', trigger: 'change' },
{ required: true, type: 'string', message: '部门名称 值不能为空', trigger: 'blur' }, { required: true, type: 'string', message: '部门名称 值不能为空', trigger: 'blur' },
], ],
orgname: [
{ type: 'string', message: '单位 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: '单位 值必须为字符串类型', trigger: 'blur' },
{ required: false, type: 'string', message: '单位 值不能为空', trigger: 'change' },
{ required: false, type: 'string', message: '单位 值不能为空', trigger: 'blur' },
],
orgid: [ orgid: [
{ type: 'string', message: '单位 值必须为字符串类型', trigger: 'change' }, { type: 'string', message: '单位 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: '单位 值必须为字符串类型', trigger: 'blur' }, { type: 'string', message: '单位 值必须为字符串类型', trigger: 'blur' },
...@@ -556,6 +588,8 @@ export default class MainBase extends Vue implements ControlInterface { ...@@ -556,6 +588,8 @@ export default class MainBase extends Vue implements ControlInterface {
deptcode: new FormItemModel({ caption: '部门代码', detailType: 'FORMITEM', name: 'deptcode', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 1 }) deptcode: new FormItemModel({ caption: '部门代码', detailType: 'FORMITEM', name: 'deptcode', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 1 })
, ,
deptname: new FormItemModel({ caption: '部门名称', detailType: 'FORMITEM', name: 'deptname', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 }) deptname: new FormItemModel({ caption: '部门名称', detailType: 'FORMITEM', name: 'deptname', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
orgname: new FormItemModel({ caption: '单位', detailType: 'FORMITEM', name: 'orgname', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, ,
orgid: new FormItemModel({ caption: '单位', detailType: 'FORMITEM', name: 'orgid', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 }) orgid: new FormItemModel({ caption: '单位', detailType: 'FORMITEM', name: 'orgid', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
, ,
...@@ -707,6 +741,18 @@ export default class MainBase extends Vue implements ControlInterface { ...@@ -707,6 +741,18 @@ export default class MainBase extends Vue implements ControlInterface {
this.formDataChange({ name: 'deptname', newVal: newVal, oldVal: oldVal }); this.formDataChange({ name: 'deptname', newVal: newVal, oldVal: oldVal });
} }
/**
* 监控表单属性 orgname 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Main
*/
@Watch('data.orgname')
onOrgnameChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'orgname', newVal: newVal, oldVal: oldVal });
}
/** /**
* 监控表单属性 orgid 值 * 监控表单属性 orgid 值
* *
...@@ -857,6 +903,7 @@ export default class MainBase extends Vue implements ControlInterface { ...@@ -857,6 +903,7 @@ export default class MainBase extends Vue implements ControlInterface {
} }
......
...@@ -70,6 +70,11 @@ export default class MainModel { ...@@ -70,6 +70,11 @@ export default class MainModel {
prop: 'deptname', prop: 'deptname',
dataType: 'TEXT', dataType: 'TEXT',
}, },
{
name: 'orgname',
prop: 'orgname',
dataType: 'PICKUPTEXT',
},
{ {
name: 'orgid', name: 'orgid',
prop: 'orgid', prop: 'orgid',
......
...@@ -2,6 +2,7 @@ import { Http,Util,Errorlog } from '@/utils'; ...@@ -2,6 +2,7 @@ import { Http,Util,Errorlog } from '@/utils';
import ControlService from '@/widgets/control-service'; import ControlService from '@/widgets/control-service';
import IBZDepartmentService from '@/service/ibzdepartment/ibzdepartment-service'; import IBZDepartmentService from '@/service/ibzdepartment/ibzdepartment-service';
import MainModel from './main-form-model'; import MainModel from './main-form-model';
import IBZOrganizationService from '@/service/ibzorganization/ibzorganization-service';
/** /**
...@@ -41,6 +42,14 @@ export default class MainService extends ControlService { ...@@ -41,6 +42,14 @@ export default class MainService extends ControlService {
this.model = new MainModel(); this.model = new MainModel();
} }
/**
* 单位机构服务对象
*
* @type {IBZOrganizationService}
* @memberof MainService
*/
public ibzorganizationService: IBZOrganizationService = new IBZOrganizationService();
/** /**
* 处理数据 * 处理数据
* *
...@@ -80,6 +89,9 @@ export default class MainService extends ControlService { ...@@ -80,6 +89,9 @@ export default class MainService extends ControlService {
*/ */
@Errorlog @Errorlog
public getItems(serviceName: string, interfaceName: string, context: any = {}, data: any, isloading?: boolean): Promise<any[]> { public getItems(serviceName: string, interfaceName: string, context: any = {}, data: any, isloading?: boolean): Promise<any[]> {
if (Object.is(serviceName, 'IBZOrganizationService') && Object.is(interfaceName, 'FetchDefault')) {
return this.doItems(this.ibzorganizationService.FetchDefault(JSON.parse(JSON.stringify(context)),data, isloading), 'orgid', 'ibzorganization');
}
return Promise.reject([]) return Promise.reject([])
} }
......
...@@ -51,6 +51,9 @@ export default class PickupViewpickupviewpanelModel { ...@@ -51,6 +51,9 @@ export default class PickupViewpickupviewpanelModel {
{ {
name: 'updatedate', name: 'updatedate',
}, },
{
name: 'orgname',
},
] ]
} }
......
...@@ -124,6 +124,14 @@ public class IBZDepartment extends EntityMP implements Serializable { ...@@ -124,6 +124,14 @@ public class IBZDepartment extends EntityMP implements Serializable {
@JSONField(name = "updatedate" , format="yyyy-MM-dd HH:mm:ss") @JSONField(name = "updatedate" , format="yyyy-MM-dd HH:mm:ss")
@JsonProperty("updatedate") @JsonProperty("updatedate")
private Timestamp updatedate; private Timestamp updatedate;
/**
* 单位
*/
@DEField(preType = DEPredefinedFieldType.ORGNAME)
@TableField(value = "orgname")
@JSONField(name = "orgname")
@JsonProperty("orgname")
private String orgname;
/** /**
* *
......
...@@ -61,6 +61,20 @@ public class IBZDepartmentSearchContext extends QueryWrapperContext<IBZDepartmen ...@@ -61,6 +61,20 @@ public class IBZDepartmentSearchContext extends QueryWrapperContext<IBZDepartmen
this.getSelectCond().like("bcode", n_bcode_like); this.getSelectCond().like("bcode", n_bcode_like);
} }
} }
private String n_orgname_eq;//[单位]
public void setN_orgname_eq(String n_orgname_eq) {
this.n_orgname_eq = n_orgname_eq;
if(!ObjectUtils.isEmpty(this.n_orgname_eq)){
this.getSelectCond().eq("orgname", n_orgname_eq);
}
}
private String n_orgname_like;//[单位]
public void setN_orgname_like(String n_orgname_like) {
this.n_orgname_like = n_orgname_like;
if(!ObjectUtils.isEmpty(this.n_orgname_like)){
this.getSelectCond().like("orgname", n_orgname_like);
}
}
/** /**
* 启用快速搜索 * 启用快速搜索
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
{ {
"dename":"IBZDepartment", "dename":"IBZDepartment",
"delogicname":"部门", "delogicname":"部门",
"sysmoudle":{"id":"OU","name":"组织人事"}, "sysmoudle":{"id":"OU","name":"ou"},
"dedataset":[{"id":"Default","name":"默认数据集"}], "dedataset":[{"id":"Default","name":"默认数据集"}],
"dedatarange":[{"id":"ALL","name":"全部数据"},{"id":"CURORG","name":"当前单位"},{"id":"PORG","name":"上级单位"},{"id":"SORG","name":"下级单位"},{"id":"CURORGDEPT","name":"当前部门"},{"id":"PORGDEPT","name":"上级部门"},{"id":"SORGDEPT","name":"下级部门"}], "dedatarange":[{"id":"ALL","name":"全部数据"},{"id":"CURORG","name":"当前单位"},{"id":"PORG","name":"上级单位"},{"id":"SORG","name":"下级单位"},{"id":"CURORGDEPT","name":"当前部门"},{"id":"PORGDEPT","name":"上级部门"},{"id":"SORGDEPT","name":"下级部门"}],
"deprivs":[{"id":"READ","name":"READ"},{"id":"CREATE","name":"CREATE"},{"id":"UPDATE","name":"UPDATE"},{"id":"DELETE","name":"DELETE"}] "deprivs":[{"id":"READ","name":"READ"},{"id":"CREATE","name":"CREATE"},{"id":"UPDATE","name":"UPDATE"},{"id":"DELETE","name":"DELETE"}]
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
{ {
"dename":"IBZEmployee", "dename":"IBZEmployee",
"delogicname":"人员", "delogicname":"人员",
"sysmoudle":{"id":"OU","name":"组织人事"}, "sysmoudle":{"id":"OU","name":"ou"},
"dedataset":[{"id":"Default","name":"默认数据集"}], "dedataset":[{"id":"Default","name":"默认数据集"}],
"dedatarange":[{"id":"ALL","name":"全部数据"},{"id":"CURORG","name":"当前单位"},{"id":"PORG","name":"上级单位"},{"id":"SORG","name":"下级单位"},{"id":"CURORGDEPT","name":"当前部门"},{"id":"PORGDEPT","name":"上级部门"},{"id":"SORGDEPT","name":"下级部门"}], "dedatarange":[{"id":"ALL","name":"全部数据"},{"id":"CURORG","name":"当前单位"},{"id":"PORG","name":"上级单位"},{"id":"SORG","name":"下级单位"},{"id":"CURORGDEPT","name":"当前部门"},{"id":"PORGDEPT","name":"上级部门"},{"id":"SORGDEPT","name":"下级部门"}],
"deprivs":[{"id":"READ","name":"READ"},{"id":"CREATE","name":"CREATE"},{"id":"UPDATE","name":"UPDATE"},{"id":"DELETE","name":"DELETE"}] "deprivs":[{"id":"READ","name":"READ"},{"id":"CREATE","name":"CREATE"},{"id":"UPDATE","name":"UPDATE"},{"id":"DELETE","name":"DELETE"}]
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
{ {
"dename":"IBZOrganization", "dename":"IBZOrganization",
"delogicname":"单位机构", "delogicname":"单位机构",
"sysmoudle":{"id":"OU","name":"组织人事"}, "sysmoudle":{"id":"OU","name":"ou"},
"dedataset":[{"id":"Default","name":"默认数据集"}], "dedataset":[{"id":"Default","name":"默认数据集"}],
"dedatarange":[{"id":"ALL","name":"全部数据"},{"id":"CURORG","name":"当前单位"},{"id":"PORG","name":"上级单位"},{"id":"SORG","name":"下级单位"},{"id":"CURORGDEPT","name":"当前部门"},{"id":"PORGDEPT","name":"上级部门"},{"id":"SORGDEPT","name":"下级部门"}], "dedatarange":[{"id":"ALL","name":"全部数据"},{"id":"CURORG","name":"当前单位"},{"id":"PORG","name":"上级单位"},{"id":"SORG","name":"下级单位"},{"id":"CURORGDEPT","name":"当前部门"},{"id":"PORGDEPT","name":"上级部门"},{"id":"SORGDEPT","name":"下级部门"}],
"deprivs":[{"id":"READ","name":"READ"},{"id":"CREATE","name":"CREATE"},{"id":"UPDATE","name":"UPDATE"},{"id":"DELETE","name":"DELETE"}] "deprivs":[{"id":"READ","name":"READ"},{"id":"CREATE","name":"CREATE"},{"id":"UPDATE","name":"UPDATE"},{"id":"DELETE","name":"DELETE"}]
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd"> <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
<!--输出实体[IBZORG]数据结构 --> <!--输出实体[IBZORG]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-ibzorg-368-1"> <changeSet author="a_A_5d9d78509" id="tab-ibzorg-380-1">
<createTable tableName="IBZORG"> <createTable tableName="IBZORG">
<column name="ORGID" remarks="" type="VARCHAR(100)"> <column name="ORGID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_IBZORG_ORGID"/> <constraints primaryKey="true" primaryKeyName="PK_IBZORG_ORGID"/>
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
</createTable> </createTable>
</changeSet> </changeSet>
<!--输出实体[IBZDEPT]数据结构 --> <!--输出实体[IBZDEPT]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-ibzdept-476-3"> <changeSet author="a_A_5d9d78509" id="tab-ibzdept-495-3">
<createTable tableName="IBZDEPT"> <createTable tableName="IBZDEPT">
<column name="DEPTID" remarks="" type="VARCHAR(100)"> <column name="DEPTID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_IBZDEPT_DEPTID"/> <constraints primaryKey="true" primaryKeyName="PK_IBZDEPT_DEPTID"/>
...@@ -133,11 +133,13 @@ ...@@ -133,11 +133,13 @@
</column> </column>
<column name="UPDATEDATE" remarks="" type="DATETIME"> <column name="UPDATEDATE" remarks="" type="DATETIME">
</column> </column>
<column name="ORGNAME" remarks="" type="VARCHAR(100)">
</column>
</createTable> </createTable>
</changeSet> </changeSet>
<!--输出实体[IBZORG]外键关系 --> <!--输出实体[IBZORG]外键关系 -->
<changeSet author="a_A_5d9d78509" id="fk-ibzorg-368-4"> <changeSet author="a_A_5d9d78509" id="fk-ibzorg-380-4">
<addForeignKeyConstraint baseColumnNames="PORGID" baseTableName="IBZORG" constraintName="DER1N_IBZORG_IBZORG_PORGID" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="ORGID" referencedTableName="IBZORG" validate="true"/> <addForeignKeyConstraint baseColumnNames="PORGID" baseTableName="IBZORG" constraintName="DER1N_IBZORG_IBZORG_PORGID" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="ORGID" referencedTableName="IBZORG" validate="true"/>
</changeSet> </changeSet>
<!--输出实体[IBZEMP]外键关系 --> <!--输出实体[IBZEMP]外键关系 -->
...@@ -148,10 +150,10 @@ ...@@ -148,10 +150,10 @@
<addForeignKeyConstraint baseColumnNames="ORGID" baseTableName="IBZEMP" constraintName="DER1N_IBZEMP_IBZORG_ORGID" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="ORGID" referencedTableName="IBZORG" validate="true"/> <addForeignKeyConstraint baseColumnNames="ORGID" baseTableName="IBZEMP" constraintName="DER1N_IBZEMP_IBZORG_ORGID" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="ORGID" referencedTableName="IBZORG" validate="true"/>
</changeSet> </changeSet>
<!--输出实体[IBZDEPT]外键关系 --> <!--输出实体[IBZDEPT]外键关系 -->
<changeSet author="a_A_5d9d78509" id="fk-ibzdept-476-7"> <changeSet author="a_A_5d9d78509" id="fk-ibzdept-495-7">
<addForeignKeyConstraint baseColumnNames="PDEPTID" baseTableName="IBZDEPT" constraintName="DER1N_IBZDEPT_IBZDEPT_PDEPTID" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="DEPTID" referencedTableName="IBZDEPT" validate="true"/> <addForeignKeyConstraint baseColumnNames="PDEPTID" baseTableName="IBZDEPT" constraintName="DER1N_IBZDEPT_IBZDEPT_PDEPTID" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="DEPTID" referencedTableName="IBZDEPT" validate="true"/>
</changeSet> </changeSet>
<changeSet author="a_A_5d9d78509" id="fk-ibzdept-476-8"> <changeSet author="a_A_5d9d78509" id="fk-ibzdept-495-8">
<addForeignKeyConstraint baseColumnNames="ORGID" baseTableName="IBZDEPT" constraintName="DER1N_IBZDEPT_IBZORG_ORGID" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="ORGID" referencedTableName="IBZORG" validate="true"/> <addForeignKeyConstraint baseColumnNames="ORGID" baseTableName="IBZDEPT" constraintName="DER1N_IBZDEPT_IBZORG_ORGID" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="ORGID" referencedTableName="IBZORG" validate="true"/>
</changeSet> </changeSet>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<!--该方法用于重写mybatis中selectById方法,以实现查询逻辑属性--> <!--该方法用于重写mybatis中selectById方法,以实现查询逻辑属性-->
<select id="selectById" resultMap="IBZDepartmentResultMap" databaseId="mysql"> <select id="selectById" resultMap="IBZDepartmentResultMap" databaseId="mysql">
<![CDATA[select t1.* from (SELECT t1.`BCODE`, t1.`CREATEDATE`, t1.`DEPTCODE`, t1.`DEPTID`, t1.`DEPTLEVEL`, t1.`DEPTNAME`, t1.`ENABLE`, t1.`ORGID`, t1.`PDEPTID`, t1.`SHORTNAME`, t1.`SHOWORDER`, t1.`UPDATEDATE` FROM `IBZDEPT` t1 ) t1 where deptid=#{id}]]> <![CDATA[select t1.* from (SELECT t1.`BCODE`, t1.`CREATEDATE`, t1.`DEPTCODE`, t1.`DEPTID`, t1.`DEPTLEVEL`, t1.`DEPTNAME`, t1.`ENABLE`, t1.`ORGID`, t1.`ORGNAME`, t1.`PDEPTID`, t1.`SHORTNAME`, t1.`SHOWORDER`, t1.`UPDATEDATE` FROM `IBZDEPT` t1 ) t1 where deptid=#{id}]]>
</select> </select>
<select id="selectById" resultMap="IBZDepartmentResultMap" databaseId="postgresql"> <select id="selectById" resultMap="IBZDepartmentResultMap" databaseId="postgresql">
<![CDATA[select t1.* from (SELECT t1.BCODE, t1.CREATEDATE, t1.DEPTCODE, t1.DEPTID, t1.DEPTLEVEL, t1.DEPTNAME, t1.ENABLE, t1.ORGID, t1.PDEPTID, t1.SHORTNAME, t1.SHOWORDER, t1.UPDATEDATE FROM IBZDEPT t1 ) t1 where deptid=#{id}]]> <![CDATA[select t1.* from (SELECT t1.BCODE, t1.CREATEDATE, t1.DEPTCODE, t1.DEPTID, t1.DEPTLEVEL, t1.DEPTNAME, t1.ENABLE, t1.ORGID, t1.PDEPTID, t1.SHORTNAME, t1.SHOWORDER, t1.UPDATEDATE FROM IBZDEPT t1 ) t1 where deptid=#{id}]]>
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<!--数据查询[Default]--> <!--数据查询[Default]-->
<sql id="Default" databaseId="mysql"> <sql id="Default" databaseId="mysql">
<![CDATA[ SELECT t1.`BCODE`, t1.`CREATEDATE`, t1.`DEPTCODE`, t1.`DEPTID`, t1.`DEPTLEVEL`, t1.`DEPTNAME`, t1.`ENABLE`, t1.`ORGID`, t1.`PDEPTID`, t1.`SHORTNAME`, t1.`SHOWORDER`, t1.`UPDATEDATE` FROM `IBZDEPT` t1 <![CDATA[ SELECT t1.`BCODE`, t1.`CREATEDATE`, t1.`DEPTCODE`, t1.`DEPTID`, t1.`DEPTLEVEL`, t1.`DEPTNAME`, t1.`ENABLE`, t1.`ORGID`, t1.`ORGNAME`, t1.`PDEPTID`, t1.`SHORTNAME`, t1.`SHOWORDER`, t1.`UPDATEDATE` FROM `IBZDEPT` t1
WHERE t1.ENABLE = 1 WHERE t1.ENABLE = 1
]]> ]]>
</sql> </sql>
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
<!--数据查询[View]--> <!--数据查询[View]-->
<sql id="View" databaseId="mysql"> <sql id="View" databaseId="mysql">
<![CDATA[ SELECT t1.`BCODE`, t1.`CREATEDATE`, t1.`DEPTCODE`, t1.`DEPTID`, t1.`DEPTLEVEL`, t1.`DEPTNAME`, t1.`ENABLE`, t1.`ORGID`, t1.`PDEPTID`, t1.`SHORTNAME`, t1.`SHOWORDER`, t1.`UPDATEDATE` FROM `IBZDEPT` t1 <![CDATA[ SELECT t1.`BCODE`, t1.`CREATEDATE`, t1.`DEPTCODE`, t1.`DEPTID`, t1.`DEPTLEVEL`, t1.`DEPTNAME`, t1.`ENABLE`, t1.`ORGID`, t1.`ORGNAME`, t1.`PDEPTID`, t1.`SHORTNAME`, t1.`SHOWORDER`, t1.`UPDATEDATE` FROM `IBZDEPT` t1
WHERE t1.ENABLE = 1 WHERE t1.ENABLE = 1
]]> ]]>
</sql> </sql>
......
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
</dependency> </dependency>
</dependencies> </dependencies>
<properties>
<docker.image.prefix>registry.cn-shanghai.aliyuncs.com/ibizsys</docker.image.prefix>
</properties>
<profiles> <profiles>
<profile> <profile>
<id>ouapi</id> <id>ouapi</id>
...@@ -62,6 +66,23 @@ ...@@ -62,6 +66,23 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
<configuration>
<serverId>ibiz-dev</serverId>
<imageName>${docker.image.prefix}/${project.artifactId}:latest</imageName>
<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>../../</directory>
<include>${project.artifactId}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
</profile> </profile>
......
FROM openjdk:8-jre-alpine
ENV SPRING_OUTPUT_ANSI_ENABLED=ALWAYS \
IBZ_SLEEP=0 \
JAVA_OPTS=""
CMD echo "The application will start in ${IBZ_SLEEP}s..." && \
sleep ${IBZ_SLEEP} && \
java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /ibzou-provider-ouapi.jar
EXPOSE 8081
ADD ibzou-provider-ouapi.jar /ibzou-provider-ouapi.jar
version: "3.2"
services:
ibzou-provider-ouapi:
image: registry.cn-shanghai.aliyuncs.com/ibizsys/ibzou-provider-ouapi:latest
ports:
- "8081:8081"
networks:
- agent_network
deploy:
mode: replicated
replicas: 1
networks:
agent_network:
driver: overlay
attachable: true
\ No newline at end of file
...@@ -121,6 +121,14 @@ public class IBZDepartmentDTO extends DTOBase implements Serializable { ...@@ -121,6 +121,14 @@ public class IBZDepartmentDTO extends DTOBase implements Serializable {
@JsonProperty("updatedate") @JsonProperty("updatedate")
private Timestamp updatedate; private Timestamp updatedate;
/**
* 属性 [ORGNAME]
*
*/
@JSONField(name = "orgname")
@JsonProperty("orgname")
private String orgname;
/** /**
* 设置 [DEPTCODE] * 设置 [DEPTCODE]
......
package cn.ibizlab.util.client;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;
@Component
public class IBZOUFallback implements IBZOUFeignClient {
@Override
public JSONObject getOrgInfo(String orgLevel) {
return null;
}
}
package cn.ibizlab.util.client;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@FeignClient(value = "ibzou",fallback = IBZOUFallback.class)
public interface IBZOUFeignClient
{
/**
* 从ou中获取当前上下级组织、部门信息
* @param orgLevel
* @return
*/
@GetMapping(value = "/ibzou/org/{orglevel}")
JSONObject getOrgInfo(@PathVariable("orglevel") String orgLevel);
}
package cn.ibizlab.util.client;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public class IBZUAAFallback implements IBZUAAFeignClient {
@Override
public JSONObject getUserPermissionData(String userId, String systemId) {
return null;
}
@Override
public Map<String, Object> pushSystemPermissionData(Map<String, Object> systemPermissionData, String systemId) {
return null;
}
}
package cn.ibizlab.util.client;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@FeignClient(value = "ibzuaa",fallback = IBZUAAFallback.class)
public interface IBZUAAFeignClient
{
/**
* 从uaa中获取当前用户权限
* @param userId
* @param systemId
* @return
*/
@GetMapping(value = "/uaa/permission/{userid}")
JSONObject getUserPermissionData(@PathVariable("userid") String userId, @RequestParam("systemid") String systemId);
/**
* 推送系统权限数据到uaa
* @param systemPermissionData
* @param systemId
* @return
*/
@PostMapping("/uaa/permission/save")
Map<String,Object> pushSystemPermissionData(@RequestBody Map<String, Object> systemPermissionData, @RequestParam("systemid") String systemId);
}
...@@ -2,7 +2,7 @@ package cn.ibizlab.util.job; ...@@ -2,7 +2,7 @@ package cn.ibizlab.util.job;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import cn.ibizlab.util.client.uaa.UAAFeignClient; import cn.ibizlab.util.client.IBZUAAFeignClient;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
...@@ -27,7 +27,7 @@ public class PermissionSyncJob implements ApplicationRunner { ...@@ -27,7 +27,7 @@ public class PermissionSyncJob implements ApplicationRunner {
private Log log = LogFactory.getLog(PermissionSyncJob.class); private Log log = LogFactory.getLog(PermissionSyncJob.class);
@Autowired @Autowired
private UAAFeignClient client; private IBZUAAFeignClient client;
@Value("${ibiz.enablePermissionValid:false}") @Value("${ibiz.enablePermissionValid:false}")
boolean enablePermissionValid; //是否开启权限校验 boolean enablePermissionValid; //是否开启权限校验
......
...@@ -2,7 +2,6 @@ package cn.ibizlab.util.security; ...@@ -2,7 +2,6 @@ package cn.ibizlab.util.security;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.ibizlab.util.domain.EntityBase; import cn.ibizlab.util.domain.EntityBase;
...@@ -111,28 +110,32 @@ public class AuthPermissionEvaluator implements PermissionEvaluator { ...@@ -111,28 +110,32 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
boolean isPermission; boolean isPermission;
EntityBase entityBase = null; EntityBase entity = null;
if (cur_entity instanceof EntityBase) if (cur_entity instanceof EntityBase)
entityBase = (EntityBase) cur_entity; entity = (EntityBase) cur_entity;
if (StringUtils.isEmpty(entityBase)) if (StringUtils.isEmpty(entity))
return false; return false;
try { try {
String entityName = entityBase.getClass().getSimpleName(); //实体名 String entityName = entity.getClass().getSimpleName(); //实体名
if(action.equals("CREATE")){ //表单新建权限校验 if(action.equals("CREATE")){ //表单新建权限校验
JSONObject permissionList= AuthenticationUser.getAuthenticationUser().getPermisionList();//获取权限列表 JSONObject permissionList= AuthenticationUser.getAuthenticationUser().getPermisionList();//获取权限列表
JSONObject formDataAbility=permissionList.getJSONObject("dataAbility-form");//获取表单的权限数据 JSONObject formDataAbility=permissionList.getJSONObject("dataAbility-form");//获取表单的权限数据
return isFormCreatePermission(formDataAbility,entityName,action);//拼接权限条件 return isFormCreatePermission(formDataAbility,entityName,action);//拼接权限条件
} }
else{ //表单编辑、查询权限校验 else{
//表单编辑、查询权限校验
ServiceImpl service= SpringContextHolder.getBean(String.format("%s%s",getBeanName(entityName),"ServiceImpl"));//获取当前实体service ServiceImpl service= SpringContextHolder.getBean(String.format("%s%s",getBeanName(entityName),"ServiceImpl"));//获取当前实体service
JSONObject permissionList= AuthenticationUser.getAuthenticationUser().getPermisionList();//获取权限列表 JSONObject permissionList= AuthenticationUser.getAuthenticationUser().getPermisionList();//获取权限列表
JSONObject formDataAbility=permissionList.getJSONObject("dataAbility-form");//获取表单的权限数据 JSONObject formDataAbility=permissionList.getJSONObject("dataAbility-form");//获取表单的权限数据
Map<String,String> permissionField=getPermissionField(entityBase);
String selectCond=generatePermissionSQLForm(formDataAbility,entityName,action,srfkey,permissionField);//拼接权限条件 if(isAllData(formDataAbility,entityName,action)){//若为全部数据则直接返回,不再进行校验
return true;
}
Map<String,String> permissionField=getPermissionField(entity);//获取系统预置属性
String selectCond=generatePermissionSQLForm(formDataAbility,entityName,action,srfkey,permissionField);//根据uaa中分配的权限拼接where条件
if(StringUtils.isEmpty(selectCond)) if(StringUtils.isEmpty(selectCond))
return false; return false;
QueryWrapper permissionCond=getPermissionCond(selectCond,permissionField); QueryWrapper permissionCond=getPermissionCond(selectCond,permissionField);
...@@ -144,6 +147,33 @@ public class AuthPermissionEvaluator implements PermissionEvaluator { ...@@ -144,6 +147,33 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
return isPermission; return isPermission;
} }
/**
* 判断是否包含全部数据
* @param formDataAbility
* @param entityName
* @param action
* @return
*/
private boolean isAllData(JSONObject formDataAbility, String entityName, String action) {
if(formDataAbility==null)
return false;
if(!formDataAbility.containsKey(entityName))
return false;
JSONObject entityObj=formDataAbility.getJSONObject(entityName);//获取实体
if(!entityObj.containsKey(action))
return false;
JSONArray entityOperation=entityObj.getJSONArray(action);//行为:read;insert...
if(entityOperation.size()==0)
return false;
if(entityOperation.contains("ALL")){ //全部数据
return true;
}
return false;
}
/** /**
* 拼接表格查询条件 * 拼接表格查询条件
* @param gridDataAbility * @param gridDataAbility
...@@ -260,41 +290,51 @@ public class AuthPermissionEvaluator implements PermissionEvaluator { ...@@ -260,41 +290,51 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
*/ */
private String getPermissionCond(JSONArray entityOperation, Map<String,String> permissionField){ private String getPermissionCond(JSONArray entityOperation, Map<String,String> permissionField){
String orgField=permissionField.get("orgfield"); String orgField=permissionField.get("orgfield");
String orgsecfield=permissionField.get("orgsecfield"); String orgDeptField=permissionField.get("orgsecfield");
StringBuffer cond=new StringBuffer(); StringBuffer permissionSQL=new StringBuffer();
AuthenticationUser authenticationUser = AuthenticationUser.getAuthenticationUser();
JSONObject userInfo = authenticationUser.getOrgInfo();
JSONObject orgObject = userInfo.getJSONObject("org");
JSONArray orgParent = orgObject.getJSONArray("porg");
JSONArray orgChild = orgObject.getJSONArray("sorg");
JSONObject orgDeptObject = userInfo.getJSONObject("orgdept");
JSONArray orgDeptParent = orgDeptObject.getJSONArray("porgdept");
JSONArray orgDeptChild = orgDeptObject.getJSONArray("sorgdept");
for(int i=0;i<entityOperation.size();i++){ for(int i=0;i<entityOperation.size();i++){
if(i>0 && (!StringUtils.isEmpty(cond.toString()))) if(i>0 && (!StringUtils.isEmpty(permissionSQL.toString())))
cond.append("OR"); permissionSQL.append("OR");
String permissionCond=entityOperation.getString(i);//权限配置条件 String permissionCond=entityOperation.getString(i);//权限配置条件
if(permissionCond.equals("CUR_ORG")){ //本单位 if(permissionCond.equals("CURORG")){ //本单位
cond.append(String.format("(t1.%s='%s')",orgField,AuthenticationUser.getAuthenticationUser().getOrgid())); permissionSQL.append(String.format("(%s='%s')",orgField,AuthenticationUser.getAuthenticationUser().getOrgid()));
} }
if(permissionCond.equals("SUB_ORG")){//下级单位 if(permissionCond.equals("SORG")){//下级单位
cond.append(" INSTR(j1.LEVELCODE,'"+AuthenticationUser.getAuthenticationUser().getLevelcode()+"')=1 "); permissionSQL.append(String.format(" %s in(%s) ", orgField, formatStringArr(orgChild)));
} }
if(permissionCond.equals("HIT_ORG")){//上级单位 if(permissionCond.equals("PORG")){//上级单位
cond.append(" INSTR('"+AuthenticationUser.getAuthenticationUser().getLevelcode()+"',j1.LEVELCODE)=1 "); permissionSQL.append(String.format(" %s in(%s) ", orgField, formatStringArr(orgParent)));
} }
if(permissionCond.equals("CREATEMAN")){//建立人 if(permissionCond.equals("CREATEMAN")){//建立人
cond.append(String.format("(t1.createman='%s')",AuthenticationUser.getAuthenticationUser().getUserid())); permissionSQL.append(String.format("(createman='%s')",AuthenticationUser.getAuthenticationUser().getUserid()));
}
if(permissionCond.equals("CURORGDEPT")){//本部门
permissionSQL.append(String.format("(orgsecid='%s')",AuthenticationUser.getAuthenticationUser().getMdeptid()));
}
if(permissionCond.equals("SORGDEPT")){//下级部门
permissionSQL.append(String.format(" %s in (%s) ", orgDeptField, formatStringArr(orgDeptChild)));
}
if(permissionCond.equals("PORGDEPT")){//上级部门
permissionSQL.append(String.format(" %s in (%s) ", orgDeptField, formatStringArr(orgDeptParent)));
} }
// if(permissionCond.equals("CUR_ORGSEC")){//本部门
// cond.append(String.format("(t1.orgsecid='%s')",AuthenticationUser.getAuthenticationUser().getMdeptid()));
// }
// if(permissionCond.equals("SUB_ORGSEC")){//下级部门
// cond.append(" INSTR(j2.LEVELCODE,'"+AuthenticationUser.getAuthenticationUser().getMdeptcode()+"')=1 ");
// }
// if(permissionCond.equals("HIGH_ORGSEC")){//上级部门
// cond.append(" INSTR('"+AuthenticationUser.getAuthenticationUser().getMdeptcode()+"',j2.LEVELCODE)=1 ");
// }
if(permissionCond.equals("ALL")){//全部数据 if(permissionCond.equals("ALL")){//全部数据
cond.append("(1=1)"); permissionSQL.append("(1=1)");
} }
} }
if(StringUtils.isEmpty(cond.toString())) if(StringUtils.isEmpty(permissionSQL.toString()))
return ""; return "";
String resultCond=cond.toString(); String resultCond=permissionSQL.toString();
if(resultCond.endsWith("OR")){ if(resultCond.endsWith("OR")){
resultCond=resultCond.substring(0,resultCond.lastIndexOf("OR")); resultCond=resultCond.substring(0,resultCond.lastIndexOf("OR"));
} }
...@@ -309,15 +349,11 @@ public class AuthPermissionEvaluator implements PermissionEvaluator { ...@@ -309,15 +349,11 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
*/ */
private QueryWrapper getPermissionCond(String whereCond, Map<String,String> permissionField){ private QueryWrapper getPermissionCond(String whereCond, Map<String,String> permissionField){
Wrapper wrapper =new QueryWrapper();
QueryWrapper allPermissionCond=new QueryWrapper(); QueryWrapper allPermissionCond=new QueryWrapper();
//permissionCond.apply("inner join JC_ORG j1 on t1.ORGID=j1.orgid inner join JC_ORGSEC j2 on t1.orgsecid=j2.orgsecid");
if(StringUtils.isEmpty(whereCond)) if(StringUtils.isEmpty(whereCond))
return allPermissionCond; return allPermissionCond;
// String strAllPermissionCond=String.format("inner join XT_ZZJG_DWBM j1 on t1.%s=j1.dwbm where (%s) ",permissionField.get("orgfield"),whereCond);
allPermissionCond.apply(whereCond); allPermissionCond.apply(whereCond);
return allPermissionCond; return allPermissionCond;
...@@ -361,4 +397,15 @@ public class AuthPermissionEvaluator implements PermissionEvaluator { ...@@ -361,4 +397,15 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
} }
} }
/**
* 转换[a,b]格式字符串到 'a','b'格式
*
* @return
*/
private String formatStringArr(JSONArray array) {
String[] arr = array.toArray(new String[array.size()]);
return "'" + String.join("','", arr) + "'";
}
} }
\ No newline at end of file
...@@ -65,6 +65,8 @@ public class AuthenticationUser implements UserDetails ...@@ -65,6 +65,8 @@ public class AuthenticationUser implements UserDetails
private String levelcode;//单位级别编码 private String levelcode;//单位级别编码
@JsonIgnore @JsonIgnore
private Map<String,String> userSessionParam;//用户自定义session值 private Map<String,String> userSessionParam;//用户自定义session值
@JsonIgnore
private JSONObject orgInfo;//上下级组织信息
@JsonIgnore @JsonIgnore
......
package cn.ibizlab.util.service; package cn.ibizlab.util.service;
import cn.ibizlab.util.security.AuthenticationUser; import cn.ibizlab.util.security.AuthenticationUser;
import cn.ibizlab.util.client.uaa.UAAFeignClient; import cn.ibizlab.util.client.IBZUAAFeignClient;
import cn.ibizlab.util.client.IBZOUFeignClient;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -18,7 +19,17 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -18,7 +19,17 @@ import org.springframework.beans.factory.annotation.Value;
@Service("SimpleUserService") @Service("SimpleUserService")
public class SimpleUserService implements AuthenticationUserService{ public class SimpleUserService implements AuthenticationUserService{
@Value("${ibiz.enablePermissionValid:false}")
boolean enablePermissionValid; //是否开启权限校验
@Value("${ibiz.systemid:2C40DFCD-0DF5-47BF-91A5-C45F810B0001}")
private String systemid;
@Autowired
private IBZUAAFeignClient uaaFeignClient;
@Autowired
private IBZOUFeignClient ouFeignClient;
@Override @Override
public AuthenticationUser loadUserByUsername(String username) { public AuthenticationUser loadUserByUsername(String username) {
...@@ -49,7 +60,9 @@ public class SimpleUserService implements AuthenticationUserService{ ...@@ -49,7 +60,9 @@ public class SimpleUserService implements AuthenticationUserService{
user.setOrgcode(domains); user.setOrgcode(domains);
user.setOrgname(domains); user.setOrgname(domains);
testPermissionData(user);
setUserPermission(user); setUserPermission(user);
setUserOrgInfo(user);
return user; return user;
} }
...@@ -73,25 +86,34 @@ public class SimpleUserService implements AuthenticationUserService{ ...@@ -73,25 +86,34 @@ public class SimpleUserService implements AuthenticationUserService{
} }
@Value("${ibiz.enablePermissionValid:false}")
boolean enablePermissionValid; //是否开启权限校验
@Value("${ibiz.systemid:2C40DFCD-0DF5-47BF-91A5-C45F810B0001}")
private String systemid;
@Autowired
private UAAFeignClient client;
/** /**
* 设置用户权限 * 设置用户权限
*/ */
private void setUserPermission(AuthenticationUser curUser) { private void setUserPermission(AuthenticationUser user) {
if(enablePermissionValid){ if(enablePermissionValid){
String userid=curUser.getUserid(); JSONObject permission= uaaFeignClient.getUserPermissionData(user.getUserid(),systemid);
//String userid="4fb71d8997d4505d2748ad2bdc471969"; user.setPermisionList(permission);
//String systemid="2C40DFCD-0DF5-47BF-91A5-C45F810B0001";
JSONObject permission= client.getUserPermissionData(userid,systemid);
curUser.setPermisionList(permission);
} }
} }
/**
* 设置用户组织相关信息
* @param user
*/
private void setUserOrgInfo(AuthenticationUser user) {
if(enablePermissionValid) {
user.setOrgInfo(ouFeignClient.getOrgInfo(user.getLevelcode()));
}
}
/**
* 测试数据
* @param user
*/
private void testPermissionData(AuthenticationUser user){
user.setLevelcode("4501");
user.setUserid("4fb71d8997d4505d2748ad2bdc471969");
this.systemid="2C40DFCD-0DF5-47BF-91A5-C45F810B0001";
}
} }
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册