Skip to content

Commit

Permalink
修复重构后Page获取数据扩展信息时候,执行字段Functional没成功赋值的Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Yiuman committed Jan 20, 2021
1 parent 6142fe7 commit af90bab
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import com.github.yiuman.citrus.support.crud.view.RecordExtender;
import com.github.yiuman.citrus.support.crud.view.TableView;
import com.github.yiuman.citrus.support.crud.view.impl.DialogView;
import com.github.yiuman.citrus.support.crud.view.impl.SimpleTableView;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
Expand Down Expand Up @@ -57,24 +57,27 @@ public void setItemKey(String itemKey) {
this.itemKey = itemKey;
}

@SuppressWarnings("unchecked")

public Map<String, Map<String, Object>> getRecordExtend() {
if (this.recordExtend == null) {
this.recordExtend = new HashMap<>();
if (!StringUtils.isEmpty(itemKey)) {
if (view instanceof RecordExtender) {
RecordExtender<T> recordExtender = (RecordExtender<T>) view;
getRecords().forEach(record -> recordExtend.put(key(record), recordExtender.apply(record)));
}
}
}
return recordExtend;
}

public void setRecordExtend(Map<String, Map<String, Object>> recordExtend) {
this.recordExtend = recordExtend;
}

@SuppressWarnings("unchecked")
@Override
public List<T> getRecords() {
List<T> records = super.getRecords();
if (this.recordExtend == null && !StringUtils.isEmpty(itemKey) && view instanceof RecordExtender) {
this.recordExtend = new HashMap<>();
RecordExtender<T> recordExtender = (RecordExtender<T>) view;
records.forEach(record -> recordExtend.put(key(record), recordExtender.apply(record)));
}
return records;
}

public Object getView() {
return view;
}
Expand Down

0 comments on commit af90bab

Please sign in to comment.