NutzCN Logo
问答 关于update单个字段更新问题?
发布于 2082天前 作者 MrSongPing 2714 次浏览 复制 上一个帖子 下一个帖子
标签:

如果表中不存在@Id/@Name/@Pk中的任何一种,那么单个字段更新还能这样写吗?dao.update(p, "^age$");

@Table("t_sys_user")
@TableIndexes({@Index(name = "INDEX_SYS_USER_LOGINNAMAE", fields = {"loginname"}, unique = true)})
public class SysUser extends Model implements Serializable {
    private static final long serialVersionUID = 1L;

    @Column
    @Comment("用户名")
    @ColDefine(type = ColType.VARCHAR, width = 120)
    private String loginname;

    @Column
    @Comment("密码")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String password;// transient 修饰符可让此字段不在对象里显示

    @Column
    @Comment("密码盐")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String salt;

    @Column
    @Comment("昵称")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String nickname;

    @Column
    @Comment("是否在线")
    @ColDefine(type = ColType.BOOLEAN)
    private boolean isOnline;

    @Column
    @Comment("是否禁用")
    @ColDefine(type = ColType.BOOLEAN)
    private boolean disabled;

    @Column
    @ColDefine(type = ColType.VARCHAR, width = 255)
    private String email;
    
    @Column
    @ColDefine(type = ColType.VARCHAR, width = 20)
    private String mobile;

    @Column
    @Comment("登陆时间")
    @ColDefine(type = ColType.DATETIME)
    private Date loginAt;

    @Column
    @Comment("登陆IP")
    @ColDefine(type = ColType.VARCHAR, width = 255)
    private String loginIp;

    @Column
    @Comment("登陆次数")
    @ColDefine(type = ColType.INT)
    private Integer loginCount;
    
    @Column
    @Comment("账户有效期")
    @ColDefine(type = ColType.DATE)
    private Date validDate;

    @Column
    @Comment("登录失败锁定时间")
    @ColDefine(type=ColType.DATETIME)
    private Date lockTime;

    @Column
    @Comment("登录失败次数")
    @ColDefine(type=ColType.INT)
    private Integer failNumber;

    private Boolean flag = false;

    @ManyMany(from = "userId", relation = "t_sys_user_role", to = "roleId")
    private List<SysRole> roles;

    protected List<SysMenu> menus;

    protected List<SysMenu> firstMenus;

    protected Map<String, List<SysMenu>> secondMenus;

    private List<SysMenu> customMenus;
11 回复

文档写的很清楚, p至少带@Id/@Name/@Pk中的一种

dao.update(XXX.class, Chain...., Cnd.where....)

@wendal Chain这个表示什么呢?

@wendal 以及Chain.make("age","+1")中的+1是指在原来的基础上增长一个,还是其他什么?

把Chain的javadoc看完

@wendal userService中构造器调用了dao。但是这种写法是错误的,前面这个sysuser.class报错了

userService.update(SysUser.class,Chain.make("failNumber","0"),Cnd.where("loginname","=",user.getLoginname()));

编译错误? 没import呗

是有的

import com.ynstack.framework.model.SysUser;

鼠标放上去出现这样的错误

Wrong 1st argument type. Found: 'java.lang.Class<com.ynstack.framework.model.SysUser>', required: 'java.lang.String

@wendal 看的提示是第一个用String类型,但是文档上第一个是class文件

userService类你自己写的吧, 封装了呗

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