/** 查看留言回复 */ @RequestMapping(value = "/member/guestbook_replay.jspx") public String guestbook_replay( Integer id, String nextUrl, 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); } CmsGuestbook guestbook = guestbookMng.findById(id); if (!guestbook.getMember().equals(user)) { WebErrors errors = WebErrors.create(request); errors.addErrorCode("error.noPermissionsView"); return FrontUtils.showError(request, response, model, errors); } model.addAttribute("guestbook", guestbook); return FrontUtils.getTplPath( request, site.getSolutionPath(), TPLDIR_GUESTBOOK, GUESTBOOK_REPLAY); }
/** * 我的留言 * * <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); }
/** * 密码修改提交页 * * @param origPwd 原始密码 * @param newPwd 新密码 * @param email 邮箱 * @param nextUrl 下一个页面地址 * @param request * @param response * @param model * @return * @throws IOException */ @RequestMapping(value = "/member/pwd.jspx", method = RequestMethod.POST) public String passwordSubmit( String origPwd, String newPwd, String email, String nextUrl, HttpServletRequest request, HttpServletResponse response, ModelMap model) throws IOException { 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); } WebErrors errors = validatePasswordSubmit(user.getId(), origPwd, newPwd, email, request); if (errors.hasErrors()) { return FrontUtils.showError(request, response, model, errors); } cmsUserMng.updatePwdEmail(user.getId(), newPwd, email); return FrontUtils.showSuccess(request, model, nextUrl); }
@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); }
/** * 更换头像 * * @param request * @param response * @param model * @return */ @RequestMapping(value = "/member/portrait.jspx", method = RequestMethod.GET) public String portrait(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); } return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_MEMBER, MEMBER_PORTRAIT); }
@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); } }
/** 留言详细 */ @RequestMapping(value = "/member/guestbook_detail.jspx") public String guestbook_detail( Integer id, 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); } CmsGuestbook guestbook = guestbookMng.findById(id); model.addAttribute("guestbook", guestbook); return FrontUtils.getTplPath( request, site.getSolutionPath(), TPLDIR_GUESTBOOK, GUESTBOOK_DETAIL); }
@RequiresPermissions("special:o_create_dimensioncode") @RequestMapping("/special/o_create_dimensioncode.do") public void createCodeImg( String content, String logoPicPath, String logoWord, Integer fontSize, Integer size, HttpServletRequest request, HttpServletResponse response) { JSONObject json = new JSONObject(); if (StringUtils.isNotBlank(content)) { CmsSite site = CmsUtils.getSite(request); if (size == null) { size = 100; } if (fontSize == null) { fontSize = 10; } String logoPic = null; if (StringUtils.isNotBlank(logoPicPath)) { if (StringUtils.isNotBlank(site.getContextPath()) && logoPicPath.startsWith(site.getContextPath())) { logoPicPath = logoPicPath.substring(site.getContextPath().length()); } logoPic = realPathResolver.get(logoPicPath); } response.setContentType("image/png; charset=utf-8"); try { ZXingCode zp = ZXingCode.getInstance(); BufferedImage bim = zp.getQRCODEBufferedImage( content, BarcodeFormat.QR_CODE, size, size, zp.getDecodeHintType()); if (StringUtils.isNotBlank(logoPicPath)) { zp.addLogoQRCode(bim, new File(logoPic), new ZxingLogoConfig()); } else if (StringUtils.isNotBlank(logoWord)) { zp.addLogoWordQRCode(bim, logoWord, fontSize, new ZxingLogoConfig()); } String tempFileName = DEMENSION_CODE_IMG_NAME; File file = new File(realPathResolver.get(tempFileName)); ImageIO.write(bim, "png", file); if (StringUtils.isNotBlank(site.getContextPath())) { tempFileName = site.getContextPath() + tempFileName; } json.put("url", tempFileName); } catch (Exception e) { e.printStackTrace(); } } ResponseUtils.renderJson(response, json.toString()); }
/** * 个人资料提交页 * * @param request * @param response * @param model * @return * @throws IOException */ @RequestMapping(value = "/member/profile.jspx", method = RequestMethod.POST) public String profileSubmit( CmsUserExt ext, String nextUrl, HttpServletRequest request, HttpServletResponse response, ModelMap model) throws IOException { 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); } ext.setId(user.getId()); cmsUserExtMng.update(ext, user); log.info("update CmsUserExt success. id={}", user.getId()); return FrontUtils.showSuccess(request, model, nextUrl); }
@RequestMapping(value = "/vote.jspx", method = RequestMethod.GET) public String input( Integer voteId, HttpServletRequest request, HttpServletResponse response, ModelMap model) { CmsSite site = CmsUtils.getSite(request); CmsVoteTopic vote = null; if (voteId != null) { vote = cmsVoteTopicMng.findById(voteId); } if (vote != null) { model.addAttribute("vote", vote); FrontUtils.frontData(request, model, site); return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_SPECIAL, VOTE_INPUT); } else { WebErrors errors = WebErrors.create(request); errors.addError("error.vote.novotefind"); return FrontUtils.showError(request, response, model, errors); } }
@RequiresPermissions("common:o_upload_image") @RequestMapping("/common/o_upload_image.do") public String execute( String filename, Integer uploadNum, Boolean mark, @RequestParam(value = "uploadFile", required = false) MultipartFile file, HttpServletRequest request, ModelMap model) { WebCoreErrors errors = validateImage(file, request); if (errors.hasErrors()) { model.addAttribute(ERROR, errors.getErrors().get(0)); return RESULT_PAGE; } CmsSite site = CmsUtils.getSite(request); MarkConfig conf = site.getConfig().getMarkConfig(); if (mark == null) { mark = conf.getOn(); } String origName = file.getOriginalFilename(); String ext = FilenameUtils.getExtension(origName).toLowerCase(Locale.ENGLISH); try { String fileUrl; if (site.getConfig().getUploadToDb()) { String dbFilePath = site.getConfig().getDbFileUri(); if (!StringUtils.isBlank(filename)) { filename = filename.substring(dbFilePath.length()); if (mark) { File tempFile = mark(file, conf); fileUrl = dbFileMng.storeByFilename(filename, new FileInputStream(tempFile)); tempFile.delete(); } else { fileUrl = dbFileMng.storeByFilename(filename, file.getInputStream()); } } else { if (mark) { File tempFile = mark(file, conf); fileUrl = dbFileMng.storeByExt(site.getUploadPath(), ext, new FileInputStream(tempFile)); tempFile.delete(); } else { fileUrl = dbFileMng.storeByExt(site.getUploadPath(), ext, file.getInputStream()); } // 加上访问地址 fileUrl = request.getContextPath() + dbFilePath + fileUrl; } } else if (site.getUploadFtp() != null) { Ftp ftp = site.getUploadFtp(); String ftpUrl = ftp.getUrl(); if (!StringUtils.isBlank(filename)) { filename = filename.substring(ftpUrl.length()); if (mark) { File tempFile = mark(file, conf); fileUrl = ftp.storeByFilename(filename, new FileInputStream(tempFile)); tempFile.delete(); } else { fileUrl = ftp.storeByFilename(filename, file.getInputStream()); } } else { if (mark) { File tempFile = mark(file, conf); fileUrl = ftp.storeByExt(site.getUploadPath(), ext, new FileInputStream(tempFile)); tempFile.delete(); } else { fileUrl = ftp.storeByExt(site.getUploadPath(), ext, file.getInputStream()); } // 加上url前缀 fileUrl = ftpUrl + fileUrl; } } else { String ctx = request.getContextPath(); if (!StringUtils.isBlank(filename)) { filename = filename.substring(ctx.length()); if (mark) { File tempFile = mark(file, conf); fileUrl = fileRepository.storeByFilename(filename, tempFile); tempFile.delete(); } else { fileUrl = fileRepository.storeByFilename(filename, file); } } else { if (mark) { File tempFile = mark(file, conf); fileUrl = fileRepository.storeByExt(site.getUploadPath(), ext, tempFile); tempFile.delete(); } else { fileUrl = fileRepository.storeByExt(site.getUploadPath(), ext, file); } // 加上部署路径 fileUrl = ctx + fileUrl; } } fileMng.saveFileByPath(fileUrl, origName, false); model.addAttribute("uploadPath", fileUrl); model.addAttribute("uploadNum", uploadNum); } catch (IllegalStateException e) { model.addAttribute(ERROR, e.getMessage()); log.error("upload file error!", e); } catch (IOException e) { model.addAttribute(ERROR, e.getMessage()); log.error("upload file error!", e); } catch (Exception e) { model.addAttribute(ERROR, e.getMessage()); log.error("upload file error!", e); } cmsUserMng.updateUploadSize( CmsUtils.getUserId(request), Integer.parseInt(String.valueOf(file.getSize() / 1024))); return RESULT_PAGE; }
/** * 验证密码是否正确 * * @param origPwd 原密码 * @param request * @param response */ @RequestMapping("/member/checkPwd.jspx") public void checkPwd(String origPwd, HttpServletRequest request, HttpServletResponse response) { CmsUser user = CmsUtils.getUser(request); boolean pass = cmsUserMng.isPasswordValid(user.getId(), origPwd); ResponseUtils.renderJson(response, pass ? "true" : "false"); }