use of com.bc.pmpheep.back.vo.PmphGroupFileVO in project pmph by BCSquad.
the class PmphGroupFileServiceTest method testGetList.
@Test
public void testGetList() {
pmphGroupFileService.add(pmphGroupFile);
PageResult pageResult = new PageResult<>();
PageParameter pageParameter = new PageParameter<>();
PmphGroupFileVO fileVO = new PmphGroupFileVO();
fileVO.setFileName(null);
fileVO.setFileId(null);
fileVO.setGroupId(pmphGroupFile.getGroupId());
;
pageParameter.setParameter(fileVO);
pageParameter.setPageSize(15);
pageResult = pmphGroupFileService.listGroupFile(pageParameter);
Assert.assertNotNull("没有获取到数据", pageResult.getRows());
}
use of com.bc.pmpheep.back.vo.PmphGroupFileVO in project pmph by BCSquad.
the class PmphGroupFileServiceImpl method listGroupFile.
@Override
public PageResult<PmphGroupFileVO> listGroupFile(PageParameter<PmphGroupFileVO> pageParameter) {
if (ObjectUtil.isNull(pageParameter.getParameter().getGroupId())) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "小组id不能为空");
}
String fileName = pageParameter.getParameter().getFileName();
if (StringUtil.notEmpty(fileName)) {
pageParameter.getParameter().setFileName(fileName);
}
PageResult<PmphGroupFileVO> pageResult = new PageResult<PmphGroupFileVO>();
PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
int total = pmphGroupFileDao.getGroupFileTotal(pageParameter);
if (total > 0) {
List<PmphGroupFileVO> list = pmphGroupFileDao.listGroupFile(pageParameter);
for (PmphGroupFileVO pmphGroupFileVO : list) {
Double fileSize = pmphGroupFileVO.getFileSize();
if (ObjectUtil.notNull(fileSize)) {
if (fileSize > 0) {
pmphGroupFileVO.setFileLenth(String.format("%.2f", fileSize) + " KB");
} else {
pmphGroupFileVO.setFileLenth("0 KB");
}
if (fileSize > 1024) {
pmphGroupFileVO.setFileLenth(String.format("%.2f", fileSize / 1024) + " M");
}
if (fileSize > 1024 * 1024) {
pmphGroupFileVO.setFileLenth(String.format("%.2f", fileSize / 1024 / 1024) + " G");
}
} else {
pmphGroupFileVO.setFileLenth("大小不详");
}
pmphGroupFileVO.setFileId(RouteUtil.MONGODB_GROUP_FILE + pmphGroupFileVO.getFileId());
}
pageResult.setRows(list);
}
pageResult.setTotal(total);
return pageResult;
}
Aggregations