Skip to content

Java web dynamic project for finance managing of city automatic bicycle rent.

License

Notifications You must be signed in to change notification settings

babroval/bike-rent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alt text

Bike Rent

Automatic Bicycle Rent For City

To use one of the many bikes on bike stations of the city, the customer needs to register on the site, which lists personal data (name, passport number, credit card number, etc.). The site can also be viewed online information about the number of bikes in parking lots. To use the rental service, you need to have a balance of bank card not less than 100$.

Conditions:

1 - the funds will be blocked on the client's account since the beginning of the rental,

2 - in case of timely return bike to any rent station, blocked funds will be available again to the client, while part of the funds may be subject to write-off according to the rates for services.

MIT licensed

	@RequestMapping(value = { "/order-{numPoint}" }, method = RequestMethod.GET)
	public String order(@PathVariable Integer numPoint, ModelMap model) {
		Point point = pointService.getPointByNum(numPoint);
		model.addAttribute("point", point);
		Integer vacant = point.getSlots() - point.getFreeBikes();
		if (vacant < 0) {
			vacant = 0;
		}
		List<String> vacantSlots = new ArrayList<String>();
		for (int i = 0; i < vacant; i++) {
			vacantSlots.add("VACANT SLOT");
		}
		model.addAttribute("vacantSlots", vacantSlots);
		List<Bike> bikes = bikeService.getBikesByPoint(numPoint);
		model.addAttribute("bikes", bikes);
		String login = (String) session.getAttribute("loggedUser");
		Order prossesingOrder = orderService.getProssesingOrderByLogin(login);
		if (prossesingOrder == null) {
			Order order = new Order();
			model.addAttribute("order", order);
			return "order";
		}
		model.addAttribute("order", prossesingOrder);
		return "order";
	}
	@RequestMapping(value = { "/order-{numPoint}" }, method = RequestMethod.POST)
	public String order(Order order, @PathVariable Integer numPoint,
						BindingResult result, ModelMap model) {
		if (order.getId() == null) {
			String login = (String) session.getAttribute("loggedUser");
			orderService.openOrder(order, numPoint, login);
			Order prossesingOrder = orderService.getProssesingOrderByLogin(login);
			model.addAttribute("success", "Your order \"" 
				  + prossesingOrder.getId() 
				  + "\" confirmed successfully.");
			return "orderSuccess";
		}
		orderService.closeOrder(order, numPoint);
		Order completeOrder = orderService.getOrderById(order.getId());
		model.addAttribute("success", "Your order \"" 
						  + completeOrder.getId() + "\" completed successfully."
						  + " Total cost is " + completeOrder.getTotalCost());
		return "orderSuccess";
	}

Table of Contents

Requirements

Bike Rent requires the following to run:

Usage

Bike Rent is easiest to use with Eclipse IDE:
File -> Import -> Git -> Projects From Git > URI

To create a database, execute script from file https://github.com/babroval/bike-rent/blob/master/src/main/resources/db_bike_script.sql You can do it for example from MySQL Command Line Client: mysql> source C:/db_bike_script.sql

Contributing

To contribute to Bike Rent, clone this repo locally and
commit your code on a separate branch.

License

Bike Rent is licensed under the MIT license.

About

Java web dynamic project for finance managing of city automatic bicycle rent.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published