1 | package edu.ucsb.cs156.happiercows.entities; | |
2 | ||
3 | import com.fasterxml.jackson.annotation.JsonIgnore; | |
4 | import com.fasterxml.jackson.annotation.JsonInclude; | |
5 | import lombok.*; | |
6 | ||
7 | import javax.persistence.*; | |
8 | import java.util.List; | |
9 | ||
10 | @Data | |
11 | @AllArgsConstructor | |
12 | @NoArgsConstructor(access = AccessLevel.PROTECTED) | |
13 | @Builder | |
14 | @Entity(name = "users") | |
15 | public class User { | |
16 | @Id | |
17 | @GeneratedValue(strategy = GenerationType.IDENTITY) | |
18 | private long id; | |
19 | private String email; | |
20 | private String googleSub; | |
21 | private String pictureUrl; | |
22 | private String fullName; | |
23 | private String givenName; | |
24 | private String familyName; | |
25 | private boolean emailVerified; | |
26 | private String locale; | |
27 | private String hostedDomain; | |
28 | private boolean admin; | |
29 | ||
30 | // this is used by the frontend | |
31 | @ManyToMany(fetch = FetchType.EAGER) | |
32 | @JoinTable(name = "user_commons", | |
33 | joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"), | |
34 | inverseJoinColumns = @JoinColumn(name = "commons_id", referencedColumnName = "id")) | |
35 | private List<Commons> commons; | |
36 | ||
37 | @OneToMany(mappedBy = "user", cascade = CascadeType.REMOVE) | |
38 | @JsonIgnore | |
39 | private List<UserCommons> joinedCommons; | |
40 | ||
41 | ||
42 | @Override | |
43 | public String toString() { | |
44 |
1
1. toString : replaced return value with "" for edu/ucsb/cs156/happiercows/entities/User::toString → KILLED |
return String.format("User: id=%d email=%s", id, email); |
45 | } | |
46 | } | |
Mutations | ||
44 |
1.1 |