๐Ÿ” [์ง๋ฌด ๊ด€๋ จ ์งˆ๋ฌธ] - 07. ๋ฐฑ์—”๋“œ ๊ฐœ๋ฐœ ๊ฒฝํ—˜์ด ์žˆ๋Š”๊ฐ€?

์กฐ์ค€ํ˜•ยท2021๋…„ 6์›” 22์ผ
0

interview

๋ชฉ๋ก ๋ณด๊ธฐ
12/20
post-thumbnail
  • REST API ๊ตฌ์ถ• ๊ฒฝํ—˜๊ณผ ๊ตฌํ˜„ ๊ด€์ ์—์„œ์˜ ๊ฐ„๋‹จํ•œ REST API ์„ค๊ณ„ ๋ฐฉ์‹ ์„ค๋ช…ํ•ด ๋ณด์„ธ์š”.
    (๋ธŒ๋ผ์šฐ์ €์˜ URL ์š”์ฒญ์„ ๋ฐ›์•„์„œ ์„œ๋ฒ„์˜ ๋ฐ์ดํ„ฐ๋ฅผ ํ™”๋ฉด์— ๋‹ค์‹œ ๋ฟŒ๋ ค์ฃผ๊ธฐ๊นŒ์ง€์˜ ๋ฐฑ์—”๋“œ ์ชฝ์˜ ํ”Œ๋กœ์šฐ๋ฅผ ์•Œ๊ณ  ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๋Š” ์ฐจ์›.)

๐Ÿ’ฌ Answer

๐ŸŒ Spring, mybatis

๐Ÿ‘‰ ๊ฐœ์ธ ๊ณต๋ถ€ ๋ฐ ํ† ์ดํ”„๋กœ์ ํŠธ

์ฒ˜์Œ vue์— ์ต์ˆ™ํ•ด์ง€๊ธฐ์œ„ํ•ด ๋งŒ๋“ค์—ˆ๋˜ cafe bombom์‚ฌ์ดํŠธ์™€ ๊ฐœ์ธ ๊ณต๋ถ€์šฉ ํ”„๋กœ์ ํŠธ์—์„œ ๊ฐ„๋‹จํ•œ CRUD๋ฅผ Spring boot๋ฅผ ์ด์šฉํ•˜์—ฌ ๊ตฌํ˜„ ํ•ด๋ดค์—ˆ์Šต๋‹ˆ๋‹ค.

๐ŸŒ REST API ์„ค๊ณ„

CRUD(Create, Read, Update, Delete)์— ํ•ด๋‹นํ•˜๋Š” ๋™์ž‘์„ ๊ฐ๊ฐ POST, GET, PUT, DELETE์— ๋งž์ถฐ ์–ด๋…ธํ…Œ์ด์…˜์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐœ๋ฐœํ•˜์˜€์Šต๋‹ˆ๋‹ค.
๋ฉ”์†Œ๋“œ๋ช…์˜ ๊ฒฝ์šฐ ๋™์ž‘์— ๋”ฐ๋ผ ์ด๋ฆ„์•ž์— crud๋ฅผ ๋ถ™์ด๊ณ  ๋’ค์— ํ•ด๋‹นํ•˜๋Š” ๋Œ€์ƒ์„ ์ ์—ˆ์Šต๋‹ˆ๋‹ค.
ex) ๋ฉค๋ฒ„์ •๋ณด์กฐํšŒ - getMemberInfo

url์˜ ๊ฒฝ์šฐ @RequestMapping์„ ํ†ตํ•ด ๊ณตํ†ต๋œ ๋Œ€์ƒ์„ ๋จผ์ € ์ ๊ณ , ๊ทธ ๋’ค์— ์ถ”๊ฐ€ ์ž‘์„ฑ.
ex) ๊ณ ์–‘์ด์˜ ์ •๋ณด๋ฅผ ์กฐํšŒ, ๊ณ ์–‘์ด์˜ ์„ฑ๊ฒฉ ์กฐํšŒ
'/cats/detail/{cat_num}', '/cats/charc/{cat_num}'

Front์™€์˜ ํ†ต์‹ ์€ axios๋ฅผ ์ด์šฉํ•˜์—ฌ ํ†ต์‹ ํ•˜์˜€์Šต๋‹ˆ๋‹ค.
axios๋ฅผ ์ด์šฉํ•˜์—ฌ back์— ์š”์ฒญํ•˜๊ฒŒ๋˜๋ฉด url์— ๋งž๋Š” ์ปจํŠธ๋กค๋Ÿฌ๋ฅผ ์ฐพ์•„ ๊ทธ ํ•˜์œ„์— url์—๋”ฐ๋ผ ๋งž๋Š” ๋™์ž‘์˜ ๋ฉ”์„œ๋“œ๋ฅผ ์ฐพ์Œ.
๊ทธ ํ›„ service๊ฐ„ ๋‹ค์Œ DAO๋กœ ์ด๋™ํ•˜๊ฒŒ๋˜๋ฉด DAO๋Š” mapperํŒŒ์ผ๊ณผ ์—ฐ๊ฒฐ๋˜์–ด ์—ฐ๊ฒฐ๋œ query๋ฌธ์„ ์‹คํ–‰ํ•˜๊ฒŒ ๋˜๊ณ , ๊ทธ ๊ฒฐ๊ณผ๋ฅผ Front๋กœ ๋‹ค์‹œ๋ณด๋ƒ„.

profile
๊นƒํ—ˆ๋ธŒ : github.com/JuneHyung

0๊ฐœ์˜ ๋Œ“๊ธ€