From 7daa0a6e98fa292e94961392eac3e8ebd244a629 Mon Sep 17 00:00:00 2001 From: huangyw <1207046171@qq.com> Date: Wed, 7 Aug 2024 16:23:17 +0800 Subject: [PATCH] =?UTF-8?q?release:=20=E5=BC=95=E5=85=A5queryDsl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luoo_common/src/main/java/util/ExcelUtil.java | 2 -- luoo_user/pom.xml | 29 +++++++++++++++++++ .../com/luoo/user/config/WebMvcConfig.java | 23 +++++++++++++++ .../user/service/UserPointLogService.java | 3 ++ 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 luoo_user/src/main/java/com/luoo/user/config/WebMvcConfig.java diff --git a/luoo_common/src/main/java/util/ExcelUtil.java b/luoo_common/src/main/java/util/ExcelUtil.java index 579600d..52c5d75 100644 --- a/luoo_common/src/main/java/util/ExcelUtil.java +++ b/luoo_common/src/main/java/util/ExcelUtil.java @@ -26,7 +26,6 @@ import annotation.Excel; import annotation.Excels; import annotation.Excel.ColumnType; import annotation.Excel.Type; -import com.sun.xml.internal.ws.util.UtilException; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.RegExUtils; import org.apache.commons.lang3.reflect.FieldUtils; @@ -267,7 +266,6 @@ public class ExcelUtil{ catch (Exception e) { log.error("导入Excel异常{}", e.getMessage()); - throw new UtilException(e.getMessage()); } finally { diff --git a/luoo_user/pom.xml b/luoo_user/pom.xml index 73faf45..3789860 100644 --- a/luoo_user/pom.xml +++ b/luoo_user/pom.xml @@ -147,6 +147,17 @@ ${mybatis-plus.version} compile + + + + com.querydsl + querydsl-apt + + + com.querydsl + querydsl-jpa + + app @@ -174,6 +185,24 @@ http://116.62.145.60:2375 + + + com.mysema.maven + apt-maven-plugin + 1.1.3 + + + generate-sources + + process + + + target/generated-sources/java + com.querydsl.apt.jpa.JPAAnnotationProcessor + + + + diff --git a/luoo_user/src/main/java/com/luoo/user/config/WebMvcConfig.java b/luoo_user/src/main/java/com/luoo/user/config/WebMvcConfig.java new file mode 100644 index 0000000..2cd1d35 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/config/WebMvcConfig.java @@ -0,0 +1,23 @@ +package com.luoo.user.config; + +import com.querydsl.jpa.impl.JPAQueryFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import javax.persistence.EntityManager; + + +/** + * 使用QueryDSL的功能时,会依赖使用到JPAQueryFactory,而JPAQueryFactory在这里依赖使用EntityManager, + * 所以在主类中做如下配置,使得Spring自动帮我们注入EntityManager与自动管理JPAQueryFactory + * @author NJ + * @create 2022/12/5 15:12 + */ +@Configuration +public class WebMvcConfig implements WebMvcConfigurer { + + @Bean + public JPAQueryFactory jpaQuery(EntityManager entityManager) { + return new JPAQueryFactory(entityManager); + } +} diff --git a/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java b/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java index 6f0ac9d..6c33706 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java @@ -155,6 +155,9 @@ public class UserPointLogService { if (taskPointId != null) { TaskPoint taskPoint = taskPointService.getTaskPoint(taskPointId); + if(taskPoint == null) { + return ; + } // 获取积分任务类型 Integer type = taskPoint.getType();