Search in sources :

Example 16 with CheckedServiceException

use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.

the class BookVideoServiceImpl method addBookVideo.

@Override
public Integer addBookVideo(String sessionId, BookVideo bookVideo, MultipartFile cover) throws CheckedServiceException, IOException {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.BOOK_VEDIO, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (ObjectUtil.isNull(bookVideo.getBookId()) || StringUtil.isEmpty(bookVideo.getTitle()) || StringUtil.isEmpty(bookVideo.getFileName()) || StringUtil.isEmpty(bookVideo.getPath()) || StringUtil.isEmpty(bookVideo.getOrigFileName()) || StringUtil.isEmpty(bookVideo.getOrigPath()) || ObjectUtil.isNull(bookVideo.getFileSize()) || ObjectUtil.isNull(bookVideo.getOrigFileSize())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.BOOK_VEDIO, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    bookVideo.setUserId(0L);
    bookVideo.setIsAuth(true);
    bookVideo.setAuthUserId(pmphUser.getId());
    bookVideo.setAuthDate(new Date());
    // 暂设为默认值
    bookVideo.setCover("DEFAULT");
    bookVideoDao.addBookVideo(bookVideo);
    /* 保存封面 */
    String coverId = fileService.save(cover, FileType.BOOKVEDIO_CONER, bookVideo.getId());
    bookVideo.setCover(coverId);
    return bookVideoDao.updateBookVideo(bookVideo);
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) Date(java.util.Date)

Example 17 with CheckedServiceException

use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.

the class CmsAdvertisementServiceImpl method deleteCmsAdvertisementImageById.

@Override
public Integer deleteCmsAdvertisementImageById(String[] image, Long[] id, String sessionId) {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == pmphUser || null == pmphUser.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (!pmphUser.getIsAdmin()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.ILLEGAL_PARAM, "该用户没有操作权限");
    }
    if (null == id) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    if (null == image) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    Integer count = 0;
    // 遍历数组 进行删除MongoDB的图
    for (int i = 0; i < image.length; i++) {
        if (null != id[i]) {
            // 取芒果图片上保存的id
            String ids = image[i].substring(15);
            fileService.remove(ids);
        }
    }
    // 删除本地相对应的图片信息
    for (int i = 0; i < id.length; i++) {
        if (null != id[i]) {
            count = cmsAdvertisementImageDao.deleteCmsAdvertisementByImages(id[i]);
        }
    }
    return count;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 18 with CheckedServiceException

use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.

the class CmsAdvertisementServiceImpl method updateCmsAdvertisement.

@Override
public Integer updateCmsAdvertisement(CmsAdvertisement cmsAdvertisement, String sessionId) throws CheckedServiceException {
    Integer count = 0;
    // session PmphUser用户验证
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == pmphUser || null == pmphUser.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (!pmphUser.getIsAdmin()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.ILLEGAL_PARAM, "该用户没有操作权限");
    }
    if (ObjectUtil.isNull(cmsAdvertisement)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    if (null == cmsAdvertisement.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "广告id");
    }
    count = cmsAdvertisementDao.updateCmsAdvertisement(cmsAdvertisement);
    return count;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 19 with CheckedServiceException

use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.

the class CmsCategoryServiceImpl method getCmsCategoryDetail.

@Override
public Map<String, Object> getCmsCategoryDetail(Long id) throws CheckedServiceException {
    if (ObjectUtil.isNull(id)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    Map<String, Object> resultMap = new HashMap<String, Object>();
    CmsCategory cmsCategory = this.getCmsCategoryById(id);
    resultMap.put("cmsCategory", cmsCategory);
    // 按Category查询对应权限
    List<CmsCategoryRoleVO> cmsCategoryRoles = this.getCmsCategoryRoleByCategoryId(id);
    for (CmsCategoryRoleVO cmsCategoryRole : cmsCategoryRoles) {
        if (Const.CMS_CATEGORY_PERMISSSION_1 == cmsCategoryRole.getPermissionType()) {
            resultMap.put("permissionId", cmsCategoryRole.getRoleId());
        } else {
            resultMap.put("authRoleId", cmsCategoryRole.getRoleId());
        }
    }
    return resultMap;
}
Also used : HashMap(java.util.HashMap) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) CmsCategory(com.bc.pmpheep.back.po.CmsCategory) CmsCategoryRoleVO(com.bc.pmpheep.back.vo.CmsCategoryRoleVO)

Example 20 with CheckedServiceException

use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.

the class CmsContentServiceImpl method addCmsContent.

@Override
public CmsContent addCmsContent(CmsContent cmsContent, String[] files, String content, String scheduledTime, 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, "内容参数为空");
    }
    if (ObjectUtil.isNull(cmsContent.getCategoryId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "所属栏目不能为空");
    }
    if (ObjectUtil.isNull(cmsContent.getMaterialId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "教材ID不能为空");
    }
    // MongoDB 内容插入
    Content contentObj = contentService.add(new Content(content));
    if (StringUtil.isEmpty(contentObj.getId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.PO_ADD_FAILED, "Content对象内容保存失败");
    }
    // 内容保存
    // 上级id
    cmsContent.setParentId(cmsContent.getCategoryId());
    // cmsContent.setPath(cmsContent.getPath());// 根节点路径
    // 内容id
    cmsContent.setMid(contentObj.getId());
    // 作者类型
    cmsContent.setAuthorType(Const.CMS_AUTHOR_TYPE_1);
    // 作者id
    cmsContent.setAuthorId(pmphUser.getId());
    // cmsContent.setMaterialId(cmsContent.getMaterialId());// 教材ID,为0表示未选择教材
    String summary = SummaryUtil.htmlToText(content);
    summary = summary.substring(0, Math.min(summary.length(), 60));
    cmsContent.setSummary(summary);
    if (Const.TRUE == cmsContent.getIsPublished()) {
        cmsContent.setAuthStatus(Const.CMS_AUTHOR_STATUS_2);
    }
    // 信息快报/公告管理(发布),审核时间就为当前时间
    if (ObjectUtil.notNull(cmsContent.getAuthStatus())) {
        if (Const.CMS_AUTHOR_STATUS_2.shortValue() == cmsContent.getAuthStatus()) {
            cmsContent.setAuthUserId(pmphUser.getId());
            cmsContent.setAuthStatus(Const.CMS_AUTHOR_STATUS_2);
            cmsContent.setAuthDate(DateUtil.formatTimeStamp("yyyy-MM-dd HH:mm:ss", DateUtil.getCurrentTime()));
            cmsContent.setIsPublished(true);
        }
    }
    if (ObjectUtil.notNull(cmsContent.getIsStaging())) {
        if (Const.TRUE.booleanValue() == cmsContent.getIsStaging().booleanValue()) {
            // 信息快报/公告管理(暂存)
            cmsContent.setAuthUserId(pmphUser.getId());
            cmsContent.setAuthStatus(null);
            cmsContent.setAuthDate(null);
            cmsContent.setIsPublished(false);
        }
    }
    // 获取新增后的主键ID
    Long contentId = this.addCmsContent(cmsContent).getId();
    if (ObjectUtil.isNull(contentId)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.PO_ADD_FAILED, "CmsContent添加内容失败");
    }
    // 定时发布
    // if (Const.TRUE.booleanValue() == cmsContent.getIsScheduled().booleanValue())
    // {
    // if (StringUtil.isEmpty(scheduledTime)) {
    // throw new CheckedServiceException(CheckedExceptionBusiness.CMS,
    // CheckedExceptionResult.NULL_PARAM, "定时发布时间参数为空");
    // }
    // cmsScheduleService.addCmsSchedule(new CmsSchedule(contentId,
    // DateUtil.str2Timestam(scheduledTime)));
    // }
    // 保存附件到MongoDB
    this.saveFileToMongoDB(request, files, null, contentId);
    return cmsContent;
}
Also used : 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)

Aggregations

CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)208 PmphUser (com.bc.pmpheep.back.po.PmphUser)81 ArrayList (java.util.ArrayList)73 PageResult (com.bc.pmpheep.back.plugin.PageResult)33 Material (com.bc.pmpheep.back.po.Material)30 IOException (java.io.IOException)30 HashMap (java.util.HashMap)27 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)25 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)24 Workbook (org.apache.poi.ss.usermodel.Workbook)23 UserMessage (com.bc.pmpheep.back.po.UserMessage)22 LogDetail (com.bc.pmpheep.annotation.LogDetail)20 Message (com.bc.pmpheep.general.po.Message)20 Textbook (com.bc.pmpheep.back.po.Textbook)18 WriterUser (com.bc.pmpheep.back.po.WriterUser)17 OutputStream (java.io.OutputStream)17 CmsContent (com.bc.pmpheep.back.po.CmsContent)16 BufferedOutputStream (java.io.BufferedOutputStream)16 PmphGroupMemberVO (com.bc.pmpheep.back.vo.PmphGroupMemberVO)14 UnsupportedEncodingException (java.io.UnsupportedEncodingException)14