diff --git a/src/main/java/ntou/auction/spring/NtouAuctionJavaApplication.java b/src/main/java/ntou/auction/spring/NtouAuctionJavaApplication.java index c032e2d..4bedc9e 100644 --- a/src/main/java/ntou/auction/spring/NtouAuctionJavaApplication.java +++ b/src/main/java/ntou/auction/spring/NtouAuctionJavaApplication.java @@ -1,6 +1,6 @@ package ntou.auction.spring; -import ntou.auction.spring.data.service.UserRepository; +import ntou.auction.spring.account.repository.UserRepository; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.sql.init.SqlDataSourceScriptDatabaseInitializer; diff --git a/src/main/java/ntou/auction/spring/security/JWTRequestFilter.java b/src/main/java/ntou/auction/spring/account/config/JWTRequestFilter.java similarity index 93% rename from src/main/java/ntou/auction/spring/security/JWTRequestFilter.java rename to src/main/java/ntou/auction/spring/account/config/JWTRequestFilter.java index 2009817..0aeaf71 100644 --- a/src/main/java/ntou/auction/spring/security/JWTRequestFilter.java +++ b/src/main/java/ntou/auction/spring/account/config/JWTRequestFilter.java @@ -1,9 +1,11 @@ -package ntou.auction.spring.security; +package ntou.auction.spring.account.config; import jakarta.servlet.FilterChain; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import ntou.auction.spring.account.service.JWTService; +import ntou.auction.spring.account.service.UserDetailsServiceImpl; import org.springframework.http.HttpHeaders; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.context.SecurityContextHolder; diff --git a/src/main/java/ntou/auction/spring/security/SecurityConfiguration.java b/src/main/java/ntou/auction/spring/account/config/SecurityConfiguration.java similarity index 97% rename from src/main/java/ntou/auction/spring/security/SecurityConfiguration.java rename to src/main/java/ntou/auction/spring/account/config/SecurityConfiguration.java index 6254382..5af12bb 100644 --- a/src/main/java/ntou/auction/spring/security/SecurityConfiguration.java +++ b/src/main/java/ntou/auction/spring/account/config/SecurityConfiguration.java @@ -1,7 +1,6 @@ -package ntou.auction.spring.security; +package ntou.auction.spring.account.config; -import ntou.auction.spring.core.AppConfig; -import ntou.auction.spring.data.Role; +import ntou.auction.spring.util.AppConfig; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; diff --git a/src/main/java/ntou/auction/spring/controller/AuthController.java b/src/main/java/ntou/auction/spring/account/controller/AuthController.java similarity index 90% rename from src/main/java/ntou/auction/spring/controller/AuthController.java rename to src/main/java/ntou/auction/spring/account/controller/AuthController.java index a0c848d..ffef66b 100644 --- a/src/main/java/ntou/auction/spring/controller/AuthController.java +++ b/src/main/java/ntou/auction/spring/account/controller/AuthController.java @@ -1,12 +1,12 @@ -package ntou.auction.spring.controller; +package ntou.auction.spring.account.controller; import jakarta.validation.Valid; -import ntou.auction.spring.data.Role; -import ntou.auction.spring.data.entity.User; -import ntou.auction.spring.data.service.UserService; -import ntou.auction.spring.security.AuthRequest; -import ntou.auction.spring.security.JWTService; -import ntou.auction.spring.security.SignupRequest; +import ntou.auction.spring.account.entity.Role; +import ntou.auction.spring.account.entity.User; +import ntou.auction.spring.account.service.UserService; +import ntou.auction.spring.account.request.AuthRequest; +import ntou.auction.spring.account.service.JWTService; +import ntou.auction.spring.account.request.SignupRequest; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/ntou/auction/spring/controller/UserController.java b/src/main/java/ntou/auction/spring/account/controller/UserController.java similarity index 92% rename from src/main/java/ntou/auction/spring/controller/UserController.java rename to src/main/java/ntou/auction/spring/account/controller/UserController.java index 227c09b..237606e 100644 --- a/src/main/java/ntou/auction/spring/controller/UserController.java +++ b/src/main/java/ntou/auction/spring/account/controller/UserController.java @@ -1,13 +1,13 @@ -package ntou.auction.spring.controller; +package ntou.auction.spring.account.controller; import jakarta.validation.Valid; -import ntou.auction.spring.data.entity.FavoriteRequest; -import ntou.auction.spring.data.entity.Product; -import ntou.auction.spring.data.entity.User; -import ntou.auction.spring.data.service.ProductService; -import ntou.auction.spring.data.service.UserIdentity; -import ntou.auction.spring.data.service.UserService; -import ntou.auction.spring.security.SignupRequest; +import ntou.auction.spring.account.request.FavoriteRequest; +import ntou.auction.spring.product.entity.Product; +import ntou.auction.spring.account.entity.User; +import ntou.auction.spring.product.service.ProductService; +import ntou.auction.spring.account.response.UserIdentity; +import ntou.auction.spring.account.service.UserService; +import ntou.auction.spring.account.request.SignupRequest; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/ntou/auction/spring/account/entity/Role.java b/src/main/java/ntou/auction/spring/account/entity/Role.java new file mode 100644 index 0000000..abaa4a5 --- /dev/null +++ b/src/main/java/ntou/auction/spring/account/entity/Role.java @@ -0,0 +1,5 @@ +package ntou.auction.spring.account.entity; + +public enum Role { + USER, ADMIN +} diff --git a/src/main/java/ntou/auction/spring/data/entity/User.java b/src/main/java/ntou/auction/spring/account/entity/User.java similarity index 96% rename from src/main/java/ntou/auction/spring/data/entity/User.java rename to src/main/java/ntou/auction/spring/account/entity/User.java index 79840ce..fea61f9 100644 --- a/src/main/java/ntou/auction/spring/data/entity/User.java +++ b/src/main/java/ntou/auction/spring/account/entity/User.java @@ -1,14 +1,14 @@ -package ntou.auction.spring.data.entity; +package ntou.auction.spring.account.entity; import com.fasterxml.jackson.annotation.JsonIgnore; import jakarta.persistence.*; import jakarta.validation.constraints.NotBlank; -import ntou.auction.spring.data.Role; import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import ntou.auction.spring.util.AbstractEntity; import org.hibernate.validator.constraints.Length; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; diff --git a/src/main/java/ntou/auction/spring/data/service/UserRepository.java b/src/main/java/ntou/auction/spring/account/repository/UserRepository.java similarity index 87% rename from src/main/java/ntou/auction/spring/data/service/UserRepository.java rename to src/main/java/ntou/auction/spring/account/repository/UserRepository.java index 624c08e..06e697d 100644 --- a/src/main/java/ntou/auction/spring/data/service/UserRepository.java +++ b/src/main/java/ntou/auction/spring/account/repository/UserRepository.java @@ -1,6 +1,6 @@ -package ntou.auction.spring.data.service; +package ntou.auction.spring.account.repository; -import ntou.auction.spring.data.entity.User; +import ntou.auction.spring.account.entity.User; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; diff --git a/src/main/java/ntou/auction/spring/security/AuthRequest.java b/src/main/java/ntou/auction/spring/account/request/AuthRequest.java similarity index 86% rename from src/main/java/ntou/auction/spring/security/AuthRequest.java rename to src/main/java/ntou/auction/spring/account/request/AuthRequest.java index 06db39a..6a0617b 100644 --- a/src/main/java/ntou/auction/spring/security/AuthRequest.java +++ b/src/main/java/ntou/auction/spring/account/request/AuthRequest.java @@ -1,4 +1,4 @@ -package ntou.auction.spring.security; +package ntou.auction.spring.account.request; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; diff --git a/src/main/java/ntou/auction/spring/data/entity/FavoriteRequest.java b/src/main/java/ntou/auction/spring/account/request/FavoriteRequest.java similarity index 85% rename from src/main/java/ntou/auction/spring/data/entity/FavoriteRequest.java rename to src/main/java/ntou/auction/spring/account/request/FavoriteRequest.java index 671fe83..d8a3b0e 100644 --- a/src/main/java/ntou/auction/spring/data/entity/FavoriteRequest.java +++ b/src/main/java/ntou/auction/spring/account/request/FavoriteRequest.java @@ -1,4 +1,4 @@ -package ntou.auction.spring.data.entity; +package ntou.auction.spring.account.request; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; diff --git a/src/main/java/ntou/auction/spring/security/SignupRequest.java b/src/main/java/ntou/auction/spring/account/request/SignupRequest.java similarity index 95% rename from src/main/java/ntou/auction/spring/security/SignupRequest.java rename to src/main/java/ntou/auction/spring/account/request/SignupRequest.java index ed10983..91c3f9a 100644 --- a/src/main/java/ntou/auction/spring/security/SignupRequest.java +++ b/src/main/java/ntou/auction/spring/account/request/SignupRequest.java @@ -1,4 +1,4 @@ -package ntou.auction.spring.security; +package ntou.auction.spring.account.request; import jakarta.persistence.*; import jakarta.validation.constraints.Email; diff --git a/src/main/java/ntou/auction/spring/security/AuthResponse.java b/src/main/java/ntou/auction/spring/account/response/AuthResponse.java similarity index 66% rename from src/main/java/ntou/auction/spring/security/AuthResponse.java rename to src/main/java/ntou/auction/spring/account/response/AuthResponse.java index 3d5ea58..0fc1a5c 100644 --- a/src/main/java/ntou/auction/spring/security/AuthResponse.java +++ b/src/main/java/ntou/auction/spring/account/response/AuthResponse.java @@ -1,4 +1,4 @@ -package ntou.auction.spring.security; +package ntou.auction.spring.account.response; import lombok.Data; diff --git a/src/main/java/ntou/auction/spring/data/service/UserIdentity.java b/src/main/java/ntou/auction/spring/account/response/UserIdentity.java similarity index 82% rename from src/main/java/ntou/auction/spring/data/service/UserIdentity.java rename to src/main/java/ntou/auction/spring/account/response/UserIdentity.java index 43f2998..77f3c7d 100644 --- a/src/main/java/ntou/auction/spring/data/service/UserIdentity.java +++ b/src/main/java/ntou/auction/spring/account/response/UserIdentity.java @@ -1,7 +1,8 @@ -package ntou.auction.spring.data.service; +package ntou.auction.spring.account.response; -import ntou.auction.spring.data.Role; -import ntou.auction.spring.data.entity.User; +import ntou.auction.spring.account.service.UserService; +import ntou.auction.spring.account.entity.Role; +import ntou.auction.spring.account.entity.User; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; diff --git a/src/main/java/ntou/auction/spring/security/JWTService.java b/src/main/java/ntou/auction/spring/account/service/JWTService.java similarity index 96% rename from src/main/java/ntou/auction/spring/security/JWTService.java rename to src/main/java/ntou/auction/spring/account/service/JWTService.java index 48cb9a2..a4bc4bd 100644 --- a/src/main/java/ntou/auction/spring/security/JWTService.java +++ b/src/main/java/ntou/auction/spring/account/service/JWTService.java @@ -1,8 +1,9 @@ -package ntou.auction.spring.security; +package ntou.auction.spring.account.service; import io.jsonwebtoken.*; import io.jsonwebtoken.io.Decoders; import io.jsonwebtoken.security.Keys; +import ntou.auction.spring.account.request.AuthRequest; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; diff --git a/src/main/java/ntou/auction/spring/security/UserDetailsServiceImpl.java b/src/main/java/ntou/auction/spring/account/service/UserDetailsServiceImpl.java similarity index 91% rename from src/main/java/ntou/auction/spring/security/UserDetailsServiceImpl.java rename to src/main/java/ntou/auction/spring/account/service/UserDetailsServiceImpl.java index 45bc3f7..e752fdd 100644 --- a/src/main/java/ntou/auction/spring/security/UserDetailsServiceImpl.java +++ b/src/main/java/ntou/auction/spring/account/service/UserDetailsServiceImpl.java @@ -1,7 +1,7 @@ -package ntou.auction.spring.security; +package ntou.auction.spring.account.service; -import ntou.auction.spring.data.entity.User; -import ntou.auction.spring.data.service.UserRepository; +import ntou.auction.spring.account.entity.User; +import ntou.auction.spring.account.repository.UserRepository; import java.util.List; import java.util.stream.Collectors; diff --git a/src/main/java/ntou/auction/spring/data/service/UserService.java b/src/main/java/ntou/auction/spring/account/service/UserService.java similarity index 95% rename from src/main/java/ntou/auction/spring/data/service/UserService.java rename to src/main/java/ntou/auction/spring/account/service/UserService.java index c96ce9f..92bd490 100644 --- a/src/main/java/ntou/auction/spring/data/service/UserService.java +++ b/src/main/java/ntou/auction/spring/account/service/UserService.java @@ -1,10 +1,11 @@ -package ntou.auction.spring.data.service; +package ntou.auction.spring.account.service; -import ntou.auction.spring.data.entity.User; +import ntou.auction.spring.account.entity.User; import java.util.Optional; import java.util.Set; +import ntou.auction.spring.account.repository.UserRepository; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.domain.Specification; diff --git a/src/main/java/ntou/auction/spring/chat/config/AuthChannelInterceptor.java b/src/main/java/ntou/auction/spring/chat/config/AuthChannelInterceptor.java index 2084154..c31e6d1 100644 --- a/src/main/java/ntou/auction/spring/chat/config/AuthChannelInterceptor.java +++ b/src/main/java/ntou/auction/spring/chat/config/AuthChannelInterceptor.java @@ -1,8 +1,8 @@ package ntou.auction.spring.chat.config; import io.micrometer.common.util.StringUtils; -import ntou.auction.spring.security.JWTService; -import ntou.auction.spring.security.UserDetailsServiceImpl; +import ntou.auction.spring.account.service.JWTService; +import ntou.auction.spring.account.service.UserDetailsServiceImpl; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.messaging.Message; @@ -39,7 +39,7 @@ public Message preSend(Message message, MessageChannel channel) { List header = accessor.getNativeHeader("Authorization"); // header裡面有沒有token if (header != null && !header.isEmpty()) { - String token = header.get(0); + String token = header.getFirst(); if (StringUtils.isNotBlank(token)) { String username = JWTService.validateTokenAndGetUsername(token); System.out.println("username:" + username); diff --git a/src/main/java/ntou/auction/spring/chat/config/WebSocketMessageConfig.java b/src/main/java/ntou/auction/spring/chat/config/WebSocketMessageConfig.java index 21b1315..fa3ed8c 100644 --- a/src/main/java/ntou/auction/spring/chat/config/WebSocketMessageConfig.java +++ b/src/main/java/ntou/auction/spring/chat/config/WebSocketMessageConfig.java @@ -12,7 +12,6 @@ import org.springframework.web.socket.config.annotation.StompEndpointRegistry; import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; -import java.net.http.WebSocketHandshakeException; import java.util.List; @Configuration diff --git a/src/main/java/ntou/auction/spring/chat/controller/ChatController.java b/src/main/java/ntou/auction/spring/chat/controller/ChatController.java index 2cf8c59..7a9c3e9 100644 --- a/src/main/java/ntou/auction/spring/chat/controller/ChatController.java +++ b/src/main/java/ntou/auction/spring/chat/controller/ChatController.java @@ -1,12 +1,12 @@ package ntou.auction.spring.chat.controller; -import ntou.auction.spring.chat.data.entity.ChatMessage; -import ntou.auction.spring.chat.data.entity.ChatNotification; -import ntou.auction.spring.chat.data.service.ChatMessageService; -import ntou.auction.spring.chat.data.service.ChatRoomService; -import ntou.auction.spring.data.service.UserIdentity; -import ntou.auction.spring.data.service.UserService; +import ntou.auction.spring.chat.entity.ChatMessage; +import ntou.auction.spring.chat.entity.ChatNotification; +import ntou.auction.spring.chat.service.ChatMessageService; +import ntou.auction.spring.chat.service.ChatRoomService; +import ntou.auction.spring.account.response.UserIdentity; +import ntou.auction.spring.account.service.UserService; import org.springframework.http.ResponseEntity; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.handler.annotation.Payload; @@ -45,13 +45,6 @@ public ChatController(UserService userService, UserIdentity userIdentity, SimpMe @MessageMapping("/send") public void sendMessage(@Payload ChatMessage chatMessage, Principal principal) { - /* - User sender = userService.findByUsername(userIdentity.getUsername()); - ChatMessage message = new ChatMessage(); - message.setSenderId(sender.getId()); - message.setReceiverId(chatMessageRequest.getReceiverId()); - message.setContent(chatMessageRequest.getContent()); - */ // token無效 if (principal.getName() == null) { diff --git a/src/main/java/ntou/auction/spring/chat/data/entity/ChatMessage.java b/src/main/java/ntou/auction/spring/chat/entity/ChatMessage.java similarity index 86% rename from src/main/java/ntou/auction/spring/chat/data/entity/ChatMessage.java rename to src/main/java/ntou/auction/spring/chat/entity/ChatMessage.java index 17107ee..ba28cca 100644 --- a/src/main/java/ntou/auction/spring/chat/data/entity/ChatMessage.java +++ b/src/main/java/ntou/auction/spring/chat/entity/ChatMessage.java @@ -1,11 +1,11 @@ -package ntou.auction.spring.chat.data.entity; +package ntou.auction.spring.chat.entity; import com.fasterxml.jackson.annotation.JsonFormat; import jakarta.persistence.Entity; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import ntou.auction.spring.data.entity.AbstractEntity; +import ntou.auction.spring.util.AbstractEntity; import java.time.LocalDateTime; @Entity diff --git a/src/main/java/ntou/auction/spring/chat/data/entity/ChatMessageStatus.java b/src/main/java/ntou/auction/spring/chat/entity/ChatMessageStatus.java similarity index 56% rename from src/main/java/ntou/auction/spring/chat/data/entity/ChatMessageStatus.java rename to src/main/java/ntou/auction/spring/chat/entity/ChatMessageStatus.java index 2d9ef65..28ee876 100644 --- a/src/main/java/ntou/auction/spring/chat/data/entity/ChatMessageStatus.java +++ b/src/main/java/ntou/auction/spring/chat/entity/ChatMessageStatus.java @@ -1,4 +1,4 @@ -package ntou.auction.spring.chat.data.entity; +package ntou.auction.spring.chat.entity; public enum ChatMessageStatus { RECEIVED, DELIVERED diff --git a/src/main/java/ntou/auction/spring/chat/data/entity/ChatNotification.java b/src/main/java/ntou/auction/spring/chat/entity/ChatNotification.java similarity index 72% rename from src/main/java/ntou/auction/spring/chat/data/entity/ChatNotification.java rename to src/main/java/ntou/auction/spring/chat/entity/ChatNotification.java index 477d19a..bb8003b 100644 --- a/src/main/java/ntou/auction/spring/chat/data/entity/ChatNotification.java +++ b/src/main/java/ntou/auction/spring/chat/entity/ChatNotification.java @@ -1,9 +1,9 @@ -package ntou.auction.spring.chat.data.entity; +package ntou.auction.spring.chat.entity; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import ntou.auction.spring.data.entity.AbstractEntity; +import ntou.auction.spring.util.AbstractEntity; @Data @AllArgsConstructor diff --git a/src/main/java/ntou/auction/spring/chat/data/entity/ChatRoom.java b/src/main/java/ntou/auction/spring/chat/entity/ChatRoom.java similarity index 75% rename from src/main/java/ntou/auction/spring/chat/data/entity/ChatRoom.java rename to src/main/java/ntou/auction/spring/chat/entity/ChatRoom.java index 3de0d92..534ea40 100644 --- a/src/main/java/ntou/auction/spring/chat/data/entity/ChatRoom.java +++ b/src/main/java/ntou/auction/spring/chat/entity/ChatRoom.java @@ -1,10 +1,10 @@ -package ntou.auction.spring.chat.data.entity; +package ntou.auction.spring.chat.entity; import jakarta.persistence.Entity; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import ntou.auction.spring.data.entity.AbstractEntity; +import ntou.auction.spring.util.AbstractEntity; @Entity @Data @NoArgsConstructor diff --git a/src/main/java/ntou/auction/spring/chat/repository/ChatMessageRepository.java b/src/main/java/ntou/auction/spring/chat/repository/ChatMessageRepository.java index 949d63f..242a91d 100644 --- a/src/main/java/ntou/auction/spring/chat/repository/ChatMessageRepository.java +++ b/src/main/java/ntou/auction/spring/chat/repository/ChatMessageRepository.java @@ -2,11 +2,10 @@ import jakarta.validation.constraints.NotNull; -import ntou.auction.spring.chat.data.entity.ChatMessageStatus; -import ntou.auction.spring.chat.data.entity.ChatMessage; +import ntou.auction.spring.chat.entity.ChatMessageStatus; +import ntou.auction.spring.chat.entity.ChatMessage; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; import java.util.List; diff --git a/src/main/java/ntou/auction/spring/chat/repository/ChatRoomRepository.java b/src/main/java/ntou/auction/spring/chat/repository/ChatRoomRepository.java index e40289d..205e778 100644 --- a/src/main/java/ntou/auction/spring/chat/repository/ChatRoomRepository.java +++ b/src/main/java/ntou/auction/spring/chat/repository/ChatRoomRepository.java @@ -1,6 +1,6 @@ package ntou.auction.spring.chat.repository; -import ntou.auction.spring.chat.data.entity.ChatRoom; +import ntou.auction.spring.chat.entity.ChatRoom; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.stereotype.Repository; diff --git a/src/main/java/ntou/auction/spring/chat/data/service/ChatMessageService.java b/src/main/java/ntou/auction/spring/chat/service/ChatMessageService.java similarity index 94% rename from src/main/java/ntou/auction/spring/chat/data/service/ChatMessageService.java rename to src/main/java/ntou/auction/spring/chat/service/ChatMessageService.java index fe1d613..a2f4354 100644 --- a/src/main/java/ntou/auction/spring/chat/data/service/ChatMessageService.java +++ b/src/main/java/ntou/auction/spring/chat/service/ChatMessageService.java @@ -1,7 +1,7 @@ -package ntou.auction.spring.chat.data.service; +package ntou.auction.spring.chat.service; -import ntou.auction.spring.chat.data.entity.ChatMessage; -import ntou.auction.spring.chat.data.entity.ChatMessageStatus; +import ntou.auction.spring.chat.entity.ChatMessage; +import ntou.auction.spring.chat.entity.ChatMessageStatus; import ntou.auction.spring.chat.exception.MessageNotFound; import ntou.auction.spring.chat.repository.ChatMessageRepository; import org.springframework.stereotype.Service; diff --git a/src/main/java/ntou/auction/spring/chat/data/service/ChatRoomService.java b/src/main/java/ntou/auction/spring/chat/service/ChatRoomService.java similarity index 93% rename from src/main/java/ntou/auction/spring/chat/data/service/ChatRoomService.java rename to src/main/java/ntou/auction/spring/chat/service/ChatRoomService.java index 6252856..3334105 100644 --- a/src/main/java/ntou/auction/spring/chat/data/service/ChatRoomService.java +++ b/src/main/java/ntou/auction/spring/chat/service/ChatRoomService.java @@ -1,6 +1,6 @@ -package ntou.auction.spring.chat.data.service; +package ntou.auction.spring.chat.service; -import ntou.auction.spring.chat.data.entity.ChatRoom; +import ntou.auction.spring.chat.entity.ChatRoom; import ntou.auction.spring.chat.repository.ChatRoomRepository; import org.springframework.stereotype.Service; diff --git a/src/main/java/ntou/auction/spring/data/Role.java b/src/main/java/ntou/auction/spring/data/Role.java deleted file mode 100644 index 4b6d60b..0000000 --- a/src/main/java/ntou/auction/spring/data/Role.java +++ /dev/null @@ -1,5 +0,0 @@ -package ntou.auction.spring.data; - -public enum Role { - USER, ADMIN -} diff --git a/src/main/java/ntou/auction/spring/mail/EmailService.java b/src/main/java/ntou/auction/spring/mail/EmailService.java index 5ef146d..a807948 100644 --- a/src/main/java/ntou/auction/spring/mail/EmailService.java +++ b/src/main/java/ntou/auction/spring/mail/EmailService.java @@ -2,10 +2,10 @@ import jakarta.mail.Message; import jakarta.mail.internet.InternetAddress; -import ntou.auction.spring.core.AppConfig; -import ntou.auction.spring.data.entity.Product; -import ntou.auction.spring.data.entity.User; -import ntou.auction.spring.data.service.UserService; +import ntou.auction.spring.util.AppConfig; +import ntou.auction.spring.product.entity.Product; +import ntou.auction.spring.account.entity.User; +import ntou.auction.spring.account.service.UserService; import org.springframework.mail.MailException; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.MimeMessagePreparator; diff --git a/src/main/java/ntou/auction/spring/controller/OrderController.java b/src/main/java/ntou/auction/spring/order/controller/OrderController.java similarity index 94% rename from src/main/java/ntou/auction/spring/controller/OrderController.java rename to src/main/java/ntou/auction/spring/order/controller/OrderController.java index fce9882..06f051f 100644 --- a/src/main/java/ntou/auction/spring/controller/OrderController.java +++ b/src/main/java/ntou/auction/spring/order/controller/OrderController.java @@ -1,8 +1,16 @@ -package ntou.auction.spring.controller; +package ntou.auction.spring.order.controller; import jakarta.validation.Valid; -import ntou.auction.spring.data.entity.*; -import ntou.auction.spring.data.service.*; +import ntou.auction.spring.account.response.UserIdentity; +import ntou.auction.spring.account.service.UserService; +import ntou.auction.spring.order.entity.Order; +import ntou.auction.spring.order.request.AddOrderRequest; +import ntou.auction.spring.order.request.OperateOrderRequest; +import ntou.auction.spring.order.response.OrderWithProductDetail; +import ntou.auction.spring.order.service.OrderService; +import ntou.auction.spring.product.entity.Product; +import ntou.auction.spring.product.service.ProductService; +import ntou.auction.spring.shoppingcart.service.ShoppingcartService; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -118,7 +126,7 @@ ResponseEntity> addOrder(@Valid @RequestBody AddOrderRequest List> getrequest = request.getProductList(); for (List eachProductAddAmount : getrequest) { - Long productId = eachProductAddAmount.get(0); + Long productId = eachProductAddAmount.getFirst(); Product getProduct = productService.getID(productId); // Id error if (getProduct == null) { diff --git a/src/main/java/ntou/auction/spring/data/entity/Order.java b/src/main/java/ntou/auction/spring/order/entity/Order.java similarity index 90% rename from src/main/java/ntou/auction/spring/data/entity/Order.java rename to src/main/java/ntou/auction/spring/order/entity/Order.java index b293623..3caf4ea 100644 --- a/src/main/java/ntou/auction/spring/data/entity/Order.java +++ b/src/main/java/ntou/auction/spring/order/entity/Order.java @@ -1,12 +1,12 @@ -package ntou.auction.spring.data.entity; +package ntou.auction.spring.order.entity; -import ch.qos.logback.core.joran.sanity.Pair; import com.fasterxml.jackson.annotation.JsonFormat; import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import ntou.auction.spring.util.AbstractEntity; import java.time.LocalDateTime; import java.util.*; diff --git a/src/main/java/ntou/auction/spring/data/service/OrderRepository.java b/src/main/java/ntou/auction/spring/order/repository/OrderRepository.java similarity index 92% rename from src/main/java/ntou/auction/spring/data/service/OrderRepository.java rename to src/main/java/ntou/auction/spring/order/repository/OrderRepository.java index 09af174..02b0dd9 100644 --- a/src/main/java/ntou/auction/spring/data/service/OrderRepository.java +++ b/src/main/java/ntou/auction/spring/order/repository/OrderRepository.java @@ -1,8 +1,6 @@ -package ntou.auction.spring.data.service; +package ntou.auction.spring.order.repository; -import jakarta.transaction.Transactional; -import ntou.auction.spring.data.entity.Order; -import ntou.auction.spring.data.entity.Shoppingcart; +import ntou.auction.spring.order.entity.Order; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Modifying; diff --git a/src/main/java/ntou/auction/spring/data/entity/AddOrderRequest.java b/src/main/java/ntou/auction/spring/order/request/AddOrderRequest.java similarity index 78% rename from src/main/java/ntou/auction/spring/data/entity/AddOrderRequest.java rename to src/main/java/ntou/auction/spring/order/request/AddOrderRequest.java index d0da843..8f6c6e4 100644 --- a/src/main/java/ntou/auction/spring/data/entity/AddOrderRequest.java +++ b/src/main/java/ntou/auction/spring/order/request/AddOrderRequest.java @@ -1,6 +1,5 @@ -package ntou.auction.spring.data.entity; +package ntou.auction.spring.order.request; -import ch.qos.logback.core.joran.sanity.Pair; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/src/main/java/ntou/auction/spring/data/entity/OperateOrderRequest.java b/src/main/java/ntou/auction/spring/order/request/OperateOrderRequest.java similarity index 85% rename from src/main/java/ntou/auction/spring/data/entity/OperateOrderRequest.java rename to src/main/java/ntou/auction/spring/order/request/OperateOrderRequest.java index 2eaf0fb..76a425b 100644 --- a/src/main/java/ntou/auction/spring/data/entity/OperateOrderRequest.java +++ b/src/main/java/ntou/auction/spring/order/request/OperateOrderRequest.java @@ -1,4 +1,4 @@ -package ntou.auction.spring.data.entity; +package ntou.auction.spring.order.request; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; diff --git a/src/main/java/ntou/auction/spring/data/entity/OrderWithProductDetail.java b/src/main/java/ntou/auction/spring/order/response/OrderWithProductDetail.java similarity index 87% rename from src/main/java/ntou/auction/spring/data/entity/OrderWithProductDetail.java rename to src/main/java/ntou/auction/spring/order/response/OrderWithProductDetail.java index a1f207c..1aa7e49 100644 --- a/src/main/java/ntou/auction/spring/data/entity/OrderWithProductDetail.java +++ b/src/main/java/ntou/auction/spring/order/response/OrderWithProductDetail.java @@ -1,12 +1,12 @@ -package ntou.auction.spring.data.entity; +package ntou.auction.spring.order.response; -import ch.qos.logback.core.joran.sanity.Pair; import com.fasterxml.jackson.annotation.JsonFormat; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import ntou.auction.spring.shoppingcart.response.ProductAddAmount; import java.time.LocalDateTime; import java.util.*; diff --git a/src/main/java/ntou/auction/spring/data/service/OrderService.java b/src/main/java/ntou/auction/spring/order/service/OrderService.java similarity index 92% rename from src/main/java/ntou/auction/spring/data/service/OrderService.java rename to src/main/java/ntou/auction/spring/order/service/OrderService.java index 0b606e6..a459b86 100644 --- a/src/main/java/ntou/auction/spring/data/service/OrderService.java +++ b/src/main/java/ntou/auction/spring/order/service/OrderService.java @@ -1,8 +1,11 @@ -package ntou.auction.spring.data.service; - -import ntou.auction.spring.data.entity.Order; -import ntou.auction.spring.data.entity.OrderWithProductDetail; -import ntou.auction.spring.data.entity.ProductAddAmount; +package ntou.auction.spring.order.service; + +import ntou.auction.spring.order.entity.Order; +import ntou.auction.spring.order.response.OrderWithProductDetail; +import ntou.auction.spring.order.repository.OrderRepository; +import ntou.auction.spring.shoppingcart.response.ProductAddAmount; +import ntou.auction.spring.product.service.ProductService; +import ntou.auction.spring.shoppingcart.service.ShoppingcartService; import org.springframework.stereotype.Service; import java.time.Duration; @@ -112,7 +115,7 @@ public void addOrder(Order order) { public boolean checkIsSameSeller(List> list) { Set check = new HashSet<>(); for(List productAddAmount: list) { - check.add(productService.getID(productAddAmount.get(0)).getSellerID()); + check.add(productService.getID(productAddAmount.getFirst()).getSellerID()); } return check.size()==1; } diff --git a/src/main/java/ntou/auction/spring/controller/ProductController.java b/src/main/java/ntou/auction/spring/product/controller/ProductController.java similarity index 97% rename from src/main/java/ntou/auction/spring/controller/ProductController.java rename to src/main/java/ntou/auction/spring/product/controller/ProductController.java index 8f9cc14..7b93a31 100644 --- a/src/main/java/ntou/auction/spring/controller/ProductController.java +++ b/src/main/java/ntou/auction/spring/product/controller/ProductController.java @@ -1,11 +1,12 @@ -package ntou.auction.spring.controller; +package ntou.auction.spring.product.controller; import jakarta.validation.Valid; -import ntou.auction.spring.data.entity.*; -import ntou.auction.spring.data.service.ProductService; -import ntou.auction.spring.data.service.ShoppingcartService; -import ntou.auction.spring.data.service.UserIdentity; -import ntou.auction.spring.data.service.UserService; +import ntou.auction.spring.product.service.ProductService; +import ntou.auction.spring.shoppingcart.service.ShoppingcartService; +import ntou.auction.spring.account.response.UserIdentity; +import ntou.auction.spring.account.service.UserService; +import ntou.auction.spring.product.entity.*; +import ntou.auction.spring.product.request.*; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/ntou/auction/spring/data/entity/Product.java b/src/main/java/ntou/auction/spring/product/entity/Product.java similarity index 95% rename from src/main/java/ntou/auction/spring/data/entity/Product.java rename to src/main/java/ntou/auction/spring/product/entity/Product.java index 7c66363..ac5e7da 100644 --- a/src/main/java/ntou/auction/spring/data/entity/Product.java +++ b/src/main/java/ntou/auction/spring/product/entity/Product.java @@ -1,13 +1,13 @@ -package ntou.auction.spring.data.entity; +package ntou.auction.spring.product.entity; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; import jakarta.persistence.*; -import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import ntou.auction.spring.util.AbstractEntity; import org.hibernate.validator.constraints.Length; import java.time.LocalDateTime; diff --git a/src/main/java/ntou/auction/spring/data/service/ProductRepository.java b/src/main/java/ntou/auction/spring/product/repository/ProductRepository.java similarity index 91% rename from src/main/java/ntou/auction/spring/data/service/ProductRepository.java rename to src/main/java/ntou/auction/spring/product/repository/ProductRepository.java index b9281b5..e7c31ac 100644 --- a/src/main/java/ntou/auction/spring/data/service/ProductRepository.java +++ b/src/main/java/ntou/auction/spring/product/repository/ProductRepository.java @@ -1,6 +1,6 @@ -package ntou.auction.spring.data.service; +package ntou.auction.spring.product.repository; -import ntou.auction.spring.data.entity.Product; +import ntou.auction.spring.product.entity.Product; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; diff --git a/src/main/java/ntou/auction/spring/data/entity/BidRequest.java b/src/main/java/ntou/auction/spring/product/request/BidRequest.java similarity index 73% rename from src/main/java/ntou/auction/spring/data/entity/BidRequest.java rename to src/main/java/ntou/auction/spring/product/request/BidRequest.java index 97f9d1c..aea0b4b 100644 --- a/src/main/java/ntou/auction/spring/data/entity/BidRequest.java +++ b/src/main/java/ntou/auction/spring/product/request/BidRequest.java @@ -1,13 +1,10 @@ -package ntou.auction.spring.data.entity; +package ntou.auction.spring.product.request; -import jakarta.persistence.Column; -import jakarta.persistence.Lob; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; @Data @NoArgsConstructor diff --git a/src/main/java/ntou/auction/spring/data/entity/BuyProductRequest.java b/src/main/java/ntou/auction/spring/product/request/BuyProductRequest.java similarity index 83% rename from src/main/java/ntou/auction/spring/data/entity/BuyProductRequest.java rename to src/main/java/ntou/auction/spring/product/request/BuyProductRequest.java index 31e1a9e..059e62a 100644 --- a/src/main/java/ntou/auction/spring/data/entity/BuyProductRequest.java +++ b/src/main/java/ntou/auction/spring/product/request/BuyProductRequest.java @@ -1,11 +1,10 @@ -package ntou.auction.spring.data.entity; +package ntou.auction.spring.product.request; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; @Data @NoArgsConstructor diff --git a/src/main/java/ntou/auction/spring/data/entity/PostFixedPriceProductRequest.java b/src/main/java/ntou/auction/spring/product/request/PostFixedPriceProductRequest.java similarity index 96% rename from src/main/java/ntou/auction/spring/data/entity/PostFixedPriceProductRequest.java rename to src/main/java/ntou/auction/spring/product/request/PostFixedPriceProductRequest.java index 214fc50..a48a3c7 100644 --- a/src/main/java/ntou/auction/spring/data/entity/PostFixedPriceProductRequest.java +++ b/src/main/java/ntou/auction/spring/product/request/PostFixedPriceProductRequest.java @@ -1,4 +1,4 @@ -package ntou.auction.spring.data.entity; +package ntou.auction.spring.product.request; import jakarta.persistence.Column; import jakarta.persistence.Lob; diff --git a/src/main/java/ntou/auction/spring/data/entity/PostNonFixedPriceProductRequest.java b/src/main/java/ntou/auction/spring/product/request/PostNonFixedPriceProductRequest.java similarity index 96% rename from src/main/java/ntou/auction/spring/data/entity/PostNonFixedPriceProductRequest.java rename to src/main/java/ntou/auction/spring/product/request/PostNonFixedPriceProductRequest.java index 390da51..377b611 100644 --- a/src/main/java/ntou/auction/spring/data/entity/PostNonFixedPriceProductRequest.java +++ b/src/main/java/ntou/auction/spring/product/request/PostNonFixedPriceProductRequest.java @@ -1,4 +1,4 @@ -package ntou.auction.spring.data.entity; +package ntou.auction.spring.product.request; import jakarta.persistence.Column; import jakarta.persistence.Lob; diff --git a/src/main/java/ntou/auction/spring/data/entity/ProductRequestGet.java b/src/main/java/ntou/auction/spring/product/request/ProductRequestGet.java similarity index 75% rename from src/main/java/ntou/auction/spring/data/entity/ProductRequestGet.java rename to src/main/java/ntou/auction/spring/product/request/ProductRequestGet.java index 501a6c8..a74b1ee 100644 --- a/src/main/java/ntou/auction/spring/data/entity/ProductRequestGet.java +++ b/src/main/java/ntou/auction/spring/product/request/ProductRequestGet.java @@ -1,8 +1,5 @@ -package ntou.auction.spring.data.entity; +package ntou.auction.spring.product.request; -import jakarta.persistence.Column; -import jakarta.persistence.Lob; -import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/src/main/java/ntou/auction/spring/data/entity/UpdateFixedPriceProductRequest.java b/src/main/java/ntou/auction/spring/product/request/UpdateFixedPriceProductRequest.java similarity index 95% rename from src/main/java/ntou/auction/spring/data/entity/UpdateFixedPriceProductRequest.java rename to src/main/java/ntou/auction/spring/product/request/UpdateFixedPriceProductRequest.java index 1a9637f..7fba4ae 100644 --- a/src/main/java/ntou/auction/spring/data/entity/UpdateFixedPriceProductRequest.java +++ b/src/main/java/ntou/auction/spring/product/request/UpdateFixedPriceProductRequest.java @@ -1,4 +1,4 @@ -package ntou.auction.spring.data.entity; +package ntou.auction.spring.product.request; import jakarta.persistence.Column; import jakarta.persistence.Lob; diff --git a/src/main/java/ntou/auction/spring/data/entity/UpdateNonFixedPriceProductRequest.java b/src/main/java/ntou/auction/spring/product/request/UpdateNonFixedPriceProductRequest.java similarity index 96% rename from src/main/java/ntou/auction/spring/data/entity/UpdateNonFixedPriceProductRequest.java rename to src/main/java/ntou/auction/spring/product/request/UpdateNonFixedPriceProductRequest.java index b7b3ade..36f27bf 100644 --- a/src/main/java/ntou/auction/spring/data/entity/UpdateNonFixedPriceProductRequest.java +++ b/src/main/java/ntou/auction/spring/product/request/UpdateNonFixedPriceProductRequest.java @@ -1,4 +1,4 @@ -package ntou.auction.spring.data.entity; +package ntou.auction.spring.product.request; import jakarta.persistence.Column; import jakarta.persistence.Lob; diff --git a/src/main/java/ntou/auction/spring/data/service/ProductService.java b/src/main/java/ntou/auction/spring/product/service/ProductService.java similarity index 94% rename from src/main/java/ntou/auction/spring/data/service/ProductService.java rename to src/main/java/ntou/auction/spring/product/service/ProductService.java index 5de58d6..8f3eaa6 100644 --- a/src/main/java/ntou/auction/spring/data/service/ProductService.java +++ b/src/main/java/ntou/auction/spring/product/service/ProductService.java @@ -1,6 +1,6 @@ -package ntou.auction.spring.data.service; -import jakarta.validation.constraints.Null; -import ntou.auction.spring.data.entity.Product; +package ntou.auction.spring.product.service; +import ntou.auction.spring.product.repository.ProductRepository; +import ntou.auction.spring.product.entity.Product; import org.springframework.stereotype.Service; import java.util.List; diff --git a/src/main/java/ntou/auction/spring/data/service/TimerTask.java b/src/main/java/ntou/auction/spring/product/service/TimerTask.java similarity index 84% rename from src/main/java/ntou/auction/spring/data/service/TimerTask.java rename to src/main/java/ntou/auction/spring/product/service/TimerTask.java index fd307c2..c776882 100644 --- a/src/main/java/ntou/auction/spring/data/service/TimerTask.java +++ b/src/main/java/ntou/auction/spring/product/service/TimerTask.java @@ -1,8 +1,11 @@ -package ntou.auction.spring.data.service; +package ntou.auction.spring.product.service; +import ntou.auction.spring.shoppingcart.service.ShoppingcartService; +import ntou.auction.spring.account.response.UserIdentity; +import ntou.auction.spring.account.service.UserService; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; -import ntou.auction.spring.data.entity.Product; +import ntou.auction.spring.product.entity.Product; import org.springframework.transaction.annotation.Transactional; import java.util.List; diff --git a/src/main/java/ntou/auction/spring/controller/ShoppingcartController.java b/src/main/java/ntou/auction/spring/shoppingcart/controller/ShoppingcartController.java similarity index 89% rename from src/main/java/ntou/auction/spring/controller/ShoppingcartController.java rename to src/main/java/ntou/auction/spring/shoppingcart/controller/ShoppingcartController.java index 72a9d35..3b61154 100644 --- a/src/main/java/ntou/auction/spring/controller/ShoppingcartController.java +++ b/src/main/java/ntou/auction/spring/shoppingcart/controller/ShoppingcartController.java @@ -1,11 +1,16 @@ -package ntou.auction.spring.controller; +package ntou.auction.spring.shoppingcart.controller; import jakarta.validation.Valid; -import ntou.auction.spring.data.entity.*; -import ntou.auction.spring.data.service.ProductService; -import ntou.auction.spring.data.service.ShoppingcartService; -import ntou.auction.spring.data.service.UserIdentity; -import ntou.auction.spring.data.service.UserService; +import ntou.auction.spring.account.entity.User; +import ntou.auction.spring.product.service.ProductService; +import ntou.auction.spring.shoppingcart.service.ShoppingcartService; +import ntou.auction.spring.account.response.UserIdentity; +import ntou.auction.spring.account.service.UserService; +import ntou.auction.spring.product.entity.Product; +import ntou.auction.spring.shoppingcart.entity.Shoppingcart; +import ntou.auction.spring.shoppingcart.response.ProductAddAmount; +import ntou.auction.spring.shoppingcart.response.ProductClassificatedBySeller; +import ntou.auction.spring.shoppingcart.request.ShoppingcartRequest; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/ntou/auction/spring/data/entity/Shoppingcart.java b/src/main/java/ntou/auction/spring/shoppingcart/entity/Shoppingcart.java similarity index 94% rename from src/main/java/ntou/auction/spring/data/entity/Shoppingcart.java rename to src/main/java/ntou/auction/spring/shoppingcart/entity/Shoppingcart.java index 6b61d0d..50d332f 100644 --- a/src/main/java/ntou/auction/spring/data/entity/Shoppingcart.java +++ b/src/main/java/ntou/auction/spring/shoppingcart/entity/Shoppingcart.java @@ -1,10 +1,12 @@ -package ntou.auction.spring.data.entity; +package ntou.auction.spring.shoppingcart.entity; import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import ntou.auction.spring.util.AbstractEntity; + import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/ntou/auction/spring/data/service/ShoppingcartRepository.java b/src/main/java/ntou/auction/spring/shoppingcart/repository/ShoppingcartRepository.java similarity index 87% rename from src/main/java/ntou/auction/spring/data/service/ShoppingcartRepository.java rename to src/main/java/ntou/auction/spring/shoppingcart/repository/ShoppingcartRepository.java index 6620533..f03c37c 100644 --- a/src/main/java/ntou/auction/spring/data/service/ShoppingcartRepository.java +++ b/src/main/java/ntou/auction/spring/shoppingcart/repository/ShoppingcartRepository.java @@ -1,13 +1,12 @@ -package ntou.auction.spring.data.service; +package ntou.auction.spring.shoppingcart.repository; import jakarta.transaction.Transactional; -import ntou.auction.spring.data.entity.Shoppingcart; +import ntou.auction.spring.shoppingcart.entity.Shoppingcart; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; -import java.util.ArrayList; import java.util.List; import java.util.Optional; diff --git a/src/main/java/ntou/auction/spring/data/entity/ShoppingcartRequest.java b/src/main/java/ntou/auction/spring/shoppingcart/request/ShoppingcartRequest.java similarity index 85% rename from src/main/java/ntou/auction/spring/data/entity/ShoppingcartRequest.java rename to src/main/java/ntou/auction/spring/shoppingcart/request/ShoppingcartRequest.java index ce6d3df..eae457e 100644 --- a/src/main/java/ntou/auction/spring/data/entity/ShoppingcartRequest.java +++ b/src/main/java/ntou/auction/spring/shoppingcart/request/ShoppingcartRequest.java @@ -1,4 +1,4 @@ -package ntou.auction.spring.data.entity; +package ntou.auction.spring.shoppingcart.request; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; diff --git a/src/main/java/ntou/auction/spring/data/entity/ProductAddAmount.java b/src/main/java/ntou/auction/spring/shoppingcart/response/ProductAddAmount.java similarity index 68% rename from src/main/java/ntou/auction/spring/data/entity/ProductAddAmount.java rename to src/main/java/ntou/auction/spring/shoppingcart/response/ProductAddAmount.java index 4366945..e358e97 100644 --- a/src/main/java/ntou/auction/spring/data/entity/ProductAddAmount.java +++ b/src/main/java/ntou/auction/spring/shoppingcart/response/ProductAddAmount.java @@ -1,8 +1,10 @@ -package ntou.auction.spring.data.entity; +package ntou.auction.spring.shoppingcart.response; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; +import ntou.auction.spring.product.entity.Product; + @Getter @NoArgsConstructor @AllArgsConstructor diff --git a/src/main/java/ntou/auction/spring/data/entity/ProductClassificatedBySeller.java b/src/main/java/ntou/auction/spring/shoppingcart/response/ProductClassificatedBySeller.java similarity index 87% rename from src/main/java/ntou/auction/spring/data/entity/ProductClassificatedBySeller.java rename to src/main/java/ntou/auction/spring/shoppingcart/response/ProductClassificatedBySeller.java index 06bf779..d9b2e55 100644 --- a/src/main/java/ntou/auction/spring/data/entity/ProductClassificatedBySeller.java +++ b/src/main/java/ntou/auction/spring/shoppingcart/response/ProductClassificatedBySeller.java @@ -1,4 +1,4 @@ -package ntou.auction.spring.data.entity; +package ntou.auction.spring.shoppingcart.response; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/ntou/auction/spring/data/service/ShoppingcartService.java b/src/main/java/ntou/auction/spring/shoppingcart/service/ShoppingcartService.java similarity index 92% rename from src/main/java/ntou/auction/spring/data/service/ShoppingcartService.java rename to src/main/java/ntou/auction/spring/shoppingcart/service/ShoppingcartService.java index 1653e57..6394c86 100644 --- a/src/main/java/ntou/auction/spring/data/service/ShoppingcartService.java +++ b/src/main/java/ntou/auction/spring/shoppingcart/service/ShoppingcartService.java @@ -1,7 +1,9 @@ -package ntou.auction.spring.data.service; +package ntou.auction.spring.shoppingcart.service; -import ntou.auction.spring.data.entity.Product; -import ntou.auction.spring.data.entity.Shoppingcart; +import ntou.auction.spring.product.entity.Product; +import ntou.auction.spring.shoppingcart.entity.Shoppingcart; +import ntou.auction.spring.product.service.ProductService; +import ntou.auction.spring.shoppingcart.repository.ShoppingcartRepository; import org.springframework.stereotype.Service; import java.util.*; @@ -95,7 +97,7 @@ public Long checkIsProductAllInShoppingCart(List> order, Long userid) public boolean checkIsViolateSelfBuying(List> order, Long userid) { for(List product: order) { - Product nowProduct = productService.getID(product.get(0)); + Product nowProduct = productService.getID(product.getFirst()); if(nowProduct.getSellerID().equals(userid)) return true; } return false; diff --git a/src/main/java/ntou/auction/spring/data/entity/AbstractEntity.java b/src/main/java/ntou/auction/spring/util/AbstractEntity.java similarity index 96% rename from src/main/java/ntou/auction/spring/data/entity/AbstractEntity.java rename to src/main/java/ntou/auction/spring/util/AbstractEntity.java index ffd93c8..115a47c 100644 --- a/src/main/java/ntou/auction/spring/data/entity/AbstractEntity.java +++ b/src/main/java/ntou/auction/spring/util/AbstractEntity.java @@ -1,4 +1,4 @@ -package ntou.auction.spring.data.entity; +package ntou.auction.spring.util; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; diff --git a/src/main/java/ntou/auction/spring/core/AppConfig.java b/src/main/java/ntou/auction/spring/util/AppConfig.java similarity index 96% rename from src/main/java/ntou/auction/spring/core/AppConfig.java rename to src/main/java/ntou/auction/spring/util/AppConfig.java index 38bd0b1..9998a2c 100644 --- a/src/main/java/ntou/auction/spring/core/AppConfig.java +++ b/src/main/java/ntou/auction/spring/util/AppConfig.java @@ -1,4 +1,4 @@ -package ntou.auction.spring.core; +package ntou.auction.spring.util; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/src/main/java/ntou/auction/spring/controller/RestResponseEntityExceptionHandler.java b/src/main/java/ntou/auction/spring/util/RestResponseEntityExceptionHandler.java similarity index 96% rename from src/main/java/ntou/auction/spring/controller/RestResponseEntityExceptionHandler.java rename to src/main/java/ntou/auction/spring/util/RestResponseEntityExceptionHandler.java index 4f9ebea..b5ea398 100644 --- a/src/main/java/ntou/auction/spring/controller/RestResponseEntityExceptionHandler.java +++ b/src/main/java/ntou/auction/spring/util/RestResponseEntityExceptionHandler.java @@ -1,4 +1,4 @@ -package ntou.auction.spring.controller; +package ntou.auction.spring.util; import jakarta.validation.ConstraintViolation; import jakarta.validation.ConstraintViolationException; @@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.context.request.WebRequest; -import org.springframework.web.servlet.NoHandlerFoundException; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; import java.util.*; diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index 7000ac9..ebcf5fa 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -3,32 +3,33 @@ insert into user (version, id, username, name, hashed_password, avatar_image, av values (1, 1, 'admin', 'admin', '{argon2}$argon2id$v=19$m=16384,t=2,p=1$S9swkCEbXj5O8cwbZdyrtQ$4RkxTGl3xkEfm51P/gc3FORCysPStozAsm6smOnQR18', null, null, 'admin@example.com', true, true, true, true); - +/* insert into user (version, id, username, name, hashed_password, avatar_image, avatar_image_name, email, enabled, is_account_non_expired, is_account_non_locked, is_credentials_non_expired) values (1, 2, 'shit', 'admin', '{argon2}$argon2id$v=19$m=16384,t=2,p=1$S9swkCEbXj5O8cwbZdyrtQ$4RkxTGl3xkEfm51P/gc3FORCysPStozAsm6smOnQR18', null, null, 'weichun@example.com', true, true, true, true); - +*/ insert into user_roles (user_id, roles) values (1, 'USER'); +/* insert into user_roles (user_id, roles) values (2, 'USER'); +*/ insert into user_roles (user_id, roles) values (1, 'ADMIN'); - -insert into product (version,id,product_name,product_type,is_fixed_price,product_description,sellerid,upset_price,product_amount,current_price,update_time,finish_time,bid_increment,product_image) -values (1,1,'IPhone13','electronic',true,'ggggg',1,null,3,1500,"2023-11-04 19:45:00",null,null,null); +/* +insert into product (version,id,product_name,product_type,is_fixed_price,product_description,sellerid,seller_name,upset_price,product_amount,current_price,update_time,finish_time,bid_increment,product_image,visible) +values (1,1,'IPhone13','3C產品',true,'ggggg',1,'admin',null,3,1500,"2023-11-04 19:45:00",null,null,null,true); +insert into product (version,id,product_name,product_type,is_fixed_price,product_description,sellerid,seller_name,upset_price,product_amount,current_price,update_time,finish_time,bid_increment,product_image,visible) +values (1,2,'IPhone18','3C產品',true,'ggggg',1,'admin',null,3,1500,"2023-11-04 19:45:00",null,null,null,true); -/* -insert into product (version,id,product_name,product_type,is_fixed_price,product_description,sellerid,upset_price,product_amount,current_price,update_time,finish_time,bid_increment,product_image) -values (1,2,'IPhone18','electronic',true,'ggggg',1057088,null,3,1500,"2023-11-04 19:45:00",null,null,null); -*/ -insert into product (version,id,product_name,product_type,is_fixed_price,product_description,sellerid,upset_price,product_amount,current_price,update_time,finish_time,bid_increment,product_image) -values (1,3,'IPhone13','electronic',false,'ggggg',1,1000,1,1500,"2023-11-04 19:45:00","2023-11-04 20:45:00",1000,null); +insert into product (version,id,product_name,product_type,is_fixed_price,product_description,sellerid,upset_price,product_amount,current_price,update_time,finish_time,bid_increment,product_image,visible) +values (1,3,'IPhone13','3C產品',false,'ggggg',1,1000,1,1500,"2023-11-04 19:45:00","2023-11-04 20:45:00",1000,null,true); -insert into product (version,id,product_name,product_type,is_fixed_price,product_description,sellerid,upset_price,product_amount,current_price,update_time,finish_time,bid_increment,product_image) -values (1,4,'IPhone13','electronic',false,'ggggg',1,1000,1,1500,"2023-11-04 19:45:00","2023-11-30 18:45:00",1000,null); +insert into product (version,id,product_name,product_type,is_fixed_price,product_description,sellerid,upset_price,product_amount,current_price,update_time,finish_time,bid_increment,product_image,visible) +values (1,4,'IPhone13','3C產品',false,'ggggg',1,1000,1,1500,"2023-11-04 19:45:00","2023-11-30 18:45:00",1000,null,true); +*/ \ No newline at end of file