✨ 添加新特性。基于代码生成 任务执行日志

This commit is contained in:
冷冷 committed 2018-08-05 17:07:18 +08:00
1 parent 5e2694588f
commit f5c19f0cdc
22 files changed
+641 -25

No files matched your search

+1 -13
View File
@@ -15,14 +15,6 @@
<name>pigx-codegen</name>
<description>代码生成模块</description>
<properties>
<mybatis.spring.boot.version>1.3.0</mybatis.spring.boot.version>
<commons.lang.version>2.6</commons.lang.version>
<commons.io.version>2.5</commons.io.version>
<commons.configuration.version>1.10</commons.configuration.version>
<velocity.version>1.7</velocity.version>
</properties>
<dependencies>
<!--配置中心客户端-->
<dependency>
@@ -45,16 +37,12 @@
<artifactId>pigx-common-core</artifactId>
<version>${pigx.version}</version>
</dependency>
<!--swagger 内置安全模块-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-swagger</artifactId>
<version>${pigx.version}</version>
</dependency>
<!--spring security 、oauth、jwt依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-security</artifactId>
</dependency>
<!--代码生成模板引擎-->
<dependency>
<artifactId>velocity</artifactId>
@@ -265,7 +265,7 @@ public class GenUtils {
}
if (template.contains(MAPPER_XML_VM)) {
return "pigx" + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + "mapper" + File.separator + moduleName + File.separator + className + "Mapper.xml";
return "pigx" + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + "mapper" + File.separator + className + "Mapper.xml";
}
if (template.contains(MENU_SQL_VM)) {
@@ -23,6 +23,7 @@ export const tableOption = {
"align": "center",
"editBtn": false,
"delBtn": false,
"addBtn": false,
"dic": [],
"column": [
#foreach ($column in $columns)
@@ -2,12 +2,12 @@
-- 菜单SQL
insert into `pigx`.`sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
values ( '父菜单ID', 'views/${moduleName}/${pathName}/index', '菜单ID', '0', '${pathName}', 'icon-bangzhushouji', '8', '0', '2018-01-20 13:17:19', '8', '2018-07-29 13:38:19', '${comments}管理');
values ( '父菜单ID', 'views/${moduleName}/${pathName}/index', '', '0', '${pathName}', 'icon-bangzhushouji', '菜单ID', '0', '2018-01-20 13:17:19', '8', '2018-07-29 13:38:19', '${comments}管理');
-- 菜单对应按钮SQL
insert into `pigx`.`sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
values ( '子按钮ID1', null, '${moduleName}_${pathName}_add', '1', null, '1', '菜单ID', '0', '2018-05-15 21:35:18', '0', '2018-07-29 13:38:59', '${comments}新增');
values ( '菜单ID', null, '${moduleName}_${pathName}_add', '1', null, '1', '子按钮ID1', '0', '2018-05-15 21:35:18', '0', '2018-07-29 13:38:59', '${comments}新增');
insert into `pigx`.`sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
values ( '子按钮ID2', null, '${moduleName}_${pathName}_edit', '1', null, '1', '菜单ID', '0', '2018-05-15 21:35:18', '1', '2018-07-29 13:38:59', '${comments}修改');
values ( '菜单ID', null, '${moduleName}_${pathName}_edit', '1', null, '1', '子按钮ID2', '0', '2018-05-15 21:35:18', '1', '2018-07-29 13:38:59', '${comments}修改');
insert into `pigx`.`sys_menu` ( `parent_id`, `component`, `permission`, `type`, `path`, `icon`, `menu_id`, `del_flag`, `create_time`, `sort`, `update_time`, `name`)
values ( '子按钮ID3', null, '${moduleName}_${pathName}_del', '1', null, '1', '菜单ID', '0', '2018-05-15 21:35:18', '2', '2018-07-29 13:38:59', '${comments}删除');
values ( '菜单ID', null, '${moduleName}_${pathName}_del', '1', null, '1', '子按钮ID3', '0', '2018-05-15 21:35:18', '2', '2018-07-29 13:38:59', '${comments}删除');
+12 -5
View File
@@ -44,15 +44,16 @@
<artifactId>pigx-common-job</artifactId>
<version>${pigx.version}</version>
</dependency>
<!--数据库-->
<!--mybatis-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mbp.boot.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!--ZK 依赖-->
<dependency>
<groupId>org.apache.curator</groupId>
@@ -64,6 +65,12 @@
<artifactId>curator-recipes</artifactId>
<version>${curator.version}</version>
</dependency>
<!--swagger 内置安全模块-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-swagger</artifactId>
<version>${pigx.version}</version>
</dependency>
<!--web 模块-->
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -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();
}
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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> {
}
@@ -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> {
}
@@ -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> {
}
@@ -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> {
}
@@ -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 {
}
@@ -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>