mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-06 17:36:47 +08:00
修改项目下考试结束时间并未生效修复
This commit is contained in:
@@ -2,6 +2,7 @@ package com.xboe.module.exam.api;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -81,10 +82,23 @@ public class ExamTestApi extends ApiBaseController {
|
||||
if(StringUtil.isBlank(examTest.getTestName())){
|
||||
return badRequest("标题为空");
|
||||
}
|
||||
|
||||
// 确保examTest有一个有效的主键ID(如果适用)
|
||||
// 这取决于您的业务逻辑是否允许更新主键
|
||||
// 通常,更新操作不会改变主键
|
||||
if (examTest.getId() == null) {
|
||||
return badRequest("更新操作需要有效的主键ID");
|
||||
}
|
||||
|
||||
try {
|
||||
examTestService.update(examTest);
|
||||
return success(examTest);
|
||||
} catch (ConstraintViolationException e) {
|
||||
// 捕获约束违反异常,并返回一个更具体的错误消息
|
||||
log.error("修改失败,违反了约束条件", e);
|
||||
return error("修改失败,违反了约束条件(可能是主键已存在)");
|
||||
} catch (Exception e) {
|
||||
// 捕获其他所有异常
|
||||
log.error("修改失败", e);
|
||||
return error("修改失败", e.getMessage());
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public class ExamTest extends BaseEntity {
|
||||
/**
|
||||
* 试卷的ID
|
||||
*/
|
||||
@Column(name = "paper_id",nullable = false,length=20)
|
||||
@Column(name = "paper_id",length=20)
|
||||
private String paperId;
|
||||
|
||||
/**
|
||||
@@ -173,7 +173,7 @@ public class ExamTest extends BaseEntity {
|
||||
|
||||
|
||||
/**启用的,上架*/
|
||||
@Column(name = "enabled", nullable = false, length = 1)
|
||||
@Column(name = "enabled", length = 1)
|
||||
private Boolean enabled;
|
||||
|
||||
@Transient
|
||||
|
||||
@@ -70,7 +70,18 @@ public class ExamTestServiceImpl implements IExamTestService {
|
||||
|
||||
@Override
|
||||
public void update(ExamTest examTest) {
|
||||
examTestDao.update(examTest);
|
||||
if (examTest.getId() == null) {
|
||||
throw new IllegalArgumentException("ID must not be null");
|
||||
}
|
||||
String sql = "update boe_exam_test set arrange = "+ examTest.getArrange() +", deadline_time = '"+examTest.getDeadlineTime() +"' , " +
|
||||
"entrance_time = '"+examTest.getEntranceTime() +"' , paper_id = "+examTest.getPaperId() +",pass_line = "+examTest.getPassLine() +
|
||||
", percent_score = "+examTest.getPercentScore() +" ,publish_time = '"+examTest.getPublishTime()+"' , published = "+examTest.getPublished()+
|
||||
",random_count = "+examTest.getRandomCount()+" ,random_mode = "+examTest.getRandomMode()+",range_type = "+examTest.getRangeType() +
|
||||
",scoring_type = "+examTest.getScoringType() +",show_analysis="+examTest.getShowAnalysis() +",show_answer = "+examTest.getShowAnswer() +
|
||||
",test_duration = "+examTest.getTestDuration() +",test_name = '"+examTest.getTestName() +"',test_remark= "+examTest.getTestRemark() +
|
||||
",test_type= "+examTest.getTestType() +" ,test_up = '"+examTest.getTestUp() +"' ,test_front= "+examTest.getTestFront() +
|
||||
",times = '"+examTest.getTimes() +"' where id = "+examTest.getId()+"";
|
||||
examTestDao.sqlUpdate(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user