Example #1
0
 @Override
 protected CmsWord init(CmsWord entity) {
   if (empty(entity.getCreateDate())) {
     entity.setCreateDate(getDate());
   }
   return entity;
 }
 @RequestMapping("delete")
 public String delete(
     Integer id, HttpServletRequest request, HttpSession session, ModelMap model) {
   SysSite site = getSite(request);
   CmsWord entity = service.getEntity(id);
   if (notEmpty(entity)) {
     if (virifyNotEquals("siteId", site.getId(), entity.getSiteId(), model)) {
       return TEMPLATE_ERROR;
     }
     service.delete(id);
     logOperateService.save(
         new LogOperate(
             site.getId(),
             getAdminFromSession(session).getId(),
             LogLoginService.CHANNEL_WEB_MANAGER,
             "delete.word",
             getIpAddress(request),
             getDate(),
             id + ":" + entity.getName()));
   }
   return TEMPLATE_DONE;
 }
 @RequestMapping("save")
 public String save(
     CmsWord entity, HttpServletRequest request, HttpSession session, ModelMap model) {
   SysSite site = getSite(request);
   if (notEmpty(entity.getId())) {
     CmsWord oldEntity = service.getEntity(entity.getId());
     if (empty(oldEntity)
         || virifyNotEquals("siteId", site.getId(), oldEntity.getSiteId(), model)) {
       return TEMPLATE_ERROR;
     }
     entity = service.update(entity.getId(), entity, new String[] {"id", "siteId"});
     if (notEmpty(entity)) {
       logOperateService.save(
           new LogOperate(
               entity.getSiteId(),
               getAdminFromSession(session).getId(),
               LogLoginService.CHANNEL_WEB_MANAGER,
               "update.word",
               getIpAddress(request),
               getDate(),
               entity.getId() + ":" + entity.getName()));
     }
   } else {
     service.save(entity);
     logOperateService.save(
         new LogOperate(
             site.getId(),
             getAdminFromSession(session).getId(),
             LogLoginService.CHANNEL_WEB_MANAGER,
             "save.word",
             getIpAddress(request),
             getDate(),
             entity.getId() + ":" + entity.getName()));
   }
   return TEMPLATE_DONE;
 }