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