diff --git a/customer-apigateway-service/src/main/resources/application.yml b/customer-apigateway-service/src/main/resources/application.yml index 58d0ba0..8662617 100644 --- a/customer-apigateway-service/src/main/resources/application.yml +++ b/customer-apigateway-service/src/main/resources/application.yml @@ -21,7 +21,7 @@ spring: predicates: - Path=/customer-frontend-service/** filters: - - RewritePath=/owner-frontend-service/(?.*),/$\{segment} + - RewritePath=/customer-frontend-service/(?.*),/$\{segment} - id: order-service uri: lb://ORDER-SERVCIE predicates: diff --git a/customer-frontend-service/src/main/java/com/justpickup/customerfrontendservice/domain/customer/CustomerController.java b/customer-frontend-service/src/main/java/com/justpickup/customerfrontendservice/domain/customer/CustomerController.java index 676cdad..bbc1fe0 100644 --- a/customer-frontend-service/src/main/java/com/justpickup/customerfrontendservice/domain/customer/CustomerController.java +++ b/customer-frontend-service/src/main/java/com/justpickup/customerfrontendservice/domain/customer/CustomerController.java @@ -7,9 +7,13 @@ import org.springframework.web.bind.annotation.RequestMapping; @Controller @Slf4j -@RequestMapping("/") public class CustomerController { + @GetMapping("/") + public String index(){ + return "/index"; + } + @GetMapping("/food-home") public String hello(){ diff --git a/customer-frontend-service/src/main/resources/templates/domain/food/food-home-1.html b/customer-frontend-service/src/main/resources/templates/domain/food/food-home-1.html index 6a02a1e..02061ab 100755 --- a/customer-frontend-service/src/main/resources/templates/domain/food/food-home-1.html +++ b/customer-frontend-service/src/main/resources/templates/domain/food/food-home-1.html @@ -5,11 +5,7 @@
-
diff --git a/customer-frontend-service/src/main/resources/templates/index.html b/customer-frontend-service/src/main/resources/templates/index.html new file mode 100755 index 0000000..425b204 --- /dev/null +++ b/customer-frontend-service/src/main/resources/templates/index.html @@ -0,0 +1,481 @@ + + + +
+ + + +
+ +
+
+
+
+
+
+

StickyMobile

+

The Menu Everyone Requested.

+
+
+ +
+
+
+
+
+

Carefuly Built

+

Flexibility, Speed, Ease of Use.

+
+
+ +
+
+
+
+
+

Elite Quality

+

Mobile Website, App or PWA Ready.

+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+

Call to Actions

+

Sticky comes Prepared for You

+

+ Call to action are highly important, but we can't choose a style for you, so we created a few! +

+ Swipe Left to Begin +
+
+
+ +
+
+
+

Let's get Social

+

Follow & Get in Touch with Us

+

+ It's easy. Just add your links and you're ready to go. Social links are wildely available in Sticky +

+

+ + + +

+
+
+
+ +
+
+
+

This or That?

+

Which is your Favorite?

+

+ Multiple choices are awesome, highlighting them is even easier with our Call to Actions +

+

+ Call Now + or + GET A QUOTE +

+
+
+
+ +
+
+
+

Direct Action

+

Invite Users to Tap Button

+

+ Make a button stand out at the top of your page so it's easily accessible as a first option. +

+ Purchase today for $25 +
+
+
+
+
+
+ +
+
+

Packed with Goodies

+

The Absolute Best Products & Care for You

+

+ Over 10 years of Experience in Building Gorgeous Products only for you! We are Envato Elite. +

+
+
+
+
+ +

Future Proof

+

Built to last, with the latest quality code

+
+
+ +

Powerful

+

Speed, Features and Flexibility all in One!

+
+
+ +

Easy to Use

+

Customers love our work for it's ease.

+
+
+ +

Customer Care

+

We treat others like we want to be treated.

+
+
+
+ + +
+
+
+
+
+
+

EazyMobile

+

+ + + + + +

+ Purchase +
+
+
+
+
+
+
+

UltraMobile

+

+ + + + + +

+ Purchase +
+
+
+
+
+
+
+

KolorMobile

+

+ + + + + +

+ Purchase +
+
+
+
+
+
+
+ +
+
+

Care & Quality

+

No stone left unturned, no aspect overlooked.

+

+ + + + + +

+
+
+
+
+

+ The code is always great with any Enabled template, the customer support that wins me over always. +

+
+
+

+ The best support I have ever had, it's so good I purchased another theme. Highlighy Recommended. +

+
+
+
+
+ More Testimonials +
+
+ +
+
+
+
+
+
+ +
+
+

Performance

+

Fast and feature filled

+
+
+
+
+
+
+
+ +
+
+

Elite Care

+

Built by the Best for You

+
+
+
+
+
+
+
+ +
+
+

Quality

+

Built with Care and Detail

+
+
+
+
+
+
+
+ + + +
+
+

Get Sticky Today

+

Tons of Awesome Features just for You.

+

+ Fast, easy to use and filled with features. Get Sticky Today and give your site the Mobile Feeling it deserves. +

+ Purchase Now - $25 +
+
+ + + +
+ + + + + + + + + + + + + + + + + + +
+ + \ No newline at end of file diff --git a/user-service/src/main/java/com/justpickup/userservice/domain/user/dto/OAuthAttributeDto.java b/user-service/src/main/java/com/justpickup/userservice/domain/user/dto/OAuthAttributeDto.java new file mode 100644 index 0000000..a5b8282 --- /dev/null +++ b/user-service/src/main/java/com/justpickup/userservice/domain/user/dto/OAuthAttributeDto.java @@ -0,0 +1,66 @@ +package com.justpickup.userservice.domain.user.dto; + +import com.justpickup.userservice.domain.user.entity.AuthType; +import com.justpickup.userservice.domain.user.entity.Customer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OAuthAttributeDto { + private Map attributes; // OAuth2 반환하는 유저정보 MAP + private String nameAttributeKey; + private String name; + private String email; + private AuthType authType; + + + public OAuthAttributeDto(Map attributes, String nameAttributeKey, String name, String email) { + this.attributes = attributes; + this.nameAttributeKey = nameAttributeKey; + this.name = name; + this.email = email; + } + + public static OAuthAttributeDto of(String registrationId, String userNameAttributeName, Map attributes){ + // 여기서 네이버와 카카오 등 구분 (ofNaver, ofKakao) + if("naver".equals(registrationId)) + return ofNaver(userNameAttributeName , attributes); + + return ofGoogle(userNameAttributeName, attributes); + } + + private static OAuthAttributeDto ofNaver(String userNameAttributeName, Map attributes) { + Map response = (Map) attributes.get("response"); + return OAuthAttributeDto.builder() + .name((String) response.get("name")) + .email((String) response.get("email")) + .nameAttributeKey("id") + .attributes(response) + .authType(AuthType.NAVER) + .build(); + } + + + private static OAuthAttributeDto ofGoogle(String userNameAttributeName, Map attributes) { + return OAuthAttributeDto.builder() + .name((String) attributes.get("name")) + .email((String) attributes.get("email")) + .nameAttributeKey(userNameAttributeName) + .attributes(attributes) + .authType(AuthType.GOOGLE) + .build(); + } + + public Customer toEntity(OAuthAttributeDto attributeDto){ + return new Customer(email,"temp",name,null, attributeDto.getAuthType()); + } + + +} diff --git a/user-service/src/main/java/com/justpickup/userservice/domain/user/entity/Role.java b/user-service/src/main/java/com/justpickup/userservice/domain/user/entity/Role.java new file mode 100644 index 0000000..ad49513 --- /dev/null +++ b/user-service/src/main/java/com/justpickup/userservice/domain/user/entity/Role.java @@ -0,0 +1,14 @@ +package com.justpickup.userservice.domain.user.entity; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum Role { + GUEST("ROLE_GUEST", "손님"), + USER("ROLE_USER", "일반 사용자"); + + private final String key; + private final String title; +} diff --git a/user-service/src/main/java/com/justpickup/userservice/domain/user/service/UserServiceImpl.java b/user-service/src/main/java/com/justpickup/userservice/domain/user/service/UserServiceImpl.java index 1875c8a..541d7d2 100644 --- a/user-service/src/main/java/com/justpickup/userservice/domain/user/service/UserServiceImpl.java +++ b/user-service/src/main/java/com/justpickup/userservice/domain/user/service/UserServiceImpl.java @@ -1,23 +1,14 @@ package com.justpickup.userservice.domain.user.service; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; import com.justpickup.userservice.domain.user.dto.CustomerDto; import com.justpickup.userservice.domain.user.dto.OAuthAttributeDto; -import com.justpickup.userservice.domain.user.entity.AuthType; import com.justpickup.userservice.domain.user.entity.Customer; import com.justpickup.userservice.domain.user.exception.NotExistUserException; import com.justpickup.userservice.domain.user.repository.CustomerRepository; import lombok.*; import lombok.extern.slf4j.Slf4j; import org.springframework.core.env.Environment; -import org.springframework.data.annotation.ReadOnlyProperty; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.oauth2.client.userinfo.DefaultOAuth2UserService; import org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest; @@ -27,14 +18,10 @@ import org.springframework.security.oauth2.core.user.DefaultOAuth2User; import org.springframework.security.oauth2.core.user.OAuth2User; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.client.RestTemplate; -import javax.servlet.http.HttpSession; +import javax.servlet.http.HttpServletResponse; import java.io.Serializable; import java.util.Collections; -import java.util.HashMap; -import java.util.Optional; -import java.util.function.Function; @Service @RequiredArgsConstructor @@ -43,7 +30,7 @@ import java.util.function.Function; public class UserServiceImpl implements UserService { private final CustomerRepository customerRepository; - private final HttpSession httpSession; + private final HttpServletResponse response; private final Environment env; @Override @@ -98,7 +85,7 @@ public class UserServiceImpl implements UserService { .orElse(attributeDto.toEntity(attributeDto)) ); - httpSession.setAttribute("user", new SessionCustomer(customer)); // SessionUser (직렬화된 dto 클래스 사용) + // TODO: 2022/02/16 Response에 token 담아 보내기 return new DefaultOAuth2User( Collections.singleton(new SimpleGrantedAuthority(customer.getRole().getKey())) @@ -108,11 +95,11 @@ public class UserServiceImpl implements UserService { } @Getter - public class SessionCustomer implements Serializable { + public static class UserPayload implements Serializable { private String name; private String email; - public SessionCustomer(Customer user){ + public UserPayload(Customer user){ this.name = user.getName(); this.email = user.getEmail(); } diff --git a/user-service/src/main/java/com/justpickup/userservice/global/security/WebSecurity.java b/user-service/src/main/java/com/justpickup/userservice/global/security/WebSecurity.java index 4ff3b05..933a097 100644 --- a/user-service/src/main/java/com/justpickup/userservice/global/security/WebSecurity.java +++ b/user-service/src/main/java/com/justpickup/userservice/global/security/WebSecurity.java @@ -24,6 +24,7 @@ public class WebSecurity extends WebSecurityConfigurerAdapter { .logoutSuccessUrl("/") .and() .oauth2Login() + .defaultSuccessUrl("http://just-pickup.com:8000/customer-frontend-service/") .userInfoEndpoint() .userService(userService);