https://github.com/GSM-Backend-Dev-Class/Task.1-2
/api/v1/order/{orderId}
,/api/v1/order/search
API๊ฐ ์ด๋ฏธ ๊ตฌํ๋์ด ์์ต๋๋ค.ํด๋น ์๋ํฌ์ธํธ์ Spring Security์ JJWT ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ด์ฉํ์ฌ JWT ์ธ์ฆ/์ธ๊ฐ๋ฅผ ๊ตฌํํ์ฌ์ฃผ์ธ์global/security
ํจํค์ง ๋ด๋ถ์ domain/auth
ํจํค์ง ๋ด๋ถ๋ง ์์ ํ์ฌ์ฃผ์ธ์
create table member
(
id bigint auto_increment
primary key,
created_at timestamp default CURRENT_TIMESTAMP not null,
updated_at timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP,
address varchar(255) not null,
email varchar(255) not null,
is_adult bit not null,
name varchar(255) not null,
password varchar(255) not null,
phone_number varchar(255) not null,
role enum ('ROLE_ADMIN', 'ROLE_USER') not null
);
create table orders
(
id bigint auto_increment
primary key,
created_at timestamp default CURRENT_TIMESTAMP not null,
updated_at timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP,
address varchar(255) not null,
order_number binary(16) not null,
order_status enum ('CANCELED', 'COMPLETED', 'ORDERED', 'SHIPPING') not null,
total_price bigint not null,
member_id bigint not null,
constraint FK1
foreign key (member_id) references `task-12`.member (id)
);
create table product
(
id bigint auto_increment
primary key,
created_at timestamp default CURRENT_TIMESTAMP not null,
updated_at timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP,
description varchar(255) not null,
image_url varchar(255) not null,
price int not null,
product_name varchar(255) not null,
stock int not null
);
create table orders_order_items
(
order_jpa_entity_id bigint not null,
order_items_id bigint not null,
constraint FK2
foreign key (order_items_id) references product (id),
constraint FK3
foreign key (order_jpa_entity_id) references orders (id)
);
INSERT INTO member (id, name, phone_number, email, password, address, is_adult, role)
VALUES
(1, '๊น์ฒ ์', '010-1234-5678', '[email protected]', 'password123', '์์ธ์ ๊ฐ๋จ๊ตฌ', true, 'ROLE_USER'),
(2, '์ด์ํฌ', '010-2345-6789', '[email protected]', 'password123', '๋ถ์ฐ์ ํด์ด๋๊ตฌ', true, 'ROLE_ADMIN'),
(3, '๋ฐ๋ฏผ์', '010-3456-7890', '[email protected]', 'password123', '๋๊ตฌ์ ์์ฑ๊ตฌ', true, 'ROLE_USER'),
(4, '์ต์งํ', '010-4567-8901', '[email protected]', 'password123', '์ธ์ฒ์ ๋จ๋๊ตฌ', true, 'ROLE_USER'),
(5, '์ ์ฐ์ฑ', '010-5678-9012', '[email protected]', 'password123', '๊ด์ฃผ์ ์๊ตฌ', true, 'ROLE_ADMIN'),
(6, 'ํ๊ฐํฌ', '010-6789-0123', '[email protected]', 'password123', '๋์ ์ ์ ์ฑ๊ตฌ', false, 'ROLE_USER'),
(7, '์ค์ธํ', '010-7890-1234', '[email protected]', 'password123', '์ธ์ฐ์ ๋จ๊ตฌ', true, 'ROLE_USER'),
(8, '๊ฐ์์ง', '010-8901-2345', '[email protected]', 'password123', '๊ฒฝ๊ธฐ๋ ์ฑ๋จ์', true, 'ROLE_USER');
INSERT INTO product (id, product_name, price, stock, description, image_url)
VALUES
(1, '๋ฌด์ ์ด์ดํฐ', 99000, 50, '๊ณ ์์ง ๋ธ๋ฃจํฌ์ค ๋ฌด์ ์ด์ดํฐ', '<https://example.com/earphone.jpg>'),
(2, '๊ฒ์ด๋ฐ ๋ง์ฐ์ค', 45000, 30, 'RGB ์กฐ๋ช
๊ธฐ๋ฅ์ด ์๋ ๊ฒ์ด๋ฐ ๋ง์ฐ์ค', '<https://example.com/mouse.jpg>'),
(3, '๊ธฐ๊ณ์ ํค๋ณด๋', 120000, 20, '์ฒญ์ถ ๊ธฐ๊ณ์ ํค๋ณด๋', '<https://example.com/keyboard.jpg>'),
(4, '์ค๋งํธ์์น', 185000, 15, '๊ฑด๊ฐ ๊ด๋ฆฌ ๊ธฐ๋ฅ์ด ํฌํจ๋ ์ค๋งํธ์์น', '<https://example.com/smartwatch.jpg>'),
(5, '๋ชจ๋ํฐ 27์ธ์น', 300000, 10, '๊ณ ํด์๋ IPS ํจ๋ ๋ชจ๋ํฐ', '<https://example.com/monitor.jpg>'),
(6, '์ธ์ฅ SSD 1TB', 160000, 25, '์ด๊ณ ์ ์ธ์ฅ SSD 1TB', '<https://example.com/ssd.jpg>'),
(7, '๋ฌด์ ์ถฉ์ ๊ธฐ', 35000, 40, '๊ณ ์ ์ถฉ์ ์ ์ง์ํ๋ ๋ฌด์ ์ถฉ์ ๊ธฐ', '<https://example.com/charger.jpg>'),
(8, '๋
ธ์ด์ฆ ์บ์ฌ๋ง ํค๋ํฐ', 250000, 12, '์กํฐ๋ธ ๋
ธ์ด์ฆ ์บ์ฌ๋ง ๊ธฐ๋ฅ ํ์ฌ', '<https://example.com/headphone.jpg>');
INSERT INTO orders (id, member_id, order_number, address, total_price, order_status)
VALUES
(1, 1, UUID_TO_BIN(UUID()), '์์ธ์ ๊ฐ๋จ๊ตฌ', 120000, 'ORDERED'),
(2, 2, UUID_TO_BIN(UUID()), '๋ถ์ฐ์ ํด์ด๋๊ตฌ', 250000, 'COMPLETED'),
(3, 3, UUID_TO_BIN(UUID()), '๋๊ตฌ์ ์์ฑ๊ตฌ', 175000, 'SHIPPING'),
(4, 4, UUID_TO_BIN(UUID()), '์ธ์ฒ์ ๋จ๋๊ตฌ', 98000, 'CANCELED'),
(5, 5, UUID_TO_BIN(UUID()), '๊ด์ฃผ์ ์๊ตฌ', 220000, 'ORDERED'),
(6, 6, UUID_TO_BIN(UUID()), '๋์ ์ ์ ์ฑ๊ตฌ', 320000, 'COMPLETED'),
(7, 7, UUID_TO_BIN(UUID()), '์ธ์ฐ์ ๋จ๊ตฌ', 145000, 'ORDERED'),
(8, 8, UUID_TO_BIN(UUID()), '๊ฒฝ๊ธฐ๋ ์ฑ๋จ์', 210000, 'SHIPPING');
INSERT INTO orders_order_items (order_jpa_entity_id, order_items_id)
VALUES
(1, 1), (1, 3), (1, 5),
(2, 2), (2, 4),
(3, 3), (3, 6), (3, 7),
(4, 1), (4, 5),
(5, 2), (5, 6),
(6, 4), (6, 7),
(7, 3), (7, 8),
(8, 5), (8, 6), (8, 8);