/** * 打开添加 * * @param model * @param source * @return */ @RequestMapping(params = "action=create", method = RequestMethod.GET) public String initCreate(ModelMap model) { ContactGroupDTO contactGroupDTO = new ContactGroupDTO(); contactGroupDTO.setAllContacters(contactGroupService.getAllContacters()); model.addAttribute("command", contactGroupDTO); return EDIT_PAGE; }
/** * 删除出数据源信息 * * @param id * @return * @throws Exception */ @RequestMapping(params = "action=delete", method = RequestMethod.GET) public String delete(int id) throws Exception { try { contactGroupService.delete(id); } catch (Exception e) { log.error(e); e.printStackTrace(); throw new Exception("不能删除,相关数据源正在使用该联系人组"); } return "redirect:" + List_ACTION; }
/** * 联系人列表 * * @param model * @return */ @RequestMapping( params = "action=list", method = {RequestMethod.GET, RequestMethod.POST}) public String list(ContactGroupCriteria criteria, ModelMap model) { if (criteria == null) { criteria = new ContactGroupCriteria(); } List<ContactGroupDTO> list = contactGroupService.queryPageByCriteria(criteria); model.addAttribute("contactGroupList", list); model.addAttribute("criteria", criteria); return LIST_PAGE; }
/** * 批量删除数据源信息 * * @param ids * @return * @throws IOException */ @RequestMapping( params = "action=deleteAll", method = {RequestMethod.POST, RequestMethod.GET}) public void deleteAll(HttpServletResponse response, String ids) throws IOException { if (!StringUtils.isBlank(ids)) { try { for (String id : ids.split(",")) { contactGroupService.delete(Integer.parseInt(id)); } HttpServletResponseUtil.writeObject2Response(response, "success"); } catch (IOException e) { log.error(e); HttpServletResponseUtil.writeObject2Response(response, "fail"); } } }
/** * 添加联系人 * * @param model * @param userInfo * @return */ @RequestMapping(params = "action=submit", method = RequestMethod.POST) public String submit(ModelMap model, ContactGroupDTO contactGroupDTO) { ContactGroup contacterGroup = BeanCopyUtil.copy(contactGroupDTO, ContactGroup.class); contactGroupService.submit(contacterGroup); return "redirect:" + List_ACTION; }
/** * 打开修改 * * @param model * @param source * @return */ @RequestMapping(params = "action=update", method = RequestMethod.GET) public String initUpldate(ModelMap model, Integer id) { model.addAttribute("command", contactGroupService.getDto(id)); return EDIT_PAGE; }