Browse Source

提交评论接口

dev
王金鹏 6 years ago
parent
commit
aef1b98ca5
  1. 30
      esua-epdc/epdc-module/epdc-api/epdc-api-client/src/main/java/com/elink/esua/epdc/dto/CommentFormDTO.java
  2. 38
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiCommentController.java
  3. 31
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/CommentFeignClient.java
  4. 25
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/CommentFeignClientFallback.java
  5. 23
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/CommentService.java
  6. 38
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/CommentServiceImpl.java
  7. 136
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/comment/EventCommentDTO.java
  8. 57
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/controller/AppEventCommentController.java
  9. 94
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/controller/EventCommentController.java
  10. 33
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/dao/EventCommentDao.java
  11. 106
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/entity/EventCommentEntity.java
  12. 95
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/excel/EventCommentExcel.java
  13. 47
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/redis/EventCommentRedis.java
  14. 97
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/EventCommentService.java
  15. 118
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/impl/EventCommentServiceImpl.java
  16. 1
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/controller/EpdcEventsController.java
  17. 6
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/dao/EpdcEventsDao.java
  18. 5
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/service/EpdcEventsService.java
  19. 5
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/service/impl/EpdcEventsServiceImpl.java
  20. 30
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/comment/EventCommentDao.xml
  21. 6
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml

30
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.
* <p>
* https://www.renren.io
* <p>
* 版权所有侵权必究
*/
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;
}

38
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);
}
}

31
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);
}

25
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);
}
}

23
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);
}

38
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);
}
}

136
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
* <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.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;
}

57
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
* <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.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();
}
}

94
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
* <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.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<PageData<EventCommentDTO>> page(@RequestParam Map<String, Object> params){
PageData<EventCommentDTO> page = eventCommentService.page(params);
return new Result<PageData<EventCommentDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<EventCommentDTO> get(@PathVariable("id") String id){
EventCommentDTO data = eventCommentService.get(id);
return new Result<EventCommentDTO>().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<String, Object> params, HttpServletResponse response) throws Exception {
List<EventCommentDTO> list = eventCommentService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, EventCommentExcel.class);
}
}

33
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
* <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.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<EventCommentEntity> {
}

106
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
* <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.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;
}

95
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
* <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.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;
}

47
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
* <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.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;
}
}

97
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
* <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.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<EventCommentEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<EventCommentDTO>
* @author
* @date
*/
PageData<EventCommentDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<EventCommentDTO>
* @author
* @date
*/
List<EventCommentDTO> list(Map<String, Object> 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);
}

118
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
* <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.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<EventCommentDao, EventCommentEntity> implements EventCommentService {
@Autowired
private EventCommentRedis eventCommentRedis;
@Autowired
private EpdcEventsService epdcEventsService;
@Override
public PageData<EventCommentDTO> page(Map<String, Object> params) {
IPage<EventCommentEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, EventCommentDTO.class);
}
@Override
public List<EventCommentDTO> list(Map<String, Object> params) {
List<EventCommentEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, EventCommentDTO.class);
}
private QueryWrapper<EventCommentEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<EventCommentEntity> 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());
}
}

1
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 @RestController
@RequestMapping("epdcevents") @RequestMapping("epdcevents")
public class EpdcEventsController { public class EpdcEventsController {
@Autowired @Autowired
private EpdcEventsService epdcEventsService; private EpdcEventsService epdcEventsService;

6
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<EpdcEventsEntity> {
* @Date: 2019/9/7 10:07 * @Date: 2019/9/7 10:07
*/ */
long selectCountOfComments(@Param("eventId") String eventId); long selectCountOfComments(@Param("eventId") String eventId);
/**
* 修改评论数+1
*/
void updateCommentNum(String id);
} }

5
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<EpdcEventsEntity> {
* @Date: 2019/9/6 17:42 * @Date: 2019/9/6 17:42
*/ */
PageData<EpdcEventsCommentsDTO> listOfEventsCommentSByEventId(String eventId, Map<String, Object> params); PageData<EpdcEventsCommentsDTO> listOfEventsCommentSByEventId(String eventId, Map<String, Object> params);
/**
* 修改评论数+1
*/
void updateCommentNum(String id);
} }

5
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<EpdcEventsDao, EpdcEv
return issueEntity; return issueEntity;
} }
@Override
public void updateCommentNum(String id) {
baseDao.updateCommentNum(id);
}
} }

30
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/comment/EventCommentDao.xml

@ -0,0 +1,30 @@
<?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.modules.comment.dao.EventCommentDao">
<resultMap type="com.elink.esua.epdc.modules.comment.entity.EventCommentEntity" id="eventCommentMap">
<result property="id" column="ID"/>
<result property="eventId" column="EVENT_ID"/>
<result property="userId" column="USER_ID"/>
<result property="userName" column="USER_NAME"/>
<result property="userFace" column="USER_FACE"/>
<result property="content" column="CONTENT"/>
<result property="commentType" column="COMMENT_TYPE"/>
<result property="commentId" column="COMMENT_ID"/>
<result property="replyCount" column="REPLY_COUNT"/>
<result property="replyUserId" column="REPLY_USER_ID"/>
<result property="replyUserName" column="REPLY_USER_NAME"/>
<result property="replyUserFace" column="REPLY_USER_FACE"/>
<result property="likeCount" column="LIKE_COUNT"/>
<result property="unLikeCount" column="UN_LIKE_COUNT"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
</mapper>

6
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml

@ -158,4 +158,10 @@
t1.DEL_FLAG = '0' t1.DEL_FLAG = '0'
AND t1.EVENT_ID = #{eventId} AND t1.EVENT_ID = #{eventId}
</select> </select>
<update id="updateCommentNum" parameterType="java.lang.String">
UPDATE epdc_events SET COMMENT_NUM = COMMENT_NUM + 1 WHERE ID = #{id}
</update>
</mapper> </mapper>

Loading…
Cancel
Save