-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build tool maven, spring boot framework in combination with a databas…
…e mysql added
- Loading branch information
Showing
29 changed files
with
462 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com; | ||
|
||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class ApplicationStartDrinkMachine { | ||
public static void main(String[] args) { | ||
SpringApplication.run(ApplicationStartDrinkMachine.class, args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.controller; | ||
|
||
import com.service.IDrinkService; | ||
import com.model.Drink; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
|
||
import java.util.List; | ||
|
||
@Controller | ||
public class ViewsController { | ||
|
||
@Autowired | ||
private IDrinkService drinkService; | ||
|
||
@GetMapping("/drinks") | ||
public String findDrinks(Model model) { | ||
|
||
List<Drink> drinks = (List<Drink>) drinkService.findAll(); | ||
|
||
model.addAttribute("drinks", drinks); | ||
|
||
return "showDrinks"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.exceptions; | ||
|
||
public class InputContainsException extends Exception { | ||
|
||
public InputContainsException() { | ||
} | ||
|
||
public InputContainsException(String message) { | ||
super(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.model; | ||
|
||
import com.interfaces_and_enum.EnumCoinValue; | ||
|
||
public class Coin { | ||
|
||
EnumCoinValue coinValue; | ||
|
||
/** | ||
* @param coinValue represents the real coin value. | ||
*/ | ||
public Coin(EnumCoinValue coinValue) { | ||
this.coinValue = coinValue; | ||
} | ||
|
||
public EnumCoinValue getCoinValue() { | ||
return coinValue; | ||
} | ||
|
||
public void setCoinValue(EnumCoinValue coinValue) { | ||
this.coinValue = coinValue; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.model; | ||
|
||
import com.interfaces_and_enum.AbstractProductType; | ||
|
||
import javax.persistence.*; | ||
|
||
import java.util.Objects; | ||
|
||
import static javax.persistence.GenerationType.AUTO; | ||
|
||
@Entity | ||
@Table(name = "drinks") | ||
public class Drink extends AbstractProductType { | ||
@Id | ||
@GeneratedValue(strategy = AUTO) | ||
protected long id; | ||
|
||
public Drink(long id, String name, double price) { | ||
super(name, price); | ||
this.id = id; | ||
} | ||
|
||
public Drink() { | ||
super(); | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int hash = 7; | ||
hash = 79 * hash + Objects.hashCode(this.id); | ||
hash = 79 * hash + Objects.hashCode(this.name); | ||
hash = (int) ((79 * hash) + this.price); | ||
return hash; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
final StringBuilder sb = new StringBuilder("drink{"); | ||
sb.append("id=").append(id); | ||
sb.append(", name='").append(name).append('\''); | ||
sb.append(", price=").append(price); | ||
sb.append('}'); | ||
return sb.toString(); | ||
} | ||
} |
Oops, something went wrong.