|
@@ -1,72 +0,0 @@
|
|
-package cn.com.qmth.examcloud.core.basic.api.controller;
|
|
|
|
-
|
|
|
|
-import java.util.List;
|
|
|
|
-
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
-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.RestController;
|
|
|
|
-
|
|
|
|
-import cn.com.qmth.examcloud.commons.web.helpers.tree.TreeNode;
|
|
|
|
-import cn.com.qmth.examcloud.commons.web.helpers.tree.TreeUtil;
|
|
|
|
-import cn.com.qmth.examcloud.commons.web.helpers.tree.ZtreeNode;
|
|
|
|
-import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
|
-import cn.com.qmth.examcloud.core.basic.dao.FunctionRepo;
|
|
|
|
-import cn.com.qmth.examcloud.core.basic.dao.OrgFunctionRepo;
|
|
|
|
-import cn.com.qmth.examcloud.core.basic.dao.entity.Function;
|
|
|
|
-import cn.com.qmth.examcloud.core.basic.dao.entity.OrgFunction;
|
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * 机构功能API
|
|
|
|
- *
|
|
|
|
- * @author wang wei
|
|
|
|
- * @date 2018年4月9日
|
|
|
|
- */
|
|
|
|
-@RestController
|
|
|
|
-@RequestMapping("${$rmp.ctr.basic}/orgFunction")
|
|
|
|
-public class OrgFunctionController extends ControllerSupport {
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- OrgFunctionRepo orgFunctionRepo;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- FunctionRepo functionRepo;
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "查询所有功能", notes = "查询")
|
|
|
|
- @GetMapping("/getAllFunctions")
|
|
|
|
- public ResponseEntity<?> getAllFunctions() {
|
|
|
|
- List<Function> allFuncs = functionRepo.findAll();
|
|
|
|
-
|
|
|
|
- List<TreeNode> zTreeData = TreeUtil.convert(allFuncs, ZtreeNode.class);
|
|
|
|
- return new ResponseEntity<>(zTreeData, HttpStatus.OK);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "查询机构功能", notes = "查询")
|
|
|
|
- @GetMapping("/{id}")
|
|
|
|
- public ResponseEntity<?> getOrgFunctions(@PathVariable Long id) {
|
|
|
|
- log.debug("getOrgFunctions(). id=" + id);
|
|
|
|
- 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);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|