Browse Source

新闻发布

dev
qushutong 6 years ago
parent
commit
348aeb6809
  1. 7
      esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NewsDTO.java
  2. 81
      esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NewsDepartmentDTO.java
  3. 12
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NewsController.java
  4. 94
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NewsDepartmentController.java
  5. 39
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NewsDepartmentDao.java
  6. 51
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NewsDepartmentEntity.java
  7. 8
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NewsEntity.java
  8. 62
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/NewsDepartmentExcel.java
  9. 3
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/NewsExcel.java
  10. 47
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/redis/NewsDepartmentRedis.java
  11. 109
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NewsDepartmentService.java
  12. 2
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NewsService.java
  13. 131
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NewsDepartmentServiceImpl.java
  14. 74
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java
  15. 1
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NewsDao.xml
  16. 22
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NewsDepartmentDao.xml

7
esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NewsDTO.java

@ -73,6 +73,11 @@ public class NewsDTO implements Serializable {
*/
private String newsUpDownState;
/**
* 新闻是否发布 0否1是
*/
private String newsReleaseState;
/**
* 新闻发布开始时间
*/
@ -91,7 +96,7 @@ public class NewsDTO implements Serializable {
/**
* 发布人部门ID
*/
private String deptId;
private Long deptId;
/**
* 阅读量

81
esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NewsDepartmentDTO.java

@ -0,0 +1,81 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.dto;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 新闻部门关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-09-06
*/
@Data
public class NewsDepartmentDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String id;
/**
* 新闻ID
*/
private String newsId;
/**
* 部门ID
*/
private Long deptId;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
/**
* 删除标记
*/
private String delFlag;
}

12
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NewsController.java

@ -97,5 +97,17 @@ public class NewsController {
return new Result();
}
/**
* 发布新闻
* @param dto
* @return
*/
@PostMapping()
public Result publishNews(@RequestBody NewsDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
newsService.savePublishNews(dto);
return new Result();
}
}

94
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NewsDepartmentController.java

@ -0,0 +1,94 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.controller;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.commons.tools.validator.AssertUtils;
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils;
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup;
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup;
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup;
import com.elink.esua.epdc.dto.NewsDepartmentDTO;
import com.elink.esua.epdc.excel.NewsDepartmentExcel;
import com.elink.esua.epdc.service.NewsDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 新闻部门关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-09-06
*/
@RestController
@RequestMapping("newsdepartment")
public class NewsDepartmentController {
@Autowired
private NewsDepartmentService newsDepartmentService;
@GetMapping("page")
public Result<PageData<NewsDepartmentDTO>> page(@RequestParam Map<String, Object> params){
PageData<NewsDepartmentDTO> page = newsDepartmentService.page(params);
return new Result<PageData<NewsDepartmentDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<NewsDepartmentDTO> get(@PathVariable("id") String id){
NewsDepartmentDTO data = newsDepartmentService.get(id);
return new Result<NewsDepartmentDTO>().ok(data);
}
@PostMapping
public Result save(@RequestBody NewsDepartmentDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
newsDepartmentService.save(dto);
return new Result();
}
@PutMapping
public Result update(@RequestBody NewsDepartmentDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
newsDepartmentService.update(dto);
return new Result();
}
@DeleteMapping
public Result delete(@RequestBody String[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
newsDepartmentService.delete(ids);
return new Result();
}
@GetMapping("export")
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<NewsDepartmentDTO> list = newsDepartmentService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, NewsDepartmentExcel.class);
}
}

39
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NewsDepartmentDao.java

@ -0,0 +1,39 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.entity.NewsDepartmentEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 新闻部门关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-09-06
*/
@Mapper
public interface NewsDepartmentDao extends BaseDao<NewsDepartmentEntity> {
/**
* 修改的时候把该新闻的部门关联都清除
* @param newsId
*/
void deleteByNewsId(String newsId);
}

51
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NewsDepartmentEntity.java

@ -0,0 +1,51 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 新闻部门关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-09-06
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("epdc_news_department")
public class NewsDepartmentEntity extends BaseEpdcEntity {
private static final long serialVersionUID = 1L;
/**
* 新闻ID
*/
private String newsId;
/**
* 部门ID
*/
private Long deptId;
}

8
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NewsEntity.java

@ -17,6 +17,7 @@
package com.elink.esua.epdc.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableName;
import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity;
@ -91,7 +92,12 @@ public class NewsEntity extends BaseEpdcEntity {
/**
* 发布人部门ID
*/
private String deptId;
private Long deptId;
/**
* 新闻是否发布 0否1是
*/
private String newsReleaseState;
/**
* 阅读量

62
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/NewsDepartmentExcel.java

@ -0,0 +1,62 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.util.Date;
/**
* 新闻部门关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-09-06
*/
@Data
public class NewsDepartmentExcel {
@Excel(name = "主键")
private String id;
@Excel(name = "新闻ID")
private String newsId;
@Excel(name = "部门ID")
private String deptId;
@Excel(name = "乐观锁")
private Integer revision;
@Excel(name = "创建人")
private String createdBy;
@Excel(name = "创建时间")
private Date createdTime;
@Excel(name = "更新人")
private String updatedBy;
@Excel(name = "更新时间")
private Date updatedTime;
@Excel(name = "删除标记")
private String delFlag;
}

3
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/NewsExcel.java

@ -55,6 +55,9 @@ public class NewsExcel {
@Excel(name = "新闻上下线状态 0-下线,1-上线")
private String newsUpDownState;
@Excel(name = "新闻是否发布 0否,1是")
private String newsReleaseState;
@Excel(name = "新闻发布开始时间")
private Date newsReleaseStartTime;

47
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/redis/NewsDepartmentRedis.java

@ -0,0 +1,47 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.redis;
import com.elink.esua.epdc.commons.tools.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 新闻部门关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-09-06
*/
@Component
public class NewsDepartmentRedis {
@Autowired
private RedisUtils redisUtils;
public void delete(Object[] ids) {
}
public void set(){
}
public String get(String id){
return null;
}
}

109
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NewsDepartmentService.java

@ -0,0 +1,109 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.service;
import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.dto.NewsDepartmentDTO;
import com.elink.esua.epdc.entity.NewsDepartmentEntity;
import java.util.List;
import java.util.Map;
/**
* 新闻部门关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-09-06
*/
public interface NewsDepartmentService extends BaseService<NewsDepartmentEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<NewsDepartmentDTO>
* @author
* @date
*/
PageData<NewsDepartmentDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<NewsDepartmentDTO>
* @author
* @date
*/
List<NewsDepartmentDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return NewsDepartmentDTO
* @author
* @date
*/
NewsDepartmentDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author
* @date
*/
void save(NewsDepartmentDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author
* @date
*/
void update(NewsDepartmentDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author
* @date
*/
void delete(String[] ids);
/**
* 修改的时候把该新闻的部门关联都清除
* @param newsId
*/
void deleteByNewsId(String newsId);
/**
* 保存所有网格
* @param id
* @param newsGridList
*/
void save(String id, List<Long> newsGridList);
}

2
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NewsService.java

@ -105,6 +105,6 @@ public interface NewsService extends BaseService<NewsEntity> {
*/
void modifyOnLine(Map<String,String> parmas);
void savePublishNews(NewsDTO newsDTO);
}

131
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NewsDepartmentServiceImpl.java

@ -0,0 +1,131 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.constant.NumConstant;
import com.elink.esua.epdc.commons.tools.exception.RenException;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.dao.NewsDepartmentDao;
import com.elink.esua.epdc.dto.NewsDepartmentDTO;
import com.elink.esua.epdc.entity.NewsDepartmentEntity;
import com.elink.esua.epdc.entity.NoticeDepartmentEntity;
import com.elink.esua.epdc.redis.NewsDepartmentRedis;
import com.elink.esua.epdc.service.NewsDepartmentService;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 新闻部门关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-09-06
*/
@Service
public class NewsDepartmentServiceImpl extends BaseServiceImpl<NewsDepartmentDao, NewsDepartmentEntity> implements NewsDepartmentService {
@Autowired
private NewsDepartmentRedis newsDepartmentRedis;
@Override
public PageData<NewsDepartmentDTO> page(Map<String, Object> params) {
IPage<NewsDepartmentEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, NewsDepartmentDTO.class);
}
@Override
public List<NewsDepartmentDTO> list(Map<String, Object> params) {
List<NewsDepartmentEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, NewsDepartmentDTO.class);
}
private QueryWrapper<NewsDepartmentEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<NewsDepartmentEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public NewsDepartmentDTO get(String id) {
NewsDepartmentEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, NewsDepartmentDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(NewsDepartmentDTO dto) {
NewsDepartmentEntity entity = ConvertUtils.sourceToTarget(dto, NewsDepartmentEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(NewsDepartmentDTO dto) {
NewsDepartmentEntity entity = ConvertUtils.sourceToTarget(dto, NewsDepartmentEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Override
public void deleteByNewsId(String newsId) {
baseDao.deleteByNewsId(newsId);
}
@Override
public void save(String id, List<Long> newsGridList) {
if (StringUtils.isBlank(id) || CollUtil.isEmpty(newsGridList)) {
throw new RenException("保存通知网格信息失败");
}
List<NewsDepartmentEntity> list = new ArrayList<>();
NewsDepartmentEntity entity;
for (Long gridId : newsGridList) {
entity = new NewsDepartmentEntity();
entity.setNewsId(id);
entity.setDeptId(gridId);
list.add(entity);
}
this.insertBatch(list, NumConstant.TWENTY);
}
}

74
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java

@ -17,17 +17,25 @@
package com.elink.esua.epdc.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.exception.RenException;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.security.user.SecurityUser;
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.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dao.NewsDao;
import com.elink.esua.epdc.dto.NewsDTO;
import com.elink.esua.epdc.entity.NewsEntity;
import com.elink.esua.epdc.feign.AdminFeignClient;
import com.elink.esua.epdc.redis.NewsRedis;
import com.elink.esua.epdc.service.NewsDepartmentService;
import com.elink.esua.epdc.service.NewsService;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -43,12 +51,20 @@ import java.util.Map;
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-09-05
*/
@Service
public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implements NewsService {
@Autowired
private NewsRedis newsRedis;
@Autowired
private NewsDepartmentService newsDepartmentService;
@Autowired
private AdminFeignClient adminFeignClient;
@Override
public PageData<NewsDTO> page(Map<String, Object> params) {
IPage<NewsEntity> page = baseDao.selectPage(
@ -85,6 +101,15 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem
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);
@ -128,4 +153,53 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem
updateById(entity);
}
@Override
public void savePublishNews(NewsDTO newsDTO) {
NewsEntity entity = ConvertUtils.sourceToTarget(newsDTO, NewsEntity.class);
entity.setNewsUpDownState("1");
UserDetail user = SecurityUser.getUser();
entity.setCreatorName(user.getRealName());
entity.setDeptId(user.getDeptId());
entity.setDeptName(user.getDeptName());
entity.setNewsUpDownState("1");
// 通知所属部门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("您没有操作此部门的数据权限");
}
boolean isSave = true;
if (StringUtils.isNotBlank(newsDTO.getId())) {
isSave = false;
}
if (isSave) {
insert(entity);
} else {
updateById(entity);
newsDepartmentService.deleteByNewsId(entity.getId());
}
if (CollUtil.isEmpty(newsGridList)) {
Result<List<Long>> adminResult = adminFeignClient.listGridIdByDeptPid(newsDeptId);
if (!adminResult.success() || CollUtil.isEmpty(adminResult.getData())) {
throw new RenException("获取部门信息失败");
}
newsGridList = adminResult.getData();
}else {
}
this.newsDepartmentService.save(entity.getId(), newsGridList);
}
}

1
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NewsDao.xml

@ -32,6 +32,7 @@
<result property="grid" column="GRID"/>
<result property="gridId" column="GRID_ID"/>
<result property="creatorName" column="CREATOR_NAME"/>
<result property="newsReleaseState" column="NEWS_RELEASE_STATE"/>
</resultMap>
<select id="selectCountByCategoryId" resultType="int">
SELECT

22
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NewsDepartmentDao.xml

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.elink.esua.epdc.dao.NewsDepartmentDao">
<resultMap type="com.elink.esua.epdc.entity.NewsDepartmentEntity" id="newsDepartmentMap">
<result property="id" column="ID"/>
<result property="newsId" column="NEWS_ID"/>
<result property="deptId" column="DEPT_ID"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
<result property="delFlag" column="DEL_FLAG"/>
</resultMap>
<select id="deleteByNewsId">
DELETE FROM epdc_news_department WHERE NEWS_ID = #{newsId}
</select>
</mapper>
Loading…
Cancel
Save