0.0.12, new fields of User
This commit is contained in:
1 parent
ac328d8cef
commit
60f2de1b5b
5 files changed
+45
-12
No files matched your search
@@ -26,10 +26,14 @@ public class User implements UserDetails {
|
||||
private String status;
|
||||
private String iconPath;
|
||||
private String email;
|
||||
private String about;
|
||||
private String country;
|
||||
private String city;
|
||||
|
||||
|
||||
@ElementCollection(targetClass = String.class, fetch = FetchType.EAGER)
|
||||
@CollectionTable(name = "user_tag", joinColumns = @JoinColumn(name = "user_id"))
|
||||
private Set<String> tags;
|
||||
@CollectionTable(name = "user_technologies", joinColumns = @JoinColumn(name = "user_id"))
|
||||
private Set<String> technologies;
|
||||
|
||||
@ElementCollection(targetClass = String.class, fetch = FetchType.EAGER)
|
||||
@CollectionTable(name = "user_profession", joinColumns = @JoinColumn(name = "user_id"))
|
||||
@@ -47,6 +51,17 @@ public class User implements UserDetails {
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Set<Role> roles;
|
||||
|
||||
@ElementCollection(targetClass = String.class, fetch = FetchType.EAGER)
|
||||
@CollectionTable(name = "user_lang", joinColumns = @JoinColumn(name = "user_id"))
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Set<String> langs;
|
||||
|
||||
@ElementCollection
|
||||
@CollectionTable(name = "user_contact",
|
||||
joinColumns = {@JoinColumn(name = "user_id")})
|
||||
@MapKeyColumn(name = "media")
|
||||
private Map<String, String> contacts;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
||||
@@ -6,6 +6,7 @@ import site.easystartup.web.project.domain.model.Participant;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@@ -22,4 +23,9 @@ public class UserDto implements Serializable {
|
||||
private Set<Long> projects;
|
||||
private List<Participant> requests;
|
||||
private Set<Role> roles;
|
||||
private String about;
|
||||
private String country;
|
||||
private String city;
|
||||
private Set<String> langs;
|
||||
private Map<String, String> contacts;
|
||||
}
|
||||
@@ -22,7 +22,7 @@ public class Tag {
|
||||
@Column(name = "tage_name")
|
||||
private String tagName;
|
||||
|
||||
@ManyToMany(mappedBy = "technology")
|
||||
@ManyToMany(mappedBy = "projects")
|
||||
@ToString.Exclude
|
||||
private Set<Project> projects;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@@ -35,4 +36,12 @@ public class UserRequest {
|
||||
private Set<Long> projects;
|
||||
private List<Participant> requests;
|
||||
private Set<Role> roles;
|
||||
@Size(max = 1000, message = "Status should be no more 1000 signs")
|
||||
private String about;
|
||||
@Size(max = 100, message = "Status should be no more 100 signs")
|
||||
private String country;
|
||||
@Size(max = 100, message = "Status should be no more 100 signs")
|
||||
private String city;
|
||||
private Set<String> langs;
|
||||
private Map<String, String> contacts;
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package site.easystartup.web.service;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.tomcat.util.http.fileupload.FileUpload;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
@@ -12,7 +11,7 @@ import site.easystartup.web.request.UserRequest;
|
||||
import site.easystartup.web.storage.service.StorageService;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.util.TreeSet;
|
||||
import java.util.Collections;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -46,13 +45,17 @@ public class UserService {
|
||||
user.setStatus(userRequest.getStatus());
|
||||
|
||||
if(userRequest.getIcon() != null) storageService.saveImage(userRequest.getIcon(), username + "-icon");
|
||||
user.setIconPath(user.getIconPath() == null ? user.getIconPath() : username + "-icon.jpg");
|
||||
|
||||
user.setEmail(userRequest.getEmail() == null ? user.getEmail() : userRequest.getEmail());
|
||||
user.setTags(userRequest.getTags() == null ? user.getTags() : userRequest.getTags());
|
||||
user.setProfessions(userRequest.getProfessions() == null ? user.getProfessions() : userRequest.getProfessions());
|
||||
user.setProjects(userRequest.getProjects() == null ? user.getProjects() : userRequest.getProjects());
|
||||
user.setRequests(userRequest.getRequests() == null ? user.getRequests() : userRequest.getRequests());
|
||||
user.setIconPath(user.getIconPath() == null ? "" : username + "-icon.jpg");
|
||||
user.setEmail(userRequest.getEmail() == null ? "" : userRequest.getEmail());
|
||||
user.setTechnologies(userRequest.getTags() == null ? Collections.emptySet() : userRequest.getTags());
|
||||
user.setProfessions(userRequest.getProfessions() == null ? Collections.emptySet() : userRequest.getProfessions());
|
||||
user.setProjects(userRequest.getProjects() == null ? Collections.emptySet() : userRequest.getProjects());
|
||||
user.setRequests(userRequest.getRequests() == null ? Collections.emptyList() : userRequest.getRequests());
|
||||
user.setAbout(userRequest.getAbout() == null ? "" : userRequest.getAbout());
|
||||
user.setCountry(userRequest.getCountry() == null ? "" : userRequest.getCountry());
|
||||
user.setCity(userRequest.getCity() == null ? "" : userRequest.getCity());
|
||||
user.setLangs(userRequest.getLangs() == null ? Collections.emptySet() : userRequest.getLangs());
|
||||
user.setContacts(userRequest.getContacts() == null ? Collections.emptyMap() : userRequest.getContacts());
|
||||
return userRepo.save(user);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user