jfinal的model和record如何相互转化?
一、model转record:
Model类:
1、
/**
* Convert model to record.
*/
public Record toRecord() {
return new Record().setColumns(getAttrs());
}
Record 类
2、
/**
* Set columns value with map.
* @param columns the columns map
*/
public Record setColumns(Map<String, Object> columns) {
this.getColumns().putAll(columns);
return this;
}
3、
/**
* Set columns value with Model object.
* @param model the Model object
*/
public Record setColumns(Model<?> model) {
getColumns().putAll(model.getAttrs());
return this;
}
二、record转model:
model类:
public M put(Record record) {
attrs.putAll(record.getColumns());
return (M)this;
}
不积跬步无以至千里,不积小流无以成江海