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

ibizdev提交

上级 df88a3fd
......@@ -23,7 +23,7 @@
</ul>
</template>
<template v-if="hasImported === true && importDataArray.length === 0">
<span class="font-class">{{isUploading === true?$t('info.importing')+"......":$t('info.completed')}}</span>
<span class="font-class">{{isUploading === true?$t('info.importing')+"......":promptInfo}}</span>
</template>
</div>
</el-row>
......@@ -327,6 +327,7 @@ export default class AppDataUploadView extends Vue {
return;
}
this.importSuccessData = result.data;
this.promptInfo = (this.$t('info.completed') as string);
this.isUploading = false;
})
}).catch((error:any) =>{
......
......@@ -17,6 +17,7 @@ import cn.ibizlab.util.enums.DEPredefinedFieldType;
import cn.ibizlab.util.enums.DEFieldDefaultValueType;
import java.io.Serializable;
import lombok.Data;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;
......@@ -24,13 +25,12 @@ 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 org.springframework.data.annotation.Transient;
/**
* 大数据 [数据字典] 对象
*/
@Data
@Document(collection = "ibzdict")
public class IBZDict implements Serializable {
public class IBZDict extends EntityBase implements Serializable {
/**
* 字典标识
......@@ -39,7 +39,6 @@ public class IBZDict implements Serializable {
@DEField(isKeyField=true)
@JSONField(name = "dictid")
@JsonProperty("dictid")
@Field(name = "ibzdictid")
private String dictid;
/**
......@@ -53,7 +52,7 @@ public class IBZDict implements Serializable {
/**
* 逻辑有效标志
*/
@DEField(preType = DEPredefinedFieldType.LOGICVALID)
@DEField(preType = DEPredefinedFieldType.LOGICVALID, logicval = "1" , logicdelval="0")
@JSONField(name = "enable")
@JsonProperty("enable")
@Field(name = "enable")
......
......@@ -17,13 +17,14 @@ import cn.ibizlab.util.enums.DEPredefinedFieldType;
import cn.ibizlab.util.enums.DEFieldDefaultValueType;
import java.io.Serializable;
import lombok.Data;
import org.springframework.data.annotation.Transient;
/**
* ServiceApi [字典项目] 对象
*/
@Data
public class IBZDictItem implements Serializable {
public class IBZDictItem extends EntityBase implements Serializable {
/**
* 字典项目标识
......
......@@ -33,5 +33,17 @@ public @interface DEField
* @return
*/
DEPredefinedFieldType preType() default DEPredefinedFieldType.DEFAULT;
/**
* 逻辑删除有效值
* @return
*/
String logicval() default "";
/**
* 逻辑删除无效值
* @return
*/
String logicdelval() default "";
}
......@@ -2,6 +2,7 @@ package cn.ibizlab.util.aspect;
import cn.ibizlab.util.annotation.DEField;
import cn.ibizlab.util.enums.DEFieldDefaultValueType;
import cn.ibizlab.util.enums.DEPredefinedFieldType;
import cn.ibizlab.util.helper.DEFieldCacheMap;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
......@@ -13,6 +14,8 @@ import org.springframework.util.StringUtils;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -35,6 +38,16 @@ public class DEFieldDefaultValueAspect
fillDEFieldDefaultValue(point);
}
/**
* 更新数据切入点
* @param point
* @throws Exception
*/
@Before(value = "execution(* cn.ibizlab.core.*.service.*.update(..))")
public void BeforeUpdate(JoinPoint point) throws Exception {
fillDEFieldDefaultValue(point);
}
/**
* 保存数据切入点
* @param point
......@@ -113,7 +126,7 @@ public class DEFieldDefaultValueAspect
//从属性列表中过滤出预置属性
Map<Field, DEField> deFields = this.SearchDEField(className);
//填充预置属性
fillDEField(obj, deFields);
fillDEField(obj, deFields,joinPoint);
return true;
}
return true;
......@@ -141,61 +154,135 @@ public class DEFieldDefaultValueAspect
* 填充系统预置属性
* @param et 当前实体对象
*/
private void fillDEField(Object et, Map<Field, DEField> deFields) throws Exception {
private void fillDEField(Object et, Map<Field, DEField> deFields, JoinPoint joinPoint) throws Exception {
if(deFields.size()==0)
return ;
for (Map.Entry<Field, DEField> entry : deFields.entrySet()) {
//获取预置属性
Field deField=entry.getKey();
String filename=deField.getName();
//获取预置属性注解
String fileName=deField.getName();
//获取注解
DEField fieldAnnotation=entry.getValue();
//获取预置属性类型
//获取默认值类型
DEFieldDefaultValueType deFieldType=fieldAnnotation.defaultValueType();
//获取属性默认值
String deFieldDefaultValue = fieldAnnotation.defaultValue();
//获取预置属性类型
DEPredefinedFieldType predefinedFieldType = fieldAnnotation.preType();
//获取预置属性的get、set方法及字段值
PropertyDescriptor field = new PropertyDescriptor(filename, et.getClass());
Method fieldSetMethod = field.getWriteMethod();
Method fieldGetMethod = field.getReadMethod();
Object fieldValue = fieldGetMethod.invoke(et);
//为默认值属性进行赋值
if(org.springframework.util.StringUtils.isEmpty(fieldValue)){
//填充直接值及其余默认值类型
if( (deFieldType== DEFieldDefaultValueType.NONE && !StringUtils.isEmpty(deFieldDefaultValue)) || (deFieldType != DEFieldDefaultValueType.NONE) ){
switch(deFieldType){//根据注解给预置属性填充值
case SESSION:
break;
case APPLICATION:
break;
case UNIQUEID:
break;
case CONTEXT:
break;
case PARAM:
break;
case OPERATOR:
break;
case OPERATORNAME:
break;
case CURTIME:
break;
case APPDATA:
break;
case NONE:
//对字段值进行类型转换
Object deFieldDefaultValueObj=fieldValueConvert(deFieldDefaultValue,field);
fieldSetMethod.invoke(et,deFieldDefaultValueObj);
break;
}
//填充系统默认值
if( deFieldType!= DEFieldDefaultValueType.NONE || (!StringUtils.isEmpty(deFieldDefaultValue)) ){
fillFieldDefaultValue(fileName, deFieldType, deFieldDefaultValue, et) ;
}
//填充系统预置属性
if(predefinedFieldType != DEPredefinedFieldType.NONE){
fillPreFieldValue( fileName, predefinedFieldType , et ,joinPoint);
}
}
}
/**
* 填充属性默认值
* @param fileName 实体属性名
* @param deFieldType 默认值类型
* @param deFieldDefaultValue 默认值
* @param et 当前实体对象
* @throws Exception
*/
private void fillFieldDefaultValue(String fileName , DEFieldDefaultValueType deFieldType,String deFieldDefaultValue,Object et) throws Exception {
//获取当前所需填充属性的get、set方法及字段值
PropertyDescriptor field = new PropertyDescriptor(fileName, et.getClass());
Method fieldSetMethod = field.getWriteMethod();
Method fieldGetMethod = field.getReadMethod();
Object fieldValue = fieldGetMethod.invoke(et);
if(org.springframework.util.StringUtils.isEmpty(fieldValue)){
//填充直接值及其余默认值类型
if( (deFieldType== DEFieldDefaultValueType.NONE && !StringUtils.isEmpty(deFieldDefaultValue)) || (deFieldType != DEFieldDefaultValueType.NONE) ){
switch(deFieldType){//根据注解给预置属性填充值
case SESSION:
break;
case APPLICATION:
break;
case UNIQUEID:
break;
case CONTEXT:
break;
case PARAM:
break;
case OPERATOR:
break;
case OPERATORNAME:
break;
case CURTIME:
break;
case APPDATA:
break;
case NONE:
//对字段值进行类型转换
Object deFieldDefaultValueObj=fieldValueConvert(deFieldDefaultValue,field);
fieldSetMethod.invoke(et,deFieldDefaultValueObj);
break;
}
}
}
}
/**
* 填充系统预置属性
* @param fileName 实体属性名
* @param preFieldType 预置类型
* @param et 当前实体对象
* @throws Exception
*/
private void fillPreFieldValue(String fileName , DEPredefinedFieldType preFieldType ,Object et , JoinPoint joinPoint) throws Exception {
//当前操作行为
String actionName=joinPoint.getSignature().getName();
//获取当前所需填充属性的get、set方法及字段值
PropertyDescriptor field = new PropertyDescriptor(fileName, et.getClass());
Method fieldSetMethod = field.getWriteMethod();
Method fieldGetMethod = field.getReadMethod();
Object fieldValue = fieldGetMethod.invoke(et);
//为预置属性进行赋值
if( (actionName.equalsIgnoreCase("create") && org.springframework.util.StringUtils.isEmpty(fieldValue) )||
preFieldType== DEPredefinedFieldType.UPDATEDATE|| preFieldType== DEPredefinedFieldType.UPDATEMAN||
preFieldType== DEPredefinedFieldType.UPDATEMANNAME){
switch(preFieldType){//根据注解给预置属性填充值
case CREATEMAN:
break;
case CREATEMANNAME:
break;
case UPDATEMAN:
break;
case UPDATEMANNAME:
break;
case CREATEDATE:
fieldSetMethod.invoke(et,new Timestamp(new Date().getTime()));
break;
case UPDATEDATE:
fieldSetMethod.invoke(et,new Timestamp(new Date().getTime()));
case ORGID:
break;
case ORGNAME:
break;
case ORGSECTORID:
break;
case ORGSECTORNAME:
break;
case LOGICVALID:
break;
}
}
}
/**
* 值类型转换
* @param fieldValue
......
package cn.ibizlab.util.domain;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.util.AlternativeJdkIdGenerator;
import org.springframework.data.annotation.Transient;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
@Data
public class EntityBase implements Serializable {
@JsonIgnore
@JSONField(serialize = false)
@TableField(exist = false)
@Transient
private Set<String> focusNull;
public void modify(String field,Object val) {
if(val==null)
this.getFocusNull().add(field.toLowerCase());
......@@ -26,30 +22,21 @@ public class EntityBase implements Serializable {
this.getFocusNull().remove(field.toLowerCase());
}
public Set<String> getFocusNull() {
if(focusNull==null)
focusNull=new HashSet<>();
return focusNull;
}
public UpdateWrapper getUpdateWrapper(boolean clean) {
UpdateWrapper wrapper=new UpdateWrapper();
for(String nullField:getFocusNull()) {
wrapper.set(nullField,null);
}
if(clean)
focusNull.clear();
return wrapper;
}
public Serializable getDefaultKey(boolean gen)
{
return IdWorker.get32UUID();
public void setFocusNull(Set<String> focusNull) {
this.focusNull = focusNull;
}
public Serializable getDefaultKey(boolean gen) {
String Id=(new AlternativeJdkIdGenerator()).generateId().toString();
return gen?Id.replace("-", ""):Id;
}
}
package cn.ibizlab.util.domain;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
public class EntityMP extends EntityBase {
@JsonIgnore
@JSONField(serialize = false)
@TableField(exist = false)
private Set<String> focusNull;
@Override
public Set<String> getFocusNull() {
if(focusNull==null)
focusNull=new HashSet<>();
return focusNull;
}
@Override
public void setFocusNull(Set<String> focusNull) {
this.focusNull = focusNull;
}
public UpdateWrapper getUpdateWrapper(boolean clean) {
UpdateWrapper wrapper=new UpdateWrapper();
for(String nullField:getFocusNull()) {
wrapper.set(nullField,null);
}
if(clean)
focusNull.clear();
return wrapper;
}
@Override
public Serializable getDefaultKey(boolean gen) {
return IdWorker.get32UUID();
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册