NutzCN Logo
问答 入门手册-为Shiro做准备-修改User类-代码加在哪里?
发布于 2905天前 作者 lampardlee 3161 次浏览 复制 上一个帖子 下一个帖子
标签: nutzbook

修改User类
通过Daos.migration实现表结构自动修改
Daos.migration(dao, User.class, true, false);
这一行代码应该加在User类的哪个地方?

package net.wendal.nutzbook.bean;
import java.util.Date;
import java.util.List;
import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Id;
import org.nutz.dao.entity.annotation.ManyMany;
import org.nutz.dao.entity.annotation.Name;
import org.nutz.dao.entity.annotation.One;
import org.nutz.dao.entity.annotation.Table;
import net.wendal.nutzbook.bean.UserProfile;
@Table("t_user")
public class User extends BasePojo {
	@Id
    private int id;
    @Name
    @Column
    private String name;
    @Column("passwd")
    private String password;
    @Column
    private String salt;
    @Column
    private boolean locked;
    @ManyMany(from="u_id", relation="t_user_role", target=Role.class, to="role_id")
    protected List<Role> roles;
    @ManyMany(from="u_id", relation="t_user_permission", target=Permission.class, to="permission_id")
    protected List<Permission> permissions;
    @One(target=UserProfile.class, field="id", key="userId")
	protected UserProfile profile;

    public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getSalt() {
		return salt;
	}
	public void setSalt(String salt) {
		this.salt = salt;
	}
	public boolean isLocked() {
		return locked;
	}
	public void setLocked(boolean locked) {
		this.locked = locked;
	}
	public List<Role> getRoles() {
		return roles;
	}
	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}
	public List<Permission> getPermissions() {
		return permissions;
	}
	public void setPermissions(List<Permission> permissions) {
		this.permissions = permissions;
	}
	public UserProfile getProfile() {
		return profile;
	}
	public void setProfile(UserProfile profile) {
		this.profile = profile;
	}
}

1 回复

加在MainSetup.init方法, Daos.createTableInPackage之后.

添加回复
请先登陆
回到顶部