@RequiresPermissions("plug:resume:list")
 @RequestMapping("list.do")
 public String list(
     @PageableDefaults(sort = "id", sortDir = Direction.DESC) Pageable pageable,
     HttpServletRequest request,
     org.springframework.ui.Model modelMap) {
   Integer siteId = Context.getCurrentSiteId(request);
   Map<String, String[]> params = Servlets.getParameterValuesMap(request, Constants.SEARCH_PREFIX);
   Page<Resume> pagedList = service.findAll(siteId, params, pageable);
   modelMap.addAttribute("pagedList", pagedList);
   return "plug/resume/resume_list";
 }
Esempio n. 2
0
 private String validateSubmit(
     HttpServletRequest request, Response resp, String coo, Integer id, Integer[] optionIds) {
   List<String> messages = resp.getMessages();
   if (!Validations.notNull(id, messages, "id")) {
     return resp.post(401);
   }
   if (!Validations.notEmpty(optionIds)) {
     return resp.post(402);
   }
   Vote vote = service.get(id);
   if (!Validations.exist(vote, messages, "Vote", id)) {
     return resp.post(451);
   }
   if (vote.getStatus() == Vote.DISABLED_STATUS) {
     return resp.post(510, "vote.desiabled");
   }
   Date now = new Date();
   Date beginDate = vote.getBeginDate();
   if (beginDate != null && beginDate.after(now)) {
     return resp.post(520, "vote.notStarted");
   }
   Date endDate = vote.getEndDate();
   if (endDate != null && endDate.before(now)) {
     return resp.post(530, "vote.ended");
   }
   if (vote.getMaxSelected() > 0 && optionIds.length > vote.getMaxSelected()) {
     return resp.post(540, "vote.exceedsMaxSelected");
   }
   Integer userId = null;
   String ip = null;
   String cookie = null;
   if (vote.getMode() == Vote.USER_MODE) {
     User user = Context.getCurrentUser(request);
     if (user == null) {
       return resp.post(550, "vote.needLogin");
     }
     userId = user.getId();
   } else if (vote.getMode() == Vote.IP_MODE) {
     ip = Servlets.getRemoteAddr(request);
   } else if (vote.getMode() == Vote.COOKIE_MODE) {
     cookie = coo;
   }
   if (userId != null || ip != null || cookie != null) {
     Integer beforeHour = null;
     if (vote.getInterval() != 0) {
       beforeHour = vote.getInterval() * 24;
     }
     if (voteMarkService.isVoted(Vote.MARK_CODE, vote.getId(), userId, ip, cookie, beforeHour)) {
       return resp.post(560, "vote.voted");
     }
   }
   return null;
 }
 @RequiresPermissions("plug:resume:save")
 @RequestMapping("save.do")
 public String save(
     @Valid Resume bean, String redirect, HttpServletRequest request, RedirectAttributes ra) {
   Integer siteId = Context.getCurrentSiteId(request);
   service.save(bean, siteId);
   logger.info("save Resume, name={}.", bean.getName());
   ra.addFlashAttribute(MESSAGE, SAVE_SUCCESS);
   if (Constants.REDIRECT_LIST.equals(redirect)) {
     return "redirect:list.do";
   } else if (Constants.REDIRECT_CREATE.equals(redirect)) {
     return "redirect:create.do";
   } else {
     ra.addAttribute("id", bean.getId());
     return "redirect:edit.do";
   }
 }
 @RequiresPermissions("plug:resume:edit")
 @RequestMapping("edit.do")
 public String edit(
     Integer id,
     Integer position,
     @PageableDefaults(sort = "id", sortDir = Direction.DESC) Pageable pageable,
     HttpServletRequest request,
     org.springframework.ui.Model modelMap) {
   Integer siteId = Context.getCurrentSiteId(request);
   Resume bean = service.get(id);
   Map<String, String[]> params = Servlets.getParameterValuesMap(request, Constants.SEARCH_PREFIX);
   RowSide<Resume> side = service.findSide(siteId, params, bean, position, pageable.getSort());
   modelMap.addAttribute("bean", bean);
   modelMap.addAttribute("side", side);
   modelMap.addAttribute("position", position);
   modelMap.addAttribute(OPRT, EDIT);
   return "plug/resume/resume_form";
 }
Esempio n. 5
0
  @RequestMapping(value = "/vote/{id}.jspx")
  public String view(
      @PathVariable("id") Integer id,
      HttpServletRequest request,
      HttpServletResponse response,
      org.springframework.ui.Model modelMap) {
    Response resp = new Response(request, response, modelMap);
    List<String> messages = resp.getMessages();
    Vote vote = service.get(id);
    if (!Validations.exist(vote, messages, "Vote", id)) {
      return resp.notFound();
    }

    Site currSite = Context.getCurrentSite(request);
    modelMap.addAttribute("vote", vote);
    Map<String, Object> data = modelMap.asMap();
    ForeContext.setData(data, request);
    return currSite.getTemplate(VIEW_TEMPLATE);
  }
Esempio n. 6
0
  @RequestMapping(value = "/vote.jspx", method = RequestMethod.POST)
  public String submit(
      Integer id,
      Integer[] optionIds,
      HttpServletRequest request,
      HttpServletResponse response,
      org.springframework.ui.Model modelMap) {
    Response resp = new Response(request, response, modelMap);
    String cookie = Site.getIdentityCookie(request, response);
    String result = validateSubmit(request, resp, cookie, id, optionIds);
    if (resp.hasErrors()) {
      return result;
    }

    Integer userId = Context.getCurrentUserId(request);
    String ip = Servlets.getRemoteAddr(request);
    service.vote(id, optionIds, userId, ip, cookie);
    resp.addData("id", id);
    return resp.post();
  }
Esempio n. 7
0
  @RequestMapping(value = "/vote.jspx")
  public String form(
      Integer id,
      HttpServletRequest request,
      HttpServletResponse response,
      org.springframework.ui.Model modelMap) {
    Response resp = new Response(request, response, modelMap);
    List<String> messages = resp.getMessages();
    if (!Validations.notNull(id, messages, "id")) {
      return resp.badRequest();
    }
    Vote vote = service.get(id);
    if (!Validations.exist(vote, messages, "Vote", id)) {
      return resp.notFound();
    }

    modelMap.addAttribute("vote", vote);
    Site site = Context.getCurrentSite(request);
    Map<String, Object> data = modelMap.asMap();
    ForeContext.setData(data, request);
    return site.getTemplate(TEMPLATE);
  }