use of io.jpom.model.data.UserBindWorkspaceModel in project Jpom by dromara.
the class UserBindWorkspaceService method existsWorkspace.
/**
* 判断对应的工作空间是否被用户绑定
*
* @param workspaceId 工作空间ID
* @return true 有用户绑定
*/
public boolean existsWorkspace(String workspaceId) {
UserBindWorkspaceModel userBindWorkspaceModel = new UserBindWorkspaceModel();
userBindWorkspaceModel.setWorkspaceId(workspaceId);
return super.exists(userBindWorkspaceModel);
}
use of io.jpom.model.data.UserBindWorkspaceModel in project Jpom by dromara.
the class UserBindWorkspaceService method listUserWorkspace.
/**
* 查询用户绑定的工作空间
*
* @param userId 用户ID
* @return list
*/
public List<UserBindWorkspaceModel> listUserWorkspace(String userId) {
UserBindWorkspaceModel userBindWorkspaceModel = new UserBindWorkspaceModel();
userBindWorkspaceModel.setUserId(userId);
return super.listByBean(userBindWorkspaceModel);
}
use of io.jpom.model.data.UserBindWorkspaceModel in project Jpom by dromara.
the class UserBindWorkspaceService method updateUserWorkspace.
/**
* 更新用户的工作空间信息
*
* @param userId 用户ID
* @param workspace 工作空间信息
*/
public void updateUserWorkspace(String userId, List<String> workspace) {
Assert.notEmpty(workspace, "没有任何工作空间信息");
List<UserBindWorkspaceModel> list = new HashSet<>(workspace).stream().filter(s -> {
s = StrUtil.removeSuffix(s, SYSTEM_USER);
s = StrUtil.removeSuffix(s, SSH_COMMAND_NOT_LIMITED);
MethodFeature[] values = MethodFeature.values();
for (MethodFeature value : values) {
s = StrUtil.removeSuffix(s, StrUtil.DASHED + value.name());
}
return workspaceService.exists(new WorkspaceModel(s));
}).map(s -> {
UserBindWorkspaceModel userBindWorkspaceModel = new UserBindWorkspaceModel();
userBindWorkspaceModel.setWorkspaceId(s);
userBindWorkspaceModel.setUserId(userId);
userBindWorkspaceModel.setId(UserBindWorkspaceModel.getId(userId, s));
return userBindWorkspaceModel;
}).collect(Collectors.toList());
// 删除之前的数据
UserBindWorkspaceModel userBindWorkspaceModel = new UserBindWorkspaceModel();
userBindWorkspaceModel.setUserId(userId);
super.del(super.dataBeanToEntity(userBindWorkspaceModel));
// 重新入库
super.insert(list);
}
use of io.jpom.model.data.UserBindWorkspaceModel in project Jpom by dromara.
the class UserBindWorkspaceService method exists.
/**
* 查询用户 是否存在工作空间权限
*
* @param userId 用户ID
* @param workspaceId 工作空间
* @return true 存在
*/
public boolean exists(String userId, String workspaceId) {
UserBindWorkspaceModel workspaceModel = new UserBindWorkspaceModel();
workspaceModel.setId(UserBindWorkspaceModel.getId(userId, workspaceId));
return this.exists(workspaceModel);
}
use of io.jpom.model.data.UserBindWorkspaceModel in project Jpom by dromara.
the class UserBindWorkspaceService method listUserWorkspaceInfo.
/**
* 查询用户绑定的工作空间
*
* @param userModel 用户
* @return list
*/
public List<WorkspaceModel> listUserWorkspaceInfo(UserModel userModel) {
if (userModel.isSuperSystemUser()) {
// 超级管理员有所有工作空间权限
return workspaceService.list();
}
UserBindWorkspaceModel userBindWorkspaceModel = new UserBindWorkspaceModel();
userBindWorkspaceModel.setUserId(userModel.getId());
List<UserBindWorkspaceModel> userBindWorkspaceModels = super.listByBean(userBindWorkspaceModel);
Assert.notEmpty(userBindWorkspaceModels, "没有任何工作空间信息");
List<String> collect = userBindWorkspaceModels.stream().map(UserBindWorkspaceModel::getWorkspaceId).collect(Collectors.toList());
return workspaceService.listById(collect);
}
Aggregations