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

ibiz4j 发布系统代码

上级 8c39dcbc
<template>
<el-select size="small" class="filter-mode" placeholder="条件逻辑" clearable v-model="curVal" @change="onChange">
<el-select size="small" class="filter-mode" placeholder="条件逻辑" v-model="curVal" @change="onChange">
<el-option
v-for="mode in filterMode"
:key="mode.value"
:label="mode.en"
:label="getLabel(mode)"
:value="mode.value"
>
</el-option>
......@@ -43,23 +43,36 @@ export default class FilterMode extends Vue {
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' }
{ 'zh-CN': '等于(=)', 'en-US': 'EQ', value: '$eq' },
{ 'zh-CN': '不等于(<>)', 'en-US': 'NE', value: '$ne' },
{ 'zh-CN': '大于(>)', 'en-US': 'GT', value: '$gt' },
{ 'zh-CN': '大于等于(>=)', 'en-US': 'GE', value: '$gte' },
{ 'zh-CN': '小于(<)', 'en-US': 'LT', value: '$lt' },
{ 'zh-CN': '小于(<=)', 'en-US': 'LE', value: '$lte' },
{ 'zh-CN': '值为空(Nil)', 'en-US': 'IS_NULL', value: '$null' },
{ 'zh-CN': '值不为空(NotNil)', 'en-US': 'IS_NOT_NULL', value: '$notNull' },
{ 'zh-CN': '值在范围中(In)', 'en-US': 'IN', value: '$in' },
{ 'zh-CN': '值不在范围中(NotIn)', 'en-US': 'NOTIN', value: '$notIn' },
{ 'zh-CN': '文本包含(%)', 'en-US': 'LIKE', value: '$like' },
{ 'zh-CN': '文本左包含(%#)', 'en-US': 'LIFTLIKE', value: '$startsWith' },
{ 'zh-CN': '文本右包含(#%)', 'en-US': 'RIGHTLIKE', value: '$endsWith' },
// { 'zh-CN': '', en: 'EXISTS', value: '$exists' },
// { 'zh-CN': '', en: 'NOTEXISTS', value: '$notExists' }
];
/**
* 获取语言文本
*
* @return {string}
* @memberof FilterMode
*/
getLabel(mode: any): string {
if(this.$i18n.locale) {
return mode[this.$i18n.locale];
}
return mode['zh-CN'];
}
/**
* 值改变
*
......
.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;
width: 100%;
>div {
margin-right: 10px;
}
......@@ -33,10 +11,20 @@
margin-right: 0;
}
.filter-tree-action {
margin-left: 20px;
display: none;
align-items: center;
.ivu-btn {
margin-right: 5px;
}
.ivu-icon-md-close {
color: red;
font-size: 24px;
}
}
}
.filter-tree-item:hover {
.filter-tree-action {
display: flex;
}
}
}
......
<template>
<el-tree class="filter-tree" :data="treeItems" :props="defaultProps" :expand-on-click-node="false" default-expand-all>
<el-tree class="filter-tree" :data="treeItems" :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')">
<template v-if="Object.is(data.label, '$and') || Object.is(data.label, '$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 size="small" v-model="data.label" :disabled="data.isroot">
<el-option v-for="mode in relationModes" :key="mode.value" :label="getLabel(mode)" :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>
<icon v-if="!data.isroot" type="md-close" @click="onRemoveItem(node, data)"/>
</div>
</div>
</template>
......@@ -28,7 +29,7 @@
<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>
<icon type="md-close" @click="onRemoveItem(node, data)"/>
</div>
</div>
</template>
......@@ -47,24 +48,44 @@ import FilterMode from './filter-mode.vue';
})
export default class FilterTree extends Vue {
/**
* 数据集
*
* @type {*}
* @memberof FilterTree
*/
@Prop() datas: any;
/**
* 过滤项集合
*
* @type {*}
* @memberof FilterTree
*/
@Prop() fields: any;
protected defaultProps: any = {
children: 'items',
label: 'name'
};
/**
* 组条件集合
*
* @type {*}
* @memberof FilterTree
*/
protected relationModes: any[] = [
{ zh: '并且', en: 'AND', value: '$and' },
{ zh: '或', en: 'OR', value: '$or' }
{ 'zh-CN': '并且', 'en-US': 'AND', value: '$and' },
{ 'zh-CN': '或', 'en-US': 'OR', value: '$or' }
];
/**
* 树数据集合
*
* @type {*}
* @memberof FilterTree
*/
get treeItems() {
let root: any = {
name: '$and',
items: this.datas
label: '$and',
isroot: true,
children: this.datas
};
if(this.datas.length == 0) {
this.onAddItem(root);
......@@ -73,35 +94,72 @@ export default class FilterTree extends Vue {
return [root];
}
/**
* 获取语言文本
*
* @return {string}
* @memberof FilterTree
*/
getLabel(mode: any): string {
if(this.$i18n.locale) {
return mode[this.$i18n.locale];
}
return mode['zh-CN'];
}
/**
* 属性变化
*
* @return {*}
* @memberof FilterTree
*/
public onFieldChange(data: any) {
if(!data.mode) {
data.mode = '$eq';
}
}
/**
* 添加条件
*
* @return {*}
* @memberof FilterTree
*/
public onAddItem(data: any) {
if(data && data.items) {
data.items.push({
if(data && data.children) {
data.children.push({
field: null,
mode: null
});
}
}
/**
* 添加组
*
* @return {*}
* @memberof FilterTree
*/
public onAddGroup(data: any) {
if(data && data.items) {
data.items.push({
name: '$and',
items: []
if(data && data.children) {
data.children.push({
label: '$and',
children: []
})
}
}
/**
* 删除条件/组
*
* @return {*}
* @memberof FilterTree
*/
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)
if(pData.children.indexOf(data) >= 0) {
pData.children.splice(pData.children.indexOf(data), 1)
}
}
}
......
......@@ -48,8 +48,7 @@ export default class DictCatalogServiceBase extends EntityService {
* @memberof DictCatalogServiceBase
*/
public async Select(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = await Http.getInstance().get(`/dictcatalogs/${context.dictcatalog}/select`,isloading);
return res;
return Http.getInstance().get(`/dictcatalogs/${context.dictcatalog}/select`,isloading);
}
/**
......@@ -133,8 +132,7 @@ export default class DictCatalogServiceBase extends EntityService {
* @memberof DictCatalogServiceBase
*/
public async Remove(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = await Http.getInstance().delete(`/dictcatalogs/${context.dictcatalog}`,isloading);
return res;
return Http.getInstance().delete(`/dictcatalogs/${context.dictcatalog}`,isloading);
}
/**
......@@ -178,8 +176,7 @@ export default class DictCatalogServiceBase extends EntityService {
* @memberof DictCatalogServiceBase
*/
public async CheckKey(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = await Http.getInstance().post(`/dictcatalogs/${context.dictcatalog}/checkkey`,data,isloading);
return res;
return Http.getInstance().post(`/dictcatalogs/${context.dictcatalog}/checkkey`,data,isloading);
}
/**
......@@ -225,7 +222,6 @@ export default class DictCatalogServiceBase extends EntityService {
*/
public async FetchDefault(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let tempData:any = JSON.parse(JSON.stringify(data));
let res:any = await Http.getInstance().get(`/dictcatalogs/fetchdefault`,tempData,isloading);
return res;
return Http.getInstance().get(`/dictcatalogs/fetchdefault`,tempData,isloading);
}
}
\ No newline at end of file
......@@ -49,10 +49,9 @@ export default class DictOptionServiceBase extends EntityService {
*/
public async Select(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.dictcatalog && context.dictoption){
let res:any = await Http.getInstance().get(`/dictcatalogs/${context.dictcatalog}/dictoptions/${context.dictoption}/select`,isloading);
return Http.getInstance().get(`/dictcatalogs/${context.dictcatalog}/dictoptions/${context.dictoption}/select`,isloading);
}
let res:any = await Http.getInstance().get(`/dictoptions/${context.dictoption}/select`,isloading);
return res;
return Http.getInstance().get(`/dictoptions/${context.dictoption}/select`,isloading);
}
/**
......@@ -76,6 +75,7 @@ export default class DictOptionServiceBase extends EntityService {
}
let tempContext:any = JSON.parse(JSON.stringify(context));
let res:any = await Http.getInstance().post(`/dictcatalogs/${context.dictcatalog}/dictoptions`,data,isloading);
return res;
}
let masterData:any = {};
Object.assign(data,masterData);
......@@ -104,6 +104,7 @@ export default class DictOptionServiceBase extends EntityService {
let masterData:any = {};
Object.assign(data,masterData);
let res:any = await Http.getInstance().put(`/dictcatalogs/${context.dictcatalog}/dictoptions/${context.dictoption}`,data,isloading);
return res;
}
let masterData:any = {};
Object.assign(data,masterData);
......@@ -122,10 +123,9 @@ export default class DictOptionServiceBase extends EntityService {
*/
public async Remove(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.dictcatalog && context.dictoption){
let res:any = await Http.getInstance().delete(`/dictcatalogs/${context.dictcatalog}/dictoptions/${context.dictoption}`,isloading);
return Http.getInstance().delete(`/dictcatalogs/${context.dictcatalog}/dictoptions/${context.dictoption}`,isloading);
}
let res:any = await Http.getInstance().delete(`/dictoptions/${context.dictoption}`,isloading);
return res;
return Http.getInstance().delete(`/dictoptions/${context.dictoption}`,isloading);
}
/**
......@@ -140,6 +140,7 @@ export default class DictOptionServiceBase extends EntityService {
public async Get(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.dictcatalog && context.dictoption){
let res:any = await Http.getInstance().get(`/dictcatalogs/${context.dictcatalog}/dictoptions/${context.dictoption}`,isloading);
return res;
}
let res:any = await Http.getInstance().get(`/dictoptions/${context.dictoption}`,isloading);
return res;
......@@ -158,6 +159,7 @@ export default class DictOptionServiceBase extends EntityService {
if(context.dictcatalog && true){
let res:any = await Http.getInstance().get(`/dictcatalogs/${context.dictcatalog}/dictoptions/getdraft`,isloading);
res.data.dictoption = data.dictoption;
return res;
}
let res:any = await Http.getInstance().get(`/dictoptions/getdraft`,isloading);
res.data.dictoption = data.dictoption;
......@@ -178,10 +180,10 @@ export default class DictOptionServiceBase extends EntityService {
let masterData:any = {};
Object.assign(data,masterData);
let res:any = await Http.getInstance().post(`/dictcatalogs/${context.dictcatalog}/dictoptions/${context.dictoption}/checkkey`,data,isloading);
}
let res:any = await Http.getInstance().post(`/dictoptions/${context.dictoption}/checkkey`,data,isloading);
return res;
}
return Http.getInstance().post(`/dictoptions/${context.dictoption}/checkkey`,data,isloading);
}
/**
* Save接口方法
......@@ -197,6 +199,7 @@ export default class DictOptionServiceBase extends EntityService {
let masterData:any = {};
Object.assign(data,masterData);
let res:any = await Http.getInstance().post(`/dictcatalogs/${context.dictcatalog}/dictoptions/${context.dictoption}/save`,data,isloading);
return res;
}
let masterData:any = {};
Object.assign(data,masterData);
......@@ -216,10 +219,9 @@ export default class DictOptionServiceBase extends EntityService {
public async FetchDefault(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.dictcatalog && true){
let tempData:any = JSON.parse(JSON.stringify(data));
let res:any = await Http.getInstance().get(`/dictcatalogs/${context.dictcatalog}/dictoptions/fetchdefault`,tempData,isloading);
return Http.getInstance().get(`/dictcatalogs/${context.dictcatalog}/dictoptions/fetchdefault`,tempData,isloading);
}
let tempData:any = JSON.parse(JSON.stringify(data));
let res:any = await Http.getInstance().get(`/dictoptions/fetchdefault`,tempData,isloading);
return res;
return Http.getInstance().get(`/dictoptions/fetchdefault`,tempData,isloading);
}
}
\ No newline at end of file
......@@ -52,8 +52,6 @@ public interface IDictCatalogService extends IService<DictCatalog>{
*/
boolean execute(String sql, Map param);
}
......@@ -54,8 +54,6 @@ public interface IDictOptionService extends IService<DictOption>{
*/
boolean execute(String sql, Map param);
}
......@@ -23,7 +23,7 @@ import java.util.Map;
* 实体属性默认值切面,只有新建(Create)时才会填充默认值
*/
@Aspect
@Order(0)
@Order(50)
@Component
public class DEFieldDefaultValueAspect
{
......
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;
......@@ -24,7 +23,7 @@ import java.lang.reflect.Field;
* 数据库版本检查
*/
@Aspect
@Order(0)
@Order(50)
@Component
public class VersionCheckAspect
{
......@@ -33,22 +32,40 @@ public class VersionCheckAspect
@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))
if(StringUtils.isEmpty(versionField))
return;
versionCheck(versionCheck,point.getTarget(),dto,id);
}
@SneakyThrows
@Before("execution(* cn.ibizlab.*.rest.*.updateBy*(..)) && @annotation(versionCheck)")
public void BeforeUpdateBy(JoinPoint point, VersionCheck versionCheck){
Object[] args = point.getArgs();
Object id=args[1];
Object dto=args[2];
if(ObjectUtils.isEmpty(id) || ObjectUtils.isEmpty(dto))
return;
String versionField=versionCheck.versionfield();
if(StringUtils.isEmpty(versionField))
return;
versionCheck(versionCheck,point.getTarget(),dto,id);
}
private void versionCheck(VersionCheck versionCheck,Object resource,Object dto,Object id ){
EvaluationContext context = new StandardEvaluationContext();
context.setVariable("dto",dto);
Expression newExp = parser.parseExpression(String.format("#dto.%s",versionField));
Expression newExp = parser.parseExpression(String.format("#dto.%s",versionCheck.versionfield()));
Object newVersion=newExp.getValue(context);
if(ObjectUtils.isEmpty(newVersion))
return;
//进行版本检查
Object oldVersion =getDBVersion(versionCheck,getService(point.getTarget(),versionCheck.entity()),id);
Object oldVersion =getDBVersion(versionCheck,getService(resource,versionCheck.entity()),id);
if(!ObjectUtils.isEmpty(oldVersion)){
if(RuleUtils.gt(newVersion,oldVersion))
throw new BadRequestAlertException("数据已变更,可能后台数据已被修改,请重新加载数据","VersionCheckAspect","versionCheck");
......
......@@ -92,7 +92,7 @@ public class DEFieldCacheMap {
if(cacheDEField.containsKey(className))
return cacheDEField.get(className);
else{
DEFieldCacheMap.getFieldMap(clazz);
DEFieldCacheMap.getFieldMap(className);
return cacheDEField.get(className);
}
}
......@@ -109,7 +109,7 @@ public class DEFieldCacheMap {
if(cacheDEKeyField.containsKey(className))
return cacheDEKeyField.get(className);
else{
DEFieldCacheMap.getFieldMap(clazz);
DEFieldCacheMap.getFieldMap(className);
return cacheDEKeyField.get(className);
}
}
......@@ -127,7 +127,7 @@ public class DEFieldCacheMap {
if(cacheList.containsKey(className))
return cacheList.get(className);
else{
DEFieldCacheMap.getFieldMap(clazz);
DEFieldCacheMap.getFieldMap(className);
return cacheList.get(className);
}
}
......@@ -155,7 +155,7 @@ public class DEFieldCacheMap {
if(cacheKey.containsKey(className))
return cacheKey.get(className);
else{
DEFieldCacheMap.getFieldMap(clazz);
DEFieldCacheMap.getFieldMap(className);
return cacheKey.get(className);
}
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册