-
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.
Merge pull request #5 from codeBoogie/feature/4
[개발 #4] Auth Api (controller, service), Member관련 Domain 폴더 설정 추가
- Loading branch information
Showing
6 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
...d/src/main/java/com/codeboogie/comfortbackend/api/member/controller/MemberController.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,36 @@ | ||
package com.codeboogie.comfortbackend.api.member.controller; | ||
|
||
import com.codeboogie.comfortbackend.api.member.service.MemberService; | ||
import com.codeboogie.comfortbackend.common.member.domain.dto.MemberDTO; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.util.MultiValueMap; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.HashMap; | ||
|
||
@RestController | ||
@RequestMapping("api") | ||
public class MemberController { | ||
|
||
@Autowired | ||
private MemberService memberService; | ||
|
||
@RequestMapping(value = "/member", method= {RequestMethod.POST}) | ||
public @ResponseBody void insert(@RequestParam HashMap<String, String> data, MemberDTO memberDTO) { | ||
System.out.println("안드로이드 -> 서버로 Post 요청"+ data+ ":"+ data.get("userId")); | ||
|
||
try{ | ||
|
||
String userId = String.valueOf(data.get("userId")); | ||
String userName = String.valueOf(data.get("userName")); | ||
memberDTO.setUserId(userId); | ||
memberDTO.setUserName(userName); | ||
|
||
memberService.createMember(memberDTO); | ||
|
||
} catch (Exception e){ | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
backend/src/main/java/com/codeboogie/comfortbackend/api/member/service/MemberService.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.codeboogie.comfortbackend.api.member.service; | ||
|
||
import com.codeboogie.comfortbackend.common.member.domain.dto.MemberDTO; | ||
|
||
public interface MemberService { | ||
boolean createMember(MemberDTO memberDTO); | ||
} |
34 changes: 34 additions & 0 deletions
34
...end/src/main/java/com/codeboogie/comfortbackend/api/member/service/MemberServiceImpl.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.codeboogie.comfortbackend.api.member.service; | ||
|
||
import com.codeboogie.comfortbackend.common.member.domain.dto.MemberDTO; | ||
import com.codeboogie.comfortbackend.common.member.domain.model.Member; | ||
import com.codeboogie.comfortbackend.common.member.domain.repository.MemberRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class MemberServiceImpl implements MemberService{ | ||
|
||
@Autowired | ||
private final MemberRepository memberRepository; | ||
|
||
@Override | ||
public boolean createMember(MemberDTO memberDTO){ | ||
// TODO: login id 검사 로직 추가 | ||
try{ | ||
Member member = new Member(); | ||
member.setUserId(memberDTO.getUserId()); | ||
member.setUserName(memberDTO.getUserName()); | ||
|
||
Member memberResult = memberRepository.save(member); | ||
|
||
|
||
} catch (Exception e){ | ||
e.printStackTrace(); | ||
} | ||
return true; | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
backend/src/main/java/com/codeboogie/comfortbackend/common/member/domain/dto/MemberDTO.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,12 @@ | ||
package com.codeboogie.comfortbackend.common.member.domain.dto; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class MemberDTO { | ||
private String _id; | ||
|
||
private String userId; | ||
|
||
private String userName; | ||
} |
33 changes: 33 additions & 0 deletions
33
backend/src/main/java/com/codeboogie/comfortbackend/common/member/domain/model/Member.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,33 @@ | ||
package com.codeboogie.comfortbackend.common.member.domain.model; | ||
|
||
import lombok.*; | ||
import org.springframework.data.mongodb.core.index.Indexed; | ||
import org.springframework.data.mongodb.core.mapping.Document; | ||
|
||
import javax.persistence.*; | ||
import java.util.Date; | ||
|
||
/** | ||
* @author 이해인 | ||
* @version 1.0, 2021.10.08 생성 | ||
* 회원 API 객체 모델 정의 | ||
* | ||
*/ | ||
|
||
@Data | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Document(collection = "member") | ||
public class Member { | ||
|
||
@Id | ||
@Column(name= "member_id") // mongodb에선 jpa적용 불가 | ||
private String _id; | ||
|
||
@Indexed(unique = true) | ||
private String userId; //카카오 사용자 아이디 | ||
|
||
private String userName; //카카오 사용자 이름 | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
.../java/com/codeboogie/comfortbackend/common/member/domain/repository/MemberRepository.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,10 @@ | ||
package com.codeboogie.comfortbackend.common.member.domain.repository; | ||
|
||
import com.codeboogie.comfortbackend.common.member.domain.model.Member; | ||
import org.springframework.data.mongodb.repository.MongoRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface MemberRepository extends MongoRepository<Member, String> { | ||
Optional<Member> findById(String userId); | ||
} |