Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ma91n/gqlgen-ekiapp
https://github.com/ma91n/gqlgen-ekiapp
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ma91n/gqlgen-ekiapp
- Owner: ma91n
- License: apache-2.0
- Created: 2020-06-09T01:53:54.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-06-09T02:04:58.000Z (over 4 years ago)
- Last Synced: 2023-07-10T17:10:27.300Z (over 1 year ago)
- Language: Go
- Size: 22.5 KB
- Stars: 4
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gqlgen-ekiapp
## Data Download
[駅データ.jp](https://ekidata.jp/) からデータをダウンロードします。
以下のように、init配下に置きます。```
.gqlgen-ekiapp
├── Dockerfile
├── docker-compose.yml
└── init
├── 1_create.sql # DDL
├── 2_copy.sql # Copy句
├── company20200309.csv # DownloadしたCSV
├── join20200306.csv # DownloadしたCSV
├── line20200306free.csv # DownloadしたCSV
└── station20200316free.csv # DownloadしたCSV
```## SetUp
```bash
# Only init
docker volume create pg-data-eki# Start postgres
docker-compose up --build# Stop
# docker-compose down# GraphQL Server launch(localhost:8080)
go run server.go
```## Development
Required: xo/xo
```bash
# 駅名検索
xo pgsql://postgres:postgres@localhost/postgres?sslmode=disable -N -M -B -T StationByName -o models/ << ENDSQL
select l.line_cd, l.line_name, s.station_cd, station_g_cd, s.station_name, s.address
from station s
inner join line l on s.line_cd = l.line_cd
where s.station_name = %%stationName string%%
and s.e_status = 0
ENDSQL# 駅CD検索
xo pgsql://postgres:postgres@localhost/postgres?sslmode=disable -N -M -B -T StationByCD -o models/ << ENDSQL
select l.line_cd, l.line_name, s.station_cd, station_g_cd, s.station_name, s.address
from station s
inner join line l on s.line_cd = l.line_cd
where s.station_cd = %%stationCD int%%
and s.e_status = 0
ENDSQL# 乗換駅検索
xo pgsql://postgres:postgres@localhost/postgres?sslmode=disable -N -M -B -T Transfer -o models/ << ENDSQL
select s.station_cd,
ls.line_cd,
ls.line_name,
s.station_name,
s.station_g_cd,
s.address,
COALESCE(lt.line_cd, 0) as transfer_line_cd,
COALESCE(lt.line_name, '') as transfer_line_name,
COALESCE(t.station_cd, 0) as transfer_station_cd,
COALESCE(t.station_name, '') as transfer_station_name,
COALESCE(t.address, '') as transfer_address
from station s
left outer join station t on s.station_g_cd = t.station_g_cd and s.station_cd <> t.station_cd
left outer join line ls on s.line_cd = ls.line_cd
left outer join line lt on t.line_cd = lt.line_cd
where s.station_cd = %%stationCD int%%
ENDSQLxo pgsql://postgres:postgres@localhost/postgres?sslmode=disable -N -M -B -T Before -o models/ << ENDSQL
select sl.line_cd,
sl.line_name,
s.station_cd,
s.station_name,
s.address,
COALESCE(js.station_cd, 0) as before_station_cd,
COALESCE(js.station_name, '') as before_station_name,
COALESCE(js.station_g_cd, 0) as before_station_g_cd,
COALESCE(js.address, '') as before_station_address
from station s
left outer join line sl on s.line_cd = sl.line_cd
left outer join station_join j on s.line_cd = j.line_cd and s.station_cd = j.station_cd1
left outer join station js on j.station_cd2 = js.station_cd
where s.e_status = 0
and s.station_cd = %%stationCD int%%
ENDSQLxo pgsql://postgres:postgres@localhost/postgres?sslmode=disable -N -M -B -T After -o models/ << ENDSQL
select sl.line_cd,
sl.line_name,
s.station_cd,
s.station_name,
s.address,
COALESCE(js.station_cd, 0) as after_station_cd,
COALESCE(js.station_name, '') as after_station_name,
COALESCE(js.station_g_cd, 0) as after_station_g_cd,
COALESCE(js.address, '') as after_station_address
from station s
left outer join line sl on s.line_cd = sl.line_cd
left outer join station_join j on s.line_cd = j.line_cd and s.station_cd = j.station_cd2
left outer join station js on j.station_cd1 = js.station_cd
where s.e_status = 0
and s.station_cd = %%stationCD int%%
ENDSQL
```