Jordan Mason
4 years ago
5 changed files with 177 additions and 0 deletions
@ -0,0 +1,26 @@ |
|||||||
|
{ |
||||||
|
// Use IntelliSense to learn about possible attributes. |
||||||
|
// Hover to view descriptions of existing attributes. |
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 |
||||||
|
"version": "0.2.0", |
||||||
|
"configurations": [ |
||||||
|
{ |
||||||
|
"command": "mvn exec:java", |
||||||
|
"name": "Run mvn exec", |
||||||
|
"request": "launch", |
||||||
|
"type": "node-terminal" |
||||||
|
}, |
||||||
|
|
||||||
|
{ |
||||||
|
"type": "java", |
||||||
|
"name": "Debug (Launch) - Current File", |
||||||
|
"request": "launch", |
||||||
|
"mainClass": "${file}" |
||||||
|
}, |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
] |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
package MTGClone.controller; |
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller; |
||||||
|
import org.springframework.ui.Model; |
||||||
|
import org.springframework.ui.ModelMap; |
||||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||||
|
|
||||||
|
import MTGClone.Card; |
||||||
|
import MTGClone.SQLDriver; |
||||||
|
import java.util.ArrayList; |
||||||
|
|
||||||
|
@Controller |
||||||
|
public class CardController { |
||||||
|
@GetMapping({"/card"}) |
||||||
|
public String hello(Model model) { |
||||||
|
ArrayList<Card> allCards = (new SQLDriver()).getAllCards(); |
||||||
|
model.addAttribute("allcards", allCards); |
||||||
|
|
||||||
|
return "card"; |
||||||
|
} |
||||||
|
|
||||||
|
@PostMapping({"/card"}) |
||||||
|
public String greet(@RequestParam("cardname") String cardname, @RequestParam("manacost") int manacost, |
||||||
|
@RequestParam("power") int power, @RequestParam("toughness") int toughness, @RequestParam("description") String description, @RequestParam("creaturetype") String creaturetype, |
||||||
|
ModelMap modelMap) { |
||||||
|
Card newCard = new Card(cardname, manacost, power, toughness, description, "", creaturetype); |
||||||
|
SQLDriver d = new SQLDriver(); |
||||||
|
d.insertCard(newCard); |
||||||
|
return "card"; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,67 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> |
||||||
|
<html lang="en"> |
||||||
|
<head> |
||||||
|
<style> |
||||||
|
.container { |
||||||
|
width: 350px; |
||||||
|
clear: both; |
||||||
|
} |
||||||
|
|
||||||
|
.container input { |
||||||
|
width: 100%; |
||||||
|
clear: both; |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
</style> |
||||||
|
<meta charset="UTF-8"> |
||||||
|
<title>Hello ${name}!</title> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
<h2 class="hello-title">Hello ${name}!</h2> |
||||||
|
<div class="container"> |
||||||
|
|
||||||
|
<form action="/card" method="post"> |
||||||
|
<label for="cardname">Card Name:</label> |
||||||
|
<input type="text" id="cardname" name="cardname"><br> |
||||||
|
<label for="manacost">Mana Cost:</label> |
||||||
|
<input type="text" id="manacost" name="manacost"><br> |
||||||
|
<label for="power">Power:</label> |
||||||
|
<input type="text" id="power" name="power"><br> |
||||||
|
<label for="toughness">Toughness:</label> |
||||||
|
<input type="text" id="toughness" name="toughness"><br> |
||||||
|
<label for="description">Description:</label> |
||||||
|
<input type="text" id="description" name="description"><br> |
||||||
|
<label for="creaturetype">Creature Type:</label> |
||||||
|
<input type="text" id="creaturetype" name="creaturetype"><br> |
||||||
|
<br> <input style="width:30%;display:block;margin:0 auto;" type="submit" value="Submit"> |
||||||
|
</form> |
||||||
|
|
||||||
|
</div> |
||||||
|
<table style="width:100%"> |
||||||
|
<tr> |
||||||
|
<th>Card Name</th> |
||||||
|
<th>Mana Cost</th> |
||||||
|
<th>Power</th> |
||||||
|
<th>Toughness</th> |
||||||
|
<th>Description</th> |
||||||
|
<th>Creature Type</th> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<c:if test="${not empty allcards}"> |
||||||
|
|
||||||
|
<c:forEach var="listValue" items="${allcards}"> |
||||||
|
<td>${listValue.cardName}</td> |
||||||
|
<td>${listValue.manaCost}</td> |
||||||
|
<td>${listValue.power}</td> |
||||||
|
<td>${listValue.toughness}</td> |
||||||
|
<td>${listValue.description}</td> |
||||||
|
<td>${listValue.creatureType}</td> |
||||||
|
</c:forEach> |
||||||
|
|
||||||
|
</c:if> |
||||||
|
</tr> |
||||||
|
</table> |
||||||
|
</body> |
||||||
|
</html> |
Loading…
Reference in new issue