我们可以通过java 8提供的 ::
关键字来快速访问类的构造方法、对象方法、静态方法。
下面例子通过’::'关键字获取SysUserRole对象中的属性值getUserId
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class SysUserRole implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
/**
* 用户id
*/
private String userId;
/**
* 角色id
*/
private String roleId;
public SysUserRole() {
}
public SysUserRole(String userId, String roleId) {
this.userId = userId;
this.roleId = roleId;
}
}
通过userid赋值getUserId,查询SysUserRole对象list
List<SysUserRole> userRole = sysUserRoleService.list(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, userid));