/* * (non-Javadoc) * @see com.opensymphony.xwork2.ActionSupport#execute() */ @Override @Action( results = { @Result(name = "success", location = "/WEB-INF/content/success.jsp"), @Result(name = "fail", location = "/WEB-INF/content/register.jsp") }) public String execute() { HttpServletRequest request = ServletActionContext.getRequest(); String ccode = (String) request.getSession().getAttribute(SystemVariables.VALIDATE_CODE); log.debug(">>>from session ccode:" + ccode); if (vcode == null || !ccode.equals(vcode)) { return "fail"; } boolean exist = enterpriseService.exist(email); if (exist) { return "fail"; } Enterprise ent = new Enterprise(); ent.setUserType(userType); ent.setSex(sex == 0); ent.setAccount(email); ent.setEmail(email); ent.setNickname(nickname); ent.setAddress(address); ent.setLinkman(linkman); ent.setName(name); ent.setMobilePhone(mobilePhone); if (userType == Enterprise.USER_TYPE_PERSON) { ent.setName(nickname); } // 拼音 String pinyin = ent.getNamePinyinByName(); String firstPinyin = ent.getNameFirstPinyinByName(); ent.setNamePinyin(pinyin); ent.setNameFirstPinyin(firstPinyin); ent.setPassword(EncryptUtil.md5(password)); enterpriseService.insert(ent); entInfo = new EntInfo(); entInfo.setEnterprise(ent); entInfo.setIndexImgUrl("/member/images/banner1.jpg"); entInfoService.insert(entInfo); enterpriseId = ent.getId(); log.debug(">>>用户注册:" + ent); request.getSession().setAttribute(SystemVariables.ENTERPRISE_USER, ent); request.getSession().setAttribute(SystemVariables.ENTERPRISE_USER_ID, ent.getId()); return SUCCESS; }
public String detail() { type = "0"; // 产品搜索标识 supply = supplyService.getEntityById(supplyId); if (supply.getStatus() == 1) { return "list"; } /* * 2012/9/11 * 判断产品是否被禁止,不用查看 * 能够查看的条件: * 1. 登录 & 是自己的产品 * 2. 登录 & 后台管理员 */ PTags tag = supply.getPtags(); boolean pass = tag == null ? true : tag.getPass(); if (!pass) { if (Struts2Utils.getSession().getAttribute(SystemVariables.ADMIN_USER) == null || Struts2Utils.getSession().getAttribute(SystemVariables.CUSTOME_USER) == null || (Struts2Utils.getSession().getAttribute(SystemVariables.CUSTOME_USER) != null && ((Enterprise) Struts2Utils.getSession().getAttribute(SystemVariables.CUSTOME_USER)) .getId() != supply.getCreator().getId())) { return "list"; } } List<Map<String, String>> units = Unit.getInstance().getUnits(); if (supply != null && units != null) { for (int i = 0; i < units.size(); i++) { Map map = units.get(i); if (map != null && map.get("id") != null && map.get("id").toString().equals(supply.getUnit())) { unitname = map.get("name").toString(); break; } } } // 获取SEO关键字 if (supply != null && supply.getCategory() != null) { int level = supply.getCategory().getCategoryLevel().intValue(); String firstName = supply.getCategory().getName(); // 显示在最前面的类别名称 switch (level) { case 1: // 第一级 seoStr = firstName; break; case 2: // 第二级 seoStr = firstName + "," + supply.getCategory().getCategory().getName(); break; case 3: // 第三级 seoStr = firstName + "," + supply.getCategory().getCategory().getName() + "," + supply.getCategory().getCategory().getCategory().getName(); break; case 4: // 第四级 seoStr = firstName + "," + supply.getCategory().getCategory().getName() + "," + supply.getCategory().getCategory().getCategory().getName() + supply.getCategory().getCategory().getCategory().getCategory().getName(); break; default: seoStr = ""; break; } seoStr = supply.getName() + "," + seoStr; } entInfo = entInfoService.getEntInfoByEnterpriseId(supply.getCreator().getId()); HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); clickedKeywordExecute(request); // 将最近浏览过的产品添加到cookie当中 String ids = CookieUtil.setSupplyIdCookies(request, response, supplyId + ""); // 将最近浏览过的产品添加到session当中 List<Long> supplyIds = CookieUtil.getSupplyIdByString(ids); request.getSession().setAttribute(SystemVariables.RECENTLY_BROWSE_SUPPLY, supplyIds); Enterprise ent = supply.getCreator(); Long enterpriseId = ent.getId(); recommends = supplyService.getRecommendSupplies(enterpriseId, 5); // 商品的点击率 int hit = supply.getHit() == null ? 0 : supply.getHit(); supply.setHit(hit + 1); supplyService.update(supply); return "detail"; }