-
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.
Merge branch 'main' of https://github.com/goormthon-Univ/2024_BEOTKKO…
…TTHON_TEAM_32_BE into develope
- Loading branch information
Showing
20 changed files
with
392 additions
and
17 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,12 @@ | ||
package site.balpyo.ai.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
|
||
public class AIGenerateResponse { | ||
private Object resultScript; | ||
private String gptId; | ||
} |
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
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
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(); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
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,29 @@ | ||
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.common.dto.ErrorEnum; | ||
import site.balpyo.common.util.CommonUtils; | ||
import site.balpyo.guest.service.GuestService; | ||
|
||
@RestController | ||
@CrossOrigin | ||
@RequiredArgsConstructor | ||
@RequestMapping("/guest/manage") | ||
public class GuestController { | ||
|
||
private final GuestService guestService; | ||
@PostMapping("/uid") | ||
public ResponseEntity<CommonResponse> generateUniqueIdentifier(){ | ||
return guestService.generateUID(); | ||
} | ||
|
||
@GetMapping("/uid") | ||
public ResponseEntity<CommonResponse> verifyUID( @RequestHeader(value = "UID", required = false) String uid){ | ||
if(CommonUtils.isAnyParameterNullOrBlank(uid))return CommonResponse.error(ErrorEnum.BALPYO_UID_KEY_MISSING); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package site.balpyo.guest.entity; | ||
|
||
import lombok.*; | ||
import org.hibernate.annotations.CreationTimestamp; | ||
import site.balpyo.ai.entity.AIGenerateLogEntity; | ||
import site.balpyo.script.entity.ScriptEntity; | ||
|
||
import javax.persistence.*; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@Getter | ||
@Setter | ||
@Entity | ||
@Table(name = "guest") | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class GuestEntity { | ||
|
||
@Id | ||
private String uid; | ||
|
||
@CreationTimestamp | ||
private LocalDateTime createdAt; | ||
|
||
@OneToMany(mappedBy = "guestEntity", cascade = CascadeType.ALL) | ||
private List<AIGenerateLogEntity> aiGenerateLogEntities; | ||
|
||
@OneToMany(mappedBy = "guestEntity", cascade = CascadeType.ALL) | ||
private List<ScriptEntity> scriptEntities; | ||
|
||
} |
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)); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/site/balpyo/script/controller/EveryScriptController.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,28 @@ | ||
package site.balpyo.script.controller; | ||
|
||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import site.balpyo.common.dto.CommonResponse; | ||
import site.balpyo.common.dto.ErrorEnum; | ||
import site.balpyo.common.util.CommonUtils; | ||
import site.balpyo.script.dto.ScriptRequest; | ||
import site.balpyo.script.service.ScriptService; | ||
|
||
@RestController | ||
@CrossOrigin | ||
@RequiredArgsConstructor | ||
@RequestMapping("/every/manage") | ||
public class EveryScriptController { | ||
|
||
private final ScriptService scriptService; | ||
|
||
@PostMapping("/script") | ||
public ResponseEntity<CommonResponse> saveScript(@RequestBody ScriptRequest scriptRequest, | ||
@RequestHeader(value = "UID", required = false) String uid){ | ||
|
||
if(CommonUtils.isAnyParameterNullOrBlank(uid))return CommonResponse.error(ErrorEnum.BALPYO_UID_KEY_MISSING); | ||
return scriptService.saveScript(scriptRequest,uid); | ||
} | ||
} |
Oops, something went wrong.