Search in sources :

Example 21 with PageResult

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

the class PmphUserServiceImpl method getListPmphUser.

@Override
public PageResult<PmphUserManagerVO> getListPmphUser(PageParameter<PmphUserManagerVO> pageParameter, Long groupId) throws CheckedServiceException {
    String name = pageParameter.getParameter().getName();
    if (StringUtil.notEmpty(name)) {
        pageParameter.getParameter().setName(name);
    }
    String path = pageParameter.getParameter().getPath();
    Long departmentId = pageParameter.getParameter().getDepartmentId();
    if (StringUtil.notEmpty(path) && ObjectUtil.notNull(departmentId)) {
        pageParameter.getParameter().setPath(path + "-" + java.lang.String.valueOf(departmentId) + '-');
    }
    PageResult<PmphUserManagerVO> pageResult = new PageResult<>();
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    int total = pmphUserDao.getListPmphUserTotal(pageParameter);
    if (total > 0) {
        List<PmphUserManagerVO> list = pmphUserDao.getListPmphUser(pageParameter);
        for (PmphUserManagerVO pmphUserManagerVO : list) {
            List<PmphRoleVO> pmphRoles = pmphRoleDao.listPmphUserRoleByUserId(pmphUserManagerVO.getId());
            pmphUserManagerVO.setPmphRoles(pmphRoles);
        }
        pageResult.setRows(list);
    }
    pageResult.setTotal(total);
    // 设置职位
    if (null != pageResult.getRows() && pageResult.getRows().size() > 0 && null != groupId) {
        // 清空职位
        for (PmphUserManagerVO pmphUserManagerVO : pageResult.getRows()) {
            pmphUserManagerVO.setPosition("无");
        }
        PmphGroup pmphGroup = pmphGroupService.getPmphGroupById(groupId);
        Long bookId = pmphGroup.getBookId();
        if (null != bookId && bookId.intValue() > 0) {
            Textbook textbook = textbookService.getTextbookById(bookId);
            Material material = materialService.getMaterialById(textbook.getMaterialId());
            List<MaterialProjectEditorVO> projects = materialProjectEditorService.listMaterialProjectEditors(textbook.getMaterialId());
            for (PmphUserManagerVO pmphUserManagerVO : pageResult.getRows()) {
                Long pmphUserId = pmphUserManagerVO.getId();
                String posotion = null;
                if (material.getDirector().intValue() == pmphUserId.intValue()) {
                    posotion = "主任";
                }
                if (null != projects && projects.size() > 0) {
                    for (MaterialProjectEditorVO item : projects) {
                        if (item.getEditorId().intValue() == pmphUserId.intValue()) {
                            posotion += (posotion == null) ? "项目编辑" : ",项目编辑";
                            break;
                        }
                    }
                }
                if (textbook.getPlanningEditor().intValue() == pmphUserId.intValue()) {
                    posotion += (posotion == null) ? "策划编辑" : ",策划编辑";
                }
                pmphUserManagerVO.setPosition(posotion == null ? "无" : posotion);
            }
        }
    }
    // 设置职位 end
    return pageResult;
}
Also used : Material(com.bc.pmpheep.back.po.Material) PageResult(com.bc.pmpheep.back.plugin.PageResult) MaterialProjectEditorVO(com.bc.pmpheep.back.vo.MaterialProjectEditorVO) PmphGroup(com.bc.pmpheep.back.po.PmphGroup) Textbook(com.bc.pmpheep.back.po.Textbook) PmphUserManagerVO(com.bc.pmpheep.back.vo.PmphUserManagerVO) PmphRoleVO(com.bc.pmpheep.back.vo.PmphRoleVO)

Example 22 with PageResult

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

the class SysOperationServiceImpl method getListSysOperation.

@Override
public PageResult<SysOperation> getListSysOperation(PageParameter<SysOperation> pageParameter) throws CheckedServiceException {
    PageResult<SysOperation> pageResult = new PageResult<SysOperation>();
    String startTime = pageParameter.getParameter().getStartTime();
    String endTime = pageParameter.getParameter().getEndTime();
    // 查询近一个月操作日志
    String startDate = DateUtil.date2Str(new Date());
    String endDate = DateUtil.getAfterDayDate("-30");
    if (StringUtil.isEmpty(startTime) && StringUtil.isEmpty(endTime)) {
        pageParameter.getParameter().setStartTime(endDate);
        pageParameter.getParameter().setEndTime(startDate);
    } else {
        if (StringUtil.isEmpty(startTime)) {
            pageParameter.getParameter().setStartTime(DateUtil.date2Str(DateUtil.getDateBefore(DateUtil.str2Date(endTime), 30)));
            pageParameter.getParameter().setEndTime(endTime);
        }
        if (StringUtil.isEmpty(endTime)) {
            pageParameter.getParameter().setStartTime(startTime);
            pageParameter.getParameter().setEndTime(DateUtil.date2Str(DateUtil.getDateBefore(DateUtil.str2Date(startTime), -30)));
        }
    }
    // 将页面大小和页面页码拷贝
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    // 包含数据总条数的数据集
    List<SysOperation> sysOperations = sysOperationDao.getListSysOperation(pageParameter);
    if (CollectionUtil.isNotEmpty(sysOperations)) {
        Integer count = sysOperations.get(0).getCount();
        pageResult.setTotal(count);
        pageResult.setRows(sysOperations);
    }
    return pageResult;
}
Also used : SysOperation(com.bc.pmpheep.back.po.SysOperation) PageResult(com.bc.pmpheep.back.plugin.PageResult) Date(java.util.Date)

Example 23 with PageResult

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

the class TextbookLogServiceImpl method listTextbookLogByTextBookId.

@Override
public PageResult<TextbookLogVO> listTextbookLogByTextBookId(Long textbookId, Integer pageSize, Integer pageNumber, String updaterName) throws CheckedServiceException {
    if (null == textbookId) {
        throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK_LOG, CheckedExceptionResult.NULL_PARAM, "书籍为空!");
    }
    Map<String, Object> map = new HashMap<String, Object>(2);
    map.put("textbookId", textbookId);
    updaterName = StringUtil.toAllCheck(updaterName);
    if (null != updaterName) {
        map.put("updaterName", updaterName);
    }
    // 包装参数实体
    PageParameter<Map<String, Object>> pageParameter = new PageParameter<Map<String, Object>>(pageNumber, pageSize, map);
    // 返回实体
    PageResult<TextbookLogVO> pageResult = new PageResult<TextbookLogVO>();
    // 参数拷贝
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    // 获取总数
    Integer total = textbookLogDao.listTotalTextbookLogByTextBookId(pageParameter);
    if (null != total && total > 0) {
        List<TextbookLog> rows = textbookLogDao.listTextbookLogByTextBookId(pageParameter);
        List<TextbookLogVO> newRows = new ArrayList<TextbookLogVO>(rows.size());
        for (TextbookLog textbookLog : rows) {
            Long id = textbookLog.getId();
            String detail = textbookLog.getDetail();
            Timestamp gmtCreate = textbookLog.getGmtCreate();
            detail = detail.replace("{gmt_create}", DateUtil.format(gmtCreate));
            newRows.add(new TextbookLogVO(id, detail));
        }
        pageResult.setRows(newRows);
    }
    pageResult.setTotal(total);
    return pageResult;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) Timestamp(java.sql.Timestamp) PageResult(com.bc.pmpheep.back.plugin.PageResult) TextbookLog(com.bc.pmpheep.back.po.TextbookLog) TextbookLogVO(com.bc.pmpheep.back.vo.TextbookLogVO) HashMap(java.util.HashMap) Map(java.util.Map)

Example 24 with PageResult

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

the class TopicServiceImpl method listOpts.

@Override
public PageResult<TopicOPtsManagerVO> listOpts(String sessionId, PageParameter<TopicOPtsManagerVO> pageParameter) throws CheckedServiceException {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.NULL_PARAM, "用户为空!");
    }
    PageResult<TopicOPtsManagerVO> pageResult = new PageResult<>();
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    Integer total = 0;
    String submitTime = DateUtil.date2Str(pageParameter.getParameter().getSubmitTime(), "yyyy-MM-dd");
    if (pmphUser.getIsAdmin()) {
        total = topicDao.listTotal(pageParameter.getParameter().getBookname(), submitTime);
        if (total > 0) {
            List<TopicOPtsManagerVO> list = topicDao.list(pageParameter.getParameter().getBookname(), submitTime, pageParameter.getStart(), pageParameter.getPageSize());
            list = addTypeName(list);
            pageResult.setRows(list);
        }
    } else {
        total = topicDao.listOptsTotal(pmphUser.getId(), pageParameter.getParameter().getBookname(), submitTime);
        if (total > 0) {
            List<TopicOPtsManagerVO> list = topicDao.listOpts(pmphUser.getId(), pageParameter.getParameter().getBookname(), submitTime, pageParameter.getStart(), pageParameter.getPageSize());
            list = addTypeName(list);
            pageResult.setRows(list);
        }
    }
    pageResult.setTotal(total);
    return pageResult;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) TopicOPtsManagerVO(com.bc.pmpheep.back.vo.TopicOPtsManagerVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Example 25 with PageResult

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

the class TopicServiceImpl method listTopicEditorVOs.

@Override
public PageResult<TopicEditorVO> listTopicEditorVOs(String sessionId, PageParameter<TopicEditorVO> pageParameter) throws CheckedServiceException {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    PageResult<TopicEditorVO> pageResult = new PageResult<>();
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    Integer total = 0;
    String submitTime = DateUtil.date2Str(pageParameter.getParameter().getSubmitTime(), "yyyy-MM-dd");
    if (pmphUser.getIsAdmin()) {
        total = topicDao.totalEditorView(pageParameter.getParameter().getBookname(), submitTime);
        if (total > 0) {
            List<TopicEditorVO> list = topicDao.listEditorView(pageParameter.getParameter().getBookname(), submitTime, pageParameter.getStart(), pageParameter.getPageSize());
            list = addTypeNameEditor(list);
            pageResult.setRows(list);
        }
    } else {
        total = topicDao.totalTopicEditorVOs(pmphUser.getId(), pageParameter.getParameter().getBookname(), submitTime);
        if (total > 0) {
            List<TopicEditorVO> list = topicDao.listTopicEditorVOs(pmphUser.getId(), pageParameter.getParameter().getBookname(), submitTime, pageParameter.getStart(), pageParameter.getPageSize());
            list = addTypeNameEditor(list);
            pageResult.setRows(list);
        }
    }
    pageResult.setTotal(total);
    return pageResult;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) TopicEditorVO(com.bc.pmpheep.back.vo.TopicEditorVO) 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