20260728173026
This commit is contained in:
1 parent
63588bd217
commit
5ec7aadef9
25 files changed
+627
-462
No files matched your search
@@ -532,7 +532,26 @@ public class DbUtils {
|
||||
}
|
||||
|
||||
private String buildOrderBy(String orderBy) {
|
||||
String[] parts = orderBy.trim().split("\\s+");
|
||||
String trimmed = orderBy.trim();
|
||||
String lower = trimmed.toLowerCase();
|
||||
|
||||
// CASE 表达式:从末尾剥离可选 ASC/DESC,其余直接返回
|
||||
if (lower.startsWith("case")) {
|
||||
String direction = "";
|
||||
if (lower.endsWith(" asc")) {
|
||||
direction = " ASC";
|
||||
trimmed = trimmed.substring(0, trimmed.length() - 4);
|
||||
} else if (lower.endsWith(" desc")) {
|
||||
direction = " DESC";
|
||||
trimmed = trimmed.substring(0, trimmed.length() - 5);
|
||||
}
|
||||
if (!trimmed.trim().toLowerCase().endsWith("end")) {
|
||||
throw new BusinessException("CASE 表达式必须以 END 结尾");
|
||||
}
|
||||
return trimmed + direction;
|
||||
}
|
||||
|
||||
String[] parts = trimmed.split("\\s+");
|
||||
if (parts.length > 2) {
|
||||
throw new BusinessException("排序字段格式不正确");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user