Commit b0153f6f authored by mcb's avatar mcb

commit

parent d4b31294
......@@ -5,6 +5,7 @@ import com.jz.common.constant.ResultCode;
import com.jz.common.page.BasePageBean;
import com.jz.common.page.PageInfoResponse;
import com.jz.dmp.modules.controller.DataIntegration.bean.*;
import com.jz.dmp.modules.service.DmpNavigationTreeService;
import com.jz.dmp.modules.service.OfflineSynchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -231,4 +232,30 @@ public class OfflineSynchController {
JsonResult list = offlineSynchService.updateSyncTask(syncDmpTaskAddReq);
return list;
}
/**
* 新增同步任务
*
* @return
* @author Bellamy
* @since 2021-01-26
*/
@ApiOperation(value = "新增同步任务", notes = "新增同步任务")
@PostMapping(value = "/newSynchTask")
public JsonResult addNewSynchTask(@RequestBody @Validated NewSynchTaskReq newSynchTaskReq) throws Exception {
if (StringUtils.isEmpty(newSynchTaskReq.getProjectId())) {
return JsonResult.error(ResultCode.PARAMS_ERROR, "项目ID不能为空");
}
if (StringUtils.isEmpty(newSynchTaskReq.getTreeName())) {
return JsonResult.error(ResultCode.PARAMS_ERROR, "任务名称不能为空");
}
if (StringUtils.isEmpty(newSynchTaskReq.getType())) {
return JsonResult.error(ResultCode.PARAMS_ERROR, "任务类型不能为空");
}
if (StringUtils.isEmpty(newSynchTaskReq.getProjectId())) {
return JsonResult.error(ResultCode.PARAMS_ERROR, "目标文件夹不能为空");
}
JsonResult list = offlineSynchService.addNewSynchTask(newSynchTaskReq);
return list;
}
}
package com.jz.dmp.modules.controller.DataIntegration.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @ClassName: NewSynchTaskReq
* @Description: 新增同步任务请求参数
* @Author:Bellamy
* @Date 2021/01/26
* @Version 1.0
*/
@ApiModel(value = "新增同步任务请求参数", description = "新增同步任务请求参数")
public class NewSynchTaskReq implements Serializable {
private static final long serialVersionUID = 43527848022765137L;
/*
* 任务类型
* */
@ApiModelProperty(value = "任务类型:01:离线同步,02:实时同步,03:数据开发")
@NotNull(message = "任务类型不能为空")
@NotEmpty(message = "任务类型不能为空")
private String type;
/*
* 项目id
* */
@ApiModelProperty(value = "项目id")
@NotNull(message = "项目id不能为空")
@NotEmpty(message = "项目ID不能为空")
private String projectId;
/*
* 任务名称
* */
@ApiModelProperty(value = "任务名称")
@NotNull(message = "任务名称不能为空")
@NotEmpty(message = "任务名称不能为空")
private String treeName;
@ApiModelProperty(value = "目标文件夹")
@NotNull(message = "目标文件夹不能为空")
@NotEmpty(message = "目标文件夹不能为空")
private String parentId;
public String getProjectId() {
return projectId;
}
public void setProjectId(String projectId) {
this.projectId = projectId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getTreeName() {
return treeName;
}
public void setTreeName(String treeName) {
this.treeName = treeName;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
}
......@@ -11,7 +11,7 @@ import java.util.List;
* @author makejava
* @since 2020-12-29 15:08:16
*/
public interface DmpNavigationTreeDao{
public interface DmpNavigationTreeDao {
/**
* 通过ID查询单条数据
......@@ -45,7 +45,7 @@ public interface DmpNavigationTreeDao{
* @param dmpNavigationTree 实例对象
* @return 影响行数
*/
int insert(DmpNavigationTree dmpNavigationTree);
int insert(DmpNavigationTree dmpNavigationTree) throws Exception;
/**
* 批量新增数据(MyBatis原生foreach方法)
......@@ -80,34 +80,36 @@ public interface DmpNavigationTreeDao{
int deleteById(Integer id);
int countTreeByName(DmpNavigationTree tree);
/**
* @Title: getByProjectIdAndName
* @Description: TODO(根据项目ID和任务名称获取tree)
* @param @param projectId
* @param @param name
* @param @return
* @param @throws Exception 参数
* @return DmpNavigationTree 返回类型
* @throws
*/
public DmpNavigationTree getByProjectIdAndName(@Param("projectId") Long projectId,@Param("name") String name)throws Exception;
/**
* @Title: getMaxSortById
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param tree
* @param @return
* @param @throws Exception 参数
* @return Integer 返回类型
* @throws
*/
public Integer getMaxSortById(DmpNavigationTree tree)throws Exception;
/**选择性增加DMP资源导航树
/**
* @param @param projectId
* @param @param name
* @param @return
* @param @throws Exception 参数
* @return DmpNavigationTree 返回类型
* @throws
* @Title: getByProjectIdAndName
* @Description: TODO(根据项目ID和任务名称获取tree)
*/
public DmpNavigationTree getByProjectIdAndName(@Param("projectId") Long projectId, @Param("name") String name) throws Exception;
/**
* @param @param tree
* @param @return
* @param @throws Exception 参数
* @return Integer 返回类型
* @throws
* @Title: getMaxSortById
* @Description: TODO(这里用一句话描述这个方法的作用)
*/
public Integer getMaxSortById(DmpNavigationTree tree) throws Exception;
/**
* 选择性增加DMP资源导航树
*
* @param dmpNavigationTree
* @return
* @throws Exception
*/
public int insertSelective(DmpNavigationTree dmpNavigationTree)throws Exception;
public int insertSelective(DmpNavigationTree dmpNavigationTree) throws Exception;
}
\ No newline at end of file
......@@ -111,4 +111,13 @@ public interface OfflineSynchService {
* @since 2021-01-07
*/
JsonResult stopSyncingTaskByTaskId(String taskId) throws Exception;
/**
* 新增同步任务
*
* @return
* @author Bellamy
* @since 2021-01-26
*/
JsonResult addNewSynchTask(NewSynchTaskReq newSynchTaskReq) throws Exception;
}
......@@ -15,6 +15,7 @@ import com.jz.common.utils.AzkabanApiUtils2;
import com.jz.common.utils.FileUtils;
import com.jz.common.utils.JsonMapper;
import com.jz.common.utils.ZipUtils;
import com.jz.common.utils.web.SessionUtils;
import com.jz.common.utils.web.XmlUtils;
import com.jz.dmp.agent.DmpAgentResult;
import com.jz.dmp.modules.controller.DataIntegration.bean.*;
......@@ -755,4 +756,30 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
return JsonResult.ok();
}
/**
* 新增同步任务
*
* @return
* @author Bellamy
* @since 2021-01-26
*/
@Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public JsonResult addNewSynchTask(NewSynchTaskReq newSynchTaskReq) throws Exception {
DmpNavigationTree tree = new DmpNavigationTree();
tree.setCreateTime(new Date());
tree.setCreateUserId(SessionUtils.getCurrentUserId());
tree.setName(newSynchTaskReq.getTreeName());
tree.setProjectId(Integer.valueOf(newSynchTaskReq.getProjectId()));
tree.setType(newSynchTaskReq.getType());
tree.setParentId(Integer.valueOf(newSynchTaskReq.getParentId()));
tree.setIsLevel("1");
tree.setIsEnable("1");
tree.setDataStatus("1");
int len = dmpNavigationTreeDao.insert(tree);
if (len > 0)
return JsonResult.ok();
return JsonResult.error();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment