forked from maxliaops/Java_Web_Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStuUserAction.java
More file actions
177 lines (170 loc) · 5.29 KB
/
StuUserAction.java
File metadata and controls
177 lines (170 loc) · 5.29 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.jwy.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
import org.apache.struts.actions.DispatchAction;
import com.jwy.dao.ICourseDao;
import com.jwy.dao.ISpecialtyDao;
import com.jwy.dao.IStuUserDao;
import com.jwy.dto.Course;
import com.jwy.dto.Specialty;
import com.jwy.dto.StuUser;
/**
* MyEclipse Struts
* Creation date: 05-12-2009
*
* XDoclet definition:
* @struts.action path="/stuInfo" name="stuInfoForm" input="/stu/stuInfo.jsp" scope="request" validate="true"
*/
public class StuUserAction extends DispatchAction {
private IStuUserDao stuUserDao;
private ICourseDao courseDao;
private ISpecialtyDao specialtyDao;
/**
* @param stuUserDao the stuUserDao to set
*/
public void setStuUserDao(IStuUserDao stuUserDao) {
this.stuUserDao = stuUserDao;
}
/**
* @param courseDao the courseDao to set
*/
public void setCourseDao(ICourseDao courseDao) {
this.courseDao = courseDao;
}
/**
* @param specialtyDao the specialtyDao to set
*/
public void setSpecialtyDao(ISpecialtyDao specialtyDao) {
this.specialtyDao = specialtyDao;
}
/**
* 学生添加基础信息
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward insert(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DynaActionForm stu = (DynaActionForm) form;
StuUser user = new StuUser();
user.setId((Integer)request.getSession().getAttribute("id"));
user.setStuName(stu.getString("stuName"));
user.setStuNo(stu.getString("stuNo"));
user.setSpecialtyId(Integer.valueOf(stu.getString("specialtyId")));
user.setStuSex(stu.getString("stuSex"));
user.setBirthday(stu.getString("birthday"));
user.setHomeAddr(stu.getString("homeAddr"));
user.setTel(stu.getString("tel"));
user.setAddr(stu.getString("addr"));
stuUserDao.insert(user);
Specialty specialty = specialtyDao.findById(user.getSpecialtyId());
request.setAttribute("stuUser", user);
request.setAttribute("specialty", specialty);
return mapping.findForward("welcome");
}
/**
* 进入学生模块首页面
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward welcome(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
Integer id = (Integer) request.getSession().getAttribute("id");
StuUser stuUser = stuUserDao.findById(id);
Specialty specialty = specialtyDao.findById(stuUser.getSpecialtyId());
request.setAttribute("stuUser", stuUser);
request.setAttribute("specialty", specialty);
return mapping.findForward("welcome");
}
/**
* 学生退出系统
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward exit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
request.getSession().invalidate();
return mapping.findForward("exit");
}
/**
* 学生查询已选课程
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward selected(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
Integer id = (Integer) request.getSession().getAttribute("id");
List<Object[]> list = stuUserDao.findSelected(id);
request.setAttribute("list", list);
return mapping.findForward("selected");
}
/**
* 学生查询可选课程
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward select(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
Integer id = (Integer) request.getSession().getAttribute("id");
List<Object[]> list = stuUserDao.findSelect(id);
request.setAttribute("list", list);
return mapping.findForward("select");
}
/**
* 学生选课操作
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward selectting(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
Integer id = (Integer) request.getSession().getAttribute("id");
String[] courseIds = request.getParameterValues("courseId");
if(courseIds!=null){
stuUserDao.insertSC(courseIds,id);
}
return select(mapping, form, request, response);
}
/**
* 查询课程详细信息
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward courseInfo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
Integer id = Integer.valueOf(request.getParameter("id"));
String path = request.getParameter("path");
Course course = courseDao.findByID(id);
request.setAttribute("course", course);
request.setAttribute("path", path);
return mapping.findForward("courseInfo");
}
}