提交 a204cd87 编写于 作者: zhouweidong's avatar zhouweidong

代码规范检查

上级 941741f5
...@@ -60,15 +60,17 @@ public class AuditAspect ...@@ -60,15 +60,17 @@ public class AuditAspect
request=((ServletRequestAttributes)requestAttributes).getRequest(); request=((ServletRequestAttributes)requestAttributes).getRequest();
} }
Object [] args = point.getArgs(); Object [] args = point.getArgs();
if(ObjectUtils.isEmpty(args) || args.length==0) if(ObjectUtils.isEmpty(args) || args.length==0) {
return; return;
}
Object serviceParam =args[0]; Object serviceParam =args[0];
if(serviceParam instanceof EntityBase){ if(serviceParam instanceof EntityBase){
EntityBase entity=(EntityBase)serviceParam;//创建数据 EntityBase entity=(EntityBase)serviceParam;
Map<String, Audit> auditFields= DEFieldCacheMap.getAuditFields(entity.getClass()); Map<String, Audit> auditFields= DEFieldCacheMap.getAuditFields(entity.getClass());
if(auditFields.size()==0)//是否有审计属性 //是否有审计属性
if(auditFields.size()==0) {
return; return;
}
String idField=DEFieldCacheMap.getDEKeyField(entity.getClass()); String idField=DEFieldCacheMap.getDEKeyField(entity.getClass());
Object idValue=""; Object idValue="";
...@@ -95,8 +97,9 @@ public class AuditAspect ...@@ -95,8 +97,9 @@ public class AuditAspect
Object serviceObj=point.getTarget(); Object serviceObj=point.getTarget();
Object args[]=point.getArgs(); Object args[]=point.getArgs();
if(ObjectUtils.isEmpty(args) || args.length==0) if(ObjectUtils.isEmpty(args) || args.length==0) {
return point.proceed(); return point.proceed();
}
Object arg=args[0]; Object arg=args[0];
if(arg instanceof EntityBase){ if(arg instanceof EntityBase){
...@@ -104,15 +107,17 @@ public class AuditAspect ...@@ -104,15 +107,17 @@ public class AuditAspect
Map<String, Audit> auditFields= DEFieldCacheMap.getAuditFields(entity.getClass()); Map<String, Audit> auditFields= DEFieldCacheMap.getAuditFields(entity.getClass());
//是否有审计属性 //是否有审计属性
if(auditFields.size()==0) if(auditFields.size()==0) {
return point.proceed(); return point.proceed();
}
String idField=DEFieldCacheMap.getDEKeyField(entity.getClass()); String idField=DEFieldCacheMap.getDEKeyField(entity.getClass());
Object idValue=""; Object idValue="";
if(!StringUtils.isEmpty(idField)){ if(!StringUtils.isEmpty(idField)){
idValue=entity.get(idField); idValue=entity.get(idField);
} }
if(ObjectUtils.isEmpty(idValue)) if(ObjectUtils.isEmpty(idValue)) {
return point.proceed(); return point.proceed();
}
//获取更新前实体 //获取更新前实体
EntityBase beforeEntity=getEntity(serviceObj,idValue); EntityBase beforeEntity=getEntity(serviceObj,idValue);
...@@ -142,8 +147,9 @@ public class AuditAspect ...@@ -142,8 +147,9 @@ public class AuditAspect
Object serviceObj=point.getTarget(); Object serviceObj=point.getTarget();
Object args[]=point.getArgs(); Object args[]=point.getArgs();
if(ObjectUtils.isEmpty(args) || args.length==0) if(ObjectUtils.isEmpty(args) || args.length==0) {
return point.proceed(); return point.proceed();
}
Object idValue=args[0]; Object idValue=args[0];
EntityBase entity=getEntity(serviceObj,idValue); EntityBase entity=getEntity(serviceObj,idValue);
......
...@@ -87,8 +87,9 @@ public class DEFieldDefaultValueAspect ...@@ -87,8 +87,9 @@ public class DEFieldDefaultValueAspect
Map<String, DEField> deFields = DEFieldCacheMap.getDEFields(obj.getClass()); Map<String, DEField> deFields = DEFieldCacheMap.getDEFields(obj.getClass());
AuthenticationUser curUser = AuthenticationUser.getAuthenticationUser(); AuthenticationUser curUser = AuthenticationUser.getAuthenticationUser();
String keyField=DEFieldCacheMap.getDEKeyField(obj.getClass()); String keyField=DEFieldCacheMap.getDEKeyField(obj.getClass());
if(StringUtils.isEmpty(keyField)) if(StringUtils.isEmpty(keyField)) {
return true; return true;
}
fillDEField((EntityBase)obj, deFields,actionName,curUser,keyField); fillDEField((EntityBase)obj, deFields,actionName,curUser,keyField);
} }
else if (obj instanceof List) { else if (obj instanceof List) {
...@@ -101,9 +102,10 @@ public class DEFieldDefaultValueAspect ...@@ -101,9 +102,10 @@ public class DEFieldDefaultValueAspect
deFields = DEFieldCacheMap.getDEFields(item.getClass()); deFields = DEFieldCacheMap.getDEFields(item.getClass());
curUser = AuthenticationUser.getAuthenticationUser(); curUser = AuthenticationUser.getAuthenticationUser();
keyField=DEFieldCacheMap.getDEKeyField(item.getClass()); keyField=DEFieldCacheMap.getDEKeyField(item.getClass());
if(StringUtils.isEmpty(keyField)) if(StringUtils.isEmpty(keyField)) {
return true; return true;
} }
}
fillDEField((EntityBase)item, deFields,actionName,curUser,keyField); fillDEField((EntityBase)item, deFields,actionName,curUser,keyField);
} }
} }
...@@ -119,14 +121,14 @@ public class DEFieldDefaultValueAspect ...@@ -119,14 +121,14 @@ public class DEFieldDefaultValueAspect
* @param et 当前实体对象 * @param et 当前实体对象
*/ */
private void fillDEField(EntityBase et, Map<String, DEField> deFields, String actionName,AuthenticationUser curUser,String keyField) throws Exception { private void fillDEField(EntityBase et, Map<String, DEField> deFields, String actionName,AuthenticationUser curUser,String keyField) throws Exception {
if(deFields.size()==0) if(deFields.size()==0) {
return ; return;
}
if(actionName.toLowerCase().startsWith("save")) { if(actionName.toLowerCase().startsWith("save")) {
if(ObjectUtils.isEmpty(et.get(keyField))) if(ObjectUtils.isEmpty(et.get(keyField))) {
actionName="create"; actionName="create";
} }
}
for (Map.Entry<String, DEField> entry : deFields.entrySet()) { for (Map.Entry<String, DEField> entry : deFields.entrySet()) {
String fieldname=entry.getKey(); String fieldname=entry.getKey();
//获取注解 //获取注解
......
...@@ -127,11 +127,13 @@ public class DupCheckAspect { ...@@ -127,11 +127,13 @@ public class DupCheckAspect {
* @param value * @param value
*/ */
private void setValue(Object entity , QueryFilter filter, String fieldName, Object value){ private void setValue(Object entity , QueryFilter filter, String fieldName, Object value){
if(ObjectUtils.isEmpty(value)) if(ObjectUtils.isEmpty(value)) {
filter.isnull(DEFieldCacheMap.getFieldColumnName(entity.getClass(), fieldName)); filter.isnull(DEFieldCacheMap.getFieldColumnName(entity.getClass(), fieldName));
else }
else {
filter.eq(DEFieldCacheMap.getFieldColumnName(entity.getClass(), fieldName),value); filter.eq(DEFieldCacheMap.getFieldColumnName(entity.getClass(), fieldName),value);
} }
}
} }
</#if> </#if>
......
...@@ -61,8 +61,9 @@ public class ESAspect ...@@ -61,8 +61,9 @@ public class ESAspect
Object service=point.getTarget(); Object service=point.getTarget();
String action=point.getSignature().getName(); String action=point.getSignature().getName();
Object [] args = point.getArgs(); Object [] args = point.getArgs();
if(ObjectUtils.isEmpty(args) || args.length==0 || StringUtils.isEmpty(action)) if(ObjectUtils.isEmpty(args) || args.length==0 || StringUtils.isEmpty(action)) {
return; return;
}
EvaluationContext exServiceCtx = new StandardEvaluationContext(); EvaluationContext exServiceCtx = new StandardEvaluationContext();
exServiceCtx.setVariable("service",service); exServiceCtx.setVariable("service",service);
......
...@@ -98,15 +98,17 @@ public class RocketMQAspect ...@@ -98,15 +98,17 @@ public class RocketMQAspect
Object entity=null; Object entity=null;
String action=point.getSignature().getName(); String action=point.getSignature().getName();
Object [] args = point.getArgs(); Object [] args = point.getArgs();
if(ObjectUtils.isEmpty(args) || args.length==0 || StringUtils.isEmpty(action)) if(ObjectUtils.isEmpty(args) || args.length==0 || StringUtils.isEmpty(action)) {
return entity; return entity;
}
Object arg=args[0]; Object arg=args[0];
if(arg instanceof EntityBase || arg instanceof List) if(arg instanceof EntityBase || arg instanceof List) {
return arg; return arg;
else }
else {
return null; return null;
} }
}
/** /**
* 发送消息 * 发送消息
......
...@@ -43,11 +43,13 @@ public class VersionCheckAspect ...@@ -43,11 +43,13 @@ public class VersionCheckAspect
Object[] args = point.getArgs(); Object[] args = point.getArgs();
Object id=args[0]; Object id=args[0];
Object dto=args[1]; Object dto=args[1];
if(ObjectUtils.isEmpty(id) || ObjectUtils.isEmpty(dto)) if(ObjectUtils.isEmpty(id) || ObjectUtils.isEmpty(dto)) {
return; return;
}
String versionField=versionCheck.versionfield(); String versionField=versionCheck.versionfield();
if(StringUtils.isEmpty(versionField)) if(StringUtils.isEmpty(versionField)) {
return; return;
}
versionCheck(versionCheck,point.getTarget(),dto,id); versionCheck(versionCheck,point.getTarget(),dto,id);
} }
...@@ -58,11 +60,13 @@ public class VersionCheckAspect ...@@ -58,11 +60,13 @@ public class VersionCheckAspect
if(args.length>=2){ if(args.length>=2){
Object id=args[args.length-2]; Object id=args[args.length-2];
Object dto=args[args.length-1]; Object dto=args[args.length-1];
if(ObjectUtils.isEmpty(id) || ObjectUtils.isEmpty(dto)) if(ObjectUtils.isEmpty(id) || ObjectUtils.isEmpty(dto)) {
return; return;
}
String versionField=versionCheck.versionfield(); String versionField=versionCheck.versionfield();
if(StringUtils.isEmpty(versionField)) if(StringUtils.isEmpty(versionField)) {
return; return;
}
versionCheck(versionCheck,point.getTarget(),dto,id); versionCheck(versionCheck,point.getTarget(),dto,id);
} }
} }
...@@ -73,19 +77,22 @@ public class VersionCheckAspect ...@@ -73,19 +77,22 @@ public class VersionCheckAspect
//忽略版本检查 //忽略版本检查
Expression dtoParamsExp = parser.parseExpression("#dto.extensionparams"); Expression dtoParamsExp = parser.parseExpression("#dto.extensionparams");
Map dtoParam=dtoParamsExp.getValue(context, Map.class); Map dtoParam=dtoParamsExp.getValue(context, Map.class);
if(!ObjectUtils.isEmpty(dtoParam) && !ObjectUtils.isEmpty(dtoParam.get(IgnoreField)) && dtoParam.get(IgnoreField).equals(1)) if(!ObjectUtils.isEmpty(dtoParam) && !ObjectUtils.isEmpty(dtoParam.get(IgnoreField)) && dtoParam.get(IgnoreField).equals(1)) {
return; return;
}
Expression newExp = parser.parseExpression(String.format("#dto.%s",versionCheck.versionfield())); Expression newExp = parser.parseExpression(String.format("#dto.%s",versionCheck.versionfield()));
Object newVersion=newExp.getValue(context); Object newVersion=newExp.getValue(context);
if(ObjectUtils.isEmpty(newVersion)) if(ObjectUtils.isEmpty(newVersion)) {
return; return;
}
//进行版本检查 //进行版本检查
Object oldVersion =getDBVersion(versionCheck,getService(resource,versionCheck.entity()),id); Object oldVersion =getDBVersion(versionCheck,getService(resource,versionCheck.entity()),id);
if(!ObjectUtils.isEmpty(oldVersion)){ if(!ObjectUtils.isEmpty(oldVersion)){
if(RuleUtils.gt(newVersion,oldVersion)) if(RuleUtils.gt(newVersion,oldVersion)) {
throw new BadRequestAlertException("数据已变更,可能后台数据已被修改,请重新加载数据","VersionCheckAspect","versionCheck"); throw new BadRequestAlertException("数据已变更,可能后台数据已被修改,请重新加载数据","VersionCheckAspect","versionCheck");
} }
} }
}
/** /**
* 获取实体服务对象 * 获取实体服务对象
......
...@@ -24,33 +24,39 @@ public class DTOBase implements Serializable { ...@@ -24,33 +24,39 @@ public class DTOBase implements Serializable {
public void modify(String field,Object val) { public void modify(String field,Object val) {
if(val==null) if(val==null) {
this.getFocusNull(true).add(field.toLowerCase()); this.getFocusNull(true).add(field.toLowerCase());
else }
else {
this.getFocusNull(true).remove(field.toLowerCase()); this.getFocusNull(true).remove(field.toLowerCase());
} }
}
public Set<String> getFocusNull() { public Set<String> getFocusNull() {
if(focusNull==null) if(focusNull==null) {
focusNull=new HashSet<>(); focusNull=new HashSet<>();
}
if(focusNull.size()>0 && extensionparams.containsKey("dirtyflagenable")) if(focusNull.size()>0 && extensionparams.containsKey("dirtyflagenable"))
{ {
Set<String> nocheck=new HashSet<>(); Set<String> nocheck=new HashSet<>();
for(String key:focusNull) for(String key:focusNull)
{ {
if(!extensionparams.containsKey(key+"dirtyflag")) if(!extensionparams.containsKey(key+"dirtyflag")) {
nocheck.add(key); nocheck.add(key);
} }
for(String key:nocheck) }
for(String key:nocheck) {
focusNull.remove(key); focusNull.remove(key);
} }
}
return focusNull; return focusNull;
} }
private Set<String> getFocusNull(boolean newflag) { private Set<String> getFocusNull(boolean newflag) {
if(focusNull==null) if(focusNull==null) {
focusNull=new HashSet<>(); focusNull=new HashSet<>();
}
return focusNull; return focusNull;
} }
......
...@@ -27,8 +27,9 @@ public class EntityBase implements Serializable { ...@@ -27,8 +27,9 @@ public class EntityBase implements Serializable {
private Set<String> focusNull; private Set<String> focusNull;
public Set<String> getFocusNull() { public Set<String> getFocusNull() {
if(focusNull==null) if(focusNull==null) {
focusNull=new HashSet<>(); focusNull=new HashSet<>();
}
return focusNull; return focusNull;
} }
...@@ -53,8 +54,9 @@ public class EntityBase implements Serializable { ...@@ -53,8 +54,9 @@ public class EntityBase implements Serializable {
private BeanMap getMap() private BeanMap getMap()
{ {
if(map==null) if(map==null) {
map=BeanMap.create(this); map=BeanMap.create(this);
}
return map; return map;
} }
...@@ -71,16 +73,15 @@ public class EntityBase implements Serializable { ...@@ -71,16 +73,15 @@ public class EntityBase implements Serializable {
this.extensionparams = extensionparams; this.extensionparams = extensionparams;
} }
public Object get(String field) { public Object get(String field) {
String fieldRealName=DEFieldCacheMap.getFieldRealName(this.getClass(),field); String fieldRealName=DEFieldCacheMap.getFieldRealName(this.getClass(),field);
if(!StringUtils.isEmpty(fieldRealName)) if(!StringUtils.isEmpty(fieldRealName)) {
return getMap().get(fieldRealName); return getMap().get(fieldRealName);
else }
else {
return this.extensionparams.get(field.toLowerCase()); return this.extensionparams.get(field.toLowerCase());
} }
}
@JsonAnyGetter @JsonAnyGetter
public Map<String , Object> any() { public Map<String , Object> any() {
...@@ -92,14 +93,17 @@ public class EntityBase implements Serializable { ...@@ -92,14 +93,17 @@ public class EntityBase implements Serializable {
field=field.toLowerCase(); field=field.toLowerCase();
String fieldRealName=DEFieldCacheMap.getFieldRealName(this.getClass(),field); String fieldRealName=DEFieldCacheMap.getFieldRealName(this.getClass(),field);
if(!StringUtils.isEmpty(fieldRealName)) { if(!StringUtils.isEmpty(fieldRealName)) {
if (value == null) if (value == null) {
getMap().put(fieldRealName, null); getMap().put(fieldRealName, null);
else }
else {
getMap().put(fieldRealName, DEFieldCacheMap.fieldValueOf(this.getClass(), fieldRealName, value)); getMap().put(fieldRealName, DEFieldCacheMap.fieldValueOf(this.getClass(), fieldRealName, value));
} }
else }
else {
this.extensionparams.put(field.toLowerCase(),value); this.extensionparams.put(field.toLowerCase(),value);
} }
}
/** /**
* 复制当前对象数据到目标对象 * 复制当前对象数据到目标对象
......
...@@ -8,25 +8,26 @@ import org.springframework.util.StringUtils; ...@@ -8,25 +8,26 @@ import org.springframework.util.StringUtils;
public class EntityMP extends EntityBase { public class EntityMP extends EntityBase {
public UpdateWrapper getUpdateWrapper(boolean clean) { public UpdateWrapper getUpdateWrapper(boolean clean) {
UpdateWrapper wrapper=new UpdateWrapper(); UpdateWrapper wrapper=new UpdateWrapper();
for(String nullField:getFocusNull()) { for(String nullField:getFocusNull()) {
wrapper.set(nullField,null); wrapper.set(nullField,null);
} }
if(clean) if(clean) {
getFocusNull().clear(); getFocusNull().clear();
}
return wrapper; return wrapper;
} }
@Override @Override
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());
else }
else {
this.getFocusNull().remove(field.toLowerCase()); this.getFocusNull().remove(field.toLowerCase());
} }
}
@Override @Override
public void reset(String field){ public void reset(String field){
...@@ -36,6 +37,5 @@ public class EntityMP extends EntityBase { ...@@ -36,6 +37,5 @@ public class EntityMP extends EntityBase {
getFocusNull().remove(resetField); getFocusNull().remove(resetField);
} }
} }
} }
...@@ -5,7 +5,5 @@ package ${pub.getPKGCodeName()}.util.domain; ...@@ -5,7 +5,5 @@ package ${pub.getPKGCodeName()}.util.domain;
public class EntityMongo extends EntityBase { public class EntityMongo extends EntityBase {
} }
...@@ -47,9 +47,9 @@ public class QueryBuildContext extends SearchContextBase implements ISearchConte ...@@ -47,9 +47,9 @@ public class QueryBuildContext extends SearchContextBase implements ISearchConte
*/ */
private QueryBuilder parseQueryFilter(QueryFilter queryFilter){ private QueryBuilder parseQueryFilter(QueryFilter queryFilter){
if( ObjectUtils.isEmpty(queryFilter.get$and()) && ObjectUtils.isEmpty(queryFilter.get$or()) && ObjectUtils.isEmpty(queryFilter.any())) if(ObjectUtils.isEmpty(queryFilter.get$and()) && ObjectUtils.isEmpty(queryFilter.get$or()) && ObjectUtils.isEmpty(queryFilter.any())) {
return null; return null;
}
QueryBuilder rsBuilder=QueryBuilder.start(); QueryBuilder rsBuilder=QueryBuilder.start();
QueryBuilder fieldBuilder=parseFieldMap(queryFilter.any()); QueryBuilder fieldBuilder=parseFieldMap(queryFilter.any());
QueryBuilder orBuilder=parseOrQueryFilter(queryFilter.get$or()); QueryBuilder orBuilder=parseOrQueryFilter(queryFilter.get$or());
...@@ -110,8 +110,9 @@ public class QueryBuildContext extends SearchContextBase implements ISearchConte ...@@ -110,8 +110,9 @@ public class QueryBuildContext extends SearchContextBase implements ISearchConte
* @return * @return
*/ */
private QueryBuilder parseFieldMap(Map<String , QueryFilter.SegmentCond> fieldMap) { private QueryBuilder parseFieldMap(Map<String , QueryFilter.SegmentCond> fieldMap) {
if(fieldMap.size()==0) if(fieldMap.size()==0) {
return null; return null;
}
QueryBuilder fieldBuilders=QueryBuilder.start(); QueryBuilder fieldBuilders=QueryBuilder.start();
for(Map.Entry<String, QueryFilter.SegmentCond> entry: fieldMap.entrySet()){ for(Map.Entry<String, QueryFilter.SegmentCond> entry: fieldMap.entrySet()){
getSegmentCondSql(entry.getKey(),entry.getValue(),fieldBuilders); getSegmentCondSql(entry.getKey(),entry.getValue(),fieldBuilders);
......
...@@ -66,8 +66,9 @@ public class QueryFilter { ...@@ -66,8 +66,9 @@ public class QueryFilter {
private Map<String,SegmentCond> getMap() private Map<String,SegmentCond> getMap()
{ {
if(map==null) if(map==null) {
map=new LinkedHashMap<>(); map=new LinkedHashMap<>();
}
return map; return map;
} }
...@@ -135,11 +136,12 @@ public class QueryFilter { ...@@ -135,11 +136,12 @@ public class QueryFilter {
} }
private QueryFilter op(String column, SegmentCond segmentCond) { private QueryFilter op(String column, SegmentCond segmentCond) {
if(this.getMap().containsKey(column)) {
if(this.getMap().containsKey(column))
((SegmentCond)this.getMap().get(column)).getMap().putAll(segmentCond.getMap()); ((SegmentCond)this.getMap().get(column)).getMap().putAll(segmentCond.getMap());
else }
else {
this.getMap().put(column,segmentCond); this.getMap().put(column,segmentCond);
}
return this; return this;
} }
...@@ -158,8 +160,9 @@ public class QueryFilter { ...@@ -158,8 +160,9 @@ public class QueryFilter {
private Map<String,Object> getMap() private Map<String,Object> getMap()
{ {
if(map==null) if(map==null) {
map=new LinkedHashMap<>(); map=new LinkedHashMap<>();
}
return map; return map;
} }
......
...@@ -40,17 +40,20 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch ...@@ -40,17 +40,20 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
int pageSize=getPageable().getPageSize(); int pageSize=getPageable().getPageSize();
//构造mybatis-plus分页 //构造mybatis-plus分页
if(StringUtils.isEmpty(currentPage) || StringUtils.isEmpty(pageSize)) if(StringUtils.isEmpty(currentPage) || StringUtils.isEmpty(pageSize)) {
page=new Page(1,Short.MAX_VALUE); page=new Page(1,Short.MAX_VALUE);
else }
else {
page=new Page(currentPage+1,pageSize); page=new Page(currentPage+1,pageSize);
}
//构造mybatis-plus排序 //构造mybatis-plus排序
Sort sort = getPageable().getSort(); Sort sort = getPageable().getSort();
Iterator<Sort.Order> it_sort = sort.iterator(); Iterator<Sort.Order> it_sort = sort.iterator();
if(ObjectUtils.isEmpty(it_sort)) if(ObjectUtils.isEmpty(it_sort)) {
return page; return page;
}
ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass(); ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass();
Class<T> type = (Class<T>)parameterizedType.getActualTypeArguments()[0]; Class<T> type = (Class<T>)parameterizedType.getActualTypeArguments()[0];
...@@ -98,9 +101,9 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch ...@@ -98,9 +101,9 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
* @return * @return
*/ */
private Consumer<QueryWrapper<T>> parseQueryFilter(QueryFilter queryFilter){ private Consumer<QueryWrapper<T>> parseQueryFilter(QueryFilter queryFilter){
if(queryFilter.any().size()==0 && queryFilter.get$or()==null && queryFilter.get$and()==null) {
if(queryFilter.any().size()==0 && queryFilter.get$or()==null && queryFilter.get$and()==null)
return null; return null;
}
Consumer<QueryWrapper<T>> consumer = queryWrapper -> { Consumer<QueryWrapper<T>> consumer = queryWrapper -> {
Consumer fieldConsumer=parseFieldMap(queryFilter.any()); Consumer fieldConsumer=parseFieldMap(queryFilter.any());
Consumer orConsumer=parseOrQueryFilter(queryFilter.get$or()); Consumer orConsumer=parseOrQueryFilter(queryFilter.get$or());
...@@ -124,7 +127,6 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch ...@@ -124,7 +127,6 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
* @return * @return
*/ */
private Consumer<QueryWrapper<T>> parseOrQueryFilter(List<QueryFilter> queryFilters) { private Consumer<QueryWrapper<T>> parseOrQueryFilter(List<QueryFilter> queryFilters) {
if(queryFilters==null || queryFilters.size()==0) if(queryFilters==null || queryFilters.size()==0)
return null; return null;
Consumer<QueryWrapper<T>> consumer = queryWrapper -> { Consumer<QueryWrapper<T>> consumer = queryWrapper -> {
...@@ -142,9 +144,9 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch ...@@ -142,9 +144,9 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
* @return * @return
*/ */
private Consumer<QueryWrapper<T>> parseAndQueryFilter(List<QueryFilter> queryFilters) { private Consumer<QueryWrapper<T>> parseAndQueryFilter(List<QueryFilter> queryFilters) {
if(queryFilters==null || queryFilters.size()==0) {
if(queryFilters==null || queryFilters.size()==0)
return null; return null;
}
Consumer<QueryWrapper<T>> consumer = queryWrapper -> { Consumer<QueryWrapper<T>> consumer = queryWrapper -> {
for(QueryFilter queryFilter: queryFilters){ for(QueryFilter queryFilter: queryFilters){
Consumer tempQueryWrapper=parseQueryFilter(queryFilter); Consumer tempQueryWrapper=parseQueryFilter(queryFilter);
...@@ -160,9 +162,9 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch ...@@ -160,9 +162,9 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
* @return * @return
*/ */
private Consumer<QueryWrapper<T>> parseFieldMap(Map<String , QueryFilter.SegmentCond> fieldMap) { private Consumer<QueryWrapper<T>> parseFieldMap(Map<String , QueryFilter.SegmentCond> fieldMap) {
if(fieldMap.size()==0) {
if(fieldMap.size()==0)
return null; return null;
}
Consumer<QueryWrapper<T>> consumer = queryWrapper -> { Consumer<QueryWrapper<T>> consumer = queryWrapper -> {
for(Map.Entry<String, QueryFilter.SegmentCond> field: fieldMap.entrySet()){ for(Map.Entry<String, QueryFilter.SegmentCond> field: fieldMap.entrySet()){
String fieldName=field.getKey(); String fieldName=field.getKey();
......
...@@ -117,11 +117,13 @@ public class SearchContextBase implements ISearchContext{ ...@@ -117,11 +117,13 @@ public class SearchContextBase implements ISearchContext{
* @return * @return
*/ */
public Pageable getPageable() { public Pageable getPageable() {
if(ObjectUtils.isEmpty(pageSort)) if(ObjectUtils.isEmpty(pageSort)) {
return PageRequest.of(page,size); return PageRequest.of(page,size);
else }
else {
return PageRequest.of(page,size,pageSort); return PageRequest.of(page,size,pageSort);
} }
}
/** /**
* 设置排序值 * 设置排序值
......
...@@ -16,8 +16,9 @@ public class CachedBeanCopier { ...@@ -16,8 +16,9 @@ public class CachedBeanCopier {
} }
public static void copy(Object srcObj, Object destObj,boolean useConverter) { public static void copy(Object srcObj, Object destObj,boolean useConverter) {
if(srcObj==null||destObj==null) if(srcObj==null||destObj==null) {
return; return;
}
getCopier(srcObj,destObj,useConverter).copy(srcObj, destObj, null); getCopier(srcObj,destObj,useConverter).copy(srcObj, destObj, null);
} }
...@@ -32,6 +33,4 @@ public class CachedBeanCopier { ...@@ -32,6 +33,4 @@ public class CachedBeanCopier {
} }
return copier; return copier;
} }
} }
...@@ -39,13 +39,16 @@ public class DEFieldCacheMap { ...@@ -39,13 +39,16 @@ public class DEFieldCacheMap {
*/ */
public static <T> Hashtable<String,Field> getFieldMap(Class<T> clazz) { public static <T> Hashtable<String,Field> getFieldMap(Class<T> clazz) {
String className=clazz.getName(); String className=clazz.getName();
if(className.indexOf("_$")>0) if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$")); className=className.substring(0, className.lastIndexOf("_$"));
if(cacheMap.containsKey(className)) }
if(cacheMap.containsKey(className)) {
return cacheMap.get(className); return cacheMap.get(className);
}
synchronized (objLock1) { synchronized (objLock1) {
if(cacheMap.containsKey(className)) if(cacheMap.containsKey(className)) {
return cacheMap.get(className); return cacheMap.get(className);
}
Hashtable<String,Field> result = new Hashtable<String,Field>(); Hashtable<String,Field> result = new Hashtable<String,Field>();
List<Field> list=new ArrayList<Field>(); List<Field> list=new ArrayList<Field>();
Hashtable<String,String> keys=new Hashtable<String,String>(); Hashtable<String,String> keys=new Hashtable<String,String>();
...@@ -61,9 +64,10 @@ public class DEFieldCacheMap { ...@@ -61,9 +64,10 @@ public class DEFieldCacheMap {
Audit auditField=field.getAnnotation(Audit.class); Audit auditField=field.getAnnotation(Audit.class);
if(!ObjectUtils.isEmpty(deField)) { if(!ObjectUtils.isEmpty(deField)) {
defields.put(field.getName(),deField); defields.put(field.getName(),deField);
if(deField.isKeyField()) if(deField.isKeyField()) {
cacheDEKeyField.put(className,field.getName()); cacheDEKeyField.put(className,field.getName());
} }
}
if(!ObjectUtils.isEmpty(auditField)) { if(!ObjectUtils.isEmpty(auditField)) {
auditfields.put(field.getName(),auditField); auditfields.put(field.getName(),auditField);
} }
...@@ -77,10 +81,12 @@ public class DEFieldCacheMap { ...@@ -77,10 +81,12 @@ public class DEFieldCacheMap {
} }
} }
public static Hashtable<String,Field> getFieldMap(String className) { public static Hashtable<String,Field> getFieldMap(String className) {
if(className.indexOf("_$")>0) if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$")); className=className.substring(0, className.lastIndexOf("_$"));
if(cacheMap.containsKey(className)) }
if(cacheMap.containsKey(className)) {
return cacheMap.get(className); return cacheMap.get(className);
}
Class clazz = null; Class clazz = null;
try { try {
clazz = Class.forName(className); clazz = Class.forName(className);
...@@ -99,10 +105,12 @@ public class DEFieldCacheMap { ...@@ -99,10 +105,12 @@ public class DEFieldCacheMap {
*/ */
public static <T> Hashtable<String,DEField> getDEFields(Class<T> clazz) { public static <T> Hashtable<String,DEField> getDEFields(Class<T> clazz) {
String className=clazz.getName(); String className=clazz.getName();
if(className.indexOf("_$")>0) if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$")); className=className.substring(0, className.lastIndexOf("_$"));
if(cacheDEField.containsKey(className)) }
if(cacheDEField.containsKey(className)) {
return cacheDEField.get(className); return cacheDEField.get(className);
}
else{ else{
DEFieldCacheMap.getFieldMap(className); DEFieldCacheMap.getFieldMap(className);
return cacheDEField.get(className); return cacheDEField.get(className);
...@@ -116,10 +124,12 @@ public class DEFieldCacheMap { ...@@ -116,10 +124,12 @@ public class DEFieldCacheMap {
*/ */
public static <T> Hashtable<String,Audit> getAuditFields(Class<T> clazz) { public static <T> Hashtable<String,Audit> getAuditFields(Class<T> clazz) {
String className=clazz.getName(); String className=clazz.getName();
if(className.indexOf("_$")>0) if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$")); className=className.substring(0, className.lastIndexOf("_$"));
if(cacheAuditField.containsKey(className)) }
if(cacheAuditField.containsKey(className)) {
return cacheAuditField.get(className); return cacheAuditField.get(className);
}
else{ else{
DEFieldCacheMap.getFieldMap(className); DEFieldCacheMap.getFieldMap(className);
return cacheAuditField.get(className); return cacheAuditField.get(className);
...@@ -133,10 +143,12 @@ public class DEFieldCacheMap { ...@@ -133,10 +143,12 @@ public class DEFieldCacheMap {
*/ */
public static <T> String getDEKeyField(Class<T> clazz) { public static <T> String getDEKeyField(Class<T> clazz) {
String className=clazz.getName(); String className=clazz.getName();
if(className.indexOf("_$")>0) if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$")); className=className.substring(0, className.lastIndexOf("_$"));
if(cacheDEKeyField.containsKey(className)) }
if(cacheDEKeyField.containsKey(className)) {
return cacheDEKeyField.get(className); return cacheDEKeyField.get(className);
}
else{ else{
DEFieldCacheMap.getFieldMap(className); DEFieldCacheMap.getFieldMap(className);
return cacheDEKeyField.get(className); return cacheDEKeyField.get(className);
...@@ -151,10 +163,12 @@ public class DEFieldCacheMap { ...@@ -151,10 +163,12 @@ public class DEFieldCacheMap {
*/ */
public static <T> List<Field> getFields(Class<T> clazz) { public static <T> List<Field> getFields(Class<T> clazz) {
String className=clazz.getName(); String className=clazz.getName();
if(className.indexOf("_$")>0) if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$")); className=className.substring(0, className.lastIndexOf("_$"));
if(cacheList.containsKey(className)) }
if(cacheList.containsKey(className)) {
return cacheList.get(className); return cacheList.get(className);
}
else{ else{
DEFieldCacheMap.getFieldMap(className); DEFieldCacheMap.getFieldMap(className);
return cacheList.get(className); return cacheList.get(className);
...@@ -162,10 +176,12 @@ public class DEFieldCacheMap { ...@@ -162,10 +176,12 @@ public class DEFieldCacheMap {
} }
public static List<Field> getFields(String className) { public static List<Field> getFields(String className) {
if(className.indexOf("_$")>0) if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$")); className=className.substring(0, className.lastIndexOf("_$"));
if(cacheList.containsKey(className)) }
if(cacheList.containsKey(className)) {
return cacheList.get(className); return cacheList.get(className);
}
else{ else{
DEFieldCacheMap.getFieldMap(className); DEFieldCacheMap.getFieldMap(className);
return cacheList.get(className); return cacheList.get(className);
...@@ -179,10 +195,12 @@ public class DEFieldCacheMap { ...@@ -179,10 +195,12 @@ public class DEFieldCacheMap {
*/ */
public static <T> Hashtable<String,String> getFieldKeys(Class<T> clazz) { public static <T> Hashtable<String,String> getFieldKeys(Class<T> clazz) {
String className=clazz.getName(); String className=clazz.getName();
if(className.indexOf("_$")>0) if(className.indexOf("_$")>0) {
className=className.substring(0, className.lastIndexOf("_$")); className=className.substring(0, className.lastIndexOf("_$"));
if(cacheKey.containsKey(className)) }
if(cacheKey.containsKey(className)) {
return cacheKey.get(className); return cacheKey.get(className);
}
else{ else{
DEFieldCacheMap.getFieldMap(className); DEFieldCacheMap.getFieldMap(className);
return cacheKey.get(className); return cacheKey.get(className);
...@@ -192,21 +210,26 @@ public class DEFieldCacheMap { ...@@ -192,21 +210,26 @@ public class DEFieldCacheMap {
public static <T> String getFieldRealName(Class<T> clazz,String fieldname) { public static <T> String getFieldRealName(Class<T> clazz,String fieldname) {
fieldname=fieldname.toLowerCase(); fieldname=fieldname.toLowerCase();
Hashtable<String,String> keys=DEFieldCacheMap.getFieldKeys(clazz); Hashtable<String,String> keys=DEFieldCacheMap.getFieldKeys(clazz);
if(keys.containsKey(fieldname)) if(keys.containsKey(fieldname)) {
return keys.get(fieldname); return keys.get(fieldname);
else if(keys.containsKey(fieldname.replace("_",""))) }
else if(keys.containsKey(fieldname.replace("_",""))) {
return keys.get(fieldname.replace("_","")); return keys.get(fieldname.replace("_",""));
else }
else {
return ""; return "";
} }
}
public static <T> Field getField(Class<T> clazz,String fieldname) { public static <T> Field getField(Class<T> clazz,String fieldname) {
String fieldRealName=DEFieldCacheMap.getFieldRealName(clazz,fieldname); String fieldRealName=DEFieldCacheMap.getFieldRealName(clazz,fieldname);
if(!StringUtils.isEmpty(fieldRealName)) if(!StringUtils.isEmpty(fieldRealName)) {
return DEFieldCacheMap.getFieldMap(clazz).get(fieldRealName); return DEFieldCacheMap.getFieldMap(clazz).get(fieldRealName);
else }
else {
return null; return null;
} }
}
public static <T> String getFieldColumnName(Class<T> clazz,String fieldname) { public static <T> String getFieldColumnName(Class<T> clazz,String fieldname) {
Field field = DEFieldCacheMap.getField(clazz,fieldname); Field field = DEFieldCacheMap.getField(clazz,fieldname);
...@@ -229,6 +252,4 @@ public class DEFieldCacheMap { ...@@ -229,6 +252,4 @@ public class DEFieldCacheMap {
} }
return resultValue; return resultValue;
} }
} }
\ No newline at end of file
...@@ -22,30 +22,34 @@ public class DataObject { ...@@ -22,30 +22,34 @@ public class DataObject {
final static public DateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd"); final static public DateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd");
final static public String getStringValue(Object objValue, String strDefault) { final static public String getStringValue(Object objValue, String strDefault) {
if (objValue == null) return strDefault; if (objValue == null) {
if (objValue instanceof String) return (String) objValue; return strDefault;
}
if (objValue instanceof String) {
return (String) objValue;
}
if (objValue instanceof java.sql.Timestamp||objValue instanceof java.sql.Date||objValue instanceof java.util.Date) { if (objValue instanceof java.sql.Timestamp||objValue instanceof java.sql.Date||objValue instanceof java.util.Date) {
String rt=datetimeFormat.format(objValue); String rt=datetimeFormat.format(objValue);
if(rt.endsWith(" 00:00:00")) if(rt.endsWith(" 00:00:00")) {
rt=dayFormat.format(objValue); rt=dayFormat.format(objValue);
else if(rt.endsWith(":00")) }
else if(rt.endsWith(":00")) {
rt=datetimeFormat2.format(objValue); rt=datetimeFormat2.format(objValue);
}
return rt; return rt;
} }
return objValue.toString(); return objValue.toString();
} }
public static <T> Object objectValueOf(Class<T> type,Object fieldValue) { public static <T> Object objectValueOf(Class<T> type,Object fieldValue) {
if(fieldValue==null) if(fieldValue==null) {
return null; return null;
}
Object resultValue=fieldValue; Object resultValue=fieldValue;
String targetType=type.getSimpleName(); String targetType=type.getSimpleName();
if(targetType.equalsIgnoreCase(fieldValue.getClass().getSimpleName())) if(targetType.equalsIgnoreCase(fieldValue.getClass().getSimpleName())){
return resultValue; return resultValue;
}
if(targetType.equals("Boolean")){ if(targetType.equals("Boolean")){
resultValue=getBooleanValue(fieldValue,false); resultValue=getBooleanValue(fieldValue,false);
} }
...@@ -82,10 +86,9 @@ public class DataObject { ...@@ -82,10 +86,9 @@ public class DataObject {
else if(targetType.equals("String")) { else if(targetType.equals("String")) {
resultValue= getStringValue(fieldValue,null); resultValue= getStringValue(fieldValue,null);
} }
if(resultValue==null) {
if(resultValue==null)
return null; return null;
}
return resultValue; return resultValue;
} }
...@@ -98,8 +101,9 @@ public class DataObject { ...@@ -98,8 +101,9 @@ public class DataObject {
if (objValue == null) { if (objValue == null) {
return jDefault; return jDefault;
} }
if(objValue instanceof JSONObject) if(objValue instanceof JSONObject) {
return (JSONObject)objValue; return (JSONObject)objValue;
}
String strValue = objValue.toString(); String strValue = objValue.toString();
try { try {
return JSONObject.parseObject(strValue); return JSONObject.parseObject(strValue);
...@@ -114,8 +118,9 @@ public class DataObject { ...@@ -114,8 +118,9 @@ public class DataObject {
if (objValue == null) { if (objValue == null) {
return jDefault; return jDefault;
} }
if(objValue instanceof JSONArray) if(objValue instanceof JSONArray) {
return (JSONArray)objValue; return (JSONArray)objValue;
}
String strValue = objValue.toString(); String strValue = objValue.toString();
try { try {
return JSONArray.parseArray(strValue); return JSONArray.parseArray(strValue);
...@@ -136,9 +141,10 @@ public class DataObject { ...@@ -136,9 +141,10 @@ public class DataObject {
List<String> chk1=new ArrayList<>(); List<String> chk1=new ArrayList<>();
for(int i=0;i<arr.size();i++) for(int i=0;i<arr.size();i++)
{ {
if(arr.get(i) instanceof String) if(arr.get(i) instanceof String) {
chk1.add(arr.getString(i)); chk1.add(arr.getString(i));
} }
}
return chk1; return chk1;
} }
else else
...@@ -149,8 +155,9 @@ public class DataObject { ...@@ -149,8 +155,9 @@ public class DataObject {
} }
final static public Boolean getBooleanValue(Object objValue,Boolean bDefault) { final static public Boolean getBooleanValue(Object objValue,Boolean bDefault) {
if (objValue == null) return bDefault; if (objValue == null) {
return bDefault;
}
if (objValue instanceof Boolean) { if (objValue instanceof Boolean) {
return (Boolean) objValue; return (Boolean) objValue;
} }
...@@ -158,20 +165,24 @@ public class DataObject { ...@@ -158,20 +165,24 @@ public class DataObject {
} }
final static public char[] getCharacterValue(Object objValue,char[] cDefault) { final static public char[] getCharacterValue(Object objValue,char[] cDefault) {
if (objValue == null) return cDefault; if (objValue == null) {
return cDefault;
}
return objValue.toString().toCharArray(); return objValue.toString().toCharArray();
} }
final static public Double getDoubleValue(Object objValue,Double dDefault) { final static public Double getDoubleValue(Object objValue,Double dDefault) {
if (objValue == null) return dDefault; if (objValue == null) {
return dDefault;
}
if (objValue instanceof Double) { if (objValue instanceof Double) {
return (Double) objValue; return (Double) objValue;
} }
String strValue = objValue.toString(); String strValue = objValue.toString();
if (StringUtils.isEmpty(strValue)) return null; if (StringUtils.isEmpty(strValue)) {
return null;
}
strValue = strValue.replace(",", ""); strValue = strValue.replace(",", "");
return Double.parseDouble(strValue); return Double.parseDouble(strValue);
} }
...@@ -182,8 +193,9 @@ public class DataObject { ...@@ -182,8 +193,9 @@ public class DataObject {
return nDefault; return nDefault;
} }
if(objValue instanceof Integer) if(objValue instanceof Integer) {
return (Integer)objValue; return (Integer)objValue;
}
if (objValue instanceof Double) { if (objValue instanceof Double) {
return ((Double) objValue).intValue(); return ((Double) objValue).intValue();
...@@ -194,8 +206,9 @@ public class DataObject { ...@@ -194,8 +206,9 @@ public class DataObject {
} }
String strValue = objValue.toString(); String strValue = objValue.toString();
if(StringUtils.isEmpty(strValue)) if(StringUtils.isEmpty(strValue)) {
return nDefault; return nDefault;
}
strValue = strValue.replace(",", ""); strValue = strValue.replace(",", "");
return Integer.parseInt(strValue); return Integer.parseInt(strValue);
} }
...@@ -207,12 +220,13 @@ public class DataObject { ...@@ -207,12 +220,13 @@ public class DataObject {
} }
try { try {
if(objValue instanceof Float) if(objValue instanceof Float) {
return (Float)objValue; return (Float)objValue;
}
String strValue = objValue.toString(); String strValue = objValue.toString();
if(StringUtils.isEmpty(strValue)) if(StringUtils.isEmpty(strValue)) {
return fDefault; return fDefault;
}
strValue = strValue.replace(",", ""); strValue = strValue.replace(",", "");
return Float.parseFloat(strValue); return Float.parseFloat(strValue);
} catch (Exception ex) { } catch (Exception ex) {
...@@ -236,8 +250,9 @@ public class DataObject { ...@@ -236,8 +250,9 @@ public class DataObject {
return BigDecimal.valueOf((Long)objValue); return BigDecimal.valueOf((Long)objValue);
} }
String strValue = objValue.toString(); String strValue = objValue.toString();
if(StringUtils.isEmpty(strValue)) if(StringUtils.isEmpty(strValue)) {
return fDefault; return fDefault;
}
strValue = strValue.replace(",", ""); strValue = strValue.replace(",", "");
return BigDecimal.valueOf(Double.parseDouble(strValue)); return BigDecimal.valueOf(Double.parseDouble(strValue));
} catch (Exception ex) { } catch (Exception ex) {
...@@ -256,9 +271,10 @@ public class DataObject { ...@@ -256,9 +271,10 @@ public class DataObject {
} }
else { else {
Long l=getLongValue(objValue,null); Long l=getLongValue(objValue,null);
if(l!=null) if(l!=null) {
return BigInteger.valueOf(l); return BigInteger.valueOf(l);
} }
}
} catch (Exception ex) { } catch (Exception ex) {
} }
...@@ -286,8 +302,9 @@ public class DataObject { ...@@ -286,8 +302,9 @@ public class DataObject {
} }
String strValue = objValue.toString(); String strValue = objValue.toString();
if(StringUtils.isEmpty(strValue)) if(StringUtils.isEmpty(strValue)) {
return nDefault; return nDefault;
}
strValue = strValue.replace(",", ""); strValue = strValue.replace(",", "");
return Long.parseLong(strValue); return Long.parseLong(strValue);
} catch (Exception ex) { } catch (Exception ex) {
...@@ -297,7 +314,9 @@ public class DataObject { ...@@ -297,7 +314,9 @@ public class DataObject {
final static public byte[] getBinaryValue(Object objValue, byte[] def) { final static public byte[] getBinaryValue(Object objValue, byte[] def) {
if (objValue == null) return def; if (objValue == null) {
return def;
}
if(objValue instanceof byte[]){ if(objValue instanceof byte[]){
return (byte[])objValue; return (byte[])objValue;
} }
...@@ -315,7 +334,9 @@ public class DataObject { ...@@ -315,7 +334,9 @@ public class DataObject {
* @ * @
*/ */
final static public java.sql.Timestamp getTimestampValue(Object objValue,java.sql.Timestamp tDefault) { final static public java.sql.Timestamp getTimestampValue(Object objValue,java.sql.Timestamp tDefault) {
if (objValue == null) return tDefault; if (objValue == null) {
return tDefault;
}
if (objValue instanceof java.sql.Timestamp) { if (objValue instanceof java.sql.Timestamp) {
java.sql.Timestamp ti = (java.sql.Timestamp) objValue; java.sql.Timestamp ti = (java.sql.Timestamp) objValue;
...@@ -335,7 +356,9 @@ public class DataObject { ...@@ -335,7 +356,9 @@ public class DataObject {
if (objValue instanceof String) { if (objValue instanceof String) {
String strValue = (String) objValue; String strValue = (String) objValue;
strValue = strValue.trim(); strValue = strValue.trim();
if (StringUtils.isEmpty(strValue)) return null; if (StringUtils.isEmpty(strValue)) {
return null;
}
try { try {
java.util.Date date = parse((String) objValue); java.util.Date date = parse((String) objValue);
...@@ -376,7 +399,9 @@ public class DataObject { ...@@ -376,7 +399,9 @@ public class DataObject {
* @ * @
*/ */
public static Object testDateTime(String strInput, TimeZone timeZone) throws Exception{ public static Object testDateTime(String strInput, TimeZone timeZone) throws Exception{
if (StringUtils.isEmpty(strInput)) return null; if (StringUtils.isEmpty(strInput)) {
return null;
}
Date dtDate = parse(strInput, timeZone); Date dtDate = parse(strInput, timeZone);
java.sql.Timestamp retDate = new java.sql.Timestamp(dtDate.getTime()); java.sql.Timestamp retDate = new java.sql.Timestamp(dtDate.getTime());
return retDate; return retDate;
...@@ -428,8 +453,9 @@ public class DataObject { ...@@ -428,8 +453,9 @@ public class DataObject {
if(strTimeString.indexOf("T")!=-1){ if(strTimeString.indexOf("T")!=-1){
strPart = strTimeString.split("[T]"); strPart = strTimeString.split("[T]");
} }
else else{
strPart = strTimeString.split(" "); strPart = strTimeString.split(" ");
}
if (strPart.length == 2) { if (strPart.length == 2) {
// 两个部分 // 两个部分
String strDate = ""; String strDate = "";
...@@ -592,6 +618,4 @@ public class DataObject { ...@@ -592,6 +618,4 @@ public class DataObject {
return new Timestamp(cl.getTime().getTime()); return new Timestamp(cl.getTime().getTime());
} }
} }
...@@ -21,8 +21,9 @@ public class RuleUtils ...@@ -21,8 +21,9 @@ public class RuleUtils
public static Object getObj(Object object, String members) public static Object getObj(Object object, String members)
{ {
if(object==null) if(object==null) {
return null; return null;
}
Object currentObj = object; Object currentObj = object;
String[] arrayOfString = members.split("\\."); String[] arrayOfString = members.split("\\.");
int i = arrayOfString.length; int i = arrayOfString.length;
...@@ -34,21 +35,24 @@ public class RuleUtils ...@@ -34,21 +35,24 @@ public class RuleUtils
if(currentObj instanceof EntityBase) if(currentObj instanceof EntityBase)
{ {
currentObj=((EntityBase) currentObj).get(methodName); currentObj=((EntityBase) currentObj).get(methodName);
if (currentObj == null) if (currentObj == null) {
return null; return null;
} }
}
else if(currentObj instanceof JSONObject) else if(currentObj instanceof JSONObject)
{ {
currentObj=((JSONObject) currentObj).get(methodName); currentObj=((JSONObject) currentObj).get(methodName);
if (currentObj == null) if (currentObj == null) {
return null; return null;
} }
}
else if(currentObj instanceof Map) else if(currentObj instanceof Map)
{ {
currentObj=((Map) currentObj).get(methodName); currentObj=((Map) currentObj).get(methodName);
if (currentObj == null) if (currentObj == null) {
return null; return null;
} }
}
else else
{ {
Class clazz = currentObj.getClass(); Class clazz = currentObj.getClass();
...@@ -63,10 +67,10 @@ public class RuleUtils ...@@ -63,10 +67,10 @@ public class RuleUtils
} }
currentObj = method.invoke(currentObj, methodName); currentObj = method.invoke(currentObj, methodName);
if (currentObj == null) if (currentObj == null){
return null; return null;
} }
}
} }
catch (Exception e) catch (Exception e)
{ {
...@@ -80,45 +84,64 @@ public class RuleUtils ...@@ -80,45 +84,64 @@ public class RuleUtils
public static boolean test(Object finalObject,String option,Object exp) public static boolean test(Object finalObject,String option,Object exp)
{ {
if(option.equalsIgnoreCase("eq")||option.equalsIgnoreCase("equal")||option.equalsIgnoreCase("=")) if(option.equalsIgnoreCase("eq")||option.equalsIgnoreCase("equal")||option.equalsIgnoreCase("=")){
return equal(exp,finalObject); return equal(exp,finalObject);
else if (option.equalsIgnoreCase("noteq")||option.equalsIgnoreCase("notequal")||option.equalsIgnoreCase("<>")||option.equalsIgnoreCase("!=")) }
else if (option.equalsIgnoreCase("noteq")||option.equalsIgnoreCase("notequal")||option.equalsIgnoreCase("<>")||option.equalsIgnoreCase("!=")){
return !equal(exp,finalObject); return !equal(exp,finalObject);
else if (option.equalsIgnoreCase("gt")||option.equalsIgnoreCase(">")) }
else if (option.equalsIgnoreCase("gt")||option.equalsIgnoreCase(">")){
return gt(exp,finalObject); return gt(exp,finalObject);
else if (option.equalsIgnoreCase("lt")||option.equalsIgnoreCase("<")) }
else if (option.equalsIgnoreCase("lt")||option.equalsIgnoreCase("<")){
return lt(exp,finalObject); return lt(exp,finalObject);
else if (option.equalsIgnoreCase("gtandeq")||option.equalsIgnoreCase("ge")||option.equalsIgnoreCase(">=")) }
else if (option.equalsIgnoreCase("gtandeq")||option.equalsIgnoreCase("ge")||option.equalsIgnoreCase(">=")){
return ge(exp,finalObject); return ge(exp,finalObject);
else if (option.equalsIgnoreCase("ltandeq")||option.equalsIgnoreCase("le")||option.equalsIgnoreCase("<=")) }
else if (option.equalsIgnoreCase("ltandeq")||option.equalsIgnoreCase("le")||option.equalsIgnoreCase("<=")){
return le(exp,finalObject); return le(exp,finalObject);
else if (option.equalsIgnoreCase("null")||option.equalsIgnoreCase("isnull")) }
else if (option.equalsIgnoreCase("null")||option.equalsIgnoreCase("isnull")){
return isNull(finalObject); return isNull(finalObject);
else if (option.equalsIgnoreCase("notnull")||option.equalsIgnoreCase("isnotnull")) }
else if (option.equalsIgnoreCase("notnull")||option.equalsIgnoreCase("isnotnull")){
return isNotNull(finalObject); return isNotNull(finalObject);
else if (option.equalsIgnoreCase("like")||option.equalsIgnoreCase("matchor")) }
else if (option.equalsIgnoreCase("like")||option.equalsIgnoreCase("matchor")){
return matchor(exp,finalObject); return matchor(exp,finalObject);
else if (option.equalsIgnoreCase("leftlike")||option.equalsIgnoreCase("startswith")||option.equalsIgnoreCase("begin")) }
else if (option.equalsIgnoreCase("leftlike")||option.equalsIgnoreCase("startswith")||option.equalsIgnoreCase("begin")){
return leftmatchor(exp,finalObject); return leftmatchor(exp,finalObject);
else if (option.equalsIgnoreCase("rightlike")||option.equalsIgnoreCase("endswith")||option.equalsIgnoreCase("end")) }
else if (option.equalsIgnoreCase("rightlike")||option.equalsIgnoreCase("endswith")||option.equalsIgnoreCase("end")){
return rightmatchor(exp,finalObject); return rightmatchor(exp,finalObject);
else if (option.equalsIgnoreCase("match")||option.equalsIgnoreCase("matchand")||option.equalsIgnoreCase("matches")) }
else if (option.equalsIgnoreCase("match")||option.equalsIgnoreCase("matchand")||option.equalsIgnoreCase("matches")){
return matchand(exp,finalObject); return matchand(exp,finalObject);
else if (option.equalsIgnoreCase("in")) }
else if (option.equalsIgnoreCase("in")){
return in(exp,finalObject); return in(exp,finalObject);
else if (option.equalsIgnoreCase("notin")) }
else if (option.equalsIgnoreCase("notin")){
return notin(exp,finalObject); return notin(exp,finalObject);
else if (option.equalsIgnoreCase("NOTLIKE")) }
else if (option.equalsIgnoreCase("NOTLIKE")){
return notmatchor(exp,finalObject); return notmatchor(exp,finalObject);
else if (option.equalsIgnoreCase("LEFTNOTLIKE")) }
else if (option.equalsIgnoreCase("LEFTNOTLIKE")){
return !leftmatchor(exp,finalObject); return !leftmatchor(exp,finalObject);
else if (option.equalsIgnoreCase("RIGHTNOTLIKE")) }
else if (option.equalsIgnoreCase("RIGHTNOTLIKE")){
return !rightmatchor(exp,finalObject); return !rightmatchor(exp,finalObject);
else if (option.equalsIgnoreCase("NOTMATCHES")) }
else if (option.equalsIgnoreCase("NOTMATCHES")){
return notmatchand(exp,finalObject); return notmatchand(exp,finalObject);
else }
else{
return false; return false;
} }
}
public static boolean equal(Object exp, Object object, String members) public static boolean equal(Object exp, Object object, String members)
...@@ -128,10 +151,12 @@ public class RuleUtils ...@@ -128,10 +151,12 @@ public class RuleUtils
public static boolean equal(Object exp, Object finalObject) public static boolean equal(Object exp, Object finalObject)
{ {
if(exp==null) if(exp==null){
return false; return false;
if(finalObject ==null) }
if(finalObject ==null){
return false; return false;
}
if(exp instanceof String && ((String) exp).length()==10 && finalObject instanceof Timestamp) if(exp instanceof String && ((String) exp).length()==10 && finalObject instanceof Timestamp)
{ {
...@@ -148,10 +173,12 @@ public class RuleUtils ...@@ -148,10 +173,12 @@ public class RuleUtils
return ObjectUtils.nullSafeEquals(tm,finalObject); return ObjectUtils.nullSafeEquals(tm,finalObject);
} }
if(ObjectUtils.nullSafeEquals(exp,finalObject)) if(ObjectUtils.nullSafeEquals(exp,finalObject)){
return true; return true;
if(exp.toString().equalsIgnoreCase(finalObject.toString())) }
if(exp.toString().equalsIgnoreCase(finalObject.toString())){
return true; return true;
}
return false; return false;
} }
...@@ -161,10 +188,12 @@ public class RuleUtils ...@@ -161,10 +188,12 @@ public class RuleUtils
} }
public static boolean gt(Object exp, Object finalObject) public static boolean gt(Object exp, Object finalObject)
{ {
if(ObjectUtils.isEmpty(exp)) if(ObjectUtils.isEmpty(exp)){
return false; return false;
if(ObjectUtils.isEmpty(finalObject)) }
if(ObjectUtils.isEmpty(finalObject)){
return false; return false;
}
try try
{ {
if(finalObject instanceof java.sql.Timestamp) if(finalObject instanceof java.sql.Timestamp)
...@@ -179,9 +208,10 @@ public class RuleUtils ...@@ -179,9 +208,10 @@ public class RuleUtils
else else
{ {
tm=DataObject.getTimestampValue(exp,null); tm=DataObject.getTimestampValue(exp,null);
if(tm==null) if(tm==null){
return false; return false;
} }
}
return finalTime.getTime()>tm.getTime(); return finalTime.getTime()>tm.getTime();
} }
else if (finalObject instanceof Integer) else if (finalObject instanceof Integer)
...@@ -212,15 +242,14 @@ public class RuleUtils ...@@ -212,15 +242,14 @@ public class RuleUtils
{ {
return finalObject.toString().compareToIgnoreCase(exp.toString())>0; return finalObject.toString().compareToIgnoreCase(exp.toString())>0;
} }
else else{
return false; return false;
} }
}
catch(Exception ex) catch(Exception ex)
{ {
return false; return false;
} }
} }
public static boolean lt(Object exp, Object object, String members) public static boolean lt(Object exp, Object object, String members)
...@@ -229,10 +258,12 @@ public class RuleUtils ...@@ -229,10 +258,12 @@ public class RuleUtils
} }
public static boolean lt(Object exp, Object finalObject) public static boolean lt(Object exp, Object finalObject)
{ {
if(ObjectUtils.isEmpty(exp)) if(ObjectUtils.isEmpty(exp)){
return false; return false;
if(ObjectUtils.isEmpty(finalObject)) }
if(ObjectUtils.isEmpty(finalObject)){
return false; return false;
}
try try
{ {
if(finalObject instanceof java.sql.Timestamp) if(finalObject instanceof java.sql.Timestamp)
...@@ -314,8 +345,9 @@ public class RuleUtils ...@@ -314,8 +345,9 @@ public class RuleUtils
return false; return false;
String tvs=expObj.toString().trim(); String tvs=expObj.toString().trim();
if(StringUtils.isEmpty(tvs)) if(StringUtils.isEmpty(tvs)){
return false; return false;
}
if (finalObject instanceof Integer) if (finalObject instanceof Integer)
{ {
...@@ -355,8 +387,9 @@ public class RuleUtils ...@@ -355,8 +387,9 @@ public class RuleUtils
} }
public static boolean isNull(Object finalObject) public static boolean isNull(Object finalObject)
{ {
if(finalObject instanceof String) if(finalObject instanceof String){
return StringUtils.isEmpty(finalObject.toString().trim()); return StringUtils.isEmpty(finalObject.toString().trim());
}
return (ObjectUtils.isEmpty(finalObject)); return (ObjectUtils.isEmpty(finalObject));
} }
...@@ -385,11 +418,13 @@ public class RuleUtils ...@@ -385,11 +418,13 @@ public class RuleUtils
} }
public static boolean matchor(Object expObj, Object obj) public static boolean matchor(Object expObj, Object obj)
{ {
if(obj==null) if(obj==null){
return false; return false;
}
String exp=expObj.toString().trim(); String exp=expObj.toString().trim();
if(StringUtils.isEmpty(exp)) if(StringUtils.isEmpty(exp)){
return false; return false;
}
exp=exp.replace(";", ","); exp=exp.replace(";", ",");
exp=exp.replace(";", ","); exp=exp.replace(";", ",");
exp=exp.replace(",", ","); exp=exp.replace(",", ",");
...@@ -406,11 +441,13 @@ public class RuleUtils ...@@ -406,11 +441,13 @@ public class RuleUtils
public static boolean leftmatchor(Object expObj, Object obj) public static boolean leftmatchor(Object expObj, Object obj)
{ {
if(obj==null) if(obj==null){
return false; return false;
}
String exp=expObj.toString().trim(); String exp=expObj.toString().trim();
if(StringUtils.isEmpty(exp)) if(StringUtils.isEmpty(exp)){
return false; return false;
}
exp=exp.replace(";", ","); exp=exp.replace(";", ",");
exp=exp.replace(";", ","); exp=exp.replace(";", ",");
exp=exp.replace(",", ","); exp=exp.replace(",", ",");
...@@ -419,19 +456,22 @@ public class RuleUtils ...@@ -419,19 +456,22 @@ public class RuleUtils
for(String strExp:arr) for(String strExp:arr)
{ {
bRt=obj.toString().matches(strExp+"(.*)"); bRt=obj.toString().matches(strExp+"(.*)");
if(bRt) if(bRt){
return true; return true;
} }
}
return bRt; return bRt;
} }
public static boolean rightmatchor(Object expObj, Object obj) public static boolean rightmatchor(Object expObj, Object obj)
{ {
if(obj==null) if(obj==null){
return false; return false;
}
String exp=expObj.toString().trim(); String exp=expObj.toString().trim();
if(StringUtils.isEmpty(exp)) if(StringUtils.isEmpty(exp)){
return false; return false;
}
exp=exp.replace(";", ","); exp=exp.replace(";", ",");
exp=exp.replace(";", ","); exp=exp.replace(";", ",");
exp=exp.replace(",", ","); exp=exp.replace(",", ",");
...@@ -440,9 +480,10 @@ public class RuleUtils ...@@ -440,9 +480,10 @@ public class RuleUtils
for(String strExp:arr) for(String strExp:arr)
{ {
bRt=obj.toString().matches("(.*)"+strExp); bRt=obj.toString().matches("(.*)"+strExp);
if(bRt) if(bRt){
return true; return true;
} }
}
return bRt; return bRt;
} }
...@@ -452,13 +493,16 @@ public class RuleUtils ...@@ -452,13 +493,16 @@ public class RuleUtils
} }
public static boolean matchand(Object expObj,Object obj) public static boolean matchand(Object expObj,Object obj)
{ {
if(obj==null) if(obj==null){
return false; return false;
if(expObj==null) }
if(expObj==null){
return false; return false;
}
String exp=expObj.toString().trim(); String exp=expObj.toString().trim();
if(StringUtils.isEmpty(exp)) if(StringUtils.isEmpty(exp)){
return false; return false;
}
exp=exp.replace(";", ","); exp=exp.replace(";", ",");
exp=exp.replace(";", ","); exp=exp.replace(";", ",");
exp=exp.replace(",", ","); exp=exp.replace(",", ",");
...@@ -467,12 +511,14 @@ public class RuleUtils ...@@ -467,12 +511,14 @@ public class RuleUtils
boolean bRt=true; boolean bRt=true;
for(String strExp:arr) for(String strExp:arr)
{ {
if(strExp.trim().length()==0) if(strExp.trim().length()==0){
continue; continue;
}
bRt=(obj.toString()).matches("(.*)"+(strExp)+"(.*)"); bRt=(obj.toString()).matches("(.*)"+(strExp)+"(.*)");
if(!bRt) if(!bRt){
return false; return false;
} }
}
return bRt; return bRt;
} }
...@@ -506,13 +552,15 @@ public class RuleUtils ...@@ -506,13 +552,15 @@ public class RuleUtils
switch (str1.hashCode()) switch (str1.hashCode())
{ {
case 105: case 105:
if (str1.equals("i")) if (str1.equals("i")){
i = 0; i = 0;
}
break; break;
case 115: case 115:
if (str1.equals("s")) if (str1.equals("s")){
i = 1; i = 1;
} }
}
switch (i) switch (i)
{ {
case 0: case 0:
......
...@@ -45,12 +45,14 @@ public class AppController { ...@@ -45,12 +45,14 @@ public class AppController {
while(it.hasNext()) { while(it.hasNext()) {
GrantedAuthority authority = (GrantedAuthority)it.next(); GrantedAuthority authority = (GrantedAuthority)it.next();
String strAuthority=authority.getAuthority(); String strAuthority=authority.getAuthority();
if(strAuthority.startsWith("UNIRES_"+systemId)) if(strAuthority.startsWith("UNIRES_"+systemId)) {
uniRes.add(strAuthority.substring(systemId.length()+8)); uniRes.add(strAuthority.substring(systemId.length()+8));
else if(strAuthority.startsWith("APPMENU_"+systemId)) }
else if(strAuthority.startsWith("APPMENU_"+systemId)){
appMenu.add(strAuthority.substring(systemId.length()+9)); appMenu.add(strAuthority.substring(systemId.length()+9));
} }
} }
}
Map<String,Object> context = new HashMap<>(); Map<String,Object> context = new HashMap<>();
context.putAll(curUser.getSessionParams()); context.putAll(curUser.getSessionParams());
context.put("srfusername",curUser.getPersonname()); context.put("srfusername",curUser.getPersonname());
...@@ -58,10 +60,12 @@ public class AppController { ...@@ -58,10 +60,12 @@ public class AppController {
appData.put("unires",uniRes); appData.put("unires",uniRes);
appData.put("appmenu",appMenu); appData.put("appmenu",appMenu);
appData.put("enablepermissionvalid",enablePermissionValid); appData.put("enablepermissionvalid",enablePermissionValid);
if(curUser.getSuperuser()==1) if(curUser.getSuperuser()==1){
appData.put("enablepermissionvalid",false); appData.put("enablepermissionvalid",false);
else }
else{
appData.put("enablepermissionvalid",enablePermissionValid); appData.put("enablepermissionvalid",enablePermissionValid);
}
fillAppData(appData); fillAppData(appData);
return ResponseEntity.status(HttpStatus.OK).body(appData); return ResponseEntity.status(HttpStatus.OK).body(appData);
} }
...@@ -79,16 +83,18 @@ public class AppController { ...@@ -79,16 +83,18 @@ public class AppController {
@RequestMapping(method = RequestMethod.PUT, value = "/configs/{configType}/{targetType}") @RequestMapping(method = RequestMethod.PUT, value = "/configs/{configType}/{targetType}")
public ResponseEntity<Boolean> saveConfig(@PathVariable("configType") String configType, @PathVariable("targetType") String targetType, @RequestBody JSONObject config) { public ResponseEntity<Boolean> saveConfig(@PathVariable("configType") String configType, @PathVariable("targetType") String targetType, @RequestBody JSONObject config) {
String userId=AuthenticationUser.getAuthenticationUser().getUserid(); String userId=AuthenticationUser.getAuthenticationUser().getUserid();
if(StringUtils.isEmpty(userId)) if(StringUtils.isEmpty(userId)){
throw new BadRequestAlertException("保存配置失败,参数缺失","IBZConfig",configType); throw new BadRequestAlertException("保存配置失败,参数缺失","IBZConfig",configType);
}
return ResponseEntity.ok(ibzConfigService.saveConfig(configType,targetType,userId,config)); return ResponseEntity.ok(ibzConfigService.saveConfig(configType,targetType,userId,config));
} }
@RequestMapping(method = RequestMethod.GET, value = "/configs/{configType}/{targetType}") @RequestMapping(method = RequestMethod.GET, value = "/configs/{configType}/{targetType}")
public ResponseEntity<JSONObject> getConfig(@PathVariable("configType") String configType, @PathVariable("targetType") String targetType) { public ResponseEntity<JSONObject> getConfig(@PathVariable("configType") String configType, @PathVariable("targetType") String targetType) {
String userId=AuthenticationUser.getAuthenticationUser().getUserid(); String userId=AuthenticationUser.getAuthenticationUser().getUserid();
if(StringUtils.isEmpty(userId)) if(StringUtils.isEmpty(userId)){
throw new BadRequestAlertException("获取配置失败,参数缺失","IBZConfig",configType); throw new BadRequestAlertException("获取配置失败,参数缺失","IBZConfig",configType);
}
return ResponseEntity.ok(ibzConfigService.getConfig(configType,targetType,userId)); return ResponseEntity.ok(ibzConfigService.getConfig(configType,targetType,userId));
} }
......
...@@ -41,18 +41,22 @@ public class AuthPermissionEvaluator implements PermissionEvaluator { ...@@ -41,18 +41,22 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
@Override @Override
@SneakyThrows @SneakyThrows
public boolean hasPermission(Authentication authentication, Object entity, Object action) { public boolean hasPermission(Authentication authentication, Object entity, Object action) {
if(!enablePermissionValid) if(!enablePermissionValid){
return true; return true;
}
Object principal = authentication.getPrincipal(); Object principal = authentication.getPrincipal();
if(ObjectUtils.isEmpty(principal)) if(ObjectUtils.isEmpty(principal)){
return false; return false;
}
AuthenticationUser authenticationUser= (AuthenticationUser) authentication.getPrincipal(); AuthenticationUser authenticationUser= (AuthenticationUser) authentication.getPrincipal();
if(authenticationUser.getSuperuser()==1) if(authenticationUser.getSuperuser()==1){
return true; return true;
}
String strAction=String.valueOf(action); String strAction=String.valueOf(action);
Set<String> userAuthorities = getAuthorities(authentication,strAction); Set<String> userAuthorities = getAuthorities(authentication,strAction);
if(userAuthorities.size()==0) if(userAuthorities.size()==0){
return false; return false;
}
if(isAllData(strAction,userAuthorities)){ if(isAllData(strAction,userAuthorities)){
return true; return true;
} }
...@@ -105,8 +109,9 @@ public class AuthPermissionEvaluator implements PermissionEvaluator { ...@@ -105,8 +109,9 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
*/ */
@SneakyThrows @SneakyThrows
private void setPermissionCondToSearchContext(EntityBase entity, QueryWrapperContext qc , Set<String> userAuthorities ,AuthenticationUser authenticationUser){ private void setPermissionCondToSearchContext(EntityBase entity, QueryWrapperContext qc , Set<String> userAuthorities ,AuthenticationUser authenticationUser){
if(entity==null) if(entity==null){
return ; return ;
}
Map<String,String> permissionField=getPermissionField(entity);//获取组织、部门预置属性 Map<String,String> permissionField=getPermissionField(entity);//获取组织、部门预置属性
String orgField=permissionField.get("orgfield"); String orgField=permissionField.get("orgfield");
String orgDeptField=permissionField.get("orgsecfield"); String orgDeptField=permissionField.get("orgsecfield");
...@@ -188,9 +193,10 @@ public class AuthPermissionEvaluator implements PermissionEvaluator { ...@@ -188,9 +193,10 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
Iterator it = authorities.iterator(); Iterator it = authorities.iterator();
while(it.hasNext()) { while(it.hasNext()) {
GrantedAuthority authority = (GrantedAuthority)it.next(); GrantedAuthority authority = (GrantedAuthority)it.next();
if(authority.getAuthority().contains(action)) if(authority.getAuthority().contains(action)){
userAuthorities.add(authority.getAuthority()); userAuthorities.add(authority.getAuthority());
} }
}
return userAuthorities; return userAuthorities;
} }
...@@ -256,23 +262,27 @@ public class AuthPermissionEvaluator implements PermissionEvaluator { ...@@ -256,23 +262,27 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
} }
if(action.endsWith("Create") || action.endsWith("Save")){ if(action.endsWith("Create") || action.endsWith("Save")){
if(!ObjectUtils.isEmpty(orgFieldValue) && !userOrg.contains(orgFieldValue)) if(!ObjectUtils.isEmpty(orgFieldValue) && !userOrg.contains(orgFieldValue)){
return false; return false;
if(!ObjectUtils.isEmpty(orgDeptFieldValue) && !userOrgDept.contains(orgDeptFieldValue)) }
if(!ObjectUtils.isEmpty(orgDeptFieldValue) && !userOrgDept.contains(orgDeptFieldValue)){
return false; return false;
if(!ObjectUtils.isEmpty(crateManFieldValue) && !authenticationUser.getUserid().equals(crateManFieldValue)) }
if(!ObjectUtils.isEmpty(crateManFieldValue) && !authenticationUser.getUserid().equals(crateManFieldValue)){
return false; return false;
}
return true; return true;
} }
else{ else{
if(!ObjectUtils.isEmpty(orgFieldValue) && userOrg.contains(orgFieldValue)) if(!ObjectUtils.isEmpty(orgFieldValue) && userOrg.contains(orgFieldValue)){
return true; return true;
if(!ObjectUtils.isEmpty(orgDeptFieldValue) && userOrgDept.contains(orgDeptFieldValue)) }
if(!ObjectUtils.isEmpty(orgDeptFieldValue) && userOrgDept.contains(orgDeptFieldValue)){
return true; return true;
if(!ObjectUtils.isEmpty(crateManFieldValue) && authenticationUser.getUserid().equals(crateManFieldValue)) }
if(!ObjectUtils.isEmpty(crateManFieldValue) && authenticationUser.getUserid().equals(crateManFieldValue)){
return true; return true;
}
return false; return false;
} }
} }
...@@ -296,13 +306,19 @@ public class AuthPermissionEvaluator implements PermissionEvaluator { ...@@ -296,13 +306,19 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
String fieldName=entry.getKey();//获取注解字段 String fieldName=entry.getKey();//获取注解字段
DEField fieldAnnotation=entry.getValue();//获取注解值 DEField fieldAnnotation=entry.getValue();//获取注解值
DEPredefinedFieldType prefieldType=fieldAnnotation.preType(); DEPredefinedFieldType prefieldType=fieldAnnotation.preType();
if(prefieldType==prefieldType.ORGID)//用户配置系统预置属性-组织机构标识 //用户配置系统预置属性-组织机构标识
if(prefieldType==prefieldType.ORGID){
orgField=fieldName; orgField=fieldName;
if(prefieldType==prefieldType.ORGSECTORID)//用户配置系统预置属性-部门标识 }
//用户配置系统预置属性-部门标识
if(prefieldType==prefieldType.ORGSECTORID){
orgDeptField=fieldName; orgDeptField=fieldName;
if(prefieldType==prefieldType.CREATEMAN)//用户配置系统预置属性-部门标识 }
//用户配置系统预置属性-部门标识
if(prefieldType==prefieldType.CREATEMAN){
createManField=fieldName; createManField=fieldName;
} }
}
permissionFiled.put("orgfield",orgField); permissionFiled.put("orgfield",orgField);
permissionFiled.put("orgsecfield",orgDeptField); permissionFiled.put("orgsecfield",orgDeptField);
permissionFiled.put("createmanfield",createManField); permissionFiled.put("createmanfield",createManField);
......
...@@ -263,11 +263,13 @@ public class AuthenticationUser implements UserDetails ...@@ -263,11 +263,13 @@ public class AuthenticationUser implements UserDetails
return this.sessionParams; return this.sessionParams;
} }
private Map<String, Object> getUserSessionParam() { private Map<String, Object> getUserSessionParam() {
if(userSessionParam!=null) if(userSessionParam!=null){
return userSessionParam; return userSessionParam;
else }
else{
return new HashMap<>(); return new HashMap<>();
} }
}
public void setOrgInfo(Map<String, Set<String>> orgInfo) { public void setOrgInfo(Map<String, Set<String>> orgInfo) {
this.orgInfo = orgInfo; this.orgInfo = orgInfo;
......
...@@ -37,8 +37,9 @@ public class IBZConfigService extends ServiceImpl<IBZConfigMapper, IBZConfig> im ...@@ -37,8 +37,9 @@ public class IBZConfigService extends ServiceImpl<IBZConfigMapper, IBZConfig> im
@Cacheable( value="${cachename}",key = "'cfgid:'+#p0+'||'+#p1+'||'+#p2") @Cacheable( value="${cachename}",key = "'cfgid:'+#p0+'||'+#p1+'||'+#p2")
public JSONObject getConfig(String cfgType,String targetType,String userId) public JSONObject getConfig(String cfgType,String targetType,String userId)
{ {
if(StringUtils.isEmpty(userId)||StringUtils.isEmpty(cfgType)||StringUtils.isEmpty(targetType)) if(StringUtils.isEmpty(userId)||StringUtils.isEmpty(cfgType)||StringUtils.isEmpty(targetType)){
throw new BadRequestAlertException("获取配置失败,参数缺失","IBZConfig",cfgType); throw new BadRequestAlertException("获取配置失败,参数缺失","IBZConfig",cfgType);
}
IBZConfig config=this.getOne(Wrappers.query(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(userId).build()),false); IBZConfig config=this.getOne(Wrappers.query(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(userId).build()),false);
if(config==null) { if(config==null) {
config=this.getOne(Wrappers.query(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(adminuserid).build()),false); config=this.getOne(Wrappers.query(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(adminuserid).build()),false);
...@@ -52,19 +53,22 @@ public class IBZConfigService extends ServiceImpl<IBZConfigMapper, IBZConfig> im ...@@ -52,19 +53,22 @@ public class IBZConfigService extends ServiceImpl<IBZConfigMapper, IBZConfig> im
@CacheEvict( value="${cachename}",key = "'cfgid:'+#p0+'||'+#p1+'||'+#p2") @CacheEvict( value="${cachename}",key = "'cfgid:'+#p0+'||'+#p1+'||'+#p2")
public boolean saveConfig(String cfgType,String targetType,String userId,JSONObject config) public boolean saveConfig(String cfgType,String targetType,String userId,JSONObject config)
{ {
if(StringUtils.isEmpty(userId)||StringUtils.isEmpty(cfgType)||StringUtils.isEmpty(targetType)) if(StringUtils.isEmpty(userId)||StringUtils.isEmpty(cfgType)||StringUtils.isEmpty(targetType)){
throw new BadRequestAlertException("保存配置失败,参数缺失","IBZConfig",cfgType); throw new BadRequestAlertException("保存配置失败,参数缺失","IBZConfig",cfgType);
}
String cfg="{}"; String cfg="{}";
if(config!=null) if(config!=null){
cfg=JSONObject.toJSONString(config); cfg=JSONObject.toJSONString(config);
}
return this.saveOrUpdate(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(userId).cfg(cfg).updateDate(DataObject.getNow()).build()); return this.saveOrUpdate(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(userId).cfg(cfg).updateDate(DataObject.getNow()).build());
} }
@CacheEvict( value="${cachename}",key = "'cfgid:'+#p0+'||'+#p1+'||'+#p2") @CacheEvict( value="${cachename}",key = "'cfgid:'+#p0+'||'+#p1+'||'+#p2")
public void resetConfig(String cfgType,String targetType,String userId) public void resetConfig(String cfgType,String targetType,String userId)
{ {
if(StringUtils.isEmpty(userId)||StringUtils.isEmpty(cfgType)||StringUtils.isEmpty(targetType)) if(StringUtils.isEmpty(userId)||StringUtils.isEmpty(cfgType)||StringUtils.isEmpty(targetType)){
throw new BadRequestAlertException("重置配置失败,参数缺失","IBZConfig",cfgType); throw new BadRequestAlertException("重置配置失败,参数缺失","IBZConfig",cfgType);
}
this.remove(Wrappers.query(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(userId).build())); this.remove(Wrappers.query(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(userId).build()));
} }
......
...@@ -29,10 +29,10 @@ public class IBZUAAUserService implements AuthenticationUserService{ ...@@ -29,10 +29,10 @@ public class IBZUAAUserService implements AuthenticationUserService{
@Override @Override
public AuthenticationUser loadUserByUsername(String username) { public AuthenticationUser loadUserByUsername(String username) {
AuthenticationUser user=uaaFeignClient.loginByUsername(username); AuthenticationUser user=uaaFeignClient.loginByUsername(username);
if(user==null) if(user==null){
throw new BadRequestAlertException("登录失败","IBZUAAUser",username); throw new BadRequestAlertException("登录失败","IBZUAAUser",username);
}
return user; return user;
} }
...@@ -51,8 +51,9 @@ public class IBZUAAUserService implements AuthenticationUserService{ ...@@ -51,8 +51,9 @@ public class IBZUAAUserService implements AuthenticationUserService{
logininfo.setLoginname(loginname); logininfo.setLoginname(loginname);
logininfo.setPassword(password); logininfo.setPassword(password);
AuthenticationUser user=uaaFeignClient.login(logininfo); AuthenticationUser user=uaaFeignClient.login(logininfo);
if(user==null) if(user==null){
throw new BadRequestAlertException("登录失败","IBZUAAUser",username); throw new BadRequestAlertException("登录失败","IBZUAAUser",username);
}
return user; return user;
} }
......
...@@ -37,14 +37,18 @@ public class IBZUSERServiceImpl extends ServiceImpl<IBZUSERMapper, IBZUSER> impl ...@@ -37,14 +37,18 @@ public class IBZUSERServiceImpl extends ServiceImpl<IBZUSERMapper, IBZUSER> impl
String[] data=username.split("[|]"); String[] data=username.split("[|]");
String loginname=""; String loginname="";
String domains=""; String domains="";
if(data.length>0) if(data.length>0){
loginname=data[0].trim(); loginname=data[0].trim();
if(data.length>1) }
if(data.length>1){
domains=data[1].trim(); domains=data[1].trim();
if(!StringUtils.isEmpty(loginname)) }
if(!StringUtils.isEmpty(loginname)){
conds.eq("loginname",loginname); conds.eq("loginname",loginname);
if(!StringUtils.isEmpty(domains)) }
if(!StringUtils.isEmpty(domains)){
conds.eq("domains",domains); conds.eq("domains",domains);
}
IBZUSER user = this.getOne(conds); IBZUSER user = this.getOne(conds);
if (user == null) { if (user == null) {
throw new UsernameNotFoundException("用户" + username + "未找到"); throw new UsernameNotFoundException("用户" + username + "未找到");
...@@ -58,10 +62,12 @@ public class IBZUSERServiceImpl extends ServiceImpl<IBZUSERMapper, IBZUSER> impl ...@@ -58,10 +62,12 @@ public class IBZUSERServiceImpl extends ServiceImpl<IBZUSERMapper, IBZUSER> impl
@Override @Override
public AuthenticationUser loadUserByLogin(String username, String password){ public AuthenticationUser loadUserByLogin(String username, String password){
AuthenticationUser authuserdetail = loadUserByUsername(username); AuthenticationUser authuserdetail = loadUserByUsername(username);
if(pwencrymode==1) if(pwencrymode==1){
password = DigestUtils.md5DigestAsHex(password.getBytes()); password = DigestUtils.md5DigestAsHex(password.getBytes());
else if(pwencrymode==2) }
else if(pwencrymode==2){
password = DigestUtils.md5DigestAsHex(String.format("%1$s||%2$s", username, password).getBytes()); password = DigestUtils.md5DigestAsHex(String.format("%1$s||%2$s", username, password).getBytes());
}
if(!authuserdetail.getPassword().equals( password )){ if(!authuserdetail.getPassword().equals( password )){
throw new BadRequestAlertException("用户名密码错误","IBZUSER",username); throw new BadRequestAlertException("用户名密码错误","IBZUSER",username);
} }
......
...@@ -48,10 +48,12 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -48,10 +48,12 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
if(cacheMap.size()>0){ if(cacheMap.size()>0){
log.info(String.format("正在保存审计数据,当前审计集合数量为[%s]",cacheMap.size())); log.info(String.format("正在保存审计数据,当前审计集合数量为[%s]",cacheMap.size()));
List temp=new ArrayList(); List temp=new ArrayList();
if(cacheMap.size()<500) if(cacheMap.size()<500){
temp.addAll(cacheMap); temp.addAll(cacheMap);
else }
else{
temp.addAll(cacheMap.subList(0,500)); temp.addAll(cacheMap.subList(0,500));
}
this.saveBatch(temp); this.saveBatch(temp);
cacheMap.removeAll(temp); cacheMap.removeAll(temp);
log.info(String.format("保存完成,当前审计集合数量为[%s]",cacheMap.size())); log.info(String.format("保存完成,当前审计集合数量为[%s]",cacheMap.size()));
...@@ -74,8 +76,9 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -74,8 +76,9 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
dataAudit.setAuditobject(entity.getClass().getSimpleName()); dataAudit.setAuditobject(entity.getClass().getSimpleName());
dataAudit.setAuditobjectdata(idValue); dataAudit.setAuditobjectdata(idValue);
dataAudit.setOptime(new Timestamp(new Date().getTime())); dataAudit.setOptime(new Timestamp(new Date().getTime()));
if(request!=null) if(request!=null){
dataAudit.setIpaddress(getIpAddress(request, AuthenticationUser.getAuthenticationUser())); dataAudit.setIpaddress(getIpAddress(request, AuthenticationUser.getAuthenticationUser()));
}
dataAudit.setAuditinfo(getAuditInfo(entity,auditFields)); dataAudit.setAuditinfo(getAuditInfo(entity,auditFields));
dataAudit.setIsdatachanged(1); dataAudit.setIsdatachanged(1);
cacheMap.add(dataAudit); cacheMap.add(dataAudit);
...@@ -96,9 +99,10 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -96,9 +99,10 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
//获取更新后的审计内容 //获取更新后的审计内容
String auditInfo=getUpdateAuditInfo(beforeEntity,afterEntity,auditFields);//比较更新前后差异内容 String auditInfo=getUpdateAuditInfo(beforeEntity,afterEntity,auditFields);//比较更新前后差异内容
int isDataChanged=1; int isDataChanged=1;
if(StringUtils.isEmpty(auditInfo))//审计内容是否发生变化 //审计内容是否发生变化
if(StringUtils.isEmpty(auditInfo)){
isDataChanged=0; isDataChanged=0;
}
IBZDataAudit dataAudit =new IBZDataAudit(); IBZDataAudit dataAudit =new IBZDataAudit();
dataAudit.setOppersonid(AuthenticationUser.getAuthenticationUser().getUserid()); dataAudit.setOppersonid(AuthenticationUser.getAuthenticationUser().getUserid());
dataAudit.setOppersonname(String.format("%s[%s]",AuthenticationUser.getAuthenticationUser().getPersonname(),AuthenticationUser.getAuthenticationUser().getOrgname())); dataAudit.setOppersonname(String.format("%s[%s]",AuthenticationUser.getAuthenticationUser().getPersonname(),AuthenticationUser.getAuthenticationUser().getOrgname()));
...@@ -106,8 +110,9 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -106,8 +110,9 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
dataAudit.setAuditobject(afterEntity.getClass().getSimpleName()); dataAudit.setAuditobject(afterEntity.getClass().getSimpleName());
dataAudit.setAuditobjectdata(idValue); dataAudit.setAuditobjectdata(idValue);
dataAudit.setOptime(new Timestamp(new Date().getTime())); dataAudit.setOptime(new Timestamp(new Date().getTime()));
if(request!=null) if(request!=null){
dataAudit.setIpaddress(getIpAddress(request, AuthenticationUser.getAuthenticationUser())); dataAudit.setIpaddress(getIpAddress(request, AuthenticationUser.getAuthenticationUser()));
}
dataAudit.setAuditinfo(auditInfo); dataAudit.setAuditinfo(auditInfo);
dataAudit.setIsdatachanged(isDataChanged); dataAudit.setIsdatachanged(isDataChanged);
cacheMap.add(dataAudit); cacheMap.add(dataAudit);
...@@ -128,8 +133,9 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -128,8 +133,9 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
dataAudit.setAuditobject(entity.getClass().getSimpleName()); dataAudit.setAuditobject(entity.getClass().getSimpleName());
dataAudit.setAuditobjectdata(idValue); dataAudit.setAuditobjectdata(idValue);
dataAudit.setOptime(new Timestamp(new Date().getTime())); dataAudit.setOptime(new Timestamp(new Date().getTime()));
if(request!=null) if(request!=null){
dataAudit.setIpaddress(getIpAddress(request, AuthenticationUser.getAuthenticationUser())); dataAudit.setIpaddress(getIpAddress(request, AuthenticationUser.getAuthenticationUser()));
}
dataAudit.setAuditinfo(getAuditInfo(entity,auditFields)); dataAudit.setAuditinfo(getAuditInfo(entity,auditFields));
dataAudit.setIsdatachanged(1); dataAudit.setIsdatachanged(1);
cacheMap.add(dataAudit); cacheMap.add(dataAudit);
...@@ -137,13 +143,13 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -137,13 +143,13 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
private String getAuditInfo(EntityBase entity, Map<String, Audit> auditFields){ private String getAuditInfo(EntityBase entity, Map<String, Audit> auditFields){
String auditResult=""; String auditResult="";
if(auditFields.size()==0) if(auditFields.size()==0){
return auditResult; return auditResult;
}
Map<String, DEField> deFields= DEFieldCacheMap.getDEFields(entity.getClass()); Map<String, DEField> deFields= DEFieldCacheMap.getDEFields(entity.getClass());
if(deFields.size()==0) if(deFields.size()==0){
return auditResult; return auditResult;
}
JSONArray auditFieldArray=new JSONArray(); JSONArray auditFieldArray=new JSONArray();
for (Map.Entry<String, Audit> auditField : auditFields.entrySet()) { for (Map.Entry<String, Audit> auditField : auditFields.entrySet()) {
Object objFieldName=auditField.getKey(); Object objFieldName=auditField.getKey();
...@@ -152,8 +158,9 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -152,8 +158,9 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
if(deFields.containsKey(fieldName)){ if(deFields.containsKey(fieldName)){
deField= deFields.get(fieldName); deField= deFields.get(fieldName);
} }
if(ObjectUtils.isEmpty(deField)) if(ObjectUtils.isEmpty(deField)){
continue; continue;
}
Object value=dataTransfer(entity.get(fieldName),deField.fieldType(),deField.format()); Object value=dataTransfer(entity.get(fieldName),deField.fieldType(),deField.format());
if(!StringUtils.isEmpty(value)){ if(!StringUtils.isEmpty(value)){
JSONObject auditFieldObj=new JSONObject(); JSONObject auditFieldObj=new JSONObject();
...@@ -181,12 +188,14 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -181,12 +188,14 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
private String getUpdateAuditInfo(EntityBase oldData, EntityBase newData, Map<String, Audit> auditFields){ private String getUpdateAuditInfo(EntityBase oldData, EntityBase newData, Map<String, Audit> auditFields){
String auditResult=""; String auditResult="";
JSONArray auditFieldArray=new JSONArray(); JSONArray auditFieldArray=new JSONArray();
if(auditFields.size()==0) if(auditFields.size()==0){
return auditResult; return auditResult;
}
Map<String, DEField> deFields= DEFieldCacheMap.getDEFields(oldData.getClass()); Map<String, DEField> deFields= DEFieldCacheMap.getDEFields(oldData.getClass());
if(deFields.size()==0) if(deFields.size()==0){
return auditResult; return auditResult;
}
for (Map.Entry<String, Audit> auditField : auditFields.entrySet()) { for (Map.Entry<String, Audit> auditField : auditFields.entrySet()) {
Object objFieldName=auditField.getKey();//获取注解字段 Object objFieldName=auditField.getKey();//获取注解字段
...@@ -195,8 +204,9 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -195,8 +204,9 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
if(deFields.containsKey(fieldName)){ if(deFields.containsKey(fieldName)){
deField= deFields.get(fieldName); deField= deFields.get(fieldName);
} }
if(ObjectUtils.isEmpty(deField)) if(ObjectUtils.isEmpty(deField)){
continue; continue;
}
Object oldValue=oldData.get(fieldName);//老属性值 Object oldValue=oldData.get(fieldName);//老属性值
Object newValue=newData.get(fieldName);//新属性值 Object newValue=newData.get(fieldName);//新属性值
if(!compare(oldValue,newValue)){ if(!compare(oldValue,newValue)){
...@@ -226,8 +236,9 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -226,8 +236,9 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
* @return * @return
*/ */
private String dataTransfer(Object value,String dataType, String strFormat){ private String dataTransfer(Object value,String dataType, String strFormat){
if(value==null) if(value==null){
return ""; return "";
}
String transResult=value.toString(); String transResult=value.toString();
if((dataType.equals("DATE") || dataType.equals("DATETIME") || dataType.equals("TIME")) && (!StringUtils.isEmpty(strFormat))){ //时间类型转换 if((dataType.equals("DATE") || dataType.equals("DATETIME") || dataType.equals("TIME")) && (!StringUtils.isEmpty(strFormat))){ //时间类型转换
Timestamp timestamp =(Timestamp)value; Timestamp timestamp =(Timestamp)value;
...@@ -245,10 +256,12 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -245,10 +256,12 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
* @return * @return
*/ */
private boolean compare(Object sourceObj,Object targetObj){ private boolean compare(Object sourceObj,Object targetObj){
if(sourceObj==null && targetObj==null) if(sourceObj==null && targetObj==null){
return true; return true;
if(sourceObj==null && targetObj!=null) }
if(sourceObj==null && targetObj!=null){
return false; return false;
}
return sourceObj.equals(targetObj); return sourceObj.equals(targetObj);
} }
...@@ -281,8 +294,9 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA ...@@ -281,8 +294,9 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
if(authenticationUser != null && !StringUtils.isEmpty(authenticationUser.getAddr())){ if(authenticationUser != null && !StringUtils.isEmpty(authenticationUser.getAddr())){
return authenticationUser.getAddr(); return authenticationUser.getAddr();
} }
if(request == null) if(request == null){
return ""; return "";
}
String Xip = request.getHeader("X-Real-IP"); String Xip = request.getHeader("X-Real-IP");
String XFor = request.getHeader("X-Forwarded-For"); String XFor = request.getHeader("X-Forwarded-For");
if(!StringUtils.isEmpty(XFor) && !"unKnown".equalsIgnoreCase(XFor)){ if(!StringUtils.isEmpty(XFor) && !"unKnown".equalsIgnoreCase(XFor)){
......
...@@ -36,8 +36,9 @@ public class SimpleFileService implements FileService { ...@@ -36,8 +36,9 @@ public class SimpleFileService implements FileService {
String fileFullPath = this.fileRoot+"ibizutil"+File.separator+fileid+File.separator+fileName; String fileFullPath = this.fileRoot+"ibizutil"+File.separator+fileid+File.separator+fileName;
File file = new File(fileFullPath); File file = new File(fileFullPath);
File parent = new File(file.getParent()); File parent = new File(file.getParent());
if(!parent.exists()) if(!parent.exists()){
parent.mkdirs(); parent.mkdirs();
}
FileCopyUtils.copy(multipartFile.getInputStream(),Files.newOutputStream(file.toPath())); FileCopyUtils.copy(multipartFile.getInputStream(),Files.newOutputStream(file.toPath()));
item=new FileItem(fileid,fileName,fileid,fileName,(int)multipartFile.getSize(),extname); item=new FileItem(fileid,fileName,fileid,fileName,(int)multipartFile.getSize(),extname);
} catch (IOException e) { } catch (IOException e) {
......
...@@ -32,8 +32,9 @@ public class FeignRequestInterceptor implements RequestInterceptor { ...@@ -32,8 +32,9 @@ public class FeignRequestInterceptor implements RequestInterceptor {
if (headerNames != null) { if (headerNames != null) {
while (headerNames.hasMoreElements()) { while (headerNames.hasMoreElements()) {
String name = headerNames.nextElement(); String name = headerNames.nextElement();
if(name.equalsIgnoreCase("transfer-encoding")) if(name.equalsIgnoreCase("transfer-encoding")){
continue; continue;
}
String values = request.getHeader(name); String values = request.getHeader(name);
requestTemplate.header(name, values); requestTemplate.header(name, values);
} }
......
...@@ -44,7 +44,4 @@ public class SearchContextHandlerMethodArgumentResolver implements HandlerMethod ...@@ -44,7 +44,4 @@ public class SearchContextHandlerMethodArgumentResolver implements HandlerMethod
String json=objectMapper.writeValueAsString(set); String json=objectMapper.writeValueAsString(set);
return objectMapper.readValue(json,parameter.getParameterType()); return objectMapper.readValue(json,parameter.getParameterType());
} }
} }
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册