Search in sources :

Example 61 with PmphUser

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

the class CmsAdvertisementServiceImpl method addCmsAdvertisement.

@Override
public CmsAdvertisement addCmsAdvertisement(CmsAdvertisement cmsAdvertisement, CmsAdvertisementImage cmsAdvertisementImage, MultipartFile file, String sessionId) throws CheckedServiceException, IOException {
    // 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");
    }
    if (null == file) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "图片为空");
    }
    // 先保存上传的广告图片返回MongoDBid
    String newImage = fileService.save(file, ImageType.CMS_ADVERTISEMENT_IMAGE, cmsAdvertisementImage.getId());
    // 保存图片id和关联广告id
    cmsAdvertisementImage.setAdvertId(cmsAdvertisement.getId());
    cmsAdvertisementImage.setImage(newImage);
    cmsAdvertisementImageDao.addCmsAdvertisementImage(cmsAdvertisementImage);
    // 保存广告管理设置
    cmsAdvertisementDao.addCmsAdvertisement(cmsAdvertisement);
    return cmsAdvertisement;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 62 with PmphUser

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

the class CmsAdvertisementServiceImpl method addCmsAdevertisementImage.

@Override
public CmsAdvertisementImage addCmsAdevertisementImage(CmsAdvertisementOrImageVO cmsAdvertisementOrImageVO, MultipartFile file, String sessionId) throws CheckedServiceException, IOException {
    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(cmsAdvertisementOrImageVO)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    if (null == file) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "图片为空");
    }
    CmsAdvertisementImage cmsAdvertisementImage = new CmsAdvertisementImage();
    cmsAdvertisementImage.setAdvertId(cmsAdvertisementOrImageVO.getAdvertId());
    // 新增图片默认不启用
    cmsAdvertisementImage.setIsDisabled(Const.TRUE);
    // 因新建图片信息,未有图片id,先插入芒果DB默认路径
    cmsAdvertisementImage.setImage(RouteUtil.MONGODB_IMAGE);
    cmsAdvertisementImageDao.addCmsAdvertisementImage(cmsAdvertisementImage);
    // 保存图片到 MongoDB 返回id存入图片id
    String newImage = fileService.save(file, ImageType.CMS_ADVERTISEMENT_IMAGE, cmsAdvertisementImage.getId());
    // 替换之前图片id的临时值
    cmsAdvertisementImage.setImage(newImage);
    cmsAdvertisementImageDao.updateCmsAdvertisementImage(cmsAdvertisementImage);
    // 拼接芒果DB图片路径
    cmsAdvertisementImage.setImage(RouteUtil.MONGODB_IMAGE.concat(newImage));
    return cmsAdvertisementImage;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) CmsAdvertisementImage(com.bc.pmpheep.back.po.CmsAdvertisementImage)

Example 63 with PmphUser

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

the class CmsAdvertisementServiceImpl method getAdvertisementList.

@Override
public List<CmsAdvertisementOrImageVO> getAdvertisementList(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, "用户为空");
    }
    List<CmsAdvertisementOrImageVO> cmsAdvertisementOrImageVOs = cmsAdvertisementDao.getAdvertisementList();
    if (pmphUser.getIsAdmin()) {
        for (CmsAdvertisementOrImageVO cmsAdvertisementOrImageVO : cmsAdvertisementOrImageVOs) {
            cmsAdvertisementOrImageVO.setIsPlay(true);
        }
    }
    return cmsAdvertisementOrImageVOs;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) CmsAdvertisementOrImageVO(com.bc.pmpheep.back.vo.CmsAdvertisementOrImageVO)

Example 64 with PmphUser

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

the class CmsAdvertisementServiceImpl method updateCmsAdvertisement.

@Override
public Integer updateCmsAdvertisement(CmsAdvertisementOrImageVO cmsAdvertisementOrImageVO, String sessionId, Long[] imageId, Long[] disable) throws CheckedServiceException {
    // 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(cmsAdvertisementOrImageVO)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    if (null != cmsAdvertisementOrImageVO.getAdname()) {
        if (StringUtil.strLength(cmsAdvertisementOrImageVO.getAdname()) > 25) {
            throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.ILLEGAL_PARAM, "最多只能输入25个字符");
        }
        CmsAdvertisement cmsAdvertisement = cmsAdvertisementDao.getCmsAdvertisementById(cmsAdvertisementOrImageVO.getId());
        if (!cmsAdvertisementOrImageVO.getAdname().equals(cmsAdvertisement.getAdname())) {
            if (cmsAdvertisementDao.getCmsAdvertisementByName(cmsAdvertisementOrImageVO.getAdname()).size() > 0) {
                throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.ILLEGAL_PARAM, "广告位置名称已存在,请重新输入");
            }
        }
    }
    if (null == cmsAdvertisementOrImageVO.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "广告id为空");
    }
    if (null == cmsAdvertisementOrImageVO.getAdname()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "广告名称为空");
    }
    if (null == imageId) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    if (null != cmsAdvertisementOrImageVO.getUrl()) {
        if (StringUtil.strLength(cmsAdvertisementOrImageVO.getUrl()) > 150) {
            throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.ILLEGAL_PARAM, "最多只能输入150个字符");
        }
    }
    if (null != cmsAdvertisementOrImageVO.getNote()) {
        if (StringUtil.strLength(cmsAdvertisementOrImageVO.getNote()) > 20) {
            throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.ILLEGAL_PARAM, "备注最多只能输入20个字符");
        }
    }
    if (null == cmsAdvertisementOrImageVO.getNote()) {
        cmsAdvertisementOrImageVO.setNote("");
    }
    if (null == cmsAdvertisementOrImageVO.getUrl()) {
        cmsAdvertisementOrImageVO.setUrl("");
    }
    Integer count = 0;
    CmsAdvertisementImage cmsAdvertisementImage = new CmsAdvertisementImage();
    if (0 != imageId.length) {
        for (int i = 0; i < imageId.length; i++) {
            cmsAdvertisementImage.setId(imageId[i]);
            cmsAdvertisementImage.setIsDisabled((Boolean) cmsAdvertisementOrImageVO.getIsDisplay());
            // 修改图片为显示
            cmsAdvertisementImageDao.updateCmsAdvertisementImage(cmsAdvertisementImage);
        }
    }
    if (0 != disable.length) {
        for (int i = 0; i < disable.length; i++) {
            // 把不启用的图片更改禁用
            cmsAdvertisementImage.setId(disable[i]);
            cmsAdvertisementImageDao.updateImageIsDisabled(cmsAdvertisementImage);
        }
    }
    count = cmsAdvertisementDao.updateCmsAdvertisement(cmsAdvertisementOrImageVO);
    return count;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) CmsAdvertisement(com.bc.pmpheep.back.po.CmsAdvertisement) CmsAdvertisementImage(com.bc.pmpheep.back.po.CmsAdvertisementImage)

Example 65 with PmphUser

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

the class CmsContentServiceImpl method checkContentById.

@Override
public Integer checkContentById(Long id, Short authStatus, Long categoryId, 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) || ObjectUtil.isNull(authStatus)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    Boolean isPublished = false;
    Boolean isStaging = false;
    if (Const.CMS_AUTHOR_STATUS_2 == authStatus) {
        // 发布
        isPublished = true;
        isStaging = true;
    }
    Integer count = 0;
    count = cmsContentDao.checkContentById(new CmsContent(id, authStatus, pmphUser.getId(), DateUtil.formatTimeStamp("yyyy-MM-dd HH:mm:ss", DateUtil.getCurrentTime()), isPublished, isStaging, Const.MATERIAL_TYPE_ID));
    CmsContent cmsContent = this.getCmsContentById(id);
    if (ObjectUtil.isNull(cmsContent)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.OBJECT_NOT_FOUND, "获取对象为空");
    }
    // 评论审核通过,评论数加1
    if (Const.CMS_CATEGORY_ID_0.longValue() == categoryId.longValue() && isPublished) {
        this.updatCmsContentCommentsById(id, 1);
        this.updateCmsContentByParentId(cmsContent.getParentId(), 1);
    }
    Integer type = 0;
    if (Const.CMS_CATEGORY_ID_0.longValue() == categoryId.longValue()) {
        type = Const.WRITER_USER_TRENDST_TYPE_2;
    } else if (Const.CMS_CATEGORY_ID_1.longValue() == categoryId.longValue()) {
        type = Const.WRITER_USER_TRENDST_TYPE_1;
    }
    if (isPublished) {
        writerUserTrendstService.addWriterUserTrendst(new WriterUserTrendst(cmsContent.getAuthorId(), type, id));
    }
    // 当文章通过的时候 给用户增加积分
    if (Const.CMS_CATEGORY_ID_1.longValue() == categoryId.longValue() && isPublished && Const.CMS_AUTHOR_TYPE_2 == cmsContent.getAuthorType()) {
        String ruleName = "发表文章";
        writerPointLogService.addWriterPointLogByRuleName(ruleName, cmsContent.getAuthorId());
    }
    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)

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