Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • d1656298/client-project
  • d1634883/client-project
2 results
Show changes
Commits on Source (17)
Showing
with 241 additions and 2 deletions
......@@ -24,14 +24,15 @@ repositories {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.mariadb.jdbc:mariadb-java-client:2.1.2'
compileOnly 'org.projectlombok:lombok'
testImplementation 'org.projectlombok:lombok:1.18.28'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.springframework.boot:spring-boot-starter-validation'
// implementation 'org.springframework.boot:spring-boot-starter-jdbc'
// implementation 'org.mariadb.jdbc:mariadb-java-client:2.1.2'
}
tasks.named('bootBuildImage') {
......
File added
package Team5.SmartTowns.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;
import java.util.*;
@Controller
public class DatabaseController {
@Autowired
private UserRepository userRepository;
@Autowired
private locationRepository locationRepository;
@Autowired
private trailsRepository trailsRepository;
@GetMapping("/userList")
public ModelAndView userList() {
ModelAndView mav = new ModelAndView("towns/userData");
List<user> users = userRepository.getAllUsers();
mav.addObject("users", users);
return mav;
}
@GetMapping("/trailList")
public ModelAndView trailList() {
ModelAndView mav1 = new ModelAndView("towns/trailsData");
List<trail> trail = trailsRepository.getAllTrails();
mav1.addObject("trails", trail);
return mav1;
}
@GetMapping("locationList")
public ModelAndView locationList(){
ModelAndView mav2 = new ModelAndView("towns/locationData");
List<location> locations = locationRepository.getAllLocation();
mav2.addObject("location", locations);
return mav2;
}
}
//Holds users data repository
package Team5.SmartTowns.Data;
import java.util.List;
public interface UserRepository {
List<user> getAllUsers();
}
//Implements the users repository using JDBC
package Team5.SmartTowns.Data;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class UserRepositoryJDBC implements UserRepository{
private JdbcTemplate jdbc;
private RowMapper<user> userMapper;
public UserRepositoryJDBC(JdbcTemplate aJdbc){
this.jdbc = aJdbc;
setuserMapper();
}
private void setuserMapper(){
userMapper = (rs, i) -> new user(
rs.getInt("userID"),
rs.getString("name")
);
}
@Override
public List<user> getAllUsers(){
String sql= "SELECT * FROM users";
return jdbc.query(sql, userMapper);
}
}
//Holds variable data for the locations table
package Team5.SmartTowns.Data;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class location {
private int locationID;
private String name;
}
//Holds locations data repository
package Team5.SmartTowns.Data;
import java.util.List;
public interface locationRepository {
List<location> getAllLocation();
}
//Implements the locations repository using JDBC
package Team5.SmartTowns.Data;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class locationRepositoryJDBC implements locationRepository {
private JdbcTemplate jdbc;
private RowMapper<location> locationMapper;
public locationRepositoryJDBC(JdbcTemplate aJdbc) {
this.jdbc = aJdbc;
setlocationMapper();
}
private void setlocationMapper(){
locationMapper = (rs, i) -> new location(
rs.getInt("locationID"),
rs.getString("name")
);
}
public List<location> getAllLocation(){
String sql= "SELECT * FROM locations";
return jdbc.query(sql, locationMapper);
}
}
//Holds variable data for the trails table
package Team5.SmartTowns.Data;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class trail {
private int trailsId;
private String name;
}
//Holds trails data repository
package Team5.SmartTowns.Data;
import java.util.List;
public interface trailsRepository {
List<trail> getAllTrails();
}
//Implements the trails repository using JDBC
package Team5.SmartTowns.Data;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class trailsRepositoryJDBC implements trailsRepository{
private JdbcTemplate jdbc;
private RowMapper<trail> trailMapper;
public trailsRepositoryJDBC(JdbcTemplate aJdbc){
this.jdbc = aJdbc;
settrailsMapper();
}
private void settrailsMapper(){
trailMapper = (rs, i) -> new trail(
rs.getInt("trailID"),
rs.getString("name")
);
}
public List<trail> getAllTrails(){
String sql= "SELECT * FROM trails";
return jdbc.query(sql, trailMapper);
}
}
//Holds variable data for the users table
package Team5.SmartTowns.Data;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class user {
private int userId;
private String name;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>QR Camera</title>
</head>
<body>
</body>
</html>
\ No newline at end of file
spring.datasource.url=jdbc:mariadb://localhost:3306/towns
spring.datasource.username=root
spring.datasource.password=comsc
spring.sql.init.mode=always
delete from users;
insert into users (userID, Name) value ('1', 'Hannah');
insert into users (userID, Name) value ('2', 'Nigel');
delete from trails;
insert into trails (trailID, Name) value ('1', 'Caerphilly Coffee Trail');
insert into trails (trailID, Name) value ('2', 'Penarth Dragon Trail');
delete from locations;
insert into locations (locationID, Name) value ('1', 'Caerphilly');
insert into locations (locationID, Name) value ('2', 'Penarth');
\ No newline at end of file
drop table if exists trails;
create table if not exists trails
(
trailID bigint auto_increment primary key,
name varchar(128)
) engine=InnoDB;
drop table if exists locations;
create table if not exists locations
(
locationID bigint auto_increment primary key,
name varchar(128)
) engine=InnoDB;
drop table if exists users;
create table if not exists users
(
userID bigint auto_increment primary key,
name varchar(128)
) engine=InnoDB;
\ No newline at end of file
src/main/resources/static/images/Facebook.png

5.53 KiB | W: 0px | H: 0px

src/main/resources/static/images/Facebook.png

54.5 KiB | W: 0px | H: 0px

src/main/resources/static/images/Facebook.png
src/main/resources/static/images/Facebook.png
src/main/resources/static/images/Facebook.png
src/main/resources/static/images/Facebook.png
  • 2-up
  • Swipe
  • Onion skin
src/main/resources/static/images/Instagram.jpg

7.69 KiB | W: 0px | H: 0px

src/main/resources/static/images/Instagram.jpg

173 KiB | W: 0px | H: 0px

src/main/resources/static/images/Instagram.jpg
src/main/resources/static/images/Instagram.jpg
src/main/resources/static/images/Instagram.jpg
src/main/resources/static/images/Instagram.jpg
  • 2-up
  • Swipe
  • Onion skin
src/main/resources/static/images/LinkedIn.jpg

34.7 KiB