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

ibiz4j 发布系统代码

上级 32dc0933
......@@ -93,6 +93,11 @@
<template v-if="!Object.is(layoutType, 'FLEX')">
<row :gutter="10"><slot></slot></row>
</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>
<template v-if="isShowCaption === false">
<slot></slot>
......@@ -115,6 +120,22 @@ export default class AppFormGroup extends Vue {
*/
@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 {
public doUIAction($event: any, item: any): void {
this.$emit('groupuiactionclick', { event: $event, item: item });
}
/**
* 操作管理容器
*
* @param {*} $event
* @memberof AppFormGroup
*/
public doManageContainer(){
this.$emit('managecontainerclick');
}
}
</script>
<style lang='less'>
......
......@@ -44,6 +44,11 @@ export default class AppMpicker extends Vue {
*/
@Prop() curvalue?: any;
/**
* 值项
*/
@Prop() valueitem?: any;
/**
* 局部上下文导航参数
*
......@@ -144,6 +149,7 @@ export default class AppMpicker extends Vue {
this.value = [];
this.selectItems = [];
if (newVal) {
try {
this.selectItems = this.parseValue(JSON.parse(newVal));
this.selectItems.forEach((item: any) => {
this.value.push(item[this.deKeyField]);
......@@ -152,6 +158,25 @@ export default class AppMpicker extends Vue {
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();
}
......
......@@ -25,7 +25,7 @@
</span>
</el-col>
<el-col :span="14">
<span>{{ item.label }}</span>
<span>{{ item.fullName ? item.fullName:item.label }}</span>
</el-col>
<el-col :span="6">
<div class="bar">
......@@ -46,7 +46,7 @@
<Drawer class-name="menu-drawer" width="60" :closable="true" :mask="false" placement="left" v-model="rightDrawerVisiable">
<div class="menuItems">
<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)">
<Icon type="ios-star" />
</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 {
position: relative;
margin: 8px 0;
.left{
.el-tabs__header{
padding-right:120px;
......@@ -60,7 +61,8 @@
border-bottom:2px solid transparent !important;
}
.el-tabs__header{
margin:0 0 1 0;
margin:0;
border-bottom: none;
}
}
}
......
......@@ -395,6 +395,9 @@ export default class MDViewEngine extends ViewEngine {
if (this.getSearchForm() && this.view.isExpandSearchForm) {
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) {
Object.assign(arg, { query: this.view.query });
}
......
......@@ -169,4 +169,8 @@ export default {
YouYuan: 'YouYuan',
},
},
appFormGroup: {
hide: 'hide',
showMore: 'show more',
},
};
\ No newline at end of file
......@@ -170,4 +170,8 @@ export default {
YouYuan: '幼圆',
},
},
appFormGroup: {
hide: '隐藏字段',
showMore: '显示更多字段',
},
};
\ No newline at end of file
......@@ -46,6 +46,22 @@ export class FormDetailModel {
*/
public visible: boolean = true;
/**
* 成员是否显示(旧)
*
* @type {boolean}
* @memberof FormDetailModel
*/
public oldVisible: boolean = true;
/**
* 成员是否为受控内容
*
* @type {boolean}
* @memberof FormDetailModel
*/
public isControlledContent: boolean = false;
/**
* 成员是否显示标题
*
......@@ -54,6 +70,7 @@ export class FormDetailModel {
*/
public isShowCaption: boolean = true;
/**
* Creates an instance of FormDetailModel.
* FormDetailModel 实例
......@@ -67,7 +84,9 @@ export class FormDetailModel {
this.form = opts.form ? opts.form : {};
this.name = !Object.is(opts.name, '') ? opts.name : '';
this.visible = opts.visible ? true : false;
this.oldVisible = opts.visible ? true : false;
this.isShowCaption = opts.isShowCaption ? true : false;
this.isControlledContent = opts.isControlledContent ? true : false;
}
/**
......
......@@ -17,6 +17,30 @@ export class FormGroupPanelModel extends FormDetailModel {
*/
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.
* 创建 FormGroupPanelModel 实例
......@@ -27,5 +51,17 @@ export class FormGroupPanelModel extends FormDetailModel {
constructor(opts: any = {}) {
super(opts);
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 {
*
* @memberof SDFileEditViewBase
*/
public initNavDataWithRoute(data:any = null, isNew:boolean = false){
if(this.viewDefaultUsage && Object.is(this.navModel,"route")){
public initNavDataWithRoute(data:any = null, isNew:boolean = false, isAlways:boolean = false){
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});
}
}
......@@ -554,8 +554,8 @@ export default class SDFileEditViewBase extends Vue {
*
* @memberof SDFileEditViewBase
*/
public initNavDataWithTab(data:any = null,isOnlyAdd:boolean = true){
if(this.viewDefaultUsage && !Object.is(this.navModel,"route")){
public initNavDataWithTab(data:any = null,isOnlyAdd:boolean = true, isAlways:boolean = false){
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);
}
}
......
......@@ -577,8 +577,8 @@ export default class SDFileGridViewBase extends Vue {
*
* @memberof SDFileGridViewBase
*/
public initNavDataWithRoute(data:any = null, isNew:boolean = false){
if(this.viewDefaultUsage && Object.is(this.navModel,"route")){
public initNavDataWithRoute(data:any = null, isNew:boolean = false, isAlways:boolean = false){
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});
}
}
......@@ -588,8 +588,8 @@ export default class SDFileGridViewBase extends Vue {
*
* @memberof SDFileGridViewBase
*/
public initNavDataWithTab(data:any = null,isOnlyAdd:boolean = true){
if(this.viewDefaultUsage && !Object.is(this.navModel,"route")){
public initNavDataWithTab(data:any = null,isOnlyAdd:boolean = true, isAlways:boolean = false){
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);
}
}
......@@ -1248,6 +1248,13 @@ export default class SDFileGridViewBase extends Vue {
* @memberof SDFileGridView
*/
public opendata(args: any[],fullargs?:any[],params?: any, $event?: any, xData?: any) {
if(!this.viewDefaultUsage){
if(Object.is(this.navModel,"route")){
this.initNavDataWithRoute(this.viewCacheData, false, true);
}else{
this.initNavDataWithTab(this.viewCacheData, false, true);
}
}
let localContext:any = null;
let localViewParam:any =null;
const data: any = {};
......
......@@ -6,7 +6,7 @@
<sider :width="collapseChange ? 64 : 200" hide-trigger v-model="collapseChange">
<div class="sider-top">
<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>
</div>
</div>
......@@ -26,7 +26,7 @@
ref='appmenu'
@closeview="closeView($event)">
</view_appmenu>
<context-menu-drag :contextMenuDragVisiable="contextMenuDragVisiable"></context-menu-drag>
<context-menu-drag v-if="isEnableAppSwitch" :contextMenuDragVisiable="contextMenuDragVisiable"></context-menu-drag>
</sider>
<layout>
<header class="index_header">
......@@ -408,8 +408,8 @@ export default class SDIndexViewBase extends Vue {
*
* @memberof SDIndexViewBase
*/
public initNavDataWithRoute(data:any = null, isNew:boolean = false){
if(this.viewDefaultUsage && Object.is(this.navModel,"route")){
public initNavDataWithRoute(data:any = null, isNew:boolean = false, isAlways:boolean = false){
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});
}
}
......@@ -419,8 +419,8 @@ export default class SDIndexViewBase extends Vue {
*
* @memberof SDIndexViewBase
*/
public initNavDataWithTab(data:any = null,isOnlyAdd:boolean = true){
if(this.viewDefaultUsage && !Object.is(this.navModel,"route")){
public initNavDataWithTab(data:any = null,isOnlyAdd:boolean = true, isAlways:boolean = false){
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);
}
}
......@@ -542,6 +542,14 @@ export default class SDIndexViewBase extends Vue {
*/
public contextMenuDragVisiable: boolean = false;
/**
* 是否支持应用切换
*
* @type {boolean}
* @memberof SDIndexViewBase
*/
public isEnableAppSwitch: boolean = false;
/**
* 初始化之前
*
......
......@@ -91,6 +91,7 @@
display: flex;
align-items: center;
height: 100%;
justify-content: center;
>.menuicon{
display: block;
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
----
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) =>{
resourceIndex= state.resourceData.findIndex((resourcetag: any, objIndex: any, objs: any) => {
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;
}
}
\ No newline at end of file
......@@ -63,7 +63,7 @@ export class ViewTool {
public static buildUpRoutePath(route: Route, viewParam: any = {}, deResParameters: any[], parameters: any[], args: any[], data: any): string {
const indexRoutePath = this.getIndexRoutePath(route);
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}`;
}
......@@ -123,7 +123,7 @@ export class ViewTool {
* @returns {string}
* @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 = '';
// 不存在应用实体
if(parameters && parameters.length >0){
......@@ -137,8 +137,7 @@ export class ViewTool {
let [arg] = args;
arg = arg ? arg : {};
const [{ pathName: _pathName, parameterName: _parameterName }, { pathName: _pathName2, parameterName: _parameterName2 }] = parameters;
const _value: any = arg[_parameterName] && !Object.is(arg[_parameterName], '') ?
arg[_parameterName] : null;
const _value: any = arg[_parameterName] || viewParam[_parameterName] || null;
routePath = `/${_pathName}/${_value}/${_pathName2}`;
if (Object.keys(data).length > 0) {
routePath = `${routePath}?${qs.stringify(data, { delimiter: ';' })}`;
......
......@@ -124,6 +124,7 @@ import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import { UIActionTool,Util } from '@/utils';
import NavDataService from '@/service/app/navdata-service';
import AppCenterService from "@service/app/app-center-service";
import SDIndexViewService from './sdindex-view-appmenu-service';
import SDIndexViewModel from './sdindex-view-appmenu-model';
......
......@@ -28,6 +28,7 @@ import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import { UIActionTool,Util } from '@/utils';
import NavDataService from '@/service/app/navdata-service';
import AppCenterService from "@service/app/app-center-service";
import SDFileService from '@/service/sdfile/sdfile-service';
import DefaultService from './default-searchform-service';
......
......@@ -80,6 +80,8 @@ export default class DefaultService extends ControlService {
*/
@Errorlog
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([])
}
......
......@@ -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):
- 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 {
},
{
name: 'filepath',
prop: 'filepath',
prop: 'file_path',
dataType: 'TEXT',
},
{
name: 'filesize',
prop: 'filesize',
prop: 'file_size',
dataType: 'INT',
},
{
name: 'fileext',
prop: 'fileext',
prop: 'extension',
dataType: 'TEXT',
},
{
......@@ -82,17 +82,17 @@ export default class MainModel {
},
{
name: 'digestcode',
prop: 'digestcode',
prop: 'digest_code',
dataType: 'TEXT',
},
{
name: 'ownerid',
prop: 'ownerid',
prop: 'owner_id',
dataType: 'TEXT',
},
{
name: 'ownertype',
prop: 'ownertype',
prop: 'owner_type',
dataType: 'TEXT',
},
{
......
......@@ -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):
- 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
----
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 {
return [
{
name: 'fileext',
prop: 'fileext',
prop: 'extension',
dataType: 'TEXT',
},
{
name: 'filepath',
prop: 'filepath',
prop: 'file_path',
dataType: 'TEXT',
},
{
......@@ -48,7 +48,7 @@ export default class MainModel {
},
{
name: 'ownerid',
prop: 'ownerid',
prop: 'owner_id',
dataType: 'TEXT',
},
{
......@@ -73,7 +73,7 @@ export default class MainModel {
},
{
name: 'filesize',
prop: 'filesize',
prop: 'file_size',
dataType: 'INT',
},
{
......@@ -83,7 +83,7 @@ export default class MainModel {
},
{
name: 'ownertype',
prop: 'ownertype',
prop: 'owner_type',
dataType: 'TEXT',
},
{
......
......@@ -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):
- 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;
@EnableTransactionManagement
@EnableFeignClients(basePackages = {"cn.ibizlab" })
@SpringBootApplication(exclude = {
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration.class,
})
@ComponentScan(basePackages = {"cn.ibizlab"}
// ,excludeFilters={
......
......@@ -23,142 +23,203 @@ import lombok.*;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.data.mongodb.core.mapping.FieldType;
import cn.ibizlab.util.domain.EntityMongo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.baomidou.mybatisplus.annotation.*;
import cn.ibizlab.util.domain.EntityMP;
/**
* 大数据 [文件] 对象
* 实体[文件]
*/
@Data
@Document(collection = "sdfile")
public class SDFile extends EntityMongo implements Serializable {
@Getter
@Setter
@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)
@TableId(value= "fileid",type=IdType.ASSIGN_UUID)
@JSONField(name = "id")
@JsonProperty("id")
private String id;
/**
* 名称
*/
@DEField(name = "filename")
@TableField(value = "filename")
@JSONField(name = "name")
@JsonProperty("name")
@Field(name = "filename")
private String name;
/**
* 路径
*/
@JSONField(name = "filepath")
@JsonProperty("filepath")
@Field(name = "filepath")
private String filepath;
@TableField(value = "filepath")
@JSONField(name = "file_path")
@JsonProperty("file_path")
private String filePath;
/**
* 特定目录
*/
@TableField(value = "folder")
@JSONField(name = "folder")
@JsonProperty("folder")
@Field(name = "folder")
private String folder;
/**
* 文件大小
*/
@JSONField(name = "filesize")
@JsonProperty("filesize")
@Field(name = "filesize")
private Integer filesize;
@TableField(value = "filesize")
@JSONField(name = "file_size")
@JsonProperty("file_size")
private Integer fileSize;
/**
* 扩展名
*/
@JSONField(name = "fileext")
@JsonProperty("fileext")
@Field(name = "fileext")
private String fileext;
@DEField(name = "fileext")
@TableField(value = "fileext")
@JSONField(name = "extension")
@JsonProperty("extension")
private String extension;
/**
* 所属类型
*/
@JSONField(name = "ownertype")
@JsonProperty("ownertype")
@Field(name = "ownertype")
private String ownertype;
@TableField(value = "ownertype")
@JSONField(name = "owner_type")
@JsonProperty("owner_type")
private String ownerType;
/**
* 所属主体
*/
@JSONField(name = "ownerid")
@JsonProperty("ownerid")
@Field(name = "ownerid")
private String ownerid;
@TableField(value = "ownerid")
@JSONField(name = "owner_id")
@JsonProperty("owner_id")
private String ownerId;
/**
* 备注
*/
@TableField(value = "memo")
@JSONField(name = "memo")
@JsonProperty("memo")
@Field(name = "memo")
private String memo;
/**
* 签名
*/
@JSONField(name = "digestcode")
@JsonProperty("digestcode")
@Field(name = "digestcode")
private String digestcode;
@TableField(value = "digestcode")
@JSONField(name = "digest_code")
@JsonProperty("digest_code")
private String digestCode;
/**
* 创建人
*/
@DEField(preType = DEPredefinedFieldType.CREATEMAN)
@TableField(value = "createman" , fill = FieldFill.INSERT)
@JSONField(name = "createman")
@JsonProperty("createman")
@Field(name = "createman")
private String createman;
/**
* 创建日期
*/
@DEField(preType = DEPredefinedFieldType.CREATEDATE)
@TableField(value = "createdate" , fill = FieldFill.INSERT)
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
@JSONField(name = "createdate" , format="yyyy-MM-dd HH:mm:ss")
@JsonProperty("createdate")
@Field(name = "createdate")
private Timestamp createdate;
/**
* 更新人
*/
@DEField(preType = DEPredefinedFieldType.UPDATEMAN)
@TableField(value = "updateman")
@JSONField(name = "updateman")
@JsonProperty("updateman")
@Field(name = "updateman")
private String updateman;
/**
* 更新时间
*/
@DEField(preType = DEPredefinedFieldType.UPDATEDATE)
@TableField(value = "updatedate")
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
@JSONField(name = "updatedate" , format="yyyy-MM-dd HH:mm:ss")
@JsonProperty("updatedate")
@Field(name = "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;
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 java.util.regex.Pattern;
import com.mongodb.BasicDBObject;
/**
* NoSQL数据实体[SDFile] 查询条件对象
* 关系型数据实体[SDFile] 查询条件对象
*/
@Slf4j
@Data
public class SDFileSearchContext extends QueryBuildContext {
public class SDFileSearchContext extends QueryWrapperContext<SDFile> {
private String n_filename_like;//[名称]
public void setN_filename_like(String n_filename_like) {
this.n_filename_like = n_filename_like;
if(!ObjectUtils.isEmpty(this.n_filename_like)){
Pattern pattern = Pattern.compile("^.*" + n_filename_like + ".*$", Pattern.CASE_INSENSITIVE);
this.getSearchCond().and("filename").regex(pattern);
this.getSearchCond().like("filename", n_filename_like);
}
}
......@@ -45,11 +42,13 @@ public class SDFileSearchContext extends QueryBuildContext {
{
this.query=query;
if(!StringUtils.isEmpty(query)){
Pattern pattern = Pattern.compile("^.*" + query + ".*$", Pattern.CASE_INSENSITIVE);
this.getSearchCond().or(new BasicDBObject("filename",pattern));
this.getSearchCond().and( wrapper ->
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;
import cn.ibizlab.core.disk.filter.SDFileSearchContext;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* 实体[SDFile] 服务对象接口
*/
public interface ISDFileService{
public interface ISDFileService extends IService<SDFile>{
boolean update(SDFile et) ;
void updateBatch(List<SDFile> list) ;
......@@ -35,10 +37,25 @@ public interface ISDFileService{
boolean save(SDFile et) ;
void saveBatch(List<SDFile> list) ;
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> getSdfileByEntities(List<SDFile> entities) ;
}
}
......@@ -30,53 +30,55 @@ import cn.ibizlab.core.disk.service.ISDFileService;
import cn.ibizlab.util.helper.CachedBeanCopier;
import cn.ibizlab.core.disk.repository.SDFileRepository;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.BasicQuery;
import org.springframework.data.mongodb.core.query.Query;
import javax.annotation.Resource;
import com.mongodb.QueryBuilder;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.ibizlab.core.disk.mapper.SDFileMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.alibaba.fastjson.JSONObject;
import org.springframework.util.StringUtils;
/**
* 实体[文件] 服务对象接口实现
*/
@Slf4j
@Service
public class SDFileServiceImpl implements ISDFileService {
@Service("SDFileServiceImpl")
public class SDFileServiceImpl extends ServiceImpl<SDFileMapper, SDFile> implements ISDFileService {
@Autowired
private SDFileRepository repository;
protected int batchSize = 500;
@Override
@Transactional
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);
return true ;
return true;
}
@Override
public void updateBatch(List<SDFile> list) {
repository.saveAll(list);
updateBatchById(list,batchSize);
}
@Override
@Transactional
public boolean create(SDFile et) {
repository.insert(et);
if(!this.retBool(this.baseMapper.insert(et)))
return false;
CachedBeanCopier.copy(get(et.getId()),et);
return true ;
return true;
}
@Override
public void createBatch(List<SDFile> list) {
repository.insert(list);
this.saveBatch(list,batchSize);
}
@Override
public boolean checkKey(SDFile et) {
return repository.findById(et.getId()).isPresent();
return (!ObjectUtils.isEmpty(et.getId()))&&(!Objects.isNull(this.getById(et.getId())));
}
@Override
public SDFile getDraft(SDFile et) {
return et;
......@@ -85,74 +87,107 @@ public class SDFileServiceImpl implements ISDFileService {
@Override
@Transactional
public SDFile get(String key) {
Optional<SDFile> result = repository.findById(key);
if(!result.isPresent()){
SDFile et=new SDFile();
SDFile et = getById(key);
if(et==null){
et=new SDFile();
et.setId(key);
return et;
}
else{
SDFile et=result.get();
return et;
}
return et;
}
@Override
@Transactional
public boolean remove(String key) {
repository.deleteById(key);
return true ;
boolean result=removeById(key);
return result ;
}
@Override
public void removeBatch(Collection<String> idList) {
repository.deleteAll(repository.findAllById(idList));
removeByIds(idList);
}
@Override
@Transactional
public boolean save(SDFile et) {
repository.save(et);
CachedBeanCopier.copy(get(et.getId()),et);
return true ;
if(!saveOrUpdate(et))
return false;
return true;
}
@Override
public void saveBatch(List<SDFile> list) {
repository.saveAll(list);
@Transactional(
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
*/
@Override
public Page<SDFile> searchDefault(SDFileSearchContext context) {
Query query = new BasicQuery(context.getSelectCond().get().toString());
long total = mongoTemplate.count(query, SDFile.class);
List<SDFile> list=mongoTemplate.find(query.with(context.getPageable()),SDFile.class);
return new PageImpl<SDFile>(list,context.getPageable(),total);
com.baomidou.mybatisplus.extension.plugins.pagination.Page<SDFile> pages=baseMapper.searchDefault(context.getPages(),context,context.getSelectCond());
return new PageImpl<SDFile>(pages.getRecords(), context.getPageable(), pages.getTotal());
}
@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
public List<SDFile> getSdfileByIds(List<String> ids) {
QueryBuilder permissionCond=new QueryBuilder();
permissionCond.and("id").in(ids);
Query query = new BasicQuery(permissionCond.get().toString());
return mongoTemplate.find(query,SDFile.class);
return this.listByIds(ids);
}
@Override
public List<SDFile> getSdfileByEntities(List<SDFile> entities) {
List ids =new ArrayList();
for(SDFile entity : entities){
Serializable id=entity.getId();
......@@ -160,12 +195,8 @@ public class SDFileServiceImpl implements ISDFileService {
ids.add(id);
}
}
if(ids.size()>0){
QueryBuilder permissionCond=new QueryBuilder();
permissionCond.and("id").in(ids);
Query query = new BasicQuery(permissionCond.get().toString());
return mongoTemplate.find(query,SDFile.class);
}
if(ids.size()>0)
return this.listByIds(ids);
else
return entities;
}
......@@ -173,5 +204,3 @@ public class SDFileServiceImpl implements ISDFileService {
}
......@@ -5,6 +5,7 @@ import cn.ibizlab.util.helper.UniqueNameGenerator;
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
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.VendorDatabaseIdProvider;
import org.springframework.context.annotation.Bean;
......@@ -42,7 +43,14 @@ public class MybatisConfiguration {
*/
@Bean
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 {
* 属性 [FILEPATH]
*
*/
@JSONField(name = "filepath")
@JsonProperty("filepath")
private String filepath;
@JSONField(name = "file_path")
@JsonProperty("file_path")
private String filePath;
/**
* 属性 [FOLDER]
......@@ -59,33 +59,33 @@ public class SDFileDTO extends DTOBase implements Serializable {
* 属性 [FILESIZE]
*
*/
@JSONField(name = "filesize")
@JsonProperty("filesize")
private Integer filesize;
@JSONField(name = "file_size")
@JsonProperty("file_size")
private Integer fileSize;
/**
* 属性 [FILEEXT]
*
*/
@JSONField(name = "fileext")
@JsonProperty("fileext")
private String fileext;
@JSONField(name = "extension")
@JsonProperty("extension")
private String extension;
/**
* 属性 [OWNERTYPE]
*
*/
@JSONField(name = "ownertype")
@JsonProperty("ownertype")
private String ownertype;
@JSONField(name = "owner_type")
@JsonProperty("owner_type")
private String ownerType;
/**
* 属性 [OWNERID]
*
*/
@JSONField(name = "ownerid")
@JsonProperty("ownerid")
private String ownerid;
@JSONField(name = "owner_id")
@JsonProperty("owner_id")
private String ownerId;
/**
* 属性 [MEMO]
......@@ -99,9 +99,9 @@ public class SDFileDTO extends DTOBase implements Serializable {
* 属性 [DIGESTCODE]
*
*/
@JSONField(name = "digestcode")
@JsonProperty("digestcode")
private String digestcode;
@JSONField(name = "digest_code")
@JsonProperty("digest_code")
private String digestCode;
/**
* 属性 [CREATEMAN]
......@@ -149,9 +149,9 @@ public class SDFileDTO extends DTOBase implements Serializable {
/**
* 设置 [FILEPATH]
*/
public void setFilepath(String filepath){
this.filepath = filepath ;
this.modify("filepath",filepath);
public void setFilePath(String filePath){
this.filePath = filePath ;
this.modify("filepath",filePath);
}
/**
......@@ -165,33 +165,33 @@ public class SDFileDTO extends DTOBase implements Serializable {
/**
* 设置 [FILESIZE]
*/
public void setFilesize(Integer filesize){
this.filesize = filesize ;
this.modify("filesize",filesize);
public void setFileSize(Integer fileSize){
this.fileSize = fileSize ;
this.modify("filesize",fileSize);
}
/**
* 设置 [FILEEXT]
*/
public void setFileext(String fileext){
this.fileext = fileext ;
this.modify("fileext",fileext);
public void setExtension(String extension){
this.extension = extension ;
this.modify("fileext",extension);
}
/**
* 设置 [OWNERTYPE]
*/
public void setOwnertype(String ownertype){
this.ownertype = ownertype ;
this.modify("ownertype",ownertype);
public void setOwnerType(String ownerType){
this.ownerType = ownerType ;
this.modify("ownertype",ownerType);
}
/**
* 设置 [OWNERID]
*/
public void setOwnerid(String ownerid){
this.ownerid = ownerid ;
this.modify("ownerid",ownerid);
public void setOwnerId(String ownerId){
this.ownerId = ownerId ;
this.modify("ownerid",ownerId);
}
/**
......@@ -205,9 +205,9 @@ public class SDFileDTO extends DTOBase implements Serializable {
/**
* 设置 [DIGESTCODE]
*/
public void setDigestcode(String digestcode){
this.digestcode = digestcode ;
this.modify("digestcode",digestcode);
public void setDigestCode(String digestCode){
this.digestCode = digestCode ;
this.modify("digestcode",digestCode);
}
......
......@@ -28,6 +28,7 @@ import java.util.List;
@MapperScan("cn.ibizlab.*.mapper")
@SpringBootApplication(exclude = {
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration.class,
})
@Import({
org.springframework.cloud.openfeign.FeignClientsConfiguration.class
......
......@@ -32,6 +32,7 @@ import cn.ibizlab.api.mapping.*;
import cn.ibizlab.core.disk.domain.SDFile;
import cn.ibizlab.core.disk.service.ISDFileService;
import cn.ibizlab.core.disk.filter.SDFileSearchContext;
import cn.ibizlab.util.annotation.VersionCheck;
@Slf4j
@Api(tags = {"文件" })
......@@ -46,6 +47,7 @@ public class SDFileResource {
@Lazy
public SDFileMapping sdfileMapping;
@VersionCheck(entity = "sdfile" , versionfield = "updatedate")
@PreAuthorize("hasPermission(this.sdfileService.get(#sdfile_id),'ibzdisk-SDFile-Update')")
@ApiOperation(value = "更新文件", tags = {"文件" }, notes = "更新文件")
@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,9 +94,11 @@ public class LayeringCache extends AbstractValueAdaptingCache {
@Override
public void put(Object key, Object value) {
if(value!=null) {
caffeineCache.put(key, value);
redisCache.put(key, value);
}
}
@Override
public ValueWrapper putIfAbsent(Object key, Object value) {
......
......@@ -55,6 +55,10 @@ public class AppController {
appData.put("unires",uniRes);
appData.put("appmenu",appMenu);
appData.put("enablepermissionvalid",enablePermissionValid);
if(curUser.getSuperuser()==1)
appData.put("enablepermissionvalid",false);
else
appData.put("enablepermissionvalid",enablePermissionValid);
return ResponseEntity.status(HttpStatus.OK).body(appData);
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册