Skip to content

Commit

Permalink
Merge branch 'develop' into feature/#140
Browse files Browse the repository at this point in the history
  • Loading branch information
xxoznge authored Feb 10, 2024
2 parents b8a269b + d55c805 commit 2b2daff
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 57 deletions.
15 changes: 6 additions & 9 deletions http/test.http
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,11 @@ Content-Type: application/json

{
"name": "팀 스포너스",
"email": "sponus@gmail.com",
"email": "sponus_student@gmail.com",
"password": "password1234",
"location": "none",
"organizationType": "STUDENT",
"suborganizationType": "STUDENT_COUNCIL",
"managerName": "이가은",
"managerPosition": "Project Manager",
"managerEmail": "[email protected]",
"managerPhone": "01012345678",
"managerAvailableDay": "월-금",
"managerAvailableHour": "15:00-18:00",
"managerContactPreference": "EMAIL"
"suborganizationType": "STUDENT_COUNCIL"
}

### 로그인
Expand Down Expand Up @@ -161,6 +154,10 @@ Authorization: Bearer {{masterToken}}
GET http://localhost:8080/api/v1/organizations/1
Authorization: Bearer {{matsterToken}}

### 조직 검색
GET http://localhost:8080/api/v1/organizations?search=스포너스
Authorization: Bearer {{matsterToken}}

### 이메일 인증
POST http://localhost:8080/api/v1/organizations/email?email=이메일

Expand Down
6 changes: 4 additions & 2 deletions out/production/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ INSERT INTO organization (organization_name,
manager_available_day,
manager_available_hour,
manager_contact_preference,
organization_status)
organization_status,
organization_image_url)
VALUES ('팀 스포너스',
'[email protected]',
'$2a$10$tzrzG/BSFrrye7Kbm4qPYuP6jaQcj5TX5ER1.X/THqkudiSjtEmWW',
Expand All @@ -25,7 +26,8 @@ VALUES ('팀 스포너스',
'월-금',
'09:00-18:00',
'EMAIL',
'ACTIVE');
'ACTIVE',
'https://sponus.s3.ap-northeast-2.amazonaws.com/images/56d5e787-8ac2-4162-be41-e55db05d8d8b.png');

INSERT INTO announcement (announcement_title,
announcement_type,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.sponus.sponusbe.domain.organization.controller;

import java.util.List;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
Expand All @@ -14,6 +16,7 @@
import com.sponus.sponusbe.domain.organization.dto.OrganizationDetailGetResponse;
import com.sponus.sponusbe.domain.organization.dto.OrganizationJoinRequest;
import com.sponus.sponusbe.domain.organization.dto.OrganizationJoinResponse;
import com.sponus.sponusbe.domain.organization.dto.OrganizationSummaryResponse;
import com.sponus.sponusbe.domain.organization.dto.OrganizationUpdateRequest;
import com.sponus.sponusbe.domain.organization.entity.Organization;
import com.sponus.sponusbe.domain.organization.service.OrganizationQueryService;
Expand Down Expand Up @@ -73,4 +76,9 @@ public ApiResponse<OrganizationDetailGetResponse> getOrganization(@PathVariable
public ApiResponse<String> sendEmail(@RequestParam("email") String email) throws Exception {
return ApiResponse.onSuccess(organizationService.sendEmail(email));
}

@GetMapping
public ApiResponse<List<OrganizationSummaryResponse>> searchOrganization(@RequestParam("search") String keyword) {
return ApiResponse.onSuccess(organizationService.searchOrganization(keyword));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,53 +22,19 @@ public record OrganizationJoinRequest(
@Size(min = 10, message = "[ERROR] 비밀번호는 최소 10자리 이이어야 합니다.")
String password,

@NotBlank(message = "[ERROR] 위치 입력은 필수 입니다.")
String location,

@NotNull(message = "[ERROR] 단체 유형 입력은 필수입니다.")
OrganizationType organizationType,

@NotNull(message = "[ERROR] 단체 서브 유형 입력은 필수입니다.")
SuborganizationType suborganizationType,

@NotBlank(message = "[ERROR] 담당자 이름 입력은 필수입니다.")
String managerName,

@NotBlank(message = "[ERROR] 담당자 직책 입력은 필수입니다.")
String managerPosition,

@NotBlank(message = "[ERROR] 담당자 이메일 입력은 필수입니다.")
@Pattern(regexp = "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,6}$", message = "[ERROR] 이메일 형식에 맞지 않습니다.")
String managerEmail,

@NotBlank(message = "[ERROR] 담당자 전화번호 입력은 필수입니다.")
String managerPhone,

@NotBlank(message = "[ERROR] 담당자 연락 가능 요일 입력은 필수입니다.")
String managerAvailableDay,

@NotBlank(message = "[ERROR] 담당자 연락 가능 시간 입력은 필수입니다.")
String managerAvailableHour,

@NotBlank(message = "[ERROR] 담당자 연락 선호 방법 입력은 필수입니다.")
String managerContactPreference
SuborganizationType suborganizationType
) {

public Organization toEntity(String encodedPassword) {
return Organization.builder()
.name(name)
.email(email)
.password(encodedPassword)
.location(location)
.organizationType(organizationType)
.suborganizationType(suborganizationType)
.managerName(managerName)
.managerPosition(managerPosition)
.managerEmail(managerEmail)
.managerPhone(managerPhone)
.managerAvailableDay(managerAvailableDay)
.managerAvailableHour(managerAvailableHour)
.managerContactPreference(managerContactPreference)
.organizationStatus(OrganizationStatus.ACTIVE)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.sponus.sponusbe.domain.organization.dto;

import java.util.List;

import com.sponus.sponusbe.domain.organization.entity.Organization;
import com.sponus.sponusbe.domain.tag.dto.TagGetResponse;

import lombok.Builder;

@Builder
public record OrganizationSummaryResponse(
Long id,
String name,
String image,
List<TagGetResponse> tags
) {
public static OrganizationSummaryResponse from(Organization organization) {
List<TagGetResponse> tags = TagGetResponse.getTagResponse(organization);

return OrganizationSummaryResponse.builder()
.id(organization.getId())
.name(organization.getName())
.image(organization.getImageUrl())
.tags(tags)
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class Organization extends BaseEntity {
@Column(name = "organization_password", nullable = false)
private String password;

@Column(name = "organization_location", nullable = false)
@Column(name = "organization_location")
private String location;

@Column(name = "organization_description")
Expand All @@ -62,29 +62,29 @@ public class Organization extends BaseEntity {
@Enumerated(EnumType.STRING)
private OrganizationType organizationType;

@Column(name = "suborganization_type", nullable = false)
@Column(name = "suborganization_type")
@Enumerated(EnumType.STRING)
private SuborganizationType suborganizationType;

@Column(name = "manager_name", nullable = false)
@Column(name = "manager_name")
private String managerName;

@Column(name = "manager_position", nullable = false)
@Column(name = "manager_position")
private String managerPosition;

@Column(name = "manager_email", nullable = false)
@Column(name = "manager_email")
private String managerEmail;

@Column(name = "manager_phone", nullable = false)
@Column(name = "manager_phone")
private String managerPhone;

@Column(name = "manager_available_day", nullable = false)
@Column(name = "manager_available_day")
private String managerAvailableDay;

@Column(name = "manager_available_hour", nullable = false)
@Column(name = "manager_available_hour")
private String managerAvailableHour;

@Column(name = "manager_contact_preference", nullable = false)
@Column(name = "manager_contact_preference")
private String managerContactPreference;

// TODO 알림 허용 여부
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.sponus.sponusbe.domain.organization.repository;

import java.util.List;
import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;
Expand All @@ -9,4 +10,6 @@
public interface OrganizationRepository extends JpaRepository<Organization, Long> {

Optional<Organization> findOrganizationByEmail(String email);

List<Organization> findByNameContains(String name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static com.sponus.sponusbe.domain.organization.exception.OrganizationErrorCode.*;

import java.util.List;
import java.util.Random;

import org.springframework.mail.javamail.JavaMailSender;
Expand All @@ -11,6 +12,7 @@

import com.sponus.sponusbe.domain.organization.dto.OrganizationJoinRequest;
import com.sponus.sponusbe.domain.organization.dto.OrganizationJoinResponse;
import com.sponus.sponusbe.domain.organization.dto.OrganizationSummaryResponse;
import com.sponus.sponusbe.domain.organization.dto.OrganizationUpdateRequest;
import com.sponus.sponusbe.domain.organization.entity.Organization;
import com.sponus.sponusbe.domain.organization.exception.OrganizationException;
Expand Down Expand Up @@ -101,4 +103,11 @@ public static String createEmailCode() {
}
return code.toString();
}

public List<OrganizationSummaryResponse> searchOrganization(String keyword) {
return organizationRepository.findByNameContains(keyword)
.stream()
.map(OrganizationSummaryResponse::from)
.toList();
}
}
6 changes: 4 additions & 2 deletions src/main/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ INSERT INTO organization (organization_name,
manager_available_day,
manager_available_hour,
manager_contact_preference,
organization_status)
organization_status,
organization_image_url)
VALUES ('팀 스포너스',
'[email protected]',
'$2a$10$tzrzG/BSFrrye7Kbm4qPYuP6jaQcj5TX5ER1.X/THqkudiSjtEmWW',
Expand All @@ -25,7 +26,8 @@ VALUES ('팀 스포너스',
'월-금',
'09:00-18:00',
'EMAIL',
'ACTIVE');
'ACTIVE',
'https://sponus.s3.ap-northeast-2.amazonaws.com/images/56d5e787-8ac2-4162-be41-e55db05d8d8b.png');

INSERT INTO announcement (announcement_title,
announcement_type,
Expand Down

0 comments on commit 2b2daff

Please sign in to comment.