| | |
| | | |
| | | import com.tourguide.modules.user.entity.AdminUser; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** 管理后台账号的脱敏返回对象,不包含密码字段。 */ |
| | | public class UserResponse { |
| | |
| | | private final String mobile; |
| | | private final String avatar; |
| | | private final String roleCode; |
| | | private final List<String> menuCodes; |
| | | private final Integer status; |
| | | private final LocalDateTime createdAt; |
| | | |
| | | private UserResponse(AdminUser user) { |
| | | private UserResponse(AdminUser user, List<String> menuCodes) { |
| | | this.id = user.getId(); |
| | | this.username = user.getUsername(); |
| | | this.nickname = user.getNickname(); |
| | | this.mobile = user.getMobile(); |
| | | this.avatar = user.getAvatar(); |
| | | this.roleCode = user.getRoleCode(); |
| | | this.menuCodes = menuCodes; |
| | | this.status = user.getStatus(); |
| | | this.createdAt = user.getCreatedAt(); |
| | | } |
| | | public static UserResponse from(AdminUser user) { return new UserResponse(user); } |
| | | public static UserResponse from(AdminUser user) { |
| | | return new UserResponse(user, Collections.<String>emptyList()); |
| | | } |
| | | public static UserResponse from(AdminUser user, List<String> menuCodes) { |
| | | return new UserResponse(user, Collections.unmodifiableList(new ArrayList<String>(menuCodes))); |
| | | } |
| | | public Long getId() { return id; } |
| | | public String getUsername() { return username; } |
| | | public String getNickname() { return nickname; } |
| | | public String getMobile() { return mobile; } |
| | | public String getAvatar() { return avatar; } |
| | | public String getRoleCode() { return roleCode; } |
| | | public List<String> getMenuCodes() { return menuCodes; } |
| | | public Integer getStatus() { return status; } |
| | | public LocalDateTime getCreatedAt() { return createdAt; } |
| | | } |