fix javadoc warning
This commit is contained in:
@@ -45,6 +45,12 @@ public class SQLProvider {
|
||||
/** 反射缓存 */
|
||||
private static final Map<Class<?>, EntityMeta> ENTITY_META_CACHE = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 创建 SQL 提供器
|
||||
*/
|
||||
public SQLProvider() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 Page 对象查询数据列表
|
||||
*
|
||||
@@ -148,6 +154,12 @@ public class SQLProvider {
|
||||
return sql.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param context 代理器上下文
|
||||
* @return SQL
|
||||
*/
|
||||
public String selectAll(ProviderContext context) {
|
||||
EntityMeta meta = getEntityMeta(context);
|
||||
StringBuilder sql = new StringBuilder();
|
||||
@@ -162,6 +174,7 @@ public class SQLProvider {
|
||||
* 插入
|
||||
* <p><i>不实现 {@link Creatable} 也允许调用是合理的,某些数据属于关联数据,不参与主创建过程</i></p>
|
||||
*
|
||||
* @param context 代理器上下文
|
||||
* @param entity 实体
|
||||
* @return SQL
|
||||
*/
|
||||
@@ -299,6 +312,12 @@ public class SQLProvider {
|
||||
return "UPDATE `%s` SET `deleted_at` = %s WHERE `%s` = #{id}".formatted(meta.table, Time.now(), meta.idFieldColumn.columnName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据示例批量逻辑删除
|
||||
*
|
||||
* @param entity 实体
|
||||
* @return SQL
|
||||
*/
|
||||
public String deleteAllByExample(Object entity) {
|
||||
EntityMeta meta = getEntityMeta(entity.getClass());
|
||||
TimiException.required(meta.canDelete, "not allow delete for %s".formatted(meta.entityClass));
|
||||
@@ -398,6 +417,11 @@ public class SQLProvider {
|
||||
/** true 为可销毁(硬删除) */
|
||||
final boolean canDestroy;
|
||||
|
||||
/**
|
||||
* 创建实体元数据
|
||||
*
|
||||
* @param entityClass 实体类型
|
||||
*/
|
||||
public EntityMeta(Class<?> entityClass) {
|
||||
this.entityClass = entityClass;
|
||||
|
||||
@@ -459,38 +483,83 @@ public class SQLProvider {
|
||||
return sb.substring(0, sb.length() - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取实体类型
|
||||
*
|
||||
* @return 实体类型
|
||||
*/
|
||||
public Class<?> getEntityClass() {
|
||||
return entityClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表名
|
||||
*
|
||||
* @return 表名
|
||||
*/
|
||||
public String getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取查询字段映射
|
||||
*
|
||||
* @return 查询字段映射
|
||||
*/
|
||||
public String getSelectAllClause() {
|
||||
return selectAllClause;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 ID 字段映射
|
||||
*
|
||||
* @return ID 字段映射
|
||||
*/
|
||||
public FieldColumn getIdFieldColumn() {
|
||||
return idFieldColumn;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段映射列表
|
||||
*
|
||||
* @return 字段映射列表
|
||||
*/
|
||||
public List<FieldColumn> getFieldColumnList() {
|
||||
return fieldColumnList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可创建
|
||||
*
|
||||
* @return true 为可创建
|
||||
*/
|
||||
public boolean canCreate() {
|
||||
return canCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可更新
|
||||
*
|
||||
* @return true 为可更新
|
||||
*/
|
||||
public boolean canUpdate() {
|
||||
return canUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可删除
|
||||
*
|
||||
* @return true 为可删除
|
||||
*/
|
||||
public boolean canDelete() {
|
||||
return canDelete;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可销毁
|
||||
*
|
||||
* @return true 为可销毁
|
||||
*/
|
||||
public boolean canDestroy() {
|
||||
return canDestroy;
|
||||
}
|
||||
@@ -525,6 +594,11 @@ public class SQLProvider {
|
||||
|
||||
final DeleteColumn.Type deleteColumnType;
|
||||
|
||||
/**
|
||||
* 创建字段映射
|
||||
*
|
||||
* @param field 字段
|
||||
*/
|
||||
public FieldColumn(Field field) {
|
||||
this.field = field;
|
||||
|
||||
@@ -551,6 +625,12 @@ public class SQLProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字段值是否为空
|
||||
*
|
||||
* @param entity 实体
|
||||
* @return true 为 null
|
||||
*/
|
||||
public boolean isNull(Object entity) {
|
||||
try {
|
||||
return Ref.getFieldValue(entity, field, Object.class) == null;
|
||||
@@ -559,10 +639,22 @@ public class SQLProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字段值是否非空
|
||||
*
|
||||
* @param entity 实体
|
||||
* @return true 为非 null
|
||||
*/
|
||||
public boolean isNotNull(Object entity) {
|
||||
return !isNull(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字段值是否为空
|
||||
*
|
||||
* @param entity 实体
|
||||
* @return true 为空
|
||||
*/
|
||||
public boolean isEmpty(Object entity) {
|
||||
try {
|
||||
return TimiJava.isEmpty(Ref.getFieldValue(entity, field, Object.class));
|
||||
@@ -571,10 +663,22 @@ public class SQLProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字段值是否非空
|
||||
*
|
||||
* @param entity 实体
|
||||
* @return true 为非空
|
||||
*/
|
||||
public boolean isNotEmpty(Object entity) {
|
||||
return !isEmpty(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段字符串值
|
||||
*
|
||||
* @param obj 实体
|
||||
* @return 字符串值
|
||||
*/
|
||||
public String getAsString(Object obj) {
|
||||
try {
|
||||
return field.get(obj).toString();
|
||||
@@ -583,30 +687,65 @@ public class SQLProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段
|
||||
*
|
||||
* @return 字段
|
||||
*/
|
||||
public Field getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段名
|
||||
*
|
||||
* @return 字段名
|
||||
*/
|
||||
public String getFieldName() {
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列名
|
||||
*
|
||||
* @return 列名
|
||||
*/
|
||||
public String getColumnName() {
|
||||
return columnName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为 ID 字段
|
||||
*
|
||||
* @return true 为 ID 字段
|
||||
*/
|
||||
public boolean isId() {
|
||||
return isId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否非 ID 字段
|
||||
*
|
||||
* @return true 为非 ID 字段
|
||||
*/
|
||||
public boolean isNotId() {
|
||||
return !isId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否自动 UUID
|
||||
*
|
||||
* @return true 为自动 UUID
|
||||
*/
|
||||
public boolean isAutoUUID() {
|
||||
return isAutoUUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否自动大写 UUID
|
||||
*
|
||||
* @return true 为自动大写 UUID
|
||||
*/
|
||||
public boolean isAutoUpperUUID() {
|
||||
return isAutoUpperUUID;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user