@RequestMapping(value = "/login", method = RequestMethod.POST) public ModelAndView login( HttpSession session, ModelAndView mav, @RequestParam("uid") UserIdentifier uid, @RequestParam("password") String pw) { Member user = GmbPersistenceManager.get(uid); if (uid.toString() == "") { mav.addObject("failureText", "Bitte geben Sie ihren Nutzernamen ein !"); mav.addObject("uidInput", uid.toString()); mav.setViewName("index"); return mav; } if (user != null) { if (pw == "") { mav.addObject("failureText", "Bitte geben Sie ein Passwort ein !"); mav.addObject("uidInput", uid.toString()); mav.setViewName("index"); return mav; } if (user.verifyPassword(pw)) { GmbPersistenceManager.login(user, session); Capability adminCAP = new Capability("admin"); Capability employeeCAP = new Capability("employee"); Capability customerCAP = new Capability("customer"); if (user.hasCapability(adminCAP)) { mav.setViewName("employee/employee"); } else if (user.hasCapability(employeeCAP)) { mav.setViewName("employee/employee"); } else if (user.hasCapability(customerCAP)) { mav.setViewName("customer/customer"); } else { mav.setViewName("notary/notary"); int latest = Lottery.getInstance().getTipManagement().getWeeklyLottoDrawings().size() - 1; mav.addObject( "draw", Lottery.getInstance().getTipManagement().getWeeklyLottoDrawings().get(latest)); mav.addObject("time", Lottery.getInstance().getTimer().getDateTime()); } mav.addObject("currentUser", user); return mav; } else { mav.setViewName("index"); mav.addObject("failureText", "Das eingegebene Passwort ist falsch !"); mav.addObject("uidInput", user.getIdentifier().toString()); return mav; } } mav.setViewName("index"); return mav; }
@RequestMapping("/customerEditSTT") public ModelAndView editSTT( ModelAndView mav, @RequestParam("uid") UserIdentifier uid, @RequestParam("STTid") int ticketId) { Customer currentCustomer = (Customer) GmbPersistenceManager.get(uid); SingleTT stt = (SingleTT) GmbPersistenceManager.get(TipTicket.class, ticketId); mav.addObject("singleTT", stt); mav.addObject("currentUser", currentCustomer); mav.setViewName("customer/tips/editSingleTickets"); return mav; }
@RequestMapping("/customerEditPTT") public ModelAndView editPTT(ModelAndView mav, @RequestParam("uid") UserIdentifier uid) { Customer currentCustomer = (Customer) GmbPersistenceManager.get(uid); mav.addObject("currentUser", currentCustomer); mav.setViewName("customer/tips/editPermaTickets"); return mav; }
@RequestMapping(value = "/customerTips", method = RequestMethod.GET) public ModelAndView customerTips(@RequestParam("uid") UserIdentifier uid) { ModelAndView mav = new ModelAndView(); Customer currentCustomer = (Customer) GmbPersistenceManager.get(uid); mav.setViewName("customer/tips/tip_customerTips"); LinkedList<WeeklyLottoSTT> weeklySTTList = new LinkedList<WeeklyLottoSTT>(); LinkedList<TotoSTT> totoSTTList = new LinkedList<TotoSTT>(); LinkedList<DailyLottoSTT> dailyLottoSTTList = new LinkedList<DailyLottoSTT>(); for (TotoSTT tSTT : currentCustomer.getTotoSTTs()) { if (!tSTT.getTip().getDraw().getEvaluated()) totoSTTList.add(tSTT); } for (DailyLottoSTT dLSTT : currentCustomer.getDailyLottoSTTs()) { if (!dLSTT.getTip().getDraw().getEvaluated()) dailyLottoSTTList.add(dLSTT); } for (WeeklyLottoSTT wLSTT : currentCustomer.getWeeklyLottoSTTs()) { if (!wLSTT.getTip().getDraw().getEvaluated()) weeklySTTList.add(wLSTT); } mav.addObject("weeklySTTList", (weeklySTTList.size() > 0) ? weeklySTTList : null); mav.addObject("totoSTTList", (totoSTTList.size() > 0) ? totoSTTList : null); mav.addObject("dailySTTList", (dailyLottoSTTList.size() > 0) ? dailyLottoSTTList : null); mav.addObject( "weeklyPTTList", (currentCustomer.getWeeklyLottoPTTs().size() > 0) ? currentCustomer.getWeeklyLottoPTTs() : null); mav.addObject( "dailyPTTList", (currentCustomer.getDailyLottoPTTs().size() > 0) ? currentCustomer.getDailyLottoPTTs() : null); mav.addObject("currentUser", currentCustomer); return mav; }
@RequestMapping(value = "/customerTipManagement", method = RequestMethod.GET) public ModelAndView customerTipManagement(@RequestParam("uid") UserIdentifier uid) { ModelAndView mav = new ModelAndView(); mav.addObject("currentUser", GmbPersistenceManager.get(uid)); mav.setViewName("customer/tips/tip_navigation"); return mav; }
@RequestMapping(value = "/changeCustomerUserData", method = RequestMethod.POST) public ModelAndView changeCustomer( ModelAndView mav, @RequestParam("uid") UserIdentifier uid, @RequestParam("vname") String vname, @RequestParam("nname") String nname, @RequestParam("email") String email, @RequestParam("street") String street, @RequestParam("hNumber") String hNumber, @RequestParam("plz") String plz, @RequestParam("city") String city) { Customer currentUser = (Customer) GmbPersistenceManager.get(uid); boolean changeTest = false; if (!vname.equals(currentUser.getMemberData().getFirstName())) { changeTest = true; } if (!nname.equals(currentUser.getMemberData().getLastName())) { changeTest = true; } if (!email.equals(currentUser.getMemberData().getEMail())) { changeTest = true; } if (!street.equals(currentUser.getMemberData().getAdress().getStreetName())) { changeTest = true; } if (!hNumber.equals(currentUser.getMemberData().getAdress().getHouseNumber())) { changeTest = true; } if (!plz.equals(currentUser.getMemberData().getAdress().getPostCode())) { changeTest = true; } if (!city.equals(currentUser.getMemberData().getAdress().getTownName())) { changeTest = true; } if (changeTest) { Adress newAdress = GmbFactory.new_Adress(street, hNumber, plz, city); MemberData newMemberData = GmbFactory.new_MemberData( vname, nname, currentUser.getMemberData().getBirthDate(), currentUser.getMemberData().getPhoneNumber(), email, newAdress); currentUser .sendDataUpdateRequest(newMemberData, "Hello, please accept my update. Thanks.") .accept(); mav.addObject("comment", "Ihr Änderungswunsch wird von einem Mitarbeiter bearbeitet."); } else { mav.addObject("comment", "Sie haben keine Änderungen vorgenommen."); } mav.addObject("currentUser", currentUser); mav.setViewName("customer/accountStuff/editCustomerUserData"); return mav; }
@RequestMapping(value = "/chargingBankAccount", method = RequestMethod.POST) public ModelAndView chargingBankAccount( ModelAndView mav, @RequestParam("uid") UserIdentifier uid, @RequestParam("load") String load) { System.out.println("----loadingBankAccount----"); Customer currentUser = (Customer) GmbPersistenceManager.get(uid); ExternalTransactionRequest currentRequest = currentUser .getBankAccount() .sendExternalTransactionRequest(new CDecimal("-" + load), "druff") .var2; currentRequest.accept(); mav.setViewName("bankingCustomer"); mav.addObject("currentUser", GmbPersistenceManager.get(uid)); return mav; }
@RequestMapping(value = "/cancelEditingCustomer", method = RequestMethod.GET) public ModelAndView cancelEditingCustomer( ModelAndView mav, @RequestParam("uid") UserIdentifier uid) throws UnsupportedEncodingException { uid = GmbDecoder.decodeUTF8String(uid); Customer currentUser = (Customer) GmbPersistenceManager.get(uid); mav.setViewName("customer/customer"); mav.addObject("currentUser", currentUser); return mav; }
@RequestMapping(value = "/editUser", method = RequestMethod.GET) public ModelAndView editUser(ModelAndView mav, @RequestParam("uid") UserIdentifier uid) throws UnsupportedEncodingException { uid = GmbDecoder.decodeUTF8String(uid); Member currentMember = GmbPersistenceManager.get(uid); if (currentMember.getType().name().equals("Customer")) { Customer currentUser = (Customer) GmbPersistenceManager.get(uid); mav.addObject("currentUser", currentUser); mav.addObject("comment", "Führen Sie Ihre Änderungswünsche im entsprechenden Feld aus !"); mav.setViewName("customer/accountStuff/editCustomerUserData"); } else if (currentMember.getType().name().equals("Notary")) { mav.setViewName("editNotary"); mav.addObject("currentUser", GmbPersistenceManager.get(uid)); } else { mav.setViewName("editEmployee"); mav.addObject("currentUser", GmbPersistenceManager.get(uid)); } return mav; }
@RequestMapping(value = "/bankingCustomer", method = RequestMethod.GET) public ModelAndView bankingCustomer(ModelAndView mav, @RequestParam("uid") UserIdentifier uid) throws UnsupportedEncodingException { uid = GmbDecoder.decodeUTF8String(uid); Customer currentUser = (Customer) GmbPersistenceManager.get(uid); // LotteryBankAccount acc = (LotteryBankAccount) // GmbPersistenceManager.get(LotteryBankAccount.class, currentUser.getBankAccount().getId()); mav.setViewName("customer/accountStuff/bankingCustomer"); mav.addObject("currentUser", currentUser); return mav; }
@RequestMapping(value = "/editCustomerRealAccount", method = RequestMethod.GET) public ModelAndView editCustomerRealAccount( ModelAndView mav, @RequestParam("uid") UserIdentifier uid) throws UnsupportedEncodingException { uid = GmbDecoder.decodeUTF8String(uid); Customer currentUser = (Customer) GmbPersistenceManager.get(uid); mav.addObject("currentUser", currentUser); mav.addObject("comment", "Führen Sie Ihre Änderungswünsche im entsprechenden Feld aus !"); mav.setViewName("customer/accountStuff/editCustomerRealAccount"); return mav; }
@RequestMapping(value = "/editCustomerPassword", method = RequestMethod.GET) public ModelAndView editCustomerPassword( ModelAndView mav, @RequestParam("uid") UserIdentifier uid) throws UnsupportedEncodingException { uid = GmbDecoder.decodeUTF8String(uid); Customer currentUser = (Customer) GmbPersistenceManager.get(uid); mav.addObject("currentUser", currentUser); mav.addObject("comment", "Bitte geben Sie Ihr altes und Ihr neues Passwort ein !"); mav.setViewName("customer/accountStuff/editCustomerPassword"); return mav; }
@RequestMapping(value = "/changeCustomerPassword", method = RequestMethod.POST) public ModelAndView changeCustomerPassword( ModelAndView mav, @RequestParam("uid") UserIdentifier uid, @RequestParam("oldPassword") String oldPassword, @RequestParam("newPassword") String newPassword) { Customer currentUser = (Customer) GmbPersistenceManager.get(uid); if ((oldPassword == "" || newPassword == "")) { mav.addObject("comment", "Sie müssen alle Felder Füllen !"); } else if (currentUser.verifyPassword(oldPassword)) { currentUser.changePassword(newPassword); GmbPersistenceManager.update(currentUser); mav.addObject("comment", "Ihr Passwort wurde geändert."); } else { mav.addObject("comment", "Sie haben ein falsches Passwort eingegeben !"); } mav.addObject("currentUser", currentUser); mav.setViewName("customer/accountStuff/editCustomerPassword"); return mav; }
@RequestMapping(value = "/changeCustomerRealAccount", method = RequestMethod.POST) public ModelAndView changeCustomerRealAccount( ModelAndView mav, @RequestParam("uid") UserIdentifier uid, @RequestParam("newBankCode") String newBankCode, @RequestParam("newAccountNumber") String newAccountNumber) { Customer currentUser = (Customer) GmbPersistenceManager.get(uid); boolean changeTest = false; if (!newBankCode.equals(currentUser.getBankAccount().getRealAccountData().getBankCode())) { changeTest = true; } if (!newAccountNumber.equals( currentUser.getBankAccount().getRealAccountData().getAccountNumber())) { changeTest = true; } System.out.println(changeTest); if ((newBankCode == "" || newAccountNumber == "")) { mav.addObject("comment", "Sie müssen alle Felder ausüllen !"); } else if (changeTest) { RealAccountData rad = GmbFactory.new_RealAccountData(newBankCode, newAccountNumber); currentUser .getBankAccount() .sendDataUpdateRequest( GmbFactory.new_RealAccountData(newBankCode, newAccountNumber), "Bitte aendern.") .accept(); mav.addObject("comment", "Ihr Änderungswunsch wird von einem Mitarbeiter bearbeitet."); } else if (!changeTest) { mav.addObject("comment", "Sie haben keine Änderungen vorgenommen."); } mav.addObject("currentUser", currentUser); mav.setViewName("customer/accountStuff/editCustomerRealAccount"); return mav; }
@RequestMapping(value = "/createUser", method = RequestMethod.POST) public ModelAndView createUser( ModelAndView mav, @RequestParam("vname") String vname, @RequestParam("nname") String nname, @RequestParam("uid") UserIdentifier uid, @RequestParam("password") String password, @RequestParam("email") String email, @RequestParam("street") String street, @RequestParam("hNumber") String hNumber, @RequestParam("plz") String plz, @RequestParam("city") String city, @RequestParam("accountNumber") String accountNumber, @RequestParam("bankCode") String bankCode, @RequestParam("age") String age) { if (age.equals(new String("false"))) { mav.setViewName("register"); mav.addObject("vorname", vname); mav.addObject("nachname", nname); mav.addObject("password", password); mav.addObject("uid", uid); mav.addObject("email", email); mav.addObject("street", street); mav.addObject("hNumber", hNumber); mav.addObject("plz", plz); mav.addObject("city", city); mav.addObject("accountNumber", accountNumber); mav.addObject("bankCode", bankCode); mav.addObject("fail", "- Fehler"); mav.addObject( "comment", new String( "Sie müssen mindestens 18 Jahre alt sein um an Gewinnspielen teilnehmen zu können!")); return mav; } // Username schon vorhanden if (GmbPersistenceManager.get(uid) != null) { mav.setViewName("register"); mav.addObject("vorname", vname); mav.addObject("nachname", nname); mav.addObject("password", password); mav.addObject("uid", ""); mav.addObject("email", email); mav.addObject("street", street); mav.addObject("hNumber", hNumber); mav.addObject("plz", plz); mav.addObject("city", city); mav.addObject("accountNumber", accountNumber); mav.addObject("bankCode", bankCode); mav.addObject("uidFail", "fail"); mav.addObject("fail", "- Fehler"); mav.addObject("comment", new String("Die UID wird schon verwendet !")); } else if (this.testeEingabeFehler( vname, nname, uid.getIdentifier(), password, email, street, hNumber, plz, city, accountNumber, bankCode)) { mav.setViewName("register"); mav.addObject("vorname", vname); mav.addObject("nachname", nname); mav.addObject("password", password); mav.addObject("uid", uid.toString()); mav.addObject("email", email); mav.addObject("street", street); mav.addObject("hNumber", hNumber); mav.addObject("plz", plz); mav.addObject("city", city); mav.addObject("accountNumber", accountNumber); mav.addObject("bankCode", bankCode); mav.addObject("fail", "- Fehler"); mav.addObject("comment", new String("Alle Felder fuellen !!!")); } else { Adress adress = GmbFactory.new_Adress(street, hNumber, plz, city); MemberData memberData = GmbFactory.new_MemberData( vname, nname, new DateTime(1970, 10, 16, 0, 0), "0735643", email, adress); RealAccountData rad = GmbFactory.new_RealAccountData(bankCode, accountNumber); LotteryBankAccount lba = GmbFactory.new_LotteryBankAccount(rad); Customer user = new Customer(uid.toString(), password, memberData, lba); Lottery.getInstance().getMemberManagement().addMember(user); lba.setOwner(user); user.getBankAccount().setCredit(new CDecimal(5000)); user.activateAccount(); mav.setViewName("redirect:/"); } return mav; }
@RequestMapping("/logout") public String logout(HttpSession session) { GmbPersistenceManager.logout(session); return "redirect:/"; }