package com.changhong.autoform.entity.sql.delete; import java.util.Arrays; import java.util.Map; import com.changhong.autoform.entity.sql.Sql; import com.changhong.autoform.entity.sql.Where; import com.changhong.autoform.entity.sql.Where.Conditions; import com.changhong.autoform.entity.sql.Where.JoinType; import com.changhong.autoform.entity.sql.Where.Type; public class Delete extends Sql{ public Delete(String tableName, Map fields) { super(tableName, fields); } public Delete(String tableName, Where where) { super(tableName, null); this.where = where; } private Where where; public Where getWhere() { return where; } public void setWhere(Where where) { this.where = where; } @Override public String getSql() { StringBuilder sql = new StringBuilder(); sql.append(" DELETE FROM ").append(getTableName()) .append(where.getSql()); return sql.toString(); } @Override public Object[] getParams() { return where.getParams(); } public static void main(String[] args) { Delete u = new Delete("user" , new Where( new Conditions("id",Type.EQ,"123"), new Conditions("name",Type.IN, JoinType.AND, Arrays.asList("张三","李四")) )); System.err.println(u.getSql()); System.err.println(Arrays.toString(u.getParams())); } }