@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";
 }
Example #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: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";
 }
Example #4
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();
  }