-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of https://github.com/DCNJ-Uket/Uket-BE into admin
# Conflicts: # application/ticket-app-api/src/main/java/com/uket/app/ticket/api/controller/impl/TicketController.java # application/ticket-app-api/src/main/java/com/uket/app/ticket/api/controller/impl/UserController.java # core/src/main/java/com/uket/core/exception/ErrorCode.java # domain/form-domain/src/main/java/com/uket/domain/form/dto/FormDto.java # domain/form-domain/src/main/java/com/uket/domain/form/dto/OptionDto.java # domain/form-domain/src/main/java/com/uket/domain/form/entity/Form.java # domain/form-domain/src/main/java/com/uket/domain/form/repository/AnswerRepository.java # domain/form-domain/src/main/java/com/uket/domain/form/service/FormService.java # domain/ticket-domain/src/main/java/com/uket/domain/ticket/dto/CheckTicketDto.java # domain/ticket-domain/src/main/java/com/uket/domain/ticket/repository/TicketRepository.java # domain/ticket-domain/src/main/java/com/uket/domain/ticket/service/TicketService.java
- Loading branch information
Showing
41 changed files
with
670 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
* @0703kyj @sam971114 | ||
* @0703kyj @sam971114 @nonaninona |
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
66 changes: 66 additions & 0 deletions
66
application/ticket-app-api/src/main/java/com/uket/app/ticket/api/controller/TermsApi.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,66 @@ | ||
package com.uket.app.ticket.api.controller; | ||
|
||
import com.uket.app.ticket.api.dto.request.TermsAgreementRequest; | ||
import com.uket.app.ticket.api.dto.response.ListResponse; | ||
import com.uket.app.ticket.api.dto.response.TermsAgreementResponse; | ||
import com.uket.app.ticket.api.dto.response.TermsResponse; | ||
import com.uket.core.dto.response.ErrorResponse; | ||
import com.uket.domain.auth.config.userid.LoginUserId; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.ExampleObject; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import java.util.List; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Tag(name = "약관 API", description = "약관 관련 API") | ||
@RestController | ||
@SecurityRequirement(name = "JWT") | ||
@ApiResponse(responseCode = "200", description = "OK") | ||
public interface TermsApi { | ||
|
||
@GetMapping("/api/v1/terms") | ||
@Operation(summary = "약관 목록 조회 API", description = "회원가입 시 필요한 약관 목록을 조회할 수 있습니다.") | ||
ResponseEntity<ListResponse<TermsResponse>> getTerms( | ||
@LoginUserId | ||
@Parameter(hidden = true) | ||
Long userId | ||
); | ||
|
||
@PostMapping("/api/v1/terms/agreement") | ||
@Operation(summary = "약관 동의 API", description = "회원가입 시 약관 동의를 할 수 있습니다.") | ||
@ApiResponse(responseCode = "404", description = "NOT FOUND", content = @Content( | ||
mediaType = "application/json", | ||
examples = { | ||
@ExampleObject(name = "TE0001", description = "약관 id에 해당하는 약관을 찾을 수 없습니다.", | ||
value = """ | ||
{"code": "TE0001", "message": "약관을 찾을 수 없습니다."} | ||
""" | ||
) | ||
}, schema = @Schema(implementation = ErrorResponse.class))) | ||
@ApiResponse(responseCode = "400", description = "BAD REQUEST", content = @Content( | ||
mediaType = "application/json", | ||
examples = { | ||
@ExampleObject(name = "TE0002", description = "필수 문서에 대해 동의가 되지 않은 경우 발생합니다.", | ||
value = """ | ||
{"code": "TE0002", "message": "필수 문서는 동의가 필수입니다."} | ||
""" | ||
) | ||
}, schema = @Schema(implementation = ErrorResponse.class))) | ||
ResponseEntity<ListResponse<TermsAgreementResponse>> agreeTerms( | ||
@LoginUserId | ||
@Parameter(hidden = true) | ||
Long userId, | ||
|
||
@RequestBody | ||
List<TermsAgreementRequest> requests | ||
); | ||
} |
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
71 changes: 71 additions & 0 deletions
71
...ticket-app-api/src/main/java/com/uket/app/ticket/api/controller/impl/TermsController.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,71 @@ | ||
package com.uket.app.ticket.api.controller.impl; | ||
|
||
import com.uket.app.ticket.api.controller.TermsApi; | ||
import com.uket.app.ticket.api.dto.request.TermsAgreementRequest; | ||
import com.uket.app.ticket.api.dto.response.ListResponse; | ||
import com.uket.app.ticket.api.dto.response.TermsAgreementResponse; | ||
import com.uket.app.ticket.api.dto.response.TermsResponse; | ||
import com.uket.app.ticket.api.service.TermsAgreementService; | ||
import com.uket.domain.terms.entity.Terms; | ||
import com.uket.domain.terms.entity.TermsSign; | ||
import com.uket.domain.terms.service.DocumentService; | ||
import com.uket.domain.terms.service.TermsService; | ||
import com.uket.domain.terms.service.TermsSignService; | ||
import java.util.List; | ||
import java.util.Map; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
|
||
@Controller | ||
@RequiredArgsConstructor | ||
public class TermsController implements TermsApi { | ||
|
||
private final TermsService termsService; | ||
private final TermsSignService termsSignService; | ||
private final DocumentService documentService; | ||
private final TermsAgreementService termsAgreementService; | ||
|
||
@Override | ||
public ResponseEntity<ListResponse<TermsResponse>> getTerms(Long userId) { | ||
List<Terms> activeTerms = termsService.findAllActive(); | ||
|
||
Map<Long, Boolean> termsSignMap = termsSignService.getTermsSignMap(userId, getTermsIds(activeTerms)); | ||
Map<Long, String> linkMap = documentService.getLinkMap(getDocumentNos(activeTerms)); | ||
List<TermsResponse> termsResponses = getTermsResponse(activeTerms, termsSignMap, linkMap); | ||
|
||
return ResponseEntity.ok(ListResponse.from(termsResponses)); | ||
} | ||
|
||
@Override | ||
public ResponseEntity<ListResponse<TermsAgreementResponse>> agreeTerms(Long userId, List<TermsAgreementRequest> requests) { | ||
List<TermsSign> termsSigns = termsAgreementService.agreeTerms(userId, requests); | ||
List<TermsAgreementResponse> termsAgreementResponse = termsSigns.stream() | ||
.map(TermsAgreementResponse::from) | ||
.toList(); | ||
|
||
return ResponseEntity.ok(ListResponse.from(termsAgreementResponse)); | ||
} | ||
|
||
private List<Long> getTermsIds(List<Terms> activeTerms) { | ||
return activeTerms.stream().map(Terms::getId).toList(); | ||
} | ||
|
||
private List<Long> getDocumentNos(List<Terms> activeTerms) { | ||
return activeTerms.stream().map(Terms::getDocumentNo).toList(); | ||
} | ||
|
||
private List<TermsResponse> getTermsResponse( | ||
List<Terms> activeTerms, | ||
Map<Long, Boolean> termsSignMap, | ||
Map<Long, String> termsLinkMap | ||
) { | ||
return activeTerms.stream() | ||
.map(terms -> TermsResponse.of( | ||
terms, | ||
termsSignMap.getOrDefault(terms.getId(), false), | ||
termsLinkMap.get(terms.getDocumentNo()) | ||
)) | ||
.toList(); | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
...cket-app-api/src/main/java/com/uket/app/ticket/api/dto/request/TermsAgreementRequest.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,6 @@ | ||
package com.uket.app.ticket.api.dto.request; | ||
|
||
public record TermsAgreementRequest( | ||
Long termId, | ||
Boolean isAgreed | ||
) { } |
23 changes: 23 additions & 0 deletions
23
...pp-api/src/main/java/com/uket/app/ticket/api/dto/response/ActiveUniversitiesResponse.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,23 @@ | ||
package com.uket.app.ticket.api.dto.response; | ||
|
||
import com.uket.domain.university.dto.UniversityDto; | ||
import com.uket.domain.university.entity.University; | ||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record ActiveUniversitiesResponse( | ||
Long id, | ||
String name, | ||
String logoUrl, | ||
LocalDateTime startDateTime | ||
) { | ||
public static UniversityDto from(University university) { | ||
return UniversityDto.builder() | ||
.id(university.getId()) | ||
.name(university.getName()) | ||
.logoUrl(university.getLogoPath()) | ||
.build(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...et-app-api/src/main/java/com/uket/app/ticket/api/dto/response/TermsAgreementResponse.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,12 @@ | ||
package com.uket.app.ticket.api.dto.response; | ||
|
||
import com.uket.domain.terms.entity.TermsSign; | ||
|
||
public record TermsAgreementResponse( | ||
Long termId, | ||
Boolean isAgreed | ||
) { | ||
public static TermsAgreementResponse from(TermsSign termsSign){ | ||
return new TermsAgreementResponse(termsSign.getTermsId(), termsSign.getIsAgreed()); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...tion/ticket-app-api/src/main/java/com/uket/app/ticket/api/dto/response/TermsResponse.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,25 @@ | ||
package com.uket.app.ticket.api.dto.response; | ||
|
||
import com.uket.domain.terms.entity.Terms; | ||
import com.uket.domain.terms.entity.TermsType; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record TermsResponse( | ||
Long termsId, | ||
String name, | ||
TermsType type, | ||
String link, | ||
Boolean isAgreed | ||
) { | ||
|
||
public static TermsResponse of(Terms terms, Boolean isAgreed, String link){ | ||
return TermsResponse.builder() | ||
.termsId(terms.getId()) | ||
.name(terms.getName()) | ||
.type(terms.getType()) | ||
.link(link) | ||
.isAgreed(isAgreed) | ||
.build(); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...n/ticket-app-api/src/main/java/com/uket/app/ticket/api/service/TermsAgreementService.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,34 @@ | ||
package com.uket.app.ticket.api.service; | ||
|
||
import com.uket.app.ticket.api.dto.request.TermsAgreementRequest; | ||
import com.uket.domain.terms.entity.Terms; | ||
import com.uket.domain.terms.entity.TermsSign; | ||
import com.uket.domain.terms.service.TermsService; | ||
import com.uket.domain.terms.service.TermsSignService; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class TermsAgreementService { | ||
|
||
private final TermsService termsService; | ||
private final TermsSignService termsSignService; | ||
|
||
@Transactional | ||
public List<TermsSign> agreeTerms(Long userId, List<TermsAgreementRequest> requests){ | ||
List<TermsSign> termsSigns = requests.stream().map(request -> { | ||
Long termsId = request.termId(); | ||
Boolean isAgreed = request.isAgreed(); | ||
|
||
Terms term = termsService.findById(termsId); | ||
term.checkMandatory(isAgreed); | ||
|
||
return isAgreed ? TermsSign.agree(userId, termsId) : TermsSign.agreeNot(userId, termsId); | ||
}).toList(); | ||
|
||
return termsSignService.saveAll(termsSigns); | ||
} | ||
} |
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
Oops, something went wrong.