Exemplo n.º 1
0
 public String forModelDeleteById(TableInfo tInfo) {
   String primaryKey = tInfo.getPrimaryKey();
   StringBuilder sql = new StringBuilder(45);
   sql.append("delete from \"");
   sql.append(tInfo.getTableName());
   sql.append("\" where \"").append(primaryKey).append("\" = ?");
   return sql.toString();
 }
Exemplo n.º 2
0
 public String forModelFindById(TableInfo tInfo, String columns) {
   StringBuilder sql = new StringBuilder("select ");
   if (columns.trim().equals("*")) {
     sql.append(columns);
   } else {
     String[] columnsArray = columns.split(",");
     for (int i = 0; i < columnsArray.length; i++) {
       if (i > 0) sql.append(", ");
       sql.append("\"").append(columnsArray[i].trim()).append("\"");
     }
   }
   sql.append(" from \"");
   sql.append(tInfo.getTableName());
   sql.append("\" where \"").append(tInfo.getPrimaryKey()).append("\" = ?");
   return sql.toString();
 }
Exemplo n.º 3
0
 public void forModelSave(
     TableInfo tableInfo, Map<String, Object> attrs, StringBuilder sql, List<Object> paras) {
   sql.append("insert into \"").append(tableInfo.getTableName()).append("\"(");
   StringBuilder temp = new StringBuilder(") values(");
   for (Entry<String, Object> e : attrs.entrySet()) {
     String colName = e.getKey();
     if (tableInfo.hasColumnLabel(colName)) {
       if (paras.size() > 0) {
         sql.append(", ");
         temp.append(", ");
       }
       sql.append("\"").append(colName).append("\"");
       temp.append("?");
       paras.add(e.getValue());
     }
   }
   sql.append(temp.toString()).append(")");
 }
Exemplo n.º 4
0
 public void forModelUpdate(
     TableInfo tableInfo,
     Map<String, Object> attrs,
     Set<String> modifyFlag,
     String primaryKey,
     Object id,
     StringBuilder sql,
     List<Object> paras) {
   sql.append("update \"").append(tableInfo.getTableName()).append("\" set ");
   for (Entry<String, Object> e : attrs.entrySet()) {
     String colName = e.getKey();
     if (!primaryKey.equalsIgnoreCase(colName)
         && modifyFlag.contains(colName)
         && tableInfo.hasColumnLabel(colName)) {
       if (paras.size() > 0) sql.append(", ");
       sql.append("\"").append(colName).append("\" = ? ");
       paras.add(e.getValue());
     }
   }
   sql.append(" where \"").append(primaryKey).append("\" = ?");
   paras.add(id);
 }