|
|
@ -42,6 +42,7 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
@ -82,6 +83,7 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<NewsEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String draft= (String) params.get("draft"); |
|
|
|
String streetId=(String) params.get("streetId"); |
|
|
|
String communityId=(String) params.get("communityId"); |
|
|
|
String gridId=(String) params.get("gridId"); |
|
|
@ -97,19 +99,16 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem |
|
|
|
wrapper.lt(StringUtils.isNotBlank(endTime),"CREATED_TIME",endTime); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(category),"NEWS_CATERORY_ID",category); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(keyword),"NEWS_TITLE",keyword); |
|
|
|
//draft 前端传上来的一个标志 有则代表是存草稿箱的 1
|
|
|
|
if(StringUtils.isNotEmpty(draft)){ |
|
|
|
wrapper.eq(StringUtils.isNotBlank(draft),"NEWS_RELEASE_STATE","1"); |
|
|
|
}else { |
|
|
|
wrapper.eq(StringUtils.isNotBlank(draft),"NEWS_RELEASE_STATE","0"); |
|
|
|
} |
|
|
|
wrapper.orderByDesc("CREATED_TIME"); |
|
|
|
return wrapper; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description |
|
|
|
* @Author qushutong |
|
|
|
* @Date 2019/9/6 14:14 |
|
|
|
* @Param |
|
|
|
* @Return |
|
|
|
* @Exception |
|
|
|
* |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public NewsDTO get(String id) { |
|
|
|
NewsEntity entity = baseDao.selectById(id); |
|
|
@ -120,6 +119,14 @@ 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("0"); |
|
|
|
UserDetail user = SecurityUser.getUser(); |
|
|
|
entity.setCreatorName(user.getRealName()); |
|
|
|
entity.setDeptId(user.getDeptId()); |
|
|
|
entity.setDeptName(user.getDeptName()); |
|
|
|
//存草稿
|
|
|
|
entity.setNewsReleaseState("1"); |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
@ -135,6 +142,8 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem |
|
|
|
public void delete(String[] ids) { |
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
//删除部门关系表相关数据
|
|
|
|
newsDepartmentService.deleteByNewsId(ids[0]); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -144,25 +153,38 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void modifyOnLine(Map<String,String> parmas) { |
|
|
|
public boolean modifyOnLine(Map<String,String> parmas) { |
|
|
|
String id=parmas.get("id"); |
|
|
|
String onLineState=parmas.get("onLineState"); |
|
|
|
NewsDTO newsDTO = get(id); |
|
|
|
newsDTO.setNewsUpDownState(onLineState); |
|
|
|
NewsEntity entity = ConvertUtils.sourceToTarget(newsDTO, NewsEntity.class); |
|
|
|
updateById(entity); |
|
|
|
//判断下是不是上线 是的话才执行
|
|
|
|
if("1".equals(newsDTO.getNewsUpDownState())){ |
|
|
|
newsDTO.setNewsUpDownState(onLineState); |
|
|
|
NewsEntity entity = ConvertUtils.sourceToTarget(newsDTO, NewsEntity.class); |
|
|
|
updateById(entity); |
|
|
|
return true; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void savePublishNews(NewsDTO newsDTO) { |
|
|
|
|
|
|
|
|
|
|
|
publishNews(newsDTO,"0"); |
|
|
|
} |
|
|
|
|
|
|
|
private void publishNews(NewsDTO newsDTO,String newsReleaseState ) { |
|
|
|
NewsEntity entity = ConvertUtils.sourceToTarget(newsDTO, NewsEntity.class); |
|
|
|
entity.setNewsUpDownState("1"); |
|
|
|
//发布的时候 默认是0 手动下线 为1
|
|
|
|
entity.setNewsUpDownState("0"); |
|
|
|
UserDetail user = SecurityUser.getUser(); |
|
|
|
entity.setCreatorName(user.getRealName()); |
|
|
|
entity.setDeptId(user.getDeptId()); |
|
|
|
entity.setDeptName(user.getDeptName()); |
|
|
|
entity.setNewsUpDownState("1"); |
|
|
|
//不是草稿箱
|
|
|
|
entity.setNewsReleaseState("0"); |
|
|
|
|
|
|
|
// 通知所属部门id
|
|
|
|
Long newsDeptId = entity.getStreetId(); |
|
|
@ -202,4 +224,11 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem |
|
|
|
this.newsDepartmentService.save(entity.getId(), newsGridList); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void modifyDraftsPublic(String id) { |
|
|
|
NewsDTO newsDTO = get(id); |
|
|
|
publishNews(newsDTO,"1"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |