Browse Source

add verify queue_name

pull/1/MERGE
ligang 6 years ago
parent
commit
30a63a05aa
  1. 3
      escheduler-api/src/main/java/cn/escheduler/api/enums/Status.java
  2. 44
      escheduler-api/src/main/java/cn/escheduler/api/service/QueueService.java

3
escheduler-api/src/main/java/cn/escheduler/api/enums/Status.java

@ -152,7 +152,8 @@ public enum Status {
CREATE_QUEUE_ERROR(10127, "create queue error"), CREATE_QUEUE_ERROR(10127, "create queue error"),
QUEUE_NOT_EXIST(10128, "queue {0} not exists"), QUEUE_NOT_EXIST(10128, "queue {0} not exists"),
QUEUE_EXIST(10129, "queue already exists"), QUEUE_EXIST(10129, "queue already exists"),
UPDATE_QUEUE_ERROR(10130, "update queue error"), QUEUE_NAME_EXIST(10130, "queue name already exists"),
UPDATE_QUEUE_ERROR(10131, "update queue error"),
UDF_FUNCTION_NOT_EXIST(20001, "UDF function not found"), UDF_FUNCTION_NOT_EXIST(20001, "UDF function not found"),

44
escheduler-api/src/main/java/cn/escheduler/api/service/QueueService.java

@ -35,7 +35,7 @@ import java.util.Map;
* queue service * queue service
*/ */
@Service @Service
public class QueueService extends BaseService{ public class QueueService extends BaseService {
@Autowired @Autowired
@ -55,20 +55,21 @@ public class QueueService extends BaseService{
List<Queue> queueList = queueMapper.queryAllQueue(); List<Queue> queueList = queueMapper.queryAllQueue();
result.put(Constants.DATA_LIST, queueList); result.put(Constants.DATA_LIST, queueList);
putMsg(result,Status.SUCCESS); putMsg(result, Status.SUCCESS);
return result; return result;
} }
/** /**
* query queue list paging * query queue list paging
*
* @param loginUser * @param loginUser
* @param searchVal * @param searchVal
* @param pageNo * @param pageNo
* @param pageSize * @param pageSize
* @return * @return
*/ */
public Map<String, Object> queryList(User loginUser,String searchVal, Integer pageNo, Integer pageSize) { public Map<String, Object> queryList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
if (checkAdmin(loginUser, result)) { if (checkAdmin(loginUser, result)) {
return result; return result;
@ -76,29 +77,42 @@ public class QueueService extends BaseService{
Integer count = queueMapper.countQueuePaging(searchVal); Integer count = queueMapper.countQueuePaging(searchVal);
PageInfo<Queue> pageInfo = new PageInfo<>(pageNo,pageSize); PageInfo<Queue> pageInfo = new PageInfo<>(pageNo, pageSize);
List<Queue> queueList = queueMapper.queryQueuePaging(searchVal,pageInfo.getStart(),pageSize); List<Queue> queueList = queueMapper.queryQueuePaging(searchVal, pageInfo.getStart(), pageSize);
pageInfo.setTotalCount(count); pageInfo.setTotalCount(count);
pageInfo.setLists(queueList); pageInfo.setLists(queueList);
result.put(Constants.DATA_LIST, pageInfo); result.put(Constants.DATA_LIST, pageInfo);
putMsg(result,Status.SUCCESS); putMsg(result, Status.SUCCESS);
return result; return result;
} }
public Map<String, Object> createQueue(User loginUser,String queue, String queueName) { /**
* create queue
*
* @param loginUser
* @param queue
* @param queueName
* @return
*/
public Map<String, Object> createQueue(User loginUser, String queue, String queueName) {
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
if (checkAdmin(loginUser, result)) { if (checkAdmin(loginUser, result)) {
return result; return result;
} }
if (checkQueueExists(queue)){ if (checkQueueExists(queue)) {
putMsg(result, Status.QUEUE_EXIST, queue); putMsg(result, Status.QUEUE_EXIST, queue);
return result; return result;
} }
if (checkQueueExists(queueName)) {
putMsg(result, Status.QUEUE_NAME_EXIST, queueName);
return result;
}
Queue queueObj = new Queue(); Queue queueObj = new Queue();
Date now = new Date(); Date now = new Date();
@ -113,17 +127,25 @@ public class QueueService extends BaseService{
return result; return result;
} }
public Map<String, Object> updateQueue(User loginUser,int id,String queue, String queueName) { /**
* update queue
*
* @param loginUser
* @param id
* @param queue
* @param queueName
* @return
*/
public Map<String, Object> updateQueue(User loginUser, int id, String queue, String queueName) {
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
if (checkAdmin(loginUser, result)) { if (checkAdmin(loginUser, result)) {
return result; return result;
} }
Queue queueObj = queueMapper.queryById(id); Queue queueObj = queueMapper.queryById(id);
if (queueObj == null) { if (queueObj == null) {
putMsg(result,Status.QUEUE_NOT_EXIST,id); putMsg(result, Status.QUEUE_NOT_EXIST, id);
return result; return result;
} }

Loading…
Cancel
Save