该方法是sql中where部分的拼写方法。如果感觉有不对的地方可以在评论中指出,并写出正确的代码。
1 /**
2 *
3 * 方法描述:拼接Where条件。
4 * 2016-4-1 下午2:12:14
5 * @param columns("column [|judge][|matching]")judge不写默认为 and,如果val里的值为Object[]则自动为in,matching不写默认为 =
6 * @param value如果是要用
7 * @param param 参数值,
8 * @return
9 */
10 @SuppressWarnings("unchecked")
11 public static String getSqlWhere(String[] columns, Object[] values, List
例子:
1 System.out.println(getSqlWhere(new String[]{"claId","claId|or","claIds","claIds|and|like"},new Object[]{1,2,new Object[]{1,2,1,3},88},new ArrayList()));
2 System.out.println(getSqlWhere(new String[]{"btpTeaId||>=","btpClaId","btpClaArrTeaUserId","btpTeaId||not","or|(","detpId",")"}, new Object[]{"asd","1,1,21".split(","),3,null,null,45,null},new ArrayList()));
3 System.out.println(getSqlWhere(new String[]{"or|(","detpId",")","(","detpId",")"}, new Object[]{null,45,null,null,45,null},new ArrayList()));
4 System.out.println(getSqlWhere(new String[]{"(deptId","deptName)|or|!=","(deptId","deptName)|or|!="}, new Object[]{32,"光秃",32,"光秃"},new ArrayList()));
5 System.out.println(getSqlWhere(new String[]{"postName||like","postStatus","postIsDeleted","(","da","rr"+"|or|is",")"}, new Object[]{44,0,0,null,21,null,null},new ArrayList()));