|
@@ -1,7 +1,6 @@
|
|
|
package cn.com.qmth.examcloud.core.basic.api.controller;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
@@ -14,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
@@ -24,8 +24,6 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import cn.com.qmth.examcloud.commons.base.util.ErrorMsg;
|
|
|
-import cn.com.qmth.examcloud.commons.web.security.entity.AccessUser;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.ExamSiteRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.ExamSite;
|
|
@@ -33,78 +31,70 @@ import cn.com.qmth.examcloud.core.basic.service.impl.ExamSiteService;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
/**
|
|
|
- * 考点服务API
|
|
|
- * Created by songyue on 17/1/14.
|
|
|
+ * 考点服务API Created by songyue on 17/1/14.
|
|
|
*/
|
|
|
+@Transactional
|
|
|
@RestController
|
|
|
@RequestMapping("${$rmp.ctr.basic}/examsite")
|
|
|
-public class ExamSiteController extends ControllerSupport{
|
|
|
-
|
|
|
- private static final Logger LOG = LoggerFactory.getLogger(ExamSiteController.class);
|
|
|
-
|
|
|
- @Autowired
|
|
|
- ExamSiteRepo examSiteRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- ExamSiteService examSiteService;
|
|
|
-
|
|
|
- @ApiOperation(value = "查询考点分页带查询", notes = "分页带查询")
|
|
|
- @GetMapping("/all/{curPage}/{pageSize}")
|
|
|
- public ResponseEntity getAllExamSite(@ModelAttribute ExamSite examSiteCriteria,
|
|
|
- HttpServletRequest request,
|
|
|
- @PathVariable Integer curPage,
|
|
|
- @PathVariable Integer pageSize) {
|
|
|
- return new ResponseEntity(examSiteService.findAll(examSiteCriteria, new PageRequest(curPage - 1, pageSize)), HttpStatus.OK);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @ApiOperation(value = "查询考点不分页带查询", notes = "不分页带查询")
|
|
|
- @GetMapping("/all")
|
|
|
- public ResponseEntity getAllExam(@ModelAttribute ExamSite examSiteCriteria,
|
|
|
- HttpServletRequest request) {
|
|
|
- cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
- if (accessUser != null) {
|
|
|
- return new ResponseEntity(examSiteRepo.findByOrgId(accessUser.getOrgId()), HttpStatus.OK);
|
|
|
- }
|
|
|
- return new ResponseEntity(new ArrayList<ExamSite>(), HttpStatus.OK);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "按ID查询考点", notes = "ID查询")
|
|
|
- @GetMapping("/{id}")
|
|
|
- public ResponseEntity<ExamSite> getExamSiteById(@PathVariable Long id) {
|
|
|
- return new ResponseEntity(examSiteRepo.findOne(id), HttpStatus.OK);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "新增考点", notes = "新增")
|
|
|
- @PostMapping
|
|
|
- public ResponseEntity addExamSite(@RequestBody ExamSite examSite, HttpServletRequest request) {
|
|
|
-
|
|
|
- try {
|
|
|
- examSite.setCreateTime(new Date());
|
|
|
- return new ResponseEntity(examSiteService.save(examSite), HttpStatus.CREATED);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "更新考点", notes = "更新")
|
|
|
- @PutMapping
|
|
|
- public ResponseEntity updateExamSite(@RequestBody ExamSite examSite,
|
|
|
- HttpServletRequest request) {
|
|
|
- try {
|
|
|
- return new ResponseEntity(examSiteService.update(examSite.getId(), examSite), HttpStatus.OK);
|
|
|
- } catch (Exception e) {
|
|
|
- return new ResponseEntity(new ErrorMsg(e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "按ID删除考点", notes = "删除")
|
|
|
- @DeleteMapping("/{id}")
|
|
|
- public ResponseEntity deleteExamSite(@PathVariable String id) {
|
|
|
- List<Long> examStuIds = Stream.of(id.split(",")).map(s->Long.parseLong(s.trim()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- examSiteRepo.deleteInBatch(examSiteRepo.findAll(examStuIds));
|
|
|
- return new ResponseEntity(HttpStatus.OK);
|
|
|
- }
|
|
|
+public class ExamSiteController extends ControllerSupport {
|
|
|
+
|
|
|
+ private static final Logger LOG = LoggerFactory.getLogger(ExamSiteController.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ExamSiteRepo examSiteRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ExamSiteService examSiteService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询考点分页带查询", notes = "分页带查询")
|
|
|
+ @GetMapping("/all/{curPage}/{pageSize}")
|
|
|
+ public ResponseEntity getAllExamSite(@ModelAttribute ExamSite examSiteCriteria,
|
|
|
+ HttpServletRequest request, @PathVariable Integer curPage,
|
|
|
+ @PathVariable Integer pageSize) {
|
|
|
+ return new ResponseEntity(
|
|
|
+ examSiteService.findAll(examSiteCriteria, new PageRequest(curPage - 1, pageSize)),
|
|
|
+ HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询考点不分页带查询", notes = "不分页带查询")
|
|
|
+ @GetMapping("/all")
|
|
|
+ public ResponseEntity getAllExam(@ModelAttribute ExamSite examSiteCriteria,
|
|
|
+ HttpServletRequest request) {
|
|
|
+ cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
+ if (accessUser != null) {
|
|
|
+ return new ResponseEntity(examSiteRepo.findByOrgId(accessUser.getOrgId()),
|
|
|
+ HttpStatus.OK);
|
|
|
+ }
|
|
|
+ return new ResponseEntity(new ArrayList<ExamSite>(), HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "按ID查询考点", notes = "ID查询")
|
|
|
+ @GetMapping("/{id}")
|
|
|
+ public ResponseEntity<ExamSite> getExamSiteById(@PathVariable Long id) {
|
|
|
+ return new ResponseEntity(examSiteRepo.findOne(id), HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "新增考点", notes = "新增")
|
|
|
+ @PostMapping
|
|
|
+ public ExamSite addExamSite(@RequestBody ExamSite examSite) {
|
|
|
+ trim(examSite);
|
|
|
+ return examSiteService.save(examSite);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "更新考点", notes = "更新")
|
|
|
+ @PutMapping
|
|
|
+ public ExamSite updateExamSite(@RequestBody ExamSite examSite) {
|
|
|
+ trim(examSite);
|
|
|
+ ExamSite updated = examSiteService.update(examSite.getId(), examSite);
|
|
|
+ return updated;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "按ID删除考点", notes = "删除")
|
|
|
+ @DeleteMapping("/{id}")
|
|
|
+ public ResponseEntity deleteExamSite(@PathVariable String id) {
|
|
|
+ List<Long> examStuIds = Stream.of(id.split(",")).map(s -> Long.parseLong(s.trim()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ examSiteRepo.deleteInBatch(examSiteRepo.findAll(examStuIds));
|
|
|
+ return new ResponseEntity(HttpStatus.OK);
|
|
|
+ }
|
|
|
}
|