Skip to content

Commit

Permalink
fix: dummy service 로케이션에 맞게 더미 생성 로직 수정 (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
lvalentine6 committed Nov 13, 2023
2 parents b477c31 + 2680d0d commit 47ae307
Show file tree
Hide file tree
Showing 3 changed files with 325 additions and 321 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public class DummyController {

@GetMapping
public ResponseDto<?> creatDummy() {
log.info("더미호출");
dummyService.creatDummy();
log.info("더미 호출");
dummyService.createDummy();
return ResponseDto.of(RESPONSE_SUCCESS, null);
}
}
44 changes: 24 additions & 20 deletions be/src/main/java/codesquad/secondhand/service/DummyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,41 @@

import codesquad.secondhand.dto.item.ItemDetailDto;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Service
@RequiredArgsConstructor
@Slf4j
public class DummyService {

private final ItemService itemService;

public void creatDummy() {
public void createDummy() {
Random random = new Random();
for (int i = 1; i <= 10; i++) {
Long randomMemberIdx = (long) random.nextInt(5) + 1;
int randomImageNumber = random.nextInt(10);
String randomImageURL = "https://codesquadsecondhandteam01.s3.ap-northeast-2.amazonaws.com/dummy-image/"
+ randomImageNumber + ".jpg";
Faker faker = new Faker(new Locale("ko"));
for (int i = 1; i <= 6; i++) {
for (int j = 0; j < 20; j++) {
Long randomMemberIdx = (long)random.nextInt(5) + 1;
int randomImageNumber = random.nextInt(10);
String randomImageURL = "https://codesquadsecondhandteam01.s3.ap-northeast-2.amazonaws.com/dummy-image/"
+ randomImageNumber + ".jpg";

Faker faker = new Faker(new Locale("ko"));
List<MultipartFile> list = new ArrayList<>();
list.add(downloadImageAsMultipartFile(randomImageURL, "tempImageName"));

List<MultipartFile> list = new ArrayList<>();
list.add(downloadImageAsMultipartFile(randomImageURL, "tempImageName"));
ItemDetailDto itemDetailDto = new ItemDetailDto(
faker.lorem().sentence(),
faker.number().randomDigitNotZero() * 1000,
faker.lorem().sentence(),
(long)i,
(long)faker.number().numberBetween(1, 18),
list,
"판매중",
randomMemberIdx);

ItemDetailDto itemDetailDto = new ItemDetailDto(
faker.commerce().productName(),
faker.number().randomDigitNotZero() * 1000,
faker.lorem().sentence(),
(long)faker.number().numberBetween(1, 6),
(long)faker.number().numberBetween(1, 18),
list,
"판매중",
randomMemberIdx);

itemService.creatItem(itemDetailDto);
itemService.creatItem(itemDetailDto);
log.info("더미 작업 완료");
}
}
}

Expand Down

0 comments on commit 47ae307

Please sign in to comment.