|
@@ -141,14 +141,21 @@ public class OrgController extends ControllerSupport {
|
|
|
@ApiOperation(value = "模糊查询顶级机构的子机构")
|
|
|
@GetMapping("/getSubOrgList/{curPage}/{pageSize}")
|
|
|
public Page<Org> getSubOrgListOfRootOrg(@PathVariable Integer curPage,
|
|
|
- @PathVariable Integer pageSize, @RequestParam Long parentOrgId,
|
|
|
- @RequestParam String code, @RequestParam String name) {
|
|
|
+ @PathVariable Integer pageSize, @RequestParam Long rootOrgId, @RequestParam String code,
|
|
|
+ @RequestParam String name) {
|
|
|
+
|
|
|
+ User accessUser = getAccessUser();
|
|
|
+ if (!isSuperAdmin()) {
|
|
|
+ if (!accessUser.getRootOrgId().equals(rootOrgId)) {
|
|
|
+ throw new StatusException("B-140001", "非法访问");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
Pageable pageable = new PageRequest(curPage - 1, pageSize, Sort.Direction.DESC,
|
|
|
"updateTime");
|
|
|
|
|
|
Org criteria = new Org();
|
|
|
- criteria.setParentId(parentOrgId);
|
|
|
+ criteria.setParentId(rootOrgId);
|
|
|
criteria.setCode(code);
|
|
|
criteria.setName(name);
|
|
|
|
|
@@ -168,6 +175,27 @@ public class OrgController extends ControllerSupport {
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改请通知作者
|
|
|
+ *
|
|
|
+ * @author WANGWEI
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "查询所有顶级机构")
|
|
|
+ @GetMapping("/getAllRootOrgList")
|
|
|
+ public List<Org> getAllRootOrgList() {
|
|
|
+
|
|
|
+ Specification<Org> specification = (root, query, cb) -> {
|
|
|
+ List<Predicate> predicates = new ArrayList<>();
|
|
|
+ predicates.add(cb.isNull(root.get("parentId")));
|
|
|
+ predicates.add(cb.equal(root.get("enable"), true));
|
|
|
+ return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
+ };
|
|
|
+
|
|
|
+ List<Org> ret = orgRepo.findAll(specification);
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 修改请通知作者
|
|
|
*
|
|
@@ -217,7 +245,12 @@ public class OrgController extends ControllerSupport {
|
|
|
*/
|
|
|
@ApiOperation(value = "新增顶级机构", notes = "新增")
|
|
|
@PostMapping("addRootOrg")
|
|
|
- public Org addRootOrg(@RequestBody Org org, HttpServletRequest request) {
|
|
|
+ public Org addRootOrg(@RequestBody Org org) {
|
|
|
+
|
|
|
+ if (!isSuperAdmin()) {
|
|
|
+ throw new StatusException("B-140001", "非法访问");
|
|
|
+ }
|
|
|
+
|
|
|
org.setCreateTime(new Date());
|
|
|
org.setParentId(null);
|
|
|
// 临时
|
|
@@ -233,12 +266,16 @@ public class OrgController extends ControllerSupport {
|
|
|
*
|
|
|
* @author WANGWEI
|
|
|
* @param org
|
|
|
- * @param request
|
|
|
* @return
|
|
|
*/
|
|
|
@ApiOperation(value = "更新顶级机构", notes = "更新")
|
|
|
@PutMapping("updateRootOrg")
|
|
|
- public Org updateRootOrg(@RequestBody Org org, HttpServletRequest request) {
|
|
|
+ public Org updateRootOrg(@RequestBody Org org) {
|
|
|
+
|
|
|
+ if (!isSuperAdmin()) {
|
|
|
+ throw new StatusException("B-140001", "非法访问");
|
|
|
+ }
|
|
|
+
|
|
|
org.setParentId(null);
|
|
|
org.setRootId(org.getId());
|
|
|
Org updated = orgService.update(org.getId(), org);
|
|
@@ -250,12 +287,11 @@ public class OrgController extends ControllerSupport {
|
|
|
*
|
|
|
* @author WANGWEI
|
|
|
* @param org
|
|
|
- * @param request
|
|
|
* @return
|
|
|
*/
|
|
|
@ApiOperation(value = "新增子机构", notes = "新增")
|
|
|
@PostMapping("addSubOrg")
|
|
|
- public Org addSubOrg(@RequestBody Org org, HttpServletRequest request) {
|
|
|
+ public Org addSubOrg(@RequestBody Org org) {
|
|
|
org.setCreateTime(new Date());
|
|
|
cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
org.setParentId(accessUser.getRootOrgId());
|
|
@@ -274,7 +310,7 @@ public class OrgController extends ControllerSupport {
|
|
|
*/
|
|
|
@ApiOperation(value = "更新子机构", notes = "更新")
|
|
|
@PutMapping("updateSubOrg")
|
|
|
- public Org updateSubOrg(@RequestBody Org org, HttpServletRequest request) {
|
|
|
+ public Org updateSubOrg(@RequestBody Org org) {
|
|
|
cn.com.qmth.examcloud.commons.web.security.bean.User accessUser = getAccessUser();
|
|
|
|
|
|
org.setParentId(accessUser.getRootOrgId());
|
|
@@ -356,14 +392,14 @@ public class OrgController extends ControllerSupport {
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "查询所有学校", notes = "查询所有学校")
|
|
|
- @GetMapping("/getAllParentOrg")
|
|
|
+ // @GetMapping("/getAllParentOrg")
|
|
|
public List<Org> getAllParentOrg() {
|
|
|
List<Org> list = orgRepo.findAllParentOrg();
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "查询所有印刷机构", notes = "查询所有印刷机构")
|
|
|
- @GetMapping("/allPrint")
|
|
|
+ // @GetMapping("/allPrint")
|
|
|
public List<Org> getAllPrintOrg() {
|
|
|
List<Org> orgList = orgRepo.findAllPrintByParentId(0L);
|
|
|
return orgList;
|