mirror of
https://github.com/skogaby/butterfly.git
synced 2026-09-09 08:45:10 -05:00
Add a model and DAO for users of the server (not game users, server users)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -32,6 +32,7 @@ gradle-app.setting
|
||||
!gradle-wrapper.jar
|
||||
.gradletasknamecache
|
||||
/bin/
|
||||
.DS_Store
|
||||
|
||||
# vscode stuff
|
||||
.project
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.buttongames.butterfly.hibernate.dao.impl;
|
||||
|
||||
import com.buttongames.butterfly.hibernate.dao.AbstractHibernateDao;
|
||||
import com.buttongames.butterfly.model.ButterflyUser;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* DAO for interacting with <code>ButterflyUser</code> objects in the database.
|
||||
* @author skogaby (skogabyskogaby@gmail.com)
|
||||
*/
|
||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
@Repository
|
||||
public class ButterflyUserDao extends AbstractHibernateDao<ButterflyUser> {
|
||||
|
||||
@Autowired
|
||||
public ButterflyUserDao(final SessionFactory sessionFactory) {
|
||||
super(sessionFactory);
|
||||
setClazz(ButterflyUser.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.buttongames.butterfly.model;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Model class for a user within the server. This user is tied to a person -- email
|
||||
* address, password, etc. This user also has a PIN, which is applied across any
|
||||
* and all cards they possess. <code>ButterflyUser</code> does *NOT* represent a profile for any
|
||||
* particular game.
|
||||
* @author skogaby (skogabyskogaby@gmail.com)
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "users")
|
||||
public class ButterflyUser implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The integer user ID for this user. Serves as the primary key in the database.
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(name = "id")
|
||||
private long userId;
|
||||
|
||||
/**
|
||||
* The user's card PIN.
|
||||
*/
|
||||
@Column(name = "pin")
|
||||
private String pin;
|
||||
|
||||
public ButterflyUser() { }
|
||||
|
||||
public long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getPin() {
|
||||
return pin;
|
||||
}
|
||||
|
||||
public void setPin(String pin) {
|
||||
this.pin = pin;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.buttongames.butterfly.spring.configuration;
|
||||
|
||||
import com.buttongames.butterfly.hibernate.dao.impl.ButterflyUserDao;
|
||||
import com.buttongames.butterfly.util.PathUtils;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
@@ -73,4 +75,9 @@ public class HibernateConfiguration {
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ButterflyUserDao butterflyUserDao(final SessionFactory sessionFactory) {
|
||||
return new ButterflyUserDao(sessionFactory);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user