Search in sources :

Example 66 with PmphUser

use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.

the class CmsContentServiceImpl method publishCmsContentById.

@Override
public Integer publishCmsContentById(Long id, 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 (ObjectUtil.isNull(id)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    // count = cmsContentDao.publishCmsContentById(id);
    Integer count = cmsContentDao.updateCmsContent(new CmsContent(id, Boolean.TRUE, Boolean.FALSE, Const.CMS_AUTHOR_STATUS_2, pmphUser.getId(), DateUtil.formatTimeStamp("yyyy-MM-dd HH:mm:ss", DateUtil.getCurrentTime())));
    CmsContent cmsContent = this.getCmsContentById(id);
    writerUserTrendstService.addWriterUserTrendst(new WriterUserTrendst(cmsContent.getAuthorId(), Const.WRITER_USER_TRENDST_TYPE_1, id));
    return count;
}
Also used : CmsContent(com.bc.pmpheep.back.po.CmsContent) WriterUserTrendst(com.bc.pmpheep.back.po.WriterUserTrendst) PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 67 with PmphUser

use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.

the class CmsContentServiceImpl method addHelp.

@Override
public CmsContent addHelp(CmsContent cmsContent, String content, String sessionId, HttpServletRequest request) throws CheckedServiceException, IOException {
    // 获取当前登陆用户
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser) || ObjectUtil.isNull(pmphUser.getId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (StringUtil.isEmpty(content)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "内容参数为空");
    }
    List<CmsContent> listContents = this.listCmsContentByTitle(cmsContent.getTitle());
    if (CollectionUtil.isNotEmpty(listContents)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.ILLEGAL_PARAM, "添加的常见问题已存在,请确认后再添加");
    }
    // MongoDB 内容插入
    Content contentObj = contentService.add(new Content(content));
    if (StringUtil.isEmpty(contentObj.getId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.PO_ADD_FAILED, "Content对象内容保存失败");
    }
    // 内容保存
    cmsContent.setCategoryId(Const.CMS_CATEGORY_ID_4);
    // 上级id
    cmsContent.setParentId(Const.CMS_CATEGORY_ID_4);
    cmsContent.setPath("0");
    // 内容id
    cmsContent.setMid(contentObj.getId());
    // 作者类型
    cmsContent.setAuthorType(Const.CMS_AUTHOR_TYPE_1);
    // 作者id
    cmsContent.setAuthorId(pmphUser.getId());
    // 获取新增后的主键ID
    Long contentId = this.addCmsContent(cmsContent).getId();
    if (ObjectUtil.isNull(contentId)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.PO_ADD_FAILED, "CmsContent添加内容失败");
    }
    return cmsContent;
}
Also used : CmsContent(com.bc.pmpheep.back.po.CmsContent) PmphUser(com.bc.pmpheep.back.po.PmphUser) CmsContent(com.bc.pmpheep.back.po.CmsContent) Content(com.bc.pmpheep.general.po.Content) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 68 with PmphUser

use of com.bc.pmpheep.back.po.PmphUser 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 69 with PmphUser

use of com.bc.pmpheep.back.po.PmphUser 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 70 with PmphUser

use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.

the class MaterialServiceImpl method listMaterials.

@Override
public PageResult<MaterialListVO> listMaterials(PageParameter<MaterialListVO> pageParameter, String sessionId) throws CheckedServiceException {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (ObjectUtil.isNull(pageParameter)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    PageResult<MaterialListVO> pageResult = new PageResult<>();
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    List<MaterialListVO> list = new ArrayList<>();
    if (pmphUser.getIsAdmin()) {
        pageParameter.getParameter().setIsMy(null);
    }
    if (null != pageParameter.getParameter().getIsMy() && !pageParameter.getParameter().getIsMy()) {
        pageParameter.getParameter().setIsMy(null);
    }
    if (!ObjectUtil.isNull(pageParameter.getParameter().getIsMy()) && pageParameter.getParameter().getIsMy()) {
        pageParameter.getParameter().setUserId(pmphUser.getId());
    }
    Integer total = 0;
    String state = pageParameter.getParameter().getState();
    if ("已结束".equals(state)) {
        pageParameter.getParameter().setIsAllTextbookPublished(true);
        pageParameter.getParameter().setIsForceEnd(true);
        pageParameter.getParameter().setIsPublished(true);
        total = materialDao.listMaterialEndTotal(pageParameter);
        if (total > 0) {
            list = materialDao.listMaterialEnd(pageParameter);
        }
    } else {
        if (!StringUtil.isEmpty(state)) {
            switch(state) {
                case "未发布":
                    pageParameter.getParameter().setIsAllTextbookPublished(false);
                    pageParameter.getParameter().setIsForceEnd(false);
                    pageParameter.getParameter().setIsPublished(false);
                    break;
                case "已发布":
                    pageParameter.getParameter().setIsAllTextbookPublished(false);
                    pageParameter.getParameter().setIsForceEnd(false);
                    pageParameter.getParameter().setIsPublished(true);
                    break;
                case "未结束":
                    pageParameter.getParameter().setIsAllTextbookPublished(false);
                    pageParameter.getParameter().setIsForceEnd(false);
                    pageParameter.getParameter().setIsPublished(null);
                    break;
                default:
                    throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "教材状态错误");
            }
        }
        total = materialDao.listMaterialTotal(pageParameter);
        if (total > 0) {
            list = materialDao.listMaterial(pageParameter);
        }
    }
    list = addMaterialContact(list, sessionId);
    pageResult.setRows(list);
    pageResult.setTotal(total);
    return pageResult;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) MaterialListVO(com.bc.pmpheep.back.vo.MaterialListVO) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Aggregations

PmphUser (com.bc.pmpheep.back.po.PmphUser)102 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)81 ArrayList (java.util.ArrayList)33 PageResult (com.bc.pmpheep.back.plugin.PageResult)17 HashMap (java.util.HashMap)13 Material (com.bc.pmpheep.back.po.Material)11 WriterUser (com.bc.pmpheep.back.po.WriterUser)11 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)10 PmphRole (com.bc.pmpheep.back.po.PmphRole)9 UserMessage (com.bc.pmpheep.back.po.UserMessage)9 PmphGroupMemberVO (com.bc.pmpheep.back.vo.PmphGroupMemberVO)9 BaseTest (com.bc.pmpheep.test.BaseTest)9 Test (org.junit.Test)9 CmsContent (com.bc.pmpheep.back.po.CmsContent)8 PmphGroupMember (com.bc.pmpheep.back.po.PmphGroupMember)8 PmphGroup (com.bc.pmpheep.back.po.PmphGroup)7 Textbook (com.bc.pmpheep.back.po.Textbook)7 WriterUserTrendst (com.bc.pmpheep.back.po.WriterUserTrendst)6 Gson (com.google.gson.Gson)6 OrgUser (com.bc.pmpheep.back.po.OrgUser)5