ys.artifact-orm.1.0.1.source-code.bean-mongodb.btl Maven / Gradle / Ivy
/**
* 写数据
*/
public Object write(){
Map map = new HashMap<>();
<%for(column in table.columns){%>
map.put("${column.fieldName}",this.${column.fieldName});
<%}%>
return map;
}
/**
* 读数据
*/
public ${table.className} read(Object object){
Map map = (Map)object;
<%
for(column in table.columns){
if(column.type =="byte"){
%>
this.${column.fieldName} = MapUtil.getByte(map ,"${column.fieldName}");
<%}else if(column.type =="short"){%>
this.${column.fieldName} = MapUtil.getShort(map ,"${column.fieldName}");
<%}else if(column.type =="int"){%>
this.${column.fieldName} = MapUtil.getInt(map ,"${column.fieldName}");
<%}else if(column.type =="long"){%>
this.${column.fieldName} = MapUtil.getLong(map ,"${column.fieldName}");
<%}else if(column.type =="float"){%>
this.${column.fieldName} = MapUtil.getFloat(map ,"${column.fieldName}");
<%}else if(column.type =="double"){%>
this.${column.fieldName} = MapUtil.getDouble(map ,"${column.fieldName}");
<%}else if(column.type=="java.util.Date"){%>
this.${column.fieldName} = MapUtil.getDate(map ,"${column.fieldName}");
<%}else if(column.type=="String"){%>
this.${column.fieldName} = MapUtil.getStr(map ,"${column.fieldName}");
<%}else if(column.type=="boolean"){%>
this.${column.fieldName} = MapUtil.getBoolean(map ,"${column.fieldName}");
<%}else{%>
this.${column.fieldName} = MapUtil.get(map ,"${column.fieldName}",${column.type}.class);
<%}%>
<%}%>
return this;
}