Skip to content

Commit

Permalink
✨ feat: 10차 배포
Browse files Browse the repository at this point in the history
✨ feat: 10차 배포
  • Loading branch information
sunnyineverywhere authored Oct 17, 2023
2 parents e705133 + cec473b commit ba897e1
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 16 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ buildscript {
}
}


plugins {
id 'java'
id 'org.springframework.boot' version '2.7.13'
Expand Down
2 changes: 2 additions & 0 deletions snapspot-api/src/main/java/snap/ApiApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

import javax.annotation.PostConstruct;
import java.util.TimeZone;

@EnableJpaAuditing
@EntityScan(basePackages = {"snap"})
@EnableJpaRepositories(basePackages = {"snap"})
@SpringBootApplication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
import snap.domains.message.entity.Sender;
import snap.enums.Role;

import java.time.LocalDateTime;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class MessageResponseDto {
private Long messageId;
private Boolean isMine;
private Sender sender;
private String contents;
private LocalDateTime createdAt;

public MessageResponseDto(Message message, Member member) {
Sender sender = Sender.MEMBER;
Expand All @@ -27,5 +30,6 @@ public MessageResponseDto(Message message, Member member) {
this.contents = message.getContents();
this.sender = message.getSender();
this.isMine = sender.equals(message.getSender());
this.createdAt = message.getCreatedAt();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,13 @@ public Message createMessage(Member member, MessageRequestDto request) {
}
Plan plan = planDomainService.findByPlanId(request.getPlanId());


if (!plan.getCustomer().getMemberId().equals(member.getMemberId()))
{
if (!plan.getPhotographer().getMember().getMemberId().equals(member.getMemberId())) {
throw new IllegalArgumentException("사진 촬영 일정에 대해 권한이 있는 일반 계정 혹은 사진작가 계정이 아닙니다.");
}
}



return messageDomainService.createMessage(
plan,
request.getContents(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class PlanFullResponseDto {
private String y;
private Status status;
private List<MessageResponseDto> messages;
private LocalDateTime createdAt;
private LocalDateTime modifiedAt;

@Builder
public PlanFullResponseDto(Plan plan, Member member, List<Message> messageList) {
Expand All @@ -59,5 +61,7 @@ public PlanFullResponseDto(Plan plan, Member member, List<Message> messageList)
this.messages = messageList.stream()
.map(message -> new MessageResponseDto(message, member))
.collect(Collectors.toList());
this.createdAt = plan.getCreatedAt();
this.modifiedAt = plan.getModifiedAt();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class PlanResponseDto {
private Long price;
private String request;
private Status status;
private LocalDateTime createdAt;
private LocalDateTime modifiedAt;

@Builder
public PlanResponseDto(Plan plan) {
Expand All @@ -47,5 +49,7 @@ public PlanResponseDto(Plan plan) {
this.wishPlace = plan.getWishPlace();
this.request = plan.getRequest();
this.status = plan.getStatus();
this.createdAt = plan.getCreatedAt();
this.modifiedAt = plan.getModifiedAt();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.UUID;
import java.util.stream.Collectors;

@Slf4j
@Service
@RequiredArgsConstructor
public class PlanService {
Expand All @@ -46,6 +47,7 @@ public PlanResponseDto createRequest(Member member, PlanRequestDto requestDto) {

public PlanFullResponseDto createDeposit(Member member, DepositRequestDto requestDto) throws ParseException {
JSONObject coordinate = kakaoClient.getCoordinateFromAddress(requestDto.getPlaceAddress());
log.info((String) coordinate.get("x"), (String) coordinate.get("y"));
Plan plan = planDomainService.createDeposit(requestDto.toEntity(), (String) coordinate.get("x"), (String) coordinate.get("y"));
return new PlanFullResponseDto(plan, member, messageDomainService.findByPlanId(plan.getPlanId()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public List<ReviewResponseDto> findReviewListByMember(Member member) {
return reviewList.stream().map(ReviewResponseDto::new).collect(Collectors.toList());
}

@Transactional(readOnly = true)
public List<ReviewResponseDto> findReviewListByPhotographer(Photographer photographer) {
return reviewDomainService.findReviewListByPhotographer(photographer)
.stream().map(ReviewResponseDto::new).collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package snap.domains.global.entity;

import lombok.Getter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.time.LocalDateTime;

@Getter
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public class BaseTimeEntity {
@CreatedDate
@Column(updatable = false, columnDefinition = "TIMESTAMP")
private LocalDateTime createdAt;

@LastModifiedDate
@Column(columnDefinition = "TIMESTAMP")
private LocalDateTime modifiedAt;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import snap.domains.global.entity.BaseTimeEntity;
import snap.domains.plan.entity.Plan;

import javax.persistence.*;
import java.time.LocalDateTime;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Message {
public class Message extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long messageId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import snap.domains.global.entity.BaseTimeEntity;
import snap.domains.member.entity.Member;
import snap.domains.photographer.entity.Photographer;
import snap.domains.review.entity.Review;
Expand All @@ -21,7 +22,7 @@
@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Plan {
public class Plan extends BaseTimeEntity {
@Id
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy = "org.hibernate.id.UUIDGenerator")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@

public interface PlanJPARepository extends JpaRepository<Plan, UUID> {

List<Plan> findAllByCustomer(Member member);
List<Plan> findAllByPhotographer(Photographer photographer);
List<Plan> findAllByCustomerOrderByCreatedAtDesc(Member member);
List<Plan> findAllByPhotographerOrderByCreatedAtDesc(Photographer photographer);

List<Plan> findAllByPhotographerAndStatus(Photographer photographer, Status status1);

List<Plan> findAllByPhotographerAndStatusOrStatus(Photographer photographer, Status status1, Status status2);
List<Plan> findAllByPhotographerAndStatusOrStatusOrderByCreatedAtDesc(Photographer photographer, Status status1, Status status2);
List<Plan> findAllByPhotographerAndStatusOrStatusOrStatusOrderByCreatedAtDesc(Photographer photographer, Status status1, Status status2, Status status3);

List<Plan> findAllByPhotographerAndStatusOrStatusOrStatus(Photographer photographer, Status status1, Status status2, Status status3);

Optional<Plan> findByPlanIdAndCustomer(UUID planId, Member member);

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class PlanQueryDslRepository {
private final EntityManager em;
private final JPAQueryFactory queryFactory;


public void changePlanStatusOfToday() {
LocalDateTime now = LocalDateTime.now();
now = LocalDateTime.of(now.getYear(), now.getMonth(), now.getDayOfMonth(), 0, 0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ public Plan updateState(Plan plan, Status status) {

@Transactional(readOnly = true)
public List<Plan> findByPhotographer(Photographer photographer) {
return planRepository.findAllByPhotographer(photographer);
return planRepository.findAllByPhotographerOrderByCreatedAtDesc(photographer);
}

@Transactional(readOnly = true)
public List<Plan> findByMember(Member member) {
return planRepository.findAllByCustomer(member);
return planRepository.findAllByCustomerOrderByCreatedAtDesc(member);
}

public Plan findByPlanIdAndMember(UUID planId, Member member) {
Expand All @@ -100,12 +100,12 @@ public void updateStateOfComplete() {

@Transactional(readOnly = true)
public List<Plan> findByPhotographerAndStatus1(Photographer photographer, Status status, Status status1) {
return planRepository.findAllByPhotographerAndStatusOrStatus(photographer, status, status1);
return planRepository.findAllByPhotographerAndStatusOrStatusOrderByCreatedAtDesc(photographer, status, status1);
}

@Transactional(readOnly = true)
public List<Plan> findByPhotographerAndStatus(Photographer photographer, Status status, Status status1, Status status2) {
return planRepository.findAllByPhotographerAndStatusOrStatusOrStatus(photographer,status,status1,status2);
return planRepository.findAllByPhotographerAndStatusOrStatusOrStatusOrderByCreatedAtDesc(photographer,status,status1,status2);
}

public void changePlan(
Expand Down

0 comments on commit ba897e1

Please sign in to comment.