Skip to content

Commit

Permalink
Merge pull request #31 from swyp3-babpool/develop
Browse files Browse the repository at this point in the history
CI: Develop merge into main
  • Loading branch information
proHyundo authored Mar 3, 2024
2 parents 3778738 + 9580f5c commit 4e3159e
Show file tree
Hide file tree
Showing 88 changed files with 2,837 additions and 38 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/github-actions-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,13 @@ jobs:
- name: Create application.yml, *.sql and log4jdbc.lof4j2.properties for test
run: |
mkdir -p ./src/test/resources/data
touch ./src/test/resources/application-test.yml
echo -e "${{secrets.APPLICATION_TEST}}" | base64 --decode > ./src/test/resources/application-test.yml
touch ./src/test/resources/data/data.sql
echo -e "${{secrets.DATA_SQL}}" | base64 --decode > ./src/test/resources/data/data.sql
touch ./src/test/resources/data/schema.sql
echo -e "${{secrets.SCHEMA_SQL}}" | base64 --decode > ./src/test/resources/data/schema.sql
touch ./src/test/resources/log4jdbc.log4j2.properties
echo -e "${{secrets.LOG4JDBC}}" | base64 --decode > ./src/test/resources/log4jdbc.log4j2.properties
- name: Upload application-test.yml for test
uses: actions/upload-artifact@v3
with:
name: application-test.yml
path: ./src/test/resources/application-test.yml
retention-days: 1

- name: Upload data.sql for test
uses: actions/upload-artifact@v3
with:
Expand Down
18 changes: 17 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ configurations {
compileOnly {
extendsFrom annotationProcessor
}
all {
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.slf4j', module: 'slf4j-simple'
}
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-web'

implementation 'org.springframework.boot:spring-boot-starter-websocket'
Expand All @@ -30,24 +35,35 @@ dependencies {
implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.3'
implementation 'com.mysql:mysql-connector-j'
implementation group: 'org.bgee.log4jdbc-log4j2', name:'log4jdbc-log4j2-jdbc4.1', version: '1.16'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation group: 'it.ozimov', name: 'embedded-redis', version: '0.7.3'

implementation 'io.jsonwebtoken:jjwt-api:0.11.2'
implementation 'io.jsonwebtoken:jjwt-impl:0.11.2'
implementation 'io.jsonwebtoken:jjwt-jackson:0.11.2'

implementation platform("org.springframework.cloud:spring-cloud-dependencies:2023.0.0")
implementation "org.springframework.cloud:spring-cloud-starter-openfeign"

implementation 'com.google.code.gson:gson'

implementation 'org.springframework.boot:spring-boot-starter-validation'

compileOnly 'org.projectlombok:lombok'
implementation 'com.fasterxml.uuid:java-uuid-generator:4.3.0'

implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'

compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
annotationProcessor 'org.projectlombok:lombok'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter-test:3.0.3'
testImplementation 'com.h2database:h2'

testCompileOnly 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'

}

tasks.named('test') {
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/com/swyp3/babpool/domain/profile/api/ProfileApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.swyp3.babpool.domain.profile.api;

import com.swyp3.babpool.domain.profile.api.request.ProfileUpdateRequest;
import com.swyp3.babpool.domain.profile.application.ProfileService;
import com.swyp3.babpool.domain.profile.application.response.ProfileUpdateResponse;
import com.swyp3.babpool.global.common.response.ApiResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequiredArgsConstructor
public class ProfileApi {

private final ProfileService profileService;

@PostMapping("/api/profile/card")
public ApiResponse<ProfileUpdateResponse> updateProfileCard(@RequestAttribute(value = "userId") Long userId,
@RequestPart(value = "profileImageFile") MultipartFile multipartFile,
@RequestPart(value = "profileInfo") ProfileUpdateRequest profileUpdateRequest) {
profileService.uploadProfileImage(userId, multipartFile);
ProfileUpdateResponse profileResponse = profileService.saveProfileInfo(userId, profileUpdateRequest);
return ApiResponse.ok(profileResponse);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.swyp3.babpool.domain.profile.api;

import com.swyp3.babpool.domain.profile.api.request.ProfileListRequest;
import com.swyp3.babpool.domain.profile.application.ProfileService;
import com.swyp3.babpool.domain.profile.application.response.ProfileResponse;
import com.swyp3.babpool.global.common.response.ApiResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
public class ProfilePermitApi {

private final ProfileService profileService;

@GetMapping("/api/profile/list")
public ApiResponse<List<ProfileResponse>> getProfileList(@RequestParam String searchTerm,
@RequestParam List<String> keywords) {
return ApiResponse.ok(profileService.getProfileListInConditionsOf(ProfileListRequest.builder()
.searchTerm(searchTerm)
.keywords(keywords)
.build()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.swyp3.babpool.domain.profile.api.request;

import lombok.Builder;
import lombok.Getter;
import lombok.ToString;

import java.util.List;

@Getter
@ToString
public class ProfileListRequest {

private String searchTerm;
private List<String> keywords;

@Builder
public ProfileListRequest(String searchTerm, List<String> keywords) {
this.searchTerm = searchTerm;
this.keywords = keywords;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.swyp3.babpool.domain.profile.api.request;

import lombok.Builder;
import lombok.Getter;
import lombok.ToString;

@ToString
@Getter
public class ProfileUpdateRequest {

private String profileIntro;
private String profileContents;
private String profileContactPhone;
private String profileContactChat;

@Builder
public ProfileUpdateRequest(String profileIntro, String profileContents, String profileContactPhone, String profileContactChat) {
this.profileIntro = profileIntro;
this.profileContents = profileContents;
this.profileContactPhone = profileContactPhone;
this.profileContactChat = profileContactChat;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.swyp3.babpool.domain.profile.application;

import com.swyp3.babpool.domain.profile.api.request.ProfileListRequest;
import com.swyp3.babpool.domain.profile.api.request.ProfileUpdateRequest;
import com.swyp3.babpool.domain.profile.application.response.ProfileResponse;
import com.swyp3.babpool.domain.profile.application.response.ProfileUpdateResponse;
import com.swyp3.babpool.global.common.response.ApiResponse;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

public interface ProfileService {
List<ProfileResponse> getProfileListInConditionsOf(ProfileListRequest profileListRequest);

String uploadProfileImage(Long userId, MultipartFile multipartFile);

ProfileUpdateResponse saveProfileInfo(Long userId, ProfileUpdateRequest profileUpdateRequest);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.swyp3.babpool.domain.profile.application;

import com.swyp3.babpool.domain.profile.api.request.ProfileListRequest;
import com.swyp3.babpool.domain.profile.api.request.ProfileUpdateRequest;
import com.swyp3.babpool.domain.profile.application.response.ProfileResponse;
import com.swyp3.babpool.domain.profile.application.response.ProfileUpdateResponse;
import com.swyp3.babpool.domain.profile.dao.ProfileRepository;
import com.swyp3.babpool.domain.profile.domain.Profile;
import com.swyp3.babpool.infra.s3.application.AwsS3Provider;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Service
@RequiredArgsConstructor
public class ProfileServiceImpl implements ProfileService{

private final AwsS3Provider awsS3Provider;
private final ProfileRepository profileRepository;

@Override
public List<ProfileResponse> getProfileListInConditionsOf(ProfileListRequest profileListRequest) {
return profileRepository.findByUserIdAndSearchTermAndKeywords(profileListRequest).stream()
.map(ProfileResponse::from)
.toList();
}

@Override
public String uploadProfileImage(Long userId, MultipartFile multipartFile) {
String uploadedImageUrl = awsS3Provider.uploadImage(multipartFile);
profileRepository.saveProfileImageUrl(Profile.builder()
.userId(userId)
.profileImageUrl(uploadedImageUrl)
.build());
return uploadedImageUrl;
}

@Override
public ProfileUpdateResponse saveProfileInfo(Long userId, ProfileUpdateRequest profileUpdateRequest) {
return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.swyp3.babpool.domain.profile.application.response;

import com.swyp3.babpool.domain.profile.domain.Profile;
import lombok.Builder;
import lombok.Getter;
import lombok.ToString;

@ToString
@Getter
public class ProfileResponse {

private Long profileId;
private String profileImageUrl;
private String profileIntro;
private String profileContents;
private String profileContactPhone;
private String profileContactChat;

@Builder
public ProfileResponse(Long profileId, String profileImageUrl, String profileIntro, String profileContents, String profileContactPhone, String profileContactChat) {
this.profileId = profileId;
this.profileImageUrl = profileImageUrl;
this.profileIntro = profileIntro;
this.profileContents = profileContents;
this.profileContactPhone = profileContactPhone;
this.profileContactChat = profileContactChat;
}

public static ProfileResponse from(Profile profile) {
return ProfileResponse.builder()
.profileId(profile.getProfileId())
.profileImageUrl(profile.getProfileImageUrl())
.profileIntro(profile.getProfileIntro())
.profileContents(profile.getProfileContents())
.profileContactPhone(profile.getProfileContactPhone())
.profileContactChat(profile.getProfileContactChat())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.swyp3.babpool.domain.profile.application.response;

import lombok.Builder;
import lombok.Getter;
import lombok.ToString;

@ToString
@Getter
public class ProfileUpdateResponse {

private String profileImageUrl;
private String profileIntro;
private String profileContents;
private String profileContactPhone;
private String profileContactChat;

@Builder
public ProfileUpdateResponse(String profileImageUrl, String profileIntro, String profileContents, String profileContactPhone, String profileContactChat) {
this.profileImageUrl = profileImageUrl;
this.profileIntro = profileIntro;
this.profileContents = profileContents;
this.profileContactPhone = profileContactPhone;
this.profileContactChat = profileContactChat;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.swyp3.babpool.domain.profile.dao;

import com.swyp3.babpool.domain.profile.api.request.ProfileListRequest;
import com.swyp3.babpool.domain.profile.domain.Profile;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;
import java.util.Map;

@Mapper
public interface ProfileRepository {

void saveProfileImageUrl(Profile profile);

List<Profile> findByUserIdAndSearchTermAndKeywords(ProfileListRequest profileListRequest);
}
31 changes: 31 additions & 0 deletions src/main/java/com/swyp3/babpool/domain/profile/domain/Profile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.swyp3.babpool.domain.profile.domain;

import lombok.Builder;
import lombok.Getter;
import lombok.ToString;

@ToString
@Getter
public class Profile {

private Long profileId;
private Long userId;
private String profileImageUrl;
private String profileIntro;
private String profileContents;
private String profileContactPhone;
private String profileContactChat;
private Boolean profileActiveFlag;

@Builder
public Profile(Long profileId, Long userId, String profileImageUrl, String profileIntro, String profileContents, String profileContactPhone, String profileContactChat, Boolean profileActiveFlag) {
this.profileId = profileId;
this.userId = userId;
this.profileImageUrl = profileImageUrl;
this.profileIntro = profileIntro;
this.profileContents = profileContents;
this.profileContactPhone = profileContactPhone;
this.profileContactChat = profileContactChat;
this.profileActiveFlag = profileActiveFlag;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.swyp3.babpool.domain.profile.exception;

import com.swyp3.babpool.domain.profile.exception.errorcode.ProfileErrorCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public class ProfileException extends RuntimeException{

private final ProfileErrorCode errorCode;
private final String message;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.swyp3.babpool.domain.profile.exception.errorcode;

import com.swyp3.babpool.global.common.exception.errorcode.CustomErrorCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;

@Getter
@RequiredArgsConstructor
public enum ProfileErrorCode implements CustomErrorCode {

;

private final HttpStatus httpStatus;
private final String message;
}
Loading

0 comments on commit 4e3159e

Please sign in to comment.