📄 setsurveyaction.java
字号:
surveyChild.setSurveyOptionId(Integer.valueOf((String)req.getParameter("surveyOptionId")));
getSetSurveyChild().updateSurveyChild(surveyChild);
//获取已有的调查子项目
List listSurveyChildOptions = getSetSurveyChild().querySurveyChild(surveyChild.getSurveyOptionId());
//将已有的调查名称传递给页面
model.put("listSurveyChildOptions", listSurveyChildOptions);
//存放消息
model.put("msg", getSetSurveyChild().getMsg());
try {
model.put("surveyOptionName", new String(((String)req.getParameter("surveyOptionName")).getBytes("iso8859-1"),"GBK"));
} catch (Exception ex) {
ex.printStackTrace();
}
model.put("surveyOptionId", (String)req.getParameter("surveyOptionId"));
model.put("userId", (String)req.getParameter("userId"));
return new ModelAndView(getSurveyChildOption(), model);
}
//删除surveyChild
public ModelAndView deleteSurveyChildOption(HttpServletRequest req, HttpServletResponse res) throws ServletRequestBindingException {
//强制转换成surveyChild
SurveyChild surveyChild = getSurveyChildCommand(req, res);
Map model = new HashMap();
//进行修改调查子项目的业务逻辑处理
surveyChild.setSurveyOptionId(Integer.valueOf((String)req.getParameter("surveyOptionId")));
getSetSurveyChild().deleteSurveyChild(surveyChild);
//获取已有的调查子项目
List listSurveyChildOptions = getSetSurveyChild().querySurveyChild(surveyChild.getSurveyOptionId());
//将已有的调查名称传递给页面
model.put("listSurveyChildOptions", listSurveyChildOptions);
//存放消息
model.put("msg", getSetSurveyChild().getMsg());
try {
model.put("surveyOptionName", new String(((String)req.getParameter("surveyOptionName")).getBytes("iso8859-1"),"GBK"));
} catch (Exception ex) {
ex.printStackTrace();
}
model.put("surveyOptionId", (String)req.getParameter("surveyOptionId"));
model.put("userId", (String)req.getParameter("userId"));
return new ModelAndView(getSurveyChildOption(), model);
}
//设定调查项目
public ModelAndView setSurveyOption(HttpServletRequest req, HttpServletResponse res) throws ServletRequestBindingException {
//强制转换成Survey
Survey survey = getSurveyCommand(req, res);
Map model = new HashMap();
//获取已有的调查项目
List listSurveyOptions = getSetSurveyOption().querySurveyOption(survey.getId());
//将已有的调查项目传递给页面
model.put("listSurveyOptions", listSurveyOptions);
model.put("surveyName", survey.getName());
model.put("surveyId", survey.getId());
model.put("userId", (String)req.getParameter("userId"));
return new ModelAndView(getSurveyOption(), model);
}
//设定调查子项目
public ModelAndView setSurveyChildOption(HttpServletRequest req, HttpServletResponse res) throws ServletRequestBindingException {
//强制转换成SurveyOption
SurveyOption surveyOption = getSurveyOptionCommand(req, res);
Map model = new HashMap();
//获取已有的调查子项目
List listSurveyChildOptions = getSetSurveyChild().querySurveyChild(surveyOption.getId());
//将已有的调查子项目传递给页面
model.put("listSurveyChildOptions", listSurveyChildOptions);
model.put("surveyOptionName", surveyOption.getName());
model.put("surveyOptionId", surveyOption.getId());
model.put("userId", (String)req.getParameter("userId"));
return new ModelAndView(getSurveyChildOption(), model);
}
//生成调查
public ModelAndView createSurvey(HttpServletRequest req, HttpServletResponse res) throws ServletRequestBindingException {
//强制转换成Survey
Survey survey = getSurveyCommand(req, res);
Map model = new HashMap();
//获取已有的调查项目
List listSurveyOptions = getSetSurveyOption().querySurveyOption(survey.getId());
//将已有的调查项目传递给页面
model.put("listSurveyOptions", listSurveyOptions);
//获取每个调查项目的子项目
Map mapSurveyChildOptions = new HashMap();
for (int i = 0; listSurveyOptions != null && i < listSurveyOptions.size(); i++) {
SurveyOption surveyOption = (SurveyOption)listSurveyOptions.get(i);
//获取已有的调查子项目
List listSurveyChildOptions = getSetSurveyChild().querySurveyChild(surveyOption.getId());
//将每一个调查子项目根据调查项目的id,存入map
mapSurveyChildOptions.put(surveyOption.getId(), listSurveyChildOptions);
}
//将该调查的所有调查子项目传递给页面
model.put("survey", survey);
model.put("mapSurveyChildOptions", mapSurveyChildOptions);
//存储用户id
model.put("userId", (String)req.getParameter("userId"));
return new ModelAndView(getSurvey(), model);
}
//统计调查结果
public ModelAndView countSurvey(HttpServletRequest req, HttpServletResponse res) throws ServletRequestBindingException {
//强制转换成Survey
int surveyId = Integer.valueOf((String)req.getParameter("surveyId"));
Map model = new HashMap();
//获取已有的调查项目
List listSurveyOptions = getSetSurveyOption().querySurveyOption(surveyId);
//将已有的调查项目传递给页面
model.put("listSurveyOptions", listSurveyOptions);
//获取每个调查项目的子项目
Map mapSurveyChildOptions = new HashMap();
//存储每个调查子项目的统计结果
Map mapSurveyChildCount = new HashMap();
for (int i = 0; listSurveyOptions != null && i < listSurveyOptions.size(); i++) {
SurveyOption surveyOption = (SurveyOption)listSurveyOptions.get(i);
//获取用户选择的调查子项目
int surveyChildId = Integer.valueOf((String)req.getParameter(surveyOption.getId().toString()));
SurveyChildCount surveyChildCount = new SurveyChildCount();
surveyChildCount.setSurveyChildId(surveyChildId);
//查看是否有用户已经提交了调查
SurveyChildCount surveyChildCount1 = getSetSurveyChildCount().querySurveyChildCount(surveyChildCount);
if (surveyChildCount1 != null) {
surveyChildCount = surveyChildCount1;
//累加用户提交该调查子项目的次数
surveyChildCount.setCount(surveyChildCount.getCount() + 1);
//将该调查子项目的提交次数记录进数据库
getSetSurveyChildCount().updateSurveyChildCount(surveyChildCount);
} else {
//累加用户提交该调查子项目的次数
surveyChildCount.setCount(surveyChildCount.getCount() + 1);
//将该调查子项目的提交次数记录进数据库
getSetSurveyChildCount().updateSurveyChildCount(surveyChildCount);
}
//获取已有的调查子项目
List listSurveyChildOptions = getSetSurveyChild().querySurveyChild(surveyOption.getId());
//将每一个调查子项目根据调查项目的id,存入map
mapSurveyChildOptions.put(surveyOption.getId(), listSurveyChildOptions);
mapSurveyChildCount.put(surveyChildId, surveyChildCount.getCount());
}
//将该调查的所有调查子项目传递给页面
try {
model.put("surveyName", new String(((String)req.getParameter("surveyName")).getBytes("iso8859-1"),"GBK"));
} catch (Exception ex) {
ex.printStackTrace();
}
model.put("mapSurveyChildOptions", mapSurveyChildOptions);
model.put("mapSurveyChildCount", mapSurveyChildCount);
model.put("msg", "您的调查已成功提交");
//存储用户id
model.put("userId", (String)req.getParameter("userId"));
return new ModelAndView(getSurveyOK(), model);
}
/**返回the survey
*/
public String getSurvey() {
return survey;
}
/**设定survey
*/
public void setSurvey(String survey) {
this.survey = survey;
}
/**返回surveyChildOption
*/
public String getSurveyChildOption() {
return surveyChildOption;
}
/**设定surveyChildOption
*/
public void setSurveyChildOption(String surveyChildOption) {
this.surveyChildOption = surveyChildOption;
}
/**返回surveyName
*/
public String getSurveyName() {
return surveyName;
}
/**设定surveyName
*/
public void setSurveyName(String surveyName) {
this.surveyName = surveyName;
}
/**返回the surveyOption
*/
public String getSurveyOption() {
return surveyOption;
}
/**设定surveyOption
*/
public void setSurveyOption(String surveyOption) {
this.surveyOption = surveyOption;
}
/**返回setSurvey
*/
public SetSurvey getSetSurvey() {
return setSurvey;
}
/**设定setSurvey
*/
public void setSetSurvey(SetSurvey setSurvey) {
this.setSurvey = setSurvey;
}
/**返回setSurveyOption
*/
public SetSurveyOption getSetSurveyOption() {
return setSurveyOption;
}
/**设定setSurveyOption
*/
public void setSetSurveyOption(SetSurveyOption setSurveyOption) {
this.setSurveyOption = setSurveyOption;
}
/**返回the setSurveyChild
*/
public SetSurveyChild getSetSurveyChild() {
return setSurveyChild;
}
/**设定setSurveyChild
*/
public void setSetSurveyChild(SetSurveyChild setSurveyChild) {
this.setSurveyChild = setSurveyChild;
}
/**返回setSurveyChildCount.
*/
public SetSurveyChildCount getSetSurveyChildCount() {
return setSurveyChildCount;
}
/**设定setSurveyChildCount
*/
public void setSetSurveyChildCount(SetSurveyChildCount setSurveyChildCount) {
this.setSurveyChildCount = setSurveyChildCount;
}
/**返回surveyOK.
*/
public String getSurveyOK() {
return surveyOK;
}
/**设定surveyOK
*/
public void setSurveyOK(String surveyOK) {
this.surveyOK = surveyOK;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -