mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-11-29 18:48:23 +08:00
[Client] [Cli] Support data source info
This commit is contained in:
parent
f463b99445
commit
34541b3d52
1
.gitignore
vendored
1
.gitignore
vendored
@ -40,3 +40,4 @@ tmp/
|
||||
# vscode #
|
||||
.vscode
|
||||
dist/datacap/
|
||||
list
|
||||
|
@ -65,6 +65,35 @@
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>${assembly-plugin.version}</version>
|
||||
<configuration>
|
||||
<finalName>datacap-cli</finalName>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>io.edurt.datacap.client.cli.DataCapCli</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<!-- <descriptorRefs>-->
|
||||
<!-- <descriptorRef>jar-with-dependencies</descriptorRef>-->
|
||||
<!-- </descriptorRefs>-->
|
||||
<descriptors>
|
||||
<descriptor>../../configure/assembly/assembly-cli.xml</descriptor>
|
||||
</descriptors>
|
||||
<appendAssemblyId>false</appendAssemblyId>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
@ -13,6 +13,7 @@ public class DataCapCli
|
||||
SpringApplication application = new SpringApplication(DataCapCli.class);
|
||||
application.setBannerMode(Banner.Mode.OFF);
|
||||
application.setWebApplicationType(WebApplicationType.NONE);
|
||||
application.setLogStartupInfo(false);
|
||||
application.run(args);
|
||||
}
|
||||
|
||||
|
@ -5,4 +5,6 @@ import org.springframework.shell.table.Table;
|
||||
public interface DataSourceService
|
||||
{
|
||||
Table showList();
|
||||
|
||||
Table getInfo();
|
||||
}
|
||||
|
@ -13,9 +13,12 @@ import org.springframework.shell.table.TableModel;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static java.lang.Math.toIntExact;
|
||||
|
||||
@Service
|
||||
public class DataSourceServiceImpl
|
||||
implements DataSourceService
|
||||
@ -57,4 +60,28 @@ public class DataSourceServiceImpl
|
||||
TableUtils.applyStyle(tableBuilder);
|
||||
return tableBuilder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Table getInfo()
|
||||
{
|
||||
HttpConfigure configure = this.cacheService.getConfigure();
|
||||
configure.setUrl(url + "/" + configure.getSourceId());
|
||||
HttpCommon httpCommon = new HttpCommon(configure);
|
||||
ServerResponse serverResponse = httpCommon.withTokenForGet();
|
||||
LinkedTreeMap<String, Object> map = (LinkedTreeMap) serverResponse.getData();
|
||||
LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
||||
headers.put("id", "Id");
|
||||
headers.put("name", "Name");
|
||||
headers.put("type", "Type");
|
||||
headers.put("description", "Description");
|
||||
DataSource dataSource = new DataSource();
|
||||
dataSource.setId(toIntExact(configure.getSourceId()));
|
||||
dataSource.setName(String.valueOf(map.get("name")));
|
||||
dataSource.setType(String.valueOf(map.get("type")));
|
||||
dataSource.setDescription(String.valueOf(map.get("description")));
|
||||
TableModel model = new BeanListTableModel<>(Collections.singleton(dataSource), headers);
|
||||
TableBuilder tableBuilder = new TableBuilder(model);
|
||||
TableUtils.applyStyle(tableBuilder);
|
||||
return tableBuilder.build();
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,13 @@ public class DataSourceShell
|
||||
System.out.println("Use successful!");
|
||||
}
|
||||
|
||||
@ShellMethod(value = "Get data source details", key = {"source info"})
|
||||
@ShellMethodAvailability(value = "availabilityCheck")
|
||||
public Table getInfo()
|
||||
{
|
||||
return this.dataSourceService.getInfo();
|
||||
}
|
||||
|
||||
public Availability availabilityCheck()
|
||||
{
|
||||
return this.checkService.availabilityCheck();
|
||||
|
1
client/cli/src/main/resources/log4j.properties
Normal file
1
client/cli/src/main/resources/log4j.properties
Normal file
@ -0,0 +1 @@
|
||||
logging.level.root=OFF
|
30
configure/assembly/assembly-cli.xml
Normal file
30
configure/assembly/assembly-cli.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<assembly>
|
||||
<id>jar-with-dependencies-and-exclude-classes</id>
|
||||
|
||||
<formats>
|
||||
<format>jar</format>
|
||||
</formats>
|
||||
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<useProjectArtifact>false</useProjectArtifact>
|
||||
<unpack>true</unpack>
|
||||
<scope>runtime</scope>
|
||||
<excludes>
|
||||
<exclude>org.apache.logging.*:log4j</exclude>
|
||||
<exclude>ch.qos.logback:logback-classic</exclude>
|
||||
<exclude>ch.qos.logback:logback-core</exclude>
|
||||
</excludes>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<directory>${project.build.outputDirectory}</directory>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
Loading…
Reference in New Issue
Block a user