//System.out.println("DELETE:"+sql);
return rst.setCode("0").setData(rows);
}
public BizResult update(Map<String,String> e,String where ,String table){
BizResult rst = new BizResult().setCode("-1");
String sql = "desc "+table;
String f,t,k;
List<Map<String,Object>> list = this.mapper.list(sql);
sql = "update {0} set {1} where {2}";
StringBuffer cols = new StringBuffer();
for(Map<String,Object> o : list){
k = o.get("Key").toString();//主键不能修改
if("PRI".equals(k)) continue;
f = o.get("Field").toString();//字段名称
if(!e.containsKey(f)) continue;//未设置字段
cols.append(f).append("=");
t = o.get("Type").toString();//字段类型
if(t.indexOf("int")<0){
//字段未非整形
cols.append("'").append(e.get(f)).append("'").append(",");
}else{
cols.append(e.get(f)).append(",");
}
}
cols = cols.deleteCharAt(cols.length()-1);
if(StringUtil.isNullOrEmpty(where))
where = "1 = 1";
sql = StringUtil.formatSql(sql,table, cols.toString(),where);
// System.out.println(sql);
int rows = this.mapper.execute(sql);
return rst.setCode("0").setData(rows);
}