Commit 43c219ba authored by mcb's avatar mcb

数据源编辑

parent 1418cbfc
...@@ -20,6 +20,8 @@ import org.springframework.validation.annotation.Validated; ...@@ -20,6 +20,8 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/** /**
* @Description:数据源 * @Description:数据源
...@@ -68,7 +70,7 @@ public class DataSourceController { ...@@ -68,7 +70,7 @@ public class DataSourceController {
@ApiOperation(value = "批量删除数据源", notes = "批量删除数据源") @ApiOperation(value = "批量删除数据源", notes = "批量删除数据源")
@GetMapping(value = "/delDataSource") @GetMapping(value = "/delDataSource")
public JsonResult delDataSource(@RequestParam String datasourceId, HttpServletRequest httpRequest) throws Exception { public JsonResult delDataSource(@RequestParam String datasourceId, HttpServletRequest httpRequest) throws Exception {
if(StringUtils.isEmpty(datasourceId)){ if (StringUtils.isEmpty(datasourceId)) {
return new JsonResult(ResultCode.PARAMS_ERROR); return new JsonResult(ResultCode.PARAMS_ERROR);
} }
JsonResult result = dmpSyncingDatasourceService.delDataSourceById(datasourceId); JsonResult result = dmpSyncingDatasourceService.delDataSourceById(datasourceId);
...@@ -122,4 +124,38 @@ public class DataSourceController { ...@@ -122,4 +124,38 @@ public class DataSourceController {
JsonResult result = dmpSyncingDatasourceService.testConnection(saveBody); JsonResult result = dmpSyncingDatasourceService.testConnection(saveBody);
return result; return result;
} }
/**
* 编辑数据源,根据id查询数据回显
*
* @return
*/
@ApiOperation(value = "编辑数据源--根据id查询数据回显", notes = "编辑数据源--根据id查询数据回显")
@GetMapping(value = "/selectDataSourceInfoById")
public JsonResult getDataSourceInfoById(@RequestParam String datasourceId, @RequestParam(value = "projectId", required = false) String projectId) throws Exception {
if (StringUtils.isEmpty(datasourceId)) {
return new JsonResult(ResultCode.PARAMS_ERROR);
}
Map map = new HashMap();
map.put("datasourceId", datasourceId);
map.put("projectId", projectId);
JsonResult result = dmpSyncingDatasourceService.selectDataSourceInfoById(map);
return result;
}
/**
* 编辑数据源
*
* @return
*/
@ApiOperation(value = "编辑数据源", notes = "编辑数据源")
@PostMapping(value = "/updateDatasourceInfo")
public JsonResult updateDatasourceInfo(@RequestBody @Validated DmpSyncingDatasourceReq saveBody, HttpServletRequest httpRequest) throws Exception {
if (StringUtils.isEmpty(saveBody.getDatasourceId())) {
return new JsonResult(ResultCode.PARAMS_ERROR);
}
JsonResult result = dmpSyncingDatasourceService.updateDatasourceById(saveBody);
return result;
}
} }
...@@ -20,12 +20,10 @@ public class DmpSyncingDatasourceReq implements Serializable { ...@@ -20,12 +20,10 @@ public class DmpSyncingDatasourceReq implements Serializable {
* 数据源ID * 数据源ID
*/ */
@ApiModelProperty(value = "数据源ID") @ApiModelProperty(value = "数据源ID")
private String id; private String datasourceId;
/** /**
* 数据源类型ID * 数据源类型ID
*/ */
@NotNull(message = "数据源类型ID不能为空")
@NotEmpty(message = "数据源类型ID不能为空")
@ApiModelProperty(value = "数据源类型ID") @ApiModelProperty(value = "数据源类型ID")
private String datasourceType; private String datasourceType;
/** /**
...@@ -43,6 +41,8 @@ public class DmpSyncingDatasourceReq implements Serializable { ...@@ -43,6 +41,8 @@ public class DmpSyncingDatasourceReq implements Serializable {
/** /**
* JDBC URL * JDBC URL
*/ */
@NotNull(message = "JDBC URL不能为空")
@NotEmpty(message = "JDBC URL不能为空")
@ApiModelProperty(value = "JDBC URL") @ApiModelProperty(value = "JDBC URL")
private String jdbcUrl; private String jdbcUrl;
/** /**
...@@ -53,11 +53,15 @@ public class DmpSyncingDatasourceReq implements Serializable { ...@@ -53,11 +53,15 @@ public class DmpSyncingDatasourceReq implements Serializable {
/** /**
* 账号 * 账号
*/ */
@NotNull(message = "账号不能为空")
@NotEmpty(message = "账号不能为空")
@ApiModelProperty(value = "账号") @ApiModelProperty(value = "账号")
private String userName; private String userName;
/** /**
* 密码 * 密码
*/ */
@NotNull(message = "密码不能为空")
@NotEmpty(message = "密码不能为空")
@ApiModelProperty(value = "密码") @ApiModelProperty(value = "密码")
private String password; private String password;
/** /**
...@@ -109,8 +113,6 @@ public class DmpSyncingDatasourceReq implements Serializable { ...@@ -109,8 +113,6 @@ public class DmpSyncingDatasourceReq implements Serializable {
/** /**
* 项目ID * 项目ID
*/ */
@NotNull(message = "项目ID不能为空")
@NotEmpty(message = "项目ID不能为空")
@ApiModelProperty(value = "项目ID") @ApiModelProperty(value = "项目ID")
private String projectId; private String projectId;
...@@ -121,12 +123,12 @@ public class DmpSyncingDatasourceReq implements Serializable { ...@@ -121,12 +123,12 @@ public class DmpSyncingDatasourceReq implements Serializable {
@ApiModelProperty(value = "网络连接类型") @ApiModelProperty(value = "网络连接类型")
private String networkConnectionType; private String networkConnectionType;
public String getId() { public String getDatasourceId() {
return id; return datasourceId;
} }
public void setId(String id) { public void setDatasourceId(String datasourceId) {
this.id = id; this.datasourceId = datasourceId;
} }
public String getDatasourceType() { public String getDatasourceType() {
......
...@@ -97,7 +97,10 @@ public interface DmpSyncingDatasourceDao { ...@@ -97,7 +97,10 @@ public interface DmpSyncingDatasourceDao {
List<Map> queryGroupDatasourceType() throws Exception; List<Map> queryGroupDatasourceType() throws Exception;
int countDatasourceByName(@Param("datasourceName") String datasourceName, @Param("projectId") String projectId); int countDatasourceByName(@Param("datasourceName") String datasourceName, @Param("projectId") String projectId) throws Exception;
DmpSyncingDatasourceType queryDatasourceTypeById(@Param("datasourceTypeId") String datasourceTypeId) throws Exception;
DataSourceListDto selectDataSourceInfoById(Map map) throws Exception;
DmpSyncingDatasourceType queryDatasourceTypeById(@Param("datasourceTypeId") String datasourceTypeId);
} }
\ No newline at end of file
...@@ -10,6 +10,7 @@ import com.jz.dmp.modules.model.DmpSyncingDatasource; ...@@ -10,6 +10,7 @@ import com.jz.dmp.modules.model.DmpSyncingDatasource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 数据源配置(DmpSyncingDatasource)表服务接口 * 数据源配置(DmpSyncingDatasource)表服务接口
...@@ -71,4 +72,8 @@ public interface DmpSyncingDatasourceService { ...@@ -71,4 +72,8 @@ public interface DmpSyncingDatasourceService {
JsonResult addDatasourceInfo(DmpSyncingDatasourceReq saveBody) throws Exception; JsonResult addDatasourceInfo(DmpSyncingDatasourceReq saveBody) throws Exception;
JsonResult testConnection(DmpSyncingDatasourceReq saveBody) throws Exception; JsonResult testConnection(DmpSyncingDatasourceReq saveBody) throws Exception;
JsonResult selectDataSourceInfoById(Map map) throws Exception;
JsonResult updateDatasourceById(DmpSyncingDatasourceReq saveBody) throws Exception;
} }
\ No newline at end of file
...@@ -220,7 +220,44 @@ public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceServ ...@@ -220,7 +220,44 @@ public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceServ
} }
} }
private DmpAgentDatasourceInfo dsInfoDTO(DmpSyncingDatasourceReq body) { @Override
public JsonResult selectDataSourceInfoById(Map map) throws Exception {
DataSourceListDto asd = dmpSyncingDatasourceDao.selectDataSourceInfoById(map);
return new JsonResult(asd);
}
/**
* 编辑数据源
*
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public JsonResult updateDatasourceById(DmpSyncingDatasourceReq saveBody) throws Exception {
DmpSyncingDatasource dsd = new DmpSyncingDatasource();
BeanUtils.copyProperties(saveBody, dsd);
dsd.setUpdateTime(new Date());
if (StringUtils.isNotEmpty(saveBody.getDatasourceType())) {
dsd.setDatasourceType(Integer.valueOf(saveBody.getDatasourceType())); //数据源类型ID
}
if (StringUtils.isNotEmpty(saveBody.getProjectId())) {
dsd.setProjectId(Integer.valueOf(saveBody.getProjectId()));
}
if(StringUtils.isNotEmpty(saveBody.getDatasourceId())){ //数据源id
dsd.setId(Integer.valueOf(saveBody.getDatasourceId()));
}
dsd.setDataStatus("1");
int len = dmpSyncingDatasourceDao.update(dsd);
if (len > 0) {
return new JsonResult();
} else {
return new JsonResult(ResultCode.INTERNAL_SERVER_ERROR);
}
}
private DmpAgentDatasourceInfo dsInfoDTO(DmpSyncingDatasourceReq body) throws Exception {
//数据源类型ID去查询 //数据源类型ID去查询
DmpSyncingDatasourceType type = dmpSyncingDatasourceDao.queryDatasourceTypeById(body.getDatasourceType()); DmpSyncingDatasourceType type = dmpSyncingDatasourceDao.queryDatasourceTypeById(body.getDatasourceType());
DmpAgentDatasourceInfo ds = new DmpAgentDatasourceInfo(); DmpAgentDatasourceInfo ds = new DmpAgentDatasourceInfo();
......
...@@ -238,6 +238,9 @@ ...@@ -238,6 +238,9 @@
<if test="projectId != null"> <if test="projectId != null">
PROJECT_ID = #{projectId}, PROJECT_ID = #{projectId},
</if> </if>
<if test="networkConnectionType != null">
NETWORK_CONNECTION_TYPE = #{networkConnectionType},
</if>
</set> </set>
where ID = #{id} where ID = #{id}
</update> </update>
...@@ -325,4 +328,25 @@ ...@@ -325,4 +328,25 @@
where id=#{datasourceTypeId} where id=#{datasourceTypeId}
</select> </select>
<!--数据源列表查询-->
<select id="selectDataSourceInfoById" parameterType="map"
resultType="com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListDto">
select
b.datasource_catecode as datasourceCatecode,
b.datasource_type as datasourceTypeName,
a.datasource_name as datasourceName,
a.datasource_desc as datasourceDesc,
a.id as id,
a.datasource_type as datasourceTypeId,
a.jdbc_url as jdbcUrl,
a.db_name as dbName,
a.user_name as userName,
a.project_id as projectId
from dmp_syncing_datasource a
left join dmp_syncing_datasource_type b on a.datasource_type = b.id
where a.data_status = '1'
and a.id =#{datasourceId}
<if test="projectId != null and projectId !=''"> and a.project_id = #{projectId}</if>
</select>
</mapper> </mapper>
\ No newline at end of file
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