remove servers from database

This commit is contained in:
dkanada 2021-04-14 18:19:19 +09:00
commit 8a73fcf6a4
7 changed files with 25 additions and 86 deletions

View file

@ -1,30 +0,0 @@
package com.dkanada.gramophone.model;
import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
import org.jellyfin.apiclient.model.system.SystemInfo;
import java.util.UUID;
@Entity(tableName = "servers")
public class Server {
@NonNull
@PrimaryKey
public String id;
public String name;
public String url;
public Server() {
this.id = UUID.randomUUID().toString();
}
public Server(SystemInfo systemInfo) {
this.id = systemInfo.getId();
this.name = systemInfo.getServerName();
this.url = systemInfo.getWanAddress();
}
}

View file

@ -2,7 +2,6 @@ package com.dkanada.gramophone.model;
import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.PrimaryKey;
import org.jellyfin.apiclient.model.users.AuthenticationResult;
@ -14,28 +13,20 @@ public class User {
@NonNull
@PrimaryKey
public String id;
@ForeignKey(
entity = Server.class,
parentColumns = {"id"},
childColumns = {"serverId"},
onDelete = ForeignKey.CASCADE
)
public String serverId;
public String name;
public String server;
public String token;
public User() {
this.id = UUID.randomUUID().toString();
}
public User(AuthenticationResult result) {
public User(AuthenticationResult result, String server) {
this.id = result.getUser().getId();
this.serverId = result.getServerId();
this.name = result.getUser().getName();
this.server = server;
this.token = result.getAccessToken();
}
}