Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v1.2.0 #910

Merged
merged 9 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/be-cd_dev-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ jobs:
REDIS_PORT=${{ secrets.REDIS_PORT }}
REDIS_HOST=${{ secrets.REDIS_HOST }}
REDIS_PASSWORD=${{ secrets.REDIS_PASSWORD }}
REDIS_IP_ADDRESS=${{ secrets.REDIS_IP_ADDRESS }}
EOF

# - name: Check if MySQL container is running
Expand Down
1 change: 1 addition & 0 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dependencies {
runtimeOnly 'com.mysql:mysql-connector-j'
implementation 'org.flywaydb:flyway-core:9.22.3'
implementation 'org.flywaydb:flyway-mysql'
implementation 'io.hypersistence:hypersistence-utils-hibernate-60:3.5.2'

// Redis
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
Expand Down
14 changes: 14 additions & 0 deletions backend/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ services:
platform: linux/arm64
depends_on:
- database-mysql
- redis
restart: always
image: ${DOCKER_REPO_NAME}/cruru:${DOCKER_IMAGE_VERSION_TAG}
ports:
Expand All @@ -39,6 +40,19 @@ services:
cruru_network:
ipv4_address: ${APP_IP_ADDRESS}

redis:
container_name: redis-container
image: redis:latest
environment:
TZ: Asia/Seoul
REDIS_PASSWORD: ${REDIS_PASSWORD}
ports:
- ${REDIS_PORT}:6379
command: [ "redis-server", "--requirepass", "${REDIS_PASSWORD}" ]
networks:
cruru_network:
ipv4_address: ${REDIS_IP_ADDRESS}

promtail:
environment:
TZ: Asia/Seoul
Expand Down
6 changes: 3 additions & 3 deletions backend/src/docs/asciidoc/applyform.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

==== 성공

operation::applyform/submit[snippets="http-request,path-parameters,request-fields,http-response"]
operation::applyform/submit-id[snippets="http-request,path-parameters,request-fields,http-response"]

==== 실패: 개인정보 활용 거부

Expand Down Expand Up @@ -42,7 +42,7 @@ operation::applicant/submit-fail/required-not-replied[snippets="http-request,pat

==== 성공

operation::applicant/read-applyform[snippets="http-request,path-parameters,http-response,response-fields"]
operation::applicant/read-applyform-id[snippets="http-request,path-parameters,http-response,response-fields"]

==== 실패: 존재하지 않는 지원폼

Expand All @@ -52,7 +52,7 @@ operation::applicant/read-applyform-fail/applyform-not-found[snippets="http-requ

==== 성공

operation::applicant/update[snippets="http-request,request-cookies,path-parameters,request-fields,http-response"]
operation::applicant/update-id[snippets="http-request,request-cookies,path-parameters,request-fields,http-response"]

==== 실패: 존재하지 않는 지원폼

Expand Down
32 changes: 32 additions & 0 deletions backend/src/docs/asciidoc/email.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,35 @@ operation::email/send-fail/invalid-email[snippets="http-request,request-cookies,
==== 실패: 존재하지 않는 동아리

operation::email/send-fail/club-not-found[snippets="http-request,request-cookies,request-parts,http-response"]

=== 이메일 인증 번호 발송

==== 성공

operation::email/verification-code[snippets="http-request,request-fields,http-response"]

==== 실패: 이메일 형식이 올바르지 않은 이메일 형식

operation::email/verification-code-fail/invalid-email[snippets="http-request,request-fields,http-response"]

==== 실패: 이미 가입된 이메일

operation::email/verification-code-fail/already-signed-up[snippets="http-request,request-fields,http-response"]

=== 이메일 인증 확인

==== 성공

operation::email/verify-code[snippets="http-request,request-fields,http-response"]

==== 실패: 이메일 형식이 올바르지 않은 이메일 형식

operation::email/verify-code-fail/invalid-email[snippets="http-request,request-fields,http-response"]

==== 실패: 인증 번호가 없는 이메일

operation::email/verify-code-fail/code-not-found[snippets="http-request,request-fields,http-response"]

==== 실패: 인증 번호가 다른 이메일

operation::email/verify-code-fail/code-mismatch[snippets="http-request,request-fields,http-response"]
4 changes: 4 additions & 0 deletions backend/src/docs/asciidoc/member.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ operation::member/signup[snippets="http-request,request-fields,http-response"]
==== 실패: 유효하지 않은 요청

operation::member/signup-fail/invalid-request[snippets="http-request,request-fields,http-response"]

==== 실패: 인증되지 않은 이메일

operation::member/signup-fail/not-verified-email[snippets="http-request,request-fields,http-response"]
2 changes: 1 addition & 1 deletion backend/src/docs/asciidoc/question.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

==== 성공

operation::question/update[snippets="http-request,request-cookies,query-parameters,request-fields,http-response"]
operation::question/update-id[snippets="http-request,request-cookies,query-parameters,request-fields,http-response"]

==== 실패: 존재하지 않는 지원폼

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public interface ApplicantRepository extends JpaRepository<Applicant, Long> {
long countByProcess(Process process);

@Query("""
SELECT new com.cruru.applicant.domain.dto.ApplicantCard(
SELECT new com.cruru.applicant.domain.dto.ApplicantCard(
a.id, a.name, a.createdDate, a.isRejected, COUNT(e), COALESCE(AVG(e.score), 0.00), a.process.id
)
FROM Applicant a
LEFT JOIN Evaluation e ON e.applicant = a
LEFT JOIN Evaluation e ON e.applicant = a AND e.process = a.process
WHERE a.process IN :processes
GROUP BY a.id, a.name, a.createdDate, a.isRejected, a.process.id
""")
Expand All @@ -39,7 +39,7 @@ a.id, a.name, a.createdDate, a.isRejected, COUNT(e), COALESCE(AVG(e.score), 0.00
a.id, a.name, a.createdDate, a.isRejected, COUNT(e), COALESCE(AVG(e.score), 0.00), a.process.id
)
FROM Applicant a
LEFT JOIN Evaluation e ON e.applicant = a
LEFT JOIN Evaluation e ON e.applicant = a AND e.process = a.process
WHERE a.process = :process
GROUP BY a.id, a.name, a.createdDate, a.isRejected
""")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ public Applicant create(ApplicantCreateRequest request, Process firstProcess) {
return applicantRepository.save(new Applicant(request.name(), request.email(), request.phone(), firstProcess));
}

public List<Applicant> findAllByProcess(Process process) {
return applicantRepository.findAllByProcess(process);
}

@Transactional
public void updateApplicantInformation(long applicantId, ApplicantUpdateRequest request) {
Applicant applicant = findById(applicantId);
Expand Down Expand Up @@ -147,8 +143,16 @@ public List<Applicant> findAllByProcesses(List<Process> processes) {
.toList();
}

public List<Applicant> findAllByProcess(Process process) {
return applicantRepository.findAllByProcess(process);
}

@Transactional
public void deleteAllInBatch(List<Applicant> applicants) {
applicantRepository.deleteAllInBatch(applicants);
}

public List<Applicant> findAllByIds(List<Long> ids) {
return applicantRepository.findAllById(ids);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public class ApplyFormController {
@PostMapping("/{applyformId}/submit")
public ResponseEntity<Void> submit(
@RequestBody @Valid ApplyFormSubmitRequest request,
@PathVariable("applyformId") long applyFormId
@PathVariable("applyformId") Long applyFormId
) {
applyFormFacade.submit(applyFormId, request);
return ResponseEntity.created(URI.create("/v1/applyform/" + applyFormId)).build();
}

@GetMapping("/{applyformId}")
public ResponseEntity<ApplyFormResponse> read(@PathVariable("applyformId") long applyFormId) {
public ResponseEntity<ApplyFormResponse> read(@PathVariable("applyformId") Long applyFormId) {
ApplyFormResponse response = applyFormFacade.readApplyFormById(applyFormId);
return ResponseEntity.ok(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import com.cruru.applyform.exception.badrequest.StartDateAfterEndDateException;
import com.cruru.auth.util.SecureResource;
import com.cruru.dashboard.domain.Dashboard;
import com.cruru.global.util.TsidSupplier;
import com.cruru.member.domain.Member;
import io.hypersistence.utils.hibernate.id.Tsid;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;
Expand All @@ -27,7 +27,7 @@
public class ApplyForm extends BaseEntity implements SecureResource {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Tsid(TsidSupplier.class)
@Column(name = "apply_form_id")
private Long id;

Expand Down
42 changes: 6 additions & 36 deletions backend/src/main/java/com/cruru/auth/domain/RefreshToken.java
Original file line number Diff line number Diff line change
@@ -1,45 +1,16 @@
package com.cruru.auth.domain;

import com.cruru.BaseEntity;
import com.cruru.member.domain.Member;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;
import java.util.Objects;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@Getter
public class RefreshToken extends BaseEntity implements Token {
public class RefreshToken implements Token {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "refresh_token_id")
private Long id;

@Column(nullable = false, unique = true)
private String token;

@OneToOne
@JoinColumn(name = "member_id", nullable = false)
private Member member;

public RefreshToken(String token, Member member) {
this(null, token, member);
}

public boolean isSameToken(String token) {
return this.token.equals(token);
}
private String email;

@Override
public boolean equals(Object o) {
Expand All @@ -50,20 +21,19 @@ public boolean equals(Object o) {
return false;
}
RefreshToken that = (RefreshToken) o;
return Objects.equals(getId(), that.getId());
return Objects.equals(getToken(), that.getToken());
}

@Override
public int hashCode() {
return Objects.hashCode(getId());
return Objects.hashCode(getToken());
}

@Override
public String toString() {
return "RefreshToken{" +
"id=" + id +
", token='" + token + '\'' +
", member=" + member +
"token='" + token + '\'' +
", email='" + email + '\'' +
'}';
}
}

This file was deleted.

4 changes: 2 additions & 2 deletions backend/src/main/java/com/cruru/auth/facade/AuthFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public TokenResponse login(LoginRequest request) {
}

private TokenResponse createTokens(Member member) {
Token accessToken = authService.createAccessToken(member);
Token refreshToken = authService.createRefreshToken(member);
Token accessToken = authService.createAccessToken(member.getEmail(), member.getRole());
Token refreshToken = authService.createRefreshToken(member.getEmail(), member.getRole());
return new TokenResponse(accessToken.getToken(), refreshToken.getToken());
}
}
Loading