할일 추가 기능
This commit is contained in:
7
pom.xml
7
pom.xml
@@ -131,6 +131,13 @@
|
||||
<version>2.10.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-dbcp2 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-dbcp2</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package co.nook.app.common;
|
||||
|
||||
import java.sql.*;
|
||||
|
||||
public class Dao{
|
||||
|
||||
public static Connection getConnection(){
|
||||
Connection conn = null;
|
||||
try{
|
||||
Class.forName("org.mariadb.jdbc.Driver");
|
||||
|
||||
String url = "jdbc:mariadb://coon.myds.me:3307/NookSearch";
|
||||
String userId = "minechost";
|
||||
String pw = "Ahstmxj5zos1!";
|
||||
conn = DriverManager.getConnection(url, userId, pw);
|
||||
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return conn;
|
||||
}
|
||||
|
||||
public static void close(Connection conn){
|
||||
try{
|
||||
conn.close();
|
||||
}catch(SQLException throwables){
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
package co.nook.app.todo.dao;
|
||||
|
||||
import co.nook.app.todo.service.TodoMapper;
|
||||
import co.nook.app.todo.service.TodoService;
|
||||
import co.nook.app.todo.vo.TodoVo;
|
||||
import co.nook.app.user.service.UserMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -13,65 +18,64 @@ import java.util.ArrayList;
|
||||
@Repository("todoDao")
|
||||
public class TodoDao implements TodoService{
|
||||
|
||||
PreparedStatement psmt;
|
||||
ResultSet rs;
|
||||
JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
public TodoDao(JdbcTemplate jdbcTemplate){
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
|
||||
final String SELECT_ALL = "SELECT * FROM userTodo where userno = ?";
|
||||
@Override
|
||||
public ArrayList<TodoVo> selectAll(Connection conn, int userNo){
|
||||
ArrayList<TodoVo> list = new ArrayList<TodoVo>();
|
||||
try{
|
||||
psmt = conn.prepareStatement(SELECT_ALL);
|
||||
psmt.setInt(1, userNo);
|
||||
rs = psmt.executeQuery();
|
||||
|
||||
|
||||
while(rs.next()){
|
||||
TodoVo vo = new TodoVo();
|
||||
vo.setuNo(rs.getInt("uNo"));
|
||||
vo.setuContent(rs.getString("uContent"));
|
||||
vo.setuCheck(rs.getString("uCheck"));
|
||||
vo.setuSub1(rs.getString("uSub1"));
|
||||
vo.setuSub2(rs.getString("uSub2"));
|
||||
list.add(vo);
|
||||
public ArrayList<TodoVo> selectAll(int userNo){
|
||||
return (ArrayList<TodoVo>)jdbcTemplate.query(SELECT_ALL, new TodoMapper(), userNo);
|
||||
}
|
||||
}catch(SQLException throwables){
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
final String SELECT_LAST = "SELECT * FROM userTodo where uNo = LASTVAL(seq_user_todo)";
|
||||
@Override
|
||||
public int insert(Connection conn, TodoVo vo){
|
||||
return 0;
|
||||
public TodoVo selectLast() throws SQLException{
|
||||
try {
|
||||
return jdbcTemplate.queryForObject(SELECT_LAST, new TodoMapper() );
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
// EmptyResultDataAccessException 예외 발생시 null 리턴
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
final String INSERT = "INSERT INTO userTodo (uNo, userno, uContent, uCheck, uSub1, uSub2) " +
|
||||
"values (NEXTVAL(seq_user_todo), ?, ?, ?, 0, ?)";
|
||||
@Override
|
||||
public int insert(TodoVo vo){
|
||||
int n = jdbcTemplate.update(INSERT,
|
||||
vo.getUserno(),
|
||||
vo.getuContent(),
|
||||
vo.getuCheck(),
|
||||
vo.getuSub2()
|
||||
);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
final String UPDATE = "UPDATE userTodo SET uContent = ?, uCheck = ?, uSub1 = ?, uSub2 = ? WHERE uNo = ?";
|
||||
@Override
|
||||
public int update(Connection conn, TodoVo vo){
|
||||
int result = 0;
|
||||
try{
|
||||
psmt = conn.prepareStatement(UPDATE);
|
||||
psmt.setString(1, vo.getuContent());
|
||||
psmt.setString(2, vo.getuCheck());
|
||||
psmt.setString(3, vo.getuSub1());
|
||||
psmt.setString(4, vo.getuSub2());
|
||||
psmt.setInt(5, vo.getuNo());
|
||||
public int update( TodoVo vo){
|
||||
System.out.println("변경 Userno : "+vo.getuNo());
|
||||
System.out.println("변경 Contetn : " +vo.getuContent());
|
||||
int n = jdbcTemplate.update(UPDATE,
|
||||
vo.getuContent(),
|
||||
vo.getuCheck(),
|
||||
vo.getuSub1(),
|
||||
vo.getuSub2(),
|
||||
vo.getuNo()
|
||||
);
|
||||
|
||||
|
||||
result = psmt.executeUpdate();
|
||||
}catch(SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
System.out.println("변경 : " +n);
|
||||
return n;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Connection conn, TodoVo vo){
|
||||
public int delete( TodoVo vo){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
22
src/main/java/co/nook/app/todo/service/TodoMapper.java
Normal file
22
src/main/java/co/nook/app/todo/service/TodoMapper.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package co.nook.app.todo.service;
|
||||
|
||||
import co.nook.app.todo.vo.TodoVo;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class TodoMapper implements RowMapper<TodoVo>{
|
||||
@Override
|
||||
public TodoVo mapRow(ResultSet rs, int rowNum) throws SQLException{
|
||||
TodoVo vo = new TodoVo();
|
||||
vo.setuNo(rs.getInt("uNo"));
|
||||
vo.setUserno(rs.getInt("userno"));
|
||||
vo.setuContent(rs.getString("uContent"));
|
||||
vo.setuCheck(rs.getString("uCheck"));
|
||||
vo.setuSub1(rs.getString("uSub1"));
|
||||
vo.setuSub2(rs.getString("uSub2"));
|
||||
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,13 @@ package co.nook.app.todo.service;
|
||||
import co.nook.app.todo.vo.TodoVo;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface TodoService{
|
||||
public ArrayList<TodoVo> selectAll(Connection conn, int userNo);
|
||||
public int insert(Connection conn, TodoVo vo);
|
||||
public int update(Connection conn, TodoVo vo);
|
||||
public int delete(Connection conn, TodoVo vo);
|
||||
public ArrayList<TodoVo> selectAll( int userNo ) throws SQLException;
|
||||
public TodoVo selectLast() throws SQLException;
|
||||
public int insert( TodoVo vo ) throws SQLException;
|
||||
public int update( TodoVo vo ) throws SQLException;
|
||||
public int delete( TodoVo vo ) throws SQLException;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Service("todoService")
|
||||
@@ -18,22 +19,27 @@ public class TodoServiceImpl implements TodoService{
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<TodoVo> selectAll(Connection conn, int userNo){
|
||||
return todoDao.selectAll(conn, userNo);
|
||||
public ArrayList<TodoVo> selectAll( int userNo){
|
||||
return todoDao.selectAll( userNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(Connection conn, TodoVo vo){
|
||||
return todoDao.insert(conn, vo);
|
||||
public TodoVo selectLast() throws SQLException{
|
||||
return todoDao.selectLast();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Connection conn, TodoVo vo){
|
||||
return todoDao.update(conn, vo);
|
||||
public int insert( TodoVo vo) {
|
||||
return todoDao.insert( vo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Connection conn, TodoVo vo){
|
||||
return todoDao.delete(conn, vo);
|
||||
public int update(TodoVo vo){
|
||||
return todoDao.update( vo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete( TodoVo vo){
|
||||
return todoDao.delete( vo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package co.nook.app.todo.web;
|
||||
|
||||
import co.nook.app.common.Dao;
|
||||
import co.nook.app.todo.dao.TodoDao;
|
||||
import co.nook.app.todo.service.TodoService;
|
||||
import co.nook.app.todo.vo.TodoVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -10,15 +8,14 @@ import org.springframework.ui.Model;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class TodoController{
|
||||
@@ -34,13 +31,12 @@ public class TodoController{
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/getTodoData.do")
|
||||
public HashMap<String, Object> getTodoData(HttpServletRequest request, Model model){
|
||||
public HashMap<String, Object> getTodoData(HttpServletRequest request, Model model) throws SQLException{
|
||||
HttpSession session = request.getSession();
|
||||
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
Connection conn = Dao.getConnection();
|
||||
int userNo = (int)session.getAttribute("userNo");
|
||||
ArrayList<TodoVo> list = todoService.selectAll(conn, userNo);
|
||||
ArrayList<TodoVo> list = todoService.selectAll( userNo);
|
||||
HashMap<Integer, Integer> boardMap = new HashMap<Integer, Integer>();
|
||||
int index = 1;
|
||||
for(TodoVo vo : list){
|
||||
@@ -51,7 +47,6 @@ public class TodoController{
|
||||
|
||||
session.setAttribute("todoMap", boardMap);
|
||||
|
||||
Dao.close(conn);
|
||||
|
||||
map.put("list", list);
|
||||
|
||||
@@ -62,7 +57,7 @@ public class TodoController{
|
||||
@RequestMapping(value = "/todoUpdate.do")
|
||||
public HashMap<String, Object> todoUpdate(HttpServletRequest request,
|
||||
@RequestBody HashMap<String, Object> map,
|
||||
Model model){
|
||||
Model model) throws SQLException{
|
||||
HashMap<String, Object> returnMap = new HashMap<String, Object>();
|
||||
HttpSession session =request.getSession();
|
||||
HashMap<Integer, Integer> boardMap = (HashMap<Integer, Integer>)session.getAttribute("todoMap");
|
||||
@@ -80,7 +75,6 @@ public class TodoController{
|
||||
sub2= o2.toString();
|
||||
}
|
||||
|
||||
Connection conn = Dao.getConnection();
|
||||
if(!(check.equals("true") || check.equals("false")))
|
||||
{
|
||||
returnMap.put("result", 0);
|
||||
@@ -92,18 +86,43 @@ public class TodoController{
|
||||
vo.setuSub1(sub1);
|
||||
vo.setuSub2(sub2);
|
||||
|
||||
int result = todoService.update(conn, vo);
|
||||
int result = todoService.update( vo);
|
||||
returnMap.put("result", result);
|
||||
}
|
||||
Dao.close(conn);
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/insertTodo.do")
|
||||
public HashMap<String, Object> todoUpdate( HttpServletRequest request, @RequestBody HashMap<String, Object> map){
|
||||
public HashMap<String, Object> insertTodo( HttpServletRequest request, @RequestBody HashMap<String, Object> map) throws SQLException{
|
||||
HashMap<String, Object> returnMap = new HashMap<String, Object>();
|
||||
int userno = (int)request.getSession().getAttribute("userNo");
|
||||
HttpSession session = request.getSession();
|
||||
HashMap<Integer, Integer> boardMap = (HashMap<Integer, Integer>)session.getAttribute("todoMap");
|
||||
|
||||
String content = (String)map.get("content");
|
||||
String sub2 = (String)map.get("sub2");
|
||||
String check = map.get("check").toString();
|
||||
String lno = (String)map.get("lineNo");
|
||||
System.out.println(lno);
|
||||
int lineNo = Integer.parseInt(lno);
|
||||
|
||||
TodoVo vo = new TodoVo();
|
||||
vo.setuContent(content);
|
||||
vo.setuSub2(sub2);
|
||||
vo.setuCheck(check);
|
||||
vo.setUserno(userno);
|
||||
|
||||
int result = todoService.insert(vo);
|
||||
|
||||
if( result != 0 ){
|
||||
vo = todoService.selectLast();
|
||||
boardMap.put(lineNo, vo.getuNo());
|
||||
returnMap.put("item", vo);
|
||||
returnMap.put("result", "true");
|
||||
}else{
|
||||
returnMap.put("result", "false");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package co.nook.app.user.dao;
|
||||
|
||||
import co.nook.app.common.Dao;
|
||||
import co.nook.app.user.service.UserMapper;
|
||||
import co.nook.app.user.service.UserService;
|
||||
import co.nook.app.user.vo.UserVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -13,70 +16,55 @@ import java.util.ArrayList;
|
||||
|
||||
@Repository("userDao")
|
||||
public class UserDao implements UserService{
|
||||
PreparedStatement psmt;
|
||||
ResultSet rs;
|
||||
|
||||
JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
public UserDao (JdbcTemplate jdbcTemplate){
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<UserVo> allSelect(Connection conn){
|
||||
public ArrayList<UserVo> allSelect(){
|
||||
return null;
|
||||
}
|
||||
|
||||
final String SELECT_BY_ID = "select * from user where id = ?";
|
||||
@Override
|
||||
public UserVo select(Connection conn, String id){
|
||||
|
||||
UserVo vo = null;
|
||||
public UserVo select( String id ){
|
||||
try {
|
||||
conn = Dao.getConnection();
|
||||
psmt = conn.prepareStatement(SELECT_BY_ID);
|
||||
psmt.setString(1, id);
|
||||
rs = psmt.executeQuery();
|
||||
|
||||
if(rs.next()){
|
||||
vo = new UserVo();
|
||||
vo.setUserNo(rs.getInt("userno"));
|
||||
vo.setId(rs.getString("id"));
|
||||
vo.setPassword(rs.getString("password"));
|
||||
vo.setSalt(rs.getString("salt"));
|
||||
return jdbcTemplate.queryForObject(SELECT_BY_ID, new UserMapper(), id );
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
// EmptyResultDataAccessException 예외 발생시 null 리턴
|
||||
return null;
|
||||
}
|
||||
|
||||
}catch(SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVo select(Connection conn, int userNo){
|
||||
public UserVo select( int userNo){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
final String INSERT = "INSERT INTO user (userno, id, password, salt) VALUES ( NEXTVAL(seq_user), ?, ?, ?)";
|
||||
@Override
|
||||
public int insert(Connection conn, UserVo vo){
|
||||
int result = 0;
|
||||
try{
|
||||
psmt = conn.prepareStatement(INSERT);
|
||||
psmt.setString(1, vo.getId());
|
||||
psmt.setString(2, vo.getPassword());
|
||||
psmt.setString(3, vo.getSalt());
|
||||
result = psmt.executeUpdate();
|
||||
}catch(SQLException throwables){
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
public int insert( UserVo vo){
|
||||
int n =jdbcTemplate.update(INSERT,
|
||||
vo.getId(),
|
||||
vo.getPassword(),
|
||||
vo.getSalt()
|
||||
);
|
||||
return n;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Connection conn, UserVo vo){
|
||||
public int update( UserVo vo){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Connection conn, UserVo vo){
|
||||
public int delete( UserVo vo){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
20
src/main/java/co/nook/app/user/service/UserMapper.java
Normal file
20
src/main/java/co/nook/app/user/service/UserMapper.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package co.nook.app.user.service;
|
||||
|
||||
import co.nook.app.user.vo.UserVo;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class UserMapper implements RowMapper<UserVo>{
|
||||
@Override
|
||||
public UserVo mapRow(ResultSet rs, int rowNum) throws SQLException{
|
||||
UserVo vo = new UserVo();
|
||||
vo.setId(rs.getString("id"));
|
||||
vo.setUserNo(rs.getInt("userno"));
|
||||
vo.setPassword(rs.getString("password"));
|
||||
vo.setSalt(rs.getString("salt"));
|
||||
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,14 @@ package co.nook.app.user.service;
|
||||
import co.nook.app.user.vo.UserVo;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface UserService{
|
||||
public ArrayList<UserVo> allSelect(Connection conn);
|
||||
public UserVo select(Connection conn, String id);
|
||||
public UserVo select(Connection conn, int userNo);
|
||||
public int insert(Connection conn, UserVo vo);
|
||||
public int update(Connection conn, UserVo vo);
|
||||
public int delete(Connection conn, UserVo vo);
|
||||
public ArrayList<UserVo> allSelect() throws SQLException;
|
||||
public UserVo select(String id) throws SQLException;
|
||||
public UserVo select( int userNo) throws SQLException;
|
||||
public int insert( UserVo vo ) throws SQLException;
|
||||
public int update( UserVo vo ) throws SQLException;
|
||||
public int delete( UserVo vo ) throws SQLException;
|
||||
}
|
||||
|
||||
@@ -20,32 +20,32 @@ public class UserServiceImpl implements UserService{
|
||||
|
||||
|
||||
@Override
|
||||
public ArrayList<UserVo> allSelect(Connection conn){
|
||||
return userDao.allSelect(conn);
|
||||
public ArrayList<UserVo> allSelect(){
|
||||
return userDao.allSelect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVo select(Connection conn, String id){
|
||||
return userDao.select(conn, id);
|
||||
public UserVo select( String id){
|
||||
return userDao.select( id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVo select(Connection conn, int userNo){
|
||||
return userDao.select(conn, userNo);
|
||||
public UserVo select( int userNo){
|
||||
return userDao.select( userNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(Connection conn, UserVo vo){
|
||||
return userDao.insert(conn, vo);
|
||||
public int insert( UserVo vo){
|
||||
return userDao.insert( vo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Connection conn, UserVo vo){
|
||||
return userDao.update(conn, vo);
|
||||
public int update( UserVo vo){
|
||||
return userDao.update( vo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Connection conn, UserVo vo){
|
||||
return userDao.delete(conn, vo);
|
||||
public int delete( UserVo vo){
|
||||
return userDao.delete( vo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package co.nook.app.user.web;
|
||||
|
||||
import co.nook.app.HomeController;
|
||||
import co.nook.app.common.Dao;
|
||||
import co.nook.app.common.SHAEncrypt;
|
||||
import co.nook.app.user.service.UserService;
|
||||
import co.nook.app.user.vo.UserVo;
|
||||
@@ -12,9 +11,8 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.sql.Connection;
|
||||
import java.util.HashMap;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@Controller
|
||||
public class UserController{
|
||||
@@ -30,19 +28,19 @@ public class UserController{
|
||||
|
||||
|
||||
@RequestMapping(value = "/join.do", method = RequestMethod.POST)
|
||||
public String joinProcess(@RequestParam String id, @RequestParam String pw, Model model){
|
||||
Connection conn = Dao.getConnection();
|
||||
public String joinProcess(UserVo userVo, Model model) throws SQLException{
|
||||
|
||||
UserVo vo = new UserVo();
|
||||
|
||||
String salt = SHAEncrypt.generateSalt();
|
||||
String encPw= SHAEncrypt.getEncrypt(pw, salt);
|
||||
String encPw= SHAEncrypt.getEncrypt(userVo.getPassword(), salt);
|
||||
|
||||
vo.setId(id);
|
||||
vo.setId(userVo.getId());
|
||||
vo.setPassword(encPw);
|
||||
vo.setSalt(salt);
|
||||
|
||||
int result = userService.insert(conn, vo );
|
||||
Dao.close(conn);
|
||||
int result = userService.insert( vo );
|
||||
|
||||
String view = "login/login_form";
|
||||
if(result == 0){
|
||||
view = "join/join";
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package co.nook.app.user.web;
|
||||
|
||||
import co.nook.app.common.Dao;
|
||||
import co.nook.app.common.SHAEncrypt;
|
||||
import co.nook.app.user.service.UserService;
|
||||
import co.nook.app.user.vo.UserVo;
|
||||
@@ -10,6 +9,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
|
||||
@RestController
|
||||
@@ -25,13 +25,13 @@ public class UserRestController{
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping( value = "/userCheck.do", method= RequestMethod.POST)
|
||||
public HashMap<String, Object> userCheck(@RequestBody HashMap<String, Object> map, Model model ){
|
||||
public HashMap<String, Object> userCheck(@RequestBody UserVo userVo, Model model ) throws SQLException{
|
||||
HashMap<String, Object> responseMap = new HashMap<String, Object>();
|
||||
Connection conn = Dao.getConnection();
|
||||
String id = (String)map.get("id");
|
||||
|
||||
UserVo vo = userService.select(conn, id);
|
||||
Dao.close(conn);
|
||||
String id = userVo.getId();
|
||||
|
||||
UserVo vo = userService.select(id);
|
||||
|
||||
if( vo == null ){
|
||||
responseMap.put("result", "false");
|
||||
}else{
|
||||
@@ -43,19 +43,16 @@ public class UserRestController{
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/loginCheck.do", method = RequestMethod.POST)
|
||||
public HashMap<String, Object> loginCheck(@RequestBody HashMap<String, Object> map, HttpServletRequest request, Model model){
|
||||
public HashMap<String, Object> loginCheck(@RequestBody UserVo userVo, HttpServletRequest request, Model model) throws SQLException{
|
||||
HashMap<String, Object> responseMap = new HashMap<String, Object>();
|
||||
String id = (String)map.get("id");
|
||||
String pw = (String)map.get("pw");
|
||||
Connection conn = Dao.getConnection();
|
||||
UserVo vo = userService.select(conn, id);
|
||||
Dao.close(conn);
|
||||
|
||||
UserVo vo = userService.select(userVo.getId());
|
||||
if(vo == null){
|
||||
responseMap.put("result", "false");
|
||||
return responseMap;
|
||||
}
|
||||
|
||||
String encPw = SHAEncrypt.getEncrypt(pw, vo.getSalt());
|
||||
String encPw = SHAEncrypt.getEncrypt(userVo.getPassword(), vo.getSalt());
|
||||
|
||||
if( vo.getPassword().equals(encPw)){
|
||||
responseMap.put("result", "true");
|
||||
|
||||
@@ -6,6 +6,19 @@
|
||||
|
||||
<!-- Root Context: defines shared resources visible to all other web components -->
|
||||
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
|
||||
destroy-method="close">
|
||||
<property name="driverClassName" value="org.mariadb.jdbc.Driver" />
|
||||
<property name="url" value="jdbc:mariadb://coon.myds.me:3307/NookSearch" />
|
||||
<property name="username" value="minechost" />
|
||||
<property name="password" value="Ahstmxj5zos1!" />
|
||||
|
||||
</bean>
|
||||
|
||||
<!-- Spring JDBC 설정 -->
|
||||
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
$(document).ready(function(){
|
||||
|
||||
$("#pwCheck").change(function(){
|
||||
if($("#pwCheck").val() != $("#pw").val()){
|
||||
if($("#pwCheck").val() != $("#password").val()){
|
||||
$("#pwCheck").focus();
|
||||
$("#pwCheckHelp").show();
|
||||
}else{
|
||||
@@ -38,7 +38,7 @@
|
||||
json.id = str;
|
||||
var parsed = JSON.stringify(json);
|
||||
$("#btn_join").off();
|
||||
if($("#pwCheck").val() == $("#pw").val()) {
|
||||
if($("#pwCheck").val() == $("#password").val()) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "userCheck.do",
|
||||
@@ -59,7 +59,7 @@
|
||||
}
|
||||
});
|
||||
}else{
|
||||
if($("#pwCheck").val() != $("#pw").val()){
|
||||
if($("#pwCheck").val() != $("#password").val()){
|
||||
$("#pwCheck").focus();
|
||||
$("#pwCheckHelp").show();
|
||||
}else{
|
||||
@@ -83,7 +83,7 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>비밀번호</label>
|
||||
<input type="password" id="pw" name="pw" class="form-control" placeholder="Password" required>
|
||||
<input type="password" id="password" name="password" class="form-control" placeholder="Password" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>비밀번호 확인</label>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
function login(){
|
||||
let json = {};
|
||||
json.id = $("#id").val();
|
||||
json.pw = $("#pw").val();
|
||||
json.password = $("#password").val();
|
||||
let parsed = JSON.stringify(json);
|
||||
|
||||
console.log(parsed);
|
||||
@@ -63,8 +63,8 @@
|
||||
<label for="id">ID : </label>
|
||||
<input class="form-control" type="text" id="id" name="id" aria-describedby="idHelp">
|
||||
<small id="idHelp" class="form-text text-muted">아이디를 입력해주세요</small>
|
||||
<label for="pw">PW : </label>
|
||||
<input class="form-control" type="password" id="pw" name="pw" aria-describedby="pwHelp">
|
||||
<label for="password">PW : </label>
|
||||
<input class="form-control" type="password" id="password" name="password" aria-describedby="pwHelp">
|
||||
<small id="pwHelp" class="form-text text-muted">비밀번호를 입력해주세요</small>
|
||||
<button id="btn_login" class="btn btn-primary" type="button">로그인</button>
|
||||
<button id="btn_join" class="btn btn-primary" type="button">회원가입</button>
|
||||
|
||||
@@ -57,12 +57,11 @@
|
||||
function removeDel($input){
|
||||
$input.unwrap("del");
|
||||
}
|
||||
function showHideCheck($button, bool){
|
||||
let $img = $button.find("i");
|
||||
if(!bool){
|
||||
|
||||
|
||||
|
||||
function toggleCheck($button){
|
||||
let $img = $button.find("svg");
|
||||
if($img.hasClass("leafCheck")){
|
||||
$img.removeClass("leafCheck");
|
||||
$img.hasClass("leafHide");
|
||||
$img.hide();
|
||||
@@ -71,6 +70,24 @@
|
||||
$img.removeClass("leafHide");
|
||||
$img.addClass("leafCheck");
|
||||
$img.show();
|
||||
console.log("leaf Show");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function toggleCheck($button){
|
||||
let $img = $button.find("svg");
|
||||
if($img.hasClass("leafCheck")){
|
||||
console.log("leaf HIde");
|
||||
$img.removeClass("leafCheck");
|
||||
$img.hasClass("leafHide");
|
||||
$img.hide();
|
||||
|
||||
}else{
|
||||
$img.removeClass("leafHide");
|
||||
$img.addClass("leafCheck");
|
||||
$img.show();
|
||||
console.log("leaf Show");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,18 +331,20 @@
|
||||
$addTodoTr = $("<tr>");
|
||||
$tbodyTodo.append($addTodoTr);
|
||||
//숫자 부분
|
||||
|
||||
++count;
|
||||
let $td = $("<td>");
|
||||
$addTodoTr.append($td);
|
||||
$td.html((count+1).toString());
|
||||
$td.html(count.toString());
|
||||
|
||||
//체크 박스 부분
|
||||
$td = $("<td>");
|
||||
$addTodoTr.append($td);
|
||||
let $btnLeaf = $("<ct:button_leaf />");
|
||||
showHideCheck($btnLeaf, false);
|
||||
$btnLeaf.on("click", { button : $btnLeaf } , toggleCheckByEvent);
|
||||
|
||||
$td.append($btnLeaf);
|
||||
|
||||
//content 부분
|
||||
$td = $("<td>");
|
||||
$addTodoTr.append($td);
|
||||
@@ -355,17 +374,40 @@
|
||||
$btnSave.on("click", insertLine);
|
||||
}
|
||||
function insertLine() {
|
||||
let $tr = $(this).parents("tr");
|
||||
let content = $(this).parent().parent().find("input[name='ipTodo']").val();
|
||||
let sub2 = $(this).parent().parent().find("input[name='ipMax']").val();
|
||||
let check = $(this).parents("tr").find("svg").hasClass("leafCheck");
|
||||
let check = $tr.find("svg").hasClass("leafCheck");
|
||||
let lineNo = $tr.find("td:first").html();
|
||||
|
||||
|
||||
console.log("content : "+content);
|
||||
console.log("sub2 : " + sub2);
|
||||
console.log("check : " + check);
|
||||
let json= {};
|
||||
json.content= content;
|
||||
json.sub2 = sub2;
|
||||
json.check = check;
|
||||
json.lineNo = lineNo;
|
||||
|
||||
let parsed = JSON.stringify(json);
|
||||
//controller에 추가
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "insertTodo.do",
|
||||
data: parsed,
|
||||
datatype: "json",
|
||||
contentType: "application/json",
|
||||
success: function (data) {
|
||||
if(data.result == "true"){
|
||||
$tr.remove();
|
||||
alert("입력 성공");
|
||||
AddTr(parseInt(lineNo)-1, data.item);
|
||||
}else{
|
||||
alert("입력 실패");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
Reference in New Issue
Block a user