service 层
public List<PluginVO> getUserPluginList(String userId, String installState) {
Map<String, String> params = new HashMap<String, String>();
params.put("userId", userId);
params.put("installState", installState);
List<UserPlugin> userPluginList = this.userPluginDao.find("getByUserIdAndInstallState", params);
if (userPluginList == null || userPluginList.isEmpty()) return new ArrayList<PluginVO>(0);
List<PluginVO> pluginVOList = new ArrayList<PluginVO>(userPluginList.size());
PluginVO pluginVO = null;
for (UserPlugin plugin : userPluginList) {
OAuthClientPlugin clientPlugin = this.oauthClientPluginDao.load("getByClientId", plugin.getClientId());
if (clientPlugin == null || plugin.getVersion() == null || clientPlugin.getVersion() == null) continue;
pluginVO = new PluginVO();
pluginVO.setName(clientPlugin.getName());
pluginVO.setClientId(plugin.getClientId());
pluginVO.setInstallState(plugin.getInstallState());
pluginVO.setUserId(plugin.getUserId());
if ((plugin.getVersion().toString()).equals(clientPlugin.getVersion().toString())) {
pluginVO.setIsUpdate("N");
} else {
pluginVO.setIsUpdate("Y");
}
pluginVO.setVersion(plugin.getVersion());
pluginVOList.add(pluginVO);
}
return pluginVOList;
}(pluginVO 是 oauth_client_plugin 和user plugin 拼接后的表 家 isupdate字段)
rpc层
@ResourceMapping(value = "/plugin/userList", method = HttpMethod.GET)
public List<UserPluginVO> getPluginUserList() {
SecurityContext securityContext = securityContextHolder.getSecurityContext();
List<UserPluginVO> voes = new ArrayList<UserPluginVO>();
List<PluginVO> userPluginList = clientPluginService.getUserPluginList(securityContext.getCurrentUserId(), "Y");
UserPluginVO userPluginVO = null;
for (PluginVO userPlugin : userPluginList) {
userPluginVO = new UserPluginVO();
// 属性拷贝
BeanUtils.copyProperties(userPlugin, userPluginVO);
voes.add(userPluginVO);
}// end for
return voes;
}
转载于:https://blog.51cto.com/wendyjiangyue/1119845