Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
eue
Commits
efe07467
Commit
efe07467
authored
May 15, 2021
by
KangMin An
Browse files
Update : DB & Server Info Message 정리
parent
4ca7dadf
Changes
3
Hide whitespace changes
Inline
Side-by-side
server/src/controllers/locCodeController.js
View file @
efe07467
import
db
from
"
../db
"
;
import
{
getPoolConnection
as
db
,
dbMSG
}
from
"
../db
"
;
import
{
serverMSG
,
statusCode
}
from
"
../serverinfo
"
;
const
DB_QUERY_ERROR_MSG
=
"
DB Query Error.
"
;
const
DB_CONNECTION_ERROR_MSG
=
"
DB Connection Error.
"
;
const
SERVER_ERROR_MSG
=
"
The server encountered an error.
"
;
const
QUERY_SUCCESS_MSG
=
"
Query Success.
"
;
const
STATUS_OK_CODE
=
200
;
const
STATUS_SERVER_ERROR_CODE
=
500
;
export
const
getDo
=
async
(
req
,
res
)
=>
{
export
const
getDo
=
async
(
req
,
res
)
=>
{
const
query
=
"
SELECT CODE, DONAME FROM LOCDO
"
;
const
query
=
"
SELECT CODE, DONAME FROM LOCDO
"
;
db
((
connErr
,
connection
)
=>
{
db
((
connErr
,
connection
)
=>
{
if
(
connErr
)
{
if
(
connErr
)
{
console
.
log
(
DB_CONNECTION_ERROR_MSG
);
console
.
log
(
dbMSG
.
connection_err
);
res
.
status
(
STATUS_SERVER_ERROR_CODE
).
json
({
error
:
SERVER_ERROR_MSG
});
res
.
status
(
statusCode
.
err
).
json
({
error
:
serverMSG
.
server_err
});
}
else
{
}
else
{
connection
.
query
(
query
,
(
queryErr
,
result
)
=>
{
connection
.
query
(
query
,
(
queryErr
,
result
)
=>
{
if
(
queryErr
)
{
if
(
queryErr
)
{
console
.
log
(
DB_QUERY_ERROR_MSG
);
console
.
log
(
dbMSG
.
query_err
);
res
res
.
status
(
statusCode
.
err
).
json
({
error
:
serverMSG
.
server_err
});
.
status
(
STATUS_SERVER_ERROR_CODE
)
.
json
({
error
:
SERVER_ERROR_MSG
});
}
else
{
}
else
{
console
.
log
(
QUERY_SUCCESS_MSG
);
console
.
log
(
dbMSG
.
query_success
);
res
.
status
(
STATUS_OK_CODE
).
json
({
info
:
result
});
res
.
status
(
statusCode
.
ok
).
json
({
info
:
result
});
}
}
});
});
...
@@ -42,18 +33,16 @@ export const getSGG = (req, res) => {
...
@@ -42,18 +33,16 @@ export const getSGG = (req, res) => {
db
((
connErr
,
connection
)
=>
{
db
((
connErr
,
connection
)
=>
{
if
(
connErr
)
{
if
(
connErr
)
{
console
.
log
(
DB_CONNECTION_ERROR_MSG
);
console
.
log
(
dbMSG
.
connection_err
);
res
.
status
(
STATUS_SERVER_ERROR_CODE
).
json
({
error
:
SERVER_ERROR_MSG
});
res
.
status
(
statusCode
.
err
).
json
({
error
:
serverMSG
.
server_err
});
}
else
{
}
else
{
connection
.
query
(
query
,
(
queryErr
,
result
)
=>
{
connection
.
query
(
query
,
(
queryErr
,
result
)
=>
{
if
(
queryErr
)
{
if
(
queryErr
)
{
console
.
log
(
DB_QUERY_ERROR_MSG
);
console
.
log
(
dbMSG
.
query_err
);
res
res
.
status
(
statusCode
.
err
).
json
({
error
:
serverMSG
.
server_err
});
.
status
(
STATUS_SERVER_ERROR_CODE
)
.
json
({
error
:
SERVER_ERROR_MSG
});
}
else
{
}
else
{
console
.
log
(
QUERY_SUCCESS_MSG
);
console
.
log
(
dbMSG
.
query_success
);
res
.
status
(
STATUS_OK_CODE
).
json
({
info
:
result
});
res
.
status
(
statusCode
.
ok
).
json
({
info
:
result
});
}
}
});
});
...
@@ -71,18 +60,16 @@ export const getEMD = (req, res) => {
...
@@ -71,18 +60,16 @@ export const getEMD = (req, res) => {
db
((
connErr
,
connection
)
=>
{
db
((
connErr
,
connection
)
=>
{
if
(
connErr
)
{
if
(
connErr
)
{
console
.
log
(
DB_CONNECTION_ERROR_MSG
);
console
.
log
(
dbMSG
.
connection_err
);
res
.
status
(
STATUS_SERVER_ERROR_CODE
).
json
({
error
:
SERVER_ERROR_MSG
});
res
.
status
(
statusCode
.
err
).
json
({
error
:
serverMSG
.
server_err
});
}
else
{
}
else
{
connection
.
query
(
query
,
(
queryErr
,
result
)
=>
{
connection
.
query
(
query
,
(
queryErr
,
result
)
=>
{
if
(
queryErr
)
{
if
(
queryErr
)
{
console
.
log
(
DB_QUERY_ERROR_MSG
);
console
.
log
(
dbMSG
.
query_err
);
res
res
.
status
(
statusCode
.
err
).
json
({
error
:
serverMSG
.
server_err
});
.
status
(
STATUS_SERVER_ERROR_CODE
)
.
json
({
error
:
SERVER_ERROR_MSG
});
}
else
{
}
else
{
console
.
log
(
QUERY_SUCCESS_MSG
);
console
.
log
(
dbMSG
.
query_success
);
res
.
status
(
STATUS_OK_CODE
).
json
({
info
:
result
});
res
.
status
(
statusCode
.
ok
).
json
({
info
:
result
});
}
}
});
});
...
...
server/src/db.js
View file @
efe07467
...
@@ -16,7 +16,7 @@ const db_config = {
...
@@ -16,7 +16,7 @@ const db_config = {
const
pool
=
mysql
.
createPool
(
db_config
);
const
pool
=
mysql
.
createPool
(
db_config
);
// Pool을 이용시, Connection을 생성 후 반환하여 사용
// Pool을 이용시, Connection을 생성 후 반환하여 사용
const
c
onnection
=
(
callback
)
=>
{
export
const
getPoolC
onnection
=
(
callback
)
=>
{
console
.
log
(
"
db_connection()
"
);
console
.
log
(
"
db_connection()
"
);
pool
.
getConnection
(
async
(
err
,
connection
)
=>
{
pool
.
getConnection
(
async
(
err
,
connection
)
=>
{
console
.
log
(
"
db_connection_poolConnection()
"
);
console
.
log
(
"
db_connection_poolConnection()
"
);
...
@@ -24,4 +24,8 @@ const connection = (callback) => {
...
@@ -24,4 +24,8 @@ const connection = (callback) => {
});
});
};
};
export
default
connection
;
export
const
dbMSG
=
{
connection_err
:
"
DB Connection Error.
"
,
query_err
:
"
DB Query Error.
"
,
query_success
:
"
Query Success
"
,
};
server/src/serverinfo.js
0 → 100644
View file @
efe07467
const
SERVER_ERROR_MSG
=
"
The server encountered an error.
"
;
const
STATUS_OK_CODE
=
200
;
const
STATUS_ERROR_CODE
=
500
;
export
const
serverMSG
=
{
server_err
:
SERVER_ERROR_MSG
,
};
export
const
statusCode
=
{
ok
:
STATUS_OK_CODE
,
err
:
STATUS_ERROR_CODE
,
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment