Merge pull request !47 from alvis/alvis
This commit is contained in:
alvis 2021-01-13 09:17:12 +08:00 committed by Gitee
commit eb00e2b31e
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) {