Ejemplo n.º 1
0
 @RequestMapping(value = "/add", method = RequestMethod.POST)
 @ResponseBody
 public Object addPost(
     @ModelAttribute("sysAnnouncement") SysAnnouncement sysAnnouncement,
     BindingResult result,
     MultipartFile uploadfileAdvise,
     MultipartFile uploadfileAdviseExtend)
     throws Exception {
   if (StringUtils.isBlank(sysAnnouncement.getDescription())
       && sysAnnouncement.getPubDest().equals("1")) {
     result.rejectValue("description", "server", "公告内容不能为空");
     return JsonRespWrapper.error(result.getFieldErrors());
   }
   if ("1".equals(sysAnnouncement.getPubDest())) {
     sysAnnouncement.setTitle(
         sysAnnouncement.getTitle().substring(0, sysAnnouncement.getTitle().length() - 2));
   }
   if ("3".equals(sysAnnouncement.getPubDest())) {
     sysAnnouncement.setTitle(sysAnnouncement.getTitle().substring(1));
   }
   logUtils.logAdd("添加公告内容", "添加成功");
   sysAnnouncement.setEndTime(
       sysAnnouncement.getEndTime().replaceAll("-", "").replaceAll(" ", "").replaceAll(":", ""));
   this.sysAnnouncementService.save(sysAnnouncement, uploadfileAdvise, uploadfileAdviseExtend);
   return JsonRespWrapper.success("操作成功", "/websys/announcement");
 }
Ejemplo n.º 2
0
 @RequestMapping(value = "/edit", method = RequestMethod.POST)
 @ResponseBody
 public Object editPost(
     @ModelAttribute("sysAnnouncement") SysAnnouncement sysAnnouncement,
     BindingResult result,
     MultipartFile uploadfileAdvise,
     MultipartFile uploadfileAdviseExtend)
     throws Exception {
   if (null == sysAnnouncement.getPubDest()) {
     SysAnnouncement s = sysAnnouncementDao.findOne(sysAnnouncement.getId());
     sysAnnouncement.setPubDest(s.getPubDest());
   }
   if (StringUtils.isBlank(sysAnnouncement.getDescription())
       && sysAnnouncement.getPubDest().equals("1")) {
     result.rejectValue("description", "server", "公告内容不能为空");
     return JsonRespWrapper.error(result.getFieldErrors());
   }
   if ("1".equals(sysAnnouncement.getPubDest())) {
     sysAnnouncement.setTitle(sysAnnouncement.getTitle().split(",")[0]);
   }
   if ("3".equals(sysAnnouncement.getPubDest())) {
     sysAnnouncement.setTitle(sysAnnouncement.getTitle().split(",")[1]);
   }
   sysAnnouncement.setEndTime(
       sysAnnouncement.getEndTime().replaceAll("-", "").replaceAll(" ", "").replaceAll(":", ""));
   this.sysAnnouncementService.save(sysAnnouncement, uploadfileAdvise, uploadfileAdviseExtend);
   logUtils.logAdd("编辑公告内容,", "修改成功,公告编号:", +sysAnnouncement.getId());
   return JsonRespWrapper.success("操作成功", "/websys/announcement");
 }