Skip to content

Commit aa45e75

Browse files
committed
Entity ID를 숫자가 아니라 문자열로 변경
1 parent 44aae8c commit aa45e75

25 files changed

+70
-70
lines changed

20221213/spring/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Spring Boot Shop Demo

20221213/spring/src/main/java/com/example/demo/DemoApplication.java renamed to 20221213/spring/src/main/java/com/ahastudio/demo/shop/DemoApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.demo;
1+
package com.ahastudio.demo.shop;
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;

20221213/spring/src/main/java/com/example/demo/config/ModelMapperConfig.java renamed to 20221213/spring/src/main/java/com/ahastudio/demo/shop/config/ModelMapperConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.demo.config;
1+
package com.ahastudio.demo.shop.config;
22

33
import org.springframework.context.annotation.Bean;
44
import org.springframework.context.annotation.Configuration;

20221213/spring/src/main/java/com/example/demo/controllers/BackdoorController.java renamed to 20221213/spring/src/main/java/com/ahastudio/demo/shop/controllers/BackdoorController.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
package com.example.demo.controllers;
1+
package com.ahastudio.demo.shop.controllers;
22

33
import java.time.LocalDateTime;
44

55
import jakarta.transaction.Transactional;
66

77
import org.springframework.jdbc.core.JdbcTemplate;
8+
import org.springframework.ui.Model;
89
import org.springframework.web.bind.annotation.GetMapping;
910
import org.springframework.web.bind.annotation.RequestMapping;
1011
import org.springframework.web.bind.annotation.RestController;
@@ -21,6 +22,8 @@ public BackdoorController(JdbcTemplate jdbcTemplate) {
2122

2223
@GetMapping("setup-database")
2324
public String setupDatabase() {
25+
Model model;
26+
2427
jdbcTemplate.execute("DELETE FROM products");
2528
jdbcTemplate.execute("DELETE FROM shops");
2629

@@ -39,7 +42,7 @@ INSERT INTO shops(
3942
) VALUES(?, ?, ?, ?)
4043
""";
4144

42-
jdbcTemplate.update(sql, 101L, "BestShop", now, now);
45+
jdbcTemplate.update(sql, "00010001", "BestShop", now, now);
4346
}
4447

4548
private void createProducts() {
@@ -51,6 +54,6 @@ INSERT INTO products(
5154
) VALUES(?, ?, ?, ?, ?)
5255
""";
5356

54-
jdbcTemplate.update(sql, 201L, "Bread", 10_000L, now, now);
57+
jdbcTemplate.update(sql, "00020001", "Bread", 10_000L, now, now);
5558
}
5659
}

20221213/spring/src/main/java/com/example/demo/controllers/ProductController.java renamed to 20221213/spring/src/main/java/com/ahastudio/demo/shop/controllers/ProductController.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.demo.controllers;
1+
package com.ahastudio.demo.shop.controllers;
22

33
import java.util.List;
44

@@ -12,12 +12,12 @@
1212

1313
import org.modelmapper.ModelMapper;
1414

15-
import com.example.demo.controllers.dtos.ProductDetailDto;
16-
import com.example.demo.controllers.dtos.ProductListDto;
17-
import com.example.demo.exceptions.ProductNotFound;
18-
import com.example.demo.models.Product;
19-
import com.example.demo.models.ProductId;
20-
import com.example.demo.repositories.ProductRepository;
15+
import com.ahastudio.demo.shop.controllers.dtos.ProductDetailDto;
16+
import com.ahastudio.demo.shop.controllers.dtos.ProductListDto;
17+
import com.ahastudio.demo.shop.exceptions.ProductNotFound;
18+
import com.ahastudio.demo.shop.models.Product;
19+
import com.ahastudio.demo.shop.models.ProductId;
20+
import com.ahastudio.demo.shop.repositories.ProductRepository;
2121

2222
@RestController
2323
@RequestMapping("/products")
@@ -41,7 +41,7 @@ public ProductListDto list() {
4141
}
4242

4343
@GetMapping("/{id}")
44-
public ProductDetailDto detail(@PathVariable Long id) {
44+
public ProductDetailDto detail(@PathVariable String id) {
4545
Product product = productRepository.findById(new ProductId(id))
4646
.orElseThrow(ProductNotFound::new);
4747

20221213/spring/src/main/java/com/example/demo/controllers/ShopController.java renamed to 20221213/spring/src/main/java/com/ahastudio/demo/shop/controllers/ShopController.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.demo.controllers;
1+
package com.ahastudio.demo.shop.controllers;
22

33
import java.util.List;
44

@@ -12,12 +12,12 @@
1212

1313
import org.modelmapper.ModelMapper;
1414

15-
import com.example.demo.controllers.dtos.ShopDetailDto;
16-
import com.example.demo.controllers.dtos.ShopListDto;
17-
import com.example.demo.exceptions.ShopNotFound;
18-
import com.example.demo.models.Shop;
19-
import com.example.demo.models.ShopId;
20-
import com.example.demo.repositories.ShopRepository;
15+
import com.ahastudio.demo.shop.controllers.dtos.ShopDetailDto;
16+
import com.ahastudio.demo.shop.controllers.dtos.ShopListDto;
17+
import com.ahastudio.demo.shop.exceptions.ShopNotFound;
18+
import com.ahastudio.demo.shop.models.Shop;
19+
import com.ahastudio.demo.shop.models.ShopId;
20+
import com.ahastudio.demo.shop.repositories.ShopRepository;
2121

2222
@RestController
2323
@RequestMapping("/shops")
@@ -41,7 +41,7 @@ public ShopListDto list() {
4141
}
4242

4343
@GetMapping("/{id}")
44-
public ShopDetailDto detail(@PathVariable Long id) {
44+
public ShopDetailDto detail(@PathVariable String id) {
4545
Shop shop = shopRepository.findById(new ShopId(id))
4646
.orElseThrow(ShopNotFound::new);
4747

20221213/spring/src/main/java/com/example/demo/controllers/dtos/ProductDetailDto.java renamed to 20221213/spring/src/main/java/com/ahastudio/demo/shop/controllers/dtos/ProductDetailDto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.demo.controllers.dtos;
1+
package com.ahastudio.demo.shop.controllers.dtos;
22

33
import lombok.Getter;
44

20221213/spring/src/main/java/com/example/demo/controllers/dtos/ProductListDto.java renamed to 20221213/spring/src/main/java/com/ahastudio/demo/shop/controllers/dtos/ProductListDto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.demo.controllers.dtos;
1+
package com.ahastudio.demo.shop.controllers.dtos;
22

33
import java.util.List;
44

20221213/spring/src/main/java/com/example/demo/controllers/dtos/ShopDetailDto.java renamed to 20221213/spring/src/main/java/com/ahastudio/demo/shop/controllers/dtos/ShopDetailDto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.demo.controllers.dtos;
1+
package com.ahastudio.demo.shop.controllers.dtos;
22

33
import lombok.Getter;
44

20221213/spring/src/main/java/com/example/demo/controllers/dtos/ShopListDto.java renamed to 20221213/spring/src/main/java/com/ahastudio/demo/shop/controllers/dtos/ShopListDto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.demo.controllers.dtos;
1+
package com.ahastudio.demo.shop.controllers.dtos;
22

33
import java.util.List;
44

0 commit comments

Comments
 (0)