first commit
This commit is contained in:
13
src/main/java/com/safeqr/app/SafeQrAppApplication.java
Normal file
13
src/main/java/com/safeqr/app/SafeQrAppApplication.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.safeqr.app;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SafeQrAppApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SafeQrAppApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.safeqr.app.user.controller;
|
||||
|
||||
import com.safeqr.app.user.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1")
|
||||
public class UserController {
|
||||
@Autowired
|
||||
UserService userService;
|
||||
@GetMapping(value = "/version", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<String> version() {
|
||||
System.out.println(userService.getUserByEmail());
|
||||
return ResponseEntity.ok("SafeQR v1.0.0");
|
||||
}
|
||||
|
||||
}
|
||||
26
src/main/java/com/safeqr/app/user/entity/UserEntity.java
Normal file
26
src/main/java/com/safeqr/app/user/entity/UserEntity.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.safeqr.app.user.entity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.*;
|
||||
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name="user", schema = "safeqr")
|
||||
public class UserEntity {
|
||||
@Id
|
||||
private String id;
|
||||
private String cognitoId;
|
||||
private String firstname;
|
||||
private String lastname;
|
||||
private String email;
|
||||
private String source;
|
||||
private String password;
|
||||
private String salt;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.safeqr.app.user.repository;
|
||||
|
||||
import com.safeqr.app.user.entity.UserEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface UserRepository extends JpaRepository<UserEntity, String> {
|
||||
UserEntity findByEmail(String email);
|
||||
}
|
||||
23
src/main/java/com/safeqr/app/user/service/UserService.java
Normal file
23
src/main/java/com/safeqr/app/user/service/UserService.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.safeqr.app.user.service;
|
||||
|
||||
import com.safeqr.app.user.entity.UserEntity;
|
||||
import com.safeqr.app.user.repository.UserRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class UserService {
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
public String getUserByEmail() {
|
||||
|
||||
// Retrieve the user by email
|
||||
UserEntity retrievedUser = userRepository.findByEmail("test.user@example.com");
|
||||
if (retrievedUser != null) {
|
||||
return "User found: " + retrievedUser.getFirstname() + " " + retrievedUser.getLastname();
|
||||
}
|
||||
return "User not found";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user