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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations