From 866f97d8ed7fc983e6d37ac6104e196d19100631 Mon Sep 17 00:00:00 2001 From: liuchuang Date: Wed, 6 Nov 2019 16:27:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E8=AF=9D=E9=A2=98=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epdc/controller/ApiTopicController.java | 43 ++++++ .../esua/epdc/feign/TopicFeignClient.java | 32 +++++ .../fallback/TopicFeignClientFallback.java | 21 +++ .../elink/esua/epdc/service/TopicService.java | 26 ++++ .../epdc/service/impl/TopicServiceImpl.java | 56 ++++++++ .../dto/constant/TopicImageConstant.java | 16 +++ .../dto/enums/GroupStateEnum.java | 3 + .../dto/enums/TopicStateEnum.java | 56 ++++++++ .../dto/topic/TopicDTO.java | 4 +- .../dto/topic/TopicImgDTO.java | 86 ++++++++++++ .../dto/topic/form/TopicSubmitFormDTO.java | 126 ++++++++++++++++++ .../topic/controller/AppTopicController.java | 40 ++++++ .../modules/topic/dao/TopicImgDao.java | 33 +++++ .../modules/topic/entity/TopicImgEntity.java | 56 ++++++++ .../topic/service/TopicImgService.java | 106 +++++++++++++++ .../modules/topic/service/TopicService.java | 13 ++ .../service/impl/TopicImgServiceImpl.java | 119 +++++++++++++++++ .../topic/service/impl/TopicServiceImpl.java | 19 ++- 18 files changed, 851 insertions(+), 4 deletions(-) create mode 100644 esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiTopicController.java create mode 100644 esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/TopicFeignClient.java create mode 100644 esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/TopicFeignClientFallback.java create mode 100644 esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/TopicService.java create mode 100644 esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/TopicServiceImpl.java create mode 100644 esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/constant/TopicImageConstant.java create mode 100644 esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/enums/TopicStateEnum.java create mode 100644 esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/TopicImgDTO.java create mode 100644 esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/form/TopicSubmitFormDTO.java create mode 100644 esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/controller/AppTopicController.java create mode 100644 esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/dao/TopicImgDao.java create mode 100644 esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/entity/TopicImgEntity.java create mode 100644 esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/TopicImgService.java create mode 100644 esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/impl/TopicImgServiceImpl.java diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiTopicController.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiTopicController.java new file mode 100644 index 000000000..23869a8b3 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiTopicController.java @@ -0,0 +1,43 @@ +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.commons.tools.validator.ValidatorUtils; +import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; +import com.elink.esua.epdc.service.TopicService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * + * 移动端接口-话题模块 + * + * @Author:liuchuang + * @Date:2019/11/6 14:44 + */ +@RestController +@RequestMapping("group/topic") +public class ApiTopicController { + + @Autowired + private TopicService topicService; + + /** + * + * 发布话题 + * + * @params [userDetail, formDto] + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author liuchuang + * @since 2019/11/6 14:46 + */ + @PostMapping("submit") + public Result submit(@LoginUser TokenDto userDetail, @RequestBody TopicSubmitFormDTO formDto) { + ValidatorUtils.validateEntity(formDto); + return topicService.saveTopic(userDetail, formDto); + } +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/TopicFeignClient.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/TopicFeignClient.java new file mode 100644 index 000000000..22a620349 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/TopicFeignClient.java @@ -0,0 +1,32 @@ +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.topic.form.TopicSubmitFormDTO; +import com.elink.esua.epdc.feign.fallback.TopicFeignClientFallback; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; + +/** + * + * 社群-话题模块调用 + * + * @Author:liuchuang + * @Date:2019/11/6 15:36 + */ +@FeignClient(name = ServiceConstant.EPDC_GROUP_SERVER, fallback = TopicFeignClientFallback.class) +public interface TopicFeignClient { + + /** + * + * 发布话题 + * + * @params [formDto] + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author liuchuang + * @since 2019/11/6 15:40 + */ + @PostMapping(value = "group/epdc-app/topic/submit", consumes = MediaType.APPLICATION_JSON_VALUE) + Result submit(TopicSubmitFormDTO formDto); +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/TopicFeignClientFallback.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/TopicFeignClientFallback.java new file mode 100644 index 000000000..0301eec04 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/TopicFeignClientFallback.java @@ -0,0 +1,21 @@ +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.topic.form.TopicSubmitFormDTO; +import com.elink.esua.epdc.feign.TopicFeignClient; +import org.springframework.stereotype.Component; + +/** + * @Author:liuchuang + * @Date:2019/11/6 15:36 + */ +@Component +public class TopicFeignClientFallback implements TopicFeignClient { + + @Override + public Result submit(TopicSubmitFormDTO formDto) { + return ModuleUtils.feignConError(ServiceConstant.EPDC_GROUP_SERVER, "submit", formDto); + } +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/TopicService.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/TopicService.java new file mode 100644 index 000000000..a7e19c453 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/TopicService.java @@ -0,0 +1,26 @@ +package com.elink.esua.epdc.service; + +import com.elink.esua.epdc.common.token.dto.TokenDto; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; + +/** + * + * 话题模块 + * + * @Author:liuchuang + * @Date:2019/11/6 14:48 + */ +public interface TopicService { + + /** + * + * 发布话题 + * + * @params [userDetail, formDto] + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author liuchuang + * @since 2019/11/6 14:51 + */ + Result saveTopic(TokenDto userDetail, TopicSubmitFormDTO formDto); +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/TopicServiceImpl.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/TopicServiceImpl.java new file mode 100644 index 000000000..e2e4efe77 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/TopicServiceImpl.java @@ -0,0 +1,56 @@ +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.CompleteDeptDTO; +import com.elink.esua.epdc.dto.enums.TopicStateEnum; +import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; +import com.elink.esua.epdc.feign.AdminFeignClient; +import com.elink.esua.epdc.feign.TopicFeignClient; +import com.elink.esua.epdc.service.TopicService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * + * 话题模块 + * + * @Author:liuchuang + * @Date:2019/11/6 14:48 + */ +@Service +public class TopicServiceImpl implements TopicService { + + @Autowired + private AdminFeignClient adminFeignClient; + + @Autowired + private TopicFeignClient topicFeignClient; + + @Override + public Result saveTopic(TokenDto userDetail, TopicSubmitFormDTO formDto) { + if (null == userDetail) { + return new Result().error("获取用户信息失败"); + } + + // 获取该网格所有上级机构 + Result deptDTOResult = adminFeignClient.getCompleteDept(userDetail.getGridId()); + CompleteDeptDTO deptDTO = deptDTOResult.getData(); + formDto.setArea(deptDTO.getDistrict()); + formDto.setAreaId(deptDTO.getDistrictId()); + formDto.setStreet(deptDTO.getStreet()); + formDto.setStreetId(deptDTO.getStreetId()); + formDto.setCommunity(deptDTO.getCommunity()); + formDto.setCommunityId(deptDTO.getCommunityId()); + formDto.setGrid(deptDTO.getGrid()); + formDto.setGridId(deptDTO.getGridId()); + + formDto.setUserId(userDetail.getUserId()); + formDto.setUserFace(userDetail.getFaceImg()); + formDto.setNickname(userDetail.getNickname()); + formDto.setPartyMember(userDetail.getPartyFlag()); + formDto.setState(TopicStateEnum.TOPIC_STATE_IN_CONVERSATION.getValue()); + + return topicFeignClient.submit(formDto); + } +} diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/constant/TopicImageConstant.java b/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/constant/TopicImageConstant.java new file mode 100644 index 000000000..3161933e4 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/constant/TopicImageConstant.java @@ -0,0 +1,16 @@ +package com.elink.esua.epdc.dto.constant; + +/** + * + * 图片类型 + * + * @Author:liuchuang + * @Date:2019/11/6 16:17 + */ +public interface TopicImageConstant { + + /** + * 图片类型-事件 + */ + String TYPE_IMAGE_BIZ_TOPIC = "topic"; +} diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/enums/GroupStateEnum.java b/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/enums/GroupStateEnum.java index c01c83ac8..934ceb63c 100644 --- a/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/enums/GroupStateEnum.java +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/enums/GroupStateEnum.java @@ -1,6 +1,9 @@ package com.elink.esua.epdc.dto.enums; /** + * + * 社群状态枚举 + * * @Author:liuchuang * @Date:2019/10/17 14:15 */ diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/enums/TopicStateEnum.java b/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/enums/TopicStateEnum.java new file mode 100644 index 000000000..157218ad7 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/enums/TopicStateEnum.java @@ -0,0 +1,56 @@ +package com.elink.esua.epdc.dto.enums; + +/** + * + * 话题状态枚举 + * + * @Author:liuchuang + * @Date:2019/11/6 15:11 + */ +public enum TopicStateEnum { + + /** + * 0-讨论中 + */ + TOPIC_STATE_IN_CONVERSATION(0, "讨论中"), + /** + * 5-转议题待审核 + */ + TOPIC_STATE_CHANGE_TO_ISSUE_PENDING_REVIEW(5, "转议题待审核"), + /** + * 10-已转议题 + */ + TOPIC_STATE_CHANGED_ISSUE(10, "已转议题"), + /** + * 15-已转项目 + */ + TOPIC_STATE_CHANGED_ITEM(15, "已转项目"), + /** + * 20-已关闭 + */ + TOPIC_STATE_CLOSED(20, "已关闭"); + + private Integer value; + private String name; + + TopicStateEnum(Integer value, String name) { + this.value = value; + this.name = name; + } + + public Integer getValue() { + return value; + } + + public void setValue(Integer value) { + this.value = value; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/TopicDTO.java b/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/TopicDTO.java index de01e3e1f..8531b4b92 100644 --- a/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/TopicDTO.java +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/TopicDTO.java @@ -122,12 +122,12 @@ public class TopicDTO implements Serializable { /** * 话题位置纬度 */ - private BigDecimal topicLatitude; + private Double topicLatitude; /** * 话题位置经度 */ - private BigDecimal topicLongitude; + private Double topicLongitude; /** * 友邻社群 diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/TopicImgDTO.java b/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/TopicImgDTO.java new file mode 100644 index 000000000..292134001 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/TopicImgDTO.java @@ -0,0 +1,86 @@ +/** + * 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.topic; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 话题图片表 话题图片表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-11-06 + */ +@Data +public class TopicImgDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 引用ID + */ + private String referenceId; + + /** + * 图片地址 + */ + private String imgUrl; + + /** + * 图片类型 + */ + private String imgType; + + /** + * 删除标记 0:未删除,1:删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/form/TopicSubmitFormDTO.java b/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/form/TopicSubmitFormDTO.java new file mode 100644 index 000000000..68496a150 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/form/TopicSubmitFormDTO.java @@ -0,0 +1,126 @@ +package com.elink.esua.epdc.dto.topic.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.io.Serializable; +import java.util.List; + +/** + * + * 发布话题Form DTO + * + * @Author:liuchuang + * @Date:2019/11/6 14:33 + */ +@Data +public class TopicSubmitFormDTO implements Serializable { + private static final long serialVersionUID = 7888315361241643792L; + + /** + * 话题内容 + */ + @NotBlank(message = "话题内容不能为空且在2000个字以内") + @Size(min = 1, max = 2000, message = "话题内容不能为空且在2000个字以内") + private String topicContent; + + /** + * 图片 + */ + private List images; + + /** + * 话题地址 + */ + @NotBlank(message = "话题地址不能为空") + private String topicAddress; + + /** + * 话题位置纬度 + */ + private Double topicLatitude; + + /** + * 话题位置经度 + */ + private Double topicLongitude; + + /** + * 友邻社群 + */ + @NotBlank(message = "友邻社群名称不能为空") + private String groupName; + + /** + * 友邻社群ID + */ + @NotBlank(message = "友邻社群ID不能为空") + private String groupId; + + /** + * 用户ID + */ + private String userId; + + /** + * 用户昵称 + */ + private String nickname; + + /** + * 用户头像 + */ + private String userFace; + + /** + * 党员标识 0:否,1:是 + */ + private String partyMember; + + /** + * 区 + */ + private String area; + + /** + * 区ID + */ + private Long areaId; + + /** + * 街道 + */ + private String street; + + /** + * 街道ID + */ + private Long streetId; + + /** + * 社区 + */ + private String community; + + /** + * 社区ID + */ + private Long communityId; + + /** + * 网格 + */ + private String grid; + + /** + * 网格ID + */ + private Long gridId; + + /** + * 状态 0:讨论中,5:转议题待审核,10:转议题审核不通过,15:已转议题,20:已转项目,25:已关闭 + */ + private Integer state; + +} diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/controller/AppTopicController.java b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/controller/AppTopicController.java new file mode 100644 index 000000000..100284db9 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/controller/AppTopicController.java @@ -0,0 +1,40 @@ +package com.elink.esua.epdc.modules.topic.controller; + +import com.elink.esua.epdc.commons.tools.constant.Constant; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; +import com.elink.esua.epdc.modules.topic.service.TopicService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * + * 移动端-话题模块 + * + * @Author:liuchuang + * @Date:2019/11/6 15:43 + */ +@RestController +@RequestMapping(Constant.EPDC_APP + "topic") +public class AppTopicController { + + @Autowired + private TopicService topicService; + + /** + * + * 发布话题 + * + * @params [formDto] + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author liuchuang + * @since 2019/11/6 15:52 + */ + @PostMapping("submit") + public Result submit(@RequestBody TopicSubmitFormDTO formDto) { + return topicService.saveTopic(formDto); + } +} diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/dao/TopicImgDao.java b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/dao/TopicImgDao.java new file mode 100644 index 000000000..d71212c21 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/dao/TopicImgDao.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.topic.dao; + +import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.modules.topic.entity.TopicImgEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 话题图片表 话题图片表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-11-06 + */ +@Mapper +public interface TopicImgDao extends BaseDao { + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/entity/TopicImgEntity.java b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/entity/TopicImgEntity.java new file mode 100644 index 000000000..f56d8558a --- /dev/null +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/entity/TopicImgEntity.java @@ -0,0 +1,56 @@ +/** + * 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.topic.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-11-06 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("epdc_topic_img") +public class TopicImgEntity extends BaseEpdcEntity { + + private static final long serialVersionUID = 1L; + + /** + * 引用ID + */ + private String referenceId; + + /** + * 图片地址 + */ + private String imgUrl; + + /** + * 图片类型 + */ + private String imgType; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/TopicImgService.java b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/TopicImgService.java new file mode 100644 index 000000000..a60c55a76 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/TopicImgService.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.topic.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.topic.TopicImgDTO; +import com.elink.esua.epdc.modules.topic.entity.TopicImgEntity; + +import java.util.List; +import java.util.Map; + +/** + * 话题图片表 话题图片表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-11-06 + */ +public interface TopicImgService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2019-11-06 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2019-11-06 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return TopicImgDTO + * @author generator + * @date 2019-11-06 + */ + TopicImgDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2019-11-06 + */ + void save(TopicImgDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2019-11-06 + */ + void update(TopicImgDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2019-11-06 + */ + void delete(String[] ids); + + /** + * + * 保存图片 + * + * @params [images, referenceId, imgType] + * @return boolean + * @author liuchuang + * @since 2019/11/6 16:20 + */ + boolean saveImages(List images, String referenceId, String imgType); +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/TopicService.java b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/TopicService.java index c725fa991..8c485067d 100644 --- a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/TopicService.java +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/TopicService.java @@ -19,7 +19,9 @@ package com.elink.esua.epdc.modules.topic.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.topic.TopicDTO; +import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; import com.elink.esua.epdc.modules.topic.entity.TopicEntity; import java.util.List; @@ -98,4 +100,15 @@ public interface TopicService extends BaseService { * 评论数+1 */ void updateCommentNum(String id); + + /** + * + * 移动端-发布话题 + * + * @params [formDto] + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author liuchuang + * @since 2019/11/6 15:53 + */ + Result saveTopic(TopicSubmitFormDTO formDto); } diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/impl/TopicImgServiceImpl.java b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/impl/TopicImgServiceImpl.java new file mode 100644 index 000000000..7f506f409 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/impl/TopicImgServiceImpl.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.modules.topic.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.topic.TopicImgDTO; +import com.elink.esua.epdc.modules.topic.dao.TopicImgDao; +import com.elink.esua.epdc.modules.topic.entity.TopicImgEntity; +import com.elink.esua.epdc.modules.topic.service.TopicImgService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 话题图片表 话题图片表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-11-06 + */ +@Service +public class TopicImgServiceImpl extends BaseServiceImpl implements TopicImgService { + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, TopicImgDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, TopicImgDTO.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 TopicImgDTO get(String id) { + TopicImgEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, TopicImgDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(TopicImgDTO dto) { + TopicImgEntity entity = ConvertUtils.sourceToTarget(dto, TopicImgEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(TopicImgDTO dto) { + TopicImgEntity entity = ConvertUtils.sourceToTarget(dto, TopicImgEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean saveImages(List images, String referenceId, String imgType) { + if (null == images || images.isEmpty()) { + return true; + } + List imgEntities = new ArrayList<>(images.size()); + TopicImgEntity entity = null; + for (String url: + images) { + entity = new TopicImgEntity(); + entity.setReferenceId(referenceId); + entity.setImgUrl(url); + entity.setImgType(imgType); + imgEntities.add(entity); + } + return insertBatch(imgEntities); + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/impl/TopicServiceImpl.java b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/impl/TopicServiceImpl.java index 432d0a81a..8433757ce 100644 --- a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/impl/TopicServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/impl/TopicServiceImpl.java @@ -23,10 +23,13 @@ import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; import com.elink.esua.epdc.commons.tools.constant.FieldConstant; 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.utils.Result; +import com.elink.esua.epdc.dto.constant.TopicImageConstant; import com.elink.esua.epdc.dto.topic.TopicDTO; +import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; import com.elink.esua.epdc.modules.topic.dao.TopicDao; import com.elink.esua.epdc.modules.topic.entity.TopicEntity; -import com.elink.esua.epdc.modules.topic.redis.TopicRedis; +import com.elink.esua.epdc.modules.topic.service.TopicImgService; import com.elink.esua.epdc.modules.topic.service.TopicService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -47,7 +50,7 @@ import java.util.Map; public class TopicServiceImpl extends BaseServiceImpl implements TopicService { @Autowired - private TopicRedis topicRedis; + private TopicImgService topicImgService; @Override public PageData page(Map params) { @@ -106,4 +109,16 @@ public class TopicServiceImpl extends BaseServiceImpl imp baseDao.updateCommentNum(id); } + @Override + @Transactional(rollbackFor = Exception.class) + public Result saveTopic(TopicSubmitFormDTO formDto) { + TopicEntity entity = ConvertUtils.sourceToTarget(formDto, TopicEntity.class); + if (insert(entity)) { + // 保存图片 + topicImgService.saveImages(formDto.getImages(), entity.getId(), TopicImageConstant.TYPE_IMAGE_BIZ_TOPIC); + return new Result(); + } + return new Result().error(); + } + }