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
36bfc116
Commit
36bfc116
authored
Jul 20, 2021
by
Spark
Browse files
Merge remote-tracking branch 'origin/premaster' into who
parents
ea90c8ea
e11c97e9
Changes
30
Show whitespace changes
Inline
Side-by-side
server/src/models/weather_out.js
0 → 100644
View file @
36bfc116
import
{
DataTypes
,
Model
}
from
"
sequelize
"
;
import
Emd
from
"
./emd
"
;
export
class
Weather_Out
extends
Model
{
static
init
(
sequelize
)
{
return
super
.
init
(
{
loc_code
:
{
type
:
DataTypes
.
INTEGER
,
primaryKey
:
true
,
references
:
{
model
:
Emd
,
key
:
"
code_emd
"
,
},
},
collected_at
:
{
type
:
DataTypes
.
DATE
,
primaryKey
:
true
,
},
temp
:
{
type
:
DataTypes
.
FLOAT
,
defaultValue
:
0
,
},
humi
:
{
type
:
DataTypes
.
FLOAT
,
defaultValue
:
0
,
},
press
:
{
type
:
DataTypes
.
FLOAT
,
defaultValue
:
0
,
},
wind_speed
:
{
type
:
DataTypes
.
FLOAT
,
defaultValue
:
0
,
},
},
{
sequelize
,
timestamps
:
false
,
paranoid
:
false
,
}
);
}
static
associate
(
db
)
{
// weather_out 모델이 참조하는 테이블에 대한 외래키 설정.
db
.
Weather_out
.
belongsTo
(
db
.
Emd
,
{
foreignKey
:
"
loc_code
"
,
targetKey
:
"
code_emd
"
,
});
}
}
export
default
Weather_Out
;
server/src/rdb_setting/dbsetting.js
deleted
100644 → 0
View file @
ea90c8ea
import
fs
from
"
fs
"
;
import
mysql
from
"
mysql
"
;
import
dotenv
from
"
dotenv
"
;
dotenv
.
config
();
// DB Connection
const
db
=
mysql
.
createConnection
({
host
:
process
.
env
.
MYSQL_HOST
||
"
localhost
"
,
user
:
process
.
env
.
MYSQL_USER
||
"
root
"
,
password
:
process
.
env
.
MYSQL_PASSWORD
,
database
:
process
.
env
.
MYSQL_DATABASE
||
"
EUE
"
,
});
const
inputDo
=
(
code
,
name
)
=>
{
name
=
name
.
replace
(
/
\s
/g
,
""
);
let
q
=
`INSERT INTO LOCDO (CODE,DONAME) VALUES (
${
code
}
,'
${
name
}
');`
;
db
.
query
(
q
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
log
(
err
);
return
;
}
console
.
log
(
"
Result :
"
+
result
);
});
};
const
inputSi
=
(
code
,
name
,
doCode
)
=>
{
name
=
name
.
replace
(
/
\s
/g
,
""
);
let
q
=
`INSERT INTO LOCSIGUNGU (CODE,DOCODE,SGGNAME) VALUES (
${
code
}
,
${
doCode
}
,'
${
name
}
');`
;
db
.
query
(
q
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
log
(
err
);
return
;
}
console
.
log
(
"
Result :
"
+
result
);
});
};
const
inputDong
=
(
code
,
name
,
doCode
,
siCode
)
=>
{
name
=
name
.
replace
(
/
\s
/g
,
""
);
let
q
=
`INSERT INTO LOCINFO (CODE,DOCODE,SGGCODE,EMDNAME) VALUES (
${
code
}
,
${
doCode
}
,
${
siCode
}
,'
${
name
}
');`
;
db
.
query
(
q
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
log
(
err
);
return
;
}
console
.
log
(
"
Result :
"
+
result
);
});
};
const
setDB
=
()
=>
{
// DB Connect
db
.
connect
((
err
)
=>
{
if
(
err
)
{
console
.
log
(
err
);
return
;
}
console
.
log
(
"
connected as id
"
+
db
.
threadId
);
});
// File Read
let
originData
=
fs
.
readFileSync
(
"
data/admAddressCode.csv
"
,
"
utf8
"
);
// Separate Data & Input Data
let
sepData
=
originData
.
split
(
"
\r\n
"
);
let
setDoCode
=
new
Set
();
let
setSiCode
=
new
Set
();
sepData
.
forEach
((
line
)
=>
{
line
=
line
.
replace
(
/
\s
/g
,
""
);
let
addr
=
line
.
split
(
"
,
"
);
const
doCode
=
Number
(
addr
[
0
]);
if
(
!
setDoCode
.
has
(
doCode
))
{
const
doName
=
addr
[
1
];
inputDo
(
doCode
,
doName
);
setDoCode
.
add
(
doCode
);
}
const
siCode
=
Number
(
addr
[
2
]);
if
(
!
setSiCode
.
has
(
siCode
))
{
const
siName
=
addr
[
3
];
inputSi
(
siCode
,
siName
,
doCode
);
setSiCode
.
add
(
siCode
);
}
const
dongCode
=
Number
(
addr
[
4
]);
const
dongName
=
addr
[
5
];
inputDong
(
dongCode
,
dongName
,
doCode
,
siCode
);
});
// Connection Close
db
.
end
();
};
setDB
();
server/src/rdb_setting/eue.sql
deleted
100644 → 0
View file @
ea90c8ea
/*
# EUE Server Database Schema
1. LOCDO
- 행정구역 도/특별시/특별자치시 이름과 코드 저장
- LOCSIGUNGU와 LOCINFO에 참조됨
2. LOCSIGUNGU
- 행정구역 시/군/구 이름과 코드 저장
- LOCDO를 참조
- LOCINFO에 참조됨
3. LOCINFO
- 행정구역 읍/면/동 이름과 코드 및 날씨 정보 URL 저장
- LOCDO와 LOCSIGUNGU를 참조
4. USER
- 사용자 ID, PassWord, 거주지역코드, 데이터 URL 저장
- LOCINFO를 참조
*/
CREATE
TABLE
LOCDO
(
CODE
INT
NOT
NULL
,
DONAME
VARCHAR
(
20
)
NOT
NULL
,
PRIMARY
KEY
(
CODE
)
);
CREATE
TABLE
LOCSIGUNGU
(
CODE
INT
NOT
NULL
,
DOCODE
INT
NOT
NULL
,
SGGNAME
VARCHAR
(
20
)
NOT
NULL
,
PRIMARY
KEY
(
CODE
),
FOREIGN
KEY
(
DOCODE
)
REFERENCES
LOCDO
(
CODE
)
ON
UPDATE
CASCADE
ON
DELETE
RESTRICT
);
CREATE
TABLE
LOCINFO
(
CODE
INT
NOT
NULL
,
DOCODE
INT
NOT
NULL
,
SGGCODE
INT
NOT
NULL
,
EMDNAME
VARCHAR
(
20
)
NOT
NULL
,
DATALINK
TEXT
,
PRIMARY
KEY
(
CODE
),
FOREIGN
KEY
(
DOCODE
)
REFERENCES
LOCDO
(
CODE
)
ON
UPDATE
CASCADE
ON
DELETE
RESTRICT
,
FOREIGN
KEY
(
SGGCODE
)
REFERENCES
LOCSIGUNGU
(
CODE
)
ON
UPDATE
CASCADE
ON
DELETE
RESTRICT
);
CREATE
TABLE
USER
(
ID
VARCHAR
(
20
)
UNIQUE
NOT
NULL
,
PW
VARCHAR
(
20
)
NOT
NULL
,
LOCCODE
INT
NOT
NULL
,
DATALINK
TEXT
,
PRIMARY
KEY
(
ID
),
FOREIGN
KEY
(
LOCCODE
)
REFERENCES
LOCINFO
(
CODE
)
ON
UPDATE
CASCADE
ON
DELETE
RESTRICT
);
\ No newline at end of file
server/src/routers/dataRouter.js
View file @
36bfc116
import
express
from
"
express
"
;
import
routes
from
"
../routes
"
;
import
{
getDataInput
,
getUserData
}
from
"
../controllers/dataController
"
;
import
{
getDataInput
,
getUserWeatherData
,
}
from
"
../controllers/dataController
"
;
import
{
onlyPrivate
}
from
"
../middlewares
"
;
const
dataRouter
=
express
.
Router
();
dataRouter
.
get
(
routes
.
dataInput
,
getDataInput
);
dataRouter
.
get
(
routes
.
dataUser
,
onlyPrivate
,
getUserData
);
dataRouter
.
get
(
routes
.
dataUser
,
onlyPrivate
,
getUser
Weather
Data
);
export
default
dataRouter
;
server/src/routers/globalRouter.js
View file @
36bfc116
import
express
from
"
express
"
;
import
routes
from
"
../routes
"
;
import
{
getHome
}
from
"
../controllers/globalController
"
;
import
{
getLogin
,
getSignup
,
postLogin
,
postSignup
,
}
from
"
../controllers/userController
"
;
const
globalRouter
=
express
.
Router
();
globalRouter
.
get
(
routes
.
home
,
getHome
);
// Authentication
globalRouter
.
get
(
routes
.
signup
,
getSignup
);
// For development test.
globalRouter
.
get
(
routes
.
login
,
getLogin
);
// For development test.
globalRouter
.
post
(
routes
.
signup
,
postSignup
);
globalRouter
.
post
(
routes
.
login
,
postLogin
);
export
default
globalRouter
;
server/src/routers/locCodeRouter.js
View file @
36bfc116
import
express
from
"
express
"
;
import
routes
from
"
../routes
"
;
import
{
getDo
,
getEMD
,
getSGG
}
from
"
../controllers/locCodeController
"
;
import
{
getDo
e
,
getEMD
,
getSGG
}
from
"
../controllers/locCodeController
"
;
const
locCodeRouter
=
express
.
Router
();
locCodeRouter
.
get
(
routes
.
do
,
getDo
);
locCodeRouter
.
get
(
routes
.
do
e
,
getDo
e
);
locCodeRouter
.
get
(
routes
.
sigungu
+
routes
.
Detail
(),
getSGG
);
locCodeRouter
.
get
(
routes
.
eupmyeondong
+
routes
.
Detail
(),
getEMD
);
...
...
server/src/routes.js
View file @
36bfc116
...
...
@@ -11,12 +11,12 @@ const DATA_OUTSIDE = "/outside";
// # Local Code Data
const
LOCCODE
=
"
/loccode
"
;
const
DO
=
"
/do
"
;
const
DO
E
=
"
/do
e
"
;
const
SIGUNGU
=
"
/si-gun-gu
"
;
const
EUPMYEONDONG
=
"
/eup-myeon-dong
"
;
// # Auth
const
REGISTER
=
"
/register
"
;
const
SIGNUP
=
"
/signup
"
;
const
LOGIN
=
"
/login
"
;
const
EDIT_PROFILE
=
"
/edit-profile
"
;
...
...
@@ -30,10 +30,10 @@ const routes = {
dataUser
:
DATA_USER
,
dataOutside
:
DATA_OUTSIDE
,
locCode
:
LOCCODE
,
do
:
DO
,
do
e
:
DO
E
,
sigungu
:
SIGUNGU
,
eupmyeondong
:
EUPMYEONDONG
,
register
:
REGISTER
,
signup
:
SIGNUP
,
login
:
LOGIN
,
editProfile
:
EDIT_PROFILE
,
Detail
:
(
id
)
=>
{
...
...
server/src/views/home.pug
View file @
36bfc116
...
...
@@ -5,4 +5,6 @@ block content
li
a(href=routes.data+routes.dataInput) 데이터 등록
li
a(href=routes.data+routes.dataOutput) 데이터 출력
\ No newline at end of file
a(href=routes.signup) 회원가입
li
a(href=routes.login) 로그인
\ No newline at end of file
server/src/views/login.pug
0 → 100644
View file @
36bfc116
block content
.login-form_container
form(action=routes.login, method="post")
input(type="email", name="email", require=true, placeholder="E-mail")
input(type="submit", value="Submit")
\ No newline at end of file
server/src/views/signup.pug
0 → 100644
View file @
36bfc116
block content
.signup-form_container
form(action = routes.signup, method = "post")
input(type="email", name="email", require=true, placeholder="E-mail")
input(type="number", name="locCode")
input(type="submit", value="Submit")
\ No newline at end of file
Prev
1
2
Next
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