-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
130 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package site.balpyo.common.util; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.stereotype.Service; | ||
import site.balpyo.guest.entity.GuestEntity; | ||
import site.balpyo.guest.repository.GuestRepository; | ||
|
||
import java.util.Optional; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class GuestUtils { | ||
|
||
public static boolean verifyUID(String uid, GuestRepository guestRepository){ | ||
Optional<GuestEntity> guestEntity = guestRepository.findById(uid); | ||
return guestEntity.isPresent(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/site/balpyo/guest/controller/GuestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package site.balpyo.guest.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import site.balpyo.common.dto.CommonResponse; | ||
import site.balpyo.guest.service.GuestService; | ||
|
||
@RestController | ||
@CrossOrigin | ||
@RequiredArgsConstructor | ||
@RequestMapping("/guest") | ||
public class GuestController { | ||
|
||
private final GuestService guestService; | ||
@PostMapping("/uid") | ||
public ResponseEntity<CommonResponse> generateUniqueIdentifier(){ | ||
return guestService.generateUID(); | ||
} | ||
|
||
@GetMapping("/uid") | ||
public ResponseEntity<CommonResponse> verifyUID(@RequestParam String uid){ | ||
return guestService.verifyUID(uid); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package site.balpyo.guest.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public class UIDResponse { | ||
|
||
private String uid; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package site.balpyo.guest.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
@AllArgsConstructor | ||
@Data | ||
public class VerifyResponse { | ||
boolean isVerified; | ||
String yourUID; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/java/site/balpyo/guest/repository/GuestRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package site.balpyo.guest.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import site.balpyo.guest.entity.GuestEntity; | ||
|
||
public interface GuestRepository extends JpaRepository<GuestEntity, String> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package site.balpyo.guest.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Service; | ||
import site.balpyo.common.dto.CommonResponse; | ||
import site.balpyo.common.util.GuestUtils; | ||
import site.balpyo.guest.dto.UIDResponse; | ||
import site.balpyo.guest.dto.VerifyResponse; | ||
import site.balpyo.guest.entity.GuestEntity; | ||
import site.balpyo.guest.repository.GuestRepository; | ||
|
||
import java.util.UUID; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class GuestService { | ||
|
||
private final GuestRepository guestRepository; | ||
public ResponseEntity<CommonResponse> generateUID(){ | ||
UUID uuid = UUID.randomUUID(); | ||
String uuidString = uuid.toString(); | ||
|
||
GuestEntity guestEntity = GuestEntity.builder() | ||
.uid(uuidString) | ||
.build(); | ||
guestRepository.save(guestEntity); | ||
|
||
return CommonResponse.success(new UIDResponse(uuidString)); | ||
} | ||
|
||
public ResponseEntity<CommonResponse> verifyUID(String uid) { | ||
boolean isVerified = GuestUtils.verifyUID(uid,guestRepository); | ||
|
||
return CommonResponse.success(new VerifyResponse(isVerified,uid)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package site.balpyo.script.dto; | ||
|
||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public class ScriptRequest { | ||
private String script; | ||
private String gptId; | ||
private String title; | ||
private Integer secTime; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
src/main/java/site/balpyo/user/repository/GuestRepository.java
This file was deleted.
Oops, something went wrong.