Skip to content

Commit

Permalink
Merge pull request codestates-seb#348 from NtoZero/dev-be
Browse files Browse the repository at this point in the history
[BE] ✨ μ‹€μ‹œκ°„ μ±„νŒ… κ΅¬ν˜„
  • Loading branch information
NtoZero authored Dec 8, 2023
2 parents eef5c34 + 763d68c commit 582f659
Show file tree
Hide file tree
Showing 133 changed files with 7,499 additions and 280 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ jobs:
AWS_SECRET_KEY: ${{secrets.AWS_SECRET_KEY}}
AWS_BUCKET_NAME: ${{secrets.AWS_BUCKET_NAME}}
ADMIN_EMAIL: ${{secrets.ADMIN_EMAIL}}
GUEST_EMAIL: ${{secrets.GUEST_EMAIL}}
GROWSTORY_EMAIL_USERNAME: ${{secrets.GROWSTORY_EMAIL_USERNAME}}
GROWSTORY_EMAIL_PASSWORD: ${{secrets.GROWSTORY_EMAIL_PASSWORD}}
G_CLIENT_ID: ${{secrets.G_CLIENT_ID}}
G_CLIENT_SECRET: ${{secrets.G_CLIENT_SECRET}}
JWT_SECRET_KEY: ${{secrets.JWT_SECRET_KEY}}
KEY_STORE_PASSWORD: ${{secrets.KEY_STORE_PASSWORD}}
EVENT_KEY: ${{secrets.EVENT_KEY}}
working-directory: ./server

steps:
Expand Down Expand Up @@ -51,12 +53,14 @@ jobs:
--build-arg AWS_SECRET_KEY="${{env.AWS_SECRET_KEY}}" \
--build-arg AWS_BUCKET_NAME="${{env.AWS_BUCKET_NAME}}" \
--build-arg ADMIN_EMAIL="${{env.ADMIN_EMAIL}}" \
--build-arg GUEST_EMAIL="${{env.GUEST_EMAIL}}" \
--build-arg GROWSTORY_EMAIL_USERNAME="${{env.GROWSTORY_EMAIL_USERNAME}}" \
--build-arg GROWSTORY_EMAIL_PASSWORD="${{env.GROWSTORY_EMAIL_PASSWORD}}" \
--build-arg G_CLIENT_ID="${{env.G_CLIENT_ID}}" \
--build-arg G_CLIENT_SECRET="${{env.G_CLIENT_SECRET}}" \
--build-arg JWT_SECRET_KEY="${{env.JWT_SECRET_KEY}}" \
--build-arg KEY_STORE_PASSWORD="${{env.KEY_STORE_PASSWORD}}" \
--build-arg EVENT_KEY="${{env.EVENT_KEY}}" \
-t growstory-cicd .
docker tag growstory-cicd leest/growstory-cicd:${GITHUB_SHA::7}
docker push leest/growstory-cicd:${GITHUB_SHA::7}
Expand All @@ -80,4 +84,4 @@ jobs:
sudo docker rm -f server
sudo docker pull leest/growstory-cicd:${GITHUB_SHA::7}
sudo docker tag leest/growstory-cicd:${GITHUB_SHA::7} growstory-cicd
sudo docker run -d --name server -e TZ=Asia/Seoul -p 443:443 growstory-cicd
sudo docker run -d --name server -e TZ=Asia/Seoul -p 443:443 growstory-cicd
8 changes: 6 additions & 2 deletions server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ARG MYSQL_USER \
MYSQL_PASSWORD \
RDS_ENDPOINT \
ADMIN_EMAIL \
GUEST_EMAIL \
AWS_ACCESS_KEY \
AWS_SECRET_KEY \
AWS_BUCKET_NAME \
Expand All @@ -14,13 +15,15 @@ ARG MYSQL_USER \
GROWSTORY_EMAIL_PASSWORD \
GROWSTORY_EMAIL_USERNAME \
JWT_SECRET_KEY \
KEY_STORE_PASSWORD
KEY_STORE_PASSWORD \
EVENT_KEY

# ⭐ 'ENV' μ˜ˆμ•½μ–΄λ₯Ό 톡해 전달받은 값을 μ‹€μ œ κ°’κ³Ό λ§€μΉ­μ‹œμΌœμ•Ό ν•œλ‹€.
ENV MYSQL_USER=${MYSQL_USER} \
MYSQL_PASSWORD=${MYSQL_PASSWORD} \
RDS_ENDPOINT=${RDS_ENDPOINT} \
ADMIN_EMAIL=${ADMIN_EMAIL} \
GUEST_EMAIL=${GUEST_EMAIL} \
AWS_ACCESS_KEY=${AWS_ACCESS_KEY} \
AWS_SECRET_KEY=${AWS_SECRET_KEY} \
AWS_BUCKET_NAME=${AWS_BUCKET_NAME} \
Expand All @@ -29,7 +32,8 @@ ENV MYSQL_USER=${MYSQL_USER} \
GROWSTORY_EMAIL_PASSWORD=${GROWSTORY_EMAIL_PASSWORD} \
GROWSTORY_EMAIL_USERNAME=${GROWSTORY_EMAIL_USERNAME} \
JWT_SECRET_KEY=${JWT_SECRET_KEY} \
KEY_STORE_PASSWORD=${KEY_STORE_PASSWORD}
KEY_STORE_PASSWORD=${KEY_STORE_PASSWORD} \
EVENT_KEY=${EVENT_KEY}

# (2) COPYμ—μ„œ μ‚¬μš©λ  경둜 λ³€μˆ˜
ARG JAR_FILE=build/libs/*-SNAPSHOT.jar
Expand Down
8 changes: 8 additions & 0 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ dependencies {

// spring-security-test λͺ¨λ“ˆ μΆ”κ°€
testImplementation 'org.springframework.security:spring-security-test'

// websocket
implementation 'org.springframework.boot:spring-boot-starter-websocket'
// implementation 'org.webjars:sockjs-client'
// implementation 'org.webjars:stomp-websocket'
implementation 'org.springframework:spring-messaging'
implementation 'org.springframework.security:spring-security-messaging'

}

test {
Expand Down
312 changes: 312 additions & 0 deletions server/server_log

Large diffs are not rendered by default.

Binary file added server/server_log.2023-10-04.0.gz
Binary file not shown.
8 changes: 7 additions & 1 deletion server/src/main/java/com/growstory/GrowstoryApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableScheduling
@EnableJpaAuditing
@EnableAsync
@SpringBootApplication
@EnableAspectJAutoProxy
@SpringBootApplication(exclude = {
org.springframework.cloud.aws.autoconfigure.context.ContextInstanceDataAutoConfiguration.class,
org.springframework.cloud.aws.autoconfigure.context.ContextStackAutoConfiguration.class,
org.springframework.cloud.aws.autoconfigure.context.ContextRegionProviderAutoConfiguration.class
})
public class GrowstoryApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.growstory.domain.account.constants;

import lombok.Getter;

// μ‹λ¬ΌμΉ΄λ“œκ°œμˆ˜μ— μ˜ν•œ λ“±κΈ‰ μ œλ„
// 50개 미만 - 브둠즈 κ°€λ“œλ„ˆ
// 50개 이상 - 싀버 κ°€λ“œλ„ˆ
// 100개 이상 - κ³¨λ“œ κ°€λ“œλ„ˆ
public enum AccountGrade {
GRADE_BRONZE(1, "브둠즈 κ°€λ“œλ„ˆ"),
GRADE_SILVER(2, "싀버 κ°€λ“œλ„ˆ"),
GRADE_GOLD(3, "κ³¨λ“œ κ°€λ“œλ„ˆ");

@Getter
private int stepNumber;

@Getter
private String stepDescription;

AccountGrade(int stepNumber, String stepDescription) {
this.stepNumber = stepNumber;
this.stepDescription = stepDescription;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.growstory.domain.account.constants;

import lombok.Getter;

public enum Status {
ADMIN(1, "ADMIN"),
USER(2, "USER"),
SOCIAL_USER(3, "SOCIAL_USER"),
BANNED_USER(4, "BANNED_USER"),
GUEST_USER(5, "GUEST_USER");

@Getter
private int stepNumber;

@Getter
private String stepDescription;

Status(int stepNumber, String stepDescription) {
this.stepNumber = stepNumber;
this.stepDescription = stepDescription;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import com.growstory.global.response.SingleResponseDto;
import com.growstory.global.utils.UriCreator;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
Expand All @@ -36,12 +36,26 @@ public class AccountController {
@Operation(summary = "νšŒμ›κ°€μž…", description = "μ‚¬μš©μž 정보λ₯Ό μž…λ ₯λ°›μ•„ 계정 생성")
@PostMapping("/signup")
public ResponseEntity<HttpStatus> postAccount(@Valid @RequestBody AccountDto.Post accountPostDto) {
AccountDto.Response accountResponseDto = accountService.createAccount(accountPostDto);
URI location = UriCreator.createUri(ACCOUNT_DEFAULT_URL, accountResponseDto.getAccountId());
AccountDto.Response responseDto = accountService.createAccount(accountPostDto);
URI location = UriCreator.createUri(ACCOUNT_DEFAULT_URL, responseDto.getAccountId());


return ResponseEntity.created(location).build();
}

@Operation(summary = "νšŒμ›κ°€μž…", description = "게슀트 계정 생성")
@PostMapping("/guest")
public ResponseEntity<?> postAccount() {
List<String> token = accountService.createAccount();
URI location = UriCreator.createUri(ACCOUNT_DEFAULT_URL, Long.parseLong(token.get(2)));

HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", token.get(0));
headers.add("Refresh", token.get(1));

return ResponseEntity.created(location).headers(headers).build();
}

@Operation(summary = "ν”„λ‘œν•„ 사진 μˆ˜μ •", description = "μž…λ ₯받은 ν”„λ‘œν•„ μ‚¬μ§„μœΌλ‘œ 정보 μˆ˜μ •")
@PatchMapping(value = "/profileimage", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<HttpStatus> patchProfileImage(@RequestPart MultipartFile profileImage) {
Expand Down Expand Up @@ -156,4 +170,12 @@ public ResponseEntity<HttpStatus> deleteAccount() {

return ResponseEntity.noContent().build();
}

@Operation(summary = "게슀트 νšŒμ› νƒˆν‡΄", description = "게슀트 μ‚¬μš©μž 계정 μ‚­μ œ")
@DeleteMapping("/guest/{account-id}")
public ResponseEntity<HttpStatus> deleteAccount(@Positive @PathVariable("account-id") Long accountId){
accountService.deleteAccount(accountId);

return ResponseEntity.noContent().build();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.growstory.domain.account.dto;

import com.growstory.domain.point.entity.Point;
import com.growstory.global.badwords.dto.TextContainer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -16,7 +17,7 @@ public class AccountDto {
@Getter
@Builder
@Schema(name = "AccountPostDto")
public static class Post {
public static class Post implements TextContainer {
@NotBlank
private String displayName;

Expand All @@ -27,18 +28,29 @@ public static class Post {
@NotBlank
@Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*\\d).{6,}$" , message = "영문, 숫자 포함 6κΈ€μž μ΄μƒμ˜ νŒ¨μŠ€μ›Œλ“œλ§Œ ν—ˆμš©ν•©λ‹ˆλ‹€.")
private String password;

@Override
public String combineText() {
return displayName;
}
}


@Getter
@NoArgsConstructor
public static class DisplayNamePatch {
public static class DisplayNamePatch implements TextContainer {
@NotBlank
private String displayName;

@Builder
public DisplayNamePatch(String displayName) {
this.displayName = displayName;
}

@Override
public String combineText() {
return this.displayName;
}
}

@Getter
Expand Down Expand Up @@ -70,6 +82,7 @@ public static class Response {
private Long accountId;
private String email;
private String displayName;
private String status;
private String profileImageUrl;
private String grade;
private Point point;
Expand Down
Loading

0 comments on commit 582f659

Please sign in to comment.