Skip to content

Commit 8795295

Browse files
committed
build success, added bash scripts
1 parent 97a0a65 commit 8795295

File tree

5 files changed

+199
-6
lines changed

5 files changed

+199
-6
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
*config.json
2-
*.env
2+
*.env
3+
4+
bin/

README.md

+184
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
# Database gateway API
2+
3+
API for making direct sql requests to a MSSQL or Postgresql dataabses
4+
5+
> Request for Select query
6+
7+
| url | method |
8+
| ------------------------------------- | :----: |
9+
| 127.0.0.1:8000/api/v1/make-db-request | POST |
10+
11+
```json
12+
{
13+
"query_string": "select * from tbl_mg_materials",
14+
//"query_string": "select \"ResName\" from tbl_dk_resource",
15+
}
16+
```
17+
18+
**Response**
19+
```json
20+
{
21+
"data": [
22+
{
23+
"T_ID": 1,
24+
"a_status_id": 1,
25+
"acc_card_cost_of_sale_id": 108,
26+
"acc_card_inventory_id": 237,
27+
"acc_card_purches_disc_id": 0,
28+
"acc_card_purches_id": 0,
29+
"acc_card_purches_ret_id": 0,
30+
"acc_card_sale_disc_id": 36,
31+
"acc_card_sale_id": 34,
32+
"acc_card_sale_ret_id": 35,
33+
"acc_card_scrap_id": 64,
34+
"acc_card_usage_id": 64,
35+
"data_send": 0,
36+
"dept_id": 1,
37+
"div_id": 1,
38+
"firm_id": 1,
39+
"firm_id_guid": "CAB9C297-C332-4BF1-AD3B-A27154BEEC7C",
40+
"group_code": "SALAT",
41+
"m_cat_id": 14,
42+
"mat_auto_price": "0.00000",
43+
"mat_auto_production": 0,
44+
"mat_brand_code": "",
45+
"mat_height": "0.00000",
46+
"mat_last_purch_arap_id": 0,
47+
"mat_length": "0.00000",
48+
"mat_manufacturer": null,
49+
"mat_name_lang1": "WINIGRET ",
50+
"mat_name_lang2": "",
51+
"mat_name_lang3": "",
52+
"mat_name_lang4": "",
53+
"mat_name_lang5": "",
54+
"mat_online_isvisible": null,
55+
"mat_real_price": "0.00000",
56+
"mat_shop_code": "",
57+
"mat_size_code": "",
58+
"mat_weight": "0.00000",
59+
"mat_width": "0.00000",
60+
"material_code": "AN00000049",
61+
"material_description": "",
62+
"material_description1": "",
63+
"material_id": 49,
64+
"material_id_guid": "d0d43809-d242-43b0-acf7-0e4812bb2e94",
65+
"material_name": "WINIGRET ",
66+
"modify_date": "2021-03-18T16:00:33.523Z",
67+
"security_code": "KUHNYA",
68+
"spe_code": "",
69+
"spe_code1": "",
70+
"spe_code10": "",
71+
"spe_code11": "",
72+
"spe_code12": "",
73+
"spe_code13": null,
74+
"spe_code14": null,
75+
"spe_code15": null,
76+
"spe_code2": "",
77+
"spe_code3": "",
78+
"spe_code4": "",
79+
"spe_code5": "",
80+
"spe_code6": "",
81+
"spe_code7": "",
82+
"spe_code8": "",
83+
"spe_code9": "",
84+
"sync_datetime": null,
85+
"unit_det_id": 1,
86+
"unit_id": 1
87+
},
88+
{
89+
"T_ID": 1,
90+
"a_status_id": 1,
91+
"acc_card_cost_of_sale_id": 108,
92+
"acc_card_inventory_id": 237,
93+
"acc_card_purches_disc_id": 0,
94+
"acc_card_purches_id": 0,
95+
"acc_card_purches_ret_id": 0,
96+
"acc_card_sale_disc_id": 36,
97+
"acc_card_sale_id": 34,
98+
"acc_card_sale_ret_id": 35,
99+
"acc_card_scrap_id": 64,
100+
"acc_card_usage_id": 64,
101+
"data_send": 0,
102+
"dept_id": 1,
103+
"div_id": 1,
104+
"firm_id": 1,
105+
"firm_id_guid": "CAB9C297-C332-4BF1-AD3B-A27154BEEC7C",
106+
"group_code": "SALAT",
107+
"m_cat_id": 14,
108+
"mat_auto_price": "0.00000",
109+
"mat_auto_production": 0,
110+
"mat_brand_code": "",
111+
"mat_height": "0.00000",
112+
"mat_last_purch_arap_id": 0,
113+
"mat_length": "0.00000",
114+
"mat_manufacturer": null,
115+
"mat_name_lang1": "OLWIYE ",
116+
"mat_name_lang2": "",
117+
"mat_name_lang3": "",
118+
"mat_name_lang4": "",
119+
"mat_name_lang5": "",
120+
"mat_online_isvisible": null,
121+
"mat_real_price": "0.00000",
122+
"mat_shop_code": "",
123+
"mat_size_code": "",
124+
"mat_weight": "0.00000",
125+
"mat_width": "0.00000",
126+
"material_code": "AN00000050",
127+
"material_description": "",
128+
"material_description1": "",
129+
"material_id": 50,
130+
"material_id_guid": "CCC697DF-142B-449F-BF40-59C22C02E4CC",
131+
"material_name": "OLWIYE ",
132+
"modify_date": "2021-03-18T16:00:33.523Z",
133+
"security_code": "KUHNYA",
134+
"spe_code": "",
135+
"spe_code1": "",
136+
"spe_code10": "",
137+
"spe_code11": "",
138+
"spe_code12": "",
139+
"spe_code13": null,
140+
"spe_code14": null,
141+
"spe_code15": null,
142+
"spe_code2": "",
143+
"spe_code3": "",
144+
"spe_code4": "",
145+
"spe_code5": "",
146+
"spe_code6": "",
147+
"spe_code7": "",
148+
"spe_code8": "",
149+
"spe_code9": "",
150+
"sync_datetime": null,
151+
"unit_det_id": 1,
152+
"unit_id": 1
153+
}
154+
],
155+
"status": 1,
156+
"total": 2,
157+
"message": "db query result"
158+
}
159+
```
160+
161+
162+
> Request for Update | Insert | Delete query
163+
164+
| url | method |
165+
| --------------------------------------------------- | :----: |
166+
| 127.0.0.1:8000/api/v1/make-db-request?executeOnly=1 | POST |
167+
168+
```json
169+
{
170+
"query_string": "update tbl_dk_users set \"URegNo\" = 'SSFK123' where \"UId\" = 1"
171+
}
172+
```
173+
> Response
174+
175+
```json
176+
{
177+
"data": null,
178+
"status": 1,
179+
"total": 1,
180+
"message": "db query result"
181+
}
182+
```
183+
184+
!! Use **executeOnly** to make other than **SELECT** queries

build_linux.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GOOS=linux GOARCH=amd64 go build -o bin/db-gateway-go-amd64-linux .
2+
GOOS=linux GOARCH=386 go build -o bin/db-gateway-go-386-linux .

build_windows.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
GOOS=windows GOARCH=amd64 go build -o bin/sqlapi_console-amd64.exe .
2+
GOOS=windows GOARCH=386 go build -o bin/sqlapi_console-386.exe .
3+
4+
GOOS=windows GOARCH=amd64 go build -ldflags -H=windowsgui -o bin/sqlapi-amd64.exe .
5+
GOOS=windows GOARCH=386 go build -ldflags -H=windowsgui -o bin/sqlapi-386.exe .
+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"listen_address": "0.0.0.0:8000",
3-
"db_type": "postgres",
4-
"db_user": "postgres",
3+
"db_type": "sqlserver",
4+
"db_user": "sa",
55
"db_password": "123456",
6-
"db_host": "localhost",
7-
"db_database": "database",
8-
"db_params": "sslmode=disable"
6+
"db_host": "192.168.31.132:1433",
7+
"db_database": "dbSapHasap",
8+
"db_params": ""
99
}

0 commit comments

Comments
 (0)