|
@@ -15,7 +15,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.eco.vip.ai.text2sql.domain.CommentVo;
|
|
|
import org.eco.vip.ai.text2sql.mapper.Text2SqlMapper;
|
|
|
import org.eco.vip.ai.text2sql.utils.SqlValidator;
|
|
|
-import org.eco.vip.orm.utils.DataBaseHelper;
|
|
|
+import org.eco.vip.orm.utils.DBaseHelper;
|
|
|
import org.eco.vip.text2sql.domain.ContentVo;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -50,9 +50,9 @@ public class Text2SqlService implements IText2SqlService {
|
|
|
|
|
|
@Override
|
|
|
public List<CommentVo> commentByTableName(String schema, String tableName) {
|
|
|
- if (DataBaseHelper.isMySql()) {
|
|
|
+ if (DBaseHelper.isMySql()) {
|
|
|
return text2SqlMapper.selectCommentsByMysql(schema, tableName);
|
|
|
- } else if (DataBaseHelper.isDmSql()) {
|
|
|
+ } else if (DBaseHelper.isDmSql()) {
|
|
|
return text2SqlMapper.selectCommentsByDm(schema, tableName);
|
|
|
}
|
|
|
return Collections.emptyList();
|
|
@@ -87,7 +87,7 @@ public class Text2SqlService implements IText2SqlService {
|
|
|
return new JSONArray().put("只支持查询");
|
|
|
}
|
|
|
List<Map<String, Object>> mapList = text2SqlMapper.executeSql(sql);
|
|
|
- List<CommentVo> tableNames = this.commentByTableName(DataBaseHelper.getSchema(), question.getTableName());
|
|
|
+ List<CommentVo> tableNames = this.commentByTableName(DBaseHelper.getSchema(), question.getTableName());
|
|
|
return this.getCommentData(mapList, tableNames);
|
|
|
}
|
|
|
|
|
@@ -95,16 +95,16 @@ public class Text2SqlService implements IText2SqlService {
|
|
|
public ContentVo getQuestion(String question) {
|
|
|
String tableName = this.tableNameByNl(question);
|
|
|
Map<String, String> map = Collections.emptyMap();
|
|
|
- if (DataBaseHelper.isMySql()) {
|
|
|
+ if (DBaseHelper.isMySql()) {
|
|
|
map = text2SqlMapper.selectTableDdlByMysql(tableName);
|
|
|
- } else if (DataBaseHelper.isDmSql()) {
|
|
|
- map = text2SqlMapper.selectTableDdlDm(DataBaseHelper.getSchema(), tableName);
|
|
|
+ } else if (DBaseHelper.isDmSql()) {
|
|
|
+ map = text2SqlMapper.selectTableDdlDm(DBaseHelper.getSchema(), tableName);
|
|
|
}
|
|
|
String ddl = map.get("create table");
|
|
|
- return ContentVo.builder().content(ddl + "\n" + question + ",根据需求生成Mysql的查询SQL.\n" +
|
|
|
+ return ContentVo.builder().content(ddl + "\n" + question + ",根据需求生成" + DBaseHelper.getDbType() + "的查询SQL.\n" +
|
|
|
"1.不要需求外的条件.\n" +
|
|
|
"2.只输出sql语句不需要任何格式样式,就是一串sql.\n" +
|
|
|
- "3.不需要带Schema:" + DataBaseHelper.getSchema()).
|
|
|
+ "3.不需要带Schema:" + DBaseHelper.getSchema()).
|
|
|
tableName(tableName).build();
|
|
|
|
|
|
}
|