浏览代码

小重构

wangwei 6 年之前
父节点
当前提交
61c6f41e68

+ 22 - 21
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamOrgTimeController.java

@@ -1,18 +1,25 @@
 package cn.com.qmth.examcloud.core.examwork.api.controller;
 
-import cn.com.qmth.examcloud.commons.base.util.ErrorMsg;
-import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgTimeRepo;
-import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgTime;
-import cn.com.qmth.examcloud.core.examwork.service.impl.ExamOrgTimeService;
-import io.swagger.annotations.ApiOperation;
+import java.util.List;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
-import java.util.List;
+import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgTimeRepo;
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgTime;
+import cn.com.qmth.examcloud.core.examwork.service.impl.ExamOrgTimeService;
+import io.swagger.annotations.ApiOperation;
 
 /**
  * 考试服务API Created by songyue on 17/1/13.
@@ -51,23 +58,17 @@ public class ExamOrgTimeController {
 
 	@ApiOperation(value = "新增学习中心考试时间", notes = "新增")
 	@PostMapping()
-	public ResponseEntity add(@RequestBody ExamOrgTime examOrgTime) {
-		try {
-			return new ResponseEntity(examOrgTimeRepo.save(examOrgTime), HttpStatus.OK);
-		} catch (Exception e) {
-			return new ResponseEntity(new ErrorMsg(e.getMessage()),
-					HttpStatus.INTERNAL_SERVER_ERROR);
-		}
+	public ExamOrgTime add(@RequestBody ExamOrgTime examOrgTime) {
+		ExamOrgTime saved = examOrgTimeRepo.save(examOrgTime);
+
+		return saved;
 	}
 
 	@ApiOperation(value = "更新学习中心考试时间", notes = "更新")
 	@PutMapping()
-	public ResponseEntity update(@RequestBody ExamOrgTime examOrgTime) {
-		try {
-			return new ResponseEntity(examOrgTimeRepo.save(examOrgTime), HttpStatus.OK);
-		} catch (Exception e) {
-			return new ResponseEntity(new ErrorMsg(e.getMessage()),
-					HttpStatus.INTERNAL_SERVER_ERROR);
-		}
+	public ExamOrgTime update(@RequestBody ExamOrgTime examOrgTime) {
+
+		ExamOrgTime saved = examOrgTimeRepo.save(examOrgTime);
+		return saved;
 	}
 }