Browse Source

用户消息相关

dev
yujintao 7 years ago
parent
commit
238e8bfba1
  1. 34
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/async/NewsTask.java
  2. 67
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiNewsController.java
  3. 30
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/NewsFeignClient.java
  4. 10
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/NewsFeignClientFallback.java
  5. 53
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/NewsService.java
  6. 7
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java
  7. 119
      esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/InformationDTO.java
  8. 81
      esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcInformationFormDTO.java
  9. 45
      esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcReadInformationFormDTO.java
  10. 70
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/EpdcAppInformationController.java
  11. 94
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/InformationController.java
  12. 33
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/InformationDao.java
  13. 88
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/InformationEntity.java
  14. 83
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/InformationExcel.java
  15. 118
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/InformationService.java
  16. 121
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/InformationServiceImpl.java
  17. 8
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/InformationDao.xml

34
esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/async/NewsTask.java

@ -0,0 +1,34 @@
package com.elink.esua.epdc.async;
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO;
import com.elink.esua.epdc.feign.NewsFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
/**
* 新闻通知消息模块 线程任务
*
* @author yujintao
* @email yujintao@elink-cn.com
* @date 2019/9/10 10:02
*/
@Component
public class NewsTask {
@Autowired
private NewsFeignClient newsFeignClient;
/**
* 给用户发送消息
*
* @param informationDto
* @return void
* @author yujintao
* @date 2019/9/10 10:33
*/
@Async
public void insertUserInformation(EpdcInformationFormDTO informationDto) {
newsFeignClient.saveInformation(informationDto);
}
}

67
esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiNewsController.java

@ -68,64 +68,79 @@ public class ApiNewsController {
public Result<EpdcNoticeDetailResultDTO> browseNotice(@RequestBody EpdcNoticeBrowseFormDTO formDto) {
return newsService.updateReadingAmount(formDto);
}
/***
* @Description 新闻列表
* @Author qushutong
* @Date 2019/9/9 9:12
* @Param [epdcNewsFromDTO]
* @Return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.dto.epdc.result.EpdcNewsResultDTO>>
* @Description 新闻列表
* @Author qushutong
* @Date 2019/9/9 9:12
* @Param [epdcNewsFromDTO]
* @Return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < com.elink.esua.epdc.dto.epdc.result.EpdcNewsResultDTO>>
* @Exception
*
*/
@GetMapping("news/list")
public Result<List<EpdcNewsResultDTO>> listNews(@LoginUser TokenDto userDetail, EpdcNewsFromDTO epdcNewsFromDTO){
public Result<List<EpdcNewsResultDTO>> listNews(@LoginUser TokenDto userDetail, EpdcNewsFromDTO epdcNewsFromDTO) {
return newsService.listNews(userDetail,epdcNewsFromDTO);
return newsService.listNews(userDetail, epdcNewsFromDTO);
}
/***
* @Description 新闻详情
* @Author qushutong
* @Date 2019/9/7 14:13
* @Param [id]
* @Return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.epdc.result.EpdcNewsDetailResultDTO>
* @Description 新闻详情
* @Author qushutong
* @Date 2019/9/7 14:13
* @Param [id]
* @Return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.epdc.result.EpdcNewsDetailResultDTO>
* @Exception
*
*/
@GetMapping("news/detail/{newsId}")
public Result<EpdcNewsDetailResultDTO> getNewsDetail(@PathVariable("newsId") String id){
public Result<EpdcNewsDetailResultDTO> getNewsDetail(@PathVariable("newsId") String id) {
Result<EpdcNewsDetailResultDTO> newsDetail = newsService.getNewsDetail(id);
return newsDetail;
}
/***
* @Description 点赞或踩
* @Author qushutong
* @Date 2019/9/7 14:15
* @Param []
* @Return com.elink.esua.epdc.commons.tools.utils.Result
* @Description 点赞或踩
* @Author qushutong
* @Date 2019/9/7 14:15
* @Param []
* @Return com.elink.esua.epdc.commons.tools.utils.Result
* @Exception
*
*/
@PostMapping("news/statement")
public Result upDateStatement(@LoginUser TokenDto userDetail, EpdcNewsStatementFromDTO newsStatementFromDTO){
public Result upDateStatement(@LoginUser TokenDto userDetail, EpdcNewsStatementFromDTO newsStatementFromDTO) {
ValidatorUtils.validateEntity(newsStatementFromDTO);
return newsService.upDateStatement(userDetail,newsStatementFromDTO);
return newsService.upDateStatement(userDetail, newsStatementFromDTO);
}
/***
* @Description 新闻浏览
* @Author qushutong
* @Date 2019/9/7 14:47
* @Param [newsBrowseFromDTO]
* @Return com.elink.esua.epdc.commons.tools.utils.Result
* @Description 新闻浏览
* @Author qushutong
* @Date 2019/9/7 14:47
* @Param [newsBrowseFromDTO]
* @Return com.elink.esua.epdc.commons.tools.utils.Result
* @Exception
*
*/
@PostMapping("news/browse")
public Result modifyNewsBrowse(@RequestBody EpdcNewsBrowseFromDTO newsBrowseFromDTO){
public Result modifyNewsBrowse(@RequestBody EpdcNewsBrowseFromDTO newsBrowseFromDTO) {
ValidatorUtils.validateEntity(newsBrowseFromDTO);
return newsService.modifyNewsBrowse(newsBrowseFromDTO);
}
/**
* 用户消息已读
*
* @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result
* @author yujintao
* @date 2019/9/10 11:05
*/
@PostMapping("information/read")
public Result readInformation(@RequestBody EpdcReadInformationFormDTO formDto) {
ValidatorUtils.validateEntity(formDto);
return newsService.readInformation(formDto);
}
}

30
esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/NewsFeignClient.java

@ -21,7 +21,7 @@ import java.util.List;
* @email yujintao@elink-cn.com
* @date 2019/9/5 19:20
*/
@FeignClient(name = ServiceConstant.EPDC_NEWS_SERVER, fallback = NewsFeignClientFallback.class, url = "http://localhost:9064")
@FeignClient(name = ServiceConstant.EPDC_NEWS_SERVER, fallback = NewsFeignClientFallback.class)
public interface NewsFeignClient {
/**
@ -67,7 +67,7 @@ public interface NewsFeignClient {
* @Exception
*
*/
@GetMapping("news/epdc-app/news/listNews")
@GetMapping(value = "news/epdc-app/news/listNews", consumes = MediaType.APPLICATION_JSON_VALUE)
Result<List<EpdcNewsResultDTO>> listNews(@RequestBody EpdcNewsFromDTO formDto);
/***
@ -91,7 +91,7 @@ public interface NewsFeignClient {
* @Exception
*
*/
@PostMapping("news/epdc-app/news/statement")
@PostMapping(value = "news/epdc-app/news/statement", consumes = MediaType.APPLICATION_JSON_VALUE)
Result updateStatement(@RequestBody EpdcNewsStatementFromDTO newsStatementFromDTO);
/***
@ -103,6 +103,28 @@ public interface NewsFeignClient {
* @Exception
*
*/
@PostMapping("news/epdc-app/news/browse")
@PostMapping(value = "news/epdc-app/news/browse", consumes = MediaType.APPLICATION_JSON_VALUE)
Result modifyNewsBrowse(@RequestBody EpdcNewsBrowseFromDTO newsBrowseFromDTO);
/**
* 保存用户消息
*
* @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result
* @author yujintao
* @date 2019/9/10 10:44
*/
@PostMapping(value = "news/epdc-app/information/save", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
Result saveInformation(@RequestBody EpdcInformationFormDTO formDto);
/**
* 用户消息已读
*
* @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result
* @author yujintao
* @date 2019/9/10 11:05
*/
@PostMapping(value = "news/epdc-app/information/read", consumes = MediaType.APPLICATION_JSON_VALUE)
Result readInformation(@RequestBody EpdcReadInformationFormDTO formDto);
}

10
esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/NewsFeignClientFallback.java

@ -55,4 +55,14 @@ public class NewsFeignClientFallback implements NewsFeignClient {
public Result modifyNewsBrowse(EpdcNewsBrowseFromDTO newsBrowseFromDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPDC_NEWS_SERVER, "modifyNewsBrowse", newsBrowseFromDTO);
}
@Override
public Result saveInformation(EpdcInformationFormDTO formDto) {
return ModuleUtils.feignConError(ServiceConstant.EPDC_NEWS_SERVER, "saveInformation", formDto);
}
@Override
public Result readInformation(EpdcReadInformationFormDTO formDto) {
return ModuleUtils.feignConError(ServiceConstant.EPDC_NEWS_SERVER, "readInformation", formDto);
}
}

53
esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/NewsService.java

@ -62,37 +62,48 @@ public interface NewsService {
* @Exception 移动端新闻列表
*
*/
Result<List<EpdcNewsResultDTO>> listNews(TokenDto userDetail,EpdcNewsFromDTO formDto);
Result<List<EpdcNewsResultDTO>> listNews(TokenDto userDetail, EpdcNewsFromDTO formDto);
/***
* @Description 获取新闻详情
* @Author qushutong
* @Date 2019/9/9 10:16
* @Param [id]
* @Return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.epdc.result.EpdcNewsDetailResultDTO>
* @Exception
*
* @Description 获取新闻详情
* @Author qushutong
* @Date 2019/9/9 10:16
* @Param [id]
* @Return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.epdc.result.EpdcNewsDetailResultDTO>
* @Exception
*
*/
Result<EpdcNewsDetailResultDTO> getNewsDetail( String id);
Result<EpdcNewsDetailResultDTO> getNewsDetail(String id);
/***
* @Description 点赞踩
* @Author qushutong
* @Date 2019/9/9 10:17
* @Param [newsStatementFromDTO]
* @Return com.elink.esua.epdc.commons.tools.utils.Result
* @Exception
*
* @Author qushutong
* @Date 2019/9/9 10:17
* @Param [newsStatementFromDTO]
* @Return com.elink.esua.epdc.commons.tools.utils.Result
* @Exception
*
*/
Result upDateStatement(TokenDto userDetail, EpdcNewsStatementFromDTO newsStatementFromDTO);
/***
* @Description 浏览量
* @Author qushutong
* @Date 2019/9/9 10:18
* @Param [newsBrowseFromDTO]
* @Return com.elink.esua.epdc.commons.tools.utils.Result
* @Description 浏览量
* @Author qushutong
* @Date 2019/9/9 10:18
* @Param [newsBrowseFromDTO]
* @Return com.elink.esua.epdc.commons.tools.utils.Result
* @Exception
*
*/
Result modifyNewsBrowse( EpdcNewsBrowseFromDTO newsBrowseFromDTO);
Result modifyNewsBrowse(EpdcNewsBrowseFromDTO newsBrowseFromDTO);
/**
* 用户消息已读
*
* @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result
* @author yujintao
* @date 2019/9/10 11:05
*/
Result readInformation(EpdcReadInformationFormDTO formDto);
}

7
esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java

@ -44,7 +44,7 @@ public class NewsServiceImpl implements NewsService {
}
@Override
public Result<List<EpdcNewsResultDTO>> listNews(TokenDto userDetail,EpdcNewsFromDTO formDto) {
public Result<List<EpdcNewsResultDTO>> listNews(TokenDto userDetail, EpdcNewsFromDTO formDto) {
formDto.setDeptId(userDetail.getGridId());
return newsFeignClient.listNews(formDto);
@ -66,4 +66,9 @@ public class NewsServiceImpl implements NewsService {
public Result modifyNewsBrowse(EpdcNewsBrowseFromDTO newsBrowseFromDTO) {
return newsFeignClient.modifyNewsBrowse(newsBrowseFromDTO);
}
@Override
public Result readInformation(EpdcReadInformationFormDTO formDto) {
return newsFeignClient.readInformation(formDto);
}
}

119
esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/InformationDTO.java

@ -0,0 +1,119 @@
/**
* 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 yujintao yujintao@elink-cn.com
* @since v1.0.0 2019-09-10
*/
@Data
public class InformationDTO implements Serializable {
private static final long serialVersionUID = -3082151640037703859L;
/**
* 主键
*/
private String id;
/**
* 消息内容
*/
private String content;
/**
* 标题
*/
private String title;
/**
* 时间
*/
private Date time;
/**
* AppInformationEnum
* 我的消息类型0审核通知1互动通知2进度通知3社群通知
*/
private String type;
/**
* 用户ID
*/
private String userId;
/**
* AppInformationBusinessEnum
* 消息所属业务类型comment事件评论reply评论回复issue议题处理crowd社群邀请等
*/
private String businessType;
/**
* 消息所属业务ID
*/
private String businessId;
/**
* 消息关联业务内容被回复的评论被评论的议题等
*/
private String relBusinessContent;
/**
* 是否已读0否1是
*/
private String readFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
/**
* 删除标记
*/
private String delFlag;
}

81
esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcInformationFormDTO.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.epdc.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 我的消息
*
* @author yujintao yujintao@elink-cn.com
* @since v1.0.0 2019-09-10
*/
@Data
public class EpdcInformationFormDTO implements Serializable {
private static final long serialVersionUID = -3286304817997007892L;
/**
* 用户ID
*/
@NotBlank(message = "用户ID不能为空")
private String userId;
/**
* 消息内容
*/
@NotBlank(message = "消息内容不能为空")
private String content;
/**
* 标题
*/
@NotBlank(message = "标题不能为空")
private String title;
/**
* AppInformationEnum
* 我的消息类型0审核通知1互动通知2进度通知3社群通知
*/
@NotBlank(message = "消息类型不能为空")
private String type;
/**
* AppInformationBusinessEnum
* 消息所属业务类型comment事件评论reply评论回复issue议题处理crowd社群邀请等
*/
@NotBlank(message = "消息所属业务类型不能为空")
private String businessType;
/**
* 消息所属业务ID
*/
@NotBlank(message = "消息所属业务ID不能为空")
private String businessId;
/**
* 消息关联业务内容被回复的评论被评论的议题等
*/
@NotBlank(message = "消息关联业务内容不能为空")
private String relBusinessContent;
}

45
esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcReadInformationFormDTO.java

@ -0,0 +1,45 @@
/**
* 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.epdc.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 我的消息
*
* @author yujintao yujintao@elink-cn.com
* @since v1.0.0 2019-09-10
*/
@Data
public class EpdcReadInformationFormDTO implements Serializable {
private static final long serialVersionUID = -1161009882229533832L;
/**
* 消息ID
*/
@NotBlank(message = "消息ID不能为空")
private String informationId;
}

70
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/EpdcAppInformationController.java

@ -0,0 +1,70 @@
/**
* 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.constant.Constant;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils;
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO;
import com.elink.esua.epdc.dto.epdc.form.EpdcReadInformationFormDTO;
import com.elink.esua.epdc.service.InformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* 我的消息
*
* @author yujintao yujintao@elink-cn.com
* @since v1.0.0 2019-09-10
*/
@RestController
@RequestMapping(Constant.EPDC_APP + "information")
public class EpdcAppInformationController {
@Autowired
private InformationService informationService;
/**
* 给用户发送消息
*
* @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result
* @author yujintao
* @date 2019/9/10 10:37
*/
@PostMapping("save")
public Result saveInformation(@RequestBody EpdcInformationFormDTO formDto) {
ValidatorUtils.validateEntity(formDto);
return this.informationService.saveInformation(formDto);
}
/**
* 消息已读
*
* @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result
* @author yujintao
* @date 2019/9/10 11:01
*/
@PostMapping("read")
public Result readInformation(@RequestBody EpdcReadInformationFormDTO formDto) {
ValidatorUtils.validateEntity(formDto);
return this.informationService.readInformation(formDto);
}
}

94
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/InformationController.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.InformationDTO;
import com.elink.esua.epdc.excel.InformationExcel;
import com.elink.esua.epdc.service.InformationService;
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 yujintao yujintao@elink-cn.com
* @since v1.0.0 2019-09-10
*/
@RestController
@RequestMapping("information")
public class InformationController {
@Autowired
private InformationService informationService;
@GetMapping("page")
public Result<PageData<InformationDTO>> page(@RequestParam Map<String, Object> params){
PageData<InformationDTO> page = informationService.page(params);
return new Result<PageData<InformationDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<InformationDTO> get(@PathVariable("id") String id){
InformationDTO data = informationService.get(id);
return new Result<InformationDTO>().ok(data);
}
@PostMapping
public Result save(@RequestBody InformationDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
informationService.save(dto);
return new Result();
}
@PutMapping
public Result update(@RequestBody InformationDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
informationService.update(dto);
return new Result();
}
@DeleteMapping
public Result delete(@RequestBody String[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
informationService.delete(ids);
return new Result();
}
@GetMapping("export")
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<InformationDTO> list = informationService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, InformationExcel.class);
}
}

33
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/InformationDao.java

@ -0,0 +1,33 @@
/**
* 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.InformationEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 我的消息
*
* @author yujintao yujintao@elink-cn.com
* @since v1.0.0 2019-09-10
*/
@Mapper
public interface InformationDao extends BaseDao<InformationEntity> {
}

88
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/InformationEntity.java

@ -0,0 +1,88 @@
/**
* 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 yujintao yujintao@elink-cn.com
* @since v1.0.0 2019-09-10
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("epdc_information")
public class InformationEntity extends BaseEpdcEntity {
private static final long serialVersionUID = -7194968067103853454L;
/**
* 消息内容
*/
private String content;
/**
* 标题
*/
private String title;
/**
* 时间
*/
private Date time;
/**
* AppInformationEnum
* 我的消息类型0审核通知1互动通知2进度通知3社群通知
*/
private String type;
/**
* 用户ID
*/
private String userId;
/**
* AppInformationBusinessEnum
* 消息所属业务类型comment事件评论reply评论回复issue议题处理crowd社群邀请等
*/
private String businessType;
/**
* 消息所属业务ID
*/
private String businessId;
/**
* 消息关联业务内容被回复的评论被评论的议题等
*/
private String relBusinessContent;
/**
* 是否已读0否1是
*/
private String readFlag;
}

83
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/InformationExcel.java

@ -0,0 +1,83 @@
/**
* 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 yujintao yujintao@elink-cn.com
* @since v1.0.0 2019-09-10
*/
@Data
public class InformationExcel {
@Excel(name = "主键")
private String id;
@Excel(name = "消息内容")
private String content;
@Excel(name = "标题")
private String title;
@Excel(name = "时间")
private Date time;
@Excel(name = "我的消息类型:0审核通知;1互动通知;2进度通知;3社群通知")
private String type;
@Excel(name = "用户ID")
private String userId;
@Excel(name = "消息所属业务类型:comment事件评论;reply评论回复;issue议题处理;crowd社群邀请等")
private String businessType;
@Excel(name = "消息所属业务ID")
private String businessId;
@Excel(name = "消息关联业务内容(被回复的评论;被评论的议题等)")
private String relBusinessContent;
@Excel(name = "是否已读:0否;1是")
private String readFlag;
@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;
}

118
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/InformationService.java

@ -0,0 +1,118 @@
/**
* 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.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.InformationDTO;
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO;
import com.elink.esua.epdc.dto.epdc.form.EpdcReadInformationFormDTO;
import com.elink.esua.epdc.entity.InformationEntity;
import java.util.List;
import java.util.Map;
/**
* 我的消息
*
* @author yujintao yujintao@elink-cn.com
* @since v1.0.0 2019-09-10
*/
public interface InformationService extends BaseService<InformationEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<InformationDTO>
* @author
* @date
*/
PageData<InformationDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<InformationDTO>
* @author
* @date
*/
List<InformationDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return InformationDTO
* @author
* @date
*/
InformationDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author
* @date
*/
void save(InformationDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author
* @date
*/
void update(InformationDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author
* @date
*/
void delete(String[] ids);
/**
* 给用户发送消息
*
* @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result
* @author yujintao
* @date 2019/9/10 10:38
*/
Result saveInformation(EpdcInformationFormDTO formDto);
/**
* 消息已读
*
* @param formDto
* @return com.elink.esua.epdc.commons.tools.utils.Result
* @author yujintao
* @date 2019/9/10 11:00
*/
Result readInformation(EpdcReadInformationFormDTO formDto);
}

121
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/InformationServiceImpl.java

@ -0,0 +1,121 @@
/**
* 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 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.enums.YesOrNoEnum;
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.commons.tools.utils.Result;
import com.elink.esua.epdc.dao.InformationDao;
import com.elink.esua.epdc.dto.InformationDTO;
import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO;
import com.elink.esua.epdc.dto.epdc.form.EpdcReadInformationFormDTO;
import com.elink.esua.epdc.entity.InformationEntity;
import com.elink.esua.epdc.service.InformationService;
import org.apache.commons.lang3.StringUtils;
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;
/**
* 我的消息
*
* @author yujintao yujintao@elink-cn.com
* @since v1.0.0 2019-09-10
*/
@Service
public class InformationServiceImpl extends BaseServiceImpl<InformationDao, InformationEntity> implements InformationService {
@Override
public PageData<InformationDTO> page(Map<String, Object> params) {
IPage<InformationEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, InformationDTO.class);
}
@Override
public List<InformationDTO> list(Map<String, Object> params) {
List<InformationEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, InformationDTO.class);
}
private QueryWrapper<InformationEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<InformationEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public InformationDTO get(String id) {
InformationEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, InformationDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(InformationDTO dto) {
InformationEntity entity = ConvertUtils.sourceToTarget(dto, InformationEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(InformationDTO dto) {
InformationEntity entity = ConvertUtils.sourceToTarget(dto, InformationEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Override
public Result saveInformation(EpdcInformationFormDTO formDto) {
InformationEntity entity = ConvertUtils.sourceToTarget(formDto, InformationEntity.class);
entity.setReadFlag(YesOrNoEnum.NO.value());
entity.setTime(new Date());
this.insert(entity);
return new Result();
}
@Override
public Result readInformation(EpdcReadInformationFormDTO formDto) {
InformationEntity entity = new InformationEntity();
entity.setId(formDto.getInformationId());
entity.setReadFlag(YesOrNoEnum.YES.value());
this.updateById(entity);
return new Result();
}
}

8
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/InformationDao.xml

@ -0,0 +1,8 @@
<?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.InformationDao">
</mapper>
Loading…
Cancel
Save