Skip to content

Feature/rest api #24

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

Open
wants to merge 3 commits 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
21 changes: 20 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,27 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>

<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>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.accenture.codingtest.springbootcodingtest.constants;

public enum Status {
NOT_STARTED, IN_PROGRESS, READY_FOR_TEST, COMPLETED
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.accenture.codingtest.springbootcodingtest.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
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.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.accenture.codingtest.springbootcodingtest.entity.Project;
import com.accenture.codingtest.springbootcodingtest.service.ProjectService;

@RestController
@RequestMapping("/api")
public class ProjectController {
@Autowired
private ProjectService projectService;

@GetMapping("/v1/projects")
public ResponseEntity<List<Project>> getAllProjects() {
return projectService.getAllProjects();
}

@GetMapping("/v1/projects/{project_id}")
public ResponseEntity<Project> getProjectById(@PathVariable("project_id") String project_id) {
return projectService.getProjectById(project_id);
}

@PutMapping("/v1/projects")
public ResponseEntity<Project> updateProject(@RequestBody Project project) {
return projectService.updateProject(project);
}

@DeleteMapping("/v1/projects/{project_id}")
public ResponseEntity<Void> deleteProjectById(@PathVariable("project_id") String project_id) {
return projectService.deleteProject(project_id);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.accenture.codingtest.springbootcodingtest.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.accenture.codingtest.springbootcodingtest.entity.Task;
import com.accenture.codingtest.springbootcodingtest.service.TaskService;

@RestController
@RequestMapping("/api")
public class TaskController {
@Autowired
private TaskService taskService;

@GetMapping("/v1/tasks")
public ResponseEntity<List<Task>> getAllTasks() {
return taskService.getAllTasks();
}

@GetMapping("/v1/tasks/{task_id}")
public ResponseEntity<Task> getTaskById(@PathVariable("task_id") String task_id) {
return taskService.getTaskById(task_id);
}

@DeleteMapping("/v1/tasks/{task_id}")
public ResponseEntity<Void> deleteTaskById(@PathVariable("task_id") String task_id) {
return taskService.deleteTask(task_id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.accenture.codingtest.springbootcodingtest.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.accenture.codingtest.springbootcodingtest.service.UserService;

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

@Autowired
private UserService userService;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.accenture.codingtest.springbootcodingtest.entity;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "Project")
public class Project {

@Id
private String id;
private String name;

public Project() {
super();
// TODO Auto-generated constructor stub
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Project(String id, String name) {
super();
this.id = id;
this.name = name;
}

@Override
public String toString() {
return "Project [id=" + id + ", name=" + name + "]";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package com.accenture.codingtest.springbootcodingtest.entity;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "Task")
public class Task {
@Id
private String id;
private String title;
private String description;
private String status;
private String project_id;
private String user_id;

public Task() {
super();
// TODO Auto-generated constructor stub
}

public Task(String id, String title, String description, String status, String project_id, String user_id) {
super();
this.id = id;
this.title = title;
this.description = description;
this.status = status;
this.project_id = project_id;
this.user_id = user_id;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}

public String getProject_id() {
return project_id;
}

public void setProject_id(String project_id) {
this.project_id = project_id;
}

public String getUser_id() {
return user_id;
}

public void setUser_id(String user_id) {
this.user_id = user_id;
}

@Override
public String toString() {
return "Task [id=" + id + ", title=" + title + ", description=" + description + ", status=" + status
+ ", project_id=" + project_id + ", user_id=" + user_id + "]";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.accenture.codingtest.springbootcodingtest.entity;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@Entity
@Table(name = "User")
@JsonSerialize
public class User {

@Id
private String id;
private String username;
private String password;

public User() {
super();
// TODO Auto-generated constructor stub
}

public User(String id, String username, String password) {
super();
this.id = id;
this.username = username;
this.password = password;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

@Override
public String toString() {
return "User [id=" + id + ", username=" + username + ", password=" + password + "]";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.accenture.codingtest.springbootcodingtest.repository;

import com.accenture.codingtest.springbootcodingtest.entity.Project;
import org.springframework.data.jpa.repository.JpaRepository;

public interface ProjectRepository extends JpaRepository<Project, String> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.accenture.codingtest.springbootcodingtest.repository;

import com.accenture.codingtest.springbootcodingtest.entity.Task;
import org.springframework.data.jpa.repository.JpaRepository;

public interface TaskRepository extends JpaRepository<Task, String> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.accenture.codingtest.springbootcodingtest.repository;

import com.accenture.codingtest.springbootcodingtest.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;

public interface UserRepository extends JpaRepository<User, String> {
}
Loading