|
@@ -0,0 +1,118 @@
|
|
|
|
+package com.qmth.cqb.paper.web;
|
|
|
|
+
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
|
+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.RequestParam;
|
|
|
|
+
|
|
|
|
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
|
|
+
|
|
|
|
+import com.qmth.cqb.paper.dto.CoursePropertyDto;
|
|
|
|
+import com.qmth.cqb.paper.model.CourseProperty;
|
|
|
|
+import com.qmth.cqb.paper.service.CoursePropertyService;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @describle 课程属性 coursePropertyController
|
|
|
|
+ * @author weiwenhai
|
|
|
|
+ * @date 2017.11.2
|
|
|
|
+ */
|
|
|
|
+@Controller
|
|
|
|
+@RequestMapping("${api_cqb}/")
|
|
|
|
+public class CoursePropertyController {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private CoursePropertyService coursePropertyService;
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="根据orgId查询所有课程属性", notes="不带分页")
|
|
|
|
+ @GetMapping(value="/courseProperty/all")
|
|
|
|
+ public ResponseEntity<Object> findAllByOrg(HttpServletRequest request){
|
|
|
|
+ AccessUser accessUser = (AccessUser)request.getAttribute("accessUser");
|
|
|
|
+ if(accessUser != null){
|
|
|
|
+ List<CourseProperty> courseProperties = coursePropertyService.findAllByOrgId(accessUser.getRootOrgId());
|
|
|
|
+ return new ResponseEntity<Object>(courseProperties,HttpStatus.OK);
|
|
|
|
+ }
|
|
|
|
+ return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="根据orgId查询所有课程属性", notes="带分页")
|
|
|
|
+ @GetMapping(value="/courseProperty/all/{curPage}/{pageSize}")
|
|
|
|
+ public ResponseEntity<Object> findAllByOrgId(@ModelAttribute CoursePropertyDto coursePropertyDto,
|
|
|
|
+ @PathVariable Integer curPage,
|
|
|
|
+ @PathVariable Integer pageSize,
|
|
|
|
+ HttpServletRequest request){
|
|
|
|
+ AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
|
|
|
|
+ if(accessUser == null){
|
|
|
|
+ return new ResponseEntity(HttpStatus.NOT_FOUND);
|
|
|
|
+ }
|
|
|
|
+ coursePropertyDto.setOrgId(accessUser.getRootOrgId());
|
|
|
|
+ Page<CourseProperty> coursePropertiesPage = coursePropertyService.findAllByOrg(coursePropertyDto, new PageRequest(curPage - 1,pageSize));
|
|
|
|
+ return new ResponseEntity<Object>(coursePropertiesPage,HttpStatus.OK);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="新增课程属性" ,notes="新增课程属性")
|
|
|
|
+ @PostMapping(value="/courseProperty/save")
|
|
|
|
+ public ResponseEntity<Object> saveCourseProperty(HttpServletRequest request,@RequestBody CoursePropertyDto coursePropertyDto){
|
|
|
|
+ AccessUser accessUser = (AccessUser)request.getAttribute("accessUser");
|
|
|
|
+ if(accessUser != null){
|
|
|
|
+ try {
|
|
|
|
+ coursePropertyDto.setOrgId(accessUser.getRootOrgId());
|
|
|
|
+ coursePropertyService.saveCourseProperty(coursePropertyDto);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ return new ResponseEntity<Object>(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
|
+ }
|
|
|
|
+ return new ResponseEntity<Object>(HttpStatus.OK);
|
|
|
|
+ }
|
|
|
|
+ return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="启用", notes="启用")
|
|
|
|
+ @PutMapping(value="/courseProperty/open/{id}")
|
|
|
|
+ public ResponseEntity<Object> openCourseProperty(HttpServletRequest request, @PathVariable Long id){
|
|
|
|
+ AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
|
|
|
|
+ if(accessUser != null){
|
|
|
|
+ coursePropertyService.openCourseProperty(id, accessUser.getRootOrgId());
|
|
|
|
+ return new ResponseEntity<Object>(HttpStatus.OK);
|
|
|
|
+ }
|
|
|
|
+ return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="禁用", notes="禁用")
|
|
|
|
+ @PutMapping(value="/courseProperty/close/{id}")
|
|
|
|
+ public ResponseEntity<Object> closeCourseProperty(HttpServletRequest request, @PathVariable Long id){
|
|
|
|
+ AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
|
|
|
|
+ if(accessUser != null){
|
|
|
|
+ coursePropertyService.closeCourseProperty(id, accessUser.getRootOrgId());
|
|
|
|
+ return new ResponseEntity<Object>(HttpStatus.OK);
|
|
|
|
+ }
|
|
|
|
+ return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="根据courseId查询所有课程属性", notes="不带分页")
|
|
|
|
+ @GetMapping(value="/courseProperty/all/{courseId}")
|
|
|
|
+ public ResponseEntity<Object> findAllByCourseId(HttpServletRequest request,@PathVariable Long courseId){
|
|
|
|
+ AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
|
|
|
|
+ if(accessUser != null){
|
|
|
|
+ List<CourseProperty> courseProperties = coursePropertyService.findAllByCourseId(courseId);
|
|
|
|
+ return new ResponseEntity<Object>(courseProperties,HttpStatus.OK);
|
|
|
|
+ }
|
|
|
|
+ return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
|
|
|
|
+ }
|
|
|
|
+}
|