mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-10 21:19:00 +08:00
✨ 添加新特性。基于代码生成 任务执行日志
This commit is contained in:
1 parent
5e2694588f
commit
f5c19f0cdc
22 files changed
+641
-25
No files matched your search
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.daemon.config;
|
||||
|
||||
import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2017/10/29
|
||||
*/
|
||||
@Configuration
|
||||
@MapperScan("com.pig4cloud.pigx.daemon.mapper")
|
||||
public class MybatisPlusConfigurer {
|
||||
/**
|
||||
* 分页插件
|
||||
*
|
||||
* @return PaginationInterceptor
|
||||
*/
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor() {
|
||||
return new PaginationInterceptor();
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.daemon.config;
|
||||
|
||||
import com.pig4cloud.pigx.common.security.component.PigAccessDeniedHandler;
|
||||
import com.pig4cloud.pigx.common.security.component.ResourceAuthExceptionEntryPoint;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2018/6/22
|
||||
*/
|
||||
@Configuration
|
||||
@EnableResourceServer
|
||||
@AllArgsConstructor
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
|
||||
private final PigAccessDeniedHandler pigAccessDeniedHandler;
|
||||
private final ResourceAuthExceptionEntryPoint resourceAuthExceptionEntryPoint;
|
||||
|
||||
@Override
|
||||
public void configure(HttpSecurity http) throws Exception {
|
||||
http.authorizeRequests()
|
||||
.antMatchers("/actuator/**", "/v2/api-docs").permitAll()
|
||||
.anyRequest().authenticated()
|
||||
.and().csrf().disable();
|
||||
}
|
||||
|
||||
/**
|
||||
* why add resourceId
|
||||
* https://stackoverflow.com/questions/28703847/how-do-you-set-a-resource-id-for-a-token
|
||||
*
|
||||
* @param resources
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
|
||||
resources.authenticationEntryPoint(resourceAuthExceptionEntryPoint)
|
||||
.accessDeniedHandler(pigAccessDeniedHandler);
|
||||
}
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.daemon.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.baomidou.mybatisplus.plugins.Page;
|
||||
import com.pig4cloud.pigx.common.core.util.Query;
|
||||
|
||||
import com.pig4cloud.pigx.daemon.entity.ExecutionLog;
|
||||
import com.pig4cloud.pigx.daemon.service.ExecutionLogService;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author lengleng
|
||||
* @date 2018-08-03 22:15:56
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/executionlog")
|
||||
public class ExecutionLogController {
|
||||
@Autowired
|
||||
private ExecutionLogService executionLogService;
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public Page page(@RequestParam Map<String, Object> params) {
|
||||
return executionLogService.selectPage(new Query<>(params), new EntityWrapper<>());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
* @param id
|
||||
* @return R
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R info(@PathVariable("id") String id){
|
||||
ExecutionLog executionLog = executionLogService.selectById(id);
|
||||
|
||||
return new R<>(executionLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
* @param executionLog
|
||||
* @return R
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public R save(@RequestBody ExecutionLog executionLog){
|
||||
executionLogService.insert(executionLog);
|
||||
|
||||
return new R<>(Boolean.TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param executionLog
|
||||
* @return R
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public R update(@RequestBody ExecutionLog executionLog){
|
||||
executionLogService.updateById(executionLog);
|
||||
|
||||
return new R<>(Boolean.TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param ids
|
||||
* @return R
|
||||
*/
|
||||
@DeleteMapping("/delete")
|
||||
public R delete(@RequestBody String[] ids){
|
||||
executionLogService.deleteBatchIds(Arrays.asList(ids));
|
||||
|
||||
return new R<>(Boolean.TRUE);
|
||||
}
|
||||
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.daemon.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.baomidou.mybatisplus.plugins.Page;
|
||||
import com.pig4cloud.pigx.common.core.util.Query;
|
||||
|
||||
import com.pig4cloud.pigx.daemon.entity.StatusTraceLog;
|
||||
import com.pig4cloud.pigx.daemon.service.StatusTraceLogService;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author lengleng
|
||||
* @date 2018-08-03 22:15:45
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/statustracelog")
|
||||
public class StatusTraceLogController {
|
||||
@Autowired
|
||||
private StatusTraceLogService statusTraceLogService;
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public Page page(@RequestParam Map<String, Object> params) {
|
||||
return statusTraceLogService.selectPage(new Query<>(params), new EntityWrapper<>());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
* @param id
|
||||
* @return R
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R info(@PathVariable("id") String id){
|
||||
StatusTraceLog statusTraceLog = statusTraceLogService.selectById(id);
|
||||
|
||||
return new R<>(statusTraceLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
* @param statusTraceLog
|
||||
* @return R
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public R save(@RequestBody StatusTraceLog statusTraceLog){
|
||||
statusTraceLogService.insert(statusTraceLog);
|
||||
|
||||
return new R<>(Boolean.TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param statusTraceLog
|
||||
* @return R
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public R update(@RequestBody StatusTraceLog statusTraceLog){
|
||||
statusTraceLogService.updateById(statusTraceLog);
|
||||
|
||||
return new R<>(Boolean.TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param ids
|
||||
* @return R
|
||||
*/
|
||||
@DeleteMapping("/delete")
|
||||
public R delete(@RequestBody String[] ids){
|
||||
statusTraceLogService.deleteBatchIds(Arrays.asList(ids));
|
||||
|
||||
return new R<>(Boolean.TRUE);
|
||||
}
|
||||
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
package com.pig4cloud.pigx.daemon.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.activerecord.Model;
|
||||
import com.baomidou.mybatisplus.annotations.TableId;
|
||||
import com.baomidou.mybatisplus.annotations.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author lengleng
|
||||
* @date 2018-08-03 22:15:56
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("JOB_EXECUTION_LOG")
|
||||
public class ExecutionLog extends Model<ExecutionLog> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String jobName;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String taskId;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String hostname;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String ip;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer shardingItem;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String executionSource;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String failureCause;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer isSuccess;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private LocalDateTime completeTime;
|
||||
|
||||
/**
|
||||
* 主键值
|
||||
*/
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
Executable
+76
@@ -0,0 +1,76 @@
|
||||
package com.pig4cloud.pigx.daemon.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.activerecord.Model;
|
||||
import com.baomidou.mybatisplus.annotations.TableId;
|
||||
import com.baomidou.mybatisplus.annotations.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author lengleng
|
||||
* @date 2018-08-03 22:15:45
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("JOB_STATUS_TRACE_LOG")
|
||||
public class StatusTraceLog extends Model<StatusTraceLog> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String jobName;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String originalTaskId;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String taskId;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String slaveId;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String source;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String executionType;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String shardingItem;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String state;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String message;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private LocalDateTime creationTime;
|
||||
|
||||
/**
|
||||
* 主键值
|
||||
*/
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
package com.pig4cloud.pigx.daemon.mapper;
|
||||
|
||||
import com.pig4cloud.pigx.daemon.entity.ExecutionLog;
|
||||
import com.baomidou.mybatisplus.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author lengleng
|
||||
* @date 2018-08-03 22:15:56
|
||||
*/
|
||||
@Mapper
|
||||
public interface ExecutionLogMapper extends BaseMapper<ExecutionLog> {
|
||||
|
||||
}
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
package com.pig4cloud.pigx.daemon.mapper;
|
||||
|
||||
import com.pig4cloud.pigx.daemon.entity.StatusTraceLog;
|
||||
import com.baomidou.mybatisplus.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author lengleng
|
||||
* @date 2018-08-03 22:15:45
|
||||
*/
|
||||
@Mapper
|
||||
public interface StatusTraceLogMapper extends BaseMapper<StatusTraceLog> {
|
||||
|
||||
}
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
package com.pig4cloud.pigx.daemon.service;
|
||||
|
||||
import com.baomidou.mybatisplus.service.IService;
|
||||
import com.pig4cloud.pigx.daemon.entity.ExecutionLog;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author lengleng
|
||||
* @date 2018-08-03 22:15:56
|
||||
*/
|
||||
public interface ExecutionLogService extends IService<ExecutionLog> {
|
||||
}
|
||||
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
package com.pig4cloud.pigx.daemon.service;
|
||||
|
||||
import com.baomidou.mybatisplus.service.IService;
|
||||
import com.pig4cloud.pigx.daemon.entity.StatusTraceLog;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author lengleng
|
||||
* @date 2018-08-03 22:15:45
|
||||
*/
|
||||
public interface StatusTraceLogService extends IService<StatusTraceLog> {
|
||||
}
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.pig4cloud.pigx.daemon.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
||||
import com.baomidou.mybatisplus.plugins.Page;
|
||||
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
||||
|
||||
import com.pig4cloud.pigx.daemon.mapper.ExecutionLogMapper;
|
||||
import com.pig4cloud.pigx.daemon.entity.ExecutionLog;
|
||||
import com.pig4cloud.pigx.daemon.service.ExecutionLogService;
|
||||
|
||||
|
||||
@Service("executionLogService")
|
||||
public class ExecutionLogServiceImpl extends ServiceImpl<ExecutionLogMapper, ExecutionLog> implements ExecutionLogService {
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.pig4cloud.pigx.daemon.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
||||
import com.baomidou.mybatisplus.plugins.Page;
|
||||
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
||||
|
||||
import com.pig4cloud.pigx.daemon.mapper.StatusTraceLogMapper;
|
||||
import com.pig4cloud.pigx.daemon.entity.StatusTraceLog;
|
||||
import com.pig4cloud.pigx.daemon.service.StatusTraceLogService;
|
||||
|
||||
|
||||
@Service("statusTraceLogService")
|
||||
public class StatusTraceLogServiceImpl extends ServiceImpl<StatusTraceLogMapper, StatusTraceLog> implements StatusTraceLogService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.pig4cloud.pigx.daemon.dao.ExecutionLogMappper">
|
||||
|
||||
<!-- 可根据自己的需求,是否要使用 -->
|
||||
<resultMap type="com.pig4cloud.pigx.daemon.entity.ExecutionLog" id="executionLogMap">
|
||||
<result property="id" column="id"/>
|
||||
<result property="jobName" column="job_name"/>
|
||||
<result property="taskId" column="task_id"/>
|
||||
<result property="hostname" column="hostname"/>
|
||||
<result property="ip" column="ip"/>
|
||||
<result property="shardingItem" column="sharding_item"/>
|
||||
<result property="executionSource" column="execution_source"/>
|
||||
<result property="failureCause" column="failure_cause"/>
|
||||
<result property="isSuccess" column="is_success"/>
|
||||
<result property="startTime" column="start_time"/>
|
||||
<result property="completeTime" column="complete_time"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.pig4cloud.pigx.daemon.dao.StatusTraceLogMappper">
|
||||
|
||||
<!-- 可根据自己的需求,是否要使用 -->
|
||||
<resultMap type="com.pig4cloud.pigx.daemon.entity.StatusTraceLog" id="statusTraceLogMap">
|
||||
<result property="id" column="id"/>
|
||||
<result property="jobName" column="job_name"/>
|
||||
<result property="originalTaskId" column="original_task_id"/>
|
||||
<result property="taskId" column="task_id"/>
|
||||
<result property="slaveId" column="slave_id"/>
|
||||
<result property="source" column="source"/>
|
||||
<result property="executionType" column="execution_type"/>
|
||||
<result property="shardingItem" column="sharding_item"/>
|
||||
<result property="state" column="state"/>
|
||||
<result property="message" column="message"/>
|
||||
<result property="creationTime" column="creation_time"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in new issue
Block a user