重构项目2
parent
178789b3e6
commit
c61947614a
|
@ -12,6 +12,7 @@ import com.muyu.etl.service.BasicConfigInfoService;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -48,9 +49,16 @@ public class BasicConfigInfoController extends BaseController {
|
|||
@RequiresPermissions("etl:info:export")
|
||||
@Log(title = "基础信息",businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
//数据接入到basicConfigInfo
|
||||
public void export(HttpServletResponse response,BasicConfigInfo basicConfigInfo){
|
||||
|
||||
//数据接入后查询列表
|
||||
List<BasicConfigInfo> list = service.selectBasicConfigInfoList(basicConfigInfo);
|
||||
|
||||
//new一个excelUtil 接入到basicConfigInfo
|
||||
ExcelUtil<BasicConfigInfo> util = new ExcelUtil<>(BasicConfigInfo.class);
|
||||
|
||||
//可以导出到表单
|
||||
util.exportExcel(response,list,"基础信息数据");
|
||||
}
|
||||
|
||||
|
@ -59,10 +67,55 @@ public class BasicConfigInfoController extends BaseController {
|
|||
*/
|
||||
@RequiresPermissions("etl:info:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
//响应信息主体
|
||||
public Result getInfo(@PathVariable("id") Long id){
|
||||
//返回成功消息
|
||||
return success(service.selectBasicConfigInfoById(id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增基础信息
|
||||
*/
|
||||
@RequiresPermissions("etl:info:add")
|
||||
@Log(title = "基础信息",businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
//数据接入到basicConfigInfo
|
||||
public Result add(@RequestBody BasicConfigInfo configQueryReq){
|
||||
//响应返回结果
|
||||
return toAjax(service.insertBasicConfigInfo(configQueryReq));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改基础信息
|
||||
*/
|
||||
@RequiresPermissions("etl:info:edit")
|
||||
@Log(title = "基础信息",businessType = BusinessType.UPDATE)
|
||||
@PostMapping
|
||||
//数据接入basicConfigInfo
|
||||
public Result edit(@RequestBody BasicConfigInfo configQueryReq){
|
||||
//响应返回结果
|
||||
return toAjax(service.updateBasicConfigInfo(configQueryReq));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除基础信息
|
||||
*/
|
||||
@RequiresPermissions("etl:info:remove")
|
||||
@Log(title = "基础信息",businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public Result remove(@PathVariable Long[] ids){
|
||||
return toAjax(service.deleteBasicConfigInfoByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
@RequiresPermissions("etl:info:test")
|
||||
@Log(title = "测试连接")
|
||||
@PostMapping("/connectionTest")
|
||||
public Result connectionTest(@RequestBody BasicConfigInfo basicConfigInfo) throws ServletException {
|
||||
return toAjax(service.connectionTest(basicConfigInfo));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,11 @@ public interface BasicConfigInfoMapper extends BaseMapper<BasicConfigInfo> {
|
|||
* @param id
|
||||
* @return
|
||||
*/
|
||||
String selectBasicConfigInfoById(Long id);
|
||||
BasicConfigInfo selectBasicConfigInfoById(Long id);
|
||||
|
||||
int insertBasicConfigInfo(BasicConfigInfo configQueryReq);
|
||||
|
||||
int updateBasicConfigInfo(BasicConfigInfo configQueryReq);
|
||||
|
||||
int deleteBasicConfigInfoByIds(Long[] ids);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.muyu.etl.service;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.etl.domain.BasicConfigInfo;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.sql.rowset.serial.SerialException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -20,5 +22,14 @@ public interface BasicConfigInfoService extends IService<BasicConfigInfo> {
|
|||
*/
|
||||
List<BasicConfigInfo> selectBasicConfigInfoList(BasicConfigInfo basicConfigInfo);
|
||||
|
||||
String selectBasicConfigInfoById(Long id);
|
||||
BasicConfigInfo selectBasicConfigInfoById(Long id);
|
||||
|
||||
int insertBasicConfigInfo(BasicConfigInfo configQueryReq);
|
||||
|
||||
int updateBasicConfigInfo(BasicConfigInfo configQueryReq);
|
||||
|
||||
int deleteBasicConfigInfoByIds(Long[] ids);
|
||||
|
||||
boolean connectionTest(BasicConfigInfo basicConfigInfo) throws ServletException;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,13 +1,21 @@
|
|||
package com.muyu.etl.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.etl.domain.BasicConfigInfo;
|
||||
import com.muyu.etl.mapper.BasicConfigInfoMapper;
|
||||
import com.muyu.etl.service.BasicConfigInfoService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import net.sf.jsqlparser.schema.Table;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.sql.rowset.serial.SerialException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -37,7 +45,60 @@ public class BasicConfigInfoServiceImpl extends ServiceImpl<BasicConfigInfoMappe
|
|||
|
||||
|
||||
@Override
|
||||
public String selectBasicConfigInfoById(Long id) {
|
||||
public BasicConfigInfo selectBasicConfigInfoById(Long id) {
|
||||
return basicConfigInfoMapper.selectBasicConfigInfoById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertBasicConfigInfo(BasicConfigInfo configQueryReq) {
|
||||
return basicConfigInfoMapper.insertBasicConfigInfo(configQueryReq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateBasicConfigInfo(BasicConfigInfo configQueryReq) {
|
||||
return basicConfigInfoMapper.updateBasicConfigInfo(configQueryReq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteBasicConfigInfoByIds(Long[] ids) {
|
||||
return basicConfigInfoMapper.deleteBasicConfigInfoByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试练级并同步
|
||||
* @param basicConfigInfo
|
||||
* @return
|
||||
* @throws SerialException
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean connectionTest(BasicConfigInfo basicConfigInfo) throws ServletException {
|
||||
|
||||
//定义下面需要的对象
|
||||
String host = basicConfigInfo.getHost();
|
||||
String port = basicConfigInfo.getPort();
|
||||
String databaseName = basicConfigInfo.getDatabaseName();
|
||||
String databaseType = basicConfigInfo.getDatabaseType();
|
||||
String url = "jdbc:" + databaseType + "://" + host + ":" + port + "/" + databaseName + "?" + basicConfigInfo.getConnectionParams();
|
||||
String user = basicConfigInfo.getUsername();
|
||||
String password = basicConfigInfo.getPassword();
|
||||
Connection conn = null;
|
||||
|
||||
try {
|
||||
conn = DriverManager.getConnection(url,user,password);
|
||||
System.out.println("Connected to the MySQL server successfully.");
|
||||
|
||||
//同步数据库信息
|
||||
//树级结构 库 表
|
||||
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
select id, data_resource_name,username,password, data_sources_system_name, host, port, database_type, database_name, init_link_num, max_link_num, max_wait_time, max_wait_times,connection_params, remark from basic_config_info
|
||||
</sql>
|
||||
|
||||
|
||||
<select id="selectBasicConfigInfoList" parameterType="com.muyu.etl.domain.BasicConfigInfo" resultMap="BasicConfigInfoResult">
|
||||
<include refid="selectBasicConfigInfoVo"/>
|
||||
<where>
|
||||
|
@ -32,4 +33,77 @@
|
|||
</select>
|
||||
|
||||
|
||||
|
||||
<insert id="insertBasicConfigInfo" parameterType="com.muyu.etl.domain.BasicConfigInfo">
|
||||
insert into basic_config_info
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="dataResourceName != null">data_resource_name,</if>
|
||||
<if test="dataSourcesSystemName != null">data_sources_system_name,</if>
|
||||
<if test="host != null">host,</if>
|
||||
<if test="port != null">port,</if>
|
||||
<if test="databaseType != null">database_type,</if>
|
||||
<if test="databaseName != null">database_name,</if>
|
||||
<if test="username != null">username,</if>
|
||||
<if test="password != null">password</if>
|
||||
<if test="initeLinkNum != null">init_link_num,</if>
|
||||
<if test="maxLinkNum != null">max_link_num,</if>
|
||||
<if test="maxWaitTime != null">max_wait_time,</if>
|
||||
<if test="maxWaitTimes != null">max_wait_times,</if>
|
||||
<if test="connextionParams != null">connection_params,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id !=null">#{id},</if>
|
||||
<if test="dataResourceName != null">#{dataResourceName},</if>
|
||||
<if test="dataSourcesSystemName !=null">#{dataSourcesSystemName},</if>
|
||||
<if test="host != null">#{host},</if>
|
||||
<if test="port != null">#{port},</if>
|
||||
<if test="databaseType != null">#{databaseType},</if>
|
||||
<if test="databaseName != null">#{databaseName},</if>
|
||||
<if test="username != null">#{username},</if>
|
||||
<if test="password != null">#{password},</if>
|
||||
<if test="initLinkNum != null">#{initLinkNum},</if>
|
||||
<if test="maxLinkNum != null">#{maxLinkNum},</if>
|
||||
<if test="maxWaitTime != null">#{maxWaitTime},</if>
|
||||
<if test="maxWaitTimes != null">#{maxWaitTimes},</if>
|
||||
<if test="connectionParams != null">#{connectionParams},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
|
||||
</insert>
|
||||
|
||||
|
||||
<update id="updateBasicConfigInfo" parameterType="com.muyu.etl.domain.BasicConfigInfo">
|
||||
update basic_config_info
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="dataResourceName !=null">data_resource_name = #{dataResourceName},</if>
|
||||
<if test="dataSourcesSystemName != null">data_sources_system_name = #{dataSourcesSystemName},</if>
|
||||
<if test="host != null">host = #{host},</if>
|
||||
<if test="port != null">port =#{port},</if>
|
||||
<if test="databaseType != null">database_type = #{databaseType},</if>
|
||||
<if test="databaseName != null">database_name =#{databaseName},</if>
|
||||
<if test="username != null">username =#{username},</if>
|
||||
<if test="password != null">password = #{password},</if>
|
||||
<if test="initLinkNum != null">init_link_num = #{initLinkNum},</if>
|
||||
<if test="maxLinkNum != null">max_link_num = #{maxLinkNum},</if>
|
||||
<if test="maxWaitTime != null">max_wait_time=#{maxWaitTime},</if>
|
||||
<if test="maxWaitTimes != null">max_wait_times = #{maxWaitTimes},</if>
|
||||
<if test="connectionParams != null">connection_params = #{connectionParams},</if>
|
||||
<if test="remark != null">remark =#{remark},</if>
|
||||
|
||||
</trim>
|
||||
where id = #{id}
|
||||
|
||||
</update>
|
||||
|
||||
|
||||
<delete id="deleteBasicConfigInfoByIds" parameterType="String">
|
||||
delete from basic_config_info where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue