Skip to content

Commit

Permalink
项目管理模块更新
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiYe-Jing committed May 31, 2020
1 parent 01afbae commit 26acda7
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public class JobApiController {
@Resource
private AdminBiz adminBiz;



/**
* callback
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private List<String> findRegistryByAppName(String appNameParam) {
public ReturnT<String> remove(int id) {

// valid
int count = jobInfoMapper.pageListCount(0, 10, id, -1, null, null, null,null);
int count = jobInfoMapper.pageListCount(0, 10, id, -1, null, null, 0,null);
if (count > 0) {
return new ReturnT<>(500, I18nUtil.getString("jobgroup_del_limit_0"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
Expand All @@ -31,7 +32,7 @@
@Api(tags = "任务配置接口")
@RestController
@RequestMapping("/api/job")
public class JobInfoController {
public class JobInfoController extends BaseController{

@Resource
private JobService jobService;
Expand All @@ -41,9 +42,9 @@ public class JobInfoController {
@ApiOperation("任务列表")
public ReturnT<Map<String, Object>> pageList(@RequestParam(required = false, defaultValue = "0") int current,
@RequestParam(required = false, defaultValue = "10") int size,
int jobGroup, int triggerStatus, String jobDesc, String glueType, String author, String jobProject) {
int jobGroup, int triggerStatus, String jobDesc, String glueType, int userId, Integer[] projectIds) {

return new ReturnT<>(jobService.pageList((current-1)*size, size, jobGroup, triggerStatus, jobDesc, glueType, author, jobProject));
return new ReturnT<>(jobService.pageList((current-1)*size, size, jobGroup, triggerStatus, jobDesc, glueType, userId, projectIds));
}

@GetMapping("/list")
Expand All @@ -52,20 +53,17 @@ public ReturnT<List<Object>> list(){
return new ReturnT<>(jobService.list());
}

@GetMapping("/projects")
public ReturnT<List<Object>> projects(){
return new ReturnT<>(jobService.projects());
}

@PostMapping("/add")
@ApiOperation("添加任务")
public ReturnT<String> add(@RequestBody JobInfo jobInfo) {
public ReturnT<String> add(HttpServletRequest request, @RequestBody JobInfo jobInfo) {
jobInfo.setUserId(getCurrentUserId(request));
return jobService.add(jobInfo);
}

@PostMapping("/update")
@ApiOperation("更新任务")
public ReturnT<String> update(@RequestBody JobInfo jobInfo) {
public ReturnT<String> update(HttpServletRequest request,@RequestBody JobInfo jobInfo) {
jobInfo.setUserId(getCurrentUserId(request));
return jobService.update(jobInfo);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wugui.datax.admin.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

Expand Down Expand Up @@ -29,8 +30,8 @@ public class JobInfo {

private Date updateTime;

@ApiModelProperty("负责人")
private String author;
@ApiModelProperty("修改用户")
private int userId;

@ApiModelProperty("报警邮件")
private String alarmEmail;
Expand Down Expand Up @@ -115,4 +116,7 @@ public class JobInfo {

@ApiModelProperty("数据源id")
private String datasourceId;

@TableField(exist=false)
private String projectName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,20 @@ List<JobInfo> pageList(@Param("offset") int offset,
@Param("triggerStatus") int triggerStatus,
@Param("jobDesc") String jobDesc,
@Param("glueType") String glueType,
@Param("author") String author,
@Param("jobProjects") String[] jobProjects);
@Param("userId") int userId,
@Param("projectIds") Integer[] projectIds);

int pageListCount(@Param("offset") int offset,
@Param("pagesize") int pagesize,
@Param("jobGroup") int jobGroup,
@Param("triggerStatus") int triggerStatus,
@Param("jobDesc") String jobDesc,
@Param("glueType") String glueType,
@Param("author") String author,
@Param("jobProjects") String[] jobProjects);
@Param("userId") int userId,
@Param("projectIds") Integer[] projectIds);

List<Object> findAll();

List<Object> projects();

int save(JobInfo info);

JobInfo loadById(@Param("id") int id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ public interface JobService {
* @param jobGroup
* @param jobDesc
* @param glueType
* @param author
* @param userId
* @return
*/
Map<String, Object> pageList(int start, int length, int jobGroup, int triggerStatus, String jobDesc, String glueType, String author,String jobProject);
Map<String, Object> pageList(int start, int length, int jobGroup, int triggerStatus, String jobDesc, String glueType, int userId,Integer[] projectIds);

List<Object> list();

List<Object> projects();

/**
* add job
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,11 @@ public class JobServiceImpl implements JobService {
private DataxJsonService dataxJsonService;

@Override
public Map<String, Object> pageList(int start, int length, int jobGroup, int triggerStatus, String jobDesc, String glueType, String author, String jobProject) {

String[] jobProjects = null;
if (jobProject != null && !jobProject.isEmpty()) {
jobProjects = jobProject.split(",");
}

public Map<String, Object> pageList(int start, int length, int jobGroup, int triggerStatus, String jobDesc, String glueType, int userId, Integer[] projectIds) {

// page list
List<JobInfo> list = jobInfoMapper.pageList(start, length, jobGroup, triggerStatus, jobDesc, glueType, author, jobProjects);
int list_count = jobInfoMapper.pageListCount(start, length, jobGroup, triggerStatus, jobDesc, glueType, author, jobProjects);
List<JobInfo> list = jobInfoMapper.pageList(start, length, jobGroup, triggerStatus, jobDesc, glueType, userId, projectIds);
int list_count = jobInfoMapper.pageListCount(start, length, jobGroup, triggerStatus, jobDesc, glueType, userId, projectIds);

// package result
Map<String, Object> maps = new HashMap<>();
Expand All @@ -84,10 +78,6 @@ public List<Object> list() {
return jobInfoMapper.findAll();
}

public List<Object> projects() {
return jobInfoMapper.projects();
}

@Override
public ReturnT<String> add(JobInfo jobInfo) {
// valid
Expand All @@ -104,7 +94,7 @@ public ReturnT<String> add(JobInfo jobInfo) {
if (jobInfo.getJobDesc() == null || jobInfo.getJobDesc().trim().length() == 0) {
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobinfo_field_jobdesc")));
}
if (jobInfo.getAuthor() == null || jobInfo.getAuthor().trim().length() == 0) {
if (jobInfo.getUserId() == 0 ) {
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobinfo_field_author")));
}
if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) {
Expand Down Expand Up @@ -200,7 +190,7 @@ public ReturnT<String> update(JobInfo jobInfo) {
if (jobInfo.getProjectId() == 0) {
return new ReturnT<String>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobinfo_field_jobproject")));
}
if (jobInfo.getAuthor() == null || jobInfo.getAuthor().trim().length() == 0) {
if (jobInfo.getUserId() == 0) {
return new ReturnT<>(ReturnT.FAIL_CODE, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobinfo_field_author")));
}
if (ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(), null) == null) {
Expand Down Expand Up @@ -270,7 +260,7 @@ public ReturnT<String> update(JobInfo jobInfo) {
exists_jobInfo.setJobGroup(jobInfo.getJobGroup());
exists_jobInfo.setJobCron(jobInfo.getJobCron());
exists_jobInfo.setJobDesc(jobInfo.getJobDesc());
exists_jobInfo.setAuthor(jobInfo.getAuthor());
exists_jobInfo.setUserId(jobInfo.getUserId());
exists_jobInfo.setAlarmEmail(jobInfo.getAlarmEmail());
exists_jobInfo.setExecutorRouteStrategy(jobInfo.getExecutorRouteStrategy());
exists_jobInfo.setExecutorHandler(jobInfo.getExecutorHandler());
Expand Down
2 changes: 1 addition & 1 deletion datax-admin/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ mybatis-plus:
logging:
level:
com.wugui.datax.admin.mapper: error
path: /data/applogs/admin
path: ./data/applogs/admin
# config: classpath:logback.xml TODO 有这个就无法打印sql。后面排查原因


Expand Down
36 changes: 17 additions & 19 deletions datax-admin/src/main/resources/mybatis-mapper/JobInfoMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<result column="add_time" property="addTime" />
<result column="update_time" property="updateTime" />

<result column="author" property="author" />
<result column="user_id" property="userId" />
<result column="alarm_email" property="alarmEmail" />

<result column="executor_route_strategy" property="executorRouteStrategy" />
Expand Down Expand Up @@ -61,7 +61,7 @@
t.job_desc,
t.add_time,
t.update_time,
t.author,
t.user_id,
t.alarm_email,
t.executor_route_strategy,
t.executor_handler,
Expand Down Expand Up @@ -92,9 +92,13 @@
t.datasource_id
</sql>

<sql id="Project_Column_List">
p.name as project_name
</sql>
<select id="pageList" parameterType="java.util.HashMap" resultMap="JobInfo">
SELECT <include refid="Base_Column_List" />
SELECT <include refid="Base_Column_List" />,<include refid="Project_Column_List" />
FROM job_info AS t
INNER JOIN job_project p on t.project_id=p.id
<trim prefix="WHERE" prefixOverrides="AND | OR" >
<if test="jobGroup gt 0">
AND t.job_group = #{jobGroup}
Expand All @@ -108,10 +112,10 @@
<if test="glueType != null and glueType != ''">
AND t.glue_type like CONCAT(CONCAT('%', #{glueType}), '%')
</if>
<if test="author != null and author != ''">
AND t.author like CONCAT(CONCAT('%', #{author}), '%')
<if test="userId gt 0">
AND t.user_id = #{userId}
</if>
<if test="projectIds != null">
<if test="projectIds != null and projectIds.length != 0">
AND t.project_id IN
<foreach collection="projectIds" item="projectId" index="index" open="(" close=")" separator=",">
#{projectId}
Expand All @@ -128,16 +132,10 @@
ORDER BY job_desc ASC
</select>

<select id="projects" parameterType="java.util.HashMap" resultMap="JobProject">
SELECT distinct(project_id) as project_id
FROM job_info AS t
WHERE project_id IS NOT NULL
ORDER BY project_id ASC
</select>

<select id="pageListCount" parameterType="java.util.HashMap" resultType="int">
SELECT count(1)
FROM job_info AS t
INNER JOIN job_project p on t.project_id=p.id
<trim prefix="WHERE" prefixOverrides="AND | OR" >
<if test="jobGroup gt 0">
AND t.job_group = #{jobGroup}
Expand All @@ -151,10 +149,10 @@
<if test="glueType != null and glueType != ''">
AND t.glue_type like CONCAT(CONCAT('%', #{glueType}), '%')
</if>
<if test="author != null and author != ''">
AND t.author like CONCAT(CONCAT('%', #{author}), '%')
<if test="userId gt 0">
AND t.user_id =#{userId}
</if>
<if test="projectIds != null">
<if test="projectIds != null and projectIds.length != 0">
AND t.project_id IN
<foreach collection="projectIds" item="projectId" index="index" open="(" close=")" separator=",">
#{projectId}
Expand All @@ -170,7 +168,7 @@
job_desc,
add_time,
update_time,
author,
user_id,
alarm_email,
executor_route_strategy,
executor_handler,
Expand Down Expand Up @@ -205,7 +203,7 @@
#{jobDesc},
#{addTime},
#{updateTime},
#{author},
#{userId},
#{alarmEmail},
#{executorRouteStrategy},
#{executorHandler},
Expand Down Expand Up @@ -254,7 +252,7 @@
job_cron = #{jobCron},
job_desc = #{jobDesc},
update_time = #{updateTime},
author = #{author},
user_id = #{userId},
alarm_email = #{alarmEmail},
executor_route_strategy = #{executorRouteStrategy},
executor_handler = #{executorHandler},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class JobInfoMapperTest {

@Test
public void pageList(){
List<JobInfo> list = jobInfoMapper.pageList(0, 20, 0, -1, null, null, null,null);
int list_count = jobInfoMapper.pageListCount(0, 20, 0, -1, null, null, null,null);
List<JobInfo> list = jobInfoMapper.pageList(0, 20, 0, -1, null, null, 0,null);
int list_count = jobInfoMapper.pageListCount(0, 20, 0, -1, null, null, 0,null);

System.out.println(list);
System.out.println(list_count);
Expand All @@ -35,7 +35,7 @@ public void save_load(){
info.setJobGroup(1);
info.setJobCron("jobCron");
info.setJobDesc("desc");
info.setAuthor("setAuthor");
info.setUserId(1);
info.setAlarmEmail("setAlarmEmail");
info.setExecutorRouteStrategy("setExecutorRouteStrategy");
info.setExecutorHandler("setExecutorHandler");
Expand All @@ -55,7 +55,7 @@ public void save_load(){
JobInfo info2 = jobInfoMapper.loadById(info.getId());
info2.setJobCron("jobCron2");
info2.setJobDesc("desc2");
info2.setAuthor("setAuthor2");
info2.setUserId(1);
info2.setAlarmEmail("setAlarmEmail2");
info2.setExecutorRouteStrategy("setExecutorRouteStrategy2");
info2.setExecutorHandler("setExecutorHandler2");
Expand Down
8 changes: 4 additions & 4 deletions datax-executor/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ server:
# log config
logging:
config: classpath:logback.xml
path: /data/applogs/executor/jobhandler
path: ./data/applogs/executor/jobhandler

### datax admin address list, such as "http://address" or "http://address01,http://address02"
datax:
Expand All @@ -18,13 +18,13 @@ datax:
ip:
port: 9999
### job log path
logpath: /data/applogs/executor/jobhandler
logpath: ./data/applogs/executor/jobhandler
### job log retention days
logretentiondays: 30
### job, access token
accessToken:

executor:
jsonpath: D:\\temp\\executor\\json\\
jsonpath: /Users/mac/data/applogs

pypath: F:\tools\datax\bin\datax.py
pypath: /Users/mac/tools/datax/bin/datax.py
4 changes: 4 additions & 0 deletions doc/db/datax_web.sql
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,7 @@ CREATE TABLE `job_project` (
`update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT 'update time',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;


ALTER TABLE `datax_web`.`job_info`
CHANGE COLUMN `author` `user_id` INT(11) NOT NULL COMMENT '修改用户' ;

0 comments on commit 26acda7

Please sign in to comment.