48 lines
1.4 KiB
Java
48 lines
1.4 KiB
Java
package github.benjamin.equipreservebackend.vo;
|
|
|
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
|
import github.benjamin.equipreservebackend.entity.Team;
|
|
import github.benjamin.equipreservebackend.entity.User;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.Data;
|
|
import lombok.NoArgsConstructor;
|
|
|
|
import java.util.Map;
|
|
|
|
@Data
|
|
@AllArgsConstructor
|
|
@NoArgsConstructor
|
|
public class UserVO {
|
|
|
|
@JsonSerialize(using = ToStringSerializer.class)
|
|
private Long userId;
|
|
private String username;
|
|
private String team;
|
|
@JsonSerialize(using = ToStringSerializer.class)
|
|
private Long teamId;
|
|
private String name;
|
|
private String phone;
|
|
@JsonSerialize(using = ToStringSerializer.class)
|
|
private Long roleId;
|
|
|
|
public UserVO(User u, Team t) {
|
|
this.userId = u.getId();
|
|
this.username = u.getUsername();
|
|
this.name = u.getName();
|
|
this.phone = u.getPhone();
|
|
this.team = t.getName();
|
|
this.teamId = u.getId();
|
|
}
|
|
|
|
public UserVO(User u, Map<Long, Team> teamMap, Map<Long, Long> roleMap) {
|
|
this.userId = u.getId();
|
|
this.username = u.getUsername();
|
|
this.name = u.getName();
|
|
this.phone = u.getPhone();
|
|
this.team = teamMap.get(u.getTeamId()).getName();
|
|
this.teamId = u.getTeamId();
|
|
this.roleId = roleMap.get(u.getId());
|
|
}
|
|
}
|