Browse Source

update worker group

pull/2/head
baoliang 6 years ago
parent
commit
5c0372893d
  1. 45
      escheduler-api/src/main/java/cn/escheduler/api/controller/WorkerGroupController.java
  2. 31
      escheduler-api/src/main/java/cn/escheduler/api/service/WorkerGroupService.java

45
escheduler-api/src/main/java/cn/escheduler/api/controller/WorkerGroupController.java

@ -44,6 +44,14 @@ public class WorkerGroupController extends BaseController{
WorkerGroupService workerGroupService; WorkerGroupService workerGroupService;
/**
* create or update a worker group
* @param loginUser
* @param id
* @param name
* @param ipList
* @return
*/
@PostMapping(value = "/save") @PostMapping(value = "/save")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
public Result saveWorkerGroup(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, 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") @GetMapping(value = "/list-paging")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
public Result queryAllWorkerGroupsPaging(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, 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(value = "searchVal", required = false) String searchVal,
@RequestParam("pageSize") Integer pageSize @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); loginUser.getUserName() , pageNo, pageSize, searchVal);
try { 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<String, Object> 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") @GetMapping(value = "/delete-by-id")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
public Result deleteById(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, public Result deleteById(@RequestAttribute(value = Constants.SESSION_USER) User loginUser,

31
escheduler-api/src/main/java/cn/escheduler/api/service/WorkerGroupService.java

@ -41,6 +41,13 @@ public class WorkerGroupService extends BaseService {
@Autowired @Autowired
WorkerGroupMapper workerGroupMapper; WorkerGroupMapper workerGroupMapper;
/**
* create or update a worker group
* @param id
* @param name
* @param ipList
* @return
*/
public Map<String, Object> saveWorkerGroup(int id, String name, String ipList){ public Map<String, Object> saveWorkerGroup(int id, String name, String ipList){
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
@ -97,6 +104,13 @@ public class WorkerGroupService extends BaseService {
return false; return false;
} }
/**
* query worker group paging
* @param pageNo
* @param pageSize
* @param searchVal
* @return
*/
public Map<String,Object> queryAllGroupPaging(Integer pageNo, Integer pageSize, String searchVal) { public Map<String,Object> queryAllGroupPaging(Integer pageNo, Integer pageSize, String searchVal) {
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
@ -112,6 +126,11 @@ public class WorkerGroupService extends BaseService {
return result; return result;
} }
/**
* delete worker group by id
* @param id
* @return
*/
public Map<String,Object> deleteWorkerGroupById(Integer id) { public Map<String,Object> deleteWorkerGroupById(Integer id) {
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
@ -120,4 +139,16 @@ public class WorkerGroupService extends BaseService {
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
return result; return result;
} }
/**
* query all worker group
* @return
*/
public Map<String,Object> queryAllGroup() {
Map<String, Object> result = new HashMap<>(5);
List<WorkerGroup> workerGroupList = workerGroupMapper.queryAllWorkerGroup();
result.put(Constants.DATA_LIST, workerGroupList);
putMsg(result, Status.SUCCESS);
return result;
}
} }

Loading…
Cancel
Save