Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
first commit
- Loading branch information
Mohammed Fakhrulddin
committed
Mar 27, 2021
0 parents
commit eb16e9178f02c860c094274480ea2d100a7b38e8
Showing
51 changed files
with
1,637 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="test" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" path="target/generated-sources/annotations"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="ignore_optional_problems" value="true"/> | ||
<attribute name="m2e-apt" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="ignore_optional_problems" value="true"/> | ||
<attribute name="m2e-apt" value="true"/> | ||
<attribute name="test" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
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,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>TrainingEvent</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
<filteredResources> | ||
<filter> | ||
<id>1615413629282</id> | ||
<name></name> | ||
<type>30</type> | ||
<matcher> | ||
<id>org.eclipse.core.resources.regexFilterMatcher</id> | ||
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments> | ||
</matcher> | ||
</filter> | ||
</filteredResources> | ||
</projectDescription> |
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,5 @@ | ||
eclipse.preferences.version=1 | ||
encoding//src/main/java=UTF-8 | ||
encoding//src/main/resources=UTF-8 | ||
encoding//src/test/java=UTF-8 | ||
encoding/<project>=UTF-8 |
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,2 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.apt.aptEnabled=false |
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,10 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore | ||
org.eclipse.jdt.core.compiler.processAnnotations=disabled | ||
org.eclipse.jdt.core.compiler.release=disabled | ||
org.eclipse.jdt.core.compiler.source=1.8 |
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,4 @@ | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
resolveWorkspaceProjects=true | ||
version=1 |
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,54 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.4.3</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
<groupId>com.training.event</groupId> | ||
<artifactId>TrainingEvent</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>TrainingEvent</name> | ||
<description>Demo project for Spring Boot</description> | ||
<properties> | ||
<java.version>8</java.version> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jpa</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-thymeleaf</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
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,13 @@ | ||
package com.training.event; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class TrainingEventApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(TrainingEventApplication.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,164 @@ | ||
package com.training.event.controller; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.ModelAttribute; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
import com.training.event.model.Attendee; | ||
import com.training.event.model.Training; | ||
import com.training.event.model.User; | ||
import com.training.event.service.AttendeeService; | ||
import com.training.event.service.TrainingService; | ||
import com.training.event.service.UserService; | ||
|
||
@Controller | ||
public class AppController { | ||
|
||
@Autowired | ||
TrainingService trainingService; | ||
|
||
@Autowired | ||
AttendeeService attendeeService; | ||
|
||
@Autowired | ||
UserService userService; | ||
|
||
@RequestMapping("/") | ||
public String index(Model model) { | ||
List<Training> trainings = trainingService.list(); | ||
model.addAttribute("trainings", trainings); // index page | ||
return "index"; // home page | ||
} | ||
|
||
@RequestMapping("signup") | ||
public String signup(Model model) { | ||
User user = new User(); | ||
model.addAttribute("user", user); | ||
return "signup"; | ||
} | ||
|
||
@RequestMapping("signin") | ||
public String signin(Model model) { | ||
User user = new com.training.event.model.User(); | ||
model.addAttribute("user", user); | ||
return "signin"; // home page | ||
} | ||
|
||
@RequestMapping("add-training/{userId}") | ||
public String addTraining(Model model, @PathVariable(name = "userId") Long userId) { | ||
Training training = new Training(); | ||
training.setUserId(userId); | ||
model.addAttribute("training", training); | ||
model.addAttribute("user", userService.getUserById(userId)); | ||
return "add_training"; | ||
} | ||
|
||
@RequestMapping("register-training/{trainingId}") | ||
public String registerTraining(Model model, @PathVariable(name = "trainingId") Long trainingId) { | ||
Attendee attendee = new Attendee(); | ||
attendee.setTrainingId(trainingId); | ||
model.addAttribute("attendee", attendee); | ||
return "register-training"; | ||
} | ||
|
||
@RequestMapping("/user/register") | ||
public String register(@ModelAttribute("user") User user) { | ||
userService.register(user); | ||
return "signin"; | ||
} | ||
|
||
@RequestMapping("/user/login") | ||
public String login(Model model, @ModelAttribute("user") User user) { | ||
User uu = userService.login(user.getUsername(), user.getPassword()); | ||
if (uu != null) { | ||
List<Training> trainings = trainingService.getUserTraining(uu); | ||
model.addAttribute("trainings", trainings); // index page | ||
model.addAttribute("user", uu); | ||
return "home"; | ||
} | ||
return "redirect:/signin"; | ||
} | ||
|
||
@RequestMapping("/training/save") | ||
public String saveTraining(Model model, @ModelAttribute("training") Training training) { | ||
User user = userService.getUserById(training.getUserId()); | ||
training.setCreatedBy(user); | ||
trainingService.save(training); | ||
List<Training> trainings = trainingService.getUserTraining(user); | ||
model.addAttribute("trainings", trainings); // index page | ||
model.addAttribute("user", user); // index page | ||
return "home"; | ||
} | ||
|
||
@RequestMapping("/training/register") | ||
public String registerTraining(Model model, @ModelAttribute("attendee") Attendee attendee) { | ||
Training training = trainingService.get(attendee.getTrainingId()); | ||
attendee.setTraining(training); | ||
attendeeService.save(attendee); | ||
List<Training> trainings = trainingService.list(); | ||
model.addAttribute("trainings", trainings); // index page | ||
return "redirect:/"; | ||
} | ||
|
||
@RequestMapping("/logout") | ||
public String logout(Model model) { | ||
List<Training> trainings = trainingService.list(); | ||
model.addAttribute("trainings", trainings); // index page | ||
return "index"; | ||
} | ||
|
||
@RequestMapping("training-attendee/{trainingId}") | ||
public String getTrainingAttendees(Model model, @PathVariable(name = "trainingId") Long trainingId) { | ||
Training training = trainingService.get(trainingId); | ||
List<Attendee> attendees = attendeeService.getTrainingAttendees(training); | ||
model.addAttribute("attendees", attendees); | ||
return "training-attendee"; | ||
} | ||
|
||
@RequestMapping("delete-training/{trainingId}") | ||
public String deleteTraining(Model model, @PathVariable(name = "trainingId") Long trainingId) { | ||
Training training = trainingService.get(trainingId); | ||
List<Attendee> attendees = attendeeService.getTrainingAttendees(training); | ||
|
||
if (attendees != null) { | ||
for (Attendee a : attendees) { | ||
attendeeService.delete(a); | ||
} | ||
} | ||
Long userId = training.getCreatedBy().getId(); | ||
trainingService.deletedTraining(trainingId); | ||
User user = userService.getUserById(userId); | ||
List<Training> trainings = trainingService.getUserTraining(user); | ||
model.addAttribute("trainings", trainings); // index page | ||
model.addAttribute("user", user); // index page | ||
return "home"; | ||
} | ||
|
||
|
||
@RequestMapping("training-edit/{trainingId}") | ||
public String trainingEdit(Model model, @PathVariable(name = "trainingId") Long trainingId) { | ||
Training training = trainingService.get(trainingId); | ||
model.addAttribute("training", training); | ||
return "edit_training"; | ||
} | ||
|
||
@RequestMapping("edit-training") | ||
public String editTraining(Model model, @ModelAttribute("training") Training training) { | ||
Training train = trainingService.get(training.getId()); | ||
train.setTitle(training.getTitle()); | ||
train.setConductedBy(training.getConductedBy()); | ||
train.setDate(training.getDate()); | ||
train.setDuraion(training.getDuraion()); | ||
trainingService.save(train); | ||
User user = userService.getUserById(train.getCreatedBy().getId()); | ||
List<Training> trainings = trainingService.getUserTraining(user); | ||
model.addAttribute("trainings", trainings); // index page | ||
model.addAttribute("user", user); // index page | ||
return "home"; | ||
} | ||
} |
Oops, something went wrong.