-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* optimize: 移除缓存配置 * optimize: 剧集资源查询方法
- Loading branch information
Showing
5 changed files
with
91 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,13 @@ | |
|
||
更新日志文档,版本顺序从新到旧,最新版本在最前(上)面。 | ||
|
||
# 0.19.4 | ||
|
||
## 优化 | ||
|
||
- 移除缓存配置 | ||
- 优化查询剧集附件接口 | ||
|
||
# 0.19.3 | ||
|
||
## 优化 | ||
|
69 changes: 69 additions & 0 deletions
69
api/src/main/java/run/ikaros/api/infra/utils/ReflectUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package run.ikaros.api.infra.utils; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Map; | ||
|
||
public class ReflectUtils { | ||
|
||
/** | ||
* 将数据库字段名转换为驼峰命名法的 Java 字段名. | ||
* | ||
* @param dbFieldName 数据库字段名(如 ATTACHMENT_ID) | ||
* @return 转换后的 Java 字段名(如 attachmentId) | ||
*/ | ||
public static String convertToCamelCase(String dbFieldName) { | ||
if (dbFieldName == null || dbFieldName.isEmpty()) { | ||
return dbFieldName; | ||
} | ||
|
||
StringBuilder result = new StringBuilder(); | ||
boolean toUpperCase = false; | ||
|
||
for (int i = 0; i < dbFieldName.length(); i++) { | ||
char ch = dbFieldName.charAt(i); | ||
if (ch == '_') { | ||
toUpperCase = true; | ||
} else { | ||
if (toUpperCase) { | ||
result.append(Character.toUpperCase(ch)); | ||
toUpperCase = false; | ||
} else { | ||
result.append(Character.toLowerCase(ch)); | ||
} | ||
} | ||
} | ||
|
||
return result.toString(); | ||
} | ||
|
||
/** | ||
* Map to Object instance. | ||
*/ | ||
public static <T> T mapToClass(Map<String, Object> map, Class<T> clazz, | ||
boolean ignoreMissingField) { | ||
T instance; | ||
try { | ||
instance = clazz.getDeclaredConstructor().newInstance(); | ||
for (Map.Entry<String, Object> entry : map.entrySet()) { | ||
String fieldName = convertToCamelCase(entry.getKey()); | ||
Object fieldValue = entry.getValue(); | ||
|
||
Field field; | ||
try { | ||
field = clazz.getDeclaredField(fieldName); | ||
} catch (NoSuchFieldException noSuchFieldException) { | ||
if (ignoreMissingField) { | ||
continue; | ||
} else { | ||
throw noSuchFieldException; | ||
} | ||
} | ||
field.setAccessible(true); // 允许访问私有字段 | ||
field.set(instance, fieldValue); | ||
} | ||
} catch (Exception e) { | ||
throw new RuntimeException("Mapping failed", e); | ||
} | ||
return instance; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=0.19.3 | ||
version=0.19.4 |
20 changes: 0 additions & 20 deletions
20
server/src/main/java/run/ikaros/server/cache/CacheConfiguration.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters