package com.example.karakum.persist.entity;
import com.sun.istack.NotNull;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
@Getter
@Setter
@Entity
@Table(name="Client")
public class ClientEntity implements Serializable {
private static final long serialVersionUID = 4364632587002683208L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Basic(optional = false)
@Column(name = "Client_id", unique = true, nullable = false)
private Integer clientId;
@Column(name = "client_fn")
@NotNull
private String clientFn;
@Column(name = "client_passport")
private String clientPassport;
@Column(name = "client_bank")
private String clientBank;
@Column(name = "client_banknum")
private String clientBankNum;
@Column(name = "client_sign")
private String clientSign;
/* @OneToMany(mappedBy = "client")
private List contracts;
*/
public ClientEntity() {
}
public ClientEntity(String clientFn, String clientPassport, String clientBank, String clientBankNum, String clientSign) {
this.clientFn = clientFn;
this.clientPassport = clientPassport;
this.clientBank = clientBank;
this.clientBankNum = clientBankNum;
this.clientSign = clientSign;
}
}
@GetMapping(value = {"/clients/add"})
public String clientAdd(Model model) {
return "clientadd";
}
@PostMapping({"/clients/add"})
public String clientEntityAdd(@RequestParam String clientfn, @RequestParam String clientpassport, @RequestParam String clientbank, @RequestParam String clientbanknum, @RequestParam String clientsign, Model model) {
ClientEntity clientEntity = new ClientEntity(clientfn, clientpassport, clientbank, clientbanknum, clientsign);
clientRepository.save(clientEntity);
return "clientadd";
}
UserRequestDto {
@NotBlank(message = "Name is mandatory")
String username;
@NotBlank(message = "Email is mandatory")
String email;
}
//@RestController
@Controller
UserController {
public ResponseEntity<User> addUser( @Valid UserDto user ) {
// конвертируем UserDto -> User и в передаем в сервисный класс для сохранения
}
}
<input type="email" />
import com.sun.istack.NotNull;
, а должно быть hibernate validator.