Commit 64d4f18d authored by bing zhang's avatar bing zhang
Browse files

1

parent 539344b2
package com.mindskip.xzs.domain.enums;
import java.util.HashMap;
import java.util.Map;
public enum ExamPaperAnswerStatusEnum {
WaitJudge(1, "待批改"),
Complete(2, "完成");
int code;
String name;
ExamPaperAnswerStatusEnum(int code, String name) {
this.code = code;
this.name = name;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
private static final Map<Integer, ExamPaperAnswerStatusEnum> keyMap = new HashMap<>();
static {
for (ExamPaperAnswerStatusEnum item : ExamPaperAnswerStatusEnum.values()) {
keyMap.put(item.getCode(), item);
}
}
public static ExamPaperAnswerStatusEnum fromCode(Integer code) {
return keyMap.get(code);
}
}
package com.mindskip.xzs.domain.enums;
import java.util.HashMap;
import java.util.Map;
public enum ExamPaperTypeEnum {
Fixed(1, "固定试卷"),
TimeLimit(4, "时段试卷"),
Task(6, "任务试卷");
int code;
String name;
ExamPaperTypeEnum(int code, String name) {
this.code = code;
this.name = name;
}
private static final Map<Integer, ExamPaperTypeEnum> keyMap = new HashMap<>();
static {
for (ExamPaperTypeEnum item : ExamPaperTypeEnum.values()) {
keyMap.put(item.getCode(), item);
}
}
public static ExamPaperTypeEnum fromCode(Integer code) {
return keyMap.get(code);
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package com.mindskip.xzs.domain.enums;
public enum QuestionStatusEnum {
OK(1, "正常"),
Publish(2, "发布");
int code;
String name;
QuestionStatusEnum(int code, String name) {
this.code = code;
this.name = name;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package com.mindskip.xzs.domain.enums;
import java.util.HashMap;
import java.util.Map;
public enum QuestionTypeEnum {
SingleChoice(1, "单选题"),
MultipleChoice(2, "多选题"),
TrueFalse(3, "判断题"),
GapFilling(4, "填空题"),
ShortAnswer(5, "简答题");
int code;
String name;
QuestionTypeEnum(int code, String name) {
this.code = code;
this.name = name;
}
private static final Map<Integer, QuestionTypeEnum> keyMap = new HashMap<>();
static {
for (QuestionTypeEnum item : QuestionTypeEnum.values()) {
keyMap.put(item.getCode(), item);
}
}
public static QuestionTypeEnum fromCode(Integer code) {
return keyMap.get(code);
}
public static boolean needSaveTextContent(Integer code) {
QuestionTypeEnum questionTypeEnum = QuestionTypeEnum.fromCode(code);
switch (questionTypeEnum) {
case GapFilling:
case ShortAnswer:
return true;
default:
return false;
}
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package com.mindskip.xzs.domain.enums;
import java.util.HashMap;
import java.util.Map;
public enum RoleEnum {
STUDENT(1, "STUDENT"),
ADMIN(3, "ADMIN");
int code;
String name;
RoleEnum(int code, String name) {
this.code = code;
this.name = name;
}
private static final Map<Integer, RoleEnum> keyMap = new HashMap<>();
static {
for (RoleEnum item : RoleEnum.values()) {
keyMap.put(item.getCode(), item);
}
}
public static RoleEnum fromCode(Integer code) {
return keyMap.get(code);
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getRoleName() {
return "ROLE_" + name;
}
}
package com.mindskip.xzs.domain.enums;
import java.util.HashMap;
import java.util.Map;
public enum UserStatusEnum {
Enable(1, "启用"),
Disable(2, "禁用");
int code;
String name;
UserStatusEnum(int code, String name) {
this.code = code;
this.name = name;
}
private static final Map<Integer, UserStatusEnum> keyMap = new HashMap<>();
static {
for (UserStatusEnum item : UserStatusEnum.values()) {
keyMap.put(item.getCode(), item);
}
}
public static UserStatusEnum fromCode(Integer code) {
return keyMap.get(code);
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package com.mindskip.xzs.domain.exam;
public class ExamPaperQuestionItemObject {
private Integer id;
private Integer itemOrder;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getItemOrder() {
return itemOrder;
}
public void setItemOrder(Integer itemOrder) {
this.itemOrder = itemOrder;
}
}
package com.mindskip.xzs.domain.exam;
import java.util.List;
public class ExamPaperTitleItemObject {
private String name;
private List<ExamPaperQuestionItemObject> questionItems;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<ExamPaperQuestionItemObject> getQuestionItems() {
return questionItems;
}
public void setQuestionItems(List<ExamPaperQuestionItemObject> questionItems) {
this.questionItems = questionItems;
}
}
package com.mindskip.xzs.domain.other;
public class ExamPaperAnswerUpdate {
private Integer id;
private Integer customerScore;
private Boolean doRight;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getCustomerScore() {
return customerScore;
}
public void setCustomerScore(Integer customerScore) {
this.customerScore = customerScore;
}
public Boolean getDoRight() {
return doRight;
}
public void setDoRight(Boolean doRight) {
this.doRight = doRight;
}
}
package com.mindskip.xzs.domain.other;
public class KeyValue {
private String name;
private Integer value;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
}
package com.mindskip.xzs.domain.question;
public class QuestionItemObject {
private String prefix;
private String content;
private Integer score;
private String itemUuid;
public String getPrefix() {
return prefix;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Integer getScore() {
return score;
}
public void setScore(Integer score) {
this.score = score;
}
public String getItemUuid() {
return itemUuid;
}
public void setItemUuid(String itemUuid) {
this.itemUuid = itemUuid;
}
}
package com.mindskip.xzs.domain.question;
import java.util.List;
public class QuestionObject {
private String titleContent;
private String analyze;
private List<QuestionItemObject> questionItemObjects;
private String correct;
public String getTitleContent() {
return titleContent;
}
public void setTitleContent(String titleContent) {
this.titleContent = titleContent;
}
public String getAnalyze() {
return analyze;
}
public void setAnalyze(String analyze) {
this.analyze = analyze;
}
public List<QuestionItemObject> getQuestionItemObjects() {
return questionItemObjects;
}
public void setQuestionItemObjects(List<QuestionItemObject> questionItemObjects) {
this.questionItemObjects = questionItemObjects;
}
public String getCorrect() {
return correct;
}
public void setCorrect(String correct) {
this.correct = correct;
}
}
package com.mindskip.xzs.domain.task;
public class TaskItemAnswerObject {
private Integer examPaperId;
private Integer examPaperAnswerId;
private Integer status;
public TaskItemAnswerObject(){
}
public TaskItemAnswerObject(Integer examPaperId, Integer examPaperAnswerId, Integer status) {
this.examPaperId = examPaperId;
this.examPaperAnswerId = examPaperAnswerId;
this.status = status;
}
public Integer getExamPaperId() {
return examPaperId;
}
public void setExamPaperId(Integer examPaperId) {
this.examPaperId = examPaperId;
}
public Integer getExamPaperAnswerId() {
return examPaperAnswerId;
}
public void setExamPaperAnswerId(Integer examPaperAnswerId) {
this.examPaperAnswerId = examPaperAnswerId;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}
package com.mindskip.xzs.domain.task;
public class TaskItemObject {
private Integer examPaperId;
private String examPaperName;
private Integer itemOrder;
public Integer getExamPaperId() {
return examPaperId;
}
public void setExamPaperId(Integer examPaperId) {
this.examPaperId = examPaperId;
}
public String getExamPaperName() {
return examPaperName;
}
public void setExamPaperName(String examPaperName) {
this.examPaperName = examPaperName;
}
public Integer getItemOrder() {
return itemOrder;
}
public void setItemOrder(Integer itemOrder) {
this.itemOrder = itemOrder;
}
}
package com.mindskip.xzs.event;
import com.mindskip.xzs.domain.ExamPaperAnswerInfo;
import org.springframework.context.ApplicationEvent;
/**
* @version 3.3.0
* @description: The type Calculate exam paper answer complete event.
* Copyright (C), 2020-2021, 武汉思维跳跃科技有限公司
* @date 2021/5/25 10:45
*/
public class CalculateExamPaperAnswerCompleteEvent extends ApplicationEvent {
private final ExamPaperAnswerInfo examPaperAnswerInfo;
/**
* Instantiates a new Calculate exam paper answer complete event.
*
* @param examPaperAnswerInfo the exam paper answer info
*/
public CalculateExamPaperAnswerCompleteEvent(final ExamPaperAnswerInfo examPaperAnswerInfo) {
super(examPaperAnswerInfo);
this.examPaperAnswerInfo = examPaperAnswerInfo;
}
/**
* Gets exam paper answer info.
*
* @return the exam paper answer info
*/
public ExamPaperAnswerInfo getExamPaperAnswerInfo() {
return examPaperAnswerInfo;
}
}
package com.mindskip.xzs.event;
import com.mindskip.xzs.domain.User;
import org.springframework.context.ApplicationEvent;
/**
* @version 3.5.0
* @description: The type On registration complete event.
* Copyright (C), 2020-2021, 武汉思维跳跃科技有限公司
* @date 2021/12/25 9:45
*/
public class OnRegistrationCompleteEvent extends ApplicationEvent {
private final User user;
/**
* Instantiates a new On registration complete event.
*
* @param user the user
*/
public OnRegistrationCompleteEvent(final User user) {
super(user);
this.user = user;
}
/**
* Gets user.
*
* @return the user
*/
public User getUser() {
return user;
}
}
\ No newline at end of file
package com.mindskip.xzs.event;
import com.mindskip.xzs.domain.UserEventLog;
import org.springframework.context.ApplicationEvent;
/**
* @version 3.5.0
* @description: The type User event.
* Copyright (C), 2020-2021, 武汉思维跳跃科技有限公司
* @date 2021/12/25 9:45
*/
public class UserEvent extends ApplicationEvent {
private final UserEventLog userEventLog;
/**
* Instantiates a new User event.
*
* @param userEventLog the user event log
*/
public UserEvent(final UserEventLog userEventLog) {
super(userEventLog);
this.userEventLog = userEventLog;
}
/**
* Gets user event log.
*
* @return the user event log
*/
public UserEventLog getUserEventLog() {
return userEventLog;
}
}
package com.mindskip.xzs.exception;
/**
* @version 3.5.0
* @description: The type Business exception.
* Copyright (C), 2020-2021, 武汉思维跳跃科技有限公司
* @date 2021/12/25 9:45
*/
public class BusinessException extends RuntimeException {
/**
* The constant UNKNOWN_EXCEPTION.
*/
public static final int UNKNOWN_EXCEPTION = 0;
private int code;
/**
* Instantiates a new Business exception.
*/
public BusinessException() {
super();
}
/**
* Instantiates a new Business exception.
*
* @param message the message
* @param cause the cause
*/
public BusinessException(String message, Throwable cause) {
super(message, cause);
}
/**
* Instantiates a new Business exception.
*
* @param message the message
*/
public BusinessException(String message) {
super(message);
}
/**
* Instantiates a new Business exception.
*
* @param cause the cause
*/
public BusinessException(Throwable cause) {
super(cause);
}
/**
* Instantiates a new Business exception.
*
* @param code the code
*/
public BusinessException(int code) {
super();
this.code = code;
}
/**
* Instantiates a new Business exception.
*
* @param code the code
* @param message the message
* @param cause the cause
*/
public BusinessException(int code, String message, Throwable cause) {
super(message, cause);
this.code = code;
}
/**
* Instantiates a new Business exception.
*
* @param code the code
* @param message the message
*/
public BusinessException(int code, String message) {
super(message);
this.code = code;
}
/**
* Instantiates a new Business exception.
*
* @param code the code
* @param cause the cause
*/
public BusinessException(int code, Throwable cause) {
super(cause);
this.code = code;
}
/**
* Gets code.
*
* @return the code
*/
public int getCode() {
return code;
}
/**
* Sets code.
*
* @param code the code
*/
public void setCode(int code) {
this.code = code;
}
/**
* Is unknown boolean.
*
* @return the boolean
*/
public boolean isUnknown() {
return code == UNKNOWN_EXCEPTION;
}
}
package com.mindskip.xzs.listener;
import com.mindskip.xzs.domain.*;
import com.mindskip.xzs.domain.enums.ExamPaperTypeEnum;
import com.mindskip.xzs.domain.enums.QuestionTypeEnum;
import com.mindskip.xzs.event.CalculateExamPaperAnswerCompleteEvent;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
/**
* @version 3.5.0
* @description: The type Calculate exam paper answer listener.
* Copyright (C), 2020-2021, 武汉思维跳跃科技有限公司
* @date 2021/12/25 9:45
*/
@Component
public class CalculateExamPaperAnswerListener implements ApplicationListener<CalculateExamPaperAnswerCompleteEvent> {
private final ExamPaperAnswerService examPaperAnswerService;
private final ExamPaperQuestionCustomerAnswerService examPaperQuestionCustomerAnswerService;
private final TextContentService textContentService;
private final TaskExamCustomerAnswerService examCustomerAnswerService;
/**
* Instantiates a new Calculate exam paper answer listener.
*
* @param examPaperAnswerService the exam paper answer service
* @param examPaperQuestionCustomerAnswerService the exam paper question customer answer service
* @param textContentService the text content service
* @param examCustomerAnswerService the exam customer answer service
*/
@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) {
Date now = new Date();
ExamPaperAnswerInfo examPaperAnswerInfo = (ExamPaperAnswerInfo) calculateExamPaperAnswerCompleteEvent.getSource();
ExamPaper examPaper = examPaperAnswerInfo.getExamPaper();
ExamPaperAnswer examPaperAnswer = examPaperAnswerInfo.getExamPaperAnswer();
List<ExamPaperQuestionCustomerAnswer> examPaperQuestionCustomerAnswers = examPaperAnswerInfo.getExamPaperQuestionCustomerAnswers();
examPaperAnswerService.insertByFilter(examPaperAnswer);
examPaperQuestionCustomerAnswers.stream().filter(a -> QuestionTypeEnum.needSaveTextContent(a.getQuestionType())).forEach(d -> {
TextContent textContent = new TextContent(d.getAnswer(), now);
textContentService.insertByFilter(textContent);
d.setTextContentId(textContent.getId());
d.setAnswer(null);
});
examPaperQuestionCustomerAnswers.forEach(d -> {
d.setExamPaperAnswerId(examPaperAnswer.getId());
});
examPaperQuestionCustomerAnswerService.insertList(examPaperQuestionCustomerAnswers);
switch (ExamPaperTypeEnum.fromCode(examPaper.getPaperType())) {
case Task: {
examCustomerAnswerService.insertOrUpdate(examPaper, examPaperAnswer, now);
break;
}
default:
break;
}
}
}
package com.mindskip.xzs.listener;
import com.mindskip.xzs.domain.User;
import com.mindskip.xzs.event.OnRegistrationCompleteEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
/**
* @version 3.5.0
* @description: The type Email send listener.
* Copyright (C), 2020-2021, 武汉思维跳跃科技有限公司
* @date 2021/12/25 9:45
*/
@Component
public class EmailSendListener implements ApplicationListener<OnRegistrationCompleteEvent> {
@Override
@NonNull
public void onApplicationEvent(OnRegistrationCompleteEvent event) {
User user = event.getUser();
System.out.println("User register Email sender :" + user.getUserName());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment