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
@@ -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();
}
}