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

ibiz4j 发布系统代码

上级 32dc0933
...@@ -93,6 +93,11 @@ ...@@ -93,6 +93,11 @@
<template v-if="!Object.is(layoutType, 'FLEX')"> <template v-if="!Object.is(layoutType, 'FLEX')">
<row :gutter="10"><slot></slot></row> <row :gutter="10"><slot></slot></row>
</template> </template>
<template v-if="isManageContainer">
<i-button type="primary" :icon="manageContainerStatus?'ios-repeat':'ios-more'" @click="doManageContainer">
{{manageContainerStatus?$t('components.appFormGroup.hide'):$t('components.appFormGroup.showMore')}}
</i-button>
</template>
</card> </card>
<template v-if="isShowCaption === false"> <template v-if="isShowCaption === false">
<slot></slot> <slot></slot>
...@@ -115,6 +120,22 @@ export default class AppFormGroup extends Vue { ...@@ -115,6 +120,22 @@ export default class AppFormGroup extends Vue {
*/ */
@Prop() public caption?: string; @Prop() public caption?: string;
/**
* 是否为管理容器
*
* @type {string}
* @memberof AppFormGroup
*/
@Prop({ default: false }) public isManageContainer?: boolean;
/**
* 管理容器状态
*
* @type {string}
* @memberof AppFormGroup
*/
@Prop({ default: false }) public manageContainerStatus?: boolean;
/** /**
* 内置界面样式 * 内置界面样式
* *
...@@ -244,6 +265,16 @@ export default class AppFormGroup extends Vue { ...@@ -244,6 +265,16 @@ export default class AppFormGroup extends Vue {
public doUIAction($event: any, item: any): void { public doUIAction($event: any, item: any): void {
this.$emit('groupuiactionclick', { event: $event, item: item }); this.$emit('groupuiactionclick', { event: $event, item: item });
} }
/**
* 操作管理容器
*
* @param {*} $event
* @memberof AppFormGroup
*/
public doManageContainer(){
this.$emit('managecontainerclick');
}
} }
</script> </script>
<style lang='less'> <style lang='less'>
......
...@@ -44,6 +44,11 @@ export default class AppMpicker extends Vue { ...@@ -44,6 +44,11 @@ export default class AppMpicker extends Vue {
*/ */
@Prop() curvalue?: any; @Prop() curvalue?: any;
/**
* 值项
*/
@Prop() valueitem?: any;
/** /**
* 局部上下文导航参数 * 局部上下文导航参数
* *
...@@ -144,14 +149,34 @@ export default class AppMpicker extends Vue { ...@@ -144,14 +149,34 @@ export default class AppMpicker extends Vue {
this.value = []; this.value = [];
this.selectItems = []; this.selectItems = [];
if (newVal) { if (newVal) {
this.selectItems = this.parseValue(JSON.parse(newVal)); try {
this.selectItems.forEach((item: any) => { this.selectItems = this.parseValue(JSON.parse(newVal));
this.value.push(item[this.deKeyField]); this.selectItems.forEach((item: any) => {
let index = this.items.findIndex((i) => Object.is(i[this.deKeyField], item[this.deKeyField])); this.value.push(item[this.deKeyField]);
if (index < 0) { let index = this.items.findIndex((i) => Object.is(i[this.deKeyField], item[this.deKeyField]));
this.items.push({ [this.deMajorField]: item[this.deMajorField], [this.deKeyField]: item[this.deKeyField] }); if (index < 0) {
this.items.push({ [this.deMajorField]: item[this.deMajorField], [this.deKeyField]: item[this.deKeyField] });
}
});
} catch (error) {
if(error.name === 'SyntaxError'){
let srfkeys:any = newVal.split(',');
let srfmajortexts:any = null;
if(this.valueitem && this.activeData[this.valueitem]){
srfmajortexts = this.activeData[this.valueitem].split(',');
} }
}); if(srfkeys.length && srfkeys.length > 0 && srfmajortexts.length && srfmajortexts.length > 0 && srfkeys.length == srfmajortexts.length){
srfkeys.forEach((id: any, index: number) => {
this.value.push(id);
this.selectItems.push({[this.deKeyField]: id, [this.deMajorField]: srfmajortexts[index]});
let _index = this.items.findIndex((i) => Object.is(i[this.deKeyField],id));
if (_index < 0) {
this.items.push({[this.deKeyField]: id, [this.deMajorField]: srfmajortexts[index]});
}
});
}
}
}
} }
this.$forceUpdate(); this.$forceUpdate();
} }
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
</span> </span>
</el-col> </el-col>
<el-col :span="14"> <el-col :span="14">
<span>{{ item.label }}</span> <span>{{ item.fullName ? item.fullName:item.label }}</span>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<div class="bar"> <div class="bar">
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
<Drawer class-name="menu-drawer" width="60" :closable="true" :mask="false" placement="left" v-model="rightDrawerVisiable"> <Drawer class-name="menu-drawer" width="60" :closable="true" :mask="false" placement="left" v-model="rightDrawerVisiable">
<div class="menuItems"> <div class="menuItems">
<div @click="skipTo(item)" class="item" v-for="(item) in list" :key="item.id"> <div @click="skipTo(item)" class="item" v-for="(item) in list" :key="item.id">
<span class="title">{{item.label}}</span> <span class="title">{{ item.fullName ? item.fullName:item.label }}</span>
<span v-if="isStar(item.id)" class="star" @click.stop="outStar(item)"> <span v-if="isStar(item.id)" class="star" @click.stop="outStar(item)">
<Icon type="ios-star" /> <Icon type="ios-star" />
</span> </span>
......
<template>
<el-select size="small" class="filter-mode" placeholder="条件逻辑" clearable v-model="curVal" @change="onChange">
<el-option
v-for="mode in filterMode"
:key="mode.value"
:label="mode.en"
:value="mode.value"
>
</el-option>
</el-select>
</template>
<script lang="ts">
import { Vue, Component, Model } from "vue-property-decorator";
@Component({})
export default class FilterMode extends Vue {
/**
* 值属性
*
* @type {*}
* @memberof FilterMode
*/
@Model('change') readonly value: any;
get curVal() {
return this.value;
}
set curVal(val: any) {
const type: string = this.$util.typeOf(val);
val = Object.is(type, 'null') || Object.is(type, 'undefined') ? undefined : val;
this.$emit('change', val);
}
/**
* 过滤模式
*
* @type {*}
* @memberof FilterMode
*/
public filterMode: any[] = [
// { name: 'AND', value: '$and' },
// { name: 'OR', value: '$or' },
{ zh: '等于(=)', en: 'EQ', value: '$eq' },
{ zh: '', en: 'NE', value: '$ne' },
{ zh: '', en: 'GT', value: '$gt' },
{ zh: '', en: 'GE', value: '$gte' },
{ zh: '', en: 'LT', value: '$lt' },
{ zh: '', en: 'LE', value: '$lte' },
{ zh: '', en: 'IS_NULL', value: '$null' },
{ zh: '', en: 'IS_NOT_NULL', value: '$notNull' },
{ zh: '', en: 'IN', value: '$in' },
{ zh: '', en: 'NOTIN', value: '$notIn' },
{ zh: '', en: 'LIKE', value: '$like' },
{ zh: '', en: 'LIFTLIKE', value: '$startsWith' },
{ zh: '', en: 'RIGHTLIKE', value: '$endsWith' },
{ zh: '', en: 'EXISTS', value: '$exists' },
{ zh: '', en: 'NOTEXISTS', value: '$notExists' }
];
/**
* 值改变
*
* @memberof FilterMode
*/
public onChange() {
this.$emit('mode-change', this.value);
}
}
</script>
\ No newline at end of file
.filter-item {
display: flex;
// margin-top: 10px;
.fa-trash-o {
color: red;
}
.filter-item-group {
width: 100px;
margin-left: 5px;
}
.filter-item-field {
width: 200px;
margin-left: 5px;
}
.filter-item-mode {
width: 200px;
margin-left: 5px;
}
.filter-item-value {
margin-left: 5px;
flex-grow: 1;
}
}
.filter-tree {
.el-tree-node__content {
height: 40px;
.filter-tree-item {
display: flex;
>div {
margin-right: 10px;
}
>div:nth-last-child(1) {
margin-right: 0;
}
.filter-tree-action {
margin-left: 20px;
.ivu-btn {
margin-right: 5px;
}
}
}
}
}
\ No newline at end of file
<template>
<el-tree class="filter-tree" :data="treeItems" :props="defaultProps" :expand-on-click-node="false" default-expand-all>
<template slot-scope="{ node, data }">
<template v-if="Object.is(data.name, '$and') || Object.is(data.name, '$or')">
<div class="filter-tree-item">
<el-select size="small" v-model="data.name">
<el-option v-for="mode in relationModes" :key="mode.value" :label="mode.zh" :value="mode.value"></el-option>
</el-select>
<div class="filter-tree-action">
<i-button title="添加条件" @click="onAddItem(data)"><i class="fa fa-plus" aria-hidden="true"></i> 添加条件</i-button>
<i-button title="添加组" @click="onAddGroup(data)"><i class="fa fa-plus" aria-hidden="true"></i> 添加组</i-button>
</div>
</div>
</template>
<template v-else>
<div class="filter-tree-item">
<el-select size="small" class="filter-item-field" v-model="data.field" clearable placeholder="属性" @change="onFieldChange(data)">
<el-option
v-for="item in fields"
:key="item.prop"
:label="item.label"
:value="item.name">
</el-option>
</el-select>
<filter-mode class="filter-item-mode" v-model="data.mode"></filter-mode>
<div class="filter-item-value">
<i-input v-if="!data.field"></i-input>
<slot v-else :data="data"></slot>
</div>
<div class="filter-tree-action">
<i-button @click="onRemoveItem(node, data)" title="删除"><i class="fa fa-trash-o" aria-hidden="true"></i></i-button>
</div>
</div>
</template>
</template>
</el-tree>
</template>
<script lang="ts">
import {Vue, Component, Prop} from 'vue-property-decorator';
import FilterMode from './filter-mode.vue';
@Component({
components: {
FilterMode
}
})
export default class FilterTree extends Vue {
@Prop() datas: any;
@Prop() fields: any;
protected defaultProps: any = {
children: 'items',
label: 'name'
};
protected relationModes: any[] = [
{ zh: '并且', en: 'AND', value: '$and' },
{ zh: '或', en: 'OR', value: '$or' }
];
get treeItems() {
let root: any = {
name: '$and',
items: this.datas
};
if(this.datas.length == 0) {
this.onAddItem(root);
this.onAddItem(root);
}
return [root];
}
public onFieldChange(data: any) {
if(!data.mode) {
data.mode = '$eq';
}
}
public onAddItem(data: any) {
if(data && data.items) {
data.items.push({
field: null,
mode: null
});
}
}
public onAddGroup(data: any) {
if(data && data.items) {
data.items.push({
name: '$and',
items: []
})
}
}
public onRemoveItem(node: any, data: any) {
if(node && node.parent) {
let pData: any = node.parent.data;
if(pData.items.indexOf(data) >= 0) {
pData.items.splice(pData.items.indexOf(data), 1)
}
}
}
}
</script>
<style lang="less">
@import './filter-tree.less';
</style>
\ No newline at end of file
.ibiz-page-tag { .ibiz-page-tag {
position: relative; position: relative;
margin: 8px 0;
.left{ .left{
.el-tabs__header{ .el-tabs__header{
padding-right:120px; padding-right:120px;
...@@ -60,7 +61,8 @@ ...@@ -60,7 +61,8 @@
border-bottom:2px solid transparent !important; border-bottom:2px solid transparent !important;
} }
.el-tabs__header{ .el-tabs__header{
margin:0 0 1 0; margin:0;
border-bottom: none;
} }
} }
} }
......
...@@ -395,6 +395,9 @@ export default class MDViewEngine extends ViewEngine { ...@@ -395,6 +395,9 @@ export default class MDViewEngine extends ViewEngine {
if (this.getSearchForm() && this.view.isExpandSearchForm) { if (this.getSearchForm() && this.view.isExpandSearchForm) {
Object.assign(arg, this.getSearchForm().getData()); Object.assign(arg, this.getSearchForm().getData());
} }
if (this.view && this.view.searchbar) {
Object.assign(arg, this.view.searchbar.getData());
}
if (this.view && !this.view.isExpandSearchForm) { if (this.view && !this.view.isExpandSearchForm) {
Object.assign(arg, { query: this.view.query }); Object.assign(arg, { query: this.view.query });
} }
......
...@@ -169,4 +169,8 @@ export default { ...@@ -169,4 +169,8 @@ export default {
YouYuan: 'YouYuan', YouYuan: 'YouYuan',
}, },
}, },
appFormGroup: {
hide: 'hide',
showMore: 'show more',
},
}; };
\ No newline at end of file
...@@ -170,4 +170,8 @@ export default { ...@@ -170,4 +170,8 @@ export default {
YouYuan: '幼圆', YouYuan: '幼圆',
}, },
}, },
appFormGroup: {
hide: '隐藏字段',
showMore: '显示更多字段',
},
}; };
\ No newline at end of file
...@@ -46,6 +46,22 @@ export class FormDetailModel { ...@@ -46,6 +46,22 @@ export class FormDetailModel {
*/ */
public visible: boolean = true; public visible: boolean = true;
/**
* 成员是否显示(旧)
*
* @type {boolean}
* @memberof FormDetailModel
*/
public oldVisible: boolean = true;
/**
* 成员是否为受控内容
*
* @type {boolean}
* @memberof FormDetailModel
*/
public isControlledContent: boolean = false;
/** /**
* 成员是否显示标题 * 成员是否显示标题
* *
...@@ -53,6 +69,7 @@ export class FormDetailModel { ...@@ -53,6 +69,7 @@ export class FormDetailModel {
* @memberof FormDetailModel * @memberof FormDetailModel
*/ */
public isShowCaption: boolean = true; public isShowCaption: boolean = true;
/** /**
* Creates an instance of FormDetailModel. * Creates an instance of FormDetailModel.
...@@ -67,7 +84,9 @@ export class FormDetailModel { ...@@ -67,7 +84,9 @@ export class FormDetailModel {
this.form = opts.form ? opts.form : {}; this.form = opts.form ? opts.form : {};
this.name = !Object.is(opts.name, '') ? opts.name : ''; this.name = !Object.is(opts.name, '') ? opts.name : '';
this.visible = opts.visible ? true : false; this.visible = opts.visible ? true : false;
this.oldVisible = opts.visible ? true : false;
this.isShowCaption = opts.isShowCaption ? true : false; this.isShowCaption = opts.isShowCaption ? true : false;
this.isControlledContent = opts.isControlledContent ? true : false;
} }
/** /**
......
...@@ -16,6 +16,30 @@ export class FormGroupPanelModel extends FormDetailModel { ...@@ -16,6 +16,30 @@ export class FormGroupPanelModel extends FormDetailModel {
* @memberof FormGroupPanelModel * @memberof FormGroupPanelModel
*/ */
public uiActionGroup: any = {}; public uiActionGroup: any = {};
/**
* 受控内容组
*
* @type {*}
* @memberof FormGroupPanelModel
*/
public showMoreModeItems: any = [];
/**
* 是否为管理容器
*
* @type {*}
* @memberof FormGroupPanelModel
*/
public isManageContainer: boolean = false;
/**
* 管理容器状态 true显示 false隐藏
*
* @type {*}
* @memberof FormGroupPanelModel
*/
public manageContainerStatus: boolean = true;
/** /**
* Creates an instance of FormGroupPanelModel. * Creates an instance of FormGroupPanelModel.
...@@ -27,5 +51,17 @@ export class FormGroupPanelModel extends FormDetailModel { ...@@ -27,5 +51,17 @@ export class FormGroupPanelModel extends FormDetailModel {
constructor(opts: any = {}) { constructor(opts: any = {}) {
super(opts); super(opts);
Object.assign(this.uiActionGroup, opts.uiActionGroup); Object.assign(this.uiActionGroup, opts.uiActionGroup);
this.showMoreModeItems = opts.showMoreModeItems;
this.isManageContainer = opts.isManageContainer ? true : false;
}
/**
* 设置管理容器状态
*
* @param {boolean} state
* @memberof FormGroupPanelModel
*/
public setManageContainerStatus(state: boolean): void {
this.manageContainerStatus = state;
} }
} }
\ No newline at end of file
...@@ -543,8 +543,8 @@ export default class SDFileEditViewBase extends Vue { ...@@ -543,8 +543,8 @@ export default class SDFileEditViewBase extends Vue {
* *
* @memberof SDFileEditViewBase * @memberof SDFileEditViewBase
*/ */
public initNavDataWithRoute(data:any = null, isNew:boolean = false){ public initNavDataWithRoute(data:any = null, isNew:boolean = false, isAlways:boolean = false){
if(this.viewDefaultUsage && Object.is(this.navModel,"route")){ if( isAlways || (this.viewDefaultUsage && Object.is(this.navModel,"route")) ){
this.navDataService.addNavData({id:'sdfile-edit-view',tag:this.viewtag,srfkey:isNew ? null : this.context.sdfile,title:this.$t(this.model.srfTitle),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath}); this.navDataService.addNavData({id:'sdfile-edit-view',tag:this.viewtag,srfkey:isNew ? null : this.context.sdfile,title:this.$t(this.model.srfTitle),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath});
} }
} }
...@@ -554,8 +554,8 @@ export default class SDFileEditViewBase extends Vue { ...@@ -554,8 +554,8 @@ export default class SDFileEditViewBase extends Vue {
* *
* @memberof SDFileEditViewBase * @memberof SDFileEditViewBase
*/ */
public initNavDataWithTab(data:any = null,isOnlyAdd:boolean = true){ public initNavDataWithTab(data:any = null,isOnlyAdd:boolean = true, isAlways:boolean = false){
if(this.viewDefaultUsage && !Object.is(this.navModel,"route")){ if( isAlways || (this.viewDefaultUsage && !Object.is(this.navModel,"route")) ){
this.navDataService.addNavDataByOnly({id:'sdfile-edit-view',tag:this.viewtag,srfkey:this.context.sdfile,title:this.$t(this.model.srfTitle),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath},isOnlyAdd); this.navDataService.addNavDataByOnly({id:'sdfile-edit-view',tag:this.viewtag,srfkey:this.context.sdfile,title:this.$t(this.model.srfTitle),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath},isOnlyAdd);
} }
} }
......
...@@ -577,8 +577,8 @@ export default class SDFileGridViewBase extends Vue { ...@@ -577,8 +577,8 @@ export default class SDFileGridViewBase extends Vue {
* *
* @memberof SDFileGridViewBase * @memberof SDFileGridViewBase
*/ */
public initNavDataWithRoute(data:any = null, isNew:boolean = false){ public initNavDataWithRoute(data:any = null, isNew:boolean = false, isAlways:boolean = false){
if(this.viewDefaultUsage && Object.is(this.navModel,"route")){ if( isAlways || (this.viewDefaultUsage && Object.is(this.navModel,"route")) ){
this.navDataService.addNavData({id:'sdfile-grid-view',tag:this.viewtag,srfkey:isNew ? null : this.context.sdfile,title:this.$t(this.model.srfTitle),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath}); this.navDataService.addNavData({id:'sdfile-grid-view',tag:this.viewtag,srfkey:isNew ? null : this.context.sdfile,title:this.$t(this.model.srfTitle),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath});
} }
} }
...@@ -588,8 +588,8 @@ export default class SDFileGridViewBase extends Vue { ...@@ -588,8 +588,8 @@ export default class SDFileGridViewBase extends Vue {
* *
* @memberof SDFileGridViewBase * @memberof SDFileGridViewBase
*/ */
public initNavDataWithTab(data:any = null,isOnlyAdd:boolean = true){ public initNavDataWithTab(data:any = null,isOnlyAdd:boolean = true, isAlways:boolean = false){
if(this.viewDefaultUsage && !Object.is(this.navModel,"route")){ if( isAlways || (this.viewDefaultUsage && !Object.is(this.navModel,"route")) ){
this.navDataService.addNavDataByOnly({id:'sdfile-grid-view',tag:this.viewtag,srfkey:this.context.sdfile,title:this.$t(this.model.srfTitle),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath},isOnlyAdd); this.navDataService.addNavDataByOnly({id:'sdfile-grid-view',tag:this.viewtag,srfkey:this.context.sdfile,title:this.$t(this.model.srfTitle),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath},isOnlyAdd);
} }
} }
...@@ -1248,6 +1248,13 @@ export default class SDFileGridViewBase extends Vue { ...@@ -1248,6 +1248,13 @@ export default class SDFileGridViewBase extends Vue {
* @memberof SDFileGridView * @memberof SDFileGridView
*/ */
public opendata(args: any[],fullargs?:any[],params?: any, $event?: any, xData?: any) { 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 localContext:any = null;
let localViewParam:any =null; let localViewParam:any =null;
const data: any = {}; const data: any = {};
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<sider :width="collapseChange ? 64 : 200" hide-trigger v-model="collapseChange"> <sider :width="collapseChange ? 64 : 200" hide-trigger v-model="collapseChange">
<div class="sider-top"> <div class="sider-top">
<div class="page-logo"> <div class="page-logo">
<span class="menuicon" @click="contextMenuDragVisiable=!contextMenuDragVisiable"><Icon type="md-menu" /></span> <span class="menuicon" v-if="isEnableAppSwitch" @click="contextMenuDragVisiable=!contextMenuDragVisiable"><Icon type="md-menu" /></span>
<span v-show="!collapseChange" style="overflow-x: hidden;text-overflow: ellipsis;white-space: nowrap;display: block;text-align: center;font-weight: 300;font-size: 20px;">{{$t(model.srfCaption)}}</span> <span v-show="!collapseChange" style="overflow-x: hidden;text-overflow: ellipsis;white-space: nowrap;display: block;text-align: center;font-weight: 300;font-size: 20px;">{{$t(model.srfCaption)}}</span>
</div> </div>
</div> </div>
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
ref='appmenu' ref='appmenu'
@closeview="closeView($event)"> @closeview="closeView($event)">
</view_appmenu> </view_appmenu>
<context-menu-drag :contextMenuDragVisiable="contextMenuDragVisiable"></context-menu-drag> <context-menu-drag v-if="isEnableAppSwitch" :contextMenuDragVisiable="contextMenuDragVisiable"></context-menu-drag>
</sider> </sider>
<layout> <layout>
<header class="index_header"> <header class="index_header">
...@@ -408,8 +408,8 @@ export default class SDIndexViewBase extends Vue { ...@@ -408,8 +408,8 @@ export default class SDIndexViewBase extends Vue {
* *
* @memberof SDIndexViewBase * @memberof SDIndexViewBase
*/ */
public initNavDataWithRoute(data:any = null, isNew:boolean = false){ public initNavDataWithRoute(data:any = null, isNew:boolean = false, isAlways:boolean = false){
if(this.viewDefaultUsage && Object.is(this.navModel,"route")){ if( isAlways || (this.viewDefaultUsage && Object.is(this.navModel,"route")) ){
this.navDataService.addNavData({id:'sdindex-view',tag:this.viewtag,srfkey:isNew ? null : null,title:this.$t(this.model.srfTitle),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath}); this.navDataService.addNavData({id:'sdindex-view',tag:this.viewtag,srfkey:isNew ? null : null,title:this.$t(this.model.srfTitle),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath});
} }
} }
...@@ -419,8 +419,8 @@ export default class SDIndexViewBase extends Vue { ...@@ -419,8 +419,8 @@ export default class SDIndexViewBase extends Vue {
* *
* @memberof SDIndexViewBase * @memberof SDIndexViewBase
*/ */
public initNavDataWithTab(data:any = null,isOnlyAdd:boolean = true){ public initNavDataWithTab(data:any = null,isOnlyAdd:boolean = true, isAlways:boolean = false){
if(this.viewDefaultUsage && !Object.is(this.navModel,"route")){ if( isAlways || (this.viewDefaultUsage && !Object.is(this.navModel,"route")) ){
this.navDataService.addNavDataByOnly({id:'sdindex-view',tag:this.viewtag,srfkey:null,title:this.$t(this.model.srfTitle),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath},isOnlyAdd); this.navDataService.addNavDataByOnly({id:'sdindex-view',tag:this.viewtag,srfkey:null,title:this.$t(this.model.srfTitle),data:data,context:this.context,viewparams:this.viewparams,path:this.$route.fullPath},isOnlyAdd);
} }
} }
...@@ -542,6 +542,14 @@ export default class SDIndexViewBase extends Vue { ...@@ -542,6 +542,14 @@ export default class SDIndexViewBase extends Vue {
*/ */
public contextMenuDragVisiable: boolean = false; public contextMenuDragVisiable: boolean = false;
/**
* 是否支持应用切换
*
* @type {boolean}
* @memberof SDIndexViewBase
*/
public isEnableAppSwitch: boolean = false;
/** /**
* 初始化之前 * 初始化之前
* *
......
...@@ -91,6 +91,7 @@ ...@@ -91,6 +91,7 @@
display: flex; display: flex;
align-items: center; align-items: center;
height: 100%; height: 100%;
justify-content: center;
>.menuicon{ >.menuicon{
display: block; display: block;
text-align: center; text-align: center;
......
import { Subject } from 'rxjs';
export interface Message {
/**
* 名称(通常是应用实体名称)
*
* @memberof Message
*/
name: string;
/**
* 行为(操作数据行为)
*
* @memberof Message
*/
action: string;
/**
* 数据(操作数据)
*
* @memberof Message
*/
data: any;
}
/**
* 应用中心服务类
*
* @export
* @class AppCenterService
*/
export default class AppCenterService {
/**
* Vue 状态管理器
*
* @private
* @type {*}
* @memberof AppCenterService
*/
private static store: any;
/**
* 应用数据状态管理对象
*
* @private
* @type {Subject<any>}
* @memberof AppCenterService
*/
private static subject:Subject<any> = new Subject<any>();
/**
* 单例变量声明
*
* @private
* @static
* @type {AppCenterService}
* @memberof AppCenterService
*/
private static appCenterService: AppCenterService;
/**
* 初始化实例
*
* @memberof AppCenterService
*/
constructor() {}
/**
* 获取 AppCenterService 单例对象
*
* @static
* @returns {AppCenterService}
* @memberof AppCenterService
*/
public static getInstance(store: any): AppCenterService {
if (!AppCenterService.appCenterService) {
AppCenterService.appCenterService = new AppCenterService();
}
this.store = store;
return this.appCenterService;
}
/**
* 通知消息
*
* @static
* @memberof AppCenterService
*/
public static notifyMessage(message:Message){
this.subject.next(message);
}
/**
* 获取消息中心
*
* @static
* @memberof AppCenterService
*/
public static getMessageCenter():Subject<any>{
return this.subject;
}
}
\ No newline at end of file
...@@ -4,5 +4,5 @@ Tip: If the failing expression is known to be legally refer to something that's ...@@ -4,5 +4,5 @@ Tip: If the failing expression is known to be legally refer to something that's
---- ----
FTL stack trace ("~" means nesting-related): FTL stack trace ("~" means nesting-related):
- Failed at: ${item.getKeyPSAppDEField().getCodeNa... [in template "TEMPLCODE_zh_CN" at line 467, column 26] - Failed at: ${item.getKeyPSAppDEField().getCodeNa... [in template "TEMPLCODE_zh_CN" at line 466, column 26]
---- ----
\ No newline at end of file
...@@ -44,9 +44,11 @@ export const getAuthMenu = (state: any) => (menu:any) =>{ ...@@ -44,9 +44,11 @@ export const getAuthMenu = (state: any) => (menu:any) =>{
resourceIndex= state.resourceData.findIndex((resourcetag: any, objIndex: any, objs: any) => { resourceIndex= state.resourceData.findIndex((resourcetag: any, objIndex: any, objs: any) => {
return Object.is(menu.resourcetag, resourcetag); return Object.is(menu.resourcetag, resourcetag);
}) })
menuIndex= state.menuData.findIndex((menutag: any, objIndex: any, objs: any) => {
return Object.is(menu.authtag, menutag);
})
return (resourceIndex !== -1 || menuIndex !== -1)?true:false;
}else{
return true;
} }
menuIndex= state.menuData.findIndex((menutag: any, objIndex: any, objs: any) => {
return Object.is(menu.authtag, menutag);
})
return (resourceIndex !== -1 || menuIndex !== -1)?true:false;
} }
\ No newline at end of file
...@@ -63,7 +63,7 @@ export class ViewTool { ...@@ -63,7 +63,7 @@ export class ViewTool {
public static buildUpRoutePath(route: Route, viewParam: any = {}, deResParameters: any[], parameters: any[], args: any[], data: any): string { public static buildUpRoutePath(route: Route, viewParam: any = {}, deResParameters: any[], parameters: any[], args: any[], data: any): string {
const indexRoutePath = this.getIndexRoutePath(route); const indexRoutePath = this.getIndexRoutePath(route);
const deResRoutePath = this.getDeResRoutePath(viewParam, deResParameters, args); const deResRoutePath = this.getDeResRoutePath(viewParam, deResParameters, args);
const deRoutePath = this.getActiveRoutePath(parameters, args, data); const deRoutePath = this.getActiveRoutePath(parameters, args, data,viewParam);
return `${indexRoutePath}${deResRoutePath}${deRoutePath}`; return `${indexRoutePath}${deResRoutePath}${deRoutePath}`;
} }
...@@ -123,7 +123,7 @@ export class ViewTool { ...@@ -123,7 +123,7 @@ export class ViewTool {
* @returns {string} * @returns {string}
* @memberof ViewTool * @memberof ViewTool
*/ */
public static getActiveRoutePath(parameters: any[], args: any[], data: any): string { public static getActiveRoutePath(parameters: any[], args: any[], data: any,viewParam: any = {}): string {
let routePath: string = ''; let routePath: string = '';
// 不存在应用实体 // 不存在应用实体
if(parameters && parameters.length >0){ if(parameters && parameters.length >0){
...@@ -137,8 +137,7 @@ export class ViewTool { ...@@ -137,8 +137,7 @@ export class ViewTool {
let [arg] = args; let [arg] = args;
arg = arg ? arg : {}; arg = arg ? arg : {};
const [{ pathName: _pathName, parameterName: _parameterName }, { pathName: _pathName2, parameterName: _parameterName2 }] = parameters; const [{ pathName: _pathName, parameterName: _parameterName }, { pathName: _pathName2, parameterName: _parameterName2 }] = parameters;
const _value: any = arg[_parameterName] && !Object.is(arg[_parameterName], '') ? const _value: any = arg[_parameterName] || viewParam[_parameterName] || null;
arg[_parameterName] : null;
routePath = `/${_pathName}/${_value}/${_pathName2}`; routePath = `/${_pathName}/${_value}/${_pathName2}`;
if (Object.keys(data).length > 0) { if (Object.keys(data).length > 0) {
routePath = `${routePath}?${qs.stringify(data, { delimiter: ';' })}`; routePath = `${routePath}?${qs.stringify(data, { delimiter: ';' })}`;
......
...@@ -124,6 +124,7 @@ import { Subject, Subscription } from 'rxjs'; ...@@ -124,6 +124,7 @@ import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control'; import { ControlInterface } from '@/interface/control';
import { UIActionTool,Util } from '@/utils'; import { UIActionTool,Util } from '@/utils';
import NavDataService from '@/service/app/navdata-service'; import NavDataService from '@/service/app/navdata-service';
import AppCenterService from "@service/app/app-center-service";
import SDIndexViewService from './sdindex-view-appmenu-service'; import SDIndexViewService from './sdindex-view-appmenu-service';
import SDIndexViewModel from './sdindex-view-appmenu-model'; import SDIndexViewModel from './sdindex-view-appmenu-model';
......
...@@ -28,6 +28,7 @@ import { Subject, Subscription } from 'rxjs'; ...@@ -28,6 +28,7 @@ import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control'; import { ControlInterface } from '@/interface/control';
import { UIActionTool,Util } from '@/utils'; import { UIActionTool,Util } from '@/utils';
import NavDataService from '@/service/app/navdata-service'; import NavDataService from '@/service/app/navdata-service';
import AppCenterService from "@service/app/app-center-service";
import SDFileService from '@/service/sdfile/sdfile-service'; import SDFileService from '@/service/sdfile/sdfile-service';
import DefaultService from './default-searchform-service'; import DefaultService from './default-searchform-service';
......
...@@ -80,6 +80,8 @@ export default class DefaultService extends ControlService { ...@@ -80,6 +80,8 @@ export default class DefaultService 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[]> {
data.page = data.page ? data.page : 0;
data.size = data.size ? data.size : 1000;
return Promise.reject([]) return Promise.reject([])
} }
......
...@@ -4,5 +4,5 @@ Tip: If the failing expression is known to be legally refer to something that's ...@@ -4,5 +4,5 @@ Tip: If the failing expression is known to be legally refer to something that's
---- ----
FTL stack trace ("~" means nesting-related): FTL stack trace ("~" means nesting-related):
- Failed at: ${appde.getKeyPSAppDEField().getCodeN... [in template "TEMPLCODE_zh_CN" at line 1038, column 18] - Failed at: ${appde.getKeyPSAppDEField().getCodeN... [in template "TEMPLCODE_zh_CN" at line 1057, column 18]
---- ----
\ No newline at end of file
...@@ -62,17 +62,17 @@ export default class MainModel { ...@@ -62,17 +62,17 @@ export default class MainModel {
}, },
{ {
name: 'filepath', name: 'filepath',
prop: 'filepath', prop: 'file_path',
dataType: 'TEXT', dataType: 'TEXT',
}, },
{ {
name: 'filesize', name: 'filesize',
prop: 'filesize', prop: 'file_size',
dataType: 'INT', dataType: 'INT',
}, },
{ {
name: 'fileext', name: 'fileext',
prop: 'fileext', prop: 'extension',
dataType: 'TEXT', dataType: 'TEXT',
}, },
{ {
...@@ -82,17 +82,17 @@ export default class MainModel { ...@@ -82,17 +82,17 @@ export default class MainModel {
}, },
{ {
name: 'digestcode', name: 'digestcode',
prop: 'digestcode', prop: 'digest_code',
dataType: 'TEXT', dataType: 'TEXT',
}, },
{ {
name: 'ownerid', name: 'ownerid',
prop: 'ownerid', prop: 'owner_id',
dataType: 'TEXT', dataType: 'TEXT',
}, },
{ {
name: 'ownertype', name: 'ownertype',
prop: 'ownertype', prop: 'owner_type',
dataType: 'TEXT', dataType: 'TEXT',
}, },
{ {
......
...@@ -4,5 +4,5 @@ Tip: If the failing expression is known to be legally refer to something that's ...@@ -4,5 +4,5 @@ Tip: If the failing expression is known to be legally refer to something that's
---- ----
FTL stack trace ("~" means nesting-related): FTL stack trace ("~" means nesting-related):
- Failed at: ${appde.getKeyPSAppDEField().getCodeN... [in template "TEMPLCODE_zh_CN" at line 350, column 14] - Failed at: ${appde.getKeyPSAppDEField().getCodeN... [in template "TEMPLCODE_zh_CN" at line 352, column 14]
---- ----
\ No newline at end of file
...@@ -4,5 +4,5 @@ Tip: If the failing expression is known to be legally refer to something that's ...@@ -4,5 +4,5 @@ Tip: If the failing expression is known to be legally refer to something that's
---- ----
FTL stack trace ("~" means nesting-related): FTL stack trace ("~" means nesting-related):
- Failed at: ${ctrl.getPSAppDataEntity().getMajorP... [in template "TEMPLCODE_zh_CN" at line 886, column 39] - Failed at: ${ctrl.getPSAppDataEntity().getMajorP... [in template "TEMPLCODE_zh_CN" at line 903, column 39]
---- ----
\ No newline at end of file
...@@ -28,12 +28,12 @@ export default class MainModel { ...@@ -28,12 +28,12 @@ export default class MainModel {
return [ return [
{ {
name: 'fileext', name: 'fileext',
prop: 'fileext', prop: 'extension',
dataType: 'TEXT', dataType: 'TEXT',
}, },
{ {
name: 'filepath', name: 'filepath',
prop: 'filepath', prop: 'file_path',
dataType: 'TEXT', dataType: 'TEXT',
}, },
{ {
...@@ -48,7 +48,7 @@ export default class MainModel { ...@@ -48,7 +48,7 @@ export default class MainModel {
}, },
{ {
name: 'ownerid', name: 'ownerid',
prop: 'ownerid', prop: 'owner_id',
dataType: 'TEXT', dataType: 'TEXT',
}, },
{ {
...@@ -73,7 +73,7 @@ export default class MainModel { ...@@ -73,7 +73,7 @@ export default class MainModel {
}, },
{ {
name: 'filesize', name: 'filesize',
prop: 'filesize', prop: 'file_size',
dataType: 'INT', dataType: 'INT',
}, },
{ {
...@@ -83,7 +83,7 @@ export default class MainModel { ...@@ -83,7 +83,7 @@ export default class MainModel {
}, },
{ {
name: 'ownertype', name: 'ownertype',
prop: 'ownertype', prop: 'owner_type',
dataType: 'TEXT', dataType: 'TEXT',
}, },
{ {
......
...@@ -4,5 +4,5 @@ Tip: If the failing expression is known to be legally refer to something that's ...@@ -4,5 +4,5 @@ Tip: If the failing expression is known to be legally refer to something that's
---- ----
FTL stack trace ("~" means nesting-related): FTL stack trace ("~" means nesting-related):
- Failed at: ${appde.getKeyPSAppDEField().getCodeN... [in template "TEMPLCODE_zh_CN" at line 357, column 35] - Failed at: ${appde.getKeyPSAppDEField().getCodeN... [in template "TEMPLCODE_zh_CN" at line 359, column 35]
---- ----
\ No newline at end of file
...@@ -19,6 +19,7 @@ import java.util.List; ...@@ -19,6 +19,7 @@ import java.util.List;
@EnableTransactionManagement @EnableTransactionManagement
@EnableFeignClients(basePackages = {"cn.ibizlab" }) @EnableFeignClients(basePackages = {"cn.ibizlab" })
@SpringBootApplication(exclude = { @SpringBootApplication(exclude = {
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration.class,
}) })
@ComponentScan(basePackages = {"cn.ibizlab"} @ComponentScan(basePackages = {"cn.ibizlab"}
// ,excludeFilters={ // ,excludeFilters={
......
...@@ -23,142 +23,203 @@ import lombok.*; ...@@ -23,142 +23,203 @@ import lombok.*;
import org.springframework.data.annotation.Transient; import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.springframework.data.annotation.Id; import com.baomidou.mybatisplus.annotation.*;
import org.springframework.data.mongodb.core.mapping.Document; import cn.ibizlab.util.domain.EntityMP;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.data.mongodb.core.mapping.FieldType;
import cn.ibizlab.util.domain.EntityMongo;
/** /**
* 大数据 [文件] 对象 * 实体[文件]
*/ */
@Data @Getter
@Document(collection = "sdfile") @Setter
public class SDFile extends EntityMongo implements Serializable { @NoArgsConstructor
@JsonIgnoreProperties(value = "handler")
@TableName(value = "IBZFILE",resultMap = "SDFileResultMap")
public class SDFile extends EntityMP implements Serializable {
private static final long serialVersionUID = 1L;
/** /**
* 标识 * 标识
*/ */
@Id()
@DEField(name = "fileid" , isKeyField=true) @DEField(name = "fileid" , isKeyField=true)
@TableId(value= "fileid",type=IdType.ASSIGN_UUID)
@JSONField(name = "id") @JSONField(name = "id")
@JsonProperty("id") @JsonProperty("id")
private String id; private String id;
/** /**
* 名称 * 名称
*/ */
@DEField(name = "filename") @DEField(name = "filename")
@TableField(value = "filename")
@JSONField(name = "name") @JSONField(name = "name")
@JsonProperty("name") @JsonProperty("name")
@Field(name = "filename")
private String name; private String name;
/** /**
* 路径 * 路径
*/ */
@JSONField(name = "filepath") @TableField(value = "filepath")
@JsonProperty("filepath") @JSONField(name = "file_path")
@Field(name = "filepath") @JsonProperty("file_path")
private String filepath; private String filePath;
/** /**
* 特定目录 * 特定目录
*/ */
@TableField(value = "folder")
@JSONField(name = "folder") @JSONField(name = "folder")
@JsonProperty("folder") @JsonProperty("folder")
@Field(name = "folder")
private String folder; private String folder;
/** /**
* 文件大小 * 文件大小
*/ */
@JSONField(name = "filesize") @TableField(value = "filesize")
@JsonProperty("filesize") @JSONField(name = "file_size")
@Field(name = "filesize") @JsonProperty("file_size")
private Integer filesize; private Integer fileSize;
/** /**
* 扩展名 * 扩展名
*/ */
@JSONField(name = "fileext") @DEField(name = "fileext")
@JsonProperty("fileext") @TableField(value = "fileext")
@Field(name = "fileext") @JSONField(name = "extension")
private String fileext; @JsonProperty("extension")
private String extension;
/** /**
* 所属类型 * 所属类型
*/ */
@JSONField(name = "ownertype") @TableField(value = "ownertype")
@JsonProperty("ownertype") @JSONField(name = "owner_type")
@Field(name = "ownertype") @JsonProperty("owner_type")
private String ownertype; private String ownerType;
/** /**
* 所属主体 * 所属主体
*/ */
@JSONField(name = "ownerid") @TableField(value = "ownerid")
@JsonProperty("ownerid") @JSONField(name = "owner_id")
@Field(name = "ownerid") @JsonProperty("owner_id")
private String ownerid; private String ownerId;
/** /**
* 备注 * 备注
*/ */
@TableField(value = "memo")
@JSONField(name = "memo") @JSONField(name = "memo")
@JsonProperty("memo") @JsonProperty("memo")
@Field(name = "memo")
private String memo; private String memo;
/** /**
* 签名 * 签名
*/ */
@JSONField(name = "digestcode") @TableField(value = "digestcode")
@JsonProperty("digestcode") @JSONField(name = "digest_code")
@Field(name = "digestcode") @JsonProperty("digest_code")
private String digestcode; private String digestCode;
/** /**
* 创建人 * 创建人
*/ */
@DEField(preType = DEPredefinedFieldType.CREATEMAN) @DEField(preType = DEPredefinedFieldType.CREATEMAN)
@TableField(value = "createman" , fill = FieldFill.INSERT)
@JSONField(name = "createman") @JSONField(name = "createman")
@JsonProperty("createman") @JsonProperty("createman")
@Field(name = "createman")
private String createman; private String createman;
/** /**
* 创建日期 * 创建日期
*/ */
@DEField(preType = DEPredefinedFieldType.CREATEDATE) @DEField(preType = DEPredefinedFieldType.CREATEDATE)
@TableField(value = "createdate" , fill = FieldFill.INSERT)
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8") @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
@JSONField(name = "createdate" , format="yyyy-MM-dd HH:mm:ss") @JSONField(name = "createdate" , format="yyyy-MM-dd HH:mm:ss")
@JsonProperty("createdate") @JsonProperty("createdate")
@Field(name = "createdate")
private Timestamp createdate; private Timestamp createdate;
/** /**
* 更新人 * 更新人
*/ */
@DEField(preType = DEPredefinedFieldType.UPDATEMAN) @DEField(preType = DEPredefinedFieldType.UPDATEMAN)
@TableField(value = "updateman")
@JSONField(name = "updateman") @JSONField(name = "updateman")
@JsonProperty("updateman") @JsonProperty("updateman")
@Field(name = "updateman")
private String updateman; private String updateman;
/** /**
* 更新时间 * 更新时间
*/ */
@DEField(preType = DEPredefinedFieldType.UPDATEDATE) @DEField(preType = DEPredefinedFieldType.UPDATEDATE)
@TableField(value = "updatedate")
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8") @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
@JSONField(name = "updatedate" , format="yyyy-MM-dd HH:mm:ss") @JSONField(name = "updatedate" , format="yyyy-MM-dd HH:mm:ss")
@JsonProperty("updatedate") @JsonProperty("updatedate")
@Field(name = "updatedate")
private Timestamp updatedate; private Timestamp updatedate;
/**
* 设置 [名称]
*/
public void setName(String name){
this.name = name ;
this.modify("filename",name);
}
/**
* 设置 [路径]
*/
public void setFilePath(String filePath){
this.filePath = filePath ;
this.modify("filepath",filePath);
}
/**
* 设置 [特定目录]
*/
public void setFolder(String folder){
this.folder = folder ;
this.modify("folder",folder);
}
/**
* 设置 [文件大小]
*/
public void setFileSize(Integer fileSize){
this.fileSize = fileSize ;
this.modify("filesize",fileSize);
}
/**
* 设置 [扩展名]
*/
public void setExtension(String extension){
this.extension = extension ;
this.modify("fileext",extension);
}
/**
* 设置 [所属类型]
*/
public void setOwnerType(String ownerType){
this.ownerType = ownerType ;
this.modify("ownertype",ownerType);
}
/**
* 设置 [所属主体]
*/
public void setOwnerId(String ownerId){
this.ownerId = ownerId ;
this.modify("ownerid",ownerId);
}
/**
* 设置 [备注]
*/
public void setMemo(String memo){
this.memo = memo ;
this.modify("memo",memo);
}
/**
* 设置 [签名]
*/
public void setDigestCode(String digestCode){
this.digestCode = digestCode ;
this.modify("digestcode",digestCode);
}
} }
......
...@@ -17,24 +17,21 @@ import org.springframework.util.ObjectUtils; ...@@ -17,24 +17,21 @@ import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import cn.ibizlab.util.filter.QueryBuildContext; import cn.ibizlab.util.filter.QueryWrapperContext;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.ibizlab.core.disk.domain.SDFile; import cn.ibizlab.core.disk.domain.SDFile;
import java.util.regex.Pattern;
import com.mongodb.BasicDBObject;
/** /**
* NoSQL数据实体[SDFile] 查询条件对象 * 关系型数据实体[SDFile] 查询条件对象
*/ */
@Slf4j @Slf4j
@Data @Data
public class SDFileSearchContext extends QueryBuildContext { public class SDFileSearchContext extends QueryWrapperContext<SDFile> {
private String n_filename_like;//[名称] private String n_filename_like;//[名称]
public void setN_filename_like(String n_filename_like) { public void setN_filename_like(String n_filename_like) {
this.n_filename_like = n_filename_like; this.n_filename_like = n_filename_like;
if(!ObjectUtils.isEmpty(this.n_filename_like)){ if(!ObjectUtils.isEmpty(this.n_filename_like)){
Pattern pattern = Pattern.compile("^.*" + n_filename_like + ".*$", Pattern.CASE_INSENSITIVE); this.getSearchCond().like("filename", n_filename_like);
this.getSearchCond().and("filename").regex(pattern);
} }
} }
...@@ -45,11 +42,13 @@ public class SDFileSearchContext extends QueryBuildContext { ...@@ -45,11 +42,13 @@ public class SDFileSearchContext extends QueryBuildContext {
{ {
this.query=query; this.query=query;
if(!StringUtils.isEmpty(query)){ if(!StringUtils.isEmpty(query)){
Pattern pattern = Pattern.compile("^.*" + query + ".*$", Pattern.CASE_INSENSITIVE); this.getSearchCond().and( wrapper ->
this.getSearchCond().or(new BasicDBObject("filename",pattern)); wrapper.like("filename", query)
);
} }
} }
} }
package cn.ibizlab.core.disk.mapper;
import java.util.List;
import org.apache.ibatis.annotations.*;
import java.util.Map;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import java.util.HashMap;
import org.apache.ibatis.annotations.Select;
import cn.ibizlab.core.disk.domain.SDFile;
import cn.ibizlab.core.disk.filter.SDFileSearchContext;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import java.io.Serializable;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.alibaba.fastjson.JSONObject;
public interface SDFileMapper extends BaseMapper<SDFile>{
Page<SDFile> searchDefault(IPage page, @Param("srf") SDFileSearchContext context, @Param("ew") Wrapper<SDFile> wrapper) ;
@Override
SDFile selectById(Serializable id);
@Override
int insert(SDFile entity);
@Override
int updateById(@Param(Constants.ENTITY) SDFile entity);
@Override
int update(@Param(Constants.ENTITY) SDFile entity, @Param("ew") Wrapper<SDFile> updateWrapper);
@Override
int deleteById(Serializable id);
/**
* 自定义查询SQL
* @param sql
* @return
*/
@Select("${sql}")
List<JSONObject> selectBySQL(@Param("sql") String sql, @Param("et")Map param);
/**
* 自定义更新SQL
* @param sql
* @return
*/
@Update("${sql}")
boolean updateBySQL(@Param("sql") String sql, @Param("et")Map param);
/**
* 自定义插入SQL
* @param sql
* @return
*/
@Insert("${sql}")
boolean insertBySQL(@Param("sql") String sql, @Param("et")Map param);
/**
* 自定义删除SQL
* @param sql
* @return
*/
@Delete("${sql}")
boolean deleteBySQL(@Param("sql") String sql, @Param("et")Map param);
}
...@@ -18,10 +18,12 @@ import cn.ibizlab.core.disk.domain.SDFile; ...@@ -18,10 +18,12 @@ import cn.ibizlab.core.disk.domain.SDFile;
import cn.ibizlab.core.disk.filter.SDFileSearchContext; import cn.ibizlab.core.disk.filter.SDFileSearchContext;
import com.baomidou.mybatisplus.extension.service.IService;
/** /**
* 实体[SDFile] 服务对象接口 * 实体[SDFile] 服务对象接口
*/ */
public interface ISDFileService{ public interface ISDFileService extends IService<SDFile>{
boolean update(SDFile et) ; boolean update(SDFile et) ;
void updateBatch(List<SDFile> list) ; void updateBatch(List<SDFile> list) ;
...@@ -35,10 +37,25 @@ public interface ISDFileService{ ...@@ -35,10 +37,25 @@ public interface ISDFileService{
boolean save(SDFile et) ; boolean save(SDFile et) ;
void saveBatch(List<SDFile> list) ; void saveBatch(List<SDFile> list) ;
Page<SDFile> searchDefault(SDFileSearchContext context) ; Page<SDFile> searchDefault(SDFileSearchContext context) ;
/**
*自定义查询SQL
* @param sql select * from table where id =#{et.param}
* @param param 参数列表 param.put("param","1");
* @return select * from table where id = '1'
*/
List<JSONObject> select(String sql, Map param);
/**
*自定义SQL
* @param sql update table set name ='test' where id =#{et.param}
* @param param 参数列表 param.put("param","1");
* @return update table set name ='test' where id = '1'
*/
boolean execute(String sql, Map param);
List<SDFile> getSdfileByIds(List<String> ids) ; List<SDFile> getSdfileByIds(List<String> ids) ;
List<SDFile> getSdfileByEntities(List<SDFile> entities) ; List<SDFile> getSdfileByEntities(List<SDFile> entities) ;
}
}
...@@ -30,53 +30,55 @@ import cn.ibizlab.core.disk.service.ISDFileService; ...@@ -30,53 +30,55 @@ import cn.ibizlab.core.disk.service.ISDFileService;
import cn.ibizlab.util.helper.CachedBeanCopier; import cn.ibizlab.util.helper.CachedBeanCopier;
import cn.ibizlab.core.disk.repository.SDFileRepository; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.data.mongodb.core.MongoTemplate; import cn.ibizlab.core.disk.mapper.SDFileMapper;
import org.springframework.data.mongodb.core.query.BasicQuery; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.data.mongodb.core.query.Query; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import javax.annotation.Resource; import com.alibaba.fastjson.JSONObject;
import com.mongodb.QueryBuilder; import org.springframework.util.StringUtils;
/** /**
* 实体[文件] 服务对象接口实现 * 实体[文件] 服务对象接口实现
*/ */
@Slf4j @Slf4j
@Service @Service("SDFileServiceImpl")
public class SDFileServiceImpl implements ISDFileService { public class SDFileServiceImpl extends ServiceImpl<SDFileMapper, SDFile> implements ISDFileService {
@Autowired protected int batchSize = 500;
private SDFileRepository repository;
@Override @Override
@Transactional @Transactional
public boolean update(SDFile et) { public boolean update(SDFile et) {
repository.save(et); if(!update(et,(Wrapper) et.getUpdateWrapper(true).eq("fileid",et.getId())))
return false;
CachedBeanCopier.copy(get(et.getId()),et); CachedBeanCopier.copy(get(et.getId()),et);
return true ; return true;
} }
@Override @Override
public void updateBatch(List<SDFile> list) { public void updateBatch(List<SDFile> list) {
repository.saveAll(list); updateBatchById(list,batchSize);
} }
@Override @Override
@Transactional @Transactional
public boolean create(SDFile et) { public boolean create(SDFile et) {
repository.insert(et); if(!this.retBool(this.baseMapper.insert(et)))
return false;
CachedBeanCopier.copy(get(et.getId()),et); CachedBeanCopier.copy(get(et.getId()),et);
return true ; return true;
} }
@Override @Override
public void createBatch(List<SDFile> list) { public void createBatch(List<SDFile> list) {
repository.insert(list); this.saveBatch(list,batchSize);
} }
@Override @Override
public boolean checkKey(SDFile et) { public boolean checkKey(SDFile et) {
return repository.findById(et.getId()).isPresent(); return (!ObjectUtils.isEmpty(et.getId()))&&(!Objects.isNull(this.getById(et.getId())));
} }
@Override @Override
public SDFile getDraft(SDFile et) { public SDFile getDraft(SDFile et) {
return et; return et;
...@@ -85,74 +87,107 @@ public class SDFileServiceImpl implements ISDFileService { ...@@ -85,74 +87,107 @@ public class SDFileServiceImpl implements ISDFileService {
@Override @Override
@Transactional @Transactional
public SDFile get(String key) { public SDFile get(String key) {
Optional<SDFile> result = repository.findById(key); SDFile et = getById(key);
if(!result.isPresent()){ if(et==null){
SDFile et=new SDFile(); et=new SDFile();
et.setId(key); et.setId(key);
return et;
} }
else{ else{
SDFile et=result.get();
return et;
} }
return et;
} }
@Override @Override
@Transactional @Transactional
public boolean remove(String key) { public boolean remove(String key) {
repository.deleteById(key); boolean result=removeById(key);
return true ; return result ;
} }
@Override @Override
public void removeBatch(Collection<String> idList) { public void removeBatch(Collection<String> idList) {
repository.deleteAll(repository.findAllById(idList)); removeByIds(idList);
} }
@Override @Override
@Transactional @Transactional
public boolean save(SDFile et) { public boolean save(SDFile et) {
repository.save(et); if(!saveOrUpdate(et))
CachedBeanCopier.copy(get(et.getId()),et); return false;
return true ; return true;
} }
@Override @Override
public void saveBatch(List<SDFile> list) { @Transactional(
repository.saveAll(list); rollbackFor = {Exception.class}
)
public boolean saveOrUpdate(SDFile et) {
if (null == et) {
return false;
} else {
return checkKey(et) ? this.update(et) : this.create(et);
}
} }
@Override
public boolean saveBatch(Collection<SDFile> list) {
saveOrUpdateBatch(list,batchSize);
return true;
}
@Override
public void saveBatch(List<SDFile> list) {
saveOrUpdateBatch(list,batchSize);
}
@Resource
private MongoTemplate mongoTemplate;
/** /**
* 查询集合 DEFAULT * 查询集合 DEFAULT
*/ */
@Override @Override
public Page<SDFile> searchDefault(SDFileSearchContext context) { public Page<SDFile> searchDefault(SDFileSearchContext context) {
Query query = new BasicQuery(context.getSelectCond().get().toString()); com.baomidou.mybatisplus.extension.plugins.pagination.Page<SDFile> pages=baseMapper.searchDefault(context.getPages(),context,context.getSelectCond());
long total = mongoTemplate.count(query, SDFile.class); return new PageImpl<SDFile>(pages.getRecords(), context.getPageable(), pages.getTotal());
List<SDFile> list=mongoTemplate.find(query.with(context.getPageable()),SDFile.class);
return new PageImpl<SDFile>(list,context.getPageable(),total);
} }
@Override
public List<JSONObject> select(String sql, Map param){
return this.baseMapper.selectBySQL(sql,param);
}
@Override
@Transactional
public boolean execute(String sql , Map param){
if (sql == null || sql.isEmpty()) {
return false;
}
if (sql.toLowerCase().trim().startsWith("insert")) {
return this.baseMapper.insertBySQL(sql,param);
}
if (sql.toLowerCase().trim().startsWith("update")) {
return this.baseMapper.updateBySQL(sql,param);
}
if (sql.toLowerCase().trim().startsWith("delete")) {
return this.baseMapper.deleteBySQL(sql,param);
}
log.warn("暂未支持的SQL语法");
return true;
}
@Override @Override
public List<SDFile> getSdfileByIds(List<String> ids) { public List<SDFile> getSdfileByIds(List<String> ids) {
QueryBuilder permissionCond=new QueryBuilder(); return this.listByIds(ids);
permissionCond.and("id").in(ids);
Query query = new BasicQuery(permissionCond.get().toString());
return mongoTemplate.find(query,SDFile.class);
} }
@Override @Override
public List<SDFile> getSdfileByEntities(List<SDFile> entities) { public List<SDFile> getSdfileByEntities(List<SDFile> entities) {
List ids =new ArrayList(); List ids =new ArrayList();
for(SDFile entity : entities){ for(SDFile entity : entities){
Serializable id=entity.getId(); Serializable id=entity.getId();
...@@ -160,18 +195,12 @@ public class SDFileServiceImpl implements ISDFileService { ...@@ -160,18 +195,12 @@ public class SDFileServiceImpl implements ISDFileService {
ids.add(id); ids.add(id);
} }
} }
if(ids.size()>0){ if(ids.size()>0)
QueryBuilder permissionCond=new QueryBuilder(); return this.listByIds(ids);
permissionCond.and("id").in(ids);
Query query = new BasicQuery(permissionCond.get().toString());
return mongoTemplate.find(query,SDFile.class);
}
else else
return entities; return entities;
} }
} }
...@@ -5,6 +5,7 @@ import cn.ibizlab.util.helper.UniqueNameGenerator; ...@@ -5,6 +5,7 @@ import cn.ibizlab.util.helper.UniqueNameGenerator;
import com.baomidou.mybatisplus.core.injector.ISqlInjector; import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize;
import org.apache.ibatis.mapping.DatabaseIdProvider; import org.apache.ibatis.mapping.DatabaseIdProvider;
import org.apache.ibatis.mapping.VendorDatabaseIdProvider; import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
...@@ -42,7 +43,14 @@ public class MybatisConfiguration { ...@@ -42,7 +43,14 @@ public class MybatisConfiguration {
*/ */
@Bean @Bean
public PaginationInterceptor paginationInterceptor() { public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor(); PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
// 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false
// paginationInterceptor.setOverflow(false);
// 设置最大单页限制数量,默认 500 条,-1 不受限制
paginationInterceptor.setLimit(-1);
// 开启 count 的 join 优化,只针对部分 left join
paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
return paginationInterceptor;
} }
} }
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.ibizlab.core.disk.mapper.SDFileMapper">
<!--该方法用于重写mybatis中selectById方法,以实现查询逻辑属性-->
<select id="selectById" resultMap="SDFileResultMap" databaseId="mysql">
<![CDATA[select t1.* from (SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`DIGESTCODE`, t1.`FILEEXT`, t1.`FILEID`, t1.`FILENAME`, t1.`FILEPATH`, t1.`FILESIZE`, t1.`FOLDER`, t1.`MEMO`, t1.`OWNERID`, t1.`OWNERTYPE`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `IBZFILE` t1 ) t1 where fileid=#{id}]]>
</select>
<select id="selectById" resultMap="SDFileResultMap" databaseId="oracle">
<![CDATA[select t1.* from (SELECT t1.CREATEDATE, t1.CREATEMAN, t1.DIGESTCODE, t1.FILEEXT, t1.FILEID, t1.FILENAME, t1.FILEPATH, t1.FILESIZE, t1.FOLDER, t1.MEMO, t1.OWNERID, t1.OWNERTYPE, t1.UPDATEDATE, t1.UPDATEMAN FROM IBZFILE t1 ) t1 where fileid=#{id}]]>
</select>
<select id="selectById" resultMap="SDFileResultMap" databaseId="postgresql">
<![CDATA[select t1.* from (SELECT t1.CREATEDATE, t1.CREATEMAN, t1.DIGESTCODE, t1.FILEEXT, t1.FILEID, t1.FILENAME, t1.FILEPATH, t1.FILESIZE, t1.FOLDER, t1.MEMO, t1.OWNERID, t1.OWNERTYPE, t1.UPDATEDATE, t1.UPDATEMAN FROM IBZFILE t1 ) t1 where fileid=#{id}]]>
</select>
<!--通过mybatis将查询结果注入到entity中,通过配置autoMapping="true"由mybatis自动处理映射关系 -->
<resultMap id="SDFileResultMap" type="cn.ibizlab.core.disk.domain.SDFile" autoMapping="true">
<id property="id" column="fileid" /><!--主键字段映射-->
<result property="name" column="filename" />
<result property="extension" column="fileext" />
</resultMap>
<!--数据集合[Default]-->
<select id="searchDefault" parameterType="cn.ibizlab.core.disk.filter.SDFileSearchContext" resultMap="SDFileResultMap">
select t1.* from (
<include refid="Default" />
)t1
<where><if test="ew!=null and ew.sqlSegment!=null and !ew.emptyOfWhere">${ew.sqlSegment}</if></where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">${ew.sqlSegment}</if>
</select>
<!--数据查询[Default]-->
<sql id="Default" databaseId="mysql">
<![CDATA[ SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`DIGESTCODE`, t1.`FILEEXT`, t1.`FILEID`, t1.`FILENAME`, t1.`FILEPATH`, t1.`FILESIZE`, t1.`FOLDER`, t1.`MEMO`, t1.`OWNERID`, t1.`OWNERTYPE`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `IBZFILE` t1
]]>
</sql>
<!--数据查询[Default]-->
<sql id="Default" databaseId="oracle">
<![CDATA[ SELECT t1.CREATEDATE, t1.CREATEMAN, t1.DIGESTCODE, t1.FILEEXT, t1.FILEID, t1.FILENAME, t1.FILEPATH, t1.FILESIZE, t1.FOLDER, t1.MEMO, t1.OWNERID, t1.OWNERTYPE, t1.UPDATEDATE, t1.UPDATEMAN FROM IBZFILE t1
]]>
</sql>
<!--数据查询[Default]-->
<sql id="Default" databaseId="postgresql">
<![CDATA[ SELECT t1.CREATEDATE, t1.CREATEMAN, t1.DIGESTCODE, t1.FILEEXT, t1.FILEID, t1.FILENAME, t1.FILEPATH, t1.FILESIZE, t1.FOLDER, t1.MEMO, t1.OWNERID, t1.OWNERTYPE, t1.UPDATEDATE, t1.UPDATEMAN FROM IBZFILE t1
]]>
</sql>
<!--数据查询[View]-->
<sql id="View" databaseId="mysql">
<![CDATA[ SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`DIGESTCODE`, t1.`FILEEXT`, t1.`FILEID`, t1.`FILENAME`, t1.`FILEPATH`, t1.`FILESIZE`, t1.`FOLDER`, t1.`MEMO`, t1.`OWNERID`, t1.`OWNERTYPE`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `IBZFILE` t1
]]>
</sql>
<!--数据查询[View]-->
<sql id="View" databaseId="oracle">
<![CDATA[ SELECT t1.CREATEDATE, t1.CREATEMAN, t1.DIGESTCODE, t1.FILEEXT, t1.FILEID, t1.FILENAME, t1.FILEPATH, t1.FILESIZE, t1.FOLDER, t1.MEMO, t1.OWNERID, t1.OWNERTYPE, t1.UPDATEDATE, t1.UPDATEMAN FROM IBZFILE t1
]]>
</sql>
<!--数据查询[View]-->
<sql id="View" databaseId="postgresql">
<![CDATA[ SELECT t1.CREATEDATE, t1.CREATEMAN, t1.DIGESTCODE, t1.FILEEXT, t1.FILEID, t1.FILENAME, t1.FILEPATH, t1.FILESIZE, t1.FOLDER, t1.MEMO, t1.OWNERID, t1.OWNERTYPE, t1.UPDATEDATE, t1.UPDATEMAN FROM IBZFILE t1
]]>
</sql>
</mapper>
...@@ -43,9 +43,9 @@ public class SDFileDTO extends DTOBase implements Serializable { ...@@ -43,9 +43,9 @@ public class SDFileDTO extends DTOBase implements Serializable {
* 属性 [FILEPATH] * 属性 [FILEPATH]
* *
*/ */
@JSONField(name = "filepath") @JSONField(name = "file_path")
@JsonProperty("filepath") @JsonProperty("file_path")
private String filepath; private String filePath;
/** /**
* 属性 [FOLDER] * 属性 [FOLDER]
...@@ -59,33 +59,33 @@ public class SDFileDTO extends DTOBase implements Serializable { ...@@ -59,33 +59,33 @@ public class SDFileDTO extends DTOBase implements Serializable {
* 属性 [FILESIZE] * 属性 [FILESIZE]
* *
*/ */
@JSONField(name = "filesize") @JSONField(name = "file_size")
@JsonProperty("filesize") @JsonProperty("file_size")
private Integer filesize; private Integer fileSize;
/** /**
* 属性 [FILEEXT] * 属性 [FILEEXT]
* *
*/ */
@JSONField(name = "fileext") @JSONField(name = "extension")
@JsonProperty("fileext") @JsonProperty("extension")
private String fileext; private String extension;
/** /**
* 属性 [OWNERTYPE] * 属性 [OWNERTYPE]
* *
*/ */
@JSONField(name = "ownertype") @JSONField(name = "owner_type")
@JsonProperty("ownertype") @JsonProperty("owner_type")
private String ownertype; private String ownerType;
/** /**
* 属性 [OWNERID] * 属性 [OWNERID]
* *
*/ */
@JSONField(name = "ownerid") @JSONField(name = "owner_id")
@JsonProperty("ownerid") @JsonProperty("owner_id")
private String ownerid; private String ownerId;
/** /**
* 属性 [MEMO] * 属性 [MEMO]
...@@ -99,9 +99,9 @@ public class SDFileDTO extends DTOBase implements Serializable { ...@@ -99,9 +99,9 @@ public class SDFileDTO extends DTOBase implements Serializable {
* 属性 [DIGESTCODE] * 属性 [DIGESTCODE]
* *
*/ */
@JSONField(name = "digestcode") @JSONField(name = "digest_code")
@JsonProperty("digestcode") @JsonProperty("digest_code")
private String digestcode; private String digestCode;
/** /**
* 属性 [CREATEMAN] * 属性 [CREATEMAN]
...@@ -149,9 +149,9 @@ public class SDFileDTO extends DTOBase implements Serializable { ...@@ -149,9 +149,9 @@ public class SDFileDTO extends DTOBase implements Serializable {
/** /**
* 设置 [FILEPATH] * 设置 [FILEPATH]
*/ */
public void setFilepath(String filepath){ public void setFilePath(String filePath){
this.filepath = filepath ; this.filePath = filePath ;
this.modify("filepath",filepath); this.modify("filepath",filePath);
} }
/** /**
...@@ -165,33 +165,33 @@ public class SDFileDTO extends DTOBase implements Serializable { ...@@ -165,33 +165,33 @@ public class SDFileDTO extends DTOBase implements Serializable {
/** /**
* 设置 [FILESIZE] * 设置 [FILESIZE]
*/ */
public void setFilesize(Integer filesize){ public void setFileSize(Integer fileSize){
this.filesize = filesize ; this.fileSize = fileSize ;
this.modify("filesize",filesize); this.modify("filesize",fileSize);
} }
/** /**
* 设置 [FILEEXT] * 设置 [FILEEXT]
*/ */
public void setFileext(String fileext){ public void setExtension(String extension){
this.fileext = fileext ; this.extension = extension ;
this.modify("fileext",fileext); this.modify("fileext",extension);
} }
/** /**
* 设置 [OWNERTYPE] * 设置 [OWNERTYPE]
*/ */
public void setOwnertype(String ownertype){ public void setOwnerType(String ownerType){
this.ownertype = ownertype ; this.ownerType = ownerType ;
this.modify("ownertype",ownertype); this.modify("ownertype",ownerType);
} }
/** /**
* 设置 [OWNERID] * 设置 [OWNERID]
*/ */
public void setOwnerid(String ownerid){ public void setOwnerId(String ownerId){
this.ownerid = ownerid ; this.ownerId = ownerId ;
this.modify("ownerid",ownerid); this.modify("ownerid",ownerId);
} }
/** /**
...@@ -205,9 +205,9 @@ public class SDFileDTO extends DTOBase implements Serializable { ...@@ -205,9 +205,9 @@ public class SDFileDTO extends DTOBase implements Serializable {
/** /**
* 设置 [DIGESTCODE] * 设置 [DIGESTCODE]
*/ */
public void setDigestcode(String digestcode){ public void setDigestCode(String digestCode){
this.digestcode = digestcode ; this.digestCode = digestCode ;
this.modify("digestcode",digestcode); this.modify("digestcode",digestCode);
} }
......
...@@ -28,6 +28,7 @@ import java.util.List; ...@@ -28,6 +28,7 @@ import java.util.List;
@MapperScan("cn.ibizlab.*.mapper") @MapperScan("cn.ibizlab.*.mapper")
@SpringBootApplication(exclude = { @SpringBootApplication(exclude = {
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class, org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration.class,
}) })
@Import({ @Import({
org.springframework.cloud.openfeign.FeignClientsConfiguration.class org.springframework.cloud.openfeign.FeignClientsConfiguration.class
......
...@@ -32,6 +32,7 @@ import cn.ibizlab.api.mapping.*; ...@@ -32,6 +32,7 @@ import cn.ibizlab.api.mapping.*;
import cn.ibizlab.core.disk.domain.SDFile; import cn.ibizlab.core.disk.domain.SDFile;
import cn.ibizlab.core.disk.service.ISDFileService; import cn.ibizlab.core.disk.service.ISDFileService;
import cn.ibizlab.core.disk.filter.SDFileSearchContext; import cn.ibizlab.core.disk.filter.SDFileSearchContext;
import cn.ibizlab.util.annotation.VersionCheck;
@Slf4j @Slf4j
@Api(tags = {"文件" }) @Api(tags = {"文件" })
...@@ -46,6 +47,7 @@ public class SDFileResource { ...@@ -46,6 +47,7 @@ public class SDFileResource {
@Lazy @Lazy
public SDFileMapping sdfileMapping; public SDFileMapping sdfileMapping;
@VersionCheck(entity = "sdfile" , versionfield = "updatedate")
@PreAuthorize("hasPermission(this.sdfileService.get(#sdfile_id),'ibzdisk-SDFile-Update')") @PreAuthorize("hasPermission(this.sdfileService.get(#sdfile_id),'ibzdisk-SDFile-Update')")
@ApiOperation(value = "更新文件", tags = {"文件" }, notes = "更新文件") @ApiOperation(value = "更新文件", tags = {"文件" }, notes = "更新文件")
@RequestMapping(method = RequestMethod.PUT, value = "/sdfiles/{sdfile_id}") @RequestMapping(method = RequestMethod.PUT, value = "/sdfiles/{sdfile_id}")
......
package cn.ibizlab.util.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.METHOD})
public @interface VersionCheck
{
String entity();
String versionfield();
}
package cn.ibizlab.util.aspect;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import cn.ibizlab.util.annotation.VersionCheck;
import cn.ibizlab.util.domain.EntityBase;
import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.helper.RuleUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.core.annotation.Order;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.lang.reflect.Field;
/**
* 数据库版本检查
*/
@Aspect
@Order(0)
@Component
public class VersionCheckAspect
{
private final ExpressionParser parser = new SpelExpressionParser();
@SneakyThrows
@Before("execution(* cn.ibizlab.*.rest.*.update(..)) && @annotation(versionCheck)")
public void BeforeUpdate(JoinPoint point, VersionCheck versionCheck){
EvaluationContext context = new StandardEvaluationContext();
Object[] args = point.getArgs();
Object id=args[0];
Object dto=args[1];
if(ObjectUtils.isEmpty(id) || ObjectUtils.isEmpty(dto))
return;
String versionField=versionCheck.versionfield();
if(StringUtils.isEmpty(versionCheck))
return;
context.setVariable("dto",dto);
Expression newExp = parser.parseExpression(String.format("#dto.%s",versionField));
Object newVersion=newExp.getValue(context);
if(ObjectUtils.isEmpty(newVersion))
return;
//进行版本检查
Object oldVersion =getDBVersion(versionCheck,getService(point.getTarget(),versionCheck.entity()),id);
if(!ObjectUtils.isEmpty(oldVersion)){
if(RuleUtils.gt(newVersion,oldVersion))
throw new BadRequestAlertException("数据已变更,可能后台数据已被修改,请重新加载数据","VersionCheckAspect","versionCheck");
}
}
/**
* 获取实体服务对象
* @param resource
* @param entity
* @return
*/
@SneakyThrows
private Object getService(Object resource,String entity){
Object service = null;
Field[] fields= resource.getClass().getDeclaredFields();
for(Field field : fields){
if(field.getModifiers()==1 && field.getName().equalsIgnoreCase(String.format("%sService",entity))){
service=field.get(resource);
break;
}
}
return service;
}
/**
* 获取数据库版本
* @param versionCheck
* @param service
* @param id
* @return
*/
@SneakyThrows
private Object getDBVersion(VersionCheck versionCheck,Object service,Object id){
Object dbVersion=null;
String versionField=versionCheck.versionfield();
if(!ObjectUtils.isEmpty(service)){
EvaluationContext oldContext = new StandardEvaluationContext();
oldContext.setVariable("service",service);
oldContext.setVariable("id",id);
Expression oldExp = parser.parseExpression("#service.get(#id)");
EntityBase oldEntity =oldExp.getValue(oldContext, EntityBase.class);
return oldEntity.get(versionField);
}
return dbVersion;
}
}
...@@ -94,8 +94,10 @@ public class LayeringCache extends AbstractValueAdaptingCache { ...@@ -94,8 +94,10 @@ public class LayeringCache extends AbstractValueAdaptingCache {
@Override @Override
public void put(Object key, Object value) { public void put(Object key, Object value) {
caffeineCache.put(key, value); if(value!=null) {
redisCache.put(key, value); caffeineCache.put(key, value);
redisCache.put(key, value);
}
} }
@Override @Override
......
...@@ -55,6 +55,10 @@ public class AppController { ...@@ -55,6 +55,10 @@ public class AppController {
appData.put("unires",uniRes); appData.put("unires",uniRes);
appData.put("appmenu",appMenu); appData.put("appmenu",appMenu);
appData.put("enablepermissionvalid",enablePermissionValid); appData.put("enablepermissionvalid",enablePermissionValid);
if(curUser.getSuperuser()==1)
appData.put("enablepermissionvalid",false);
else
appData.put("enablepermissionvalid",enablePermissionValid);
return ResponseEntity.status(HttpStatus.OK).body(appData); return ResponseEntity.status(HttpStatus.OK).body(appData);
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册