-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deny #1
base: master
Are you sure you want to change the base?
Deny #1
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip | ||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?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.6.7</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
<groupId>com.Deny</groupId> | ||
<artifactId>MyMentorProject</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>MyMentorProject</name> | ||
<description>Demo project for Spring Boot</description> | ||
<properties> | ||
<java.version>11</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-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> | ||
|
||
|
||
|
||
<dependency> | ||
<groupId>log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
<version>1.2.17</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.Deny.MyMentorProject.Controllers; | ||
|
||
import com.Deny.MyMentorProject.Services.UserService; | ||
import com.Deny.MyMentorProject.User.User; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
|
||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class UserMainController { | ||
|
||
@Autowired | ||
UserService userService; | ||
|
||
public UserMainController(UserService userService) { | ||
this.userService = userService; | ||
} | ||
|
||
@GetMapping | ||
public String helloMessage() { | ||
|
||
return userService. helloMessage(); | ||
} | ||
|
||
@GetMapping("/greetUser") | ||
public String helloUser() { | ||
|
||
return "hello " + userService.helloUser(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The point of this feature was to be able to accept a name and greet that person. You should not hard-code Joe into your app. Have it work for any name the consumer passes to you. |
||
} | ||
@PostMapping("greetings" ) | ||
public String messageToReturn(@RequestBody String requestMessage ){ | ||
System.out.println("requestMessage = " + requestMessage); | ||
return userService.messageToReTurn( requestMessage); | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.Deny.MyMentorProject; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class MyMentorProjectApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(MyMentorProjectApplication.class, args); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.Deny.MyMentorProject.Services; | ||
|
||
import com.Deny.MyMentorProject.User.User; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class UserService { | ||
|
||
@Autowired | ||
Denywiryk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
User user; | ||
|
||
|
||
public UserService(User user) { this.user = user; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. User is a model class that frequently changes so it should not be injected into this class. Instead you would want it to be an input to a method. |
||
} | ||
|
||
|
||
public String helloMessage() { | ||
return "Hello My Friend !";} | ||
Denywiryk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public String helloUser() { | ||
user.setName("Joe"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of setting the name to Joe, pass in the name in the method |
||
return "hello " + user.getName(); | ||
} | ||
public String messageToReTurn(String messagerequest) { | ||
|
||
String reply = ""; | ||
|
||
if (messagerequest ==""){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feature 3 should be a random greeting. You can create a list of the statements below and call a randomIndex using java.util.Random. Hello {User}! |
||
reply = "hello " + user.getName(); | ||
} | ||
else if (messagerequest ==" happy Message") { | ||
reply = "Hey " + user.getName() + " nice to see you here !!"; | ||
} | ||
else if (messagerequest =="welcome me") { | ||
|
||
reply = user.getName() +" welcome back !!"; | ||
} else if (messagerequest=="bye message") { | ||
reply= "Have a splendid day "+user.getName(); | ||
|
||
} | ||
System.out.println("messagerequest = " + messagerequest); | ||
return reply; | ||
} | ||
|
||
|
||
} | ||
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.