Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e8b0d2d
Create 02-bloggingapp
0xStryK3R Jul 25, 2022
1b93ff4
Merge pull request #1 from scaleracademy/main
0xStryK3R Aug 2, 2022
7ac1bf0
Committing Self-Work in separate branch.
0xStryK3R Aug 2, 2022
4388f02
TaskController Implementation
0xStryK3R Aug 2, 2022
1119ba0
Merge branch 'main' into arup_02_08
0xStryK3R Aug 4, 2022
4f7eb8d
Merge pull request #2 from 0xStryK3R/arup_02_08
0xStryK3R Aug 4, 2022
4789b66
Commiting classwork in separate branch.
0xStryK3R Aug 4, 2022
eca0859
Merge branch 'scaleracademy:main' into main
0xStryK3R Aug 4, 2022
f3cc935
TODOs Implemented.
0xStryK3R Aug 5, 2022
25aa23a
Merge pull request #3 from scaleracademy/main
0xStryK3R Aug 6, 2022
cf0d8db
Merge branch 'assignment_03_08' into cw_03_08
0xStryK3R Aug 7, 2022
51d6bba
Merge pull request #4 from 0xStryK3R/cw_03_08
0xStryK3R Aug 7, 2022
7115c9c
Initial cw commit, to be revised and augmented later.
0xStryK3R Aug 7, 2022
1b34ad7
Classwork 05/08, Models, Entities and Repos
0xStryK3R Aug 9, 2022
3391406
Error Handling Part
0xStryK3R Aug 9, 2022
f4a45c8
Merge pull request #5 from 0xStryK3R/assignment_03_08
0xStryK3R Aug 9, 2022
890bded
Revert "Merging Previous Self work(assignment_03_08) into Latest Clas…
0xStryK3R Aug 9, 2022
bb0d46e
Merge pull request #6 from 0xStryK3R/revert-5-assignment_03_08
0xStryK3R Aug 9, 2022
7283a33
Merge pull request #7 from 0xStryK3R/cw_05_08
0xStryK3R Aug 9, 2022
0a38ba1
Merge branch 'self_work' of github.com:0xStryK3R/Project-Module-Jul-2…
0xStryK3R Aug 9, 2022
da55e7f
Merge branch 'main' into self_work
0xStryK3R Aug 9, 2022
3bc6ee0
Merge pull request #9 from 0xStryK3R/self_work
0xStryK3R Aug 9, 2022
e942f9d
Merge pull request #10 from scaleracademy/main
0xStryK3R Aug 9, 2022
1a08a46
Merge pull request #13 from scaleracademy/main
0xStryK3R Aug 18, 2022
20ce1f7
Added Authentication(JWT) from different repo.
0xStryK3R Aug 18, 2022
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.arup
*.db
1 change: 1 addition & 0 deletions 01/02-bloggingapp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 2 additions & 0 deletions 03/spring/basicapp/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.arup
samples.txt
HELP.md
.gradle
build/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package com.scaler.basicapp;

import com.scaler.basicapp.pojos.Note;
import com.scaler.basicapp.pojos.Task;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController("/tasks")
@RequestMapping("/tasks")
public class TaskController {
private ArrayList<Task> tasks = new ArrayList<Task>();

@PostMapping //Can skip the route, defaults to parent route
public Task createTask(@RequestBody Task task){
tasks.add(task);
return task;
}

@GetMapping
public ArrayList<Task> getTasks(){
return tasks;
}

@GetMapping("/{task_id}")
public Task getTask(@PathVariable("task_id") int task_id){
if(task_id >= tasks.size() || task_id < 0){
return null;
}
return tasks.get(task_id);
}

@GetMapping("/{task_id}/notes")
public ArrayList<Note> getNotes(@PathVariable("task_id") int task_id){
if(task_id >= tasks.size() || task_id < 0){
return null;
}
return tasks.get(task_id).getNotes();
}

@GetMapping("/{task_id}/notes/{note_id}")
public Note getNoteForTask(@PathVariable("task_id") int task_id, @PathVariable("note_id") int note_id){
if(task_id >= tasks.size() || task_id < 0 || note_id >= tasks.get(task_id).getNotes().size() || note_id < 0){
return null;
}
return tasks.get(task_id).getNotes().get(note_id);
}

@PatchMapping("/{id}")
public Task updateTask(@PathVariable("id") int id, @RequestBody Task newTask){
Task task = tasks.get(id);

if (newTask.getTitle() != null) task.setTitle(newTask.getTitle());

if (newTask.getDeadline() != null) task.setDeadline(newTask.getDeadline());

task.setCompleted(newTask.isCompleted()); //How to check if not sent?

if (newTask.getDescription() != null) task.setDescription(newTask.getDescription());

if (newTask.getNotes() != null) task.setNotes(newTask.getNotes());

return task;
}

@DeleteMapping("/{id}")
public String deleteTask(@PathVariable("id") int id){
String deletedTaskTitle = tasks.get(id).getTitle();
tasks.remove(id);
return "Task '"+ deletedTaskTitle + "' was Deleted.";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.scaler.basicapp.pojos;

public class Note {
private String title;
private String body;

public Note(String title, String body) {
this.title = title;
this.body = body;
}

public String getTitle() {
return title;
}

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

public String getBody() {
return body;
}

public void setBody(String body) {
this.body = body;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.scaler.basicapp.pojos;

import java.util.ArrayList;
import java.util.Date;

public class Task {
private int id;
private String title;
private String description;
private Date deadline;
private ArrayList<Note> notes;
private boolean completed;

public Task(String title, String description, Date deadline, ArrayList<Note> notes, boolean completed) {
this.title = title;
this.description = description;
this.deadline = deadline;
this.notes = notes;
this.completed = completed;
}

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 Date getDeadline() {
return deadline;
}

public void setDeadline(Date deadline) {
this.deadline = deadline;
}

public ArrayList<Note> getNotes() {
return notes;
}

public void setNotes(ArrayList<Note> notes) {
this.notes = notes;
}

public boolean isCompleted() {
return completed;
}

public void setCompleted(boolean completed) {
this.completed = completed;
}
}
37 changes: 37 additions & 0 deletions 03/spring/springproject/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/
22 changes: 22 additions & 0 deletions 03/spring/springproject/archive/sample_tasks.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"title": "My First Task",
"description": "Just a sample Task, nothing much.",
"deadline": "2023-01-01T00:00:00.000+00:00",
"completed": true
}


{
"title": "My Second Task",
"description": "Another task, which I will edit.",
"deadline": "2022-08-01T00:00:00.000+00:00",
"completed": false
}


{
"title": "My Third Task",
"description": "final task, which I will delete.",
"deadline": "2022-08-01T00:00:00.000+00:00",
"completed": true
}
Binary file not shown.
23 changes: 23 additions & 0 deletions 03/spring/springproject/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins {
id 'org.springframework.boot' version '2.7.2'
id 'io.spring.dependency-management' version '1.0.12.RELEASE'
id 'java'
}

group = 'com.scaler'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
useJUnitPlatform()
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading