diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/async/NewsTask.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/async/NewsTask.java new file mode 100644 index 000000000..e7ad9b0fe --- /dev/null +++ b/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); + } +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiNewsController.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiNewsController.java index 847e95297..0854051cf 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiNewsController.java +++ b/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 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> + * @Description 新闻列表 + * @Author qushutong + * @Date 2019/9/9 9:12 + * @Param [epdcNewsFromDTO] + * @Return com.elink.esua.epdc.commons.tools.utils.Result> * @Exception * */ @GetMapping("news/list") - public Result> listNews(@LoginUser TokenDto userDetail, EpdcNewsFromDTO epdcNewsFromDTO){ + public Result> 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 + * @Description 新闻详情 + * @Author qushutong + * @Date 2019/9/7 14:13 + * @Param [id] + * @Return com.elink.esua.epdc.commons.tools.utils.Result * @Exception * */ @GetMapping("news/detail/{newsId}") - public Result getNewsDetail(@PathVariable("newsId") String id){ + public Result getNewsDetail(@PathVariable("newsId") String id) { Result 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); + } } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/NewsFeignClient.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/NewsFeignClient.java index 1d8305aa3..4c4f22298 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/NewsFeignClient.java +++ b/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> 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); } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/NewsFeignClientFallback.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/NewsFeignClientFallback.java index 5717b71ac..cffb9a7f4 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/NewsFeignClientFallback.java +++ b/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); + } } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/NewsService.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/NewsService.java index 5733318a4..1f6b331b3 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/NewsService.java +++ b/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> listNews(TokenDto userDetail,EpdcNewsFromDTO formDto); + Result> 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 - * @Exception - * + * @Description 获取新闻详情 + * @Author qushutong + * @Date 2019/9/9 10:16 + * @Param [id] + * @Return com.elink.esua.epdc.commons.tools.utils.Result + * @Exception + * */ - Result getNewsDetail( String id); + Result 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); } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java index b3ac7d128..0ec3b3aa9 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java +++ b/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> listNews(TokenDto userDetail,EpdcNewsFromDTO formDto) { + public Result> 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); + } } diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/InformationDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/InformationDTO.java new file mode 100644 index 000000000..cd40f8a07 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcInformationFormDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcInformationFormDTO.java new file mode 100644 index 000000000..7457a79c6 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcReadInformationFormDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcReadInformationFormDTO.java new file mode 100644 index 000000000..f5d902070 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + + + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/EpdcAppInformationController.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/EpdcAppInformationController.java new file mode 100644 index 000000000..89e8c600e --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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); + } +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/InformationController.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/InformationController.java new file mode 100644 index 000000000..c89df4fd6 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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> page(@RequestParam Map params){ + PageData page = informationService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + InformationDTO data = informationService.get(id); + return new Result().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 params, HttpServletResponse response) throws Exception { + List list = informationService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, InformationExcel.class); + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/InformationDao.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/InformationDao.java new file mode 100644 index 000000000..91307e711 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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 { + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/InformationEntity.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/InformationEntity.java new file mode 100644 index 000000000..f3c707d5e --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/InformationExcel.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/InformationExcel.java new file mode 100644 index 000000000..6be222106 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/InformationService.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/InformationService.java new file mode 100644 index 000000000..c73ffa4ee --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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 { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author + * @date + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author + * @date + */ + List list(Map 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); +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/InformationServiceImpl.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/InformationServiceImpl.java new file mode 100644 index 000000000..94f2bc1b1 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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 implements InformationService { + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, InformationDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, InformationDTO.class); + } + + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); + + QueryWrapper 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(); + } +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/InformationDao.xml b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/InformationDao.xml new file mode 100644 index 000000000..920e06e00 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/InformationDao.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file