Add method for refresh table and schema

dev
floxx2112 2 years ago
parent 42085b6439
commit dd8ec9d844
  1. 5
      src/main/java/com/apside/assistDbBackend/controller/InfoTableController.java
  2. 6
      src/main/java/com/apside/assistDbBackend/repository/InfoTableRepository.java
  3. 4
      src/main/java/com/apside/assistDbBackend/service/InfoTableService.java
  4. 3
      src/main/java/com/apside/assistDbBackend/service/ResetDataService.java
  5. 5
      src/main/resources/assistDbData.json
  6. 1
      src/main/resources/pcgp.json

@ -56,6 +56,11 @@ public class InfoTableController {
return infoTableService.getTablesBySchemaName(schema);
}
@GetMapping("/schemas/{table}")
public Iterable<InfoTable> getSchemaByTableName(@PathVariable("table") final String table) {
return infoTableService.getSchemaByTableName(table);
}
@DeleteMapping("/tables/deleteAll")
public void deleteAllTables() {
infoTableService.deleteAllTable();

@ -20,6 +20,12 @@ public interface InfoTableRepository extends CrudRepository<InfoTable, Long> {
nativeQuery = true)
Iterable<InfoTable> getTablesBySchemaName(@Param("schema") String schema);
@Query(
value = "SELECT * FROM informations_table WHERE name_table=:table",
nativeQuery = true)
Iterable<InfoTable> getSchemaByTableName(@Param("table") String table);
@Modifying
@Transactional
@Query(value = "TRUNCATE TABLE informations_table", nativeQuery = true)

@ -26,6 +26,10 @@ public class InfoTableService {
return infoTableRepository.getTablesBySchemaName(schema);
}
public Iterable<InfoTable> getSchemaByTableName(String table) {
return infoTableRepository.getSchemaByTableName(table);
}
public Iterable<String> getAllSchemas(){return infoTableRepository.getAllSchemas();}
public void deleteTable(final Long id) {
infoTableRepository.deleteById(id);

@ -31,6 +31,7 @@ public class ResetDataService {
}
public void insertEverything() throws IOException {
int hopli = 0;
String result = new String(Files.readAllBytes(Paths.get("src/main/resources/assistDbData.json")));
JSONArray jo = new JSONArray(result);
System.out.println("ca marche");
@ -96,9 +97,11 @@ public class ResetDataService {
if(findCol == null){
infoColumnService.addOrUpdateColumn(infoColumn);
}
hopli++;
}
}
}
System.out.println(hopli);
}

@ -2206,6 +2206,11 @@
"name": "SRCDTA",
"data_type": "CHAR",
"length": 80
},
{
"name": "HOPLA",
"data_type": "CHAR",
"length": 8
}
],
"table_text": "",

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save