| ... | @@ -117,14 +117,338 @@ A modelagem, documentação e organização do banco de dados se situará nessa | ... | @@ -117,14 +117,338 @@ A modelagem, documentação e organização do banco de dados se situará nessa | 
|  |  |  |  | 
|  | TBD |  | TBD | 
|  |  |  |  | 
|  | ### Knex |  | ### Schemas | 
|  |  |  |  | 
|  | TBD |  | #### Aluno | 
|  |  |  |  | 
|  | ### Schemas |  | ``` | 
|  |  |  | @Entity | 
|  |  |  | @Table(name = "tb_aluno") | 
|  |  |  | public class Aluno implements Serializable { | 
|  |  |  | @Id | 
|  |  |  | @GeneratedValue(strategy = GenerationType.AUTO) | 
|  |  |  | @Column(name = "id") | 
|  |  |  | private UUID id; | 
|  |  |  |  | 
|  | TBD |  | @Column(nullable = true, name = "cpf", length = 11) | 
|  |  |  | private String cpf; | 
|  |  |  |  | 
|  | #### Postgrees |  | @Column(nullable = false, name = "nome", length = 80) | 
|  |  |  | private String nome; | 
|  |  |  |  | 
|  | TBD |  | @Column(nullable = false, name = "responsavel_primario", length = 80) | 
|  |  |  | private String responsavelPrimario; | 
|  |  |  |  | 
|  |  |  | @Column(name = "responsavel_secundario", length = 80) | 
|  |  |  | private String responsavelSecundario; | 
|  |  |  |  | 
|  |  |  | @Column(name = "responsavel_opcional", length = 80) | 
|  |  |  | private String responsavelOpcional; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "beneficiario_renda") | 
|  |  |  | private Boolean beneficiarioRenda; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "beneficiario_bpc") | 
|  |  |  | private Boolean beneficiarioBpc; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "data_nascimento") | 
|  |  |  | private LocalDate dataNascimento; | 
|  |  |  |  | 
|  |  |  | @OneToMany(mappedBy = "aluno", fetch = FetchType.LAZY, cascade = { CascadeType.ALL }) | 
|  |  |  | private List<Telefone> telefones = new ArrayList<>(); | 
|  |  |  |  | 
|  |  |  | @OneToMany(mappedBy = "aluno", fetch = FetchType.LAZY, cascade = { CascadeType.ALL }) | 
|  |  |  | private List<Endereco> enderecos = new ArrayList<>(); | 
|  |  |  |  | 
|  |  |  | @OneToMany(mappedBy = "aluno", fetch = FetchType.LAZY, cascade = { CascadeType.ALL }) | 
|  |  |  | private List<Ficha> fichas = new ArrayList<>(); | 
|  |  |  | } | 
|  |  |  | ``` | 
|  |  |  |  | 
|  |  |  | #### Cidade | 
|  |  |  |  | 
|  |  |  | ``` | 
|  |  |  | @Entity | 
|  |  |  | @Table(name = "tb_cidade") | 
|  |  |  | public class Cidade implements Serializable { | 
|  |  |  | @Id | 
|  |  |  | @GeneratedValue(strategy = GenerationType.AUTO) | 
|  |  |  | @Column(name = "id") | 
|  |  |  | private UUID id; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "codigo_ibge", length = 7) | 
|  |  |  | private String codigoIbge; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "nome", length = 30) | 
|  |  |  | private String nome; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "uf_sigla", length = 2) | 
|  |  |  | private String ufSigla; | 
|  |  |  |  | 
|  |  |  | @OneToMany(mappedBy = "cidade", fetch = FetchType.LAZY, cascade = { CascadeType.ALL }) | 
|  |  |  | @JsonIgnore | 
|  |  |  | private List<Endereco> endereco = new ArrayList<>(); | 
|  |  |  | } | 
|  |  |  | ``` | 
|  |  |  |  | 
|  |  |  | #### Endereco | 
|  |  |  |  | 
|  |  |  | ``` | 
|  |  |  | @Entity | 
|  |  |  | @Table(name = "tb_endereco") | 
|  |  |  | public class Endereco implements Serializable { | 
|  |  |  | @Id | 
|  |  |  | @GeneratedValue(strategy = GenerationType.AUTO) | 
|  |  |  | @Column(name = "id") | 
|  |  |  | private UUID id; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "data_cadastro") | 
|  |  |  | @CreationTimestamp | 
|  |  |  | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd/MM/yyyy") | 
|  |  |  | private LocalDate dataCadastro; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "cep", length = 9) | 
|  |  |  | private String cep; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "logradouro", length = 80) | 
|  |  |  | private String logradouro; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "numero", length = 9) | 
|  |  |  | private String numero; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "bairro", length = 50) | 
|  |  |  | private String bairro; | 
|  |  |  |  | 
|  |  |  | @Column(name = "complemento", length = 50) | 
|  |  |  | private String complemento; | 
|  |  |  |  | 
|  |  |  | @Column(name = "pontoReferencia", length = 500) | 
|  |  |  | private String pontoReferencia; | 
|  |  |  |  | 
|  |  |  | @ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.ALL }) | 
|  |  |  | @JoinColumn(name = "aluno_id") | 
|  |  |  | @JsonIgnore | 
|  |  |  | private Aluno aluno; | 
|  |  |  |  | 
|  |  |  | @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.ALL }) | 
|  |  |  | @JoinColumn(name = "cidade_id") | 
|  |  |  | private Cidade cidade; | 
|  |  |  | } | 
|  |  |  | ``` | 
|  |  |  |  | 
|  |  |  | #### Escola | 
|  |  |  |  | 
|  |  |  | ``` | 
|  |  |  | @Entity | 
|  |  |  | @Table(name = "tb_escola") | 
|  |  |  | public class Escola implements Serializable { | 
|  |  |  | @Id | 
|  |  |  | @GeneratedValue(strategy = GenerationType.AUTO) | 
|  |  |  | @Column(name = "id") | 
|  |  |  | private UUID id; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "escola_inep", length = 8) | 
|  |  |  | private String escolaInep; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "nome", length = 50) | 
|  |  |  | private String nome; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "cep", length = 9) | 
|  |  |  | private String cep; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "logradouro", length = 80) | 
|  |  |  | private String logradouro; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "numero", length = 9) | 
|  |  |  | private String numero; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = true, name = "complemento", length = 50) | 
|  |  |  | private String complemento; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "bairro", length = 50) | 
|  |  |  | private String bairro; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "cidade", length = 50) | 
|  |  |  | private String cidade; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "estado", length = 2) | 
|  |  |  | private String estado; | 
|  |  |  | } | 
|  |  |  | ``` | 
|  |  |  |  | 
|  |  |  | #### Ficha | 
|  |  |  |  | 
|  |  |  | ``` | 
|  |  |  | @Entity | 
|  |  |  | @Table(name = "tb_ficha") | 
|  |  |  | public class Ficha implements Serializable { | 
|  |  |  | @Id | 
|  |  |  | @GeneratedValue(strategy = GenerationType.AUTO) | 
|  |  |  | private UUID id; | 
|  |  |  |  | 
|  |  |  | @OneToOne(cascade=CascadeType.ALL) | 
|  |  |  | private IdPublico idPublico = new IdPublico(); | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "situacao_Aluno") | 
|  |  |  | private Integer situacaoAluno; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "status") | 
|  |  |  | private Integer status; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "motivo_complemento") | 
|  |  |  | private String motivoComplemento; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = true, name = "responsavel") | 
|  |  |  | private Integer responsavel; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "data_cadastro") | 
|  |  |  | @UpdateTimestamp | 
|  |  |  | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd/MM/yyyy") | 
|  |  |  | private LocalDate dataCadastro; | 
|  |  |  |  | 
|  |  |  | @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.ALL }) | 
|  |  |  | @JoinColumn(name = "aluno_id") | 
|  |  |  | private Aluno aluno; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = true, name = "id_escola") | 
|  |  |  | private UUID idEscola; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = true, name = "id_motivo_infrequencia") | 
|  |  |  | private Long idMotivoInfrequencia; | 
|  |  |  |  | 
|  |  |  | @OneToMany(mappedBy = "ficha", fetch = FetchType.LAZY, cascade = { CascadeType.ALL }) | 
|  |  |  | private List<Visita> visitas = new ArrayList<>(); | 
|  |  |  |  | 
|  |  |  | @OneToMany(mappedBy = "ficha", fetch = FetchType.LAZY, cascade = { CascadeType.ALL }) | 
|  |  |  | private List<HistoricoFicha> historicoFichas = new ArrayList<>(); | 
|  |  |  | } | 
|  |  |  | ``` | 
|  |  |  |  | 
|  |  |  | #### HistoricoFicha | 
|  |  |  |  | 
|  |  |  | ``` | 
|  |  |  | @Entity | 
|  |  |  | @Table(name = "tb_historico_ficha") | 
|  |  |  | public class HistoricoFicha implements Serializable { | 
|  |  |  | @Id | 
|  |  |  | @GeneratedValue(strategy = GenerationType.AUTO) | 
|  |  |  | private UUID id; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "data_cadastro") | 
|  |  |  | @UpdateTimestamp | 
|  |  |  | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd/MM/yyyy") | 
|  |  |  | private LocalDate dataCadastro; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "status", length = 80) | 
|  |  |  | private Integer status; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "responsavel", length = 80) | 
|  |  |  | private Integer responsavel; | 
|  |  |  |  | 
|  |  |  | @ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.ALL }) | 
|  |  |  | @JoinColumn(name = "ficha_id") | 
|  |  |  | private Ficha ficha; | 
|  |  |  | } | 
|  |  |  | ``` | 
|  |  |  |  | 
|  |  |  | #### IdPublico | 
|  |  |  |  | 
|  |  |  | ``` | 
|  |  |  | @Entity | 
|  |  |  | public class IdPublico implements Serializable { | 
|  |  |  | @Id | 
|  |  |  | @SequenceGenerator(name="ficha_id_publico_seq", | 
|  |  |  | sequenceName="ficha_id_publico", | 
|  |  |  | initialValue = 1000) | 
|  |  |  | @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "ficha_id_publico_seq") | 
|  |  |  | private Long idPublico; | 
|  |  |  | } | 
|  |  |  | ``` | 
|  |  |  |  | 
|  |  |  | #### MotivoInfrequencia | 
|  |  |  |  | 
|  |  |  | ``` | 
|  |  |  | @Entity | 
|  |  |  | @Table(name = "tb_motivo_infrequencia") | 
|  |  |  | public class MotivoInfrequencia implements Serializable { | 
|  |  |  | @Id | 
|  |  |  | @GeneratedValue(strategy = GenerationType.SEQUENCE) | 
|  |  |  | @Column(name = "id") | 
|  |  |  | private Long id; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "tipo", length = 150) | 
|  |  |  | private String tipo; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "subtipo", length = 150) | 
|  |  |  | private String subTipo; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "recorrencias_para_envio") | 
|  |  |  | private Integer recorrenciasParaEnvio; | 
|  |  |  | } | 
|  |  |  | ``` | 
|  |  |  |  | 
|  |  |  | #### Telefone | 
|  |  |  |  | 
|  |  |  | ``` | 
|  |  |  | @Entity | 
|  |  |  | @Table(name = "tb_telefone") | 
|  |  |  | public class Telefone implements Serializable { | 
|  |  |  | @Id | 
|  |  |  | @GeneratedValue(strategy = GenerationType.AUTO) | 
|  |  |  | private UUID id; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "ddd", length = 3) | 
|  |  |  | private String ddd; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "numero", length = 9) | 
|  |  |  | private String numero; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "responsavel", length = 80) | 
|  |  |  | private String responsavel; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "data_cadastro") | 
|  |  |  | @CreationTimestamp | 
|  |  |  | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd/MM/yyyy") | 
|  |  |  | private LocalDate dataCadastro; | 
|  |  |  |  | 
|  |  |  | @ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.ALL }) | 
|  |  |  | @JoinColumn(name = "aluno_id") | 
|  |  |  | @JsonIgnore | 
|  |  |  | private Aluno aluno; | 
|  |  |  | } | 
|  |  |  | ``` | 
|  |  |  |  | 
|  |  |  | #### Visita | 
|  |  |  |  | 
|  |  |  | ``` | 
|  |  |  | @Entity | 
|  |  |  | @Table(name = "tb_visita") | 
|  |  |  | public class Visita implements Serializable { | 
|  |  |  | @Id | 
|  |  |  | @GeneratedValue(strategy = GenerationType.AUTO) | 
|  |  |  | @Column(name = "id") | 
|  |  |  | private UUID id; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "descricao", length = 500) | 
|  |  |  | private String descricao; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "responsavel_visita", length = 80) | 
|  |  |  | private String responsavelVisita; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "teve_sucesso") | 
|  |  |  | private Boolean teveSucesso; | 
|  |  |  |  | 
|  |  |  | @ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.ALL }) | 
|  |  |  | @JoinColumn(name = "ficha_id") | 
|  |  |  | @JsonBackReference | 
|  |  |  | private Ficha ficha; | 
|  |  |  |  | 
|  |  |  | @Column(nullable = false, name = "data_visita") | 
|  |  |  | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd/MM/yyyy") | 
|  |  |  | private LocalDate dataVisita; | 
|  |  |  | } | 
|  |  |  | ``` | 
|  |  |  |  | 
|  |  |  | ### Postgrees | 
|  |  |  |  | 
|  |  |  |  |