+ SQLTable 类新增了几个方法

+ SQLColumn 类新增关于 char 的构造器
This commit is contained in:
坏黑 2018-09-03 19:07:20 +08:00
parent 9585dab04d
commit b4f06444ab
4 changed files with 44 additions and 11 deletions

View File

@ -6,7 +6,7 @@
<groupId>me.skymc</groupId>
<artifactId>TabooLib</artifactId>
<version>4.22</version>
<version>4.23</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -29,6 +29,16 @@ public class SQLColumn {
this(columnType, 0, 0, columnName, null);
}
/**
* CHAR 类型常用构造器
*
* @param columnType
* @param columnName
*/
public SQLColumn(SQLColumnType columnType, int m, String columnName) {
this(columnType, m, 0, columnName, null);
}
/**
* 主键 类型常用构造器
* new SQLColumn(SQLColumnType.TEXT, "username", SQLColumnOption.PRIMARY_KEY, SQLColumnOption.AUTO_INCREMENT);
@ -99,25 +109,25 @@ public class SQLColumn {
for (SQLColumnOption options : columnOptions) {
switch (options) {
case NOTNULL:
builder.append(" not null");
builder.append(" NOT NULL");
break;
case PRIMARY_KEY:
builder.append(" primary key");
builder.append(" PRIMARY KEY");
break;
case AUTO_INCREMENT:
builder.append(" auto_increment");
builder.append(" AUTO_INCREMENT");
break;
case UNIQUE_KEY:
builder.append(" unique key");
builder.append(" UNIQUE KEY");
break;
default:
}
}
if (defaultValue != null) {
if (defaultValue instanceof String) {
builder.append(" default '").append(defaultValue).append("'");
builder.append(" DEFAULT '").append(defaultValue).append("'");
} else {
builder.append(" default ").append(defaultValue);
builder.append(" DEFAULT ").append(defaultValue);
}
}
return builder.toString();

View File

@ -60,7 +60,11 @@ public class SQLTable {
return executeQuery("select * from " + tableName + " where " + where);
}
public RunnableUpdate executeUpdate(String where, String update) {
public RunnableQuery executeSelect() {
return executeQuery("select * from " + tableName);
}
public RunnableUpdate executeUpdate(String update, String where) {
return executeUpdate("update " + tableName + " set " + update + " where " + where);
}

View File

@ -3,6 +3,9 @@ package me.skymc.taboolib.other;
import java.text.DecimalFormat;
import java.util.Random;
/**
* @author sky
*/
public class NumberUtils {
private static Random random = new Random();
@ -52,6 +55,22 @@ public class NumberUtils {
}
}
public static Boolean getBooleanAbbreviation(String str) {
if (str == null || str.isEmpty()) {
return false;
}
if (str.length() < 4) {
char var = str.charAt(0);
if (var == 'y' || var == 'Y' || var == 't' || var == 'T' || var == '1') {
return true;
}
if (var == 'n' || var == 'N' || var == 'f' || var == 'F' || var == '0') {
return false;
}
}
return getBoolean(str);
}
@Deprecated
public static Random getRand() {
return random;