首页>代码>Spring+Mybatis+Mysql+Spring MVC实现企业服务呼叫中心管理后台>/CompanyCallCenter/src/com/companycallcenter/kyh/controller/AnswerController.java
package com.companycallcenter.kyh.controller; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.servlet.ModelAndView; import com.companycallcenter.kyh.entity.Answer; import com.companycallcenter.kyh.entity.Organ; import com.companycallcenter.kyh.entity.User; import com.companycallcenter.kyh.service.AnswerService; import com.companycallcenter.kyh.util.KyhHttpUtil; @SuppressWarnings("unused") public class AnswerController extends BaseController implements BaseControllerInterface<Answer> { @Autowired private AnswerService answerService; private Answer answer; private List<Answer> list; @Override public ModelAndView query(HttpServletRequest request, HttpServletResponse response) { ModelAndView model=new ModelAndView(); list=answerService.list(); model.addObject("list",list); model.setViewName("/Answer/answerList"); return model; } @Override public ModelAndView find(HttpServletRequest request, HttpServletResponse response) { String name=request.getParameter("tname"); String content=request.getParameter("content"); String username=request.getParameter("username"); String questionid=request.getParameter("questionid"); String flage=request.getParameter("flage"); Answer answer= new Answer(); if("".equals(name)){ name=null; } if("".equals(content)){ content=null; } if("".equals(username)){ username=null; }if("".equals(questionid)){ questionid=null; } answer.setTname(name); answer.setContent(content); answer.setUsername(username); answer.setQuestionid(questionid); ModelAndView model=new ModelAndView(); List<Answer> list=answerService.find(answer); model.addObject("list",list); if("1".equals(flage)){ model.setViewName("/Answer/oneQuestionAnswer"); }else { model.setViewName("/Answer/answerList"); } return model; } @Override public ModelAndView add(HttpServletRequest request, HttpServletResponse response) { ModelAndView model=new ModelAndView(); model.setViewName("/Answer/answer_add"); return model; } @Override public ModelAndView save(HttpServletRequest request, HttpServletResponse response, Answer answer) { ModelAndView model=new ModelAndView(); if(null!=answer){ // 从session 里面获取用户名的信息 User usr=KyhHttpUtil.getLoginUser(request); answer.setCreateId(usr.getTel()); answer.setUsername(usr.getName()); answerService.insert(answer); model.setViewName("redirect:answer.do?action=find&questionid="+answer.getQuestionid()); } return model; } @Override public ModelAndView look(HttpServletRequest request, HttpServletResponse response) { String id=request.getParameter("Id"); Answer answer=answerService.get(id); ModelAndView model=new ModelAndView(); if(null!=model){ model.addObject("answerMessage",answer); model.setViewName("/Answer/answer_detail"); return model; } model.setViewName("error"); return model; } @Override public ModelAndView editMessage(HttpServletRequest request, HttpServletResponse response) { String id=request.getParameter("Id"); answer=answerService.get(id); ModelAndView model=new ModelAndView(); if(null!=answer){ model.addObject("answerMessage",answer); model.setViewName("/Answer/answer_edit"); return model; } model.setViewName("error"); return model; } @Override public ModelAndView updateMessage(HttpServletRequest request, HttpServletResponse response, Answer t) { String id=request.getParameter("Id"); answer=answerService.get(id); ModelAndView model=new ModelAndView(); if(null!=answer){ model.addObject("answerMessage",answer); model.setViewName("/Answer/answer_edit"); return model; } model.setViewName("error"); return model; } @Override public void delete(HttpServletRequest request, HttpServletResponse response) { List<String> ids=KyhHttpUtil.kyhgetList(request, "ids", ";"); String method=request.getMethod().toLowerCase(); if("post".equals(method)){ try{ answerService.kyhdeletesByIds(ids); this.kyhoutSuccessMessage(request,response,""); }catch(Exception e){ String msg="数据已经被使用,不能删除!"; this.kyhoutFailMessage(request,response,msg,""); } }else{ this.kyhoutFailMessage(request,response, "对不起您没有删除权限 !",""); } } public void updatevalid1(HttpServletRequest request, HttpServletResponse response) { String valid=request.getParameter("valid"); String id=request.getParameter("Id"); String method=request.getMethod().toLowerCase(); Answer answer2=new Answer(); if("post".equals(method)){ try{ if(null!=valid && !"".equals(valid)){ answer2.setValid(Boolean.parseBoolean(valid)); } answer2.setId(Integer.parseInt(id)); answerService.update(answer2); this.kyhoutSuccessMessage(request,response,""); }catch(Exception e){ String msg="数据已经被使用,不能删除!"; this.kyhoutFailMessage(request,response,msg,""); } }else{ this.kyhoutFailMessage(request,response, "对不起您没有删除权限 !",""); } } @Override public void updatevalid(HttpServletRequest request, HttpServletResponse response) { // TODO Auto-generated method stub } }
最近下载更多
二拾 LV6
2023年4月7日
Lmfbaby LV9
2022年5月29日
wanglinddad LV55
2022年1月8日
IT白夜 LV12
2021年11月23日
543666826 LV33
2021年11月18日
2638970072 LV1
2021年11月5日
15167672991 LV6
2021年6月30日
我家大宝贝 LV4
2021年6月9日
ericxu1116 LV24
2021年5月19日
naixia LV9
2021年2月10日
最近浏览更多
微信网友_6945099420356608
4月10日
暂无贡献等级
wyyz5211314 LV4
4月7日
2775645521 LV7
4月2日
tqsDemo LV5
3月15日
54kkman
3月12日
暂无贡献等级
噜噜噜路口 LV2
2023年8月17日
hb2008 LV3
2023年6月25日
KaoPu trips LV2
2023年6月22日
明天更美好 LV10
2023年6月17日
cunbie LV4
2023年6月13日