Skip to content
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

added fw20_882_Day-2 #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions VentureTrip/bin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>


<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
Expand All @@ -45,16 +50,21 @@
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springdoc/springdoc-openapi-ui -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.13</version>
</dependency>


</dependencies>

<build>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
13 changes: 13 additions & 0 deletions VentureTrip/bin/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
#changing the server port
server.port=8088
#db specific properties
spring.datasource.url=jdbc:mysql://localhost:3306/ventureDB
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=root

#ORM s/w specific properties
spring.jpa.hibernate.ddl-auto=create
spring.jpa.show-sql=true

#Swagger specific properties
spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER
21 changes: 14 additions & 7 deletions VentureTrip/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@
<java.version>17</java.version>
</properties>
<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springdoc/springdoc-openapi-ui -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.13</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
Expand Down Expand Up @@ -57,13 +70,7 @@
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springdoc/springdoc-openapi-ui -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.13</version>
</dependency>



</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.venture.venturetrip.controller;

import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.venture.venturetrip.model.user.FeedBack;
import com.venture.venturetrip.services.userServices.UserService;

@RestController
@RequestMapping("/User")
public class UserController {


@Autowired
private UserService uService;

@PostMapping("/FeedBack")
ResponseEntity<FeedBack> giveFeedBack(@RequestBody FeedBack feedback){

FeedBack fb = uService.addFeedback(feedback);

return new ResponseEntity<FeedBack>(fb,HttpStatus.CREATED);
}

@GetMapping("/FeedBack/{Id}")
ResponseEntity<FeedBack> virewFeedBack(@PathVariable("Id") Integer feedbackID ,@RequestBody FeedBack feedback){

FeedBack fb = uService.viewFeedBack(feedbackID);

return new ResponseEntity<FeedBack>(fb,HttpStatus.OK);
}

@PutMapping("/updateFeedback/{Id}")
ResponseEntity<FeedBack> updateFeedBack(@PathVariable("Id") Integer feedbackID, @RequestBody FeedBack feedback){

FeedBack opt = uService.updateFeedBack(feedback);

return new ResponseEntity<FeedBack>(opt,HttpStatus.OK);
}

@DeleteMapping("/deleteFeedback/{Id}")
ResponseEntity<FeedBack> deleteFeedBack(@PathVariable("Id") Integer feedbackID, @RequestBody FeedBack feedback){

FeedBack fb = uService.deleteFeedBack(feedback);

return new ResponseEntity<FeedBack>(fb,HttpStatus.ACCEPTED);
}







}
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
package com.venture.venturetrip.model.user;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.time.LocalDate;
import java.time.LocalDateTime;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;


@Entity
@Data
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class FeedBack {

@Id
private String feedbackID;
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer feedbackID;
private String feedback;
private Integer rating;
private LocalDate submitDate;
// private LocalDate submitDate;




}
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package com.venture.venturetrip.repository;

import com.venture.venturetrip.model.user.FeedBack;

import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface FeedBackDao extends JpaRepository<FeedBack,Integer> {

Optional<FeedBack> findById(Integer feedbackID);

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ public interface AdminService {

public Vehicles addNewVehiclesDetials(Vehicles vehicles, Integer travelsID) throws TravelsException, VehiclesException;



}
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
package com.venture.venturetrip.services.userServices;

import com.venture.venturetrip.exception.FeedbackException;
import com.venture.venturetrip.model.user.FeedBack;

public interface UserService {

public FeedBack addFeedback(FeedBack feedback) throws FeedbackException;

public FeedBack viewFeedBack(Integer feedbackID) throws FeedbackException;

public FeedBack updateFeedBack(FeedBack feedback) throws FeedbackException;

public FeedBack deleteFeedBack(FeedBack feedback) throws FeedbackException;


}
Original file line number Diff line number Diff line change
@@ -1,4 +1,83 @@
package com.venture.venturetrip.services.userServices;

import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.venture.venturetrip.exception.FeedbackException;
import com.venture.venturetrip.model.user.FeedBack;
import com.venture.venturetrip.repository.FeedBackDao;

@Service
public class UserServiceImpl implements UserService{

@Autowired
private FeedBackDao fDao;

@Override
public FeedBack addFeedback(FeedBack feedback) throws FeedbackException {


FeedBack fb = fDao.save(feedback);

return fb;



}



@Override
public FeedBack viewFeedBack(Integer feedbackID) throws FeedbackException {

Optional<FeedBack> opt = fDao.findById(feedbackID);

if(opt.isEmpty()) {
throw new FeedbackException("FeedBack Doesn't Exsist By This Id :"+ feedbackID);
}
else {
return opt.get();
}

}

@Override
public FeedBack updateFeedBack(FeedBack feedback) throws FeedbackException {

Optional<FeedBack> opt = fDao.findById(feedback.getFeedbackID());

if(opt.isEmpty()) {
throw new FeedbackException("FeedBack Doesn't Exsist By This Id :"+ feedback.getFeedbackID());
}
else {

FeedBack updated = fDao.save(feedback);

return updated;
}

}

@Override
public FeedBack deleteFeedBack(FeedBack feedback) throws FeedbackException {

Optional<FeedBack> opt = fDao.findById(feedback.getFeedbackID());

if(opt.isPresent()) {

fDao.delete(feedback);

return feedback;
}
else {
throw new FeedbackException("FeedBack Doesn't Exsist By This Id :"+ feedback.getFeedbackID());
}

}




}
2 changes: 1 addition & 1 deletion VentureTrip/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ spring.datasource.username=root
spring.datasource.password=root

#ORM s/w specific properties
spring.jpa.hibernate.ddl-auto=create
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true

#Swagger specific properties
Expand Down