Adding DB for user management

This commit is contained in:
BrokenFire 2018-02-12 11:16:44 +01:00
parent 26759154df
commit aeeac91a32
5 changed files with 173 additions and 6 deletions

View File

@ -34,12 +34,13 @@ dependencies {
compile("com.sedmelluq:lavaplayer:1.2.45") compile("com.sedmelluq:lavaplayer:1.2.45")
compile 'net.dv8tion:JDA:3.3.1_303' compile 'net.dv8tion:JDA:3.3.1_303'
compile group: 'org.json', name: 'json', version: '20160810' compile group: 'org.json', name: 'json', version: '20160810'
compile 'org.springframework.security:spring-security-web:5.0.1.RELEASE'
// JPA Data (We are going to use Repositories, Entities, Hibernate, etc...) // JPA Data (We are going to use Repositories, Entities, Hibernate, etc...)
//compile("org.springframework.boot:spring-boot-starter-data-jpa") { compile("org.springframework.boot:spring-boot-starter-data-jpa") {
// exclude group:"org.springframework.boot", module: "spring-boot-starter-logging" exclude group:"org.springframework.boot", module: "spring-boot-starter-logging"
//} }
// Use MySQL Connector-J // Use MySQL Connector-J
//compile 'mysql:mysql-connector-java' compile 'mysql:mysql-connector-java'
compile 'org.reflections:reflections:0.9.11' compile 'org.reflections:reflections:0.9.11'

View File

@ -0,0 +1,72 @@
package net.Broken.DB.Entity;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class PendingUserEntity {
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
private Integer id;
private String name;
private String jdaId;
private String checkToken;
private String password;
public PendingUserEntity() {
}
public PendingUserEntity(String name, String jdaId, String checkToken, String password) {
this.name = name;
this.jdaId = jdaId;
this.checkToken = checkToken;
this.password = password;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getJdaId() {
return jdaId;
}
public void setJdaId(String jdaId) {
this.jdaId = jdaId;
}
public String getCheckToken() {
return checkToken;
}
public void setCheckToken(String checkToken) {
this.checkToken = checkToken;
}
}

View File

@ -0,0 +1,71 @@
package net.Broken.DB.Entity;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class UserEntity {
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
private Integer id;
private String name;
private String jdaId;
private String apiToken;
private String password;
public UserEntity() {
}
public UserEntity(PendingUserEntity pendingUserEntity, String apiToken) {
this.name = pendingUserEntity.getName();
this.jdaId = pendingUserEntity.getJdaId();
this.password = pendingUserEntity.getPassword();
this.apiToken = apiToken;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getJdaId() {
return jdaId;
}
public void setJdaId(String jdaId) {
this.jdaId = jdaId;
}
public String getApiToken() {
return apiToken;
}
public void setApiToken(String apiToken) {
this.apiToken = apiToken;
}
}

View File

@ -0,0 +1,12 @@
package net.Broken.DB.Repository;
import net.Broken.DB.Entity.PendingUserEntity;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
public interface PendingUserRepository extends CrudRepository<PendingUserEntity, Integer> {
List<PendingUserEntity> findByJdaId(String jdaId);
}

View File

@ -0,0 +1,11 @@
package net.Broken.DB.Repository;
import net.Broken.DB.Entity.UserEntity;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
public interface UserRepository extends CrudRepository<UserEntity, Integer>{
List<UserEntity> findByName(String name);
List<UserEntity> findByJdaId(String jdaId);
}