project---->database viewer

268 阅读1分钟

SQL

List some sql script that are used to query the data we wanted.

Get all tables you created

SELECT 
	table_name 
FROM 
	information_schema.tables 
WHERE 
	table_schema='public' 
ORDER by 
	"table_name";

Describe the table structure

SELECT
	ordinal_position as position, 
	column_name as name, 
	column_default as default, 
	data_type as type, 
	character_maximum_length as maxLength
FROM
	information_schema.COLUMNS
WHERE
	TABLE_NAME = '#{table_name}';

Query data pagination

SELECT 
	* 
from 
	#{table_name} 
ORDER by 
	id 
LIMIT 30 OFFSET 0;

Debug angular project in webstorm

  • start application use command line:
## use angular
> ng serve

## or npm
> npm start

we get the info from the console, remember the url http://localhost:4200 we will use it later

image-20200604173808982

  • configurate url in the webstorm:

Check if a run/debug configuration named Angular Application already exists in WebStorm. If not, create a new JavaScript debug configuration in WebStorm (menu RunEdit configurations… – Add – JavaScript Debug) to debug the client-side TypeScript code of your app.

image-20200604173848936

Paste http://localhost:4200 into the URL field.

image-20200604174010396

  • after that we click the debug button to debug our application.

image-20200604174206682

Issue

cors issue

When our client http://localhost:4200 want to get data from host http://localhost:9094, since they have different port even have the same ip, we get the cors issue as follow.

image-20200604174425116

we can fix it in the backend side, we use springboot. Just configurate it to enable the request which begin with databases from host http://localhost:4200.

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class CorsConfiguration {

  @Bean
  public WebMvcConfigurer corsConfigurer() {
    return new WebMvcConfigurer() {
      @Override
      public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/databases/**").allowedOrigins("http://localhost:4200");
      }
    };
  }
}