Skip to content

Commit

Permalink
[박현석]
Browse files Browse the repository at this point in the history
- 회원가입 중복확인 추가

#2
  • Loading branch information
DESKTOP-I633S8U\user committed Mar 20, 2023
1 parent 134a537 commit 596626f
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 49 deletions.
14 changes: 10 additions & 4 deletions src/main/java/com/hsp/hoicegram/user/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@
@RequestMapping("/user")
public class UserController {

@GetMapping("/signup/view")
public String signup() {
return "user/signup";
}


@GetMapping("/signin/view")
public String signin() {
return "user/signin";
}







@GetMapping("/signup")
public String signup() {
return "user/signup";
}
}
41 changes: 20 additions & 21 deletions src/main/java/com/hsp/hoicegram/user/UserRestController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
Expand Down Expand Up @@ -43,49 +44,47 @@ public Map<String, String> signup(


@PostMapping("/email_duplicate")
public Map<String, String> emailDuplicate(@RequestParam("email") String email) {
public Map<String, Boolean> emailDuplicate(@RequestParam("email") String email) {

int count = userBO.emailDuplicate(email);
Map<String, Boolean> resultMap = new HashMap<>();

Map<String, String> resultMap = new HashMap<>();

if(count == 0) {
resultMap.put("result", "false");
if(userBO.emailDuplicate(email)) {
resultMap.put("result", true);
} else {
resultMap.put("result", "true");
resultMap.put("result", false);
}

return resultMap;

// resultMap.put("result", userBO.nicknameDuplicate(email));
// return resultMap;

}

@PostMapping("/nickname_duplicate")
public Map<String, String> nicknameDuplicate(@RequestParam("nickname") String nickname) {
@GetMapping("/nickname_duplicate")
public Map<String, Boolean> nicknameDuplicate(@RequestParam("nickname") String nickname) {

int count = userBO.nicknameDuplicate(nickname);

Map<String, String> resultMap = new HashMap<>();
Map<String, Boolean> resultMap = new HashMap<>();

if(count == 0) {
resultMap.put("result", "false");
if(userBO.nicknameDuplicate(nickname)) {
resultMap.put("result", true);
} else {
resultMap.put("result", "true");
resultMap.put("result", false);
}

return resultMap;

}
@PostMapping("/phoneNumber_duplicate")
public Map<String, String> phoneNumberDuplicate(@RequestParam("phoneNumber") String phoneNumber) {

int count = userBO.phoneNumberDuplicate(phoneNumber);
public Map<String, Boolean> phoneNumberDuplicate(@RequestParam("phoneNumber") String phoneNumber) {

Map<String, String> resultMap = new HashMap<>();
Map<String, Boolean> resultMap = new HashMap<>();

if(count == 0) {
resultMap.put("result", "false");
if(userBO.phoneNumberDuplicate(phoneNumber)) {
resultMap.put("result", true);
} else {
resultMap.put("result", "true");
resultMap.put("result", false);
}

return resultMap;
Expand Down
33 changes: 26 additions & 7 deletions src/main/java/com/hsp/hoicegram/user/bo/UserBO.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,39 @@ public int addUser(
String encryptPassword = EncryptService.md5(password);

return userDAO.insertUser(email, userName, nickname, phoneNumber, encryptPassword);

}



public int emailDuplicate(String email) {
return userDAO.selectEmail(email);
public boolean emailDuplicate(String email) {
int count = userDAO.selectEmail(email);
if(count == 0) {
return false;
} else {
return true;
}
}

public int nicknameDuplicate(String nickname) {
return userDAO.selectNickname(nickname);
public boolean nicknameDuplicate(String nickname) {
int count = userDAO.selectNickname(nickname);

if(count == 0) {
return false;
} else {
return true;
}
}

public int phoneNumberDuplicate(String phoneNumber) {
return userDAO.selectPhoneNumber(phoneNumber);
public boolean phoneNumberDuplicate(String phoneNumber) {
int count = userDAO.selectPhoneNumber(phoneNumber);

if(count == 0) {
return false;
} else {
return true;
}

// userDAO.selectPhoneNumber(phoneNumber) != 0; => 이해 하면 쓰기
}

}
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ spring:
suffix: .jsp
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/hoicegram
url: jdbc:mysql://localhost:3306/hoicegram_0316
username: root
password: root
12 changes: 8 additions & 4 deletions src/main/resources/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,26 @@
margin:auto;
}


.join {
border-radius: 10px;
}

.join-box {
width:400px;

}

.join {
height:600px;
}

.box {
width:300px;
}

.signin {
height:70px;
border-radius: 10px;
}

footer {
footer {
height:60px;
}
47 changes: 47 additions & 0 deletions src/main/webapp/WEB-INF/jsp/user/signin.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>hoicegram-회원가입</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<script src="https://code.jquery.com/jquery-3.6.4.min.js" integrity="sha256-oP6HI9z1XaZNBrJURtCoUT5SUnxFr8s3BzRl+cbzUq8=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

<link rel="stylesheet" href="/static/css/style.css" type="text/css">
<style>
@import url('https://fonts.googleapis.com/css2?family=Italianno&display=swap');
.Italianno { font-family: Italianno; }
</style>
</head>
<body>

<div id="wrap">
<section class="mt-5 d-flex justify-content-center">
<div class="join-box">
<div class="join border border-sencondary d-flex justify-content-center align-items-center">
<div class="box my-4">
<div class="text-center Italianno display-2">hoicegram</div>
<div class="pt-2"><hr></div>
<div class="d-flex mt-5">
<input type="text" placeholder="아이디 : email" id="emailInput" class="form-control">
</div>
<input type="password" placeholder="비밀번호" id="passwordInput" class="form-control mt-4">
<button type="button" id="joinBtn" class="btn btn-primary btn-block mt-4">로그인</button>
</div>
</div>

<div class="signin mt-3 d-flex align-items-center justify-content-center border border-sencondary">
<h5 class="pt-2">계정이 없으신가요? <a href="/user/signup/view">회원가입</a></h5>
</div>
</div>
</section>
<c:import url="/WEB-INF/jsp/user/include/footer.jsp"/>
</div>

</body>
</html>
39 changes: 27 additions & 12 deletions src/main/webapp/WEB-INF/jsp/user/signup.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
<div class="join-box">
<div class="join border border-sencondary d-flex justify-content-center align-items-center">
<div class="box my-4">
<div class="text-center Italianno display-4">hoicegram</div>
<div class="pt-2"><hr></div>
<div class="text-center Italianno display-2">hoicegram</div>
<div class="d-flex mt-5">
<input type="text" placeholder="아이디 : email" id="emailInput" class="form-control col-9"> <button class="btn btn-sm btn-primary ml-2" id="emailCheck">중복확인</button>
</div>
Expand All @@ -35,7 +34,7 @@
<input type="text" placeholder="사용자 이름" id="nicknameInput" class="form-control col-9"> <button class="btn btn-sm btn-primary ml-2" id="nicknameCheck">중복확인</button>
</div>
<div class="d-flex mt-4">
<input type="text" placeholder="휴대폰 번호" id="phoneNumberInput" class="form-control col-9"> <button class="btn btn-sm btn-primary ml-2" id="phoneNumberCheck">중복확인</button>
<input type="text" placeholder="휴대폰 번호 : - 포함" id="phoneNumberInput" class="form-control col-9"> <button class="btn btn-sm btn-primary ml-2" id="phoneNumberCheck">중복확인</button>
</div>
<input type="password" placeholder="비밀번호" id="passwordInput" class="form-control mt-4">
<input type="password" placeholder="비밀번호 확인" id="passwordCheck" class="form-control mt-4">
Expand All @@ -44,7 +43,7 @@
</div>

<div class="signin mt-3 d-flex align-items-center justify-content-center border border-sencondary">
<h5 class="pt-2">계정이 있으신가요? <a href="#">로그인</a></h5>
<h5 class="pt-2">계정이 있으신가요? <a href="/user/signin/view">로그인</a></h5>
</div>
</div>
</section>
Expand All @@ -60,15 +59,31 @@
var phoneNumberCheck = false;
var phoneNumberDuplicate = true;
$("#emailinput").on("input", function()) {
emailCheck = false;
emailDuplicate = true;
};
$("#nicknameInput").on("input", function()) {
nicknameCheck = false;
nicknameDuplicate = true;
};
$("#phoneNumberInput").on("input", function() {
phoneNumberCheck = false;
phoneNumberDuplicate = true;
});
$("#nicknameCheck").on("click", function() {
let nickname = $("#nicknameInput").val();
$.ajax({
type:"post"
type:"get"
, url:"/user/nickname_duplicate"
, data:{"nickname":nickname}
, success:function(data) {
if(data.result == "false") {
if(data.result == false) {
alert("사용 가능한 이름 입니다.");
nicknameDuplicate = false;
nicknameCheck = true;
Expand All @@ -91,7 +106,7 @@
, url:"/user/email_duplicate"
, data:{"email":email}
, success:function(data) {
if(data.result == "false") {
if(!data.result) {
alert("사용 가능한 이메일 입니다.");
emailDuplicate = false;
emailCheck = true;
Expand All @@ -115,7 +130,7 @@
, url:"/user/phoneNumber_duplicate"
, data:{"phoneNumber":phoneNumber}
, success:function(data) {
if(data.result == "false") {
if(data.result == false) {
alert("사용 가능한 번호입니다.");
phoneNumberDuplicate = false;
phoneNumberCheck = true;
Expand Down Expand Up @@ -189,13 +204,13 @@
return;
}
if(phoneNumberCheck == false) {
alert("휴대폰 번호 중복 확인을 진행해 주세요.");
if(nicknameDuplicate == true) {
alert("사용자 이름이 중복되었습니다.");
return;
}
if(nicknameDuplicate == true) {
alert("사용자 이름이 중복되었습니다.");
if(phoneNumberCheck == false) {
alert("휴대폰 번호 중복 확인을 진행해 주세요.");
return;
}
Expand Down

0 comments on commit 596626f

Please sign in to comment.