/** * 新增/修改save操作 * * @param model * @param fwlog * @param request * @param response * @return * @throws Exception * @author Mr.Hao<Auto generate> * @version 2013-07-29 11:36:44 */ @RequestMapping("/update") public String saveorupdate( Model model, Fwlog fwlog, HttpServletRequest request, HttpServletResponse response) throws Exception { if (StringUtils.isBlank(fwlog.getId())) { // 新增 fwlog.setId(SecUtils.getUUID()); try { fwlogService.save(fwlog); model.addAttribute(message, MessageUtils.ADD_SUCCESS); return messageurl; } catch (Exception e) { logger.error(e.getMessage(), e); } model.addAttribute(message, MessageUtils.ADD_FAIL); return messageurl; } else { // 修改 try { fwlog.setId(fwlog.getId()); fwlogService.update(fwlog); model.addAttribute(message, MessageUtils.EDIT_SUCCESS); return messageurl; } catch (Exception e) { logger.error(e.getMessage(), e); } model.addAttribute(message, MessageUtils.EDIT_WARING); return messageurl; } }
/** 进入修改页面 */ @RequestMapping(value = "/update/pre") public String edit(Model model, HttpServletRequest request, HttpServletResponse response) throws Exception { java.lang.String id = request.getParameter("id"); if (StringUtils.isNotBlank(id)) { Fwlog fwlog = fwlogService.findFwlogById(id); model.addAttribute("fwlog", fwlog); } return "/demo/fwlog/fwlogCru"; }
/** * 进入fwlog Web页面后直接展现第一页数据 * * @param request * @param model * @return * @author Mr.Hao<Auto generate> * @version 2013-07-29 11:36:44 */ @RequestMapping("/list") public String list(HttpServletRequest request, Model model, Fwlog fwlog) throws Exception { // ==构造分页请求 Page page = newPage(request); // ==执行分页查询 List<Fwlog> datas = fwlogService.findListDataByFinder(null, page, Fwlog.class, fwlog); model.addAttribute("page", page); model.addAttribute("datas", datas); model.addAttribute("fwlog", fwlog); return listurl; }
@RequestMapping("/list/export") public void listexport( HttpServletRequest request, HttpServletResponse response, Model model, Fwlog fwlog) throws Exception { // ==构造分页请求 Page page = newPage(request); File file = fwlogService.findDataExportExcel(null, listurl, page, Fwlog.class, fwlog); String fileName = "fwlog" + GlobalStatic.excelext; downFile(response, file, fileName, true); return; }
/** 删除操作 */ @RequestMapping(value = "/delete") public @ResponseBody CFReturnObject destroy(HttpServletRequest request) throws Exception { // 执行删除 try { java.lang.String id = request.getParameter("id"); if (StringUtils.isNotBlank(id)) { fwlogService.deleteById(id, Fwlog.class); return new CFReturnObject(CFReturnObject.SUCCESS, MessageUtils.DELETE_SUCCESS); } else { return new CFReturnObject(CFReturnObject.WARNING, MessageUtils.DELETE_WARNING); } } catch (Exception e) { logger.error(e.getMessage(), e); } return new CFReturnObject(CFReturnObject.WARNING, MessageUtils.DELETE_WARNING); }
/** * 删除多条记录 * * @param request * @param model * @return * @author Mr.Hao<Auto generate> * @version 2013-07-29 11:36:44 */ @RequestMapping("/delMulti") public @ResponseBody CFReturnObject delMultiRecords(HttpServletRequest request, Model model) { String records = request.getParameter("records"); String[] rs = records.split(","); if (rs == null || rs.length < 1) { return new CFReturnObject(CFReturnObject.SUCCESS, MessageUtils.DELETE_ALL_SUCCESS); } int i = 0; for (String str : rs) { try { fwlogService.deleteById(str.trim(), Fwlog.class); } catch (Exception e) { if (i > 0) { return new CFReturnObject(CFReturnObject.ERROR, MessageUtils.DELETE_ALL_WARNING); } return new CFReturnObject(CFReturnObject.ERROR, MessageUtils.DELETE_ALL_FAIL); } i++; } return new CFReturnObject(CFReturnObject.SUCCESS, MessageUtils.DELETE_ALL_SUCCESS); }