|
@ -31,6 +31,8 @@ import com.elink.esua.epdc.commons.tools.security.user.UserDetail; |
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
|
|
|
import com.elink.esua.epdc.constant.NewsConstant; |
|
|
|
|
|
import com.elink.esua.epdc.dao.NewsCategoryDao; |
|
|
import com.elink.esua.epdc.dao.NewsDao; |
|
|
import com.elink.esua.epdc.dao.NewsDao; |
|
|
import com.elink.esua.epdc.dto.BannerDTO; |
|
|
import com.elink.esua.epdc.dto.BannerDTO; |
|
|
import com.elink.esua.epdc.dto.NewsDTO; |
|
|
import com.elink.esua.epdc.dto.NewsDTO; |
|
@ -38,10 +40,12 @@ import com.elink.esua.epdc.dto.NewsUserAttitudeDTO; |
|
|
import com.elink.esua.epdc.dto.ParentAndAllDeptDTO; |
|
|
import com.elink.esua.epdc.dto.ParentAndAllDeptDTO; |
|
|
import com.elink.esua.epdc.dto.epdc.form.*; |
|
|
import com.elink.esua.epdc.dto.epdc.form.*; |
|
|
import com.elink.esua.epdc.dto.epdc.result.EpdcNewsListResultDTO; |
|
|
import com.elink.esua.epdc.dto.epdc.result.EpdcNewsListResultDTO; |
|
|
|
|
|
import com.elink.esua.epdc.entity.NewsCategoryEntity; |
|
|
import com.elink.esua.epdc.entity.NewsUserAttitudeEntity; |
|
|
import com.elink.esua.epdc.entity.NewsUserAttitudeEntity; |
|
|
import com.elink.esua.epdc.enums.AppNewsLikeEnum; |
|
|
import com.elink.esua.epdc.enums.AppNewsLikeEnum; |
|
|
import com.elink.esua.epdc.dto.epdc.result.EpdcNewsDetailResultDTO; |
|
|
import com.elink.esua.epdc.dto.epdc.result.EpdcNewsDetailResultDTO; |
|
|
import com.elink.esua.epdc.entity.NewsEntity; |
|
|
import com.elink.esua.epdc.entity.NewsEntity; |
|
|
|
|
|
import com.elink.esua.epdc.enums.BannerPositionEnum; |
|
|
import com.elink.esua.epdc.enums.IndependentFunctionCodeEnum; |
|
|
import com.elink.esua.epdc.enums.IndependentFunctionCodeEnum; |
|
|
import com.elink.esua.epdc.feign.AdminFeignClient; |
|
|
import com.elink.esua.epdc.feign.AdminFeignClient; |
|
|
import com.elink.esua.epdc.rocketmq.dto.OrganizationModifyDTO; |
|
|
import com.elink.esua.epdc.rocketmq.dto.OrganizationModifyDTO; |
|
@ -97,17 +101,12 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem |
|
|
private QueryWrapper<NewsEntity> getWrapper(Map<String, Object> params) { |
|
|
private QueryWrapper<NewsEntity> getWrapper(Map<String, Object> params) { |
|
|
UserDetail user = SecurityUser.getUser(); |
|
|
UserDetail user = SecurityUser.getUser(); |
|
|
String draft = (String) params.get("draft"); |
|
|
String draft = (String) params.get("draft"); |
|
|
/*String streetId = (String) params.get(FieldConstant.STREET_ID_HUMP); |
|
|
|
|
|
String communityId = (String) params.get(FieldConstant.COMMUNITY_ID_HUMP);*/ |
|
|
|
|
|
String gridId = (String) params.get(FieldConstant.GRID_ID_HUMP); |
|
|
String gridId = (String) params.get(FieldConstant.GRID_ID_HUMP); |
|
|
String startTime = (String) params.get("startTime"); |
|
|
String startTime = (String) params.get("startTime"); |
|
|
String endTime = (String) params.get("endTime"); |
|
|
String endTime = (String) params.get("endTime"); |
|
|
String category = (String) params.get("category"); |
|
|
String category = (String) params.get("category"); |
|
|
String keyword = ((String) params.get("keyword")); |
|
|
String keyword = ((String) params.get("keyword")); |
|
|
QueryWrapper<NewsEntity> wrapper = new QueryWrapper<>(); |
|
|
QueryWrapper<NewsEntity> wrapper = new QueryWrapper<>(); |
|
|
/*wrapper.eq(StringUtils.isNotBlank(streetId), FieldConstant.STREET_ID, streetId); |
|
|
|
|
|
wrapper.eq(StringUtils.isNotBlank(communityId), "COMMUNITY_ID", communityId); |
|
|
|
|
|
wrapper.eq(StringUtils.isNotBlank(gridId), FieldConstant.GRID_ID, gridId);*/ |
|
|
|
|
|
wrapper.ge(StringUtils.isNotBlank(startTime), FieldConstant.CREATED_TIME, startTime); |
|
|
wrapper.ge(StringUtils.isNotBlank(startTime), FieldConstant.CREATED_TIME, startTime); |
|
|
wrapper.lt(StringUtils.isNotBlank(endTime), FieldConstant.CREATED_TIME, endTime); |
|
|
wrapper.lt(StringUtils.isNotBlank(endTime), FieldConstant.CREATED_TIME, endTime); |
|
|
wrapper.eq(StringUtils.isNotBlank(category), "NEWS_CATERORY_ID", category); |
|
|
wrapper.eq(StringUtils.isNotBlank(category), "NEWS_CATERORY_ID", category); |
|
@ -130,14 +129,7 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public NewsDTO get(String id) { |
|
|
public NewsDTO get(String id) { |
|
|
NewsEntity entity = baseDao.selectById(id); |
|
|
return baseDao.selectOneNewsDto(id); |
|
|
NewsDTO dto = ConvertUtils.sourceToTarget(entity, NewsDTO.class); |
|
|
|
|
|
/*if(StringUtils.isNotBlank(dto.getAllDeptIds())){ |
|
|
|
|
|
String[] idsShow = dto.getAllDeptIds().split(","); |
|
|
|
|
|
List<String> ids = Arrays.asList(idsShow); |
|
|
|
|
|
dto.setAllDeptIdsShow(ids.subList(1,ids.size())); |
|
|
|
|
|
}*/ |
|
|
|
|
|
return dto; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -224,26 +216,16 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem |
|
|
private void saveOrUpdateNews(NewsDTO newsDto, String newsReleaseState, String isDraftsPublishNews) { |
|
|
private void saveOrUpdateNews(NewsDTO newsDto, String newsReleaseState, String isDraftsPublishNews) { |
|
|
NewsEntity entity = ConvertUtils.sourceToTarget(newsDto, NewsEntity.class); |
|
|
NewsEntity entity = ConvertUtils.sourceToTarget(newsDto, NewsEntity.class); |
|
|
UserDetail user = SecurityUser.getUser(); |
|
|
UserDetail user = SecurityUser.getUser(); |
|
|
Long newsDeptId = user.getDeptId(); |
|
|
|
|
|
//是不是草稿箱
|
|
|
//是不是草稿箱
|
|
|
entity.setNewsReleaseState(newsReleaseState); |
|
|
entity.setNewsReleaseState(newsReleaseState); |
|
|
boolean isSave = true; |
|
|
boolean isSave = true; |
|
|
if (StringUtils.isBlank(newsDto.getId())) { |
|
|
if (StringUtils.isBlank(newsDto.getId())) { |
|
|
// 新增操作时,保存创建人,创建人部门信息。
|
|
|
initNews(entity, user); |
|
|
entity.setCreatorName(user.getRealName()); |
|
|
|
|
|
entity.setDeptId(newsDeptId); |
|
|
|
|
|
entity.setDeptName(user.getDeptName()); |
|
|
|
|
|
// 初始化互动数
|
|
|
|
|
|
entity.setLikeNumber(NumConstant.ZERO); |
|
|
|
|
|
entity.setUnLikeNumber(NumConstant.ZERO); |
|
|
|
|
|
entity.setReadingAmount(NumConstant.ZERO); |
|
|
|
|
|
// 发布的时候 默认是0 手动下线 为1
|
|
|
|
|
|
entity.setNewsUpDownState(YesOrNoEnum.NO.value()); |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
isSave = false; |
|
|
isSave = false; |
|
|
} |
|
|
} |
|
|
// 新闻所属部门id(新闻发布方所在部门)
|
|
|
// 新闻所属部门id(新闻发布方所在部门)
|
|
|
ParentAndAllDeptDTO deptDto = getParentAndAllDeptDTO(String.valueOf(newsDeptId)); |
|
|
ParentAndAllDeptDTO deptDto = getParentAndAllDeptDTO(String.valueOf(user.getDeptId())); |
|
|
DeptEntityUtils.loadDeptInfo( |
|
|
DeptEntityUtils.loadDeptInfo( |
|
|
ConvertUtils.sourceToTarget(deptDto, DeptEntityUtils.DeptDto.class), |
|
|
ConvertUtils.sourceToTarget(deptDto, DeptEntityUtils.DeptDto.class), |
|
|
entity |
|
|
entity |
|
@ -259,24 +241,17 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem |
|
|
if (isSave) { |
|
|
if (isSave) { |
|
|
insert(entity); |
|
|
insert(entity); |
|
|
} else { |
|
|
} else { |
|
|
// 修改草稿
|
|
|
updateNewsById(entity, user.getRealName(), new Date(), null); |
|
|
if (YesOrNoEnum.YES.value().equals(newsReleaseState)) { |
|
|
// 不是修改草稿
|
|
|
entity.setUpdatedBy(user.getRealName()); |
|
|
if (YesOrNoEnum.NO.value().equals(newsReleaseState)) { |
|
|
entity.setUpdatedTime(new Date()); |
|
|
|
|
|
this.baseDao.updateNewsById(entity); |
|
|
|
|
|
} else { |
|
|
|
|
|
entity.setUpdatedBy(user.getRealName()); |
|
|
|
|
|
entity.setUpdatedTime(new Date()); |
|
|
|
|
|
this.baseDao.updateNewsById(entity); |
|
|
|
|
|
|
|
|
|
|
|
// 已经上banner的处理
|
|
|
// 已经上banner的处理
|
|
|
if (newsDto.getBannerFlag().equals(YesOrNoEnum.YES.value())) { |
|
|
if (newsDto.getBannerFlag().equals(YesOrNoEnum.YES.value())) { |
|
|
String bannerId = bannerService.getBannerIdByNewsId(newsDto.getId()); |
|
|
String bannerId = bannerService.getBannerIdByNewsId(newsDto.getId()); |
|
|
BannerDTO bannerDto = ConvertUtils.sourceToTarget(newsDto, BannerDTO.class); |
|
|
BannerDTO bannerDto = ConvertUtils.sourceToTarget(newsDto, BannerDTO.class); |
|
|
bannerDto.setId(bannerId); |
|
|
bannerDto.setId(bannerId); |
|
|
bannerDto.setAllDeptIdsShow(allDeptIdsShow); |
|
|
bannerDto.setAllDeptIdsShow(allDeptIdsShow); |
|
|
bannerDto = packBannerDtoByNews(bannerDto, newsDto.getId(), newsDto.getNewsImageUrl(), newsDto.getNewsTitle()); |
|
|
bannerDto.setPosition(getBannerPositionByCategoryId(newsDto.getNewsCateroryId())); |
|
|
bannerService.saveOrUpdate(bannerDto); |
|
|
bannerService.saveOrUpdate(packBannerDtoByNews(bannerDto, newsDto.getId(), newsDto.getNewsImageUrl(), newsDto.getNewsTitle())); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
// 只要是修改操作,新闻部门关系,先删除再插入
|
|
|
// 只要是修改操作,新闻部门关系,先删除再插入
|
|
@ -284,12 +259,31 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem |
|
|
} |
|
|
} |
|
|
this.newsDepartmentService.save(entity.getId(), newsGridList); |
|
|
this.newsDepartmentService.save(entity.getId(), newsGridList); |
|
|
} else { |
|
|
} else { |
|
|
// 发布一条新闻,只可能是修改,直接修改
|
|
|
// 从草稿发布一条新闻,只可能是修改,直接修改
|
|
|
entity.setUpdatedBy(user.getRealName()); |
|
|
updateNewsById(entity, user.getRealName(), new Date(), new Date()); |
|
|
entity.setUpdatedTime(new Date()); |
|
|
} |
|
|
entity.setCreatedTime(new Date()); |
|
|
} |
|
|
this.baseDao.updateNewsById(entity); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initNews(NewsEntity entity, UserDetail user) { |
|
|
|
|
|
// 新增操作时,保存创建人,创建人部门信息。
|
|
|
|
|
|
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()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void updateNewsById(NewsEntity entity, String updatedBy, Date updatedTime, Date createdTime) { |
|
|
|
|
|
entity.setUpdatedBy(updatedBy); |
|
|
|
|
|
entity.setUpdatedTime(updatedTime); |
|
|
|
|
|
entity.setCreatedTime(createdTime); |
|
|
|
|
|
this.baseDao.updateNewsById(entity); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private ParentAndAllDeptDTO getParentAndAllDeptDTO(String gridId) { |
|
|
private ParentAndAllDeptDTO getParentAndAllDeptDTO(String gridId) { |
|
@ -312,8 +306,6 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem |
|
|
bannerDto.setTitle(newsTitle); |
|
|
bannerDto.setTitle(newsTitle); |
|
|
// 数据字典值,2-新闻类型
|
|
|
// 数据字典值,2-新闻类型
|
|
|
bannerDto.setBannerType(NumConstant.TWO_STR); |
|
|
bannerDto.setBannerType(NumConstant.TWO_STR); |
|
|
// banner位置,0顶部;1中间
|
|
|
|
|
|
bannerDto.setPosition(NumConstant.ZERO_STR); |
|
|
|
|
|
return bannerDto; |
|
|
return bannerDto; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -329,11 +321,9 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<EpdcNewsListResultDTO> listNewsByCategory(EpdcNewsListByCategoryFromDTO formDto) { |
|
|
public List<EpdcNewsListResultDTO> listNewsByCategory(EpdcNewsListByCategoryFromDTO formDto) { |
|
|
if (!IndependentFunctionCodeEnum.POLICE_NOTICE.getCode().equals(formDto.getCategoryCode()) |
|
|
if (IndependentFunctionCodeEnum.getByCode(formDto.getCategoryCode()) == null) { |
|
|
&& !IndependentFunctionCodeEnum.SAFETY_PRECAUTIONS.getCode().equals(formDto.getCategoryCode())) { |
|
|
|
|
|
return Lists.newArrayList(); |
|
|
return Lists.newArrayList(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int pageIndex = (formDto.getPageIndex() - NumConstant.ONE) * formDto.getPageSize(); |
|
|
int pageIndex = (formDto.getPageIndex() - NumConstant.ONE) * formDto.getPageSize(); |
|
|
formDto.setPageIndex(pageIndex); |
|
|
formDto.setPageIndex(pageIndex); |
|
|
return this.baseDao.selectListAppNewsByCategory(formDto); |
|
|
return this.baseDao.selectListAppNewsByCategory(formDto); |
|
@ -437,8 +427,8 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public Result newsToBanner(String newsId) { |
|
|
public Result newsToBanner(String newsId) { |
|
|
|
|
|
|
|
|
NewsEntity newsEntity = baseDao.selectById(newsId); |
|
|
NewsDTO newsDto = baseDao.selectOneNewsDto(newsId); |
|
|
if (null == newsEntity || YesOrNoEnum.YES.value().equals(newsEntity.getBannerFlag())) { |
|
|
if (null == newsDto || YesOrNoEnum.YES.value().equals(newsDto.getBannerFlag())) { |
|
|
return new Result().error("操作失败,新闻不存在或已是banner"); |
|
|
return new Result().error("操作失败,新闻不存在或已是banner"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -447,11 +437,9 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem |
|
|
throw new RenException("获取部门信息失败"); |
|
|
throw new RenException("获取部门信息失败"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BannerDTO banner = ConvertUtils.sourceToTarget(newsEntity, BannerDTO.class); |
|
|
BannerDTO banner = packBannerDtoByNews(ConvertUtils.sourceToTarget(newsDto, BannerDTO.class), |
|
|
banner = packBannerDtoByNews(banner, newsId, newsEntity.getNewsImageUrl(), newsEntity.getNewsTitle()); |
|
|
newsId, newsDto.getNewsImageUrl(), newsDto.getNewsTitle()); |
|
|
// 平安榆山相关新闻上banner时,POSITION设为2
|
|
|
banner.setPosition(getBannerPosition(newsDto.getNewsCateroryCode())); |
|
|
banner.setPosition(NumConstant.TWO_STR); |
|
|
|
|
|
banner.setNewsCategory(newsEntity.getNewsCateroryId()); |
|
|
|
|
|
this.bannerService.saveNewsToBanner(banner, deptIds); |
|
|
this.bannerService.saveNewsToBanner(banner, deptIds); |
|
|
|
|
|
|
|
|
NewsEntity news = new NewsEntity(); |
|
|
NewsEntity news = new NewsEntity(); |
|
@ -463,6 +451,44 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private NewsCategoryDao newsCategoryDao; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 新闻上banner时,根据新闻类别id确定banner位置 |
|
|
|
|
|
* |
|
|
|
|
|
* @param newsCategoryId |
|
|
|
|
|
* @return java.lang.String |
|
|
|
|
|
* @author work@yujt.net.cn |
|
|
|
|
|
* @date 2020/5/27 10:15 |
|
|
|
|
|
*/ |
|
|
|
|
|
private String getBannerPositionByCategoryId(String newsCategoryId) { |
|
|
|
|
|
String newsCategoryCode = StringUtils.EMPTY; |
|
|
|
|
|
NewsCategoryEntity categoryEntity = newsCategoryDao.selectById(newsCategoryId); |
|
|
|
|
|
if (null != categoryEntity) { |
|
|
|
|
|
newsCategoryCode = categoryEntity.getCategoryCode(); |
|
|
|
|
|
} |
|
|
|
|
|
return getBannerPosition(newsCategoryCode); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 新闻上banner时,根据新闻类别编码确定banner位置 |
|
|
|
|
|
* |
|
|
|
|
|
* @param newsCategoryCode |
|
|
|
|
|
* @return java.lang.String |
|
|
|
|
|
* @author work@yujt.net.cn |
|
|
|
|
|
* @date 2020/5/27 10:15 |
|
|
|
|
|
*/ |
|
|
|
|
|
private String getBannerPosition(String newsCategoryCode) { |
|
|
|
|
|
switch (newsCategoryCode) { |
|
|
|
|
|
case NewsConstant.POLICE_NOTICE: |
|
|
|
|
|
case NewsConstant.SAFETY_PRECAUTIONS: |
|
|
|
|
|
return BannerPositionEnum.SAFETY.getValue(); |
|
|
|
|
|
default: |
|
|
|
|
|
return BannerPositionEnum.HOME_PAGE_HEAD.getValue(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 用户新闻参与类型 |
|
|
* 用户新闻参与类型 |
|
|
* |
|
|
* |
|
|