Skip to content
Snippets Groups Projects
Commit 6a0f520b authored by John Watkins's avatar John Watkins
Browse files

dynamically load shops from db

parent 9b201af4
Branches
No related tags found
4 merge requests!56tags will be saved to userFavTags table (needs user ID of current logged in user),!22Branch Update,!19created signUp page and form that sends data to controller,!18Finished issueThree
......@@ -19,6 +19,7 @@ import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name="shops")
public class Shops {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
......
......@@ -15,7 +15,7 @@ public interface ShopsRepo extends JpaRepository<Shops, Long> {
* FindAll method
* @return list of Shops found
*/
List<Shops> findAll();
// List<Shops> findAll();
/**
* Save method
......
package com.example.clientproject.web.controllers;
import com.example.clientproject.data.shops.ShopsRepo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class HomeController {
@GetMapping
public final ShopsRepo shopsRepo;
public HomeController(ShopsRepo shopsRepo){
this.shopsRepo = shopsRepo;
}
@GetMapping("/")
public String index(Model model){
System.out.println(shopsRepo.findAll());
model.addAttribute("shops", shopsRepo.findAll());
return "index";
}
......
server.port=9090
spring.datasource.url=jdbc:mariadb://localhost:3306/charity_giving?useSSL=false&requireSSL=false&serverTimezone=UTC
spring.datasource.url=jdbc:mariadb://localhost:3306/mydb?useSSL=false&requireSSL=false&serverTimezone=UTC
#set credentials explicitly
spring.datasource.username=root
......
spring.thymeleaf.cache=false
spring.datasource.url=jdbc:mariadb://localhost:3306/mydb?useSSL=false&requireSSL=false&serverTimezone=UTC
#set credentials explicitly
spring.datasource.username=root
spring.datasource.password=comsc
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
\ No newline at end of file
This diff is collapsed.
......@@ -72,7 +72,7 @@ def namePopulator(amount, userType):
# print(current_user_id)
# print(current_user_id+amount)
stringInsert = str(current_user_id) + ',' + '1' + ',' + str(userType)
insertArray.append(createInsert(stringInsert, "UserPermissions", "User_ID, Shop_ID, Admin_Type_Id"))
insertArray.append(createInsert(stringInsert, "user_permissions", "User_ID, Shop_ID, Admin_Type_Id"))
current_user_id = current_user_id + 1
return insertArray
......
......@@ -196,15 +196,15 @@ CREATE TABLE IF NOT EXISTS `mydb`.`Reward_Shop_Links` (
CREATE TABLE IF NOT EXISTS `mydb`.`User_Shop_Links` (
`User_Shop_Link_Id` INT NOT NULL AUTO_INCREMENT,
`Shop_Id` INT NOT NULL,
`Users_User_Id` INT NOT NULL,
PRIMARY KEY (`User_Shop_Link_Id`, `Shop_Id`, `Users_User_Id`),
`User_Id` INT NOT NULL,
PRIMARY KEY (`User_Shop_Link_Id`, `Shop_Id`, `User_Id`),
CONSTRAINT `fk_User_Shop_Links_Shops1`
FOREIGN KEY (`Shop_Id`)
REFERENCES `mydb`.`Shops` (`Shop_Id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_User_Shop_Links_Users1`
FOREIGN KEY (`Users_User_Id`)
FOREIGN KEY (`User_Id`)
REFERENCES `mydb`.`Users` (`User_Id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
......
nav{
background: rgb(1,126,255);
background: linear-gradient(90deg, rgba(1,126,255,1) 0%, rgba(0,76,255,1) 100%);
}
.nav_profile_img{
background-position: center;
background-repeat: no-repeat;
background-size: cover;
height: 40px;
width: 40px;
margin: 5px;
border-radius: 100px;
}
.navbar-link,.navbar-start>.navbar-item{
color: white;
}
.navbar-link::after{
border-color: white!important;
}
.navbar-link.is-active, .navbar-link:focus, .navbar-link:focus-within, .navbar-link:hover, a.navbar-item.is-active, a.navbar-item:focus, a.navbar-item:focus-within, a.navbar-item:hover {
background-color: transparent;
color: #fffbebBB;
}
@media screen and (min-width: 1024px) {
.navbar-item.has-dropdown.is-active .navbar-link, .navbar-item.has-dropdown:focus .navbar-link, .navbar-item.has-dropdown:hover .navbar-link {
background-color: transparent;
}
}
......@@ -68,13 +68,9 @@
</div>
<div class="container is-full-width is-flex is-justify-content-center is-align-items-center is-flex-wrap-wrap">
<!--Business Containers-->
<div th:replace="fragments/business_card.html :: business_card(
title='Cafe Not so',
reward_text='Free coffee at 6 stamps',
reward_amount=4,
img_path='imgs/coffee.jpg'
)"></div>
<div th:each="shop: ${shops}" th:include="fragments/business_card.html :: business_card"
th:with="title=${shop.shopName}, reward_text='Free coffee at 6 stamps', reward_amount=4,
img_path='imgs/coffee.jpg'"></div>
</div>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment