feat(dataAccessServiceImpl,AccessServiceImpl)增加了同步和测试,完善了数据结构,重写字典
parent
8e2250f874
commit
596a557ca1
|
@ -3,9 +3,7 @@ package com.muyu.system.controller;
|
|||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.system.domain.ListStructure;
|
||||
import com.muyu.system.domain.TableList;
|
||||
import com.muyu.system.domain.TableName;
|
||||
import com.muyu.system.domain.*;
|
||||
import com.muyu.system.domain.vo.DeptVO;
|
||||
import com.muyu.system.domain.vo.SysUserVo;
|
||||
import com.muyu.system.domain.vo.TableVo;
|
||||
|
@ -35,7 +33,7 @@ public class AccreditController extends BaseController {
|
|||
* 获取表名
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("tableNameList")
|
||||
@PostMapping("/tableNameList")
|
||||
public Result<List<TableList>> tableNameList(){
|
||||
List<TableList> list = service.tableNameList();
|
||||
return Result.success(list);
|
||||
|
@ -45,7 +43,7 @@ public class AccreditController extends BaseController {
|
|||
* 获取表名
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("tableNameList2")
|
||||
@GetMapping("/tableNameList2")
|
||||
public Result<List<String>> tableNameList2() throws SQLException {
|
||||
List<String> list = service.tableNameList2();
|
||||
return Result.success(list);
|
||||
|
@ -56,17 +54,32 @@ public class AccreditController extends BaseController {
|
|||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
@GetMapping("listSqlJdbc")
|
||||
@GetMapping("/listSqlJdbc")
|
||||
public Result listSqlJdbc(@RequestParam String tableName) throws SQLException {
|
||||
return service.listSqlJdbc(tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据连接
|
||||
* @param dataAccess
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/selJDBCStream")
|
||||
public Result selJDBCStream(@RequestBody DataAccess dataAccess){
|
||||
Integer id = service.selJDBCStream(dataAccess);
|
||||
if (id>0){
|
||||
return success("连接成功");
|
||||
}else{
|
||||
return error("连接失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表详情
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("selectTableXml/{tableName}")
|
||||
@PostMapping("/selectTableXml/{tableName}")
|
||||
public Result<List<TableVo>> selectTableXml(@PathVariable String tableName){
|
||||
List<TableVo> list = service.selectTableXml(tableName);
|
||||
return Result.success(list);
|
||||
|
@ -124,4 +137,29 @@ public class AccreditController extends BaseController {
|
|||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/selectDictionaryMajor")
|
||||
public Result<List<DictionaryMajor>> selectDictionaryMajor(){
|
||||
List<DictionaryMajor> list = service.selectDictionaryMajor();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态/添加字典
|
||||
* @param listStructure
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/updateListStructure")
|
||||
public Result updateListStructure(@RequestBody ListStructure listStructure){
|
||||
Integer id = service.updateListStructure(listStructure);
|
||||
if (id>0){
|
||||
return success("修改完成");
|
||||
}else{
|
||||
return error("修改有异常请检查");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -101,4 +101,19 @@ public class DataAccessController extends BaseController
|
|||
{
|
||||
return toAjax(dataAccessService.deleteDataAccessByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步
|
||||
* @param dataAccess
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/synchronization")
|
||||
public Result synchronization(@RequestBody DataAccess dataAccess) throws SQLException {
|
||||
Integer id = dataAccessService.synchronization(dataAccess);
|
||||
if (id>0){
|
||||
return success("成功同步");
|
||||
}else{
|
||||
return error("同步失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.muyu.system.domain;
|
|||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class dictionaryMajor {
|
||||
public class DictionaryMajor {
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
|
@ -11,5 +11,5 @@ public class dictionaryMajor {
|
|||
/**
|
||||
* 展示
|
||||
*/
|
||||
private Integer dictionaryExpression;
|
||||
private String dictionaryExpression;
|
||||
}
|
|
@ -45,4 +45,12 @@ public class ListStructure {
|
|||
* 注解
|
||||
*/
|
||||
private String columnComments;
|
||||
/**
|
||||
* 是否字典
|
||||
*/
|
||||
private String yesOrNo;
|
||||
/**
|
||||
* 对应字典
|
||||
*/
|
||||
private String dictionary;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package com.muyu.system.mapper;
|
||||
|
||||
import com.muyu.system.domain.Library;
|
||||
import com.muyu.system.domain.ListStructure;
|
||||
import com.muyu.system.domain.TableList;
|
||||
import com.muyu.system.domain.TableName;
|
||||
import com.muyu.system.domain.*;
|
||||
import com.muyu.system.domain.vo.TableVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
@ -37,4 +34,9 @@ public interface AccreditMapper {
|
|||
int selectOneTableList(@Param("s") String s);
|
||||
|
||||
int selectOneSqlJdbc(@Param("s") String s);
|
||||
|
||||
List<DictionaryMajor> selectDictionaryMajor();
|
||||
|
||||
Integer updateListStructure(ListStructure listStructure);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package com.muyu.system.service;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.system.domain.Library;
|
||||
import com.muyu.system.domain.ListStructure;
|
||||
import com.muyu.system.domain.TableList;
|
||||
import com.muyu.system.domain.TableName;
|
||||
import com.muyu.system.domain.*;
|
||||
import com.muyu.system.domain.vo.TableVo;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
@ -24,4 +21,10 @@ public interface AccreditService {
|
|||
TableList selNameTableList(String name);
|
||||
|
||||
List<ListStructure> selNameListStructure(String tableName);
|
||||
|
||||
List<DictionaryMajor> selectDictionaryMajor();
|
||||
|
||||
Integer updateListStructure(ListStructure listStructure);
|
||||
|
||||
Integer selJDBCStream(DataAccess dataAccess);
|
||||
}
|
||||
|
|
|
@ -59,4 +59,6 @@ public interface IDataAccessService
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteDataAccessById(Long id);
|
||||
|
||||
Integer synchronization(DataAccess dataAccess) throws SQLException;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package com.muyu.system.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.system.domain.Library;
|
||||
import com.muyu.system.domain.ListStructure;
|
||||
import com.muyu.system.domain.TableList;
|
||||
import com.muyu.system.domain.TableName;
|
||||
import com.muyu.system.domain.*;
|
||||
import com.muyu.system.domain.vo.TableVo;
|
||||
import com.muyu.system.mapper.AccreditMapper;
|
||||
import com.muyu.system.service.AccreditService;
|
||||
|
@ -133,6 +131,46 @@ public class AccreditServiceImpl implements AccreditService {
|
|||
return mapper.selNameListStructure(tableName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictionaryMajor> selectDictionaryMajor() {
|
||||
return mapper.selectDictionaryMajor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updateListStructure(ListStructure listStructure) {
|
||||
//判断是否加入字典
|
||||
if (!listStructure.getYesOrNo().equals("Y")){
|
||||
listStructure.setDictionary(null);
|
||||
}
|
||||
//修改状态
|
||||
Integer i = mapper.updateListStructure(listStructure);
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer selJDBCStream(DataAccess dataAccess) {
|
||||
Integer id = 0;
|
||||
try {
|
||||
//加载数据库驱动
|
||||
Class<?> aClass = Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
Driver driver = (Driver) aClass.newInstance();
|
||||
System.out.println(driver);
|
||||
//获取数据库连接
|
||||
Connection connection = DriverManager.getConnection("jdbc:mysql://129.211.23.219:3306/"+ dataAccess.getDatabaseName() +"?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8","root","Qq4152637");
|
||||
System.out.println(connection);
|
||||
id = 1;
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InstantiationException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
//获取字段注解
|
||||
private Map<String,String> getColumnComments(DatabaseMetaData metaData,String typeName){
|
||||
Map<String,String> columnComents = new HashMap<>();
|
||||
|
|
|
@ -62,13 +62,6 @@ public class DataAccessServiceImpl implements IDataAccessService
|
|||
@Override
|
||||
public int insertDataAccess(DataAccess dataAccess) throws SQLException {
|
||||
int i = dataAccessMapper.insertDataAccess(dataAccess);
|
||||
List<SysDept> list = sysDeptMapper.listDeptList();
|
||||
DataAccess dataAccess1 = dataAccessMapper.oneDataAccess();
|
||||
for (SysDept sysDept : list) {
|
||||
//添加中间件
|
||||
dataAccessMapper.insertMiddle(sysDept.getDeptId(),dataAccess1.getId());
|
||||
}
|
||||
accreditService.tableNameList2();
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -107,4 +100,23 @@ public class DataAccessServiceImpl implements IDataAccessService
|
|||
{
|
||||
return dataAccessMapper.deleteDataAccessById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer synchronization(DataAccess dataAccess) throws SQLException {
|
||||
Integer id = 0;
|
||||
/**
|
||||
* 获取所有的部门
|
||||
*/
|
||||
List<SysDept> list = sysDeptMapper.listDeptList();
|
||||
for (SysDept sysDept : list) {
|
||||
//添加中间件
|
||||
dataAccessMapper.insertMiddle(sysDept.getDeptId(),dataAccess.getId());
|
||||
}
|
||||
/**
|
||||
* 添加表名
|
||||
*/
|
||||
accreditService.tableNameList2();
|
||||
id = 1;
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
insert into tableList (name)
|
||||
values (#{s});
|
||||
</insert>
|
||||
<update id="updateListStructure">
|
||||
update list_structure
|
||||
set yes_or_no = #{yesOrNo},
|
||||
dictionary = #{dictionary}
|
||||
where catalog_name = #{catalogName} and
|
||||
table_name = #{tableName} and
|
||||
column_lass_name = #{columnLassName} and
|
||||
column_type_name = #{columnTypeName} and
|
||||
column_name = #{columnName} and
|
||||
precisions = #{precisions} and
|
||||
scale = #{scale} and
|
||||
is_null = #{isNull} and
|
||||
schema_name = #{schemaName} and
|
||||
column_comments = #{columnComments}
|
||||
</update>
|
||||
<select id="selectTableXml" resultType="com.muyu.system.domain.vo.TableVo">
|
||||
SELECT *
|
||||
FROM information_schema.columns
|
||||
|
@ -59,5 +74,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select count(table_name)
|
||||
from list_structure where table_name = #{s};
|
||||
</select>
|
||||
<select id="selectDictionaryMajor" resultType="com.muyu.system.domain.DictionaryMajor">
|
||||
select *
|
||||
from dictionary_major
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue