package atom.demo.entity;

import atom.demo.dto.UserDto;
import atom.demo.entity.base.BaseEntity;
import org.springframework.beans.BeanUtils;

import javax.persistence.*;

/**
 * Created by xuetong on 2015/4/9.
 */
@Entity
@Table(name = "BF_USER")
public class User extends BaseEntity {

	private String userName;
	private String password;

	@ManyToOne(fetch= FetchType.EAGER)
	@JoinColumn(name="groupId")
	private Group userGroup;

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Group getUserGroup() {
		return userGroup;
	}

	public void setUserGroup(Group userGroup) {
		this.userGroup = userGroup;
	}

	public User() {
	}

	public User(String userName, String password) {
		this.userName = userName;
		this.password = password;
	}

	public User(UserDto userDto){
		if (null == userDto) { return;}
		BeanUtils.copyProperties(userDto, this);
	}
}
