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

ibizdev提交

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