优化
This commit is contained in:
parent
61adcc0b32
commit
4830dad754
@ -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);
|
||||
|
@ -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<CalculateExamPaperAnswerCompleteEvent> {
|
||||
|
||||
|
||||
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) {
|
||||
|
@ -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<UserEvent> {
|
||||
|
||||
private UserEventLogService userEventLogService;
|
||||
private final UserEventLogService userEventLogService;
|
||||
|
||||
@Autowired
|
||||
public UserLogListener(UserEventLogService userEventLogService) {
|
||||
this.userEventLogService = userEventLogService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(UserEvent userEvent) {
|
||||
|
Loading…
Reference in New Issue
Block a user