달력

22025  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.lat.beans;
 
public class Investment {
    private String id;
    private long project_num;
    private long reward_num;
    private long total;
    private String addr;
    private String card_num;
    private String card_exdate;
    private String card_pwd;
    private String card_birth;
    
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public long getProject_num() {
        return project_num;
    }
    public void setProject_num(long project_num) {
        this.project_num = project_num;
    }
    public long getReward_num() {
        return reward_num;
    }
    public void setReward_num(long reward_num) {
        this.reward_num = reward_num;
    }
    public long getTotal() {
        return total;
    }
    public void setTotal(long total) {
        this.total = total;
    }
    public String getAddr() {
        return addr;
    }
    public void setAddr(String addr) {
        this.addr = addr;
    }
    public String getCard_num() {
        return card_num;
    }
    public void setCard_num(String card_num) {
        this.card_num = card_num;
    }
    public String getCard_exdate() {
        return card_exdate;
    }
    public void setCard_exdate(String card_exdate) {
        this.card_exdate = card_exdate;
    }
    public String getCard_pwd() {
        return card_pwd;
    }
    public void setCard_pwd(String card_pwd) {
        this.card_pwd = card_pwd;
    }
    public String getCard_birth() {
        return card_birth;
    }
    public void setCard_birth(String card_birth) {
        this.card_birth = card_birth;
    }
    
}
 
cs

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package com.lat.controller;
 
import java.util.List;
 
import javax.servlet.http.HttpServletRequest;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
 
import com.lat.beans.Investment;
import com.lat.dao.InvestmentDAOService;
 
@Controller
public class InvestmentController {
    @Autowired
    private InvestmentDAOService investmentDAOService;
    
    @RequestMapping(value="/investment/listInvestment")
    public ModelAndView list(HttpServletRequest request){
        List<Investment> list=investmentDAOService.listInvestment();
        return new ModelAndView("investment/listInvestment","list",list);
    }
    
    @RequestMapping(value="/investment/insertInvestment")
    public ModelAndView insertInvestment(HttpServletRequest request){
        return new ModelAndView("investment/insertInvestment");
    }
    
    @RequestMapping(value="/investment/insert", method=RequestMethod.POST)
    public String listInvestment(HttpServletRequest request){
        String id=request.getParameter("id");
        String project_numVal=request.getParameter("project_num");
        long project_num=0;
        if(project_numVal!=null) project_num=Long.parseLong(project_numVal);
        String reward_numVal=request.getParameter("reward_num");
        long reward_num=0;
        if(reward_numVal!=null) reward_num=Long.parseLong(reward_numVal);
        String totalVal=request.getParameter("total");
        long total=0;
        if(totalVal!=null) total=Long.parseLong(totalVal);
        String addr=request.getParameter("addr");
        String card_num=request.getParameter("card_num");
        String card_exdate=request.getParameter("card_exdate");
        String card_pwd=request.getParameter("card_pwd");
        String card_birth=request.getParameter("card_birth");
        Investment investment=new Investment();
        investment.setId(id);
        investment.setProject_num(project_num);
        investment.setReward_num(reward_num);
        investment.setTotal(total);
        investment.setAddr(addr);
        investment.setCard_num(card_num);
        investment.setCard_exdate(card_exdate);
        investment.setCard_pwd(card_pwd);
        investment.setCard_birth(card_birth);
        investmentDAOService.insertInvestment(investment);
        return "redirect:listInvestment";
    }
    
    @RequestMapping(value="/investment/detailInvestment", method=RequestMethod.GET)
    public ModelAndView detailInvestment(HttpServletRequest request){
        String id=request.getParameter("id");
        String project_numVal=request.getParameter("project_num");
        long project_num=0;
        if(project_numVal!=null) project_num=Long.parseLong(project_numVal);
        String reward_numVal=request.getParameter("reward_num");
        long reward_num=0;
        if(reward_numVal!=null) reward_num=Long.parseLong(reward_numVal);
        Investment investment = new Investment();
        investment.setId(id);
        investment.setProject_num(project_num);
        investment.setReward_num(reward_num);
        investment=investmentDAOService.detailInvestment(investment);
        return new ModelAndView("investment/detailInvestment","investment",investment);
    }
        
    @RequestMapping(value="/investment/update", method=RequestMethod.POST)
    public String update(HttpServletRequest request){
        String id=request.getParameter("id");
        String project_numVal=request.getParameter("project_num");
        long project_num=0;
        if(project_numVal!=null) project_num=Long.parseLong(project_numVal);
        String reward_numVal=request.getParameter("reward_num");
        long reward_num=0;
        if(reward_numVal!=null) reward_num=Long.parseLong(reward_numVal);
        String totalVal=request.getParameter("total");
        long total=0;
        if(totalVal!=null) total=Long.parseLong(totalVal);
        String addr=request.getParameter("addr");
        String card_num=request.getParameter("card_num");
        String card_exdate=request.getParameter("card_exdate");
        String card_pwd=request.getParameter("card_pwd");
        String card_birth=request.getParameter("card_birth");
        Investment investment=new Investment();
        investment.setId(id);
        investment.setProject_num(project_num);
        investment.setReward_num(reward_num);
        investment.setTotal(total);
        investment.setAddr(addr);
        investment.setCard_num(card_num);
        investment.setCard_exdate(card_exdate);
        investment.setCard_pwd(card_pwd);
        investment.setCard_birth(card_birth);
        investmentDAOService.updateInvestment(investment);
        return "redirect:listInvestment";
    }
 
    @RequestMapping(value="/investment/updateInvestment")
    public ModelAndView updateInvestment(HttpServletRequest request){
        String id=request.getParameter("id");
        String project_numVal=request.getParameter("project_num");
        long project_num=0;
        if(project_numVal!=null) project_num=Long.parseLong(project_numVal);
        String reward_numVal=request.getParameter("reward_num");
        long reward_num=0;
        if(reward_numVal!=null) reward_num=Long.parseLong(reward_numVal);
        Investment investment = new Investment();
        investment.setId(id);
        investment.setProject_num(project_num);
        investment.setReward_num(reward_num);
        Investment investmentRlt=investmentDAOService.detailInvestment(investment);
        ModelAndView view=new ModelAndView("investment/insertInvestment");
        view.addObject("investment",investmentRlt);
        return view;
    }
    
    @RequestMapping(value="/investment/delete", method=RequestMethod.POST)
    public String delete(HttpServletRequest request){
        String id=request.getParameter("id");
        String project_numVal=request.getParameter("project_num");
        long project_num=0;
        if(project_numVal!=null) project_num=Long.parseLong(project_numVal);
        String reward_numVal=request.getParameter("reward_num");
        long reward_num=0;
        if(reward_numVal!=null) reward_num=Long.parseLong(reward_numVal);
        Investment investment=new Investment();
        investment.setId(id);
        investment.setProject_num(project_num);
        investment.setReward_num(reward_num);
        investmentDAOService.deleteInvestment(investment);
        return "redirect:listInvestment";
    }
}
 
cs

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
package com.lat.dao;
 
import java.util.List;
 
import com.lat.beans.Investment;
 
public interface InvestmentDAO {
    public List<Investment> listInvestment();
    public void insertInvestment(Investment investment);
    public Investment detailInvestment(Investment investment);
    public void updateInvestment(Investment investment);
    public void deleteInvestment(Investment investment);    
}
 
cs

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.lat.dao;
 
import java.util.List;
 
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
 
import com.lat.beans.Investment;
 
@Repository
public class InvestmentDAOService implements InvestmentDAO {
 
        @Autowired
        private SqlSession sqlSession;
 
        @Override
        public void insertInvestment(Investment investment) {
            // TODO Auto-generated method stub
            InvestmentMapper investmentMapper=sqlSession.getMapper(InvestmentMapper.class);
            investmentMapper.insertInvestment(investment);
        }
        @Override
        public List<Investment> listInvestment() {
            // TODO Auto-generated method stub
            InvestmentMapper investmentMapper=sqlSession.getMapper(InvestmentMapper.class);
            return investmentMapper.listInvestment();
        }
        @Override
        public Investment detailInvestment(Investment investment) {
            // TODO Auto-generated method stub
            InvestmentMapper investmentMapper=sqlSession.getMapper(InvestmentMapper.class);
            return investmentMapper.detailInvestment(investment);
        }
 
        @Override
        public void updateInvestment(Investment investment) {
            // TODO Auto-generated method stub
            InvestmentMapper investmentMapper=sqlSession.getMapper(InvestmentMapper.class);
            investmentMapper.updateInvestment(investment);
            
        }
 
        @Override
        public void deleteInvestment(Investment investment) {
            // TODO Auto-generated method stub
            InvestmentMapper investmentMapper=sqlSession.getMapper(InvestmentMapper.class);
            investmentMapper.deleteInvestment(investment);
            
        }
        
}
 
cs

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
package com.lat.dao;
 
import java.util.List;
 
import com.lat.beans.Investment;
 
public interface InvestmentMapper {
    public List<Investment> listInvestment();
    public void insertInvestment(Investment investment);
    public Investment detailInvestment(Investment investment);
    public void updateInvestment(Investment investment);
    public void deleteInvestment(Investment investment);
}
 
cs

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0 // EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lat.dao.InvestmentMapper">
    <resultMap type="Investment" id="investmentMap">
        <result property="id" column="ID"/>
        <result property="project_num" column="PROJECT_NUM"/>
        <result property="reward_num" column="REWARD_NUM"/>
        <result property="total" column="TOTAL"/>
        <result property="addr" column="ADDR"/>
        <result property="card_num" column="CARD_NUM"/>
        <result property="card_exdate" column="CARD_EXDATE"/>
        <result property="card_pwd" column="CARD_PWD"/>
        <result property="card_birth" column="CARD_BIRTH"/>
    </resultMap>
    
    <select id="listInvestment" resultMap="investmentMap">
        select * from investment
    </select>
    
    <insert id="insertInvestment" parameterType="com.lat.beans.Investment">
        insert into investment(id, project_num, reward_num, total, addr, card_num, card_exdate, card_pwd, card_birth)
        values(#{id}, #{project_num}, #{reward_num}, #{total}, #{addr}, #{card_num}, #{card_exdate}, #{card_pwd}, #{card_birth})
    </insert>
    
    <select id="detailInvestment" parameterType="com.lat.beans.Investment" resultType="com.lat.beans.Investment">
        select * from investment
         where id=#{id}
           and project_num=#{project_num}
           and reward_num=#{reward_num}
    </select>
    
    <update id="updateInvestment" parameterType="com.lat.beans.Investment">
        update investment set
            total=#{total}
           ,addr=#{addr}
           ,card_num=#{card_num}
           ,card_exdate=#{card_exdate}
           ,card_pwd=#{card_pwd}
           ,card_birth=#{card_birth}
        where id=#{id}
          and project_num=#{project_num}
          and reward_num=#{reward_num}
    </update>
    
    <delete id="deleteInvestment" parameterType="com.lat.beans.Investment">
        delete from investment
         where id=#{id}
           and project_num=#{project_num}
           and reward_num=#{reward_num}
    </delete>
</mapper>
cs

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%@ page import="com.lat.beans.Investment" %>
<%@ page import="java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>detailInvestment</title>
</head>
<body>
Investment상세보기
<%
    Investment investment=(Investment)request.getAttribute("investment");
    if(investment==null) investment=new Investment();
%>
<table border="1">
    <tr>
        <th>id</th>
        <th>project_num</th>
        <th>reward_num</th>
        <th>total</th>
        <th>addr</th>
        <th>card_num</th>
        <th>card_exdate</th>
        <th>card_pwd</th>
        <th>card_birth</th>
    </tr>
    <tr>
        <td><%=investment.getId() %></td>
        <td><%=investment.getProject_num() %></td>
        <td><%=investment.getReward_num() %></td>
        <td><%=investment.getTotal() %></td>
        <td><%=investment.getAddr() %></td>
        <td><%=investment.getCard_num() %></td>
        <td><%=investment.getCard_exdate() %></td>
        <td><%=investment.getCard_pwd() %></td>
        <td><%=investment.getCard_birth() %></td>
    </tr>
    <tr>
        <td colspan="9">
            <form method="post" action="updateInvestment">
                <input type="hidden" name="id" value="<%=investment.getId() %>"/>
                <input type="hidden" name="project_num" value="<%=investment.getProject_num() %>"/>
                <input type="hidden" name="reward_num" value="<%=investment.getReward_num() %>"/>
                <input type="submit" value="수정"/>
            </form>    
            <form method="post" action="delete">
                <input type="hidden" name="id" value="<%=investment.getId() %>"/>
                <input type="hidden" name="project_num" value="<%=investment.getProject_num() %>"/>
                <input type="hidden" name="reward_num" value="<%=investment.getReward_num() %>"/>
                <input type="submit" value="삭제"/>
            </form>    
        </td>
    </tr>
</table>
</body>
</html>
 
cs

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%@ page import="com.lat.beans.Investment" %>
<%@ page import="java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>insertInvestment</title>
</head>
<body>
<%
    Investment investment=(Investment)request.getAttribute("investment");
    if(investment==null) investment=new Investment();
%>
<form method="post"
<% if(investment.getId()==null){ %>
action="insert"
<% }else{ %>
action="update"
<% } %>
>
    <table border="1">
        <tr>
            <td>Id</td>
            <td colspan="2">
            <% if(investment.getId()==null){ %>
            <input type="text" name="id" value="<%=investment.getId() %>"/>
            <% }else{ %>
            <input type="hidden" name="id" value="<%=investment.getId() %>"/>
                <%=investment.getId() %>
            <% } %>
            </td>
        </tr>
        <tr>
            <td>Project_num</td>
            <td colspan="2">
            <% if(investment.getProject_num()==0){ %>
            <input type="text" name="project_num" value="<%=investment.getProject_num() %>"/>
            <% }else{ %>
            <input type="hidden" name="project_num" value="<%=investment.getProject_num() %>"/>
                <%=investment.getProject_num() %>
            <% } %>
            </td>
        </tr>
        <tr>
            <td>Reward_num</td>
            <td colspan="2">
            <% if(investment.getReward_num()==0){ %>
            <input type="text" name="reward_num" value="<%=investment.getReward_num() %>"/>
            <% }else{ %>
            <input type="hidden" name="reward_num" value="<%=investment.getReward_num() %>"/>
                <%=investment.getReward_num() %>
            <% } %>
            </td>
        </tr>
        <tr>
            <td>total</td>
            <td colspan="2"><input type="text" name="total" value="<%=investment.getTotal()==0?"":investment.getTotal() %>"/></td>
        </tr>
        <tr>
            <td>addr</td>
            <td colspan="2"><input type="text" name="addr" value="<%=investment.getAddr()==null?"":investment.getAddr() %>"/></td>
        </tr>
        <tr>
            <td>card_num</td>
            <td colspan="2"><input type="text" name="card_num" value="<%=investment.getCard_num()==null?"":investment.getCard_num() %>"/></td>
        </tr>
        <tr>
            <td>card_exdate</td>
            <td colspan="2"><input type="text" name="card_exdate" value="<%=investment.getCard_exdate()==null?"":investment.getCard_exdate() %>"/></td>
        </tr>
        <tr>
            <td>card_pwd</td>
            <td colspan="2"><input type="text" name="card_pwd" value="<%=investment.getCard_pwd()==null?"":investment.getCard_pwd() %>"/></td>
        </tr>
        <tr>
            <td>card_birth</td>
            <td colspan="2"><input type="text" name="card_birth" value="<%=investment.getCard_birth()==null?"":investment.getCard_birth() %>"/></td>
        </tr>
        <tr>
            <td>
            <%if(investment.getId()==null){ %>
                <input type="submit" value="등록"/>
            <%}else{ %>
                <input type="submit" value="수정"/>
            <%} %>
                <input type="reset" value="취소"/>
            </td>
            <td>
                <a href="listInvestment">
                    <input type="button" value="뒤로가기"/>
                </a>
            </td>
        </tr>
    </table>
</form>
</body>
</html>
cs

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>listInvestment</title>
</head>
<body>
    <table border="1">
        <tr>
            <th>id</th>
            <th>project_num</th>
            <th>reward_num</th>
            <th>total</th>
            <th>addr</th>
            <th>card_num</th>
            <th>card_exdate</th>
            <th>card_pwd</th>
            <th>card_birth</th>
        </tr>
    <c:forEach var="investment" items="${list}">
        <tr>
            <td>
                <a href="detailInvestment?id=${investment.id}&project_num=${investment.project_num}&reward_num=${investment.reward_num}">
                    ${investment.id}
                </a>
            </td>
            <td>${investment.project_num}</td>
            <td>${investment.reward_num}</td>
            <td>${investment.total}</td>
            <td>${investment.addr}</td>
            <td>${investment.card_num}</td>
            <td>${investment.card_exdate}</td>
            <td>${investment.card_pwd}</td>
            <td>${investment.card_birth}</td>
        </tr>
    </c:forEach>
        <tr>
            <td colspan="9">
                <a href="insertInvestment">
                    <input type="button" value="insert"/>
                </a>
            </td>
        </tr>
    </table>
</body>
</html>
cs

'Legend 개발자 > Spring' 카테고리의 다른 글

CRUD-example(Projectr_AttachFile)  (0) 2017.11.03
CRUD-example(Member_AttachFile)  (0) 2017.11.03
CRUD-example(Exam_AttachFile)  (0) 2017.11.03
CRUD-example(reward)  (0) 2017.11.02
CRUD  (0) 2017.11.02
Posted by 전설의아이
|