子类集合转父类结合:
@Override
public ArrayList<UserInfo> getOwnedUserList(Account account) {
AccountTypeEnum accountType = AccountTypeEnum.getEnum(value));
// 父类集合
ArrayList<UserInfo> ownedUserList = new ArrayList<>();
switch (accountType) {
case Sup:
//子类集合
ArrayList<Account> tempUserList = getAccountListByParentId(account.getId());
// 子类集合转父类结合
ownedUserList.addAll(tempUserList);
break;
case HC:
P p = pService.getPByAccountId(account.getId());
default:
break;
}
return ownedUserList;
}
1. ExtUser
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ExtUser extends Account {
public Long pCount;
}
2. Account
@TableName("account")
@Data
public class Account extends UserInfo implements Serializable {
private static final long serialVersionUID = 1L;
private String password;
private Integer deleteFlag;
}
3. UserInfo
@Data
public class UserInfo implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private String username;
}