Skip to content

Commit

Permalink
Merge pull request #62 from final-idea-rush/feature/BE-36
Browse files Browse the repository at this point in the history
[BE-36]
  • Loading branch information
Domae-back-end committed Sep 2, 2023
2 parents f1653ff + 994f872 commit 510f9fc
Show file tree
Hide file tree
Showing 23 changed files with 1,853 additions and 41 deletions.
1 change: 0 additions & 1 deletion idea-rush-security
Submodule idea-rush-security deleted from 8dd221
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.bid.idearush.domain.idea.controller;

import com.bid.idearush.domain.idea.model.reponse.IdeaListResponse;
import com.bid.idearush.domain.idea.model.reponse.IdeaOneResponse;
import com.bid.idearush.domain.idea.model.request.IdeaRequest;
import com.bid.idearush.domain.idea.service.IdeaService;
import com.bid.idearush.domain.idea.type.Category;
Expand Down Expand Up @@ -43,7 +44,7 @@ public Page<IdeaListResponse> findAllIdea(
}

@GetMapping("/{id}")
public IdeaListResponse findOneQuery(
public IdeaOneResponse findOneQuery(
@PathVariable Long id
) {
return ideaService.findOneIdea(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.bid.idearush.global.type.ServerIpAddress;

public record IdeaListResponse(
Long id,
String writer,
String title,
String content,
Expand All @@ -14,16 +15,5 @@ public record IdeaListResponse(
Long BidWinPrice
) {

public static IdeaListResponse from(Idea idea){
return new IdeaListResponse(
idea.getUsers().getNickname(),
idea.getTitle(),
idea.getContent(),
ServerIpAddress.s3Address+idea.getImageName(),
idea.getAuctionStatus(),
idea.getMinimumStartingPrice(),
idea.getBidWinPrice()
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.bid.idearush.domain.idea.model.reponse;

import com.bid.idearush.domain.idea.model.entity.Idea;
import com.bid.idearush.domain.idea.type.AuctionStatus;
import com.bid.idearush.domain.idea.type.Category;
import com.bid.idearush.global.type.ServerIpAddress;

import java.time.LocalDateTime;

public record IdeaOneResponse(
Long id,
String writer,
String title,
String content,
String imageUrl,
AuctionStatus status,
Long minimumStartingPrice,
Long BidWinPrice,
Long BidLastPrice,
Category category,
LocalDateTime auctionStartTime
) {


}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.bid.idearush.domain.idea.repository;

import com.bid.idearush.domain.idea.model.reponse.IdeaListResponse;
import com.bid.idearush.domain.idea.model.reponse.IdeaOneResponse;
import com.bid.idearush.domain.idea.type.Category;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
Expand All @@ -11,6 +12,6 @@ public interface IdeaRepositoryCustom {

Page<IdeaListResponse> findIdeaAll(Pageable pageable, long count);
Page<IdeaListResponse> findCategoryAndTitleAll(Category category, String keyword, Pageable pageable, long count);
Optional<IdeaListResponse> findIdeaOne(Long ideaId);
Optional<IdeaOneResponse> findIdeaOne(Long ideaId);

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package com.bid.idearush.domain.idea.repository;

import com.bid.idearush.domain.bid.model.entity.QBid;
import com.bid.idearush.domain.idea.model.entity.Idea;
import com.bid.idearush.domain.idea.model.entity.QIdea;
import com.bid.idearush.domain.idea.model.reponse.IdeaListResponse;
import com.bid.idearush.domain.idea.model.reponse.IdeaOneResponse;
import com.bid.idearush.domain.idea.type.Category;
import com.bid.idearush.domain.user.model.entity.QUsers;
import com.bid.idearush.global.type.ServerIpAddress;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Projections;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.NumberExpression;
import com.querydsl.jpa.JPAExpressions;
import com.querydsl.jpa.JPQLQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
Expand All @@ -23,6 +29,7 @@ public class IdeaRepositoryCustomImpl extends QuerydslRepositorySupport implemen

private QIdea qIdea = QIdea.idea;
private QUsers qUsers = QUsers.users;
private QBid qBid = QBid.bid;
private JPAQueryFactory queryFactory;

public IdeaRepositoryCustomImpl(JPAQueryFactory jpaQueryFactory) {
Expand All @@ -31,15 +38,23 @@ public IdeaRepositoryCustomImpl(JPAQueryFactory jpaQueryFactory) {
}

@Override
public Optional<IdeaListResponse> findIdeaOne(Long ideaId) {
return Optional.ofNullable(queryFactory.select(Projections.constructor(IdeaListResponse.class,
public Optional<IdeaOneResponse> findIdeaOne(Long ideaId) {
Expression<Long> maxBidPriceSubquery = JPAExpressions
.select(qBid.bidPrice.max())
.from(qBid)
.where(qBid.idea.id.eq(ideaId));
return Optional.ofNullable(queryFactory.select(Projections.constructor(IdeaOneResponse.class,
qUsers.id,
qUsers.nickname.as("writer"),
qIdea.title,
qIdea.content,
qIdea.imageName.concat(ServerIpAddress.s3Address).as("imageUrl"),
qIdea.auctionStatus.as("status"),
qIdea.minimumStartingPrice,
qIdea.bidWinPrice
qIdea.bidWinPrice,
maxBidPriceSubquery,
qIdea.category,
qIdea.auctionStartTime
))
.where(qIdea.id.eq(ideaId))
.from(qIdea)
Expand All @@ -50,6 +65,7 @@ public Optional<IdeaListResponse> findIdeaOne(Long ideaId) {
@Override
public Page<IdeaListResponse> findIdeaAll(Pageable pageable, long count) {
List<IdeaListResponse> results = queryFactory.select(Projections.constructor(IdeaListResponse.class,
qIdea.id,
qUsers.nickname.as("writer"),
qIdea.title,
qIdea.content,
Expand All @@ -71,6 +87,7 @@ public Page<IdeaListResponse> findIdeaAll(Pageable pageable, long count) {
@Override
public Page<IdeaListResponse> findCategoryAndTitleAll(Category category, String keyword, Pageable pageable, long count) {
List<IdeaListResponse> results = queryFactory.select(Projections.constructor(IdeaListResponse.class,
qIdea.id,
qUsers.nickname.as("writer"),
qIdea.title,
qIdea.content,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.bid.idearush.domain.idea.model.entity.Idea;
import com.bid.idearush.domain.idea.model.reponse.IdeaListResponse;
import com.bid.idearush.domain.idea.model.reponse.IdeaOneResponse;
import com.bid.idearush.domain.idea.model.request.IdeaRequest;
import com.bid.idearush.domain.idea.repository.IdeaRepository;
import com.bid.idearush.domain.idea.type.Category;
Expand Down Expand Up @@ -29,7 +30,6 @@

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

import static com.bid.idearush.global.type.ServerIpAddress.IMAGE_BASE_PATH;

Expand All @@ -43,7 +43,7 @@ public class IdeaService {
private final RedisUtil redisUtil;

@Transactional(readOnly = true)
public IdeaListResponse findOneIdea(Long ideaId) {
public IdeaOneResponse findOneIdea(Long ideaId) {
return ideaRepository.findIdeaOne(ideaId)
.orElseThrow(() -> {
throw new IdeaFindException(IdeaFindErrorCode.IDEA_EMPTY);
Expand Down Expand Up @@ -101,7 +101,6 @@ public void createIdea(IdeaRequest ideaRequest, MultipartFile image, Long userId
}
imageName = image.getOriginalFilename();
}

redisUtil.setIdeaCount(getCount()+1);

Idea newIdea = ideaRequest.toIdea(user, imageName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.requestMatchers(HttpMethod.GET, "/api/ideas/{id}/notice").authenticated()
.requestMatchers(HttpMethod.GET, "/api/sse/connect/idea/**").permitAll()
.requestMatchers("/chat/**").permitAll()
.requestMatchers("/view/**").permitAll()
.requestMatchers("/image/**").permitAll()
.anyRequest()
.authenticated()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
requestURI.matches("/api/ideas/.*") ||
requestURI.matches("/api/ideas/.*/bid")) &&
"GET".equalsIgnoreCase(method)) ||
requestURI.matches("/chat/.*")) {
requestURI.matches("/chat/.*") || requestURI.matches("/view/.*") || requestURI.matches("/image/.*")) {
filterChain.doFilter(request, response);
return;
}
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/com/bid/idearush/global/view/ViewController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.bid.idearush.global.view;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/view")
public class ViewController {

@GetMapping("/pageDetail")
public String ideaDetailPage() {
return "ideaDetail1";
}

@GetMapping("/pageMain")
public String ideaMainPage() {
return "page/ideaMain";
}

@GetMapping("/pageWrite")
public String ideaWritePage() {
return "page/ideaWrite";
}

@GetMapping("/pageUpdate")
public String ideaUpdatePage() {
return "page/ideaUpdate";
}
@GetMapping("/pageSignup")
public String signupPage() {
return "page/signup";
}

@GetMapping("/pageLogin")
public String loginPage() {
return "page/login";
}

}
Empty file.
Empty file.
Binary file added src/main/resources/static/image/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions src/main/resources/static/image/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
16 changes: 8 additions & 8 deletions src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<html>
<head>
<meta charset="utf-8" />
<script>
const eventSource = new EventSource("/api/sse/connect/user/1")
eventSource.addEventListener("NOTICE_BID_START_BEFORE", function(e){
const p = document.createElement("p")
p.innerText = e.data
<!-- <script>-->
<!-- const eventSource = new EventSource("/api/sse/connect/user/1")-->
<!-- eventSource.addEventListener("NOTICE_BID_START_BEFORE", function(e){-->
<!-- const p = document.createElement("p")-->
<!-- p.innerText = e.data-->

document.getElementById("messages").appendChild(p)
})
</script>
<!-- document.getElementById("messages").appendChild(p)-->
<!-- })-->
<!-- </script>-->
</head>

<body>
Expand Down
Loading

0 comments on commit 510f9fc

Please sign in to comment.