Search in sources :

Example 26 with PageResult

use of com.bc.pmpheep.back.plugin.PageResult in project pmph by BCSquad.

the class BookCorrectionServiceImpl method listBookCorrectionAudit.

@Override
public PageResult<BookCorrectionAuditVO> listBookCorrectionAudit(HttpServletRequest request, Integer pageNumber, Integer pageSize, String bookname, Boolean isOver, Boolean result) throws CheckedServiceException {
    if (null == request.getSession(false)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "会话过期");
    }
    // 获取当前用户
    String sessionId = CookiesUtil.getSessionId(request);
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == pmphUser || null == pmphUser.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "请求用户不存在");
    }
    if (null == pageNumber || pageNumber < 1) {
        pageNumber = 1;
    }
    if (null == pageSize || pageSize < 1) {
        pageSize = Integer.MAX_VALUE;
    }
    Long editorId = pmphUser.getId();
    // 权限的检查
    List<PmphRole> pmphRoles = pmphUserService.getListUserRole(pmphUser.getId());
    // 系统管理员权限检查
    for (PmphRole pmphRole : pmphRoles) {
        if (null != pmphRole && null != pmphRole.getRoleName() && "系统管理员".equals(pmphRole.getRoleName().trim())) {
            // 我是系统管理原
            editorId = null;
        }
    }
    // 权限由菜单控制
    editorId = null;
    Map<String, Object> map = new HashMap<String, Object>(4);
    map.put("start", (pageNumber - 1) * pageSize);
    map.put("pageSize", pageSize);
    map.put("result", result);
    map.put("bookname", StringUtil.toAllCheck(bookname));
    map.put("editorId", editorId);
    if (null != isOver && isOver) {
        // APP的已完成
        map.put("isOver", 1);
    } else {
        map.put("isOver", 2);
    }
    // 返回实体
    PageResult<BookCorrectionAuditVO> pageResult = new PageResult<BookCorrectionAuditVO>();
    pageResult.setPageNumber(pageNumber);
    pageResult.setPageSize(pageSize);
    // 获取总数
    Integer total = bookCorrectionDao.listBookCorrectionAuditTotal(map);
    if (null != total && total > 0) {
        List<BookCorrectionAuditVO> rows = bookCorrectionDao.listBookCorrectionAudit(map);
        pageResult.setRows(rows);
    }
    pageResult.setTotal(total);
    return pageResult;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) HashMap(java.util.HashMap) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) BookCorrectionAuditVO(com.bc.pmpheep.back.vo.BookCorrectionAuditVO) PageResult(com.bc.pmpheep.back.plugin.PageResult) PmphRole(com.bc.pmpheep.back.po.PmphRole)

Example 27 with PageResult

use of com.bc.pmpheep.back.plugin.PageResult in project pmph by BCSquad.

the class CmsContentServiceImpl method listCmsComment.

@Override
public PageResult<CmsContentVO> listCmsComment(PageParameter<CmsContentVO> pageParameter, String sessionId) throws CheckedServiceException {
    // 获取当前登陆用户
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser) || ObjectUtil.isNull(pmphUser.getId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (Const.CMS_CATEGORY_ID_0.longValue() == pageParameter.getParameter().getCategoryId()) {
        pageParameter.getParameter().setIsAdmin(true);
    } else {
        pageParameter.getParameter().setIsAdmin(pmphUser.getIsAdmin());
    }
    PageResult<CmsContentVO> pageResult = new PageResult<CmsContentVO>();
    // 将页面大小和页面页码拷贝
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    // 包含数据总条数的数据集
    List<CmsContentVO> cmsContentList = cmsContentDao.listCmsComment(pageParameter);
    if (CollectionUtil.isNotEmpty(cmsContentList)) {
        Integer count = cmsContentList.get(0).getCount();
        pageResult.setTotal(count);
        pageResult.setRows(cmsContentList);
    }
    return pageResult;
}
Also used : CmsContentVO(com.bc.pmpheep.back.vo.CmsContentVO) PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Example 28 with PageResult

use of com.bc.pmpheep.back.plugin.PageResult in project pmph by BCSquad.

the class CmsContentServiceImpl method listHelp.

@Override
public PageResult<CmsContentVO> listHelp(PageParameter<CmsContentVO> pageParameter, String sessionId) throws CheckedServiceException {
    // 获取当前登陆用户
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser) || ObjectUtil.isNull(pmphUser.getId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    PageResult<CmsContentVO> pageResult = new PageResult<CmsContentVO>();
    // 将页面大小和页面页码拷贝
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    // 包含数据总条数的数据集
    List<CmsContentVO> cmsContentList = cmsContentDao.listHelp(pageParameter);
    if (CollectionUtil.isNotEmpty(cmsContentList)) {
        Integer count = cmsContentList.get(0).getCount();
        pageResult.setTotal(count);
        pageResult.setRows(cmsContentList);
    }
    return pageResult;
}
Also used : CmsContentVO(com.bc.pmpheep.back.vo.CmsContentVO) PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Example 29 with PageResult

use of com.bc.pmpheep.back.plugin.PageResult in project pmph by BCSquad.

the class DecPositionServiceImpl method listChosenDeclarationResultSchoolVOs.

@Override
public PageResult<DeclarationResultSchoolVO> listChosenDeclarationResultSchoolVOs(PageParameter<DeclarationResultSchoolVO> pageParameter) throws CheckedServiceException {
    if (ObjectUtil.isNull(pageParameter.getParameter().getMaterialId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "教材id不能为空");
    }
    String schoolName = pageParameter.getParameter().getSchoolName();
    if (StringUtil.notEmpty(schoolName)) {
        pageParameter.getParameter().setSchoolName(schoolName);
    }
    PageResult<DeclarationResultSchoolVO> pageResult = new PageResult<DeclarationResultSchoolVO>();
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    int total = decPositionDao.getSchoolCount(pageParameter.getParameter().getMaterialId());
    if (total > 0) {
        boolean flag = false;
        List<DeclarationResultSchoolVO> chosens = decPositionDao.getSchoolListChosenPage(pageParameter);
        List<DeclarationResultSchoolVO> presets = decPositionDao.getSchoolListPresetChosen(pageParameter);
        List<DeclarationResultSchoolVO> delList = new ArrayList<>();
        List<DeclarationResultSchoolVO> list = new ArrayList<>();
        if (null == chosens || chosens.isEmpty()) {
            for (DeclarationResultSchoolVO preset : presets) {
                preset.setState(1);
                list.add(preset);
            }
            pageResult.setRows(list);
            pageResult.setTotal(total);
            return pageResult;
        }
        if (chosens.size() < presets.size()) {
            flag = true;
        }
        for (DeclarationResultSchoolVO chosen : chosens) {
            for (DeclarationResultSchoolVO preset : presets) {
                if (preset.getOrgId().equals(chosen.getOrgId())) {
                    delList.add(preset);
                    if (StringUtil.isEmpty(chosen.getEditorList())) {
                        chosen.setEditorList("-");
                    }
                    if (StringUtil.isEmpty(chosen.getSubEditorList())) {
                        chosen.setSubEditorList("-");
                    }
                    if (StringUtil.isEmpty(chosen.getEditorialList())) {
                        chosen.setEditorialList("-");
                    }
                    if (StringUtil.isEmpty(chosen.getIsDigitalEditorList())) {
                        chosen.setIsDigitalEditorList("-");
                    }
                    break;
                }
            }
            chosen.setState(1);
            list.add(chosen);
        }
        if (flag) {
            presets.removeAll(delList);
            list.addAll(presets);
        }
        pageResult.setRows(list);
        pageResult.setTotal(total);
    }
    return pageResult;
}
Also used : ArrayList(java.util.ArrayList) DeclarationResultSchoolVO(com.bc.pmpheep.back.vo.DeclarationResultSchoolVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Example 30 with PageResult

use of com.bc.pmpheep.back.plugin.PageResult in project pmph by BCSquad.

the class DecPositionServiceImpl method listPresetDeclarationResultSchoolVOs.

@Override
public PageResult<DeclarationResultSchoolVO> listPresetDeclarationResultSchoolVOs(PageParameter<DeclarationResultSchoolVO> pageParameter) throws CheckedServiceException {
    if (ObjectUtil.isNull(pageParameter.getParameter().getMaterialId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "教材id不能为空");
    }
    String schoolName = pageParameter.getParameter().getSchoolName();
    if (StringUtil.notEmpty(schoolName)) {
        pageParameter.getParameter().setSchoolName(schoolName);
    }
    PageResult<DeclarationResultSchoolVO> pageResult = new PageResult<DeclarationResultSchoolVO>();
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    int total = decPositionDao.getSchoolCount(pageParameter.getParameter().getMaterialId());
    if (total > 0) {
        List<DeclarationResultSchoolVO> presets = decPositionDao.getSchoolListPreset(pageParameter);
        List<DeclarationResultSchoolVO> chosens = decPositionDao.getSchoolListChosen(pageParameter);
        List<DeclarationResultSchoolVO> list = new ArrayList<>();
        if (null == chosens || chosens.isEmpty()) {
            for (DeclarationResultSchoolVO preset : presets) {
                preset.setState(2);
                list.add(preset);
            }
            pageResult.setRows(list);
            pageResult.setTotal(total);
            return pageResult;
        }
        for (DeclarationResultSchoolVO preset : presets) {
            for (DeclarationResultSchoolVO chosen : chosens) {
                if (chosen.getOrgId().equals(preset.getOrgId())) {
                    preset.setEditorList(chosen.getEditorList());
                    preset.setSubEditorList(chosen.getSubEditorList());
                    preset.setEditorialList(chosen.getEditorialList());
                    preset.setIsDigitalEditorList(chosen.getIsDigitalEditorList());
                    if (StringUtil.isEmpty(preset.getEditorList())) {
                        preset.setEditorList("-");
                    }
                    if (StringUtil.isEmpty(preset.getSubEditorList())) {
                        preset.setSubEditorList("-");
                    }
                    if (StringUtil.isEmpty(preset.getEditorialList())) {
                        preset.setEditorialList("-");
                    }
                    if (StringUtil.isEmpty(preset.getIsDigitalEditorList())) {
                        preset.setIsDigitalEditorList("-");
                    }
                    break;
                }
            }
            preset.setState(2);
            list.add(preset);
        }
        pageResult.setRows(list);
        pageResult.setTotal(total);
    }
    return pageResult;
}
Also used : ArrayList(java.util.ArrayList) DeclarationResultSchoolVO(com.bc.pmpheep.back.vo.DeclarationResultSchoolVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Aggregations

PageResult (com.bc.pmpheep.back.plugin.PageResult)57 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)33 PageParameter (com.bc.pmpheep.back.plugin.PageParameter)24 BaseTest (com.bc.pmpheep.test.BaseTest)20 Test (org.junit.Test)20 PmphUser (com.bc.pmpheep.back.po.PmphUser)17 ArrayList (java.util.ArrayList)13 Rollback (org.springframework.test.annotation.Rollback)12 HashMap (java.util.HashMap)8 CmsContentVO (com.bc.pmpheep.back.vo.CmsContentVO)4 MyMessageVO (com.bc.pmpheep.back.vo.MyMessageVO)4 OrgVO (com.bc.pmpheep.back.vo.OrgVO)4 WriterUserManagerVO (com.bc.pmpheep.back.vo.WriterUserManagerVO)4 PmphGroup (com.bc.pmpheep.back.po.PmphGroup)3 PmphRole (com.bc.pmpheep.back.po.PmphRole)3 SysOperation (com.bc.pmpheep.back.po.SysOperation)3 WriterUser (com.bc.pmpheep.back.po.WriterUser)3 PmphUserManagerVO (com.bc.pmpheep.back.vo.PmphUserManagerVO)3 Material (com.bc.pmpheep.back.po.Material)2 PmphDepartment (com.bc.pmpheep.back.po.PmphDepartment)2