Search in sources :

Example 1 with XxlJobLogGlue

use of com.xxl.job.admin.core.model.XxlJobLogGlue in project xxl-job by xuxueli.

the class JobCodeController method save.

@RequestMapping("/save")
@ResponseBody
public ReturnT<String> save(Model model, int id, String glueSource, String glueRemark) {
    // valid
    if (glueRemark == null) {
        return new ReturnT<String>(500, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobinfo_glue_remark")));
    }
    if (glueRemark.length() < 4 || glueRemark.length() > 100) {
        return new ReturnT<String>(500, I18nUtil.getString("jobinfo_glue_remark_limit"));
    }
    XxlJobInfo exists_jobInfo = xxlJobInfoDao.loadById(id);
    if (exists_jobInfo == null) {
        return new ReturnT<String>(500, I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
    }
    // update new code
    exists_jobInfo.setGlueSource(glueSource);
    exists_jobInfo.setGlueRemark(glueRemark);
    exists_jobInfo.setGlueUpdatetime(new Date());
    xxlJobInfoDao.update(exists_jobInfo);
    // log old code
    XxlJobLogGlue xxlJobLogGlue = new XxlJobLogGlue();
    xxlJobLogGlue.setJobId(exists_jobInfo.getId());
    xxlJobLogGlue.setGlueType(exists_jobInfo.getGlueType());
    xxlJobLogGlue.setGlueSource(glueSource);
    xxlJobLogGlue.setGlueRemark(glueRemark);
    xxlJobLogGlueDao.save(xxlJobLogGlue);
    // remove code backup more than 30
    xxlJobLogGlueDao.removeOld(exists_jobInfo.getId(), 30);
    return ReturnT.SUCCESS;
}
Also used : ReturnT(com.xxl.job.core.biz.model.ReturnT) Date(java.util.Date) XxlJobLogGlue(com.xxl.job.admin.core.model.XxlJobLogGlue) XxlJobInfo(com.xxl.job.admin.core.model.XxlJobInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with XxlJobLogGlue

use of com.xxl.job.admin.core.model.XxlJobLogGlue in project xxl-job by xuxueli.

the class XxlJobLogGlueDaoTest method test.

@Test
public void test() {
    XxlJobLogGlue logGlue = new XxlJobLogGlue();
    logGlue.setJobId(1);
    logGlue.setGlueType("1");
    logGlue.setGlueSource("1");
    logGlue.setGlueRemark("1");
    int ret = xxlJobLogGlueDao.save(logGlue);
    List<XxlJobLogGlue> list = xxlJobLogGlueDao.findByJobId(1);
    int ret2 = xxlJobLogGlueDao.removeOld(1, 1);
    int ret3 = xxlJobLogGlueDao.deleteByJobId(1);
}
Also used : XxlJobLogGlue(com.xxl.job.admin.core.model.XxlJobLogGlue) Test(org.junit.Test)

Example 3 with XxlJobLogGlue

use of com.xxl.job.admin.core.model.XxlJobLogGlue in project xxl-job by xuxueli.

the class JobCodeController method index.

@RequestMapping
public String index(Model model, int jobId) {
    XxlJobInfo jobInfo = xxlJobInfoDao.loadById(jobId);
    List<XxlJobLogGlue> jobLogGlues = xxlJobLogGlueDao.findByJobId(jobId);
    if (jobInfo == null) {
        throw new RuntimeException(I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
    }
    if (GlueTypeEnum.BEAN == GlueTypeEnum.match(jobInfo.getGlueType())) {
        throw new RuntimeException(I18nUtil.getString("jobinfo_glue_gluetype_unvalid"));
    }
    // Glue类型-字典
    model.addAttribute("GlueTypeEnum", GlueTypeEnum.values());
    model.addAttribute("jobInfo", jobInfo);
    model.addAttribute("jobLogGlues", jobLogGlues);
    return "jobcode/jobcode.index";
}
Also used : XxlJobLogGlue(com.xxl.job.admin.core.model.XxlJobLogGlue) XxlJobInfo(com.xxl.job.admin.core.model.XxlJobInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

XxlJobLogGlue (com.xxl.job.admin.core.model.XxlJobLogGlue)3 XxlJobInfo (com.xxl.job.admin.core.model.XxlJobInfo)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ReturnT (com.xxl.job.core.biz.model.ReturnT)1 Date (java.util.Date)1 Test (org.junit.Test)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1