提交merge1.3

This commit is contained in:
2025-12-27 15:30:25 +08:00
parent 8c607c8749
commit 088861f66e
1245 changed files with 220442 additions and 77616 deletions

View File

@@ -14,6 +14,7 @@ import javax.servlet.http.HttpServletRequest;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.core.common.utils.DateUtils;
import com.core.common.utils.SecurityUtils;
import com.core.framework.config.TenantContext;
import com.openhis.common.constant.CommonConstants;
/**
@@ -100,6 +101,15 @@ public class HisQueryUtils {
return queryWrapper;
}
// 新增SQL转义方法防止注入风险
private static String escapeSql(String value) {
if (value == null) {
return "";
}
// 转义单引号PostgreSQL中用两个单引号表示一个单引号
return value.replace("'", "''");
}
/**
* 检查时间字符串是否符合指定格式
*
@@ -146,6 +156,8 @@ public class HisQueryUtils {
// 获取当前登录用户的租户 ID
if (SecurityUtils.getAuthentication() != null) {
return SecurityUtils.getLoginUser().getTenantId();
} else if (TenantContext.getCurrentTenant() != null) {
return TenantContext.getCurrentTenant();
}
return 0;
}

View File

@@ -0,0 +1,56 @@
package com.openhis.common.utils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.ArrayList;
import java.util.List;
/**
* 分页工具类
*/
public class PageUtils {
/**
* 手动分页
*
* @param allList 数据
* @param pageNo 页码
* @param pageSize 每页大小
* @return 分页数据
*/
public static <T> Page<T> buildPage(List<T> allList, long pageNo, long pageSize) {
Page<T> page = new Page<>();
int total = allList.size();
if (total == 0) {
page.setRecords(new ArrayList<>());
page.setTotal(0);
page.setCurrent(pageNo);
page.setSize(pageSize);
page.setPages(0L);
return page;
}
// 计算分页起始位置
int startIndex = (int)((pageNo - 1) * pageSize);
if (startIndex >= total) {
// 如果起始位置超过总数,返回最后一页
startIndex = (int)((total - 1) / pageSize * pageSize);
pageNo = (total + pageSize - 1) / pageSize;
}
int endIndex = (int)Math.min(startIndex + pageSize, total);
// 获取当前页数据
List<T> currentPageList = allList.subList(startIndex, endIndex);
// 设置分页信息
page.setRecords(new ArrayList<>(currentPageList));
page.setCurrent(pageNo);
page.setSize(pageSize);
page.setTotal(total);
page.setPages((total + pageSize - 1) / pageSize); // 计算总页数
return page;
}
}