fix:修复了删除异常的bug
parent
72caf426a7
commit
0324d7c70d
|
@ -0,0 +1,52 @@
|
||||||
|
|
||||||
|
package com.bwie.goods.service.impl;
|
||||||
|
|
||||||
|
import com.bwie.common.domain.One;
|
||||||
|
import com.bwie.goods.mapper.GoodsMapper;
|
||||||
|
import com.bwie.goods.service.GoodsService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GoodsServiceImpl implements GoodsService {
|
||||||
|
@Autowired
|
||||||
|
private GoodsMapper mapper;
|
||||||
|
@Override
|
||||||
|
public List<One> list() throws Exception {
|
||||||
|
HashMap<String, Map<String, String>> hm = new HashMap<>();
|
||||||
|
Map<String,String> map = new HashMap<>();
|
||||||
|
List<String> listString = new ArrayList<>();
|
||||||
|
List<String> listMap = new ArrayList<>();
|
||||||
|
PreparedStatement pst = null;
|
||||||
|
Connection connection = null;
|
||||||
|
connection = DriverManager.getConnection("jdbc:mysql://129.211.23.219:3306/g63d15?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8","root","Qq4152637");
|
||||||
|
List<One> list = mapper.list();
|
||||||
|
try {
|
||||||
|
pst = connection.prepareCall("select * from one");
|
||||||
|
ResultSetMetaData rsd = pst.executeQuery().getMetaData();
|
||||||
|
for (int i = 0; i < rsd.getColumnCount(); i++) {
|
||||||
|
System.out.println("java类型"+rsd.getColumnClassName(i+1));
|
||||||
|
System.out.println("数据库类型"+rsd.getColumnTypeName(i+1));
|
||||||
|
System.out.println("字段名称"+rsd.getColumnName(i+1));
|
||||||
|
System.out.println("表名"+rsd.getTableName(i+1));
|
||||||
|
System.out.println("数据库名"+rsd.getCatalogName(i+1));
|
||||||
|
listString.add(rsd.getColumnName(i+1));
|
||||||
|
listMap.add(rsd.getColumnClassName(i+1));
|
||||||
|
// System.out.println(""+rsd.getSchemaName(i+1));
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
System.out.println(listString);
|
||||||
|
System.out.println(listMap);
|
||||||
|
for (One one : list) {
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,6 +14,7 @@ import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -32,7 +33,7 @@ public class AccreditController extends BaseController {
|
||||||
* 获取表名
|
* 获取表名
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("tableNameList")
|
@PostMapping("tableNameList")
|
||||||
public Result<List<TableName>> tableNameList(){
|
public Result<List<TableName>> tableNameList(){
|
||||||
List<TableName> list = service.tableNameList();
|
List<TableName> list = service.tableNameList();
|
||||||
return Result.success(list);
|
return Result.success(list);
|
||||||
|
@ -49,7 +50,7 @@ public class AccreditController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("listSqlJdbc")
|
@GetMapping("listSqlJdbc")
|
||||||
public Result listSqlJdbc(){
|
public Result listSqlJdbc() throws SQLException {
|
||||||
return service.listSqlJdbc();
|
return service.listSqlJdbc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.system.controller;
|
package com.muyu.system.controller;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -75,8 +76,7 @@ public class DataAccessController extends BaseController
|
||||||
@RequiresPermissions("system:access:add")
|
@RequiresPermissions("system:access:add")
|
||||||
@Log(title = "数据接入", businessType = BusinessType.INSERT)
|
@Log(title = "数据接入", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public Result add(@RequestBody DataAccess dataAccess)
|
public Result add(@RequestBody DataAccess dataAccess) throws SQLException {
|
||||||
{
|
|
||||||
return toAjax(dataAccessService.insertDataAccess(dataAccess));
|
return toAjax(dataAccessService.insertDataAccess(dataAccess));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,4 +20,7 @@ public interface AccreditMapper {
|
||||||
int getNameSelTable(@Param("s") String s);
|
int getNameSelTable(@Param("s") String s);
|
||||||
|
|
||||||
void indexTableName(@Param("s") String s);
|
void indexTableName(@Param("s") String s);
|
||||||
|
|
||||||
|
void indexListStructure(@Param("columnClassName") String columnClassName, @Param("columnTypeName") String columnTypeName, @Param("columnName") String columnName, @Param("tableName") String tableName, @Param("catalogName") String catalogName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.muyu.system.domain.Library;
|
||||||
import com.muyu.system.domain.TableName;
|
import com.muyu.system.domain.TableName;
|
||||||
import com.muyu.system.domain.vo.TableVo;
|
import com.muyu.system.domain.vo.TableVo;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface AccreditService {
|
public interface AccreditService {
|
||||||
|
@ -14,5 +15,5 @@ public interface AccreditService {
|
||||||
|
|
||||||
List<String> tableNameList2();
|
List<String> tableNameList2();
|
||||||
|
|
||||||
Result listSqlJdbc();
|
Result listSqlJdbc() throws SQLException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
package com.muyu.system.service;
|
package com.muyu.system.service;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.muyu.system.domain.DataAccess;
|
import com.muyu.system.domain.DataAccess;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据接入Service接口
|
* 数据接入Service接口
|
||||||
*
|
*
|
||||||
* @author muyu
|
* @author muyu
|
||||||
* @date 2024-04-21
|
* @date 2024-04-21
|
||||||
*/
|
*/
|
||||||
public interface IDataAccessService
|
public interface IDataAccessService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 查询数据接入
|
* 查询数据接入
|
||||||
*
|
*
|
||||||
* @param id 数据接入主键
|
* @param id 数据接入主键
|
||||||
* @return 数据接入
|
* @return 数据接入
|
||||||
*/
|
*/
|
||||||
|
@ -21,7 +22,7 @@ public interface IDataAccessService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询数据接入列表
|
* 查询数据接入列表
|
||||||
*
|
*
|
||||||
* @param dataAccess 数据接入
|
* @param dataAccess 数据接入
|
||||||
* @return 数据接入集合
|
* @return 数据接入集合
|
||||||
*/
|
*/
|
||||||
|
@ -29,15 +30,15 @@ public interface IDataAccessService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增数据接入
|
* 新增数据接入
|
||||||
*
|
*
|
||||||
* @param dataAccess 数据接入
|
* @param dataAccess 数据接入
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int insertDataAccess(DataAccess dataAccess);
|
public int insertDataAccess(DataAccess dataAccess) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改数据接入
|
* 修改数据接入
|
||||||
*
|
*
|
||||||
* @param dataAccess 数据接入
|
* @param dataAccess 数据接入
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
@ -45,7 +46,7 @@ public interface IDataAccessService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除数据接入
|
* 批量删除数据接入
|
||||||
*
|
*
|
||||||
* @param ids 需要删除的数据接入主键集合
|
* @param ids 需要删除的数据接入主键集合
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
@ -53,7 +54,7 @@ public interface IDataAccessService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除数据接入信息
|
* 删除数据接入信息
|
||||||
*
|
*
|
||||||
* @param id 数据接入主键
|
* @param id 数据接入主键
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -9,6 +9,7 @@ import com.muyu.system.service.AccreditService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -43,8 +44,25 @@ public class AccreditServiceImpl implements AccreditService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result listSqlJdbc() {
|
public Result listSqlJdbc() throws SQLException {
|
||||||
|
PreparedStatement pst = null;
|
||||||
return null;
|
Connection conn = null;
|
||||||
|
String database = mapper.database();
|
||||||
|
conn = DriverManager.getConnection("jdbc:mysql://129.211.23.219:3306/"+ database +"?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8","root","Qq4152637");
|
||||||
|
try {
|
||||||
|
pst = conn.prepareCall("select * from admin");
|
||||||
|
ResultSetMetaData rsd = pst.executeQuery().getMetaData();
|
||||||
|
for (int i = 0; i < rsd.getColumnCount(); i++) {
|
||||||
|
System.out.println("java类型"+rsd.getColumnClassName(i+1));
|
||||||
|
System.out.println("数据库类型"+rsd.getColumnTypeName(i+1));
|
||||||
|
System.out.println("字段名称"+rsd.getColumnName(i+1));
|
||||||
|
System.out.println("表名"+rsd.getTableName(i+1));
|
||||||
|
System.out.println("数据库名"+rsd.getCatalogName(i+1));
|
||||||
|
mapper.indexListStructure(rsd.getColumnClassName(i+1),rsd.getColumnTypeName(i+1),rsd.getColumnName(i+1),rsd.getTableName(i+1),rsd.getCatalogName(i+1));
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return Result.success("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package com.muyu.system.service.impl;
|
package com.muyu.system.service.impl;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.muyu.common.system.domain.SysDept;
|
import com.muyu.common.system.domain.SysDept;
|
||||||
|
import com.muyu.system.mapper.AccreditMapper;
|
||||||
import com.muyu.system.mapper.SysDeptMapper;
|
import com.muyu.system.mapper.SysDeptMapper;
|
||||||
|
import com.muyu.system.service.AccreditService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.muyu.system.mapper.DataAccessMapper;
|
import com.muyu.system.mapper.DataAccessMapper;
|
||||||
|
@ -23,6 +26,8 @@ public class DataAccessServiceImpl implements IDataAccessService
|
||||||
private DataAccessMapper dataAccessMapper;
|
private DataAccessMapper dataAccessMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysDeptMapper sysDeptMapper;
|
private SysDeptMapper sysDeptMapper;
|
||||||
|
@Autowired
|
||||||
|
private AccreditService accreditService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询数据接入
|
* 查询数据接入
|
||||||
|
@ -55,14 +60,14 @@ public class DataAccessServiceImpl implements IDataAccessService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertDataAccess(DataAccess dataAccess)
|
public int insertDataAccess(DataAccess dataAccess) throws SQLException {
|
||||||
{
|
|
||||||
int i = dataAccessMapper.insertDataAccess(dataAccess);
|
int i = dataAccessMapper.insertDataAccess(dataAccess);
|
||||||
List<SysDept> list = sysDeptMapper.listDeptList();
|
List<SysDept> list = sysDeptMapper.listDeptList();
|
||||||
DataAccess dataAccess1 = dataAccessMapper.oneDataAccess();
|
DataAccess dataAccess1 = dataAccessMapper.oneDataAccess();
|
||||||
for (SysDept sysDept : list) {
|
for (SysDept sysDept : list) {
|
||||||
dataAccessMapper.insertMiddle(sysDept.getDeptId(),dataAccess1.getId());
|
dataAccessMapper.insertMiddle(sysDept.getDeptId(),dataAccess1.getId());
|
||||||
}
|
}
|
||||||
|
accreditService.listSqlJdbc();
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
insert into table_name (table_name)
|
insert into table_name (table_name)
|
||||||
values (#{s});
|
values (#{s});
|
||||||
</insert>
|
</insert>
|
||||||
|
<insert id="indexListStructure">
|
||||||
|
insert into list_structure (column_lass_ame,column_type_name,column_name,table_name,catalog_name)
|
||||||
|
values (#{columnClassName},#{columnTypeName},#{columnName},#{tableName},#{catalogName});
|
||||||
|
</insert>
|
||||||
<select id="tableNameList" resultType="com.muyu.system.domain.TableName">
|
<select id="tableNameList" resultType="com.muyu.system.domain.TableName">
|
||||||
select *
|
select *
|
||||||
from table_name
|
from table_name
|
||||||
|
|
Loading…
Reference in New Issue