Skip to content

Commit

Permalink
Merge pull request #41 from LminWoo99/msa-develop
Browse files Browse the repository at this point in the history
ver 2.0.0
  • Loading branch information
LminWoo99 authored May 16, 2024
2 parents 546e00a + 57c8ceb commit 4da98ce
Show file tree
Hide file tree
Showing 68 changed files with 929 additions and 329 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Plant.PlantProject.common.config;
package Plant.PlantProject.common.config.auth;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Plant.PlantProject.common.config;
package Plant.PlantProject.common.config.auth;


import Plant.PlantProject.repository.MemberRepository;
Expand All @@ -17,7 +17,6 @@
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

import static org.springframework.http.HttpMethod.GET;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package Plant.PlantProject.common.config.kafka;

import Plant.PlantProject.dto.response.NotificationEventDto;
import com.google.common.collect.ImmutableMap;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.common.serialization.StringSerializer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.kafka.core.DefaultKafkaProducerFactory;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.core.ProducerFactory;
import org.springframework.kafka.support.serializer.JsonSerializer;

import java.util.List;
import java.util.Map;

@EnableKafka
@Configuration
public class KafkaProducerConfig {
//Kafka ProduceFactory를 생성하는 Bean 메서드
@Value("${kafka.url}")
private String kafkaServerUrl;
@Bean
public ProducerFactory<String, String> producerFactory() {
return new DefaultKafkaProducerFactory<>(producerConfigurations());
} // Kafka Producer 구성을 위한 설정값들을 포함한 맵을 반환하는 메서드
@Bean
public Map<String, Object> producerConfigurations() {
return ImmutableMap.<String, Object>builder()
.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaServerUrl)
.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class)
.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class)
.build();
}
// KafkaTemplate을 생성하는 Bean 메서드
@Bean
public KafkaTemplate<String, String> kafkaTemplate() {
return new KafkaTemplate<>(producerFactory());
}
@Bean
public ProducerFactory<String, NotificationEventDto> notificationProducerFactory() {
return new DefaultKafkaProducerFactory<>(producerConfigurations());
}
@Bean
public KafkaTemplate<String, NotificationEventDto> notificationKafkaTemplate() {
return new KafkaTemplate<>(notificationProducerFactory());
}
@Bean
public ProducerFactory<String, Long> deletePostProducerFactory() {
return new DefaultKafkaProducerFactory<>(producerConfigurations());
}
@Bean
public KafkaTemplate<String, Long> deletePostKafkaTemplate() {
return new KafkaTemplate<>(deletePostProducerFactory());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public enum ErrorCode {
PLANT_NOT_FOUND(NOT_FOUND, "식물 정보를 조회할 수 없습니다", "017"),
USER_DUPLICATED_ID(CONFLICT, "이미 가입된 아이디입니다", "018"),
USER_DUPLICATED_EMAIL(CONFLICT, "이미 가입된 이메일입니다", "019"),
MAX_FILE_SIZE_EXCEEDED(PAYLOAD_TOO_LARGE, "파일 크기가 허용되는 최대치를 초과하였습니다.", "025");
MAX_FILE_SIZE_EXCEEDED(PAYLOAD_TOO_LARGE, "파일 크기가 허용되는 최대치를 초과하였습니다.", "025"),
KEYWORD_NOT_FOUND(NOT_FOUND, "파일 크기가 허용되는 최대치를 초과하였습니다.", "027");


private final HttpStatus httpStatus;
Expand Down Expand Up @@ -67,4 +68,8 @@ public static CustomException throwMaxFileSizeExceeded() {
throw new CustomException(MAX_FILE_SIZE_EXCEEDED);
}

public static CustomException throwKeywordNotFound() {
throw new CustomException(KEYWORD_NOT_FOUND);
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package Plant.PlantProject.common.security;

import Plant.PlantProject.common.config.JwtTokenUtil;
import Plant.PlantProject.common.config.auth.JwtTokenUtil;
import Plant.PlantProject.domain.Entity.Member;
import Plant.PlantProject.common.exception.ErrorCode;
import Plant.PlantProject.repository.MemberRepository;
import Plant.PlantProject.service.user.RefreshTokenService;
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationServiceException;
Expand All @@ -28,7 +25,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package Plant.PlantProject.common.util;

import com.querydsl.core.types.Order;
import lombok.Data;
import lombok.Getter;

@Getter
public enum SearchParam {
MANAGE("manage"),
CATEGORY("category");




private final String paramKey;

SearchParam(String paramKey) {
this.paramKey = paramKey;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package Plant.PlantProject.controller.keyword;

import Plant.PlantProject.dto.request.KeywordRequestDto;
import Plant.PlantProject.dto.response.KeywordResponseDto;
import Plant.PlantProject.service.keyword.KeywordService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
public class KeywordController {
private final KeywordService keywordService;

@GetMapping("/keyword/{memberNo}")
@Operation(summary = "유저 기능- 설정한 키워드 조회", description = "유저가 설정한 키워드 조회 조회 할 수 있는 API")
private ResponseEntity<List<KeywordResponseDto>> getKeywordList(@PathVariable("memberNo") Integer memberNo) {

List<KeywordResponseDto> keywordList = keywordService.getKeywordList(memberNo);
return ResponseEntity.ok().body(keywordList);
}
@PostMapping("/keyword")
@Operation(summary = "유저 기능- 키워드 설정", description = "유저가 알림을 받기 위한 키워드 설정 할 수 있는 API")
private ResponseEntity<Long> saveKeyWord(@RequestBody KeywordRequestDto keywordRequestDto) {

Long keyWordId = keywordService.saveKeyWord(keywordRequestDto);
return ResponseEntity.ok().body(keyWordId);
}
@DeleteMapping("/keyword/{keywordId}")
@Operation(summary = "유저 기능- 설정한 키워드 삭제", description = "유저가 설정한 키워드 삭제할 수 있는 API")
private void getKeywordList(@PathVariable("keywordId") Long keywordId) {

keywordService.deleteKeyWord(keywordId);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package Plant.PlantProject.controller.plantinfo;

import Plant.PlantProject.vo.response.PlantResponseDto;
import Plant.PlantProject.service.plantinfo.PlantService;
import Plant.PlantProject.dto.response.PlantResponseDto;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
Expand All @@ -11,27 +11,33 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class PlantController {
private final PlantService plantService;
@GetMapping("plantList")
@Operation(summary = "식구 도감- 식물 조회", description = "식물 전체 정보를 조회 할 수 있는 API")
private ResponseEntity<Page<PlantResponseDto>> plantList(@RequestParam(required = false, defaultValue = "") String search, @PageableDefault(size = 15, sort = "id", direction = Sort.Direction.DESC)
Pageable pageable) {
Page<PlantResponseDto> plantDtos = plantService.plantList(search, pageable);
return ResponseEntity.ok(plantDtos);
private ResponseEntity<Page<PlantResponseDto>> plantList(@RequestParam(required = false, defaultValue = "") String search
, @PageableDefault(size = 15, sort = "id", direction = Sort.Direction.DESC) Pageable pageable) {

Page<PlantResponseDto> plantResponseDtoList = plantService.plantList(search, pageable);
return ResponseEntity.ok().body(plantResponseDtoList);
}

@GetMapping("/plantList/{id}")
@Operation(summary = "식구 도감- 식물 자세한 정보 조회", description = "식물에 관한 자세한 정보를 조회 할 수 있는 API")
private ResponseEntity<PlantResponseDto> plantDetail(@PathVariable("id") Long id) {
System.out.println("plant 호출");
return ResponseEntity.ok().body(plantService.plantDetail(id));
}
// @GetMapping("/plant")
// private void start() throws IOException {
// plantService.start();
// }
@GetMapping("/plantList/condition")
@Operation(summary = "식구 도감- 식물 조건 별 정보 조회", description = "식물에 관한 정보를 동적 쿼리를 활용하여 조건 별로 조회 할 수 있는 API")
public ResponseEntity<List<PlantResponseDto>> getPlantByCondition(@RequestParam Map<String, String> searchCondition){
List<PlantResponseDto> plantResponseDtoList = plantService.getPlantByCondition(searchCondition);

return ResponseEntity.ok().body(plantResponseDtoList);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package Plant.PlantProject.controller.tradeboard;

import Plant.PlantProject.vo.response.GoodsResponseDto;
import Plant.PlantProject.vo.request.GoodsRequestDto;
import Plant.PlantProject.vo.response.TradeBoardResponseDto;
import Plant.PlantProject.dto.response.GoodsResponseDto;
import Plant.PlantProject.dto.request.GoodsRequestDto;
import Plant.PlantProject.dto.response.TradeBoardResponseDto;
import Plant.PlantProject.service.tradeboard.GoodsService;
import Plant.PlantProject.service.tradeboard.TradeBoardService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package Plant.PlantProject.controller.tradeboard;

import Plant.PlantProject.vo.request.TradeBoardRequestDto;
import Plant.PlantProject.vo.response.TradeBoardResponseDto;
import Plant.PlantProject.dto.request.TradeBoardRequestDto;
import Plant.PlantProject.dto.response.TradeBoardResponseDto;
import Plant.PlantProject.service.tradeboard.TradeBoardService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package Plant.PlantProject.controller.user;

import Plant.PlantProject.service.user.RefreshTokenService;
import Plant.PlantProject.vo.response.TokenResponseStatus;
import Plant.PlantProject.dto.response.TokenResponseStatus;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
Expand All @@ -10,8 +10,6 @@
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

import java.util.Optional;

@Slf4j
@RestController
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package Plant.PlantProject.controller.user;

import Plant.PlantProject.vo.response.EmailReq;
import Plant.PlantProject.dto.response.EmailReq;
import Plant.PlantProject.service.user.RegisterMail;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package Plant.PlantProject.controller.user;

import Plant.PlantProject.common.config.JwtTokenUtil;
import Plant.PlantProject.vo.request.MemberRequestDto;
import Plant.PlantProject.vo.response.MemberResponseDto;
import Plant.PlantProject.common.config.auth.JwtTokenUtil;
import Plant.PlantProject.dto.request.MemberRequestDto;
import Plant.PlantProject.dto.response.MemberResponseDto;
import Plant.PlantProject.service.user.MemberService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package Plant.PlantProject.domain.Entity;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
Expand All @@ -13,21 +14,25 @@
@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class KeyWord {
public class Keyword {
@Id
@GeneratedValue //jpa 어노테이션인데 그냥 기본키 어노테이션으로 알고있으면됨
@Column(name = "keyId")
private Long id; //고유번호
@CreatedDate
private LocalDateTime createdAt;
@LastModifiedDate
private LocalDateTime updatedAt;

private String keyContent;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "tPostId")
private TradeBoard tradeBoard;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "id")
private Member member;
private String keywordContent;

private Integer memberNo;
@Builder
public Keyword(String keywordContent, Integer memberNo) {
this.keywordContent = keywordContent;
this.memberNo = memberNo;
this.createdAt = LocalDateTime.now();
this.updatedAt = LocalDateTime.now();


}
}
Loading

0 comments on commit 4da98ce

Please sign in to comment.