지금 프로젝트 파일럿 오픈이 얼마 남지않아... 코딩할 시간이 너무 없었네요..ㅠㅠ
주말에 몰아서 코딩 해 봅시다!!
1) user.js 수정
let index = {
init: function () {
$("#btn-save").on("click", ()=>{
this.save();
});
$("#btn-update").on("click", ()=>{
this.update();
});
},
save:function () {
//alert("user의 save함수 호출됨")
let data = {
username: $("#username").val(),
password: $("#password").val(),
email: $("#email").val(),
};
//console.log(data);
// ajax 호출시 default가 비동기 호출
// ajax 통신을 이용해서 3개의 데이터를 json 으로 변경하여 insert 요청
// ajax가 통신을 성공하고 서버가 json을 리턴해주면 자동으로 자바 오브젝트로 변환해줌.
$.ajax({
type: "POST",
url: "/auth/joinProc",
data: JSON.stringify(data), // http body 데이터
contentType: "application/json; charset=utf-8", // body 데이터가 어떤 타입인지(MIME)
dataType: "json"// 요청을 서버로해서 응답이 왔을 때 기본적으로 모든 것이 문자열(생긴게 json 이라면) => javascript 오브젝트로 변경
}).done(function (resp){
alert("회원가입이 완료되었습니다.");
//console.log(resp);
location.href = "/";
}).fail(function (error){
alert(JSON.stringify(error));
});
},
update:function () {
//alert("user의 save함수 호출됨")
let data = {
id: $("#id").val(),
username: $("#username").val(),
password: $("#password").val(),
email: $("#email").val(),
};
$.ajax({
type: "PUT",
url: "/user",
data: JSON.stringify(data), // http body 데이터
contentType: "application/json; charset=utf-8", // body 데이터가 어떤 타입인지(MIME)
dataType: "json"// 요청을 서버로해서 응답이 왔을 때 기본적으로 모든 것이 문자열(생긴게 json 이라면) => javascript 오브젝트로 변경
}).done(function (resp){
alert("회원수정이 완료되었습니다.");
//console.log(resp);
location.href = "/";
}).fail(function (error){
alert(JSON.stringify(error));
});
},
}
index.init();
2) UserApiController 수정
3) UserController 수정
4) UserService 수정
Spring security에 대한 이해가 아직 부족한 느낌이 있기 때문에
이 부분에 대해서 다시 공부를 해봐야 할 것 같다.