|
@@ -1,5 +1,6 @@
|
|
package cn.com.qmth.examcloud.service.core.api;
|
|
package cn.com.qmth.examcloud.service.core.api;
|
|
|
|
|
|
|
|
+import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
@@ -29,6 +30,8 @@ import cn.com.qmth.examcloud.service.core.entity.Org;
|
|
import cn.com.qmth.examcloud.service.core.repo.OrgRepo;
|
|
import cn.com.qmth.examcloud.service.core.repo.OrgRepo;
|
|
import cn.com.qmth.examcloud.service.core.service.OrgService;
|
|
import cn.com.qmth.examcloud.service.core.service.OrgService;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 机构服务API
|
|
* 机构服务API
|
|
* Created by songyue on 17/1/14.
|
|
* Created by songyue on 17/1/14.
|
|
@@ -87,15 +90,25 @@ public class OrgApi {
|
|
|
|
|
|
@ApiOperation(value="新增机构",notes="新增")
|
|
@ApiOperation(value="新增机构",notes="新增")
|
|
@PostMapping
|
|
@PostMapping
|
|
- public ResponseEntity addSchool(@RequestBody Org org){
|
|
|
|
|
|
+ public ResponseEntity addSchool(@RequestBody Org org, HttpServletRequest request){
|
|
org.setCreateTime(new Date());
|
|
org.setCreateTime(new Date());
|
|
|
|
+ AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
|
|
|
|
+ if(accessUser != null){
|
|
|
|
+ org.setParentId(accessUser.getOrgId());
|
|
|
|
+ org.setRootId(accessUser.getRootOrgId());
|
|
|
|
+ }
|
|
return new ResponseEntity(orgRepo.save(org),HttpStatus.CREATED);
|
|
return new ResponseEntity(orgRepo.save(org),HttpStatus.CREATED);
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value="更新机构",notes="更新")
|
|
@ApiOperation(value="更新机构",notes="更新")
|
|
@PutMapping
|
|
@PutMapping
|
|
- public ResponseEntity updateSchool(@RequestBody Org org){
|
|
|
|
|
|
+ public ResponseEntity updateSchool(@RequestBody Org org,HttpServletRequest request){
|
|
org.setUpdateTime(new Date());
|
|
org.setUpdateTime(new Date());
|
|
|
|
+ AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
|
|
|
|
+ if(accessUser != null){
|
|
|
|
+ org.setParentId(accessUser.getOrgId());
|
|
|
|
+ org.setRootId(accessUser.getRootOrgId());
|
|
|
|
+ }
|
|
return new ResponseEntity(orgRepo.save(org),HttpStatus.OK);
|
|
return new ResponseEntity(orgRepo.save(org),HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|