首页>代码>spring+spring mvc+hibernate开发java web宿舍后台管理系统>/DormitoryManager/src/com/bjpowernode/buss/controller/ScoreController.java
package com.bjpowernode.buss.controller; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; import org.hibernate.criterion.DetachedCriteria; 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.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; import org.json.JSONObject; import com.bjpowernode.buss.entity.base.DormEntity; import com.bjpowernode.buss.entity.base.ScoreEntity; import com.bjpowernode.buss.service.ScoreService; import com.bjpowernode.common.controller.BaseController; import com.bjpowernode.common.util.AjaxJson; import com.bjpowernode.common.util.Pagination; @Controller @RequestMapping("/scoreController") public class ScoreController extends BaseController{ private static final Logger logger = Logger.getLogger(ScoreController.class); @Autowired private ScoreService scoreService; /** * 初始访问 * @param * @param model * @return */ @RequestMapping(params="goScore") public ModelAndView goScore(HttpServletRequest request){ return new ModelAndView("buss/score"); } @RequestMapping(params="save") @ResponseBody public AjaxJson save(HttpServletRequest request, HttpServletResponse response, ScoreEntity scoreEntity,String dormid) throws Exception { AjaxJson j = new AjaxJson(); j.setMsg("保存成功!"); j.setSuccess(true); try{ DormEntity de = this.scoreService.get(DormEntity.class, dormid); scoreEntity.setDorm(de); this.scoreService.save(scoreEntity); }catch(Exception e){ j.setMsg("保存失败!"); j.setSuccess(false); } return j; } @RequestMapping(params="update") @ResponseBody public AjaxJson update(HttpServletRequest request, HttpServletResponse response, ScoreEntity scoreEntity,String dormid) throws Exception { AjaxJson j = new AjaxJson(); j.setMsg("更新成功!"); j.setSuccess(true); try{ DormEntity de = this.scoreService.get(DormEntity.class, dormid); scoreEntity.setDorm(de); this.scoreService.update(scoreEntity); }catch(Exception e){ j.setMsg("更新失败!"); j.setSuccess(false); } return j; } @RequestMapping(params="delete",method=RequestMethod.POST) @ResponseBody public AjaxJson delete(HttpServletRequest request, HttpServletResponse response, String ids) throws Exception { AjaxJson j = new AjaxJson(); j.setMsg("删除成功!"); j.setSuccess(true); try{ for(String id:ids.split(",")){ ScoreEntity scoreEntity = new ScoreEntity(); scoreEntity.setId(id); this.scoreService.delete(scoreEntity); } }catch(Exception e){ j.setMsg("删除失败!"); j.setSuccess(false); } return j; } @RequestMapping(params="datagrid") @ResponseBody public void datagrid(HttpServletRequest request, HttpServletResponse response, ScoreEntity ve, String startDate, String endDate, String paramDorm) throws Exception { String page = request.getParameter("page");//easyui datagrid 分页 页号 String rows = request.getParameter("rows");//easyui datagrid 分页 页数 if(page == null){ page = "0"; } if(rows == null){ rows = "0"; } DetachedCriteria condition = DetachedCriteria.forClass(ScoreEntity.class); Pagination<?> pagination = scoreService.findPageData(condition,ve,Integer.parseInt(page), Integer.parseInt(rows),startDate,endDate,paramDorm); JSONObject jobj = new JSONObject(); jobj.put("total", pagination.getTotalCount()); jobj.put("rows", pagination.getDatas()); response.setCharacterEncoding("utf-8"); response.getWriter().write(jobj.toString()); } }
最近下载更多
dev1ce123 LV4
2023年10月16日
泓鼎168 LV19
2023年6月30日
ziv5466123 LV7
2023年6月26日
li951753 LV2
2023年6月19日
迷迭香 LV10
2023年3月3日
朱朱啊哈 LV16
2023年2月1日
超炫爱 LV2
2022年12月5日
你是太阳 LV3
2022年11月27日
wylwylqq LV6
2022年11月26日
lq2218219081 LV2
2022年10月18日
最近浏览更多
together love LV2
3月24日
WBelong LV6
3月8日
escape1023
3月4日
暂无贡献等级
微信网友_6806154474721280 LV3
1月3日
admin_z LV22
1月2日
颜伟峰 LV1
2023年12月20日
Jjjj1111 LV5
2023年11月12日
skye1008
2023年11月5日
暂无贡献等级
毫无语 LV6
2023年10月19日
dev1ce123 LV4
2023年10月15日