-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* temp * init * init * init (#2) * Temp2 (#3) * initial setting * initial setting * Temp2 (#4) * initial setting * initial setting * entity 일부 생성 * Init e (#5) * initE * initE * Table setting * Feat/#6 (#7) * initial setting * initial setting * entity 일부 생성 * 로그인 api 구현중 * Init e (#8) * initE * initE * Table setting * ,, * #7 (#9) * 로그인 API 구현 (#11) * Feat/#10 (#12) * 로그인 API 구현 * 로그인 API 완성 * Feat/#13 (#14) * 로그인 API 구현 * 로그인 API 완성 * feat[#13] 회원가입 API, 회원탈퇴 API 구현 * Feat/#7 (#15) * #7 * history API * Feat/#13 (#16) * 로그인 API 구현 * 로그인 API 완성 * feat[#13] 회원가입 API, 회원탈퇴 API 구현 * feat[#13] * feat[#13] * Update UserService.java merge conflict resolved * Feat/#13 (#18) * 로그인 API 구현 * 로그인 API 완성 * feat[#13] 회원가입 API, 회원탈퇴 API 구현 * feat[#13] * feat[#13] * Update UserService.java merge conflict resolved * 해커톤 화이팅 이것저것 구현함 * [#19] (#20) * Feat/#13 (#22) * 로그인 API 구현 * 로그인 API 완성 * feat[#13] 회원가입 API, 회원탈퇴 API 구현 * feat[#13] * feat[#13] * Update UserService.java merge conflict resolved * 해커톤 화이팅 이것저것 구현함 * ㅇ ㅇ * . * [#23] (#24) * Feat/crossorigin (#25) * . * crossorigin * Feat/#13 (#26) * 로그인 API 구현 * 로그인 API 완성 * feat[#13] 회원가입 API, 회원탈퇴 API 구현 * feat[#13] * feat[#13] * Update UserService.java merge conflict resolved * 해커톤 화이팅 이것저것 구현함 * ㅇ ㅇ * 로그인 관련 api 구현 완성 * Feat/#13 (#27) * 로그인 API 구현 * 로그인 API 완성 * feat[#13] 회원가입 API, 회원탈퇴 API 구현 * feat[#13] * feat[#13] * Update UserService.java merge conflict resolved * 해커톤 화이팅 이것저것 구현함 * ㅇ ㅇ * 로그인 관련 api 구현 완성 * Feat/merge (#28) * . * merge * merged * Feat/merge2 (#29) * . * merge2 * Feat/merge3 (#30) * . * merge3 * Feat/#13 (#31) * 로그인 API 구현 * 로그인 API 완성 * feat[#13] 회원가입 API, 회원탈퇴 API 구현 * feat[#13] * feat[#13] * Update UserService.java merge conflict resolved * 해커톤 화이팅 이것저것 구현함 * ㅇ ㅇ * 로그인 관련 api 구현 완성 * 잔디 심기 구현 * Feat/#13 (#32) * 로그인 API 구현 * 로그인 API 완성 * feat[#13] 회원가입 API, 회원탈퇴 API 구현 * feat[#13] * feat[#13] * Update UserService.java merge conflict resolved * 해커톤 화이팅 이것저것 구현함 * ㅇ ㅇ * 로그인 관련 api 구현 완성 * 잔디 심기 구현 * 잔디 심기 구현완료 * store API 수정 * Feat/#13 (#33) * 로그인 API 구현 * 로그인 API 완성 * feat[#13] 회원가입 API, 회원탈퇴 API 구현 * feat[#13] * feat[#13] * Update UserService.java merge conflict resolved * 해커톤 화이팅 이것저것 구현함 * ㅇ ㅇ * 로그인 관련 api 구현 완성 * 잔디 심기 구현 * 잔디 심기 구현완료 * 처음 유저 기본값 설정 * final (#34) --------- Co-authored-by: shinel98 <[email protected]>
- Loading branch information
Showing
55 changed files
with
1,813 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/com/greenpoint/server/admin/controller/AdminController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.greenpoint.server.admin.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.CrossOrigin; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@CrossOrigin | ||
@RequestMapping("/api") | ||
public class AdminController { | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/greenpoint/server/admin/model/Admin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.greenpoint.server.admin.model; | ||
|
||
|
||
import com.greenpoint.server.common.BaseEntity; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.hibernate.annotations.SQLDelete; | ||
import org.hibernate.annotations.Where; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Where(clause = "deleted = false") | ||
@SQLDelete(sql = "UPDATE admin SET deleted = true Where id = ?") | ||
public class Admin extends BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
private String name; | ||
private String adminID; | ||
private String password; | ||
|
||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/greenpoint/server/admin/repository/AdminRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.greenpoint.server.admin.repository; | ||
|
||
|
||
import com.greenpoint.server.admin.model.Admin; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface AdminRepository extends JpaRepository<Admin, Long> { | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/greenpoint/server/admin/service/AdminService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.greenpoint.server.admin.service; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class AdminService { | ||
} |
82 changes: 82 additions & 0 deletions
82
src/main/java/com/greenpoint/server/auth/controller/UserController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.greenpoint.server.auth.controller; | ||
|
||
import com.greenpoint.server.auth.response.AccountResponse; | ||
import com.greenpoint.server.auth.response.LoginResponse; | ||
import com.greenpoint.server.auth.service.UserService; | ||
import com.greenpoint.server.customer.model.Customer; | ||
import com.greenpoint.server.customer.repository.CustomerRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import javax.servlet.http.HttpSession; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@CrossOrigin | ||
@RequestMapping("/api") | ||
public class UserController { | ||
@Autowired | ||
private UserService userService; | ||
|
||
@GetMapping("/login") | ||
public ResponseEntity<LoginResponse> getLogin(@RequestParam("code") String code) { | ||
|
||
boolean isRegistered; | ||
Object[] obArr = new Object[2]; | ||
Customer userInfo = new Customer(); | ||
obArr = userService.saveUser(code); | ||
System.out.println("obArr = " + obArr); | ||
userInfo = (Customer) obArr[0]; | ||
isRegistered = (boolean) obArr[1]; | ||
LoginResponse loginResponse = new LoginResponse(userInfo.getKakaoId(), userInfo.getKakaoToken(), userInfo.getNickname(), userInfo.getImage(), isRegistered); | ||
return ResponseEntity.ok(loginResponse); | ||
} | ||
|
||
@PostMapping("/makeAccount") | ||
public ResponseEntity<AccountResponse> makeAccount(@RequestBody HashMap<String, String> param) { | ||
Boolean result; | ||
System.out.println("param = " + param); | ||
result = userService.getUserInfoByForm(param); | ||
if(result == false) { | ||
AccountResponse accountResponse = new AccountResponse(false); | ||
return ResponseEntity.ok(accountResponse); | ||
} | ||
AccountResponse accountResponse = new AccountResponse(true); | ||
return ResponseEntity.ok(accountResponse); | ||
} | ||
|
||
@Transactional | ||
@DeleteMapping("/deleteMember") | ||
public String deleteAccount(@RequestParam("id") Long id){ | ||
String resultCode = ""; | ||
int result = userService.memberDelete(id); | ||
if(result == 0){ | ||
resultCode = "회원 탈퇴 실패"; | ||
|
||
} else { | ||
// session.removeAttribute("sessionId"); | ||
resultCode = "회원 탈퇴 성공"; | ||
} | ||
return resultCode; | ||
} | ||
|
||
} | ||
|
19 changes: 19 additions & 0 deletions
19
src/main/java/com/greenpoint/server/auth/model/KakaoProfile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.greenpoint.server.auth.model; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class KakaoProfile { | ||
private Long id; | ||
private Properties properties; | ||
|
||
|
||
|
||
@Data | ||
public class Properties { | ||
public String nickname; | ||
public String profile_image; // 이미지 경로 필드1 | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
11 changes: 11 additions & 0 deletions
11
src/main/java/com/greenpoint/server/auth/repository/UserRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// | ||
//package com.greenpoint.server.auth.repository; | ||
// | ||
//import com.greenpoint.server.customer.model.Customer; | ||
//import org.springframework.data.jpa.repository.JpaRepository; | ||
// | ||
//public interface UserRepository extends JpaRepository<Customer, Long> { | ||
// | ||
// | ||
//} | ||
|
16 changes: 16 additions & 0 deletions
16
src/main/java/com/greenpoint/server/auth/response/AccountResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.greenpoint.server.auth.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class AccountResponse { | ||
// private String nickname; | ||
// private String contact; | ||
private boolean isRegistered; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/greenpoint/server/auth/response/LoginResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.greenpoint.server.auth.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class LoginResponse { | ||
private Long kakaoId; | ||
private String token; | ||
private String nickname; | ||
private String image; | ||
private boolean isRegistered; | ||
} |
118 changes: 118 additions & 0 deletions
118
src/main/java/com/greenpoint/server/auth/service/UserService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package com.greenpoint.server.auth.service; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.greenpoint.server.auth.model.KakaoProfile; | ||
import com.greenpoint.server.auth.model.KakaoProfile; | ||
import com.greenpoint.server.customer.model.Customer; | ||
import com.greenpoint.server.customer.repository.CustomerRepository; | ||
import com.greenpoint.server.level.service.LevelService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.*; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.util.LinkedMultiValueMap; | ||
import org.springframework.util.MultiValueMap; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
import java.sql.SQLOutput; | ||
|
||
import javax.servlet.http.HttpSession; | ||
import java.sql.SQLOutput; | ||
import java.util.HashMap; | ||
|
||
@Service | ||
public class UserService { | ||
@Autowired | ||
private CustomerRepository customerRepository; | ||
@Autowired | ||
private LevelService levelService; | ||
public Object[] saveUser(String token) { | ||
|
||
Object[] obArr = new Object[2]; | ||
String name = null; | ||
String imageUrl = null; | ||
Long id = null; | ||
|
||
String userInfo = getUserInfoByAccessToken(token); | ||
ObjectMapper objectMapper = new ObjectMapper(); | ||
try { | ||
JsonNode jsonNode = objectMapper.readTree(userInfo); | ||
System.out.println(jsonNode); | ||
id = Long.valueOf(String.valueOf(jsonNode.get("id"))); | ||
System.out.println("id = " + id); | ||
name = String.valueOf(jsonNode.get("kakao_account").get("profile").get("nickname")); | ||
imageUrl = String.valueOf(jsonNode.get("kakao_account").get("profile").get("profile_image_url")); | ||
} catch (JsonProcessingException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
System.out.println("userInfo" + userInfo); | ||
|
||
Customer user; | ||
|
||
user = customerRepository.findByKakaoId(id); | ||
System.out.println("user = " + user); | ||
if(user == null) { | ||
Customer newUser = Customer.from(id, token, name.substring(1, name.length() - 1), imageUrl.substring(1, imageUrl.length() - 1)); | ||
obArr[0] = newUser; | ||
obArr[1] = false; | ||
customerRepository.save(newUser); | ||
return obArr; | ||
} | ||
|
||
obArr[0] = user; | ||
obArr[1] = true; | ||
return obArr; | ||
} | ||
|
||
|
||
public String getUserInfoByAccessToken(String accessToken) { | ||
RestTemplate restTemplate = new RestTemplate(); | ||
HttpHeaders headers = new HttpHeaders(); | ||
headers.set("Authorization", "Bearer " + accessToken); | ||
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); | ||
|
||
LinkedMultiValueMap<String, String> params = new LinkedMultiValueMap<>(); | ||
|
||
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(params, headers); | ||
|
||
String url = "https://kapi.kakao.com/v2/user/me"; | ||
|
||
return restTemplate.postForObject(url, request, String.class); | ||
} | ||
public Boolean getUserInfoByForm(HashMap<String, String> param) { | ||
Customer user; | ||
|
||
Long id = Long.valueOf(param.get("id")); | ||
System.out.println("id = " + id); | ||
try{ | ||
user = customerRepository.findByKakaoId(id); | ||
user.setContact(param.get("contact")); | ||
user.setNickname(param.get("nickname")); | ||
user.setLatitude(Double.valueOf(param.get("latitude"))); | ||
user.setLongitude(Double.valueOf(param.get("longitude"))); | ||
user.setPoint(0); | ||
user.setTotalPoint(0); | ||
user.setLevel(levelService.findByGrade(1)); | ||
// user = Customer.from(param.get("nickname"), param.get("contact")); | ||
user = customerRepository.save(user); | ||
if(user == null){ | ||
return false; | ||
} | ||
} | ||
catch(Exception e){ | ||
System.out.println("토큰이 다름!"); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
|
||
public int memberDelete(Long id) { | ||
int result = customerRepository.deleteByKakaoId(id); | ||
return result; | ||
} | ||
|
||
} |
Oops, something went wrong.