|
@@ -9,9 +9,14 @@ import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
+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.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
+import cn.com.qmth.examcloud.common.support.tree.TreeNode;
|
|
|
|
+import cn.com.qmth.examcloud.common.support.tree.TreeUtil;
|
|
|
|
+import cn.com.qmth.examcloud.common.support.tree.ZtreeNode;
|
|
import cn.com.qmth.examcloud.service.core.entity.OrgFunction;
|
|
import cn.com.qmth.examcloud.service.core.entity.OrgFunction;
|
|
import cn.com.qmth.examcloud.service.core.repo.OrgFunctionRepo;
|
|
import cn.com.qmth.examcloud.service.core.repo.OrgFunctionRepo;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -35,13 +40,31 @@ public class OrgFunctionApi {
|
|
@GetMapping("/getAllFunctions")
|
|
@GetMapping("/getAllFunctions")
|
|
public ResponseEntity<?> getAllFunctions() {
|
|
public ResponseEntity<?> getAllFunctions() {
|
|
List<OrgFunction> allFuncs = orgFunctionRepo.findAll();
|
|
List<OrgFunction> allFuncs = orgFunctionRepo.findAll();
|
|
- return new ResponseEntity<>(allFuncs, HttpStatus.OK);
|
|
|
|
|
|
+
|
|
|
|
+ List<TreeNode> zTreeData = TreeUtil.convert(allFuncs, ZtreeNode.class);
|
|
|
|
+ return new ResponseEntity<>(zTreeData, HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "查询机构功能", notes = "查询")
|
|
@ApiOperation(value = "查询机构功能", notes = "查询")
|
|
@GetMapping("/{id}")
|
|
@GetMapping("/{id}")
|
|
public ResponseEntity<?> getOrgFunctions(@PathVariable Long id) {
|
|
public ResponseEntity<?> getOrgFunctions(@PathVariable Long id) {
|
|
LOG.debug("getOrgFunctions(). id=" + id);
|
|
LOG.debug("getOrgFunctions(). id=" + id);
|
|
- return new ResponseEntity<>("", HttpStatus.OK);
|
|
|
|
|
|
+ List<OrgFunction> orgFunctions = orgFunctionRepo.getOrgFunctions(id);
|
|
|
|
+ return new ResponseEntity<>(orgFunctions, HttpStatus.OK);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value = "修改机构功能", notes = "修改")
|
|
|
|
+ @PutMapping("/{id}")
|
|
|
|
+ public ResponseEntity<?> setOrgFunctions(@PathVariable Long id, @RequestBody String[] funcIds) {
|
|
|
|
+ LOG.debug("setOrgFunctions(). id=" + id);
|
|
|
|
+ try {
|
|
|
|
+ orgFunctionRepo.deleteAllOrgFunctions(id);
|
|
|
|
+ for (String funcId : funcIds) {
|
|
|
|
+ orgFunctionRepo.addOrgFunction(id, Long.parseLong(funcId));
|
|
|
|
+ }
|
|
|
|
+ return new ResponseEntity<>("", HttpStatus.CREATED);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ return new ResponseEntity<>("", HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|