Skip to content

Commit

Permalink
feat: sell-to-all 추가
Browse files Browse the repository at this point in the history
Feat/sell-to-all
  • Loading branch information
yj-leez authored Nov 9, 2023
2 parents 136f738 + 86d1445 commit 8aff1e0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/main/java/wowmarket/wow_server/domain/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public class Project extends BaseEntity{
@Column(columnDefinition = "integer default 0", nullable = false)
private int view; //조회수

@Column(columnDefinition = "tinyint(0) default 1")
private boolean sellToAll; // 0-> 소속 대학 학생, 1-> 전체 학생

public void setUser(User user){
this.user = user;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public class RegisterProjectDto {
private String account_holder_name;
@NotNull
private String nickname;
@NotNull
private Boolean sell_to_all;


@Builder
Expand All @@ -71,6 +73,7 @@ public Project toEntity(){
.account(account)
.account_holder_name(account_holder_name)
.nickname(nickname)
.sellToAll(sell_to_all)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.server.ResponseStatusException;
import wowmarket.wow_server.domain.*;
import wowmarket.wow_server.global.jwt.SecurityUtil;
import wowmarket.wow_server.register.dto.RegisterDemandProjectDto;
import wowmarket.wow_server.register.dto.RegisterProjectDto;
import wowmarket.wow_server.repository.*;
Expand Down Expand Up @@ -37,6 +35,10 @@ public Long registerProject(RegisterProjectDto requestDto, User user) throws Exc
if(user != null) project.setUser(user);
else throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "유저를 찾을 수 없습니다"); //유저 없을 시 400 에러 반환

// 소속 학생만 구매 가능하도록 설정했지만 판매자의 학교 인증이 안 됐을 경우
if(!project.isSellToAll() && !user.isUniv_check())
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "학교 인증이 확인되지 않았습니다.");

projectRepository.save(project);

for (int i = 0; i < requestDto.getItem().size(); i++) {
Expand Down

0 comments on commit 8aff1e0

Please sign in to comment.