Commit fef4fdb3 authored by mcb's avatar mcb

数据源 批量删除

parent 58d6a611
......@@ -10,13 +10,11 @@ import com.jz.dmp.modules.controller.DataIntegration.bean.DvRuleTDto;
import com.jz.dmp.modules.service.DmpSyncingDatasourceService;
import com.jz.dmp.modules.service.OfflineSynchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
......@@ -57,4 +55,20 @@ public class DataSourceController {
}
return pageInfo;
}
/**
* 批量删除数据源
*
* @return
*/
@ApiImplicitParam(name = "datasourceId", value = "数据源id")
@ApiOperation(value = "批量删除数据源", notes = "批量删除数据源")
@GetMapping(value = "/delDataSource")
public JsonResult delDataSource(@RequestParam String datasourceId, HttpServletRequest httpRequest) throws Exception {
if(StringUtils.isEmpty(datasourceId)){
return new JsonResult(ResultCode.PARAMS_ERROR);
}
JsonResult result = dmpSyncingDatasourceService.delDataSourceById(datasourceId);
return result;
}
}
......@@ -87,4 +87,6 @@ public interface DmpSyncingDatasourceDao {
* @param req
*/
List<DataSourceListDto> queryDataSourceListPage(DataSourceListReq req) throws Exception;
void delDataSourceById(@Param("ids") String[] ids) throws Exception;
}
\ No newline at end of file
package com.jz.dmp.modules.service;
import com.jz.common.constant.JsonResult;
import com.jz.common.page.PageInfoResponse;
import com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListReq;
......@@ -59,4 +60,6 @@ public interface DmpSyncingDatasourceService {
boolean deleteById(Integer id);
PageInfoResponse<DataSourceListDto> queryDataSourceListPage(DataSourceListReq req, HttpServletRequest httpRequest) throws Exception;
JsonResult delDataSourceById(String datasourceId) throws Exception;
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.jz.dmp.modules.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.common.page.PageInfoResponse;
import com.jz.dmp.modules.controller.DataIntegration.bean.DataSourceListDto;
......@@ -14,6 +15,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
......@@ -114,4 +116,17 @@ public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceServ
pageInfoResponse.setData(pageInfo);
return pageInfoResponse;
}
/**
* 批量删除数据源
*
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public JsonResult delDataSourceById(String datasourceId) throws Exception {
String[] ids = datasourceId.split(",");
dmpSyncingDatasourceDao.delDataSourceById(ids);
return new JsonResult();
}
}
\ No newline at end of file
......@@ -32,7 +32,7 @@
<select id="queryById" resultMap="DmpSyncingDatasourceMap">
select
ID, DATASOURCE_TYPE, DATASOURCE_NAME, DATASOURCE_DESC, JDBC_URL, DB_NAME, USER_NAME, PASSWORD, ENDPOINT, BUCKET, ACCESS_ID, ACCESS_KEY, PROTOCOL, HOST, PORT, DEFAULT_FS, TABLE_SCHEMA, DATA_STATUS, CREATE_USER_ID, CREATE_TIME, UPDATE_USER_ID, UPDATE_TIME, PROJECT_ID
from dmp_web.dmp_syncing_datasource
from dmp_syncing_datasource
where ID = #{id}
</select>
......@@ -40,7 +40,7 @@
<select id="queryAllByLimit" resultMap="DmpSyncingDatasourceMap">
select
ID, DATASOURCE_TYPE, DATASOURCE_NAME, DATASOURCE_DESC, JDBC_URL, DB_NAME, USER_NAME, PASSWORD, ENDPOINT, BUCKET, ACCESS_ID, ACCESS_KEY, PROTOCOL, HOST, PORT, DEFAULT_FS, TABLE_SCHEMA, DATA_STATUS, CREATE_USER_ID, CREATE_TIME, UPDATE_USER_ID, UPDATE_TIME, PROJECT_ID
from dmp_web.dmp_syncing_datasource
from dmp_syncing_datasource
limit #{offset}, #{limit}
</select>
......@@ -50,7 +50,7 @@
ID, DATASOURCE_TYPE, DATASOURCE_NAME, DATASOURCE_DESC, JDBC_URL, DB_NAME, USER_NAME, PASSWORD, ENDPOINT, BUCKET,
ACCESS_ID, ACCESS_KEY, PROTOCOL, HOST, PORT, DEFAULT_FS, TABLE_SCHEMA, DATA_STATUS, CREATE_USER_ID, CREATE_TIME,
UPDATE_USER_ID, UPDATE_TIME, PROJECT_ID
from dmp_web.dmp_syncing_datasource
from dmp_syncing_datasource
<where>
<if test="id != null">
and ID = #{id}
......@@ -126,12 +126,12 @@
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into dmp_web.dmp_syncing_datasource(DATASOURCE_TYPE, DATASOURCE_NAME, DATASOURCE_DESC, JDBC_URL, DB_NAME, USER_NAME, PASSWORD, ENDPOINT, BUCKET, ACCESS_ID, ACCESS_KEY, PROTOCOL, HOST, PORT, DEFAULT_FS, TABLE_SCHEMA, DATA_STATUS, CREATE_USER_ID, CREATE_TIME, UPDATE_USER_ID, UPDATE_TIME, PROJECT_ID)
insert into dmp_syncing_datasource(DATASOURCE_TYPE, DATASOURCE_NAME, DATASOURCE_DESC, JDBC_URL, DB_NAME, USER_NAME, PASSWORD, ENDPOINT, BUCKET, ACCESS_ID, ACCESS_KEY, PROTOCOL, HOST, PORT, DEFAULT_FS, TABLE_SCHEMA, DATA_STATUS, CREATE_USER_ID, CREATE_TIME, UPDATE_USER_ID, UPDATE_TIME, PROJECT_ID)
values (#{datasourceType}, #{datasourceName}, #{datasourceDesc}, #{jdbcUrl}, #{dbName}, #{userName}, #{password}, #{endpoint}, #{bucket}, #{accessId}, #{accessKey}, #{protocol}, #{host}, #{port}, #{defaultFs}, #{tableSchema}, #{dataStatus}, #{createUserId}, #{createTime}, #{updateUserId}, #{updateTime}, #{projectId})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into dmp_web.dmp_syncing_datasource(DATASOURCE_TYPE, DATASOURCE_NAME, DATASOURCE_DESC, JDBC_URL, DB_NAME,
insert into dmp_syncing_datasource(DATASOURCE_TYPE, DATASOURCE_NAME, DATASOURCE_DESC, JDBC_URL, DB_NAME,
USER_NAME, PASSWORD, ENDPOINT, BUCKET, ACCESS_ID, ACCESS_KEY, PROTOCOL, HOST, PORT, DEFAULT_FS, TABLE_SCHEMA,
DATA_STATUS, CREATE_USER_ID, CREATE_TIME, UPDATE_USER_ID, UPDATE_TIME, PROJECT_ID)
values
......@@ -145,7 +145,7 @@
</insert>
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into dmp_web.dmp_syncing_datasource(DATASOURCE_TYPE, DATASOURCE_NAME, DATASOURCE_DESC, JDBC_URL, DB_NAME,
insert into dmp_syncing_datasource(DATASOURCE_TYPE, DATASOURCE_NAME, DATASOURCE_DESC, JDBC_URL, DB_NAME,
USER_NAME, PASSWORD, ENDPOINT, BUCKET, ACCESS_ID, ACCESS_KEY, PROTOCOL, HOST, PORT, DEFAULT_FS, TABLE_SCHEMA,
DATA_STATUS, CREATE_USER_ID, CREATE_TIME, UPDATE_USER_ID, UPDATE_TIME, PROJECT_ID)
values
......@@ -168,7 +168,7 @@
<!--通过主键修改数据-->
<update id="update">
update dmp_web.dmp_syncing_datasource
update dmp_syncing_datasource
<set>
<if test="datasourceType != null">
DATASOURCE_TYPE = #{datasourceType},
......@@ -242,7 +242,7 @@
<!--通过主键删除-->
<delete id="deleteById">
delete from dmp_web.dmp_syncing_datasource where ID = #{id}
delete from dmp_syncing_datasource where ID = #{id}
</delete>
<!--数据源列表查询-->
......@@ -269,4 +269,13 @@
<if test="datasourceName != null and datasourceName !=''">and a.datasource_name like CONCAT('%',#{datasourceName},'%')</if>
</select>
<!--批量删除-->
<delete id="delDataSourceById" parameterType="map">
delete from dmp_syncing_datasource
where ID in
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
</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