Skip to content

Commit

Permalink
Merge branch 'Twitter-Clone-Group:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
gychu1 authored Sep 6, 2022
2 parents e523184 + b04dbdd commit 78b0fad
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ services:
max-size: 10m
max-file: "3"
ports:
- '5432:5432'
- '5432:5432'
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

@Controller
Expand All @@ -35,7 +37,12 @@ public ResponseEntity<Object> findByUsername(@PathVariable String username) {

@PostMapping
public ResponseEntity<Squeak> save(@RequestBody Squeak squeak) {
squeak.setPostedAt(LocalDateTime.now());
// squeak.setPostedAt(LocalDateTime.now());
LocalDateTime date = LocalDateTime.now();
DateTimeFormatter myFormatObj = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");
String text = date.format(myFormatObj).replace("T"," ");
LocalDateTime parsedDate = LocalDateTime.parse(text, myFormatObj);
squeak.setPostedAt(parsedDate);
return new ResponseEntity<>(squeakService.saveSqueak(squeak), HttpStatus.OK);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.List;

@Controller
Expand Down Expand Up @@ -42,6 +43,7 @@ public ResponseEntity<Object> findByUsername(@RequestParam("username") String us

@PostMapping
public ResponseEntity<Squeaker> save(@RequestBody Squeaker squeaker) {
squeaker.setJoinDate(LocalDate.now());
return new ResponseEntity<>(squeakerService.saveSqueaker(squeaker), HttpStatus.OK);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import lombok.Data;

import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Set;

@Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import lombok.Data;

import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Set;

@Entity
Expand All @@ -29,4 +31,6 @@ public class Squeaker {
String profilePic = "https://t4.ftcdn.net/jpg/00/64/67/63/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg";
@Column(name = "email", unique = true)
String email;
@Column(name = "joinDate")
LocalDate joinDate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public Squeaker updateSqueaker (Long id, Squeaker squeaker) {

oldSqueaker.setUsername(squeaker.getUsername());
oldSqueaker.setPassword(squeaker.getPassword());
oldSqueaker.setEmail(squeaker.getEmail());
oldSqueaker.setFirstName(squeaker.getFirstName());
oldSqueaker.setLastName(squeaker.getLastName());
oldSqueaker.setProfilePic(squeaker.getProfilePic());

squeakerRepository.save(oldSqueaker);

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ spring:
datasource:
username: root
password: pass
url: jdbc:postgresql://localhost:5432/postgres
url: jdbc:postgresql://localhost:5432/postgres

0 comments on commit 78b0fad

Please sign in to comment.