diff --git a/src/main/java/com/dailylife/domain/board/controller/BoardController.java b/src/main/java/com/dailylife/domain/board/controller/BoardController.java index e913973..dc14a71 100644 --- a/src/main/java/com/dailylife/domain/board/controller/BoardController.java +++ b/src/main/java/com/dailylife/domain/board/controller/BoardController.java @@ -45,4 +45,5 @@ public ResponseEntity deleteBoard(@PathVariable("boardNum")Long boardNu } + } diff --git a/src/main/java/com/dailylife/domain/follow/controller/FollowingController.java b/src/main/java/com/dailylife/domain/follow/controller/FollowingController.java new file mode 100644 index 0000000..84c5370 --- /dev/null +++ b/src/main/java/com/dailylife/domain/follow/controller/FollowingController.java @@ -0,0 +1,52 @@ +package com.dailylife.domain.follow.controller; + +import com.dailylife.domain.follow.dto.FollowingRequest; +import com.dailylife.domain.follow.entity.Follow; +import com.dailylife.domain.follow.service.FollowingService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import java.util.List; + +@RestController +@RequestMapping("api/users") +@RequiredArgsConstructor +@Api(tags = "Following API") +public class FollowingController { + + private final FollowingService followingService; + + @ApiOperation(value = "팔로우를 추가합니다.", notes = "팔로우를 추가합니다.") + @PostMapping("/following") + public ResponseEntity following(@Valid @RequestBody FollowingRequest followingRequest) { + return ResponseEntity.ok(followingService.following(followingRequest)); + } + + @ApiOperation(value = "팔로우를 해제합니다.", notes = "팔로우를 해제합니다.") + @PostMapping("/unfollowing") + public ResponseEntity unfollowing(@Valid @RequestBody FollowingRequest followingRequest) { + followingService.unfollowing(followingRequest); + return ResponseEntity.ok("확인"); + } + + @ApiOperation(value = "팔로워를 확인합니다.", notes = "팔로워를 확인합니다.") + @PostMapping("/getFollower") + public ResponseEntity> getFollower() { + return ResponseEntity.ok(followingService.getFollower()); + } + + @ApiOperation(value = "팔로우를 확인합니다", notes = "팔로우를 확인합니다.") + @PostMapping("/getFollow") + public String getFollow() { + followingService.getFollow(); + return null; + } + +} diff --git a/src/main/java/com/dailylife/domain/user_follow/dto/UserFollowingRequest.java b/src/main/java/com/dailylife/domain/follow/dto/FollowingRequest.java similarity index 80% rename from src/main/java/com/dailylife/domain/user_follow/dto/UserFollowingRequest.java rename to src/main/java/com/dailylife/domain/follow/dto/FollowingRequest.java index 1f5cdbe..0fdc4a5 100644 --- a/src/main/java/com/dailylife/domain/user_follow/dto/UserFollowingRequest.java +++ b/src/main/java/com/dailylife/domain/follow/dto/FollowingRequest.java @@ -1,4 +1,4 @@ -package com.dailylife.domain.user_follow.dto; +package com.dailylife.domain.follow.dto; import io.swagger.annotations.ApiModel; @@ -8,7 +8,6 @@ import lombok.NoArgsConstructor; import lombok.Setter; -import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; @Getter @@ -16,7 +15,7 @@ @AllArgsConstructor @NoArgsConstructor @ApiModel(description = "팔로우 요청을 위한 객체") -public class UserFollowingRequest { +public class FollowingRequest { @NotNull(message = "아이디를 입력해주세요") @ApiModelProperty(notes = "아이디를 입력해주세요") diff --git a/src/main/java/com/dailylife/domain/user_follow/entity/UserFollow.java b/src/main/java/com/dailylife/domain/follow/entity/Follow.java similarity index 64% rename from src/main/java/com/dailylife/domain/user_follow/entity/UserFollow.java rename to src/main/java/com/dailylife/domain/follow/entity/Follow.java index f04e177..4a11d69 100644 --- a/src/main/java/com/dailylife/domain/user_follow/entity/UserFollow.java +++ b/src/main/java/com/dailylife/domain/follow/entity/Follow.java @@ -1,7 +1,7 @@ -package com.dailylife.domain.user_follow.entity; +package com.dailylife.domain.follow.entity; import com.dailylife.domain.user.entity.User; -import com.dailylife.domain.user_follow.dto.UserFollowingRequest; +import com.dailylife.domain.follow.dto.FollowingRequest; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.*; @@ -13,7 +13,7 @@ @NoArgsConstructor @AllArgsConstructor @Builder -public class UserFollow { +public class Follow { //1 - > 3 팔로우 //3 을 팔로우한 1번 @@ -31,15 +31,15 @@ public class UserFollow { public void setUser(User user) { this.user = user; - user.getUserFollows().add(this); + user.getFollows().add(this); } - public static UserFollow toEntity(UserFollowingRequest userFollowRequest , User user) { - UserFollow userFollow = UserFollow.builder() + public static Follow toEntity(FollowingRequest userFollowRequest , User user) { + Follow follow = Follow.builder() .followNum(userFollowRequest.getFollowNum()) .build(); - userFollow.setUser(user); - return userFollow; + follow.setUser(user); + return follow; } } diff --git a/src/main/java/com/dailylife/domain/follow/repository/FollowingRepository.java b/src/main/java/com/dailylife/domain/follow/repository/FollowingRepository.java new file mode 100644 index 0000000..3f4e500 --- /dev/null +++ b/src/main/java/com/dailylife/domain/follow/repository/FollowingRepository.java @@ -0,0 +1,17 @@ +package com.dailylife.domain.follow.repository; + +import com.dailylife.domain.follow.entity.Follow; +import com.dailylife.domain.user.entity.User; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.List; +import java.util.Optional; + +public interface FollowingRepository extends JpaRepository { + + Optional> findByFollowNum(Long followNum); + + void deleteByFollowNum(Long followNum); + + Optional> findByUser(User user); +} diff --git a/src/main/java/com/dailylife/domain/follow/service/FollowingService.java b/src/main/java/com/dailylife/domain/follow/service/FollowingService.java new file mode 100644 index 0000000..f765821 --- /dev/null +++ b/src/main/java/com/dailylife/domain/follow/service/FollowingService.java @@ -0,0 +1,16 @@ +package com.dailylife.domain.follow.service; + +import com.dailylife.domain.follow.dto.FollowingRequest; +import com.dailylife.domain.follow.entity.Follow; + +import java.util.List; + +public interface FollowingService { + Follow following(FollowingRequest userFollowRequest); + + List getFollower(); + + void unfollowing(FollowingRequest followingRequest); + + List getFollow(); +} diff --git a/src/main/java/com/dailylife/domain/follow/service/FollowingServiceImpl.java b/src/main/java/com/dailylife/domain/follow/service/FollowingServiceImpl.java new file mode 100644 index 0000000..f23307f --- /dev/null +++ b/src/main/java/com/dailylife/domain/follow/service/FollowingServiceImpl.java @@ -0,0 +1,67 @@ +package com.dailylife.domain.follow.service; + +import com.dailylife.domain.user.entity.User; +import com.dailylife.domain.user.repository.UserRepository; +import com.dailylife.domain.follow.dto.FollowingRequest; +import com.dailylife.domain.follow.entity.Follow; +import com.dailylife.domain.follow.repository.FollowingRepository; +import com.dailylife.global.jwt.service.JwtService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@RequiredArgsConstructor +@Service +@Slf4j +public class FollowingServiceImpl implements FollowingService { + + private final FollowingRepository userFollowRepository; + private final JwtService jwtService; + private final UserRepository userRepository; + + @Override + @Transactional + public Follow following(FollowingRequest userFollowRequest) { + + try{ + userRepository.findByUserNum(userFollowRequest.getFollowNum()).get(); + }catch (Exception e){ + e.printStackTrace(); + throw new RuntimeException("유저를 찾을수 없습니다."); + } + + User user = userRepository.findByUserId(jwtService.getLoginId()); + + return userFollowRepository.save(Follow.toEntity(userFollowRequest,user)); + + } + + + @Override + @Transactional + public void unfollowing(FollowingRequest followingRequest) { + + User user = userRepository.findByUserId(jwtService.getLoginId()); + userFollowRepository.deleteByFollowNum(followingRequest.getFollowNum()); + + } + + @Override + @Transactional + public List getFollow() { + User user = userRepository.findByUserId(jwtService.getLoginId()); + return userFollowRepository.findByUser(user).orElseThrow(RuntimeException::new); + } + + @Override + @Transactional + public List getFollower() { + User user = userRepository.findByUserId(jwtService.getLoginId()); + return userFollowRepository.findByFollowNum(user.getUserNum()).orElseThrow(RuntimeException::new); + } + + +} diff --git a/src/main/java/com/dailylife/domain/reply/entity/Reply.java b/src/main/java/com/dailylife/domain/reply/entity/Reply.java index 73b9511..944dc16 100644 --- a/src/main/java/com/dailylife/domain/reply/entity/Reply.java +++ b/src/main/java/com/dailylife/domain/reply/entity/Reply.java @@ -4,7 +4,6 @@ import com.dailylife.domain.reply.dto.ReplyInsertRequest; import com.dailylife.domain.replyReply.entity.ReplyReply; import com.dailylife.domain.user.entity.User; -import com.dailylife.domain.user_follow.entity.UserFollow; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.*; @@ -41,7 +40,6 @@ public class Reply { private Board board;*/ - @OneToMany(mappedBy = "reply" /*,cascade = CascadeType.ALL*/) // reply이 삭제되면 자동으로 heart또한 삭제 @JsonIgnore private List hearts = new ArrayList<>(); diff --git a/src/main/java/com/dailylife/domain/reply/service/ReplyServiceImpl.java b/src/main/java/com/dailylife/domain/reply/service/ReplyServiceImpl.java index 6a4ea54..ba6005a 100644 --- a/src/main/java/com/dailylife/domain/reply/service/ReplyServiceImpl.java +++ b/src/main/java/com/dailylife/domain/reply/service/ReplyServiceImpl.java @@ -17,8 +17,6 @@ public class ReplyServiceImpl implements ReplyService{ private final ReplyRepository replyRepository; - - @Override @Transactional public Reply insert(ReplyInsertRequest replyInsertRequest) { diff --git a/src/main/java/com/dailylife/domain/user/controller/UserController.java b/src/main/java/com/dailylife/domain/user/controller/UserController.java index 4cfcc0d..c34398f 100644 --- a/src/main/java/com/dailylife/domain/user/controller/UserController.java +++ b/src/main/java/com/dailylife/domain/user/controller/UserController.java @@ -5,10 +5,13 @@ import com.dailylife.domain.user.dto.UserModifyRequest; import com.dailylife.domain.user.entity.User; import com.dailylife.domain.user.service.UserService; +import com.dailylife.global.dto.ApplicationResponse; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; +import lombok.Value; import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; @@ -29,18 +32,28 @@ public class UserController { @ApiOperation(value = "회원가입", notes = "회원가입을 합니다.") @PostMapping("/join") - public ResponseEntity saveUser(@Valid @RequestBody UserJoinRequest userJoinRequest) { - log.info("userJoinId By React => {}" , userJoinRequest.getUserId()); - return ResponseEntity.ok(userService.join(userJoinRequest)); + public ApplicationResponse saveUser(@Valid @RequestBody UserJoinRequest userJoinRequest) { + return ApplicationResponse.create("회원가입이 완료되었습니다." , HttpStatus.CREATED , userService.join(userJoinRequest)); } @ApiOperation(value = "로그인", notes = "로그인을 합니다.") @PostMapping("/login") - public ResponseEntity loginUser(@Valid @RequestBody UserLoginRequest userLoginRequestRequest) { - log.info("userLoginId By React => {}" , userLoginRequestRequest.getUserId()); - return ResponseEntity.ok(userService.login(userLoginRequestRequest)); + public ApplicationResponse loginUser(@Valid @RequestBody UserLoginRequest userLoginRequestRequest) { + return ApplicationResponse.create("로그인이 완료되었습니다." , HttpStatus.OK , userService.login(userLoginRequestRequest)); } + @ApiOperation(value = "회원탈퇴" , notes = "회원을 탈퇴합니다.") + @DeleteMapping("/quit/{userNum}") + public ApplicationResponse quitUser(@Valid @PathVariable Long userNum) { + userService.quit(userNum); + return ApplicationResponse.ok(); + } + + @ApiOperation(value = "내정보 보기" , notes = "내정보를 자세하게 봅니다") + @PostMapping("/details/{userNum}") + public ApplicationResponse detailsUser(@Valid @PathVariable Long userNum) { + return ApplicationResponse.create("유저의 대한 정보입니다" , HttpStatus.OK , userService.getDetails(userNum)); + } @PostMapping("/post") public String PostTest(@RequestBody String msg) { diff --git a/src/main/java/com/dailylife/domain/user/dto/UserDetailResponse.java b/src/main/java/com/dailylife/domain/user/dto/UserDetailResponse.java new file mode 100644 index 0000000..a1c26fe --- /dev/null +++ b/src/main/java/com/dailylife/domain/user/dto/UserDetailResponse.java @@ -0,0 +1,39 @@ +package com.dailylife.domain.user.dto; + +import com.dailylife.domain.board.entity.Board; +import com.dailylife.domain.user.entity.User; +import io.swagger.annotations.ApiModel; +import lombok.*; + +import java.time.LocalDateTime; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@ApiModel(description = "유저의 대한 상세정보를 전달하기위한 객체") +@Builder +public class UserDetailResponse { + + private String userId; + private String userName; + private String userEmail; + private String userProfileImg; + + private int followSize; + private int followerSize; + + private Long boardNum; + + public static UserDetailResponse from(User user , int followSize , int followerSize , Board board) { + return UserDetailResponse.builder() + .userId(user.getUserId()) + .userName(user.getUserName()) + .userEmail(user.getUserEmail()) + .userProfileImg(user.getUserProfileImg()) + .followerSize(followerSize) + .followSize(followSize) + .boardNum(board.getBoardNum()).build(); + } + +} diff --git a/src/main/java/com/dailylife/domain/user/entity/User.java b/src/main/java/com/dailylife/domain/user/entity/User.java index bb6759e..c930f33 100644 --- a/src/main/java/com/dailylife/domain/user/entity/User.java +++ b/src/main/java/com/dailylife/domain/user/entity/User.java @@ -1,14 +1,11 @@ package com.dailylife.domain.user.entity; import com.dailylife.domain.board.entity.Board; -import com.dailylife.domain.heart.entity.Heart; import com.dailylife.domain.reply.entity.Reply; import com.dailylife.domain.user.dto.UserJoinRequest; -import com.dailylife.domain.user_follow.entity.UserFollow; +import com.dailylife.domain.follow.entity.Follow; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.*; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.GetMapping; import javax.persistence.*; import java.time.LocalDateTime; @@ -49,7 +46,7 @@ public class User { @OneToMany(mappedBy = "user" , orphanRemoval = true, cascade = CascadeType.PERSIST) @JsonIgnore - private List userFollows = new ArrayList<>(); + private List follows = new ArrayList<>(); @OneToMany(mappedBy = "user") @JsonIgnore @@ -69,5 +66,13 @@ public static User toEntity(UserJoinRequest userJoinRequest) { .build(); } + /* + public static User toEntity(UserJoinReq userJoinReq) { + return User.builder() + .name(userJoinReq.getName()) + .build(); + } + */ + } diff --git a/src/main/java/com/dailylife/domain/user/service/UserService.java b/src/main/java/com/dailylife/domain/user/service/UserService.java index 286963b..7fa99d3 100644 --- a/src/main/java/com/dailylife/domain/user/service/UserService.java +++ b/src/main/java/com/dailylife/domain/user/service/UserService.java @@ -18,4 +18,7 @@ public interface UserService { String modifyProfileImg(MultipartFile img) throws IOException; + void quit(Long userNum); + + User getDetails(Long userNum); } diff --git a/src/main/java/com/dailylife/domain/user/service/UserServiceImpl.java b/src/main/java/com/dailylife/domain/user/service/UserServiceImpl.java index fee8ad5..60ff424 100644 --- a/src/main/java/com/dailylife/domain/user/service/UserServiceImpl.java +++ b/src/main/java/com/dailylife/domain/user/service/UserServiceImpl.java @@ -5,6 +5,7 @@ import com.dailylife.domain.user.dto.UserModifyRequest; import com.dailylife.domain.user.entity.User; import com.dailylife.domain.user.repository.UserRepository; +import com.dailylife.global.exception.NotFoundException; import com.dailylife.global.fileUpload.SingleUpload; import com.dailylife.global.jwt.service.JwtService; import com.dailylife.global.security.SpringSecurityConfig; @@ -73,5 +74,19 @@ public String modifyProfileImg(MultipartFile img) throws IOException { } return null; } + + @Override @Transactional + public void quit(Long userNum) { + User user = userRepository.findByUserNum(userNum).orElseThrow(NotFoundException::new); + userRepository.delete(user); + } + + @Override + public User getDetails(Long userNum) { + +// User user = userRepository.findByUserNum(userNum).orElseThrow(NotFoundException::new); + + return userRepository.findByUserNum(userNum).orElseThrow(NotFoundException::new); + } } diff --git a/src/main/java/com/dailylife/domain/user_follow/controller/UserFollowingController.java b/src/main/java/com/dailylife/domain/user_follow/controller/UserFollowingController.java deleted file mode 100644 index 3948d25..0000000 --- a/src/main/java/com/dailylife/domain/user_follow/controller/UserFollowingController.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.dailylife.domain.user_follow.controller; - -import com.dailylife.domain.user_follow.dto.UserFollowingRequest; -import com.dailylife.domain.user_follow.entity.UserFollow; -import com.dailylife.domain.user_follow.service.UserFollowingService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.validation.Valid; -import java.util.List; - -@RestController -@RequestMapping("api/users") -@RequiredArgsConstructor -@Api(tags = "User Following API") -public class UserFollowingController { - - private final UserFollowingService userFollowingService; - - @ApiOperation(value = "팔로우를 추가합니다.", notes = "팔로우를 추가합니다.") - @PostMapping("/following") - public ResponseEntity following(@Valid @RequestBody UserFollowingRequest userFollowingRequest) { - return ResponseEntity.ok(userFollowingService.following(userFollowingRequest)); - } - - @ApiOperation(value = "팔로워를 확인합니다.", notes = "팔로워를 확인합니다.") - @PostMapping("/getFollower") - public ResponseEntity> getFollower() { - return ResponseEntity.ok(userFollowingService.getFollower()); - } - - - - - -} diff --git a/src/main/java/com/dailylife/domain/user_follow/repository/UserFollowingRepository.java b/src/main/java/com/dailylife/domain/user_follow/repository/UserFollowingRepository.java deleted file mode 100644 index fbc9965..0000000 --- a/src/main/java/com/dailylife/domain/user_follow/repository/UserFollowingRepository.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.dailylife.domain.user_follow.repository; - -import com.dailylife.domain.user.entity.User; -import com.dailylife.domain.user_follow.entity.UserFollow; -import org.springframework.data.jpa.repository.JpaRepository; - -import java.util.List; -import java.util.Optional; - -public interface UserFollowingRepository extends JpaRepository { - - Optional> findByFollowNum(Long userNum); - -} diff --git a/src/main/java/com/dailylife/domain/user_follow/service/UserFollowingService.java b/src/main/java/com/dailylife/domain/user_follow/service/UserFollowingService.java deleted file mode 100644 index 16837f7..0000000 --- a/src/main/java/com/dailylife/domain/user_follow/service/UserFollowingService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.dailylife.domain.user_follow.service; - -import com.dailylife.domain.user_follow.dto.UserFollowingRequest; -import com.dailylife.domain.user_follow.entity.UserFollow; - -import java.util.List; - -public interface UserFollowingService { - UserFollow following(UserFollowingRequest userFollowRequest); - - List getFollower(); -} diff --git a/src/main/java/com/dailylife/domain/user_follow/service/UserFollowingServiceImpl.java b/src/main/java/com/dailylife/domain/user_follow/service/UserFollowingServiceImpl.java deleted file mode 100644 index 9fb8295..0000000 --- a/src/main/java/com/dailylife/domain/user_follow/service/UserFollowingServiceImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.dailylife.domain.user_follow.service; - -import com.dailylife.domain.user.entity.User; -import com.dailylife.domain.user.repository.UserRepository; -import com.dailylife.domain.user_follow.dto.UserFollowingRequest; -import com.dailylife.domain.user_follow.entity.UserFollow; -import com.dailylife.domain.user_follow.repository.UserFollowingRepository; -import com.dailylife.global.jwt.service.JwtService; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import java.util.List; - -@RequiredArgsConstructor -@Service -@Slf4j -public class UserFollowingServiceImpl implements UserFollowingService{ - - private final UserFollowingRepository userFollowRepository; - private final JwtService jwtService; - private final UserRepository userRepository; - - @Override - public UserFollow following(UserFollowingRequest userFollowRequest) { - - try{ - userRepository.findByUserNum(userFollowRequest.getFollowNum()).get(); - }catch (Exception e){ - e.printStackTrace(); - throw new RuntimeException("유저를 찾을수 없습니다."); - } - - User user = userRepository.findByUserId(jwtService.getLoginId()); - - return userFollowRepository.save(UserFollow.toEntity(userFollowRequest,user)); - - } - - @Override - public List getFollower() { - - User user = userRepository.findByUserId(jwtService.getLoginId()); - System.out.println(user.getUserNum()); - - return userFollowRepository.findByFollowNum(user.getUserNum()).orElseThrow(RuntimeException::new); - - } - -} diff --git a/src/main/java/com/dailylife/global/dto/ApplicationResponse.java b/src/main/java/com/dailylife/global/dto/ApplicationResponse.java new file mode 100644 index 0000000..f043b21 --- /dev/null +++ b/src/main/java/com/dailylife/global/dto/ApplicationResponse.java @@ -0,0 +1,48 @@ +package com.dailylife.global.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.springframework.http.HttpStatus; + +import java.time.LocalDateTime; + +@NoArgsConstructor +@AllArgsConstructor +@Getter +@Builder +public class ApplicationResponse { + + private String message; + private boolean success; + private int httpCode; + private HttpStatus httpStatus; + private T data; + private LocalDateTime localDateTime; + + public static ApplicationResponse create(String message, HttpStatus httpStatus, + T data){ + return (ApplicationResponse) + ApplicationResponse.builder() + .httpCode(httpStatus.value()) + .localDateTime(LocalDateTime.now()) + .message(message) + .httpStatus(httpStatus) + .data(data) + .success(true) + .build(); + } + + public static ApplicationResponse ok(){ + return (ApplicationResponse) ApplicationResponse.builder() + .data(null) + .success(true) + .localDateTime(LocalDateTime.now()) + .message("성공") + .httpStatus(HttpStatus.OK) + .build(); + } + + +} diff --git a/src/main/java/com/dailylife/global/exception/NotFoundException.java b/src/main/java/com/dailylife/global/exception/NotFoundException.java new file mode 100644 index 0000000..071ede6 --- /dev/null +++ b/src/main/java/com/dailylife/global/exception/NotFoundException.java @@ -0,0 +1,9 @@ +package com.dailylife.global.exception; + +public class NotFoundException extends RuntimeException{ + + public NotFoundException() { + super("찾을수 없습니다."); + } + +} diff --git a/src/main/java/com/dailylife/global/swagger/SwaggerConfig.java b/src/main/java/com/dailylife/global/swagger/SwaggerConfig.java index 567d5e2..b7cc238 100644 --- a/src/main/java/com/dailylife/global/swagger/SwaggerConfig.java +++ b/src/main/java/com/dailylife/global/swagger/SwaggerConfig.java @@ -25,12 +25,6 @@ @EnableSwagger2 public class SwaggerConfig { - /** - * git - jira test by dm - * git - jira test by ygp - * git - jira test2 by dm - */ - @Bean public Docket restAPI() { List global = new ArrayList<>(); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 2ae2897..4536416 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,9 +1,9 @@ spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://146.56.39.196:3306/dailylife?useUnicode=yes&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=Asia/Seoul - username: dailylife - password: 1234 + url: jdbc:mysql://localhost:3306/jpashop?useUnicode=yes&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=Asia/Seoul + username: sa + password: km971gb5!! mvc: pathmatch: @@ -15,7 +15,7 @@ spring: properties: hibernate: - show_sql: true + show_sql: false format_sql: true database-platform: org.hibernate.dialect.MySQL5Dialect defer-datasource-initialization: true