diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/CommentFormDTO.java b/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/CommentFormDTO.java new file mode 100644 index 000000000..101f14927 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/CommentFormDTO.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + *

+ * https://www.renren.io + *

+ * 版权所有,侵权必究! + */ + +package com.elink.esua.epdc.dto; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * 评论议题、提交评论 + * + */ +@Data +public class CommentFormDTO { + + @NotBlank(message = "议题id不能为空") + private String issueId; + + private String faCommentId; + + @NotBlank(message = "评论内容不能为空") + private String content; + +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiCommentController.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiCommentController.java new file mode 100644 index 000000000..382cc5322 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiCommentController.java @@ -0,0 +1,38 @@ +package com.elink.esua.epdc.controller; + +import com.elink.esua.epdc.common.token.dto.TokenDto; +import com.elink.esua.epdc.commons.tools.annotation.LoginUser; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.CommentFormDTO; +import com.elink.esua.epdc.service.CommentService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 移动端接口-评论模块 + * @Author WJP + * @Date 2019/9/9 09:45 + */ +@RestController +@RequestMapping("events/comment") +public class ApiCommentController { + + @Autowired + private CommentService commentService; + + /** + * + * @param userDetail + * @param commentFormDTO + * @return + */ + @PostMapping("submit") + public Result submit(@LoginUser TokenDto userDetail, CommentFormDTO commentFormDTO) { + return commentService.submit(userDetail,commentFormDTO); + } + + + +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/CommentFeignClient.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/CommentFeignClient.java new file mode 100644 index 000000000..cbacc8af9 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/CommentFeignClient.java @@ -0,0 +1,31 @@ +package com.elink.esua.epdc.feign; + +import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.comment.EventCommentDTO; +import com.elink.esua.epdc.dto.events.form.EpdcEventSubmitFormDTO; +import com.elink.esua.epdc.dto.issue.form.IssueFormDTO; +import com.elink.esua.epdc.dto.issue.result.IssueResultDTO; +import com.elink.esua.epdc.feign.fallback.CommentFeignClientFallback; +import com.elink.esua.epdc.feign.fallback.IssueFeignClientFallback; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; + +import java.util.List; + +/** + * 议题模块调用 + * @Author LC + * @Date 2019/9/7 11:34 + */ +@FeignClient(name = ServiceConstant.EPDC_EVENTS_SERVER, fallback = CommentFeignClientFallback.class) +public interface CommentFeignClient { + + + @PostMapping(value = "events/epdc-app/comment/submit", consumes = MediaType.APPLICATION_JSON_VALUE) + Result submit(EventCommentDTO eventCommentDTO); + + +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/CommentFeignClientFallback.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/CommentFeignClientFallback.java new file mode 100644 index 000000000..9d9187ded --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/CommentFeignClientFallback.java @@ -0,0 +1,25 @@ +package com.elink.esua.epdc.feign.fallback; + +import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; +import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.comment.EventCommentDTO; +import com.elink.esua.epdc.dto.events.form.EpdcEventSubmitFormDTO; +import com.elink.esua.epdc.dto.issue.form.IssueFormDTO; +import com.elink.esua.epdc.dto.issue.result.IssueResultDTO; +import com.elink.esua.epdc.feign.CommentFeignClient; +import com.elink.esua.epdc.feign.IssueFeignClient; +import org.springframework.stereotype.Component; + +import java.util.List; + + +@Component +public class CommentFeignClientFallback implements CommentFeignClient { + + @Override + public Result submit(EventCommentDTO eventCommentDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPDC_EVENTS_SERVER, "submit", eventCommentDTO); + } + +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/CommentService.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/CommentService.java new file mode 100644 index 000000000..2e815bc87 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/CommentService.java @@ -0,0 +1,23 @@ +package com.elink.esua.epdc.service; + +import com.elink.esua.epdc.common.token.dto.TokenDto; +import com.elink.esua.epdc.commons.tools.annotation.LoginUser; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.CommentFormDTO; +import com.elink.esua.epdc.dto.UploadDTO; +import com.elink.esua.epdc.dto.events.form.EpdcEventSubmitFormDTO; +import com.elink.esua.epdc.dto.issue.form.IssueFormDTO; +import com.elink.esua.epdc.dto.issue.result.IssueResultDTO; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +/** + * 移动端接口-评论模块 + * @Author WJP + * @Date 2019/9/9 09:45 + */ +public interface CommentService { + + Result submit(@LoginUser TokenDto userDetail, CommentFormDTO commentFormDTO); +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/CommentServiceImpl.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/CommentServiceImpl.java new file mode 100644 index 000000000..01ac4eda1 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/CommentServiceImpl.java @@ -0,0 +1,38 @@ +package com.elink.esua.epdc.service.impl; + + +import com.elink.esua.epdc.common.token.dto.TokenDto; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.CommentFormDTO; +import com.elink.esua.epdc.dto.comment.EventCommentDTO; +import com.elink.esua.epdc.feign.CommentFeignClient; +import com.elink.esua.epdc.service.CommentService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 移动端接口-评论模块 + * @Author WJP + * @Date 2019/9/9 09:45 + */ +@Service +public class CommentServiceImpl implements CommentService { + + @Autowired + private CommentFeignClient commentFeignClient; + + @Override + public Result submit(TokenDto userDetail, CommentFormDTO commentFormDTO) { + EventCommentDTO eventCommentDTO = new EventCommentDTO(); + eventCommentDTO.setEventId(commentFormDTO.getIssueId()); + eventCommentDTO.setUserId(userDetail.getUserId()); + eventCommentDTO.setContent(commentFormDTO.getContent()); + eventCommentDTO.setCommentId(commentFormDTO.getFaCommentId()); + if (commentFormDTO.getFaCommentId().length() != 0){ + eventCommentDTO.setCommentType("1"); + }else { + eventCommentDTO.setCommentType("0"); + } + return commentFeignClient.submit(eventCommentDTO); + } +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/comment/EventCommentDTO.java b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/comment/EventCommentDTO.java new file mode 100755 index 000000000..4bd63d187 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/comment/EventCommentDTO.java @@ -0,0 +1,136 @@ +/** + * 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.comment; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 事件评论表 事件评论表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-09-09 + */ +@Data +public class EventCommentDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * ID + */ + private String id; + + /** + * 事件ID + */ + private String eventId; + + /** + * 评论人ID + */ + private String userId; + + /** + * 评论人昵称 + */ + private String userName; + + /** + * 评论人头像 + */ + private String userFace; + + /** + * 评论内容 + */ + private String content; + + /** + * 评论类型 0:评论,1:回复,2:回复的回复 + */ + private String commentType; + + /** + * 回复的评论ID + */ + private String commentId; + + /** + * 被回复数 + */ + private Integer replyCount; + + /** + * 被回复人ID + */ + private String replyUserId; + + /** + * 被回复人名称 + */ + private String replyUserName; + + /** + * 被回复人头像 + */ + private String replyUserFace; + + /** + * 点赞数 + */ + private Integer likeCount; + + /** + * 点踩数 + */ + private Integer unLikeCount; + + /** + * 删除标识 0:未删除,1:已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/controller/AppEventCommentController.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/controller/AppEventCommentController.java new file mode 100755 index 000000000..184b5c74d --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/controller/AppEventCommentController.java @@ -0,0 +1,57 @@ +/** + * 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.modules.comment.controller; + +import com.elink.esua.epdc.commons.tools.constant.Constant; +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.comment.EventCommentDTO; +import com.elink.esua.epdc.modules.comment.excel.EventCommentExcel; +import com.elink.esua.epdc.modules.comment.service.EventCommentService; +import com.elink.esua.epdc.modules.events.service.EpdcEventsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +@RestController +@RequestMapping(Constant.EPDC_APP + "comment") +public class AppEventCommentController { + + @Autowired + private EventCommentService eventCommentService; + + + @PostMapping("submit") + public Result submit(@RequestBody EventCommentDTO dto){ + eventCommentService.submit(dto); + return new Result(); + } + + +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/controller/EventCommentController.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/controller/EventCommentController.java new file mode 100755 index 000000000..c2da1982d --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/controller/EventCommentController.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.modules.comment.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.comment.EventCommentDTO; +import com.elink.esua.epdc.modules.comment.excel.EventCommentExcel; +import com.elink.esua.epdc.modules.comment.service.EventCommentService; +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-09 + */ +@RestController +@RequestMapping("eventcomment") +public class EventCommentController { + + @Autowired + private EventCommentService eventCommentService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = eventCommentService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + EventCommentDTO data = eventCommentService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody EventCommentDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + eventCommentService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody EventCommentDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + eventCommentService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + eventCommentService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = eventCommentService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, EventCommentExcel.class); + } + +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/dao/EventCommentDao.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/dao/EventCommentDao.java new file mode 100755 index 000000000..bc4836f7e --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/dao/EventCommentDao.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.modules.comment.dao; + +import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.modules.comment.entity.EventCommentEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 事件评论表 事件评论表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-09-09 + */ +@Mapper +public interface EventCommentDao extends BaseDao { + +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/entity/EventCommentEntity.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/entity/EventCommentEntity.java new file mode 100755 index 000000000..a976b60f0 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/entity/EventCommentEntity.java @@ -0,0 +1,106 @@ +/** + * 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.modules.comment.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-09 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("epdc_event_comment") +public class EventCommentEntity extends BaseEpdcEntity { + + private static final long serialVersionUID = 1L; + + /** + * 事件ID + */ + private String eventId; + + /** + * 评论人ID + */ + private String userId; + + /** + * 评论人昵称 + */ + private String userName; + + /** + * 评论人头像 + */ + private String userFace; + + /** + * 评论内容 + */ + private String content; + + /** + * 评论类型 0:评论,1:回复,2:回复的回复 + */ + private String commentType; + + /** + * 回复的评论ID + */ + private String commentId; + + /** + * 被回复数 + */ + private Integer replyCount; + + /** + * 被回复人ID + */ + private String replyUserId; + + /** + * 被回复人名称 + */ + private String replyUserName; + + /** + * 被回复人头像 + */ + private String replyUserFace; + + /** + * 点赞数 + */ + private Integer likeCount; + + /** + * 点踩数 + */ + private Integer unLikeCount; + +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/excel/EventCommentExcel.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/excel/EventCommentExcel.java new file mode 100755 index 000000000..4be0bd5f1 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/excel/EventCommentExcel.java @@ -0,0 +1,95 @@ +/** + * 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.modules.comment.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-09 + */ +@Data +public class EventCommentExcel { + + @Excel(name = "ID") + private String id; + + @Excel(name = "事件ID") + private String eventId; + + @Excel(name = "评论人ID") + private String userId; + + @Excel(name = "评论人昵称") + private String userName; + + @Excel(name = "评论人头像") + private String userFace; + + @Excel(name = "评论内容") + private String content; + + @Excel(name = "评论类型 0:评论,1:回复,2:回复的回复") + private String commentType; + + @Excel(name = "回复的评论ID") + private String commentId; + + @Excel(name = "被回复数") + private Integer replyCount; + + @Excel(name = "被回复人ID") + private String replyUserId; + + @Excel(name = "被回复人名称") + private String replyUserName; + + @Excel(name = "被回复人头像") + private String replyUserFace; + + @Excel(name = "点赞数") + private Integer likeCount; + + @Excel(name = "点踩数") + private Integer unLikeCount; + + @Excel(name = "删除标识 0:未删除,1:已删除") + private String delFlag; + + @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; + + +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/redis/EventCommentRedis.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/redis/EventCommentRedis.java new file mode 100755 index 000000000..5af1edc2b --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/redis/EventCommentRedis.java @@ -0,0 +1,47 @@ +/** + * 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.modules.comment.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-09 + */ +@Component +public class EventCommentRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/EventCommentService.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/EventCommentService.java new file mode 100755 index 000000000..d6ed147e7 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/EventCommentService.java @@ -0,0 +1,97 @@ +/** + * 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.modules.comment.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.comment.EventCommentDTO; +import com.elink.esua.epdc.modules.comment.entity.EventCommentEntity; + +import java.util.List; +import java.util.Map; + +/** + * 事件评论表 事件评论表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-09-09 + */ +public interface EventCommentService 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 EventCommentDTO + * @author + * @date + */ + EventCommentDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author + * @date + */ + void save(EventCommentDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author + * @date + */ + void update(EventCommentDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author + * @date + */ + void delete(String[] ids); + + void submit(EventCommentDTO dto); +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/impl/EventCommentServiceImpl.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/impl/EventCommentServiceImpl.java new file mode 100755 index 000000000..941e7cb6c --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/impl/EventCommentServiceImpl.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.modules.comment.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.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.dto.comment.EventCommentDTO; +import com.elink.esua.epdc.modules.comment.dao.EventCommentDao; +import com.elink.esua.epdc.modules.comment.entity.EventCommentEntity; +import com.elink.esua.epdc.modules.comment.redis.EventCommentRedis; +import com.elink.esua.epdc.modules.comment.service.EventCommentService; +import com.elink.esua.epdc.modules.events.service.EpdcEventsService; +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.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 事件评论表 事件评论表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-09-09 + */ +@Service +public class EventCommentServiceImpl extends BaseServiceImpl implements EventCommentService { + + @Autowired + private EventCommentRedis eventCommentRedis; + + @Autowired + private EpdcEventsService epdcEventsService; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, EventCommentDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, EventCommentDTO.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 EventCommentDTO get(String id) { + EventCommentEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, EventCommentDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(EventCommentDTO dto) { + EventCommentEntity entity = ConvertUtils.sourceToTarget(dto, EventCommentEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(EventCommentDTO dto) { + EventCommentEntity entity = ConvertUtils.sourceToTarget(dto, EventCommentEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + @Transactional + public void submit(EventCommentDTO dto) { + + //插入评论或回复 + this.save(dto); + + //评论和回复都加1 + epdcEventsService.updateCommentNum(dto.getEventId()); + } +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/controller/EpdcEventsController.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/controller/EpdcEventsController.java index 37efc15e8..f894a5e30 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/controller/EpdcEventsController.java +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/controller/EpdcEventsController.java @@ -50,6 +50,7 @@ import java.util.Map; @RestController @RequestMapping("epdcevents") public class EpdcEventsController { + @Autowired private EpdcEventsService epdcEventsService; diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/dao/EpdcEventsDao.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/dao/EpdcEventsDao.java index 6a291fd0b..7a29c039d 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/dao/EpdcEventsDao.java +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/dao/EpdcEventsDao.java @@ -83,4 +83,10 @@ public interface EpdcEventsDao extends BaseDao { * @Date: 2019/9/7 10:07 */ long selectCountOfComments(@Param("eventId") String eventId); + + + /** + * 修改评论数+1 + */ + void updateCommentNum(String id); } diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/service/EpdcEventsService.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/service/EpdcEventsService.java index 56ada1d24..392e52096 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/service/EpdcEventsService.java +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/service/EpdcEventsService.java @@ -106,4 +106,9 @@ public interface EpdcEventsService extends BaseService { * @Date: 2019/9/6 17:42 */ PageData listOfEventsCommentSByEventId(String eventId, Map params); + + /** + * 修改评论数+1 + */ + void updateCommentNum(String id); } diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/service/impl/EpdcEventsServiceImpl.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/service/impl/EpdcEventsServiceImpl.java index ae43f50eb..32b83e073 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/service/impl/EpdcEventsServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/service/impl/EpdcEventsServiceImpl.java @@ -216,4 +216,9 @@ public class EpdcEventsServiceImpl extends BaseServiceImpl + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml index 2bbfdb06c..1c85bec76 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml @@ -158,4 +158,10 @@ t1.DEL_FLAG = '0' AND t1.EVENT_ID = #{eventId} + + + + UPDATE epdc_events SET COMMENT_NUM = COMMENT_NUM + 1 WHERE ID = #{id} + +