use of com.webank.wedatasphere.qualitis.response.GetAllResponse in project Qualitis by WeBankFinTech.
the class ProxyUserServiceImpl method getAllProxyUser.
@Override
public GeneralResponse<?> getAllProxyUser(PageRequest request) throws UnExpectedRequestException {
// Check Arguments
PageRequest.checkRequest(request);
// Query by page and size
int page = request.getPage();
int size = request.getSize();
Sort sort = new Sort(Sort.Direction.ASC, "id");
Pageable pageable = org.springframework.data.domain.PageRequest.of(page, size, sort);
List<ProxyUser> proxyUsers = proxyUserRepository.findAll(pageable).getContent();
long total = proxyUserRepository.count();
List<AddProxyUserResponse> proxyUserResponses = new ArrayList<>();
for (ProxyUser proxyUser : proxyUsers) {
AddProxyUserResponse tmp = new AddProxyUserResponse(proxyUser);
proxyUserResponses.add(tmp);
}
GetAllResponse<AddProxyUserResponse> response = new GetAllResponse<>();
response.setTotal(total);
response.setData(proxyUserResponses);
LOGGER.info("Succeed to find all proxyUsers, response: {}", response);
return new GeneralResponse<>("200", "{&SUCCEED_TO_FIND_ALL_PROXYUSERS}", response);
}
use of com.webank.wedatasphere.qualitis.response.GetAllResponse in project Qualitis by WeBankFinTech.
the class RolePermissionServiceImpl method findAllRolePermission.
@Override
public GeneralResponse<GetAllResponse<RolePermissionResponse>> findAllRolePermission(PageRequest request) throws UnExpectedRequestException {
// Check Arguments
PageRequest.checkRequest(request);
int page = request.getPage();
int size = request.getSize();
List<RolePermission> rolePermissions = rolePermissionDao.findAllRolePermission(page, size);
long total = rolePermissionDao.countAll();
List<RolePermissionResponse> rolePermissionResponses = new ArrayList<>();
for (RolePermission rolePermission : rolePermissions) {
RolePermissionResponse tmp = new RolePermissionResponse(rolePermission);
rolePermissionResponses.add(tmp);
}
GetAllResponse<RolePermissionResponse> responses = new GetAllResponse<>();
responses.setData(rolePermissionResponses);
responses.setTotal(total);
LOGGER.info("Succeed to find all role_permission, response: {}, current_user: {}", responses, HttpUtils.getUserName(httpServletRequest));
return new GeneralResponse<>("200", "{&FIND_ALL_ROLE_PERMISSION_SUCCESSFULLY}", responses);
}
use of com.webank.wedatasphere.qualitis.response.GetAllResponse in project Qualitis by WeBankFinTech.
the class UserServiceImpl method findAllUser.
@Override
public GeneralResponse<GetAllResponse<UserResponse>> findAllUser(PageRequest request) throws UnExpectedRequestException {
// Check Arguments
PageRequest.checkRequest(request);
int page = request.getPage();
int size = request.getSize();
List<User> users = userDao.findAllUser(page, size);
long total = userDao.countAll();
List<UserResponse> userResponses = new ArrayList<>();
for (User user : users) {
UserResponse tmp = new UserResponse(user);
userResponses.add(tmp);
}
GetAllResponse<UserResponse> response = new GetAllResponse<>();
response.setTotal(total);
response.setData(userResponses);
LOGGER.info("Succeed to find all users, response: {}, current_user: {}", response, HttpUtils.getUserName(httpServletRequest));
return new GeneralResponse<>("200", "{&FIND_ALL_USERS_SUCCESSFULLY}", response);
}
use of com.webank.wedatasphere.qualitis.response.GetAllResponse in project Qualitis by WeBankFinTech.
the class DepartmentServiceImpl method findAllDepartment.
@Override
public GeneralResponse<GetAllResponse<DepartmentResponse>> findAllDepartment(PageRequest request) throws UnExpectedRequestException {
PageRequest.checkRequest(request);
int page = request.getPage();
int size = request.getSize();
long total = departmentDao.countDepartment();
List<Department> departmentList = departmentDao.findAllDepartment(page, size);
List<DepartmentResponse> departmentResponses = new ArrayList<>(departmentList.size());
for (Department department : departmentList) {
departmentResponses.add(new DepartmentResponse(department));
}
GetAllResponse<DepartmentResponse> responses = new GetAllResponse<>();
responses.setData(departmentResponses);
responses.setTotal(total);
LOGGER.info("Succeed to find all departments, page: {}, size: {}, departments: {}", page, size, responses);
return new GeneralResponse("200", "{&GET_DEPARTMENT_SUCCESSFULLY}", responses);
}
use of com.webank.wedatasphere.qualitis.response.GetAllResponse in project Qualitis by WeBankFinTech.
the class ApplicationServiceImpl method filterStatusApplication.
@Override
public GeneralResponse<?> filterStatusApplication(FilterStatusRequest request) throws UnExpectedRequestException {
// Check arguments
FilterStatusRequest.checkRequest(request);
String userName = HttpUtils.getUserName(httpServletRequest);
if (request.getStatus() != null) {
LOGGER.info("User: {} wants to find applications with status: {}", userName, request.getStatus());
} else {
LOGGER.info("User: {} wants to find all applications", userName);
}
List<Application> applicationList;
Long total;
Integer page = request.getPage();
Integer size = request.getSize();
if (request.getStatus() == null || request.getStatus().intValue() == 0) {
// Paging find applications by user
long currentTimeUser = System.currentTimeMillis();
applicationList = applicationDao.findByCreateUser(userName, page, size);
LOGGER.info("timechecker find page application :" + (System.currentTimeMillis() - currentTimeUser));
long currentTimeCountUser = System.currentTimeMillis();
total = applicationDao.countByCreateUser(userName);
LOGGER.info("timechecker count application :" + (System.currentTimeMillis() - currentTimeCountUser));
} else {
// Paging find applications by user and status
applicationList = applicationDao.findByCreateUserAndStatus(userName, request.getStatus(), request.getCommentType(), page, size);
total = applicationDao.countByCreateUserAndStatus(userName, request.getStatus(), request.getCommentType());
}
long currentTimeResponse = System.currentTimeMillis();
GetAllResponse<ApplicationResponse> getAllResponse = new GetAllResponse<>();
List<ApplicationResponse> applicationResponses = new ArrayList<>();
for (Application application : applicationList) {
List<Task> tasks = taskDao.findByApplication(application);
ApplicationResponse response = new ApplicationResponse(application, tasks, httpServletRequest.getHeader("Content-Language"));
if (application.getCreateUser().equals(userName) || application.getExecuteUser().equals(userName)) {
response.setKillOption(true);
} else {
response.setKillOption(false);
}
applicationResponses.add(response);
}
getAllResponse.setData(applicationResponses);
getAllResponse.setTotal(total);
List<String> applicationIdList = getAllResponse.getData().stream().map(ApplicationResponse::getApplicationId).collect(Collectors.toList());
LOGGER.info("timechecker response :" + (System.currentTimeMillis() - currentTimeResponse));
LOGGER.info("Succeed to find applications. size: {}, id of applications: {}", total, applicationIdList);
return new GeneralResponse<>("200", "{&SUCCEED_TO_GET_APPLICATIONS}", getAllResponse);
}
Aggregations