|
|
@ -33,12 +33,9 @@ import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
|
import com.elink.esua.epdc.dao.NewsDao; |
|
|
|
import com.elink.esua.epdc.dto.BannerDTO; |
|
|
|
import com.elink.esua.epdc.dto.NewsDTO; |
|
|
|
import com.elink.esua.epdc.dto.NewsDepartmentDTO; |
|
|
|
import com.elink.esua.epdc.dto.NewsUserAttitudeDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.form.EpdcNewsDetailFormDTO; |
|
|
|
import com.elink.esua.epdc.dto.epdc.result.EpdcNewsListResultDTO; |
|
|
|
import com.elink.esua.epdc.entity.BannerEntity; |
|
|
|
import com.elink.esua.epdc.entity.NewsDepartmentEntity; |
|
|
|
import com.elink.esua.epdc.entity.NewsUserAttitudeEntity; |
|
|
|
import com.elink.esua.epdc.enums.AppNewsLikeEnum; |
|
|
|
import com.elink.esua.epdc.dto.epdc.form.EpdcNewsBrowseFromDTO; |
|
|
@ -134,25 +131,23 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(NewsDTO dto) { |
|
|
|
NewsEntity entity = ConvertUtils.sourceToTarget(dto, NewsEntity.class); |
|
|
|
//默认是0 手动下线是1
|
|
|
|
entity.setNewsUpDownState(YesOrNoEnum.NO.value()); |
|
|
|
UserDetail user = SecurityUser.getUser(); |
|
|
|
entity.setCreatorName(user.getRealName()); |
|
|
|
entity.setDeptId(user.getDeptId()); |
|
|
|
entity.setDeptName(user.getDeptName()); |
|
|
|
entity.setLikeNumber(NumConstant.ZERO); |
|
|
|
entity.setUnLikeNumber(NumConstant.ZERO); |
|
|
|
entity.setReadingAmount(NumConstant.ZERO); |
|
|
|
//存草稿
|
|
|
|
entity.setNewsReleaseState(YesOrNoEnum.YES.value()); |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void saveToDrafts(NewsDTO newsDto) { |
|
|
|
saveOrUpdateNews(newsDto, YesOrNoEnum.YES.value()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(NewsDTO dto) { |
|
|
|
NewsEntity entity = ConvertUtils.sourceToTarget(dto, NewsEntity.class); |
|
|
|
updateById(entity); |
|
|
|
QueryWrapper<NewsEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(FieldConstant.ID, dto.getId()) |
|
|
|
.select("NEWS_UP_DOWN_STATE"); |
|
|
|
NewsEntity entity = this.baseDao.selectOne(wrapper); |
|
|
|
this.saveOrUpdateNews(dto, entity.getNewsReleaseState()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -166,77 +161,87 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem |
|
|
|
|
|
|
|
@Override |
|
|
|
public int checkCountByCategoryId(String categoryId) { |
|
|
|
|
|
|
|
return baseDao.selectCountByCategoryId(categoryId); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean modifyOnLine(Map<String, String> parmas) { |
|
|
|
String id = parmas.get("id"); |
|
|
|
String onLineState = parmas.get("onLineState"); |
|
|
|
NewsDTO newsDTO = get(id); |
|
|
|
//判断下是不是上线 是的话才执行
|
|
|
|
if (YesOrNoEnum.NO.value().equals(newsDTO.getNewsUpDownState())) { |
|
|
|
newsDTO.setNewsUpDownState(YesOrNoEnum.YES.value()); |
|
|
|
NewsEntity entity = ConvertUtils.sourceToTarget(newsDTO, NewsEntity.class); |
|
|
|
updateById(entity); |
|
|
|
return true; |
|
|
|
NewsDTO newsDto = get(id); |
|
|
|
// 新闻上下线状态 默认是0 手动下线是1
|
|
|
|
if (null == newsDto || YesOrNoEnum.YES.value().equals(newsDto.getNewsUpDownState())) { |
|
|
|
// 新闻不存在或已下线
|
|
|
|
return false; |
|
|
|
} |
|
|
|
return false; |
|
|
|
NewsEntity entity = new NewsEntity(); |
|
|
|
entity.setId(id); |
|
|
|
entity.setNewsUpDownState(YesOrNoEnum.YES.value()); |
|
|
|
updateById(entity); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void savePublishNews(NewsDTO newsDTO) { |
|
|
|
saveOrUpdateNews(newsDTO, YesOrNoEnum.NO.value()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
publishNews(newsDTO, YesOrNoEnum.NO.value()); |
|
|
|
@Override |
|
|
|
public void modifyDraftsPublic(String id) { |
|
|
|
saveOrUpdateNews(this.get(id), YesOrNoEnum.NO.value()); |
|
|
|
} |
|
|
|
|
|
|
|
private void publishNews(NewsDTO newsDTO, String newsReleaseState) { |
|
|
|
NewsEntity entity = ConvertUtils.sourceToTarget(newsDTO, NewsEntity.class); |
|
|
|
//发布的时候 默认是0 手动下线 为1
|
|
|
|
entity.setNewsUpDownState(YesOrNoEnum.NO.value()); |
|
|
|
/** |
|
|
|
* 新闻的数据库操作 |
|
|
|
* |
|
|
|
* @param newsDto 新闻数据传输对象 |
|
|
|
* @param newsReleaseState 是否是草稿箱操作(存草稿或草稿箱中修改操作) |
|
|
|
* @return void |
|
|
|
* @author qushutong |
|
|
|
* @date |
|
|
|
*/ |
|
|
|
private void saveOrUpdateNews(NewsDTO newsDto, String newsReleaseState) { |
|
|
|
NewsEntity entity = ConvertUtils.sourceToTarget(newsDto, NewsEntity.class); |
|
|
|
UserDetail user = SecurityUser.getUser(); |
|
|
|
entity.setCreatorName(user.getRealName()); |
|
|
|
entity.setDeptId(user.getDeptId()); |
|
|
|
entity.setDeptName(user.getDeptName()); |
|
|
|
entity.setLikeNumber(NumConstant.ZERO); |
|
|
|
entity.setUnLikeNumber(NumConstant.ZERO); |
|
|
|
entity.setReadingAmount(NumConstant.ZERO); |
|
|
|
//是不是草稿箱
|
|
|
|
entity.setNewsReleaseState(newsReleaseState); |
|
|
|
|
|
|
|
boolean isSave = true; |
|
|
|
if (StringUtils.isNotBlank(newsDTO.getId())) { |
|
|
|
if (StringUtils.isBlank(newsDto.getId())) { |
|
|
|
// 新增操作时,保存创建人,创建人部门信息。
|
|
|
|
entity.setCreatorName(user.getRealName()); |
|
|
|
entity.setDeptId(user.getDeptId()); |
|
|
|
entity.setDeptName(user.getDeptName()); |
|
|
|
// 初始化互动数
|
|
|
|
entity.setLikeNumber(NumConstant.ZERO); |
|
|
|
entity.setUnLikeNumber(NumConstant.ZERO); |
|
|
|
entity.setReadingAmount(NumConstant.ZERO); |
|
|
|
// 发布的时候 默认是0 手动下线 为1
|
|
|
|
entity.setNewsUpDownState(YesOrNoEnum.NO.value()); |
|
|
|
} else { |
|
|
|
isSave = false; |
|
|
|
} |
|
|
|
//草稿箱的新增和更新
|
|
|
|
// 通知所属部门id
|
|
|
|
Long newsDeptId = entity.getStreetId(); |
|
|
|
// 能接收通知的所有网格的ID
|
|
|
|
List<Long> newsGridList = Lists.newArrayList(); |
|
|
|
if (null != entity.getCommunityId()) { |
|
|
|
newsDeptId = entity.getCommunityId(); |
|
|
|
} |
|
|
|
if (null != entity.getGridId()) { |
|
|
|
newsDeptId = entity.getGridId(); |
|
|
|
newsGridList.add(newsDeptId); |
|
|
|
} |
|
|
|
if (!user.getDeptIdList().contains(newsDeptId)) { |
|
|
|
throw new RenException("您没有操作此部门的数据权限"); |
|
|
|
} |
|
|
|
//草稿箱操作
|
|
|
|
if (YesOrNoEnum.YES.value().equals(newsReleaseState)) { |
|
|
|
if (isSave) { |
|
|
|
insert(entity); |
|
|
|
} else { |
|
|
|
updateById(entity); |
|
|
|
newsDepartmentService.deleteByNewsId(entity.getId()); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 通知所属部门id
|
|
|
|
Long newsDeptId = entity.getStreetId(); |
|
|
|
// 能接收通知的所有网格的ID
|
|
|
|
List<Long> newsGridList = Lists.newArrayList(); |
|
|
|
if (null != entity.getCommunityId()) { |
|
|
|
newsDeptId = entity.getCommunityId(); |
|
|
|
} |
|
|
|
if (null != entity.getGridId()) { |
|
|
|
newsDeptId = entity.getGridId(); |
|
|
|
newsGridList.add(newsDeptId); |
|
|
|
} |
|
|
|
|
|
|
|
if (!user.getDeptIdList().contains(newsDeptId)) { |
|
|
|
throw new RenException("您没有操作此部门的数据权限"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isEmpty(newsGridList)) { |
|
|
|
Result<List<Long>> adminResult = adminFeignClient.listGridIdByDeptPid(newsDeptId); |
|
|
|
if (!adminResult.success() || CollUtil.isEmpty(adminResult.getData())) { |
|
|
@ -254,13 +259,6 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void modifyDraftsPublic(String id) { |
|
|
|
NewsDTO newsDTO = get(id); |
|
|
|
publishNews(newsDTO, YesOrNoEnum.NO.value()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<List<EpdcNewsListResultDTO>> listNews(EpdcNewsListFromDTO formDto) { |
|
|
|
|
|
|
|