Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into feat/#246
Browse files Browse the repository at this point in the history
  • Loading branch information
seokjin8678 committed Aug 16, 2023
2 parents 2b9b6e2 + 2bcdc28 commit b8c2339
Show file tree
Hide file tree
Showing 9 changed files with 236 additions and 8 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/cd-back-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CD-Back-Dev

on:
push:
branches:
- dev
paths: 'backend/**'

workflow_dispatch:

defaults:
run:
working-directory: backend

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 리포지토리 체크아웃
uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.SUBMODULE_TOKEN }}

- name: 자바 설치
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu'

- name: gradlew 권한 부여
run: chmod +x gradlew

- name: Gradle Test
run: ./gradlew test

- name: trigger to jenkins dev cd
uses: appleboy/jenkins-action@master
with:
url: ${{ secrets.JENKINS_URL }}
user: "festago"
token: ${{ secrets.JENKINS_API_TOKEN}}
job: "festago-dev-cd"
7 changes: 3 additions & 4 deletions .github/workflows/ci-back.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: CI-Back

on:
push:
branches:
- dev
paths: 'backend/**'
pull_request:
branches:
- dev
Expand All @@ -20,6 +16,9 @@ jobs:
steps:
- name: 리포지토리 체크아웃
uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.SUBMODULE_TOKEN }}

- name: 자바 설치
uses: actions/setup-java@v3
Expand Down
4 changes: 2 additions & 2 deletions android/festago/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ android {
applicationId = "com.festago.festago"
minSdk = 28
targetSdk = 33
versionCode = 1
versionName = "1.0"
versionCode = 2
versionName = "1.0.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public record KakaoAccount(

public record Profile(
String nickname,
@JsonProperty(value = "thumbnail_image_url", defaultValue = "https://placehold.co/200")
@JsonProperty("thumbnail_image_url")
String thumbnailImageUrl
) {

Expand Down
4 changes: 3 additions & 1 deletion backend/src/main/java/com/festago/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
@Where(clause = "deleted_at is null")
public class Member extends BaseTimeEntity {

private static final String DEFAULT_IMAGE_URL = "https://festa-go.site/images/default-profile.png";

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
Expand Down Expand Up @@ -47,7 +49,7 @@ public Member(Long id, String socialId, SocialType socialType, String nickname,
this.socialId = socialId;
this.socialType = socialType;
this.nickname = nickname;
this.profileImage = profileImage;
this.profileImage = (profileImage != null) ? profileImage : DEFAULT_IMAGE_URL;
}

public Long getId() {
Expand Down
74 changes: 74 additions & 0 deletions backend/src/main/java/com/festago/domain/School.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.festago.domain;

import com.festago.exception.ErrorCode;
import com.festago.exception.InternalServerException;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

@Entity
public class School {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@NotNull
@Size(max = 50)
private String domain;

@NotNull
@Size(max = 255)
private String name;

protected School() {
}

public School(Long id, String domain, String name) {
validate(domain, name);
this.id = id;
this.domain = domain;
this.name = name;
}

private void validate(String domain, String name) {
checkNotNull(domain, name);
checkLength(domain, name);
}

private void checkNotNull(String domain, String name) {
if (domain == null ||
name == null) {
throw new InternalServerException(ErrorCode.INTERNAL_SERVER_ERROR);
}
}

private void checkLength(String domain, String name) {
if (overLength(domain, 50) ||
overLength(name, 255)) {
throw new InternalServerException(ErrorCode.INTERNAL_SERVER_ERROR);
}
}

private boolean overLength(String target, int maxLength) {
if (target == null) {
return false;
}
return target.length() > maxLength;
}

public Long getId() {
return id;
}

public String getDomain() {
return domain;
}

public String getName() {
return name;
}
}
86 changes: 86 additions & 0 deletions backend/src/main/java/com/festago/domain/Student.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.festago.domain;

import com.festago.exception.ErrorCode;
import com.festago.exception.InternalServerException;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

@Entity
public class Student {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@NotNull
@OneToOne(fetch = FetchType.LAZY)
private Member member;

@NotNull
@ManyToOne(fetch = FetchType.LAZY)
private School school;

@Size(max = 255)
@NotNull
private String username;

protected Student() {
}

public Student(Long id, Member member, School school, String username) {
validate(member, school, username);
this.id = id;
this.member = member;
this.school = school;
this.username = username;
}

private void validate(Member member, School school, String username) {
checkNotNull(member, school, username);
checkLength(username);
}

private void checkNotNull(Member member, School school, String username) {
if (member == null ||
school == null ||
username == null) {
throw new InternalServerException(ErrorCode.INTERNAL_SERVER_ERROR);
}
}

private void checkLength(String username) {
if (overLength(username, 255)) {
throw new InternalServerException(ErrorCode.INTERNAL_SERVER_ERROR);
}
}

private boolean overLength(String target, int maxLength) {
if (target == null) {
return false;
}
return target.length() > maxLength;
}

public Long getId() {
return id;
}

public Member getMember() {
return member;
}

public School getSchool() {
return school;
}

public String getUsername() {
return username;
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions backend/src/test/java/com/festago/domain/MemberTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.festago.domain;

import static org.assertj.core.api.Assertions.assertThat;

import com.festago.support.MemberFixture;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
import org.junit.jupiter.api.Test;

@DisplayNameGeneration(ReplaceUnderscores.class)
@SuppressWarnings("NonAsciiCharacters")
class MemberTest {

@Test
void 프로필_이미지가_null이면_기본값이_할당된다() {
// when
Member actual = MemberFixture.member()
.profileImage(null)
.build();

// then
assertThat(actual.getProfileImage()).isNotNull();
}
}

0 comments on commit b8c2339

Please sign in to comment.