From 5c0372893d4f53f509107a4d2148c156c2498363 Mon Sep 17 00:00:00 2001 From: baoliang Date: Mon, 22 Apr 2019 10:47:15 +0800 Subject: [PATCH] update worker group --- .../api/controller/WorkerGroupController.java | 45 ++++++++++++++++++- .../api/service/WorkerGroupService.java | 31 +++++++++++++ 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/escheduler-api/src/main/java/cn/escheduler/api/controller/WorkerGroupController.java b/escheduler-api/src/main/java/cn/escheduler/api/controller/WorkerGroupController.java index 77c504c63c..e07abc4881 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/controller/WorkerGroupController.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/controller/WorkerGroupController.java @@ -44,6 +44,14 @@ public class WorkerGroupController extends BaseController{ WorkerGroupService workerGroupService; + /** + * create or update a worker group + * @param loginUser + * @param id + * @param name + * @param ipList + * @return + */ @PostMapping(value = "/save") @ResponseStatus(HttpStatus.OK) public Result saveWorkerGroup(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, @@ -63,6 +71,14 @@ public class WorkerGroupController extends BaseController{ } } + /** + * query worker groups paging + * @param loginUser + * @param pageNo + * @param searchVal + * @param pageSize + * @return + */ @GetMapping(value = "/list-paging") @ResponseStatus(HttpStatus.OK) public Result queryAllWorkerGroupsPaging(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, @@ -70,7 +86,7 @@ public class WorkerGroupController extends BaseController{ @RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam("pageSize") Integer pageSize ) { - logger.info("query all worker group: login user {}, pageNo:{}, pageSize:{}, searchVal:{}", + logger.info("query all worker group paging: login user {}, pageNo:{}, pageSize:{}, searchVal:{}", loginUser.getUserName() , pageNo, pageSize, searchVal); try { @@ -82,6 +98,33 @@ public class WorkerGroupController extends BaseController{ } } + /** + * query all worker groups + * @param loginUser + * @return + */ + @GetMapping(value = "/all-groups") + @ResponseStatus(HttpStatus.OK) + public Result queryAllWorkerGroups(@RequestAttribute(value = Constants.SESSION_USER) User loginUser + ) { + logger.info("query all worker group: login user {}", + loginUser.getUserName() ); + + try { + Map result = workerGroupService.queryAllGroup(); + return returnDataListPaging(result); + }catch (Exception e){ + logger.error(Status.SAVE_ERROR.getMsg(),e); + return error(Status.SAVE_ERROR.getCode(), Status.SAVE_ERROR.getMsg()); + } + } + + /** + * delete worker group by id + * @param loginUser + * @param id + * @return + */ @GetMapping(value = "/delete-by-id") @ResponseStatus(HttpStatus.OK) public Result deleteById(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, diff --git a/escheduler-api/src/main/java/cn/escheduler/api/service/WorkerGroupService.java b/escheduler-api/src/main/java/cn/escheduler/api/service/WorkerGroupService.java index 52ec4c6854..0650d3c72a 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/service/WorkerGroupService.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/service/WorkerGroupService.java @@ -41,6 +41,13 @@ public class WorkerGroupService extends BaseService { @Autowired WorkerGroupMapper workerGroupMapper; + /** + * create or update a worker group + * @param id + * @param name + * @param ipList + * @return + */ public Map saveWorkerGroup(int id, String name, String ipList){ Map result = new HashMap<>(5); @@ -97,6 +104,13 @@ public class WorkerGroupService extends BaseService { return false; } + /** + * query worker group paging + * @param pageNo + * @param pageSize + * @param searchVal + * @return + */ public Map queryAllGroupPaging(Integer pageNo, Integer pageSize, String searchVal) { Map result = new HashMap<>(5); @@ -112,6 +126,11 @@ public class WorkerGroupService extends BaseService { return result; } + /** + * delete worker group by id + * @param id + * @return + */ public Map deleteWorkerGroupById(Integer id) { Map result = new HashMap<>(5); @@ -120,4 +139,16 @@ public class WorkerGroupService extends BaseService { putMsg(result, Status.SUCCESS); return result; } + + /** + * query all worker group + * @return + */ + public Map queryAllGroup() { + Map result = new HashMap<>(5); + List workerGroupList = workerGroupMapper.queryAllWorkerGroup(); + result.put(Constants.DATA_LIST, workerGroupList); + putMsg(result, Status.SUCCESS); + return result; + } }