Compare commits
No commits in common. "a29e410332f41c6493e58ae19eab110005b2cc8f" and "151a2be1c470e51e503f165087338be6d712ca44" have entirely different histories.
a29e410332
...
151a2be1c4
@ -13,5 +13,4 @@ public class CertController {
|
||||
public String index(Model model) {
|
||||
return "certs";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
package dev.araozu.eeg_java.controller;
|
||||
|
||||
import dev.araozu.eeg_java.model.Person;
|
||||
import dev.araozu.eeg_java.model.PersonRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(path = "/demo")
|
||||
public class MainController {
|
||||
|
||||
@Autowired
|
||||
private PersonRepository personRepository;
|
||||
|
||||
@PostMapping(path = "/add")
|
||||
public @ResponseBody String addNewPerson(@RequestParam String name, @RequestParam String dni) {
|
||||
Person person = new Person();
|
||||
person.setPerson_dni(dni);
|
||||
person.setPerson_names(name);
|
||||
person.setPerson_paternal_surname("Doe");
|
||||
person.setPerson_maternal_surname("Smith");
|
||||
person.setPerson_classroom_id(1);
|
||||
person.setPerson_classroom_username("JohnDoe");
|
||||
personRepository.save(person);
|
||||
|
||||
return "Saved :D";
|
||||
}
|
||||
|
||||
@GetMapping(path = "/all")
|
||||
public @ResponseBody Iterable<Person> getAllPersons() {
|
||||
return personRepository.findAll();
|
||||
}
|
||||
}
|
76
src/main/java/dev/araozu/eeg_java/model/Person.java
Normal file
76
src/main/java/dev/araozu/eeg_java/model/Person.java
Normal file
@ -0,0 +1,76 @@
|
||||
package dev.araozu.eeg_java.model;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
@Entity(name = "person")
|
||||
public class Person {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer person_id;
|
||||
|
||||
private String person_dni;
|
||||
private String person_names;
|
||||
private String person_paternal_surname;
|
||||
private String person_maternal_surname;
|
||||
private Integer person_classroom_id;
|
||||
private String person_classroom_username;
|
||||
|
||||
public Integer getPerson_id() {
|
||||
return person_id;
|
||||
}
|
||||
|
||||
public void setPerson_id(Integer person_id) {
|
||||
this.person_id = person_id;
|
||||
}
|
||||
|
||||
public String getPerson_dni() {
|
||||
return person_dni;
|
||||
}
|
||||
|
||||
public void setPerson_dni(String person_dni) {
|
||||
this.person_dni = person_dni;
|
||||
}
|
||||
|
||||
public String getPerson_names() {
|
||||
return person_names;
|
||||
}
|
||||
|
||||
public void setPerson_names(String person_names) {
|
||||
this.person_names = person_names;
|
||||
}
|
||||
|
||||
public String getPerson_paternal_surname() {
|
||||
return person_paternal_surname;
|
||||
}
|
||||
|
||||
public void setPerson_paternal_surname(String person_paternal_surname) {
|
||||
this.person_paternal_surname = person_paternal_surname;
|
||||
}
|
||||
|
||||
public String getPerson_maternal_surname() {
|
||||
return person_maternal_surname;
|
||||
}
|
||||
|
||||
public void setPerson_maternal_surname(String person_maternal_surname) {
|
||||
this.person_maternal_surname = person_maternal_surname;
|
||||
}
|
||||
|
||||
public Integer getPerson_classroom_id() {
|
||||
return person_classroom_id;
|
||||
}
|
||||
|
||||
public void setPerson_classroom_id(Integer person_classroom_id) {
|
||||
this.person_classroom_id = person_classroom_id;
|
||||
}
|
||||
|
||||
public String getPerson_classroom_username() {
|
||||
return person_classroom_username;
|
||||
}
|
||||
|
||||
public void setPerson_classroom_username(String person_classroom_username) {
|
||||
this.person_classroom_username = person_classroom_username;
|
||||
}
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
package dev.araozu.eeg_java.person;
|
||||
|
||||
import java.util.Optional;
|
||||
package dev.araozu.eeg_java.model;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
public interface PersonRepository extends CrudRepository<Person, Integer> {
|
||||
Optional<Person> findByPersonDni(String personDni);
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
package dev.araozu.eeg_java.person;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
@Entity(name = "person")
|
||||
public class Person {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer person_id;
|
||||
|
||||
@Column(name = "person_dni")
|
||||
private String personDni;
|
||||
@Column(name = "person_names")
|
||||
private String personNames;
|
||||
|
||||
@Column(name = "person_paternal_surname")
|
||||
private String personPaternalSurname;
|
||||
|
||||
@Column(name = "person_maternal_surname")
|
||||
private String personMaternalSurname;
|
||||
|
||||
@Column(name = "person_classroom_id")
|
||||
private Integer personClassroomId;
|
||||
|
||||
@Column(name = "person_classroom_username")
|
||||
private String personClassroomUsername;
|
||||
|
||||
public String getPersonClassroomUsername() {
|
||||
return personClassroomUsername;
|
||||
}
|
||||
|
||||
public void setPersonClassroomUsername(String personClassroomUsername) {
|
||||
this.personClassroomUsername = personClassroomUsername;
|
||||
}
|
||||
|
||||
public Integer getPersonId() {
|
||||
return person_id;
|
||||
}
|
||||
|
||||
public void setPersonId(Integer person_id) {
|
||||
this.person_id = person_id;
|
||||
}
|
||||
|
||||
public String getPersonDni() {
|
||||
return personDni;
|
||||
}
|
||||
|
||||
public void setPersonDni(String person_dni) {
|
||||
this.personDni = person_dni;
|
||||
}
|
||||
|
||||
public String getPersonNames() {
|
||||
return personNames;
|
||||
}
|
||||
|
||||
public void setPersonNames(String personNames) {
|
||||
this.personNames = personNames;
|
||||
}
|
||||
|
||||
public String getPersonPaternalSurname() {
|
||||
return personPaternalSurname;
|
||||
}
|
||||
|
||||
public void setPersonPaternalSurname(String personPaternalSurname) {
|
||||
this.personPaternalSurname = personPaternalSurname;
|
||||
}
|
||||
|
||||
public String getPersonMaternalSurname() {
|
||||
return personMaternalSurname;
|
||||
}
|
||||
|
||||
public void setPersonMaternalSurname(String personMaternalSurname) {
|
||||
this.personMaternalSurname = personMaternalSurname;
|
||||
}
|
||||
|
||||
public Integer getPersonClassroomId() {
|
||||
return personClassroomId;
|
||||
}
|
||||
|
||||
public void setPersonClassroomId(Integer personClassroomId) {
|
||||
this.personClassroomId = personClassroomId;
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package dev.araozu.eeg_java.person;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping(path = "/person")
|
||||
public class PersonController {
|
||||
|
||||
@Autowired
|
||||
private PersonRepository personRepository;
|
||||
|
||||
@GetMapping("/")
|
||||
public String searchPersonByDniString(
|
||||
@RequestParam(required = true, value="person_dni") String personDni,
|
||||
HttpServletResponse response
|
||||
) {
|
||||
var maybePerson = personRepository.findByPersonDni(personDni);
|
||||
|
||||
if (maybePerson.isPresent()) {
|
||||
Person person = maybePerson.get();
|
||||
System.out.println(person.getPersonDni());
|
||||
|
||||
return "fragments/person/display.html";
|
||||
} else {
|
||||
// send http 404
|
||||
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||
|
||||
return "fragments/person/create.html";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es" xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head th:replace="~{fragments/head :: head}"></head>
|
||||
<head th:replace="fragments/head"></head>
|
||||
|
||||
<body hx-ext="response-targets, class-tools, loading-states">
|
||||
<div class="grid grid-cols-[5rem_auto]">
|
||||
<!-- Navigation Rail -->
|
||||
<div th:replace="~{fragments/navigation_rail :: div}"></div>
|
||||
<div th:replace="fragments/navigation_rail :: div"></div>
|
||||
<!-- Certs -->
|
||||
<div>
|
||||
|
||||
<div class="grid grid-cols-[16rem_25rem_1fr]"
|
||||
x-data="{user_dni: ''}"
|
||||
>
|
||||
<div class="grid grid-cols-[16rem_25rem_1fr]">
|
||||
<!-- Search -->
|
||||
<div>
|
||||
<div class="text-center">
|
||||
@ -21,9 +19,9 @@
|
||||
<img class="inline-block w-[10rem] h-[10rem]" src="" />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div x-data="{user_dni: ''}">
|
||||
<form
|
||||
hx-get="/person/" hx-target="#person-search-result"
|
||||
hx-get="/certs/person" hx-target="#person-search-result"
|
||||
hx-target-4*="#person-search-result"
|
||||
hx-swap="outerHTML"
|
||||
>
|
||||
@ -32,11 +30,9 @@
|
||||
invalid:border-c-error invalid:text-c-error
|
||||
focus:border-c-primary outline-none font-mono
|
||||
disabled:opacity-50 disabled:cursor-not-allowed" type="text" minLength="8"
|
||||
name="person_dni"
|
||||
maxLength="15" pattern="[0-9]{8,15}" placeholder="Número de DNI" x-model="user_dni"
|
||||
required />
|
||||
|
||||
|
||||
<label for="search-dni"
|
||||
class="absolute -top-2 left-2 text-xs bg-c-surface px-1 select-none">DNI</label>
|
||||
|
||||
@ -58,7 +54,7 @@
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<p class="relative max-w-[14rem] mx-auto my-2 p-1 text-c-error text-sm select-none opacity-0">
|
||||
<p class="relative max-w-[14rem] mx-auto p-1 text-c-error text-sm select-none opacity-0">
|
||||
Error: {error()}
|
||||
</p>
|
||||
|
||||
|
@ -19,5 +19,5 @@
|
||||
<!-- Phosphor icons -->
|
||||
<link rel="stylesheet" type="text/css" href="https://unpkg.com/@phosphor-icons/web@2.0.3/src/regular/style.css" />
|
||||
<!-- Alpinejs -->
|
||||
<script src="https://unpkg.com/alpinejs@3.13.7" defer></script>
|
||||
<script src="https://unpkg.com/alpinejs" defer></script>
|
||||
</head>
|
@ -1,3 +0,0 @@
|
||||
<div id="person-search-result">
|
||||
<p>Create a new person here:</p>
|
||||
</div>
|
@ -1,49 +0,0 @@
|
||||
<div id="person-search-result" x-show="user_dni.length >= 8">
|
||||
<div class="relative max-w-[14rem] mx-auto my-6">
|
||||
<label class="absolute -top-2 left-2 text-xs bg-c-surface px-1 select-none">
|
||||
Apellido Paterno
|
||||
</label>
|
||||
<span class="bg-c-background text-c-on-background border-c-outline
|
||||
border-2 rounded px-2 py-1 w-full inline-block font-mono
|
||||
disabled:opacity-50 disabled:cursor-not-allowed">
|
||||
AAAAAAA
|
||||
</span>
|
||||
|
||||
<button type="button" class="absolute top-1 right-1 rounded hover:bg-c-surface-variant"
|
||||
onclick={copyToClipboard}>
|
||||
<i class="ph ph-copy inline-block w-6 text-2xl"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="relative max-w-[14rem] mx-auto my-6">
|
||||
<label class="absolute -top-2 left-2 text-xs bg-c-surface px-1 select-none">
|
||||
Apellido Materno
|
||||
</label>
|
||||
<span class="bg-c-background text-c-on-background border-c-outline
|
||||
border-2 rounded px-2 py-1 w-full inline-block font-mono
|
||||
disabled:opacity-50 disabled:cursor-not-allowed">
|
||||
BBBBBB
|
||||
</span>
|
||||
|
||||
<button type="button" class="absolute top-1 right-1 rounded hover:bg-c-surface-variant"
|
||||
onclick={copyToClipboard}>
|
||||
<i class="ph ph-copy inline-block w-6 text-2xl"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="relative max-w-[14rem] mx-auto my-6">
|
||||
<label class="absolute -top-2 left-2 text-xs bg-c-surface px-1 select-none">
|
||||
Nombres
|
||||
</label>
|
||||
<span class="bg-c-background text-c-on-background border-c-outline
|
||||
border-2 rounded px-2 py-1 w-full inline-block font-mono
|
||||
disabled:opacity-50 disabled:cursor-not-allowed">
|
||||
CCCCCCCC
|
||||
</span>
|
||||
|
||||
<button type="button" class="absolute top-1 right-1 rounded hover:bg-c-surface-variant"
|
||||
onclick={copyToClipboard}>
|
||||
<i class="ph ph-copy inline-block w-6 text-2xl"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
@ -1,7 +1,7 @@
|
||||
<!doctype html>
|
||||
<html lang="es" xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head th:replace="~{fragments/head :: head}"></head>
|
||||
<head th:replace="fragments/head"></head>
|
||||
|
||||
<body>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user