- ๐์คํ ๋ฆฌ๋ณด๋ ์์ฑ , ์คํ ๋ฆฌ๋ณด๋ ๊ธฐ๋ฐ ๋์์ธ, ERD ์์ฑ
- DB ์๋ฒ์ด๊ธฐ์ DB์ ๋๋ฏธ๋ฐ์ดํฐ ๋ฃ๊ธฐ
- ๋ฉ์ธ ํ์ด์ง ์ ์
- ํ์๊ฐ์ ํ์ด์ง ์ ์
- ํ๋ก์ ํธ๋ฑ๋ก ํ์ด์ง ์ ์
- ๊ฒฐ์ ํ์ด์ง ์ ์
์ด ํฌ์คํฐ๋ ํ๊ต ํ๋ก์ ํธ์ ํฌํธํด๋ฆฌ์ค๋ฅผ ์์ฑํ ๊ฒ์ด๋ค.
ํ๋ก์ ํธ์ ๋ด์ฉ์ ํฌ๋ผ์ฐ๋ ํ๋ฉ์ ๋ฐ์ ์ ์๋ ๊ฒ์๊ฐ๋ฐ์ฌ์ดํธ ๋ง๋ค๊ธฐ์ด๋ค.
ํ๊ต์์ ํ ํ๋ก์ ํธ๋ก ์ฌ์ดํธ ํ๋๋ฅผ ๋ง๋ค์ด์ค๋ผ๋ ๊ณผ์ ๋ฅผ ๋ฐ์๋ค.
์ด 4๋ช
์ด์ ํ ํ๋ก์ ํธ๋ฅผ ์งํ์์ผฐ๊ณ ๊ฐ๊ฐ ์ญํ ์ ์ ํ๋๋ฐ
- PM
- ๋์์ธ
- Front_End
- Back_End
์ค์์ ๋๋ Back_End์ญํ ์ ๋งก์๋ค.
๊ฐ์ฅ ์ฒ์์ ์งํํ ์์
์ PM ์ ์คํ ๋ฆฌ๋ณด๋ ์์ฑ์ด์๋ค.
์ด ์คํ ๋ฆฌ๋ณด๋๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ๋์์ธ๊ณผ Back_End๋ ์์
์ ํ์๋๋ฐ
๋์์ธ์ zeplin์ ์์
๋ฌผ์ ์ฌ๋ฆฌ๊ณ
Back_End๋ ERD๋ก ์์
์ํด์ ๊ณต์ ํ์๋ค.
(ERD ์ฌ์ดํธ์์ ์์
์ ํ์๋๋ฐ ์ ๋ฃํ๊ฐ ๋์ด์ ์บก์ฒ๋ณธ์ผ๋ก ๋ฐ์ ์ฌ๋ฆด ์๊ฐ ์์๋ค..)
ERD๋ฅผ ์ง๋ ๋์ค์ ํ๊ฐ์ ํ
์ด๋ธ์ด ์ฌ๋ฌ๊ฐ์ ํ
์ด๋ธ์ ์ฐธ์กฐํด์ผํ๋ ์ํฉ์ด ๋์์ ๊ณจ๋จธ๋ฆฌ๋ฅผ ์ฉ์๋๋ฐ.
์ฌ์ง๊ณผ๊ฐ์ด 2๊ฐ์ ํ๋์ PK๋ฅผ ๊ฑธ์ด๋๊ณ ๊ฐํ
์ด๋ธ์ ์ฐธ์กฐํ๋๋ฐฉ์์ผ๋ก ๋ฐ์ดํฐ๋ฅผ ๊ด๋ฆฌํ์ฌ ํด๊ฒฐํ์๋ค.
PK๋ฅผ ๊ฑธ์ด๋์ ํ๋๊ฐ sys_user_id , sys_project_id 2๊ฐ์ด๊ธฐ ๋๋ฌธ์ 2๊ฐ ํ๋์ ๊ฐ์ ๊ณ ์ ๊ฐ์ผ๋ก ์ธ์ํ๋๊ฑธ ํ์ธํ ์ ์์๋ค.
ERD๋ฅผ ๊ธฐ๋ฐ์ผ๋ก DB๋ฅผ ๋ค ๋ง๋ ๋ค์์ ์นดํ24์์ ๋๋ฉ์ธ์ ์ฌ์ DB์๋ฒ๋ฅผ ์ด์๋ค.
๋ง์ฝ์ ์ฌ์ดํธ์์ ์ญ์ ํด์ผํ๋ ๋ฐ์ดํฐ๊ฐ ์๊ฒผ๋ค๊ณ ๊ฐ์ ํด๋ณด์.
๊ทธ๋ด๋ DELETE ์ฟผ๋ฆฌ๋ฅผ ์ด์ฉํ์ฌ ๋ฐ์ดํฐ๋ฅผ ์ญ์ ํ๋ฉด๋๋ค๊ณ ์๊ฐํ์์์ง๋ง ๊ฑฐ์ ๋ชจ๋ table์ด Forien Key๋ก ๋ค๋ฅธ table์ ๋ฐ์ดํฐ๋ฅผ ์ฐธ์กฐํ๊ณ ์๋ ์ํ์ด๊ธฐ ๋๋ฌธ์ DELETE์ฟผ๋ฆฌ๋ฅผ ์ฌ์ฉํ๋๊ฒ์ ๋ณ๋ก ์ข์ ๋ฐฉ๋ฒ์ด ์๋๋ผ๊ณ ์๊ฐ๋์ด
๊ทธ๋ฆผ์ ๋์ค๋ f_div ํ๋๋ฅผ ๋ง๋ค์ด ํ์ฑํ ๋ฐ์ดํฐ์ ๋นํ์ฑํ ๋ฐ์ดํฐ๋ฅผ ๊ตฌ๋ถ์ง๊ธฐ๋ก ํ์๋ค.
๋ง๋ค์ด์ง DB์ ๋ฐ์ดํฐ๋ฅผ INSERTํ๊ธฐ๋ก ํ์๋ค.
open api๋ฅผ ํ๋ ๊ตฌํด์ api๋ก ํธ์ถํ JSON๊ฐ์์ ํ์ํ ์ ๋ณด๋ง ์ถ๋ ค๋ค ๋ฐฐ์ด์ ๋ด์์ Table์ INSERT ํ์๋ค.
const mariadb = require("mariadb");
const pool = mariadb.createPool(
{
host: "funware.shop",
user: "junseok816",
connectionLimit: 5,
password: "์ํธ",
port: ????,
database: "junseok816",
multipleStatements: true,
}
);
pool.getConnection()
.then((conn) => {
conn.beginTransaction();
conn.query("SELECT 1 as val").then((rows) => {
// rows: [ {val: 1}, meta: ... ]
console.log("connect");
conn.batch(
"INSERT INTO tbl_project (f_project_name , f_storyline, f_summary, f_register_account , f_donate_limit , f_par_value ,f_date_limit, sys_register_id , f_div) VALUES (?,?,?,?,?,?,20210523,1,'Y');",
arr
);
conn.commit();
});
})
.catch((err) => {
console.log(err);
});
getConnection() ํจ์๋ฅผ ํธ์ถ์ํจ๋ค์์ "SELECT 1 as val" ๊ฐ์ ๋ฌด์กฐ๊ฑด ์คํ์ด๋๋ Query๋ฌธ์ ๋ ๋ ค ์ฐ๊ฒฐ์ด ์ ๋์ด์๋์ง ํ์ธํ ํ
batch() ๋ฉ์๋๋ฅผ ํธ์ถํ์ฌ ์ํ๋ SQL ๋ฌธ์ ์ผ๊ด ์ฒ๋ฆฌ๋ฅผ ์คํํฉ๋๋ค.
์ด๋ VALUES ์์ ๋ค์ด์๋ ?์ ์์ฐจ๋ ๋ฐฐ์ด์ ์์๋ค์ ์์น๋ฅผ ๋ง์ถ๋ฉด ?์ ์ํ๋ ๊ฐ์ INSERTํ ์ ์์ต๋๋ค.
axios({
url: "https://api.igdb.com/v4/games",
method: "POST",
headers: {
Accept: "application/json",
"Client-ID": "???",
Authorization: "Bearer ???",
},
data:
"fields name,storyline,summary, screenshots.url, cover.url ,videos.video_id; where genres != (2, 8, 9, 11, 13, 15, 16, 24, 25, 26, 30, 31, 32, 34, 35, 36) & storyline != null & summary != null & screenshots.url != null & cover.url != null & videos.video_id != null & involved_companies.company.name != null & involved_companies.company.description != null & involved_companies.company.logo != null &involved_companies.company.websites != null; limit 100; offset 400;",
})
.then((response) => {
var arr = new Array(0);
response.data.forEach((v_game) => {
v_dona_limit = Math.floor(1000000 + Math.random() * 9000000);
v_accout =
"์ํ" + String(Math.floor(4190000000 + Math.random() * 900000000));
v_par_value = Math.floor(Math.random() * 10000)+1000;
var srr = new Array(
v_game.name,
v_game.storyline,
v_game.summary,
v_accout,
v_dona_limit,
v_par_value
);
arr.push(srr);
});
const axios = require("axios");
const mv_Express = require("express");
const app = mv_Express();
const port = 3000;
const mariadb = require("mariadb");
const pool = mariadb.createPool(
{
host: "funware.shop",
user: "junseok816",
connectionLimit: 5,
password: "",
port: ????,
database: "junseok816",
multipleStatements: true,
}
);
app.use(mv_Express.static("public"));
axios({
url: "https://api.igdb.com/v4/games",
method: "POST",
headers: {
Accept: "application/json",
"Client-ID": "???",
Authorization: "Bearer ???",
},
data:
"fields name,storyline,summary, screenshots.url, cover.url ,videos.video_id; where genres != (2, 8, 9, 11, 13, 15, 16, 24, 25, 26, 30, 31, 32, 34, 35, 36) & storyline != null & summary != null & screenshots.url != null & cover.url != null & videos.video_id != null & involved_companies.company.name != null & involved_companies.company.description != null & involved_companies.company.logo != null &involved_companies.company.websites != null; limit 100; offset 400;",
})
.then((response) => {
var arr = new Array(0);
response.data.forEach((v_game) => {
v_dona_limit = Math.floor(1000000 + Math.random() * 9000000);
v_accout =
"์ํ" + String(Math.floor(4190000000 + Math.random() * 900000000));
v_par_value = Math.floor(Math.random() * 10000)+1000;
var srr = new Array(
v_game.name,
v_game.storyline,
v_game.summary,
v_accout,
v_dona_limit,
v_par_value
);
arr.push(srr);
});
console.log(arr);
pool
.getConnection()
.then((conn) => {
conn.beginTransaction();
conn.query("SELECT 1 as val").then((rows) => {
// rows: [ {val: 1}, meta: ... ]
console.log("connect");
conn.batch(
"INSERT INTO tbl_project (f_project_name , f_storyline, f_summary, f_register_account , f_donate_limit , f_par_value ,f_date_limit, sys_register_id , f_div) VALUES (?,?,?,?,?,?,20210523,1,'Y');",
arr
);
conn.commit();
});
})
.catch((err) => {
console.log(err);
});
console.log("INSERT tbl_project completed...");
})
.catch((err) => {
console.error(err);
});
app.listen(port, () => {
console.log("starup");
});