commit
4290a53654
@ -2,18 +2,22 @@ package com.mindskip.xzs.context;
|
|||||||
|
|
||||||
import com.mindskip.xzs.domain.User;
|
import com.mindskip.xzs.domain.User;
|
||||||
import com.mindskip.xzs.service.UserService;
|
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.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.context.request.RequestAttributes;
|
import org.springframework.web.context.request.RequestAttributes;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@AllArgsConstructor
|
|
||||||
public class WebContext {
|
public class WebContext {
|
||||||
private static final String USER_ATTRIBUTES = "USER_ATTRIBUTES";
|
private static final String USER_ATTRIBUTES = "USER_ATTRIBUTES";
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public WebContext(UserService userService) {
|
||||||
|
this.userService = userService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setCurrentUser(User user) {
|
public void setCurrentUser(User user) {
|
||||||
RequestContextHolder.currentRequestAttributes().setAttribute(USER_ATTRIBUTES, user, RequestAttributes.SCOPE_REQUEST);
|
RequestContextHolder.currentRequestAttributes().setAttribute(USER_ATTRIBUTES, user, RequestAttributes.SCOPE_REQUEST);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.mindskip.xzs.listener;
|
package com.mindskip.xzs.listener;
|
||||||
|
|
||||||
import com.mindskip.xzs.domain.*;
|
|
||||||
import com.mindskip.xzs.domain.*;
|
import com.mindskip.xzs.domain.*;
|
||||||
import com.mindskip.xzs.domain.enums.ExamPaperTypeEnum;
|
import com.mindskip.xzs.domain.enums.ExamPaperTypeEnum;
|
||||||
import com.mindskip.xzs.domain.enums.QuestionTypeEnum;
|
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.ExamPaperQuestionCustomerAnswerService;
|
||||||
import com.mindskip.xzs.service.TaskExamCustomerAnswerService;
|
import com.mindskip.xzs.service.TaskExamCustomerAnswerService;
|
||||||
import com.mindskip.xzs.service.TextContentService;
|
import com.mindskip.xzs.service.TextContentService;
|
||||||
import lombok.AllArgsConstructor;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -22,15 +21,21 @@ import java.util.List;
|
|||||||
* @author 武汉思维跳跃科技有限公司
|
* @author 武汉思维跳跃科技有限公司
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@AllArgsConstructor
|
|
||||||
public class CalculateExamPaperAnswerListener implements ApplicationListener<CalculateExamPaperAnswerCompleteEvent> {
|
public class CalculateExamPaperAnswerListener implements ApplicationListener<CalculateExamPaperAnswerCompleteEvent> {
|
||||||
|
|
||||||
|
|
||||||
private final ExamPaperAnswerService examPaperAnswerService;
|
private final ExamPaperAnswerService examPaperAnswerService;
|
||||||
private final ExamPaperQuestionCustomerAnswerService examPaperQuestionCustomerAnswerService;
|
private final ExamPaperQuestionCustomerAnswerService examPaperQuestionCustomerAnswerService;
|
||||||
private final TextContentService textContentService;
|
private final TextContentService textContentService;
|
||||||
private final TaskExamCustomerAnswerService examCustomerAnswerService;
|
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
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void onApplicationEvent(CalculateExamPaperAnswerCompleteEvent calculateExamPaperAnswerCompleteEvent) {
|
public void onApplicationEvent(CalculateExamPaperAnswerCompleteEvent calculateExamPaperAnswerCompleteEvent) {
|
||||||
|
@ -2,15 +2,19 @@ package com.mindskip.xzs.listener;
|
|||||||
|
|
||||||
import com.mindskip.xzs.event.UserEvent;
|
import com.mindskip.xzs.event.UserEvent;
|
||||||
import com.mindskip.xzs.service.UserEventLogService;
|
import com.mindskip.xzs.service.UserEventLogService;
|
||||||
import lombok.AllArgsConstructor;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@AllArgsConstructor
|
|
||||||
public class UserLogListener implements ApplicationListener<UserEvent> {
|
public class UserLogListener implements ApplicationListener<UserEvent> {
|
||||||
|
|
||||||
private UserEventLogService userEventLogService;
|
private final UserEventLogService userEventLogService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public UserLogListener(UserEventLogService userEventLogService) {
|
||||||
|
this.userEventLogService = userEventLogService;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplicationEvent(UserEvent userEvent) {
|
public void onApplicationEvent(UserEvent userEvent) {
|
||||||
|
Loading…
Reference in New Issue
Block a user