почти работает

This commit is contained in:
bekodeg 2024-04-13 16:01:02 +04:00
parent 57a412b0d7
commit 4cc4300a14
4 changed files with 11 additions and 17 deletions

View File

@ -1,5 +1,5 @@
package com.example.demo.core.config; package com.example.demo.core.config;
public class Constants { public class Constants {
public static final String API_URL = "/api"; public static final String API_URL = "/api/2";
} }

View File

@ -9,7 +9,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
public class WebConfig implements WebMvcConfigurer { public class WebConfig implements WebMvcConfigurer {
@Override @Override
public void addCorsMappings(@NonNull CorsRegistry registry) { public void addCorsMappings(@NonNull CorsRegistry registry) {
registry.addMapping("lab2/**") registry.addMapping("/**")
.allowedMethods("GET", "POST", "PUT", "DELETE"); .allowedMethods("GET", "POST", "PUT", "DELETE");
} }
} }

View File

@ -2,9 +2,7 @@ package com.example.demo.users.api;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.Min; import jakarta.validation.constraints.*;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Past;
import java.util.Date; import java.util.Date;
@ -17,9 +15,6 @@ public class UserDTO {
@NotNull @NotNull
@Min(4) @Min(4)
private String password; private String password;
@NotNull
@Past
private Date dateCreate;
public String getName() { public String getName() {
return name; return name;
@ -27,11 +22,6 @@ public class UserDTO {
public void setName(String name){ public void setName(String name){
this.name = name; this.name = name;
} }
public Date getDateCreate() {
return dateCreate;
}
public String getPassword() { public String getPassword() {
return password; return password;
} }

View File

@ -2,6 +2,8 @@ package com.example.demo.users.model;
import com.example.demo.core.model.BaseEntity; import com.example.demo.core.model.BaseEntity;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
public class UserEntity extends BaseEntity { public class UserEntity extends BaseEntity {
@ -13,11 +15,13 @@ public class UserEntity extends BaseEntity {
super(); super();
} }
public UserEntity(Long id, String name, String password, Date dateCreate){ SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yy");
public UserEntity(Long id, String name, String password, String dateCreate) throws ParseException {
super(id); super(id);
this.name = name; this.name = name;
this.password = password; this.password = password;
this.dateCreate = dateCreate; this.dateCreate = new Date();
} }
public String getName(){ public String getName(){
@ -36,8 +40,8 @@ public class UserEntity extends BaseEntity {
this.password = password; this.password = password;
} }
public Date getDateCreate(){ public String getDateCreate(){
return dateCreate; return formatter.format(dateCreate);
} }
public void setDateCreate(Date dateCreate){ public void setDateCreate(Date dateCreate){