From d54f559d343bc5ae5cc7a96296fa1ee455660c15 Mon Sep 17 00:00:00 2001 From: b2894lxlx <517289602@qq.com> Date: Sat, 24 Oct 2026 14:55:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=A1=E6=A0=B8=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E4=B8=8E=E7=94=B3=E6=8A=A5=E5=8F=AF=E8=A7=81=E6=80=A7=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E7=BB=9F=E4=B8=80=20Docker=20=E5=8C=97=E4=BA=AC?= =?UTF-8?q?=E6=97=B6=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复团支部等角色待审漏数、PageParam 对 Collection 的 IN 条件失效,以及容器默认 UTC 导致时间偏移 8 小时的问题。 Co-authored-by: Cursor --- Dockerfile | 19 +++++++++++++++ docker-compose.yml | 17 +++++++++++++ .../com/gxwebsoft/WebSoftApplication.java | 4 ++++ .../common/core/web/BaseController.java | 4 ++++ .../gxwebsoft/common/core/web/PageParam.java | 24 +++++++++++++++++-- .../gxmu/controller/ReviewListController.java | 5 ++++ .../gxmu/mapper/xml/ReviewListMapper.xml | 7 +++--- src/main/resources/application-prod.yml | 2 +- src/main/resources/application.yml | 2 +- 9 files changed, 77 insertions(+), 7 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2ffff37 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM openjdk:8-jdk-alpine + +WORKDIR /app + +RUN mkdir -p /app/logs /app/uploads /app/file \ + && apk add --no-cache tzdata \ + && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ + && echo "Asia/Shanghai" > /etc/timezone + +ENV TZ=Asia/Shanghai +ENV LANG=C.UTF-8 +ENV JAVA_OPTS="-Xms512m -Xmx1024m -Duser.timezone=Asia/Shanghai -Djava.security.egd=file:/dev/./urandom" +ENV SPRING_PROFILES_ACTIVE=prod + +COPY target/*.jar app.jar + +EXPOSE 38927 + +ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar app.jar"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..979161b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3.8' + +services: + tuanwei-api: + build: . + container_name: tuanwei-api + ports: + - "38927:38927" + environment: + - TZ=Asia/Shanghai + - SPRING_PROFILES_ACTIVE=prod + - JAVA_OPTS=-Xms512m -Xmx1024m -Duser.timezone=Asia/Shanghai -Djava.security.egd=file:/dev/./urandom + volumes: + - ./logs:/app/logs + - ./file:/app/file + - ./uploads:/app/uploads + restart: unless-stopped diff --git a/src/main/java/com/gxwebsoft/WebSoftApplication.java b/src/main/java/com/gxwebsoft/WebSoftApplication.java index 514ef0d..0baf59a 100644 --- a/src/main/java/com/gxwebsoft/WebSoftApplication.java +++ b/src/main/java/com/gxwebsoft/WebSoftApplication.java @@ -14,6 +14,8 @@ import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.web.socket.config.annotation.EnableWebSocket; +import java.util.TimeZone; + /** * 启动类 * Created by WebSoft on 2018-02-22 11:29:03 @@ -29,6 +31,8 @@ import org.springframework.web.socket.config.annotation.EnableWebSocket; public class WebSoftApplication { public static void main(String[] args) { + // Docker 默认 UTC,未设置 TZ 时 LocalDateTime.now() 会比北京时间慢 8 小时 + TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); SpringApplication.run(WebSoftApplication.class, args); } diff --git a/src/main/java/com/gxwebsoft/common/core/web/BaseController.java b/src/main/java/com/gxwebsoft/common/core/web/BaseController.java index 45ae9fb..85b6e1c 100644 --- a/src/main/java/com/gxwebsoft/common/core/web/BaseController.java +++ b/src/main/java/com/gxwebsoft/common/core/web/BaseController.java @@ -171,6 +171,10 @@ public class BaseController { return; } Set userIds = resolveScopedUserIdsByOrganization(); + // 组织树解析偶发漏掉本人时,仍保证能看到自己提交的数据 + if (loginUserId != null) { + userIds.add(loginUserId); + } if (!userIds.isEmpty()) { userIdsSetter.accept(userIds); } diff --git a/src/main/java/com/gxwebsoft/common/core/web/PageParam.java b/src/main/java/com/gxwebsoft/common/core/web/PageParam.java index 31fa46f..8cac235 100644 --- a/src/main/java/com/gxwebsoft/common/core/web/PageParam.java +++ b/src/main/java/com/gxwebsoft/common/core/web/PageParam.java @@ -260,10 +260,30 @@ public class PageParam extends Page { queryWrapper.isNotNull(fieldName); break; case IN: - queryWrapper.in(fieldName, fieldValue); + // Collection 必须走 in(column, Collection),不能走 in(column, Object...), + // 否则整个集合会被当成单个参数,导致 user_id IN (?) 永远匹配不到。 + if (fieldValue instanceof Collection) { + Collection coll = (Collection) fieldValue; + if (!coll.isEmpty()) { + queryWrapper.in(fieldName, coll); + } + } else if (fieldValue != null && fieldValue.getClass().isArray()) { + queryWrapper.in(fieldName, (Object[]) fieldValue); + } else { + queryWrapper.in(fieldName, fieldValue); + } break; case NOT_IN: - queryWrapper.notIn(fieldName, fieldValue); + if (fieldValue instanceof Collection) { + Collection coll = (Collection) fieldValue; + if (!coll.isEmpty()) { + queryWrapper.notIn(fieldName, coll); + } + } else if (fieldValue != null && fieldValue.getClass().isArray()) { + queryWrapper.notIn(fieldName, (Object[]) fieldValue); + } else { + queryWrapper.notIn(fieldName, fieldValue); + } break; case IN_STR: if (fieldValue instanceof String) { diff --git a/src/main/java/com/gxwebsoft/gxmu/controller/ReviewListController.java b/src/main/java/com/gxwebsoft/gxmu/controller/ReviewListController.java index 1e4cf77..5817d1f 100644 --- a/src/main/java/com/gxwebsoft/gxmu/controller/ReviewListController.java +++ b/src/main/java/com/gxwebsoft/gxmu/controller/ReviewListController.java @@ -170,6 +170,11 @@ public class ReviewListController extends BaseController { if (!isBackendAccess(param) || !hasBackendScopeRole()) { return; } + // 已按当前审核人收敛时,不再按申报人组织过滤。 + // 否则团支部/院团委等角色会漏掉「已指派给自己、但申报人不在本组织树」的待审。 + if (param.getUserId() != null) { + return; + } User loginUser = getLoginUser(); if (loginUser == null || loginUser.getOrganizationId() == null) { return; diff --git a/src/main/java/com/gxwebsoft/gxmu/mapper/xml/ReviewListMapper.xml b/src/main/java/com/gxwebsoft/gxmu/mapper/xml/ReviewListMapper.xml index 352d722..d22438c 100644 --- a/src/main/java/com/gxwebsoft/gxmu/mapper/xml/ReviewListMapper.xml +++ b/src/main/java/com/gxwebsoft/gxmu/mapper/xml/ReviewListMapper.xml @@ -264,9 +264,6 @@ AND a.create_time <= #{param.createTimeEnd} - - AND a.user_id = #{param.userId} - AND a.sort_number = #{param.sortNumber} @@ -467,6 +464,10 @@ AND latest_group.pk = grouped.pk INNER JOIN gxmu_review_list latest ON latest.id = latest_group.latest_id + + + AND latest.user_id = #{param.userId} + AND latest.status = #{param.status} diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 5d99cc8..9d2e71c 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -3,7 +3,7 @@ # 数据源配置 spring: datasource: - url: jdbc:mysql://1Panel-mariadb-ZOpD:3306/tuanwei?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8&rewriteBatchedStatements=true + url: jdbc:mysql://1Panel-mariadb-ZOpD:3306/tuanwei?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true username: tuanwei password: TytQZsSW5m4wGh38 driver-class-name: com.mysql.cj.jdbc.Driver diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 6be5c30..0687ff6 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -38,7 +38,7 @@ spring: # json时间格式设置 jackson: - time-zone: GMT+8 + time-zone: Asia/Shanghai date-format: yyyy-MM-dd HH:mm:ss # 设置上传文件大小