Search in sources :

Example 1 with PmphGroupFileVO

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());
}
Also used : PmphGroupFileVO(com.bc.pmpheep.back.vo.PmphGroupFileVO) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) PageResult(com.bc.pmpheep.back.plugin.PageResult) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Example 2 with PmphGroupFileVO

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;
}
Also used : PmphGroupFileVO(com.bc.pmpheep.back.vo.PmphGroupFileVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Aggregations

PageResult (com.bc.pmpheep.back.plugin.PageResult)2 PmphGroupFileVO (com.bc.pmpheep.back.vo.PmphGroupFileVO)2 PageParameter (com.bc.pmpheep.back.plugin.PageParameter)1 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)1 BaseTest (com.bc.pmpheep.test.BaseTest)1 Test (org.junit.Test)1