From 204d7848fed36a2a12b50e0562652eb8c46fee42 Mon Sep 17 00:00:00 2001 From: "xueli.xue" Date: Sun, 2 Oct 2016 22:51:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=88=86=E7=BB=84,=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=9C=A8=E7=BA=BF=E7=BB=B4=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/tables_xxl_job.sql | 7 + .../admin/controller/JobGroupController.java | 80 ++++++++ .../xxl/job/admin/core/model/XxlJobGroup.java | 35 ++++ .../xxl/job/admin/dao/IXxlJobGroupDao.java | 21 ++ .../admin/dao/impl/XxlJobGroupDaoImpl.java | 46 +++++ .../mybatis-mapper/XxlJobGroupMapper.xml | 47 +++++ .../WEB-INF/template/common/common.macro.ftl | 1 + .../template/jobgroup/jobgroup.index.ftl | 148 ++++++++++++++ .../template/jobinfo/jobinfo.index.ftl | 6 +- .../WEB-INF/template/joblog/joblog.index.ftl | 4 +- .../main/webapp/static/js/jobgroup.index.1.js | 185 ++++++++++++++++++ .../main/webapp/static/js/jobinfo.index.1.js | 2 +- 12 files changed, 576 insertions(+), 6 deletions(-) create mode 100644 xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobGroupController.java create mode 100644 xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobGroup.java create mode 100644 xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobGroupDao.java create mode 100644 xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobGroupDaoImpl.java create mode 100644 xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobGroupMapper.xml create mode 100644 xxl-job-admin/src/main/webapp/WEB-INF/template/jobgroup/jobgroup.index.ftl create mode 100644 xxl-job-admin/src/main/webapp/static/js/jobgroup.index.1.js diff --git a/db/tables_xxl_job.sql b/db/tables_xxl_job.sql index e8613990..8a3840f1 100644 --- a/db/tables_xxl_job.sql +++ b/db/tables_xxl_job.sql @@ -203,5 +203,12 @@ CREATE TABLE XXL_JOB_QRTZ_TRIGGER_REGISTRY ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE XXL_JOB_QRTZ_TRIGGER_GROUP ( + `group_name` varchar(255) NOT NULL, + `group_desc` varchar(255) NOT NULL, + `order` int(11) NOT NULL, + PRIMARY KEY (`group_name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + commit; diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobGroupController.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobGroupController.java new file mode 100644 index 00000000..ee3d4300 --- /dev/null +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobGroupController.java @@ -0,0 +1,80 @@ +package com.xxl.job.admin.controller; + +import com.xxl.job.admin.core.model.ReturnT; +import com.xxl.job.admin.core.model.XxlJobGroup; +import com.xxl.job.admin.dao.IXxlJobGroupDao; +import com.xxl.job.admin.dao.IXxlJobInfoDao; +import org.apache.commons.lang.StringUtils; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import java.util.List; + +/** + * job group controller + * @author xuxueli 2016-10-02 20:52:56 + */ +@Controller +@RequestMapping("/jobgroup") +public class JobGroupController { + + @Resource + public IXxlJobInfoDao xxlJobInfoDao; + + @Resource + public IXxlJobGroupDao xxlJobGroupDao; + + @RequestMapping + public String index(Model model) { + List list = xxlJobGroupDao.findAll(); + model.addAttribute("list", list); + return "jobgroup/jobgroup.index"; + } + + @RequestMapping("/save") + @ResponseBody + public ReturnT save(XxlJobGroup xxlJobGroup){ + + // valid + if (xxlJobGroup.getGroupName()==null || StringUtils.isBlank(xxlJobGroup.getGroupName())) { + return new ReturnT(500, "请输入分组"); + } + if (xxlJobGroup.getGroupDesc()==null || StringUtils.isBlank(xxlJobGroup.getGroupDesc())) { + return new ReturnT(500, "请输入描述"); + } + + // check repeat + XxlJobGroup group = xxlJobGroupDao.load(xxlJobGroup.getGroupName()); + if (group!=null) { + return new ReturnT(500, "分组已存在, 请勿重复添加"); + } + + int ret = xxlJobGroupDao.save(xxlJobGroup); + return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL; + } + + @RequestMapping("/update") + @ResponseBody + public ReturnT update(XxlJobGroup xxlJobGroup){ + int ret = xxlJobGroupDao.update(xxlJobGroup); + return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL; + } + + @RequestMapping("/remove") + @ResponseBody + public ReturnT remove(String groupName){ + + // valid + int count = xxlJobInfoDao.pageListCount(0, 10, groupName, null); + if (count > 0) { + return new ReturnT(500, "该分组使用中, 不可删除"); + } + + int ret = xxlJobGroupDao.remove(groupName); + return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL; + } + +} diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobGroup.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobGroup.java new file mode 100644 index 00000000..7c41f809 --- /dev/null +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobGroup.java @@ -0,0 +1,35 @@ +package com.xxl.job.admin.core.model; + +/** + * Created by xuxueli on 16/9/30. + */ +public class XxlJobGroup { + + private String groupName; + private String groupDesc; + private int order; + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public String getGroupDesc() { + return groupDesc; + } + + public void setGroupDesc(String groupDesc) { + this.groupDesc = groupDesc; + } + + public int getOrder() { + return order; + } + + public void setOrder(int order) { + this.order = order; + } +} diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobGroupDao.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobGroupDao.java new file mode 100644 index 00000000..f94ef9d2 --- /dev/null +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobGroupDao.java @@ -0,0 +1,21 @@ +package com.xxl.job.admin.dao; + +import com.xxl.job.admin.core.model.XxlJobGroup; + +import java.util.List; + +/** + * Created by xuxueli on 16/9/30. + */ +public interface IXxlJobGroupDao { + + public List findAll(); + + public int save(XxlJobGroup xxlJobGroup); + + public int update(XxlJobGroup xxlJobGroup); + + public int remove(String groupName); + + public XxlJobGroup load(String groupName); +} diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobGroupDaoImpl.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobGroupDaoImpl.java new file mode 100644 index 00000000..1c69d63b --- /dev/null +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobGroupDaoImpl.java @@ -0,0 +1,46 @@ +package com.xxl.job.admin.dao.impl; + +import com.xxl.job.admin.core.model.XxlJobGroup; +import com.xxl.job.admin.dao.IXxlJobGroupDao; +import org.mybatis.spring.SqlSessionTemplate; +import org.springframework.stereotype.Repository; + +import javax.annotation.Resource; +import java.util.List; + +/** + * Created by xuxueli on 16/9/30. + */ +@Repository +public class XxlJobGroupDaoImpl implements IXxlJobGroupDao { + + @Resource + public SqlSessionTemplate sqlSessionTemplate; + + @Override + public List findAll() { + return sqlSessionTemplate.selectList("XxlJobGroupMapper.findAll"); + } + + @Override + public int save(XxlJobGroup xxlJobGroup) { + return sqlSessionTemplate.update("XxlJobGroupMapper.save", xxlJobGroup); + } + + @Override + public int update(XxlJobGroup xxlJobGroup) { + return sqlSessionTemplate.update("XxlJobGroupMapper.update", xxlJobGroup); + } + + @Override + public int remove(String groupName) { + return sqlSessionTemplate.delete("XxlJobGroupMapper.remove", groupName); + } + + @Override + public XxlJobGroup load(String groupName) { + return sqlSessionTemplate.selectOne("XxlJobGroupMapper.load", groupName); + } + + +} diff --git a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobGroupMapper.xml b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobGroupMapper.xml new file mode 100644 index 00000000..305888cd --- /dev/null +++ b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobGroupMapper.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + t.group_name, + t.group_desc, + t.order + + + + + + INSERT INTO XXL_JOB_QRTZ_TRIGGER_GROUP ( `group_name`, `group_desc`, `order`) + values ( #{groupName}, #{groupDesc}, #{order}); + + + + UPDATE XXL_JOB_QRTZ_TRIGGER_GROUP + SET `group_desc` = #{groupDesc}, + `order` = #{order} + WHERE group_name = #{groupName} + + + + DELETE FROM XXL_JOB_QRTZ_TRIGGER_GROUP + WHERE group_name = #{groupName} + + + + + \ No newline at end of file diff --git a/xxl-job-admin/src/main/webapp/WEB-INF/template/common/common.macro.ftl b/xxl-job-admin/src/main/webapp/WEB-INF/template/common/common.macro.ftl index 9cef31d2..bb1d11b2 100644 --- a/xxl-job-admin/src/main/webapp/WEB-INF/template/common/common.macro.ftl +++ b/xxl-job-admin/src/main/webapp/WEB-INF/template/common/common.macro.ftl @@ -85,6 +85,7 @@
  • 常用模块
  • + diff --git a/xxl-job-admin/src/main/webapp/WEB-INF/template/jobgroup/jobgroup.index.ftl b/xxl-job-admin/src/main/webapp/WEB-INF/template/jobgroup/jobgroup.index.ftl new file mode 100644 index 00000000..b6a0fa00 --- /dev/null +++ b/xxl-job-admin/src/main/webapp/WEB-INF/template/jobgroup/jobgroup.index.ftl @@ -0,0 +1,148 @@ + + + + 任务调度中心 + <#import "/common/common.macro.ftl" as netCommon> + <@netCommon.commonStyle /> + + + + + +sidebar-collapse "> +
    + + <@netCommon.commonHeader /> + + <@netCommon.commonLeft /> + + +
    + +
    +

    分组管理任务调度中心

    +
    + + +
    + +
    +
    +
    +
    +

    分组管理

    + +
    +
    + + + + + + + + + + + <#if list?exists && list?size gt 0> + <#list list as group> + + + + + + + + + +
    名称AppName排序操作
    ${group.groupDesc}${group.groupName}${group.order} + + +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + <@netCommon.commonFooter /> +
    + +<@netCommon.commonScript /> + + + + + + + diff --git a/xxl-job-admin/src/main/webapp/WEB-INF/template/jobinfo/jobinfo.index.ftl b/xxl-job-admin/src/main/webapp/WEB-INF/template/jobinfo/jobinfo.index.ftl index b4d6dc31..962b3030 100644 --- a/xxl-job-admin/src/main/webapp/WEB-INF/template/jobinfo/jobinfo.index.ftl +++ b/xxl-job-admin/src/main/webapp/WEB-INF/template/jobinfo/jobinfo.index.ftl @@ -25,7 +25,7 @@
    -

    任务调度中心调度管理

    +

    调度管理任务调度中心

    -

    任务调度中心调度日志

    +

    调度日志任务调度中心