fix(backend): 修复地磅数据查询的组织权限问题

- 在查询条件中添加组织 ID限制,确保只返回当前用户所属组织的数据
- 修复了未登录用户可以查看所有组织数据的bug
This commit is contained in:
2025-03-13 12:41:01 +08:00
parent e54f58dc72
commit d905e1dd1e

View File

@@ -513,6 +513,8 @@ where 二次过磅时间>='%s' and 二次过磅时间<='%s'
String where = "where 1 = 1 ";
where += " and d.organization_id = :organizationId";
if (request.getStartTime() != null) {
where += " and d.ecgb_time >= :startTime ";
}
@@ -609,6 +611,9 @@ where 二次过磅时间>='%s' and 二次过磅时间<='%s'
Query selectQuery = em.createNativeQuery(selectSql, Tuple.class);
Query countQuery = em.createNativeQuery(countSql, Integer.class);
selectQuery.setParameter("organizationId", Ctx.currentUser().getOrganizationId());
countQuery.setParameter("organizationId", Ctx.currentUser().getOrganizationId());
if (request.getStartTime() != null) {
selectQuery.setParameter("startTime", request.getStartTime());
countQuery.setParameter("startTime", request.getStartTime());