Skip to content

Commit

Permalink
feat: 동아리 점수 소수점 가능하도록 정책 변경 (#36)
Browse files Browse the repository at this point in the history
Co-authored-by: 5uhwann <[email protected]>
Co-authored-by: MinsuKim <[email protected]>
  • Loading branch information
3 people authored Sep 17, 2023
1 parent 9cf7a62 commit bc1bae1
Show file tree
Hide file tree
Showing 19 changed files with 270 additions and 188 deletions.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Bug report(버그 수정 템플릿)
about: 버그 제보 관련 템플릿
title: ''
labels: ''
assignees: ''
---

## 버그 사항
버그 내용을 상세하게 적어주세요!
<!-- 버그를 발견하기 위한 순서가 있다면, 함께 기록해주세요. -->

## 기대했던 상황
원했던 상황을 자세하게 적어주세요 😊


## **Screenshots**
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE/default-issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Default Issue
about: 기본 양식
title: ''
labels: ''
assignees: ''
---

## ❓ 어떤 이슈인가요?


## ✅ 투두리스트

- [ ] item
- [ ] item
11 changes: 11 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## 🔥 연관 이슈

- close #이슈번호

## 🚀 작업 내용


## 🤔 고민했던 내용


## 💬 리뷰 중점사항
2 changes: 1 addition & 1 deletion .platform/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ http {
}

server {
listen 80 default_server;
listen 80 default_server;

location / {
proxy_pass http://springboot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ddingdong.ddingdongBE.domain.club.entity.Club;
import ddingdong.ddingdongBE.domain.club.entity.Location;
import ddingdong.ddingdongBE.domain.club.entity.PhoneNumber;
import ddingdong.ddingdongBE.domain.club.entity.Score;
import ddingdong.ddingdongBE.domain.scorehistory.entity.Score;
import ddingdong.ddingdongBE.domain.user.entity.User;
import lombok.Getter;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package ddingdong.ddingdongBE.domain.club.controller.dto.request;

import com.fasterxml.jackson.annotation.JsonFormat;
import java.time.LocalDateTime;
import java.util.List;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.format.annotation.DateTimeFormat;

@Getter
@AllArgsConstructor
Expand All @@ -26,11 +22,9 @@ public class UpdateClubRequest {

private String location;

@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
private LocalDateTime startRecruitPeriod;
private String startRecruitPeriod;

@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
private LocalDateTime endRecruitPeriod;
private String endRecruitPeriod;

private String regularMeeting;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public class AdminClubResponse {

private String category;

private int score;
private float score;

private List<String> profileImageUrls;

@Builder
private AdminClubResponse(Long id, String name, String category, int score, List<String> profileImageUrls) {
private AdminClubResponse(Long id, String name, String category, float score, List<String> profileImageUrls) {
this.id = id;
this.name = name;
this.category = category;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ public class ClubResponse {

private String tag;

private boolean isRecruit;
private String recruitStatus;

@Builder
public ClubResponse(Long id, String name, String category, String tag, boolean isRecruit) {
public ClubResponse(Long id, String name, String category, String tag, String recruitStatus) {
this.id = id;
this.name = name;
this.category = category;
this.tag = tag;
this.isRecruit = isRecruit;
this.recruitStatus = recruitStatus;
}

public static ClubResponse of(Club club, boolean isRecruit) {
public static ClubResponse of(Club club, String recruitStatus) {
return ClubResponse.builder()
.id(club.getId())
.name(club.getName())
.category(club.getCategory())
.tag(club.getTag())
.isRecruit(isRecruit).build();
.recruitStatus(recruitStatus).build();
}

}
13 changes: 10 additions & 3 deletions src/main/java/ddingdong/ddingdongBE/domain/club/entity/Club.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import ddingdong.ddingdongBE.common.BaseEntity;
import ddingdong.ddingdongBE.domain.club.controller.dto.request.UpdateClubRequest;
import ddingdong.ddingdongBE.domain.scorehistory.entity.Score;
import ddingdong.ddingdongBE.domain.user.entity.User;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Embedded;
Expand Down Expand Up @@ -94,17 +96,22 @@ public void updateClubInfo(UpdateClubRequest request) {
request.getPhoneNumber() != null ? PhoneNumber.of(request.getPhoneNumber()) : this.phoneNumber;
this.location = request.getLocation() != null ? Location.of(request.getLocation()) : this.location;
this.startRecruitPeriod =
request.getStartRecruitPeriod() != null ? request.getStartRecruitPeriod() : this.startRecruitPeriod;
request.getStartRecruitPeriod().isBlank() ? null : parseLocalDateTime(request.getStartRecruitPeriod());
this.endRecruitPeriod =
request.getEndRecruitPeriod() != null ? request.getEndRecruitPeriod() : this.endRecruitPeriod;
request.getEndRecruitPeriod().isBlank() ? null : parseLocalDateTime(request.getEndRecruitPeriod());
this.regularMeeting = request.getRegularMeeting() != null ? request.getRegularMeeting() : this.regularMeeting;
this.introduction = request.getIntroduction() != null ? request.getIntroduction() : this.introduction;
this.activity = request.getActivity() != null ? request.getActivity() : this.activity;
this.ideal = request.getIdeal() != null ? request.getIdeal() : this.ideal;
this.formUrl = request.getFormUrl() != null ? request.getFormUrl() : this.formUrl;
}

public int editScore(Score score) {
private static LocalDateTime parseLocalDateTime(String inputLocalDateTimeFormat) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
return LocalDateTime.parse(inputLocalDateTimeFormat, formatter);
}

public float editScore(Score score) {
this.score = score;

return this.score.getValue();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package ddingdong.ddingdongBE.domain.club.entity;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum RecruitmentStatus {

BEFORE_RECRUIT("모집 예정"),
RECRUITING("모집 중"),
END_RECRUIT("모집 마감");

private final String text;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
package ddingdong.ddingdongBE.domain.club.repository;

import ddingdong.ddingdongBE.domain.club.entity.ClubMember;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

public interface ClubMemberRepository extends JpaRepository<ClubMember, Long> {
List<ClubMember> findClubMembersByClubId(Long clubId);

}
@Modifying
@Transactional
@Query("delete from ClubMember c where c.id in :memberIds")
void deleteAllById(List<Long> memberIds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import ddingdong.ddingdongBE.domain.club.entity.ClubMember;
import ddingdong.ddingdongBE.domain.club.repository.ClubMemberRepository;
import ddingdong.ddingdongBE.domain.club.repository.ClubRepository;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import javax.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand All @@ -24,11 +26,19 @@ public void updateClubMembers(Long userId, UpdateClubMemberRequest request) {
Club club = clubRepository.findByUserId(userId)
.orElseThrow(() -> new IllegalArgumentException(NO_SUCH_CLUB.getText()));

List<Long> memberIds = clubMemberRepository.findClubMembersByClubId(club.getId())
.stream()
.map(ClubMember::getId)
.toList();

List<ClubMember> requestedClubMembers = request.getClubMemberList().stream()
.map(clubMemberDto -> clubMemberDto.toEntity(club))
.toList();

clubMemberRepository.deleteAll();
if (!memberIds.isEmpty()) {
clubMemberRepository.deleteAllById(memberIds);
}

clubMemberRepository.saveAll(requestedClubMembers);
}
}
}
Loading

0 comments on commit bc1bae1

Please sign in to comment.