Search in sources :

Example 1 with ProjectResponse

use of com.webank.wedatasphere.qualitis.project.response.ProjectResponse in project Qualitis by WeBankFinTech.

the class ProjectServiceImpl method getAllProjectByUserReal.

@Override
public GetAllResponse<ProjectResponse> getAllProjectByUserReal() {
    // Get username
    String loginUser = HttpUtils.getUserName(httpServletRequest);
    // Find project user in different permissions.
    List<Integer> permissions = new ArrayList<>();
    permissions.add(ProjectUserPermissionEnum.CREATOR.getCode());
    permissions.add(ProjectUserPermissionEnum.DEVELOPER.getCode());
    permissions.add(ProjectUserPermissionEnum.OPERATOR.getCode());
    permissions.add(ProjectUserPermissionEnum.BUSSMAN.getCode());
    List<Project> projects = projectUserDao.findByUsernameAndPermission(loginUser, permissions);
    long total = projectUserDao.countByUsernameAndPermission(loginUser, permissions);
    List<ProjectResponse> projectResponses = new ArrayList<>();
    for (Project project : projects) {
        projectResponses.add(new ProjectResponse(project));
    }
    GetAllResponse<ProjectResponse> response = new GetAllResponse<>();
    response.setTotal(total);
    response.setData(projectResponses);
    return response;
}
Also used : Project(com.webank.wedatasphere.qualitis.project.entity.Project) ProjectResponse(com.webank.wedatasphere.qualitis.project.response.ProjectResponse) GetAllResponse(com.webank.wedatasphere.qualitis.response.GetAllResponse)

Example 2 with ProjectResponse

use of com.webank.wedatasphere.qualitis.project.response.ProjectResponse in project Qualitis by WeBankFinTech.

the class ProjectServiceImpl method getAllProjectByUserReal.

@Override
public GetAllResponse<ProjectResponse> getAllProjectByUserReal(PageRequest request, Integer projectType) throws UnExpectedRequestException {
    // Check Arguments
    PageRequest.checkRequest(request);
    // Get user name
    String userName = HttpUtils.getUserName(httpServletRequest);
    // Paging get project
    int page = request.getPage();
    int size = request.getSize();
    List<ProjectUser> projectUsers = projectUserDao.findByUsernameAndPermissionAndProjectType(userName, projectType, page, size);
    long total = projectUserDao.countByUsernameAndPermissionAndProjectType(userName, projectType);
    List<ProjectResponse> projectResponses = new ArrayList<>();
    for (ProjectUser projectUser : projectUsers) {
        projectResponses.add(new ProjectResponse(projectUser.getProject()));
    }
    GetAllResponse<ProjectResponse> response = new GetAllResponse<>();
    response.setData(projectResponses);
    response.setTotal(total);
    return response;
}
Also used : ProjectUser(com.webank.wedatasphere.qualitis.project.entity.ProjectUser) ProjectResponse(com.webank.wedatasphere.qualitis.project.response.ProjectResponse) GetAllResponse(com.webank.wedatasphere.qualitis.response.GetAllResponse)

Aggregations

ProjectResponse (com.webank.wedatasphere.qualitis.project.response.ProjectResponse)2 GetAllResponse (com.webank.wedatasphere.qualitis.response.GetAllResponse)2 Project (com.webank.wedatasphere.qualitis.project.entity.Project)1 ProjectUser (com.webank.wedatasphere.qualitis.project.entity.ProjectUser)1