From 88b9628c907440b7de9abdd493e52ced4c1f595f Mon Sep 17 00:00:00 2001 From: SunwuPark Date: Wed, 8 Nov 2023 19:53:34 +0900 Subject: [PATCH 01/15] [#63] UPDATE: LostService --- src/main/java/com/server/mappin/service/ShopService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/server/mappin/service/ShopService.java b/src/main/java/com/server/mappin/service/ShopService.java index b7397b7..ab9b267 100644 --- a/src/main/java/com/server/mappin/service/ShopService.java +++ b/src/main/java/com/server/mappin/service/ShopService.java @@ -10,4 +10,9 @@ @Transactional(readOnly = true) public class ShopService { private final ShopRepository shopRepository; + + @Transactional + public ShopRegisterResponseDto shopRegister() { + + } } From 21db80bc9d23ad2068f4b3d88052016abbb845af Mon Sep 17 00:00:00 2001 From: SunwuPark Date: Wed, 8 Nov 2023 20:15:55 +0900 Subject: [PATCH 02/15] UPDATE: application.yml create -> update --- src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index eff3ae7..9fa79c0 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -25,7 +25,7 @@ spring: charset: UTF-8 hibernate: - ddl-auto : create + ddl-auto : update properties: hibernate : #show_sql : true #??? ??? ?? From eefe1f2707cd114fe5107016ad7804e33f54a5e2 Mon Sep 17 00:00:00 2001 From: SunwuPark Date: Wed, 8 Nov 2023 20:16:13 +0900 Subject: [PATCH 03/15] UPDATE: docker.yml uppercase --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 0a6080a..20732bd 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -98,8 +98,8 @@ jobs: echo "KAKAO_CLIENT=${{ secrets.KAKAO_CLIENT }}" >> ~/.env echo "KAKAO_SECRET=${{ secrets.KAKAO_SECRET }}" >> ~/.env echo "KAKAO_REST_API_KEY=${{ secrets.KAKAO_REST_API_KEY }}" >> ~/.env - echo "S3AccessKey=${{ secrets.S3ACCESSKEY }}" >> ~/.env - echo "S3SecretKey=${{ secrets.S3SECRETKEY }}" >> ~/.env + echo "S3ACCESSKEY=${{ secrets.S3ACCESSKEY }}" >> ~/.env + echo "S3SECRETKEY=${{ secrets.S3SECRETKEY }}" >> ~/.env # Copy .env file to the project directory #cp ~/.env /home/ubuntu/.env From cabc35bc677221e6605e8aa2a4f3bcf969323913 Mon Sep 17 00:00:00 2001 From: SunwuPark Date: Thu, 9 Nov 2023 01:12:32 +0900 Subject: [PATCH 04/15] =?UTF-8?q?Update:=20LostService=20=ED=98=84?= =?UTF-8?q?=EC=9E=AC=20=EC=9C=84=EC=B9=98=20=EA=B8=B0=EB=B0=98=20=EC=B0=BE?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/mappin/service/LostService.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/server/mappin/service/LostService.java b/src/main/java/com/server/mappin/service/LostService.java index 0c236ff..92dc4bd 100644 --- a/src/main/java/com/server/mappin/service/LostService.java +++ b/src/main/java/com/server/mappin/service/LostService.java @@ -75,7 +75,7 @@ public FindByShopListResponseDto findByShop(String shopName) { .build(); } - public FindByDongListResponseDto findByCurrentLocation(Double x, Double y) { + /*public FindByDongListResponseDto findByCurrentLocation(Double x, Double y) { String dong = mapService.getDong(x, y); Optional locationByDong = locationRepository.findLocationByDong(dong); if (locationByDong.isPresent()) { @@ -84,6 +84,24 @@ public FindByDongListResponseDto findByCurrentLocation(Double x, Double y) { } return null; } + */ + + public FindByDongListResponseDto findByCurrentLocation(Double x, Double y) { + List locationByDong = lostRepository.findAll(); + return FindByDongListResponseDto.builder() + .statusCode(200) + .isSuccess("true") + .losts(locationByDong.stream().map(lost -> FindByDongResponseDto.builder() + .id(lost.getId()) + .title(lost.getTitle()) + .createdAt(lost.getCreatedAt()) + .imageUrl(lost.getImageUrl()) + .build()) + .collect(Collectors.toList())) + .build(); + } + + @Transactional public LostRegisterResponseDto registerLost(LostRegisterRequestDto lostRegisterRequestDto, MultipartFile image, String email) throws IOException { From 549a397f94e026d63c3b50062670faedbcd0855e Mon Sep 17 00:00:00 2001 From: SunwuPark Date: Thu, 9 Nov 2023 01:26:38 +0900 Subject: [PATCH 05/15] =?UTF-8?q?Update:=20Shop=20companyNumber=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/server/mappin/domain/Shop.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/server/mappin/domain/Shop.java b/src/main/java/com/server/mappin/domain/Shop.java index 543aee1..27ce515 100644 --- a/src/main/java/com/server/mappin/domain/Shop.java +++ b/src/main/java/com/server/mappin/domain/Shop.java @@ -27,6 +27,9 @@ public class Shop { @Column(name = "address") private String address; + @Column(name = "companyNumber") + private String companyNumber; + @ManyToOne @JoinColumn(name = "member_id") private Member member; @@ -36,11 +39,12 @@ public class Shop { private Location location; @Builder - public Shop(String name, Integer point, String address, Member member, Location location) { + public Shop(String name, Integer point, String address, Member member, Location location, String companyNumber) { this.name = name; this.point = point; this.address = address; this.member = member; this.location = location; + this.companyNumber = companyNumber; } } From 4ee0864dd7fec8ab19eecf0f6e8373cce380625c Mon Sep 17 00:00:00 2001 From: SunwuPark Date: Thu, 9 Nov 2023 01:26:56 +0900 Subject: [PATCH 06/15] =?UTF-8?q?Update:=20Shop=20=EB=93=B1=EB=A1=9D=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/mappin/service/ShopService.java | 51 ++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/server/mappin/service/ShopService.java b/src/main/java/com/server/mappin/service/ShopService.java index ab9b267..52ea68d 100644 --- a/src/main/java/com/server/mappin/service/ShopService.java +++ b/src/main/java/com/server/mappin/service/ShopService.java @@ -1,18 +1,67 @@ package com.server.mappin.service; +import com.server.mappin.domain.Location; +import com.server.mappin.domain.Member; +import com.server.mappin.domain.Shop; +import com.server.mappin.dto.ShopRegisterRequestDto; +import com.server.mappin.dto.ShopRegisterResponseDto; +import com.server.mappin.repository.LocationRepository; +import com.server.mappin.repository.MemberRepository; import com.server.mappin.repository.ShopRepository; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.geo.Point; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import java.util.Optional; @Service +@Slf4j @RequiredArgsConstructor @Transactional(readOnly = true) public class ShopService { private final ShopRepository shopRepository; + private final MemberRepository memberRepository; + private final LocationRepository locationRepository; + private final MapService mapService; @Transactional - public ShopRegisterResponseDto shopRegister() { + public ShopRegisterResponseDto shopRegister(ShopRegisterRequestDto shopRegisterRequestDto, String email) { + Optional memberByEmail = memberRepository.findByEmail(email); + Point point = mapService.GetLocalInfo(shopRegisterRequestDto.getAddress()); + String dong = mapService.getDong(point.getX(), point.getY()); + Optional locationByDong = locationRepository.findLocationByDong(dong); + + System.out.println("memberByEmail = " + memberByEmail); + System.out.println("locationByDong = " + locationByDong); + if (memberByEmail.isPresent() && locationByDong.isPresent()) { + Member member = memberByEmail.get(); + Shop shop = Shop.builder() + .member(member) + .name(shopRegisterRequestDto.getName()) + .address(shopRegisterRequestDto.getAddress()) + .location(locationByDong.get()) + .point(50) + .companyNumber(shopRegisterRequestDto.getCompanyNumber()) + .build(); + Shop save = shopRepository.save(shop); + return ShopRegisterResponseDto.builder() + .shopId(save.getId()) + .memberId(member.getId()) + .name(save.getName()) + .address(save.getAddress()) + .dong(dong) + .companyNumber(save.getCompanyNumber()) + .isSuccess("true") + .statusCode(200) + .build(); + } + return ShopRegisterResponseDto.builder() + .isSuccess("false") + .statusCode(400) + .build(); } } From 65b3ec1dd845d21cf5a7c919f960a8fa0f48b431 Mon Sep 17 00:00:00 2001 From: SunwuPark Date: Thu, 9 Nov 2023 01:27:15 +0900 Subject: [PATCH 07/15] =?UTF-8?q?Add:=20ShopController=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mappin/controller/ShopController.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/main/java/com/server/mappin/controller/ShopController.java diff --git a/src/main/java/com/server/mappin/controller/ShopController.java b/src/main/java/com/server/mappin/controller/ShopController.java new file mode 100644 index 0000000..91a961b --- /dev/null +++ b/src/main/java/com/server/mappin/controller/ShopController.java @@ -0,0 +1,47 @@ +package com.server.mappin.controller; + +import com.server.mappin.dto.LostRegisterRequestDto; +import com.server.mappin.dto.LostRegisterResponseDto; +import com.server.mappin.dto.ShopRegisterRequestDto; +import com.server.mappin.dto.ShopRegisterResponseDto; +import com.server.mappin.service.ShopService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.security.core.Authentication; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; + +@Tag(name = "Shop API", description = "분실물 관련 API 명세서") +@RestController +@Slf4j +@RequiredArgsConstructor +public class ShopController { + private final ShopService shopService; + + @Operation(summary = "가게 등록", description = "application/json입니다") + @ApiResponse(content = @Content(schema = @Schema(implementation = ShopRegisterResponseDto.class))) + @PutMapping(value = "/shop/register") + public ResponseEntity registerLost( + @RequestBody ShopRegisterRequestDto shopRegisterRequestDto, + Authentication authentication) throws IOException { + try { + ShopRegisterResponseDto shopRegisterResponseDto = shopService.shopRegister(shopRegisterRequestDto, authentication.getName()); + return new ResponseEntity<>(shopRegisterResponseDto, HttpStatus.OK); + } catch (IllegalStateException e) { + return new ResponseEntity<>("에러가 발생했습니다", HttpStatus.CONFLICT); + } + } +} From 028321732059508c852baa81cc75c9ae00c9454c Mon Sep 17 00:00:00 2001 From: SunwuPark Date: Thu, 9 Nov 2023 01:27:26 +0900 Subject: [PATCH 08/15] Add: shopRegisterRequestDto --- .../server/mappin/dto/ShopRegisterRequestDto.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/java/com/server/mappin/dto/ShopRegisterRequestDto.java diff --git a/src/main/java/com/server/mappin/dto/ShopRegisterRequestDto.java b/src/main/java/com/server/mappin/dto/ShopRegisterRequestDto.java new file mode 100644 index 0000000..f56f1c5 --- /dev/null +++ b/src/main/java/com/server/mappin/dto/ShopRegisterRequestDto.java @@ -0,0 +1,13 @@ +package com.server.mappin.dto; + +import lombok.Builder; +import lombok.Data; +import lombok.Getter; + +@Getter +public class ShopRegisterRequestDto { + private String name; + private String address; + private String companyNumber; + +} From 99425728c993e657f30de0897e83677dd19431f1 Mon Sep 17 00:00:00 2001 From: SunwuPark Date: Thu, 9 Nov 2023 01:27:38 +0900 Subject: [PATCH 09/15] Add: ShopRegisterResponseDto --- .../mappin/dto/ShopRegisterResponseDto.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/main/java/com/server/mappin/dto/ShopRegisterResponseDto.java diff --git a/src/main/java/com/server/mappin/dto/ShopRegisterResponseDto.java b/src/main/java/com/server/mappin/dto/ShopRegisterResponseDto.java new file mode 100644 index 0000000..cb3604a --- /dev/null +++ b/src/main/java/com/server/mappin/dto/ShopRegisterResponseDto.java @@ -0,0 +1,20 @@ +package com.server.mappin.dto; + +import lombok.Builder; +import lombok.Data; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +@Data +@Builder +public class ShopRegisterResponseDto { + private int statusCode; + private String isSuccess; + private Long memberId; + private Long shopId; + private String dong; + private String name; + private String address; + private String companyNumber; +} From f6f8c2c6cef6e0cfa348e7372ca2c14b4a9fec9a Mon Sep 17 00:00:00 2001 From: SunwuPark Date: Thu, 9 Nov 2023 01:33:37 +0900 Subject: [PATCH 10/15] =?UTF-8?q?Add:=20sout=20=EC=A7=80=EC=9A=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/server/mappin/service/ShopService.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/server/mappin/service/ShopService.java b/src/main/java/com/server/mappin/service/ShopService.java index 52ea68d..4bda58b 100644 --- a/src/main/java/com/server/mappin/service/ShopService.java +++ b/src/main/java/com/server/mappin/service/ShopService.java @@ -34,9 +34,6 @@ public ShopRegisterResponseDto shopRegister(ShopRegisterRequestDto shopRegisterR String dong = mapService.getDong(point.getX(), point.getY()); Optional locationByDong = locationRepository.findLocationByDong(dong); - System.out.println("memberByEmail = " + memberByEmail); - System.out.println("locationByDong = " + locationByDong); - if (memberByEmail.isPresent() && locationByDong.isPresent()) { Member member = memberByEmail.get(); Shop shop = Shop.builder() From 55ea9fd4f574dc0ddc9b1dbc7970417e50378d9b Mon Sep 17 00:00:00 2001 From: SunwuPark Date: Thu, 9 Nov 2023 01:36:43 +0900 Subject: [PATCH 11/15] =?UTF-8?q?UPDATE:=20=EC=8A=A4=EC=9B=A8=EA=B1=B0=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/server/mappin/controller/LostController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/server/mappin/controller/LostController.java b/src/main/java/com/server/mappin/controller/LostController.java index cebd5c3..a2eb3d6 100644 --- a/src/main/java/com/server/mappin/controller/LostController.java +++ b/src/main/java/com/server/mappin/controller/LostController.java @@ -77,7 +77,7 @@ public ResponseEntity searchByCategory(@RequestParam(value = "category") Stri } @Operation(summary = "동 검색", description = "분실물을 동 별로 검색") - @ApiResponse(content = @Content(schema = @Schema(implementation = FindByDongResponseDto.class))) + @ApiResponse(content = @Content(schema = @Schema(implementation = FindByDongListResponseDto.class))) @GetMapping("lost/search/dong") public ResponseEntity searchByDong(@RequestParam(value = "name") String dongName) { try { @@ -89,7 +89,7 @@ public ResponseEntity searchByDong(@RequestParam(value = "name") String dongN } @Operation(summary = "가게 검색", description = "분실물을 가게이름 별로 검색") - @ApiResponse(content = @Content(schema = @Schema(implementation = FindByShopResponseDto.class))) + @ApiResponse(content = @Content(schema = @Schema(implementation = FindByShopListResponseDto.class))) @GetMapping("lost/search/shop") public ResponseEntity searchByShop(@RequestParam(value = "name") String shopName) { try { From 5736bfa95691883cb1a28994be59d61e7d666726 Mon Sep 17 00:00:00 2001 From: SunwuPark Date: Thu, 9 Nov 2023 01:46:08 +0900 Subject: [PATCH 12/15] =?UTF-8?q?UPDATE:=20role=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/server/mappin/dto/MemberLoginDto.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/server/mappin/dto/MemberLoginDto.java b/src/main/java/com/server/mappin/dto/MemberLoginDto.java index 2f040f8..5b470fc 100644 --- a/src/main/java/com/server/mappin/dto/MemberLoginDto.java +++ b/src/main/java/com/server/mappin/dto/MemberLoginDto.java @@ -6,6 +6,5 @@ @Data public class MemberLoginDto { private String email; - private Role role; private String name; } From 80aba19d6a93dba3c842c8838ecfb0ebababe5d0 Mon Sep 17 00:00:00 2001 From: SunwuPark Date: Thu, 9 Nov 2023 01:46:25 +0900 Subject: [PATCH 13/15] =?UTF-8?q?UPDATE:=20MemberService=20role=20USER=20?= =?UTF-8?q?=EA=B8=B0=EB=B3=B8=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/server/mappin/service/MemberService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/server/mappin/service/MemberService.java b/src/main/java/com/server/mappin/service/MemberService.java index d9bf98d..46d77ac 100644 --- a/src/main/java/com/server/mappin/service/MemberService.java +++ b/src/main/java/com/server/mappin/service/MemberService.java @@ -43,7 +43,7 @@ public LoginResponseDto login(MemberLoginDto memberCreateDto) { } else { Member member = new Member(); member.setEmail(memberCreateDto.getEmail()); - member.setRole(memberCreateDto.getRole()); + member.setRole(Role.USER); member.setName(memberCreateDto.getName()); member.setCreatedAt(LocalDate.now()); member.setProviderType(ProviderType.KAKAO); From 8e1017fbf7e1a4f1d76e4c17a38c33991038ba19 Mon Sep 17 00:00:00 2001 From: SunwuPark Date: Thu, 9 Nov 2023 01:46:41 +0900 Subject: [PATCH 14/15] =?UTF-8?q?UPDATE:=20ShopService=20role=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=ED=95=98=EB=8A=94=20=EC=BD=94=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/server/mappin/service/ShopService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/server/mappin/service/ShopService.java b/src/main/java/com/server/mappin/service/ShopService.java index 4bda58b..60422a5 100644 --- a/src/main/java/com/server/mappin/service/ShopService.java +++ b/src/main/java/com/server/mappin/service/ShopService.java @@ -3,6 +3,7 @@ import com.server.mappin.domain.Location; import com.server.mappin.domain.Member; import com.server.mappin.domain.Shop; +import com.server.mappin.domain.enums.Role; import com.server.mappin.dto.ShopRegisterRequestDto; import com.server.mappin.dto.ShopRegisterResponseDto; import com.server.mappin.repository.LocationRepository; @@ -36,6 +37,7 @@ public ShopRegisterResponseDto shopRegister(ShopRegisterRequestDto shopRegisterR if (memberByEmail.isPresent() && locationByDong.isPresent()) { Member member = memberByEmail.get(); + member.setRole(Role.OWNER); Shop shop = Shop.builder() .member(member) .name(shopRegisterRequestDto.getName()) @@ -44,10 +46,11 @@ public ShopRegisterResponseDto shopRegister(ShopRegisterRequestDto shopRegisterR .point(50) .companyNumber(shopRegisterRequestDto.getCompanyNumber()) .build(); + Member save1 = memberRepository.save(member); Shop save = shopRepository.save(shop); return ShopRegisterResponseDto.builder() .shopId(save.getId()) - .memberId(member.getId()) + .memberId(save1.getId()) .name(save.getName()) .address(save.getAddress()) .dong(dong) From febab91cccfca0d0bd58489d220992a7b06b08fa Mon Sep 17 00:00:00 2001 From: SunwuPark Date: Thu, 9 Nov 2023 12:37:16 +0900 Subject: [PATCH 15/15] =?UTF-8?q?UPDATE:=20ShopController=20=EA=B0=80?= =?UTF-8?q?=EA=B2=8C=20=EA=B4=80=EB=A0=A8=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/server/mappin/controller/ShopController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/server/mappin/controller/ShopController.java b/src/main/java/com/server/mappin/controller/ShopController.java index 91a961b..3e7ea4c 100644 --- a/src/main/java/com/server/mappin/controller/ShopController.java +++ b/src/main/java/com/server/mappin/controller/ShopController.java @@ -24,7 +24,7 @@ import java.io.IOException; -@Tag(name = "Shop API", description = "분실물 관련 API 명세서") +@Tag(name = "Shop API", description = "가게 관련 API 명세서") @RestController @Slf4j @RequiredArgsConstructor