|
@@ -1,12 +1,17 @@
|
|
|
package com.xjrsoft.module.oa.service.impl;
|
|
|
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
+import com.github.yulichang.toolkit.MPJWrappers;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
import com.xjrsoft.common.enums.EnabledMark;
|
|
|
+import com.xjrsoft.common.page.ConventPage;
|
|
|
import com.xjrsoft.common.utils.LocalDateTimeUtil;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
import com.xjrsoft.config.CommonPropertiesConfig;
|
|
@@ -20,6 +25,7 @@ import com.xjrsoft.module.oa.mapper.NewsMapper;
|
|
|
import com.xjrsoft.module.oa.mapper.NewsRelationConfigMapper;
|
|
|
import com.xjrsoft.module.oa.mapper.NewsRelationMapper;
|
|
|
import com.xjrsoft.module.oa.service.INewsService;
|
|
|
+import com.xjrsoft.module.oa.vo.NewsPageVo;
|
|
|
import com.xjrsoft.module.oa.vo.NewsRelationVo;
|
|
|
import com.xjrsoft.module.organization.dto.WeChatSendMessageDto;
|
|
|
import com.xjrsoft.module.organization.entity.User;
|
|
@@ -73,7 +79,9 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
|
|
|
|
|
|
News news = BeanUtil.toBean(addNewsDto, News.class);
|
|
|
news.setEnabledMark(EnabledMark.ENABLED.getCode());
|
|
|
+
|
|
|
newsMapper.insert(news);
|
|
|
+ //添加附件子表
|
|
|
if (addNewsDto.getAppendixList() != null) {
|
|
|
for (AddNewsAppendixDto appendixDto : addNewsDto.getAppendixList()) {
|
|
|
NewsAppendix newsAppendix = BeanUtil.toBean(appendixDto, NewsAppendix.class);
|
|
@@ -81,6 +89,7 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
|
|
|
newsAppendixMapper.insert(newsAppendix);
|
|
|
}
|
|
|
}
|
|
|
+ //公告需要添加阅读关系
|
|
|
if (addNewsDto.getRelationList() != null) {
|
|
|
for (AddNewsRelationDto relationDto : addNewsDto.getRelationList()) {
|
|
|
|
|
@@ -105,6 +114,27 @@ public class NewsServiceImpl extends MPJBaseServiceImpl<NewsMapper, News> implem
|
|
|
return news.getId();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public IPage<NewsPageVo> box(NewsPageDto dto) {
|
|
|
+ /*MPJLambdaWrapper<News> wrapper = MPJWrappers.<News>lambdaJoin()
|
|
|
+ .eq(ObjectUtil.isNotEmpty(dto.getType()) && dto.getType() > 0, News::getTypeId, dto.getType())
|
|
|
+ .and(wq -> wq.eq(News::getLevel, 1).or().eq(News::getLevel, 2).eq(News::getClassId, dto.getClassId()))
|
|
|
+ .eq(ObjectUtil.isNotEmpty(dto.getLevel()) && dto.getLevel() > 0, News::getLevel, dto.getLevel())
|
|
|
+ .and(wq -> wq.eq(News::getSendRange, 1).or().eq(News::getSendRange, 2).in(News::getId, "select id from xjr_oa_news_relation where news_id=t.id and user_id=" + StpUtil.getLoginIdAsLong()))
|
|
|
+ .like(StrUtil.isNotBlank(dto.getKeyword()), News::getFullHead, dto.getKeyword())
|
|
|
+ .leftJoin(NewsRelation.class, onWrapper -> onWrapper.eq(NewsRelation::getNewsId, News::getId).eq(NewsRelation::getUserId, StpUtil.getLoginIdAsLong()))
|
|
|
+ .selectAs(NewsRelation::getId, NewsPageVo::getReadId)
|
|
|
+ .selectAs(News::getId, NewsPageVo::getId)
|
|
|
+ .select(News.class, x -> VoToColumnUtil.fieldsToColumns(NewsPageVo.class).contains(x.getProperty()))
|
|
|
+ .orderByDesc(News::getCreateDate);//新闻按照创建时间倒序排*/
|
|
|
+
|
|
|
+ if(ObjectUtil.isNotNull(dto.getType()) && dto.getType() == 2){
|
|
|
+ dto.setLoginId(StpUtil.getLoginIdAsLong());
|
|
|
+ }
|
|
|
+ IPage<NewsPageVo> page = newsMapper.box(ConventPage.getPage(dto),dto);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean update(UpdateNewsDto updateNewsDto) {
|