From a83f06339bdd8366aac10ea7c69eb845fd8e1729 Mon Sep 17 00:00:00 2001 From: zCans <1224895921@qq.com> Date: Sun, 25 Sep 2022 23:51:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=B0=83=E5=BA=A6=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- neutrino-proxy-admin/src/api/jobLog.js | 2 +- neutrino-proxy-admin/src/utils/request.js | 4 +- .../src/views/system/jobLog.vue | 28 +++++--- .../server/constant/AlarmStatusEnum.java | 41 ++++++++++++ .../server/controller/JobLogController.java | 54 +++++++++++++++ .../server/controller/req/JobLogListReq.java | 34 ++++++++++ .../server/controller/res/JobLogListRes.java | 65 +++++++++++++++++++ .../proxy/server/dal/JobLogMapper.java | 17 +++++ .../proxy/server/service/JobLogService.java | 17 +++++ 9 files changed, 250 insertions(+), 12 deletions(-) create mode 100644 neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/constant/AlarmStatusEnum.java create mode 100644 neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/JobLogController.java create mode 100644 neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/JobLogListReq.java create mode 100644 neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/JobLogListRes.java diff --git a/neutrino-proxy-admin/src/api/jobLog.js b/neutrino-proxy-admin/src/api/jobLog.js index 016785a9..4297c968 100644 --- a/neutrino-proxy-admin/src/api/jobLog.js +++ b/neutrino-proxy-admin/src/api/jobLog.js @@ -2,7 +2,7 @@ import request from '@/utils/request' export function fetchList(query) { return request({ - url: '/job-Log/page', + url: '/job-log/page', method: 'get', params: query }) diff --git a/neutrino-proxy-admin/src/utils/request.js b/neutrino-proxy-admin/src/utils/request.js index abaab545..2bc8a5f7 100644 --- a/neutrino-proxy-admin/src/utils/request.js +++ b/neutrino-proxy-admin/src/utils/request.js @@ -25,8 +25,8 @@ service.interceptors.request.use(config => { // respone interceptor service.interceptors.response.use( response => { - console.log('response', response) - console.log('router', this.router) + // console.log('response', response) + // console.log('router', this.router) const res = response.data if (res.code !== 0) { Message({ diff --git a/neutrino-proxy-admin/src/views/system/jobLog.vue b/neutrino-proxy-admin/src/views/system/jobLog.vue index a5a427aa..b1803f23 100644 --- a/neutrino-proxy-admin/src/views/system/jobLog.vue +++ b/neutrino-proxy-admin/src/views/system/jobLog.vue @@ -20,9 +20,9 @@ {{scope.row.param}} - + @@ -30,12 +30,12 @@ {{scope.row.msg}} - + - + @@ -77,20 +77,30 @@ export default { } }, filters: { + statusName(status) { + const statusMap = { + 0: '成功', + 1: '失败' + } + return statusMap[status] + }, statusFilter(status) { const statusMap = { - 1: 'success', - 2: 'danger' + 0: 'success', + 1: 'danger' } return statusMap[status] } }, created() { - // this.getList() + this.getList() }, activated() { - this.listQuery.jobId = this.$route.query.jobId - // this.getList() + if (this.$route.query.jobId) { + this.listQuery.jobId = this.$route.query.jobId + console.log(this.listQuery.jobId, this.$route.query.jobId) + this.getList() + } }, methods: { getList() { diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/constant/AlarmStatusEnum.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/constant/AlarmStatusEnum.java new file mode 100644 index 00000000..05d6aa62 --- /dev/null +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/constant/AlarmStatusEnum.java @@ -0,0 +1,41 @@ +/** + * 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.constant; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 启用状态枚举 + * @author: zCans + * @date: 2022/9/25 + */ +@Getter +@AllArgsConstructor +public enum AlarmStatusEnum { + WAIT(1, "待发送"), + SUCCESS(2, "发送成功"), + ERROR(3, "发送失败"); + + private Integer status; + private String desc; +} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/JobLogController.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/JobLogController.java new file mode 100644 index 00000000..16f80d38 --- /dev/null +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/JobLogController.java @@ -0,0 +1,54 @@ +/** + * 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; + +import fun.asgc.neutrino.core.annotation.Autowired; +import fun.asgc.neutrino.core.annotation.NonIntercept; +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.controller.req.*; +import fun.asgc.neutrino.proxy.server.controller.res.*; +import fun.asgc.neutrino.proxy.server.service.JobLogService; +import fun.asgc.neutrino.proxy.server.util.ParamCheckUtil; +import lombok.extern.slf4j.Slf4j; + +/** + * + * @author: zCans + * @date: 2022/9/25 + */ +@Slf4j +@NonIntercept +@RequestMapping("job-log") +@RestController +public class JobLogController { + @Autowired + private JobLogService jobLogService; + + @GetMapping("page") + public Page page(PageQuery pageQuery, JobLogListReq req) { + ParamCheckUtil.checkNotNull(pageQuery, "pageQuery"); + return jobLogService.page(pageQuery, req); + } + +} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/JobLogListReq.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/JobLogListReq.java new file mode 100644 index 00000000..274b44e2 --- /dev/null +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/req/JobLogListReq.java @@ -0,0 +1,34 @@ +/** + * 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; + +/** + * 端口映射列表请求 + * @author: zCans + * @date: 2022/9/12 + */ +@Data +public class JobLogListReq { + public Integer jobId; +} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/JobLogListRes.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/JobLogListRes.java new file mode 100644 index 00000000..d350112f --- /dev/null +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/res/JobLogListRes.java @@ -0,0 +1,65 @@ +/** + * 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.res; + +import lombok.Data; + +import java.util.Date; + +/** + * 调度日志列表响应 + * @author: zCans + * @date: 2022/9/12 + */ +@Data +public class JobLogListRes { + private Integer id; + /** + * job_id + */ + private Integer jobId; + /** + * 处理器 + */ + private String handler; + /** + * 任务参数 + */ + private String param; + /** + * code + */ + private Integer code; + /** + * msg + */ + private String msg; + /** + * 报警状态 + * {@link fun.asgc.neutrino.proxy.server.constant.AlarmStatusEnum} + */ + private Integer alarmStatus; + /** + * 创建时间 + */ + private Date createTime; +} diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/JobLogMapper.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/JobLogMapper.java index 2d9e6d5c..c661ccee 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/JobLogMapper.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/JobLogMapper.java @@ -22,9 +22,17 @@ package fun.asgc.neutrino.proxy.server.dal; import fun.asgc.neutrino.core.annotation.Component; +import fun.asgc.neutrino.core.annotation.Param; import fun.asgc.neutrino.core.aop.Intercept; import fun.asgc.neutrino.core.db.annotation.Insert; +import fun.asgc.neutrino.core.db.annotation.ResultType; +import fun.asgc.neutrino.core.db.annotation.Select; import fun.asgc.neutrino.core.db.mapper.SqlMapper; +import fun.asgc.neutrino.core.db.page.Page; +import fun.asgc.neutrino.proxy.server.controller.req.JobInfoListReq; +import fun.asgc.neutrino.proxy.server.controller.req.JobLogListReq; +import fun.asgc.neutrino.proxy.server.controller.res.JobInfoListRes; +import fun.asgc.neutrino.proxy.server.controller.res.JobLogListRes; import fun.asgc.neutrino.proxy.server.dal.entity.JobInfoDO; import fun.asgc.neutrino.proxy.server.dal.entity.JobLogDO; @@ -39,4 +47,13 @@ public interface JobLogMapper extends SqlMapper { @Insert("insert into job_log(`job_id`,`handler`,`param`,`code`,`msg`,`alarm_status`,`create_time`) values(:jobId,:handler,:param,:code,:msg,:alarmStatus,:createTime)") void add(JobLogDO jobLog); + + @ResultType(JobLogListRes.class) + @Select("select * from job_log order by create_time desc") + void page(Page page, JobLogListReq req); + + @ResultType(JobLogListRes.class) + @Select("select * from job_log where job_id = :jobId order by create_time desc") + void pageByJobId(Page page, JobLogListReq req); + } diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/JobLogService.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/JobLogService.java index 3c9c536c..63d14c9b 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/JobLogService.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/JobLogService.java @@ -24,8 +24,14 @@ package fun.asgc.neutrino.proxy.server.service; import fun.asgc.neutrino.core.annotation.Autowired; import fun.asgc.neutrino.core.annotation.Component; import fun.asgc.neutrino.core.annotation.NonIntercept; +import fun.asgc.neutrino.core.db.page.Page; +import fun.asgc.neutrino.core.db.page.PageQuery; import fun.asgc.neutrino.core.quartz.IJobCallback; import fun.asgc.neutrino.core.quartz.JobInfo; +import fun.asgc.neutrino.proxy.server.controller.req.JobInfoListReq; +import fun.asgc.neutrino.proxy.server.controller.req.JobLogListReq; +import fun.asgc.neutrino.proxy.server.controller.res.JobInfoListRes; +import fun.asgc.neutrino.proxy.server.controller.res.JobLogListRes; import fun.asgc.neutrino.proxy.server.dal.JobLogMapper; import fun.asgc.neutrino.proxy.server.dal.entity.JobLogDO; import lombok.extern.slf4j.Slf4j; @@ -68,4 +74,15 @@ public class JobLogService implements IJobCallback { ); } + public Page page(PageQuery pageQuery, JobLogListReq req) { + Page page = Page.create(pageQuery); + + if(req.getJobId() != null){ + jobLogMapper.pageByJobId(page, req); + } else { + jobLogMapper.page(page, req); + } + return page; + } + }