jfinal的model和record如何相互转化?
https://www.cnblogs.com/YuyuanNo1/p/9962022.html
https://my.oschina.net/u/2450343/blog/859638
一、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;
}