Took a year to do a network disk download site, interested friends can see the name of the station: to the rotary disk network which has a demand is to simulate baidu network disk to invite friends to register functions, thought for a long time as expected “god pays off “, finally sort out a train of thought, and attach the code, hope you netizens a lot of ridicule. My idea is to invite friends with a unique string UUID within the scope of the network. The inviter gives a status bit 1 to represent the inviter, and binds a unique UUID to him. The invitee gives an identification bit of 0 to represent the invitee. If he/she successfully registers, he/she can obtain a UUID according to the invitation link to search the database and find the invitee. After finding the UUID, he/she will be given corresponding credits.
public String invite(){ int invteOrBeInted=1; String username=null; String username=null; String temp=getParameter("username"); if(temp! =null){ try { username = new String(temp.getBytes("ISO-8859-1"), "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } //username=((User)session.get(CodeConst.USERINSESSION)).getUsername(); If (username==null){message=" No permission to invite the user "; return ERROR; } RegisterService registerService = ServiceFactory.getRegisterService(); UserDao userDao=null; try { userDao = registerService.getUserDao(); } catch (Exception e1) { e1.printStackTrace(); } @SuppressWarnings("rawtypes") java.util.List list=null; User u=null; try { list=userDao.findByUserName(username); } catch (Exception e) { e.printStackTrace(); } if(list! =null&&list.size()>0){ u=(User)list.get(0); } if(u.getInviteCode()! =null &&u.getInvitedOrbeinvited ()==1){// InviteCode =u.getInviteCode(); } else{ inviteCode=UUID.randomUUID().toString(); } String goodNews=" share disk, download disk, here is to go to disk net. Click the link below to register, massive network disk resources to share with you "; String url=goodNews+getBase()+"registerManager/inviteRegister.action? inviteCode="+inviteCode; GetTpRequest ().setAttribute("url",url); getTpRequest ().setAttribute("url",url); / / sent to the front desk try {registerService. UpdateInviteMan (username, inviteCode, invteOrBeInted); } catch (Exception e) {e.printStackTrace();} catch (Exception e) {e.printStackTrace(); } return SUCCESS; }
Technology is to share, open source, to turn the table do not stingy any technology, welcome to follow Weibo or WeChat, communication at any time. I set up a QQ group as the official group of the turntable network, the number is not much now, if you are interested in it, a number of fans to turntable more than a lively, QQ group number: 512245829