1、解決sqlMapper更新为Null报错问题

2、增加调度管理编辑接口
This commit is contained in:
zCans
2022-09-17 20:30:50 +08:00
parent 9734e12a86
commit 258fe61c98
7 changed files with 112 additions and 18 deletions
@@ -48,7 +48,7 @@ public abstract class PreparedStatementJdbcCallback<T> implements JdbcCallback<T
StringBuffer sb = new StringBuffer();
if (ArrayUtil.notEmpty(params)) {
for(Object o : params){
sb.append(o.toString()).append(",");
sb.append(o).append(",");
}
if(sb.length() > 0 && sb.charAt(sb.length() - 1) == ','){
@@ -42,7 +42,7 @@
</el-table-column>
<el-table-column align="center" :label="$t('table.actions')" width="230" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="primary" @click="handleEditClick(scope.row)" :disabled="scope.row.enable === 1">编辑</el-button>
<el-button size="mini" type="primary" @click="handleEditClick(scope.row)">编辑</el-button>
<el-button size="mini" type="primary" @click="handleExecuteClick(scope.row)">执行</el-button>
<el-button v-if="scope.row.enable === 1" size="mini" type="danger" @click="handleModifyStatus(scope.row,2)">停止</el-button>
<el-button v-if="scope.row.enable === 2" size="mini" type="success" @click="handleModifyStatus(scope.row,1)">启动</el-button>
@@ -27,14 +27,8 @@ import fun.asgc.neutrino.core.db.page.Page;
import fun.asgc.neutrino.core.db.page.PageQuery;
import fun.asgc.neutrino.core.web.annotation.*;
import fun.asgc.neutrino.proxy.server.base.rest.annotation.OnlyAdmin;
import fun.asgc.neutrino.proxy.server.controller.req.JobInfoExecuteReq;
import fun.asgc.neutrino.proxy.server.controller.req.JobInfoListReq;
import fun.asgc.neutrino.proxy.server.controller.req.JobInfoUpdateEnableStatusReq;
import fun.asgc.neutrino.proxy.server.controller.req.PortMappingUpdateEnableStatusReq;
import fun.asgc.neutrino.proxy.server.controller.res.JobInfoExecuteRes;
import fun.asgc.neutrino.proxy.server.controller.res.JobInfoListRes;
import fun.asgc.neutrino.proxy.server.controller.res.JobInfoUpdateEnableStatusRes;
import fun.asgc.neutrino.proxy.server.controller.res.PortMappingUpdateEnableStatusRes;
import fun.asgc.neutrino.proxy.server.controller.req.*;
import fun.asgc.neutrino.proxy.server.controller.res.*;
import fun.asgc.neutrino.proxy.server.service.JobInfoService;
import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil;
import lombok.extern.slf4j.Slf4j;
@@ -76,4 +70,11 @@ public class JobInfoController {
return jobInfoService.execute(req);
}
@PostMapping("update")
public JobInfoUpdateRes update(@RequestBody JobInfoUpdateReq req) {
ParamCheckUtil.checkNotNull(req, "req");
return jobInfoService.update(req);
}
}
@@ -0,0 +1,73 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package fun.asgc.neutrino.proxy.server.controller.req;
import lombok.Data;
import java.util.Date;
/**
* 调度管理更新请求
* @author: zCans
* @date: 2022/9/17
*/
@Data
public class JobInfoUpdateReq {
private Integer id;
/**
* 描述
*/
private String desc;
/**
* 处理器
*/
private String handler;
/**
* cron
*/
private String cron;
/**
* 任务参数
*/
private String param;
/**
* 任务报警邮箱
*/
private String alarmEmail;
/**
* 任务报警钉钉
*/
private String alarmDing;
/**
* 启用状态
* {@link fun.asgc.neutrino.proxy.server.constant.EnableStatusEnum}
*/
private Integer enable;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}
@@ -58,4 +58,6 @@ public interface JobInfoMapper extends SqlMapper {
@ResultType(JobInfoDO.class)
@Select("select * from job_info where enable = 1")
List<JobInfoDO> findEnableList();
void update(JobInfoDO jobInfoDO);
}
@@ -32,16 +32,10 @@ import fun.asgc.neutrino.core.quartz.JobExecutor;
import fun.asgc.neutrino.core.quartz.JobInfo;
import fun.asgc.neutrino.core.util.BeanManager;
import fun.asgc.neutrino.core.util.CollectionUtil;
import fun.asgc.neutrino.core.util.StringUtil;
import fun.asgc.neutrino.core.web.annotation.RequestBody;
import fun.asgc.neutrino.proxy.server.constant.EnableStatusEnum;
import fun.asgc.neutrino.proxy.server.constant.ExceptionConstant;
import fun.asgc.neutrino.proxy.server.controller.req.JobInfoExecuteReq;
import fun.asgc.neutrino.proxy.server.controller.req.JobInfoListReq;
import fun.asgc.neutrino.proxy.server.controller.req.JobInfoUpdateEnableStatusReq;
import fun.asgc.neutrino.proxy.server.controller.res.JobInfoExecuteRes;
import fun.asgc.neutrino.proxy.server.controller.res.JobInfoListRes;
import fun.asgc.neutrino.proxy.server.controller.res.JobInfoUpdateEnableStatusRes;
import fun.asgc.neutrino.proxy.server.controller.req.*;
import fun.asgc.neutrino.proxy.server.controller.res.*;
import fun.asgc.neutrino.proxy.server.dal.JobInfoMapper;
import fun.asgc.neutrino.proxy.server.dal.entity.JobInfoDO;
import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil;
@@ -111,4 +105,20 @@ public class JobInfoService implements IJobSource {
return jobInfoList;
}
public JobInfoUpdateRes update(JobInfoUpdateReq req) {
JobInfoDO jobInfoDO = jobInfoMapper.findById(req.getId());
ParamCheckUtil.checkNotNull( jobInfoDO, ExceptionConstant.PORT_MAPPING_NOT_EXIST);
JobInfoDO jobInfo = new JobInfoDO();
jobInfo.setId(req.getId());
jobInfo.setCron(req.getCron());
jobInfo.setDesc(req.getDesc());
jobInfo.setAlarmEmail(req.getAlarmEmail());
jobInfo.setAlarmDing(req.getAlarmDing());
jobInfo.setParam(req.getParam());
jobInfo.setUpdateTime(new Date());
jobInfoMapper.update( jobInfo);
return new JobInfoUpdateRes();
}
}
@@ -0,0 +1,8 @@
<mapper namespace = "fun.asgc.neutrino.proxy.server.dal.JobInfoMapper">
<update id="update">
update `job_info`
set cron = :cron,desc = :desc,alarm_email=:alarmEmail,alarm_ding=:alarmDing,param=:param,update_time=:updateTime
where id =:id
</update>
</mapper>