コード例 #1
0
ファイル: VoteAct.java プロジェクト: xiangqiao123/mycms
  @RequestMapping(value = "/vote.jspx", method = RequestMethod.POST)
  public String submit(
      Integer voteId,
      Integer[] subIds,
      String[] reply,
      HttpServletRequest request,
      HttpServletResponse response,
      ModelMap model) {
    CmsSite site = CmsUtils.getSite(request);
    CmsUser user = CmsUtils.getUser(request);
    String ip = RequestUtils.getIpAddr(request);
    String cookieName = VOTE_COOKIE_PREFIX + voteId;
    Cookie cookie = CookieUtils.getCookie(request, cookieName);
    String cookieValue;
    if (cookie != null && !StringUtils.isBlank(cookie.getValue())) {
      cookieValue = cookie.getValue();
    } else {
      cookieValue = null;
    }
    List<Integer[]> itemIds = getItemIdsParam(request, subIds);
    Integer[] subTxtIds = null;
    if (reply != null && reply.length > 0) {
      subTxtIds = new Integer[reply.length];
      List<Integer> subTxtIdList = new ArrayList<Integer>();
      for (int i = 0; i < itemIds.size(); i++) {
        if (itemIds.get(i) == null) {
          subTxtIdList.add(subIds[i]);
        }
      }
      // 投票文本选项和题目id数组对应相同大小
      subTxtIds = (Integer[]) subTxtIdList.toArray(subTxtIds);
    }
    if (!validateSubmit(voteId, subIds, itemIds, user, ip, cookieValue, model)) {
      if (cookieValue == null) {
        // 随机cookie
        cookieValue = StringUtils.remove(UUID.randomUUID().toString(), "-");
        // 写cookie
        CookieUtils.addCookie(request, response, cookieName, cookieValue, Integer.MAX_VALUE, null);
      }
      CmsVoteTopic vote =
          cmsVoteTopicMng.vote(voteId, subTxtIds, itemIds, reply, user, ip, cookieValue);
      model.addAttribute("status", 0);
      model.addAttribute("vote", vote);

      log.info("vote CmsVote id={}, name={}", vote.getId(), vote.getTitle());
    }
    FrontUtils.frontData(request, model, site);
    return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_SPECIAL, VOTE_RESULT);
  }
コード例 #2
0
 /**
  * 我的留言
  *
  * <p>如果没有登录则跳转到登陆页
  *
  * @param request
  * @param response
  * @param model
  * @return
  */
 @RequestMapping(value = "/member/myguestbook.jspx")
 public String myguestbook(
     Integer pageNo,
     Integer ctgId,
     HttpServletRequest request,
     HttpServletResponse response,
     ModelMap model) {
   CmsSite site = CmsUtils.getSite(request);
   CmsUser user = CmsUtils.getUser(request);
   FrontUtils.frontData(request, model, site);
   MemberConfig mcfg = site.getConfig().getMemberConfig();
   // 没有开启会员功能
   if (!mcfg.isMemberOn()) {
     return FrontUtils.showMessage(request, model, "member.memberClose");
   }
   if (user == null) {
     return FrontUtils.showLogin(request, model, site);
   }
   Pagination pagination =
       guestbookMng.getPage(
           site.getId(),
           ctgId,
           user.getId(),
           null,
           null,
           true,
           false,
           cpn(pageNo),
           CookieUtils.getPageSize(request));
   model.addAttribute("pagination", pagination);
   return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_GUESTBOOK, GUESTBOOK_LIST);
 }
コード例 #3
0
ファイル: VoteAct.java プロジェクト: xiangqiao123/mycms
 @RequestMapping(value = "/vote_reply_view.jspx", method = RequestMethod.GET)
 public String reply_view(
     Integer subId,
     Integer pageNo,
     HttpServletRequest request,
     HttpServletResponse response,
     ModelMap model) {
   CmsSite site = CmsUtils.getSite(request);
   CmsVoteSubTopic subTopic = null;
   if (subId != null) {
     subTopic = cmsVoteSubTopicMng.findById(subId);
   }
   if (subTopic != null) {
     Pagination pagination =
         cmsVoteReplyMng.getPage(subId, cpn(pageNo), CookieUtils.getPageSize(request));
     model.addAttribute("subTopic", subTopic);
     model.addAttribute("pagination", pagination);
     FrontUtils.frontData(request, model, site);
     FrontUtils.frontPageData(request, model);
     return FrontUtils.getTplPath(
         request, site.getSolutionPath(), TPLDIR_SPECIAL, VOTE_REPLY_RESULT);
   } else {
     WebErrors errors = WebErrors.create(request);
     errors.addError("error.vote.novotesubfind");
     return FrontUtils.showError(request, response, model, errors);
   }
 }
コード例 #4
0
ファイル: CmsVoteTopicAct.java プロジェクト: bgarrels/cxldemo
 @RequestMapping("/vote_topic/v_list.do")
 public String list(Integer pageNo, HttpServletRequest request, ModelMap model) {
   CmsSite site = CmsUtils.getSite(request);
   Pagination pagination =
       manager.getPage(site.getId(), cpn(pageNo), CookieUtils.getPageSize(request));
   model.addAttribute("pagination", pagination);
   model.addAttribute("pageNo", pagination.getPageNo());
   return "vote_topic/list";
 }