1、如果属性完全一致,可以使用已有方法
BeanUtils.copyProperties(clientPlugin, clientPluginVO);
@SuppressWarnings("all")
@ResourceMapping(value = "/plugin/list", method = HttpMethod.GET)
public List<ClientPluginVO> getClientPluginList() {
SecurityContext securityContext = securityContextHolder.getSecurityContext();
List<ClientPluginVO> voes = new ArrayList<ClientPluginVO>();
List<OAuthClientPlugin> clientPluginList = clientPluginService.getClientPluginList(securityContext.getClientId(),
"normal", "Y");
ClientPluginVO clientPluginVO = null;
for (OAuthClientPlugin clientPlugin : clientPluginList) {
clientPluginVO = new ClientPluginVO();
BeanUtils.copyProperties(clientPlugin, clientPluginVO);
voes.add(clientPluginVO);
}
return voes;
}
2、属性不完全一致,可以自己写方法实现转换
private ClientPluginVO convertOAuthClientPlugin2VO(OAuthClientPlugin clientPlugin) {
ClientPluginVO vo = new ClientPluginVO();
vo.setClientId(clientPlugin.getClientId());
vo.setName(clientPlugin.getName());
vo.setUserId(clientPlugin.getUserId());
vo.setPluginState(clientPlugin.getPluginState());
vo.setTargetClientId(clientPlugin.getTargetClientId());
vo.setUrl(clientPlugin.getUrl());
vo.setVersion(clientPlugin.getVersion());
vo.setPlatform(clientPlugin.getPlatform());
vo.setIsOfficial(clientPlugin.getIsOfficial());
vo.setGmtCreate(clientPlugin.getGmtCreate());
vo.setGmtModified(clientPlugin.getGmtModified());
return vo;
}
@SuppressWarnings("all")
@ResourceMapping(value = "/plugin/list", method = HttpMethod.GET)
public List<ClientPluginVO> getClientPluginList() {
SecurityContext securityContext = securityContextHolder.getSecurityContext();
List<ClientPluginVO> voes = new ArrayList<ClientPluginVO>();
List<OAuthClientPlugin> clientPluginList = clientPluginService.getClientPluginList(securityContext.getClientId(),
"normal", "Y");
for (OAuthClientPlugin clientPlugin : clientPluginList) {
voes.add(this.convertOAuthClientPlugin2VO(clientPlugin));
}
return voes;
}