Copy the attribute value of the object to the new object

Today, when looking at the source code of the login verification of the jeegboot open source framework, I found the following code

public LoginUser getUserByName(String username) {
	if(oConvertUtils.isEmpty(username)) {
		return null;
	}
	LoginUser loginUser = new LoginUser();
	SysUser sysUser = userMapper.getUserByName(username);
	if(sysUser==null) {
		return null;
	}
	BeanUtils.copyProperties(sysUser, loginUser);
	return loginUser;
}

The parameters of the loginUser object are a subset of the sysUser object, using the BeanUtils.copyProperties(sysUser, loginUser); method of the spring framework to encapsulate the corresponding parameters in sysUser into loginUser to
make a record

Guess you like

Origin blog.csdn.net/weixin_44684303/article/details/110389698
Recommended