From 4830dad75496439cca400eca940037cac2d5f57e Mon Sep 17 00:00:00 2001 From: alvis Date: Wed, 13 Jan 2021 09:16:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mindskip/xzs/context/WebContext.java | 8 ++++++-- .../listener/CalculateExamPaperAnswerListener.java | 13 +++++++++---- .../com/mindskip/xzs/listener/UserLogListener.java | 10 +++++++--- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/source/xzs/src/main/java/com/mindskip/xzs/context/WebContext.java b/source/xzs/src/main/java/com/mindskip/xzs/context/WebContext.java index 03d589e..8f5c3c8 100644 --- a/source/xzs/src/main/java/com/mindskip/xzs/context/WebContext.java +++ b/source/xzs/src/main/java/com/mindskip/xzs/context/WebContext.java @@ -2,18 +2,22 @@ package com.mindskip.xzs.context; import com.mindskip.xzs.domain.User; import com.mindskip.xzs.service.UserService; -import lombok.AllArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Component; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; @Component -@AllArgsConstructor public class WebContext { private static final String USER_ATTRIBUTES = "USER_ATTRIBUTES"; private final UserService userService; + @Autowired + public WebContext(UserService userService) { + this.userService = userService; + } + public void setCurrentUser(User user) { RequestContextHolder.currentRequestAttributes().setAttribute(USER_ATTRIBUTES, user, RequestAttributes.SCOPE_REQUEST); diff --git a/source/xzs/src/main/java/com/mindskip/xzs/listener/CalculateExamPaperAnswerListener.java b/source/xzs/src/main/java/com/mindskip/xzs/listener/CalculateExamPaperAnswerListener.java index 31cd861..c8a7ef8 100644 --- a/source/xzs/src/main/java/com/mindskip/xzs/listener/CalculateExamPaperAnswerListener.java +++ b/source/xzs/src/main/java/com/mindskip/xzs/listener/CalculateExamPaperAnswerListener.java @@ -1,6 +1,5 @@ package com.mindskip.xzs.listener; -import com.mindskip.xzs.domain.*; import com.mindskip.xzs.domain.*; import com.mindskip.xzs.domain.enums.ExamPaperTypeEnum; import com.mindskip.xzs.domain.enums.QuestionTypeEnum; @@ -9,7 +8,7 @@ import com.mindskip.xzs.service.ExamPaperAnswerService; import com.mindskip.xzs.service.ExamPaperQuestionCustomerAnswerService; import com.mindskip.xzs.service.TaskExamCustomerAnswerService; import com.mindskip.xzs.service.TextContentService; -import lombok.AllArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -22,15 +21,21 @@ import java.util.List; * @author 武汉思维跳跃科技有限公司 */ @Component -@AllArgsConstructor public class CalculateExamPaperAnswerListener implements ApplicationListener { - private final ExamPaperAnswerService examPaperAnswerService; private final ExamPaperQuestionCustomerAnswerService examPaperQuestionCustomerAnswerService; private final TextContentService textContentService; private final TaskExamCustomerAnswerService examCustomerAnswerService; + @Autowired + public CalculateExamPaperAnswerListener(ExamPaperAnswerService examPaperAnswerService, ExamPaperQuestionCustomerAnswerService examPaperQuestionCustomerAnswerService, TextContentService textContentService, TaskExamCustomerAnswerService examCustomerAnswerService) { + this.examPaperAnswerService = examPaperAnswerService; + this.examPaperQuestionCustomerAnswerService = examPaperQuestionCustomerAnswerService; + this.textContentService = textContentService; + this.examCustomerAnswerService = examCustomerAnswerService; + } + @Override @Transactional public void onApplicationEvent(CalculateExamPaperAnswerCompleteEvent calculateExamPaperAnswerCompleteEvent) { diff --git a/source/xzs/src/main/java/com/mindskip/xzs/listener/UserLogListener.java b/source/xzs/src/main/java/com/mindskip/xzs/listener/UserLogListener.java index dc1010b..24926a5 100644 --- a/source/xzs/src/main/java/com/mindskip/xzs/listener/UserLogListener.java +++ b/source/xzs/src/main/java/com/mindskip/xzs/listener/UserLogListener.java @@ -2,15 +2,19 @@ package com.mindskip.xzs.listener; import com.mindskip.xzs.event.UserEvent; import com.mindskip.xzs.service.UserEventLogService; -import lombok.AllArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; @Component -@AllArgsConstructor public class UserLogListener implements ApplicationListener { - private UserEventLogService userEventLogService; + private final UserEventLogService userEventLogService; + + @Autowired + public UserLogListener(UserEventLogService userEventLogService) { + this.userEventLogService = userEventLogService; + } @Override public void onApplicationEvent(UserEvent userEvent) {