-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from kkijuk/feature/2
[넬리] 마스터 자기소개서 CRUD
- Loading branch information
Showing
35 changed files
with
737 additions
and
17 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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 @@ | ||
* @tape4 |
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ on: | |
push: | ||
branches: | ||
- develop | ||
- example | ||
|
||
env: | ||
DOCKERHUB_REPOSITORY: umc-develop-server | ||
|
@@ -25,6 +26,13 @@ jobs: | |
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Setup MySQL | ||
uses: mirromutth/[email protected] | ||
with: | ||
mysql database: 'kkijuk' | ||
mysql user: 'test' | ||
mysql password: 'testPW' | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | ||
|
||
|
@@ -34,9 +42,10 @@ jobs: | |
|
||
- name: Generate application.properties | ||
run: | | ||
touch ./src/main/resources/application.properties | ||
echo ${{ secrets.PROPERTIES }} >> ./src/main/resources/application.properties | ||
echo commit.hash=${{ steps.slug.outputs.sha7 }} >> ./src/main/resources/application.properties | ||
echo commit.hash=${{ steps.slug.outputs.sha7 }} >> ./src/main/resources/application-prod.properties | ||
echo ${{ secrets.DATASOURCE_DB_URL }} >> ./src/main/resources/application-prod.properties | ||
echo ${{ secrets.DATASOURCE_DB_USERNAME }} >> ./src/main/resources/application-prod.properties | ||
echo ${{ secrets.DATASOURCE_DB_PASSWORD }} >> ./src/main/resources/application-prod.properties | ||
- name: Build with Gradle Wrapper | ||
run: ./gradlew build | ||
|
@@ -105,6 +114,7 @@ jobs: | |
# echo "No images found in repository $DOCKERHUB_REPOSITORY" | ||
# fi | ||
# | ||
|
||
CD_Deploy: | ||
name: CD_Deploy | ||
needs: CD_Delivery_to_DockerHub | ||
|
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 |
---|---|---|
|
@@ -3,11 +3,10 @@ name: CI FOR MVP | |
on: | ||
push: | ||
branches: | ||
- mvp/apply | ||
- mvp/member | ||
- mvp/career | ||
- mvp/portfolio | ||
|
||
- mvp/apply | ||
- mvp/member | ||
- mvp/career | ||
- mvp/portfolio | ||
|
||
jobs: | ||
CI: | ||
|
@@ -26,18 +25,35 @@ jobs: | |
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Setup MySQL | ||
uses: mirromutth/[email protected] | ||
with: | ||
mysql database: 'kkijuk' | ||
mysql user: 'test' | ||
mysql password: 'testPW' | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | ||
|
||
- name: Get short SHA | ||
id: slug | ||
run: echo "sha7=$(echo ${GITHUB_SHA} | cut -c1-7)" >> $GITHUB_OUTPUT | ||
|
||
- name: Generate application.properties | ||
run: | | ||
touch ./src/main/resources/application.properties | ||
echo ${{ secrets.PROPERTIES }} >> ./src/main/resources/application.properties | ||
echo commit.hash=${{ steps.slug.outputs.sha7 }} >> ./src/main/resources/application.properties | ||
# - name: Generate application.properties | ||
# run: | | ||
# echo commit.hash=${{ steps.slug.outputs.sha7 }} >> ./src/main/resources/application-prod.properties | ||
# echo ${{ secrets.DATASOURCE_DB_URL }} >> ./src/main/resources/application-prod.properties | ||
# echo ${{ secrets.DATASOURCE_DB_USERNAME }} >> ./src/main/resources/application-prod.properties | ||
# echo ${{ secrets.DATASOURCE_DB_PASSWORD }} >> ./src/main/resources/application.properties | ||
|
||
# touch ./src/main/resources/application.properties | ||
# touch ./src/test/resources/application.properties | ||
# echo ${{ secrets.PROPERTIES }} >> ./src/main/resources/application.properties | ||
# echo ${{ secrets.PROPERTIES }} >> ./src/test/resources/application.properties | ||
# | ||
# echo ${{ secrets.DB_PROPERTIES }} >> ./src/main/resources/application.properties | ||
# echo ${{ secrets.TEST_DB_PROPERTIES }} >> ./src/test/resources/application.properties | ||
|
||
|
||
- name: Build with Gradle Wrapper | ||
run: ./gradlew build |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM openjdk:17-alpine | ||
ARG JAR_FILE=build/libs/*.jar | ||
COPY ${JAR_FILE} app.jar | ||
ENTRYPOINT ["java", "-jar", "/app.jar"] | ||
ENTRYPOINT ["java", "-jar", "/app.jar", "--spring.profiles.active=prod "] |
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 umc.kkijuk.server.common; | ||
|
||
public class LoginUser { | ||
private static final LoginUser LOGIN_USER = new LoginUser(0L); | ||
|
||
public LoginUser(Long id) { | ||
} | ||
|
||
public static LoginUser get() { | ||
return LOGIN_USER; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/umc/kkijuk/server/common/converter/StringListToStringConverter.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,36 @@ | ||
package umc.kkijuk.server.common.converter; | ||
|
||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.DeserializationFeature; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import jakarta.persistence.AttributeConverter; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
public class StringListToStringConverter implements AttributeConverter<List<String>, String> { | ||
private static final ObjectMapper mapper = new ObjectMapper() | ||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) | ||
.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false); | ||
|
||
@Override | ||
public String convertToDatabaseColumn(List<String> attribute) { | ||
try { | ||
return mapper.writeValueAsString(attribute); | ||
} catch (JsonProcessingException e) { | ||
throw new IllegalArgumentException(); | ||
} | ||
} | ||
|
||
@Override | ||
public List<String> convertToEntityAttribute(String dbData) { | ||
TypeReference<List<String>> typeReference = new TypeReference<List<String>>() {}; | ||
try { | ||
return mapper.readValue(dbData, typeReference); | ||
} catch (IOException e) { | ||
throw new IllegalArgumentException(); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/umc/kkijuk/server/introduce/common/BaseResponse.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,30 @@ | ||
package umc.kkijuk.server.introduce.common; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class BaseResponse<T> { | ||
|
||
private final int status; | ||
private String message; | ||
private T data; | ||
|
||
// Response constructor that includes status, message, and data | ||
public BaseResponse(int status, String message, T data) { | ||
this.status = status; | ||
this.message = message; | ||
this.data = data; | ||
} | ||
|
||
// Response constructor that includes status and message only | ||
public BaseResponse(int status, String message) { | ||
this.status = status; | ||
this.message = message; | ||
} | ||
|
||
// Response constructor that includes status and data only | ||
public BaseResponse(int status, T data) { | ||
this.status = status; | ||
this.data = data; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/umc/kkijuk/server/introduce/controller/IntroduceController.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,4 @@ | ||
package umc.kkijuk.server.introduce.controller; | ||
|
||
public class IntroduceController { | ||
} |
79 changes: 79 additions & 0 deletions
79
src/main/java/umc/kkijuk/server/introduce/controller/MasterIntroduceController.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,79 @@ | ||
package umc.kkijuk.server.introduce.controller; | ||
|
||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import umc.kkijuk.server.introduce.common.BaseResponse; | ||
import umc.kkijuk.server.introduce.domain.MasterIntroduce; | ||
import umc.kkijuk.server.introduce.dto.MasterIntroduceReqDto; | ||
import umc.kkijuk.server.introduce.dto.MasterIntroduceResDto; | ||
import umc.kkijuk.server.introduce.response.BaseErrorResponse; | ||
import umc.kkijuk.server.introduce.response.BaseException; | ||
import umc.kkijuk.server.introduce.service.MasterIntroduceService; | ||
|
||
import java.util.List; | ||
|
||
@Tag(name = "master", description = "마스터 자기소개서 API") | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/history/intro/master") | ||
public class MasterIntroduceController { | ||
private final MasterIntroduceService masterIntroduceService; | ||
|
||
@PostMapping | ||
public ResponseEntity<Object> save(@RequestBody MasterIntroduceReqDto masterIntroduceReqDto){ | ||
try { | ||
MasterIntroduceResDto masterIntroduceResDto = masterIntroduceService.saveMasterIntro(masterIntroduceReqDto); | ||
return ResponseEntity | ||
.status(HttpStatus.OK) | ||
.body(new BaseResponse<>(HttpStatus.OK.value(), "마스터 자기소개서 생성 완료", masterIntroduceResDto)); | ||
} catch (BaseException e) { | ||
return ResponseEntity | ||
.status(e.getCode()) | ||
.body(new BaseErrorResponse(e.getCode(), e.getMessage())); | ||
} catch (Exception e) { | ||
return ResponseEntity | ||
.status(HttpStatus.INTERNAL_SERVER_ERROR) | ||
.body(new BaseErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server error")); | ||
} | ||
} | ||
|
||
@GetMapping | ||
public ResponseEntity<Object> get(){ | ||
try { | ||
List<MasterIntroduce> masterIntroduce = masterIntroduceService.getMasterIntro(); | ||
return ResponseEntity | ||
.status(HttpStatus.OK) | ||
.body(new BaseResponse<>(HttpStatus.OK.value(), "마스터 자기소개서 조회 완료", masterIntroduce)); | ||
} catch (BaseException e) { | ||
return ResponseEntity | ||
.status(e.getCode()) | ||
.body(new BaseErrorResponse(e.getCode(), e.getMessage())); | ||
} catch (Exception e) { | ||
return ResponseEntity | ||
.status(HttpStatus.INTERNAL_SERVER_ERROR) | ||
.body(new BaseErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server error")); | ||
} | ||
} | ||
|
||
@PatchMapping | ||
public ResponseEntity<Object> update(Long id, @RequestBody MasterIntroduceReqDto masterIntroduceReqDto){ | ||
try { | ||
MasterIntroduceResDto masterIntroduceResDto = masterIntroduceService.updateMasterIntro(id, masterIntroduceReqDto); | ||
return ResponseEntity | ||
.status(HttpStatus.OK) | ||
.body(new BaseResponse<>(HttpStatus.OK.value(), "마스터 자기소개서 수정 완료", masterIntroduceResDto)); | ||
} catch (BaseException e) { | ||
return ResponseEntity | ||
.status(e.getCode()) | ||
.body(new BaseErrorResponse(e.getCode(), e.getMessage())); | ||
} catch (Exception e) { | ||
return ResponseEntity | ||
.status(HttpStatus.INTERNAL_SERVER_ERROR) | ||
.body(new BaseErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Server error")); | ||
} | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/umc/kkijuk/server/introduce/domain/Introduce.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,15 @@ | ||
package umc.kkijuk.server.introduce.domain; | ||
|
||
import jakarta.persistence.*; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Getter; | ||
|
||
@Entity | ||
@Table(name="introduce") | ||
@Getter | ||
public class Introduce { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/umc/kkijuk/server/introduce/domain/IntroduceRepository.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 umc.kkijuk.server.introduce.domain; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface IntroduceRepository extends JpaRepository<Introduce, Long> { | ||
} |
57 changes: 57 additions & 0 deletions
57
src/main/java/umc/kkijuk/server/introduce/domain/MasterIntroduce.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,57 @@ | ||
package umc.kkijuk.server.introduce.domain; | ||
|
||
import jakarta.persistence.*; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.annotations.CreationTimestamp; | ||
import org.hibernate.annotations.UpdateTimestamp; | ||
import org.springframework.data.annotation.CreatedDate; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.Date; | ||
|
||
@Entity | ||
@Table(name = "master_introduce") | ||
@Getter | ||
@NoArgsConstructor | ||
public class MasterIntroduce { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Size(max = 24) | ||
private String oneLiner; | ||
|
||
private String subTitle; | ||
private String content; | ||
|
||
@CreationTimestamp | ||
private LocalDateTime created_at; | ||
|
||
@UpdateTimestamp | ||
private LocalDateTime updated_at; | ||
|
||
@Builder | ||
public MasterIntroduce(String oneLiner, String subTitle, String content) { | ||
this.oneLiner = oneLiner; | ||
this.subTitle = subTitle; | ||
this.content = content; | ||
} | ||
|
||
public String getUpdated_at() { | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); | ||
return updated_at != null ? updated_at.format(formatter) : null; | ||
} | ||
|
||
public void update(String oneLiner, String subTitle, String content) { | ||
this.oneLiner = oneLiner; | ||
this.subTitle = subTitle; | ||
this.content = content; | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/umc/kkijuk/server/introduce/domain/MasterIntroduceRepository.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 umc.kkijuk.server.introduce.domain; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface MasterIntroduceRepository extends JpaRepository<MasterIntroduce, Long> { | ||
} |
Oops, something went wrong.