Merge pull request #42 from mindskip/alvis

优化
This commit is contained in:
alvis 2021-01-13 09:17:20 +08:00 committed by GitHub
commit 4290a53654
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 9 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -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) {