Browse Source

Merge pull request #49 from lgcareer/dev

Added queue management additions and updates
pull/1/MERGE
lgcareer 6 years ago committed by GitHub
parent
commit
bc30e43b13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 105
      escheduler-api/src/main/java/cn/escheduler/api/controller/QueueController.java
  2. 7
      escheduler-api/src/main/java/cn/escheduler/api/enums/Status.java
  3. 238
      escheduler-api/src/main/java/cn/escheduler/api/service/QueueService.java
  4. 78
      escheduler-api/src/test/java/cn/escheduler/api/controller/QueueControllerTest.java
  5. 35
      escheduler-dao/src/main/java/cn/escheduler/dao/mapper/QueueMapper.java
  6. 80
      escheduler-dao/src/main/java/cn/escheduler/dao/mapper/QueueMapperProvider.java
  7. 29
      escheduler-dao/src/main/java/cn/escheduler/dao/model/Queue.java
  8. 41
      sql/upgrade/1.0.1_schema/mysql/escheduler_ddl.sql

105
escheduler-api/src/main/java/cn/escheduler/api/controller/QueueController.java

@ -17,6 +17,7 @@
package cn.escheduler.api.controller;
import cn.escheduler.api.enums.Status;
import cn.escheduler.api.service.QueueService;
import cn.escheduler.api.utils.Constants;
import cn.escheduler.api.utils.Result;
@ -29,7 +30,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.Map;
import static cn.escheduler.api.enums.Status.QUERY_QUEUE_LIST_ERROR;
import static cn.escheduler.api.enums.Status.*;
/**
@ -63,5 +64,107 @@ public class QueueController extends BaseController{
}
}
/**
* query queue list paging
* @param loginUser
* @return
*/
@GetMapping(value="/list-paging")
@ResponseStatus(HttpStatus.OK)
public Result queryQueueListPaging(@RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam("pageNo") Integer pageNo,
@RequestParam(value = "searchVal", required = false) String searchVal,
@RequestParam("pageSize") Integer pageSize){
try{
logger.info("login user {}, query queue list,search value:{}", loginUser.getUserName(),searchVal);
Map<String, Object> result = checkPageParams(pageNo, pageSize);
if(result.get(Constants.STATUS) != Status.SUCCESS){
return returnDataListPaging(result);
}
result = queueService.queryList(loginUser,searchVal,pageNo,pageSize);
return returnDataListPaging(result);
}catch (Exception e){
logger.error(QUERY_QUEUE_LIST_ERROR.getMsg(),e);
return error(QUERY_QUEUE_LIST_ERROR.getCode(), QUERY_QUEUE_LIST_ERROR.getMsg());
}
}
/**
* create queue
*
* @param loginUser
* @param queue
* @param queueName
* @return
*/
@PostMapping(value = "/create")
@ResponseStatus(HttpStatus.CREATED)
public Result createQueue(@RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "queue") String queue,
@RequestParam(value = "queueName") String queueName) {
logger.info("login user {}, create queue, queue: {}, queueName: {}",
loginUser.getUserName(), queue, queueName);
try {
Map<String, Object> result = queueService.createQueue(loginUser,queue,queueName);
return returnDataList(result);
}catch (Exception e){
logger.error(CREATE_QUEUE_ERROR.getMsg(),e);
return error(CREATE_QUEUE_ERROR.getCode(), CREATE_QUEUE_ERROR.getMsg());
}
}
/**
* update queue
*
* @param loginUser
* @param queue
* @param queueName
* @return
*/
@PostMapping(value = "/update")
@ResponseStatus(HttpStatus.CREATED)
public Result updateQueue(@RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "id") int id,
@RequestParam(value = "queue") String queue,
@RequestParam(value = "queueName") String queueName) {
logger.info("login user {}, update queue, id: {}, queue: {}, queueName: {}",
loginUser.getUserName(), id,queue, queueName);
try {
Map<String, Object> result = queueService.updateQueue(loginUser,id,queue,queueName);
return returnDataList(result);
}catch (Exception e){
logger.error(UPDATE_QUEUE_ERROR.getMsg(),e);
return error(UPDATE_QUEUE_ERROR.getCode(), UPDATE_QUEUE_ERROR.getMsg());
}
}
/**
* verify queue and queue name
*
* @param loginUser
* @param queue
* @param queueName
* @return
*/
@PostMapping(value = "/verify-queue")
@ResponseStatus(HttpStatus.OK)
public Result verifyQueue(@RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value ="queue") String queue,
@RequestParam(value ="queueName") String queueName
) {
try{
logger.info("login user {}, verfiy queue: {} queue name: {}",
loginUser.getUserName(),queue,queueName);
return queueService.verifyQueue(queue,queueName);
}catch (Exception e){
logger.error(VERIFY_QUEUE_ERROR.getMsg(),e);
return error(Status.VERIFY_QUEUE_ERROR.getCode(), Status.VERIFY_QUEUE_ERROR.getMsg());
}
}
}

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

@ -149,6 +149,13 @@ public enum Status {
TENANT_CODE_HAS_ALREADY_EXISTS(10124,"tenant code has already exists"),
IP_IS_EMPTY(10125,"ip is empty"),
SCHEDULE_CRON_REALEASE_NEED_NOT_CHANGE(10126, "schedule release is already {0}"),
CREATE_QUEUE_ERROR(10127, "create queue error"),
QUEUE_NOT_EXIST(10128, "queue {0} not exists"),
QUEUE_VALUE_EXIST(10129, "queue value {0} already exists"),
QUEUE_NAME_EXIST(10130, "queue name {0} already exists"),
UPDATE_QUEUE_ERROR(10131, "update queue error"),
NEED_NOT_UPDATE_QUEUE(10132, "no content changes, no updates are required"),
VERIFY_QUEUE_ERROR(10133,"verify queue error"),
UDF_FUNCTION_NOT_EXIST(20001, "UDF function not found"),

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

@ -18,12 +18,18 @@ package cn.escheduler.api.service;
import cn.escheduler.api.enums.Status;
import cn.escheduler.api.utils.Constants;
import cn.escheduler.api.utils.PageInfo;
import cn.escheduler.api.utils.Result;
import cn.escheduler.dao.mapper.QueueMapper;
import cn.escheduler.dao.model.Queue;
import cn.escheduler.dao.model.User;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -32,29 +38,219 @@ import java.util.Map;
* queue service
*/
@Service
public class QueueService extends BaseService{
@Autowired
private QueueMapper queueMapper;
/**
* query queue list
*
* @param loginUser
* @return
*/
public Map<String, Object> queryList(User loginUser) {
Map<String, Object> result = new HashMap<>(5);
if (checkAdmin(loginUser, result)) {
return result;
public class QueueService extends BaseService {
private static final Logger logger = LoggerFactory.getLogger(TenantService.class);
@Autowired
private QueueMapper queueMapper;
/**
* query queue list
*
* @param loginUser
* @return
*/
public Map<String, Object> queryList(User loginUser) {
Map<String, Object> result = new HashMap<>(5);
if (checkAdmin(loginUser, result)) {
return result;
}
List<Queue> queueList = queueMapper.queryAllQueue();
result.put(Constants.DATA_LIST, queueList);
putMsg(result, Status.SUCCESS);
return result;
}
List<Queue> queueList = queueMapper.queryAllQueue();
result.put(Constants.DATA_LIST, queueList);
putMsg(result,Status.SUCCESS);
/**
* query queue list paging
*
* @param loginUser
* @param searchVal
* @param pageNo
* @param pageSize
* @return
*/
public Map<String, Object> queryList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
Map<String, Object> result = new HashMap<>(5);
if (checkAdmin(loginUser, result)) {
return result;
}
Integer count = queueMapper.countQueuePaging(searchVal);
PageInfo<Queue> pageInfo = new PageInfo<>(pageNo, pageSize);
List<Queue> queueList = queueMapper.queryQueuePaging(searchVal, pageInfo.getStart(), pageSize);
pageInfo.setTotalCount(count);
pageInfo.setLists(queueList);
result.put(Constants.DATA_LIST, pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* 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);
if (checkAdmin(loginUser, result)) {
return result;
}
if(StringUtils.isEmpty(queue)){
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, queue);
return result;
}
if(StringUtils.isEmpty(queueName)){
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, queueName);
return result;
}
if (checkQueueNameExist(queueName)) {
putMsg(result, Status.QUEUE_NAME_EXIST, queueName);
return result;
}
if (checkQueueExist(queue)) {
putMsg(result, Status.QUEUE_VALUE_EXIST, queue);
return result;
}
Queue queueObj = new Queue();
Date now = new Date();
queueObj.setQueue(queue);
queueObj.setQueueName(queueName);
queueObj.setCreateTime(now);
queueObj.setUpdateTime(now);
queueMapper.insert(queueObj);
putMsg(result, Status.SUCCESS);
return result;
}
return result;
}
/**
* 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);
if (checkAdmin(loginUser, result)) {
return result;
}
Queue queueObj = queueMapper.queryById(id);
if (queueObj == null) {
putMsg(result, Status.QUEUE_NOT_EXIST, id);
return result;
}
// whether queue value or queueName is changed
if (queue.equals(queueObj.getQueue()) && queueName.equals(queueObj.getQueueName())) {
putMsg(result, Status.NEED_NOT_UPDATE_QUEUE);
return result;
}
// check queue name is exist
if (!queueName.equals(queueObj.getQueueName())) {
if(checkQueueNameExist(queueName)){
putMsg(result, Status.QUEUE_NAME_EXIST, queueName);
return result;
}
}
// check queue value is exist
if (!queue.equals(queueObj.getQueue())) {
if(checkQueueExist(queue)){
putMsg(result, Status.QUEUE_VALUE_EXIST, queue);
return result;
}
}
// update queue
Date now = new Date();
queueObj.setQueue(queue);
queueObj.setQueueName(queueName);
queueObj.setUpdateTime(now);
queueMapper.update(queueObj);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* verify queue and queueName
*
* @param queue
* @param queueName
* @return
*/
public Result verifyQueue(String queue, String queueName) {
Result result=new Result();
if (StringUtils.isEmpty(queue)) {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, queue);
return result;
}
if (StringUtils.isEmpty(queueName)) {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, queueName);
return result;
}
if(checkQueueNameExist(queueName)){
logger.error("queue name {} has exist, can't create again.", queueName);
putMsg(result, Status.QUEUE_NAME_EXIST, queueName);
return result;
}
if(checkQueueExist(queue)){
logger.error("queue value {} has exist, can't create again.", queue);
putMsg(result, Status.QUEUE_VALUE_EXIST, queue);
return result;
}
putMsg(result, Status.SUCCESS);
return result;
}
/**
* check queue exist
*
* @param queue
* @return
*/
private boolean checkQueueExist(String queue) {
return queueMapper.queryByQueue(queue) == null ? false : true;
}
/**
* check queue name exist
*
* @param queueName
* @return
*/
private boolean checkQueueNameExist(String queueName) {
return queueMapper.queryByQueueName(queueName) == null ? false : true;
}
}

78
escheduler-api/src/test/java/cn/escheduler/api/controller/QueueControllerTest.java

@ -32,9 +32,12 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.context.WebApplicationContext;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@ -65,4 +68,79 @@ public class QueueControllerTest {
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void queryPagingList() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
//paramsMap.add("processInstanceId","1380");
paramsMap.add("searchVal","");
paramsMap.add("pageNo","1");
paramsMap.add("pageSize","20");
MvcResult mvcResult = mockMvc.perform(get("/queue/list-paging")
.header("sessionId", "d4541e0d-0349-4f05-9c68-300176cd3c91")
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void createQueue() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("queue","ait111134");
paramsMap.add("queueName","aitName1");
MvcResult mvcResult = mockMvc.perform(post("/queue/create")
.header("sessionId", "d4541e0d-0349-4f05-9c68-300176cd3c91")
.params(paramsMap))
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
//Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void updateQueue() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("id","2");
paramsMap.add("queue","ait12");
paramsMap.add("queueName","aitName");
MvcResult mvcResult = mockMvc.perform(post("/queue/update")
.header("sessionId", "d4541e0d-0349-4f05-9c68-300176cd3c91")
.params(paramsMap))
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
//Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void verifyQueue() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("queue","ait123");
paramsMap.add("queueName","aitName");
MvcResult mvcResult = mockMvc.perform(post("/queue/verify-queue")
.header("sessionId", "d4541e0d-0349-4f05-9c68-300176cd3c91")
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
//Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
}

35
escheduler-dao/src/main/java/cn/escheduler/dao/mapper/QueueMapper.java

@ -20,6 +20,7 @@ import cn.escheduler.dao.model.Queue;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import java.sql.Timestamp;
import java.util.List;
/**
@ -64,7 +65,9 @@ public interface QueueMapper {
*/
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
@Result(property = "queueName", column = "queue_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
@Result(property = "queue", column = "queue", javaType = String.class, jdbcType = JdbcType.VARCHAR)
@Result(property = "queue", column = "queue", javaType = String.class, jdbcType = JdbcType.VARCHAR),
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
})
@SelectProvider(type = QueueMapperProvider.class, method = "queryById")
Queue queryById(@Param("queueId") int queueId);
@ -76,13 +79,41 @@ public interface QueueMapper {
*/
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
@Result(property = "queueName", column = "queue_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
@Result(property = "queue", column = "queue", javaType = String.class, jdbcType = JdbcType.VARCHAR)
@Result(property = "queue", column = "queue", javaType = String.class, jdbcType = JdbcType.VARCHAR),
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
})
@SelectProvider(type = QueueMapperProvider.class, method = "queryAllQueue")
List<Queue> queryAllQueue();
/**
* query all queue list
* @return
*/
@Results(value = {@Result(property = "id", column = "id", id = true, javaType = Integer.class, jdbcType = JdbcType.INTEGER),
@Result(property = "queueName", column = "queue_name", javaType = String.class, jdbcType = JdbcType.VARCHAR),
@Result(property = "queue", column = "queue", javaType = String.class, jdbcType = JdbcType.VARCHAR),
@Result(property = "createTime", column = "create_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE),
@Result(property = "updateTime", column = "update_time", javaType = Timestamp.class, jdbcType = JdbcType.DATE)
})
@SelectProvider(type = QueueMapperProvider.class, method = "queryQueuePaging")
List<Queue> queryQueuePaging(@Param("searchVal") String searchVal,
@Param("offset") Integer offset,
@Param("pageSize") Integer pageSize);
/**
* count queue by search value
* @param searchVal
* @return
*/
@SelectProvider(type = QueueMapperProvider.class, method = "countQueuePaging")
Integer countQueuePaging(@Param("searchVal") String searchVal);
@SelectProvider(type = QueueMapperProvider.class, method = "queryByQueue")
Queue queryByQueue(@Param("queue") String queue);
@SelectProvider(type = QueueMapperProvider.class, method = "queryByQueueName")
Queue queryByQueueName(@Param("queueName") String queueName);
}

80
escheduler-dao/src/main/java/cn/escheduler/dao/mapper/QueueMapperProvider.java

@ -16,6 +16,7 @@
*/
package cn.escheduler.dao.mapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.jdbc.SQL;
import java.util.Map;
@ -39,7 +40,8 @@ public class QueueMapperProvider {
INSERT_INTO(TABLE_NAME);
VALUES("`queue_name`", "#{queue.queueName}");
VALUES("`queue`", "#{queue.queue}");
VALUES("`create_time`", "#{queue.createTime}");
VALUES("`update_time`", "#{queue.updateTime}");
}
}.toString();
}
@ -73,6 +75,7 @@ public class QueueMapperProvider {
SET("`queue_name`=#{queue.queueName}");
SET("`queue`=#{queue.queue}");
SET("`update_time`=#{queue.updateTime}");
WHERE("`id`=#{queue.id}");
}
@ -80,10 +83,6 @@ public class QueueMapperProvider {
}
/**
* query queue by id
*
@ -117,5 +116,76 @@ public class QueueMapperProvider {
}.toString();
}
/**
* count queue by search value
* @param parameter
* @return
*/
public String countQueuePaging(Map<String, Object> parameter) {
return new SQL() {{
SELECT("count(0)");
FROM(TABLE_NAME);
Object searchVal = parameter.get("searchVal");
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
WHERE( " queue_name like concat('%', #{searchVal}, '%') ");
}
}}.toString();
}
/**
* query tenant list paging
* @param parameter
* @return
*/
public String queryQueuePaging(Map<String, Object> parameter) {
return new SQL() {
{
SELECT("*");
FROM(TABLE_NAME);
Object searchVal = parameter.get("searchVal");
if(searchVal != null && StringUtils.isNotEmpty(searchVal.toString())){
WHERE( " queue_name like concat('%', #{searchVal}, '%') ");
}
ORDER_BY(" update_time desc limit #{offset},#{pageSize} ");
}
}.toString();
}
/**
* query by queue
*
* @param parameter
* @return
*/
public String queryByQueue(Map<String, Object> parameter) {
return new SQL() {
{
SELECT("*");
FROM(TABLE_NAME);
WHERE("`queue` = #{queue}");
}
}.toString();
}
/**
* query by queue name
*
* @param parameter
* @return
*/
public String queryByQueueName(Map<String, Object> parameter) {
return new SQL() {
{
SELECT("*");
FROM(TABLE_NAME);
WHERE("`queue_name` = #{queueName}");
}
}.toString();
}
}

29
escheduler-dao/src/main/java/cn/escheduler/dao/model/Queue.java

@ -16,6 +16,8 @@
*/
package cn.escheduler.dao.model;
import java.util.Date;
/**
* queue
*/
@ -34,6 +36,15 @@ public class Queue {
*/
private String queue;
/**
* create time
*/
private Date createTime;
/**
* update time
*/
private Date updateTime;
public int getId() {
return id;
}
@ -58,12 +69,30 @@ public class Queue {
this.queue = queue;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
@Override
public String toString() {
return "Queue{" +
"id=" + id +
", queueName='" + queueName + '\'' +
", queue='" + queue + '\'' +
", createTime=" + createTime +
", updateTime=" + updateTime +
'}';
}
}

41
sql/upgrade/1.0.1_schema/mysql/escheduler_ddl.sql

@ -0,0 +1,41 @@
SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
-- ac_escheduler_T_t_escheduler_queue_C_create_time
drop PROCEDURE if EXISTS ac_escheduler_T_t_escheduler_queue_C_create_time;
delimiter d//
CREATE PROCEDURE ac_escheduler_T_t_escheduler_queue_C_create_time()
BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
WHERE TABLE_NAME='t_escheduler_queue'
AND TABLE_SCHEMA='escheduler'
AND COLUMN_NAME='create_time')
THEN
ALTER TABLE escheduler.t_escheduler_queue ADD COLUMN create_time datetime DEFAULT NULL COMMENT '创建时间' AFTER queue;
END IF;
END;
d//
delimiter ;
CALL ac_escheduler_T_t_escheduler_queue_C_create_time;
DROP PROCEDURE ac_escheduler_T_t_escheduler_queue_C_create_time;
-- ac_escheduler_T_t_escheduler_queue_C_update_time
drop PROCEDURE if EXISTS ac_escheduler_T_t_escheduler_queue_C_update_time;
delimiter d//
CREATE PROCEDURE ac_escheduler_T_t_escheduler_queue_C_update_time()
BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
WHERE TABLE_NAME='t_escheduler_queue'
AND TABLE_SCHEMA='escheduler'
AND COLUMN_NAME='update_time')
THEN
ALTER TABLE escheduler.t_escheduler_queue ADD COLUMN update_time datetime DEFAULT NULL COMMENT '更新时间' AFTER create_time;
END IF;
END;
d//
delimiter ;
CALL ac_escheduler_T_t_escheduler_queue_C_update_time;
DROP PROCEDURE ac_escheduler_T_t_escheduler_queue_C_update_time;
Loading…
Cancel
Save