diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index 3da96dcbc3..4d3c107de3 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -48,7 +48,7 @@ public enum EpmetErrorCode { IDCARDNO_ALREADY_EXITS(8109,"系统已存在相同身份证号码,请重新输入"), IDCARDNO_ERROR(8110,"身份证号格式错误,请重新输入"), CANNOT_DELETE_PARTY_MEMBER(8111,"该用户已注册党员,不允许删除"), - GROUP_LEADER_CAN_EDIT_GROUP_INFO(8112,"只有组长才可以修改小组信息"), + GROUP_LEADER_CAN_EDIT_GROUP_INFO(8112,"只有组长才可以操作"), INVITE_NEW_MEMBER(8113,"只有讨论中的小组才可以邀请新成员"), ACT_TITLE_SCAN_FAILED(8114,"活动标题审核失败,请重新编辑"), ACT_REQ_SCAN_FAILED(8115,"活动报名条件审核失败,请重新编辑"), diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpContextUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpContextUtils.java index d27da23ab7..a23b8f5d55 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpContextUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpContextUtils.java @@ -66,4 +66,20 @@ public class HttpContextUtils { } return defaultLanguage; } + + public static String getRequestServerNameAndPort() { + HttpServletRequest request = getHttpServletRequest(); + //X-Forwarded-Scheme是nginx中添加的一个header,用于获取真实的$scheme + String scheme = request.getHeader("X-Forwarded-Scheme"); + if (StringUtils.isBlank(scheme)) { + scheme = "http"; + } + + String hostAndPort = request.getHeader("Host-And-Port"); + if (StringUtils.isBlank(hostAndPort)) { + hostAndPort = request.getServerName().concat(":").concat(String.valueOf(request.getServerPort())); + } + + return String.format("%s://%s", scheme, hostAndPort); + } } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java index 8043413311..f57bb25da3 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java @@ -40,5 +40,5 @@ public interface EpmetHeartOpenFeignClient { * @return com.epmet.commons.tools.utils.Result> */ @PostMapping("/heart/resi/act/published/{staffId}") - Result> getPublishedAct(@PathVariable String staffId); + Result> getPublishedAct(@PathVariable("staffId") String staffId); } diff --git a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java index 47daa888cc..239ca51acc 100644 --- a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java +++ b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java @@ -30,6 +30,8 @@ import org.springframework.web.multipart.MultipartFile; */ @FeignClient(name = ServiceConstant.EPMET_OSS_SERVER, configuration = OssFeignClient.MultipartSupportConfig.class, fallback = OssFeignClientFallback.class) +//@FeignClient(name = ServiceConstant.EPMET_OSS_SERVER, configuration = OssFeignClient.MultipartSupportConfig.class, fallback = +// OssFeignClientFallback.class) public interface OssFeignClient { /** * 文件上传 @@ -44,7 +46,7 @@ public interface OssFeignClient { Result uploadQrCode(@RequestPart(value = "file") MultipartFile file); - @Configuration + //@Configuration class MultipartSupportConfig { @Bean public Encoder feignFormEncoder() { diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java index ff52e99ce4..0f78958d58 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java @@ -159,6 +159,7 @@ public class OssController { public Result uploadQrCode(@RequestPart(value = "file") MultipartFile file) { return ossService.uploadImg(file); } + /** * 上传客户logo(考虑到以后可能会针对不同的业务有不同的限制条件,这里不再使用通用的接口 * 针对每一个业务新建上传接口) diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/AccessTokenDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/AccessTokenDTO.java new file mode 100644 index 0000000000..dac9be670e --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/AccessTokenDTO.java @@ -0,0 +1,19 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @description: + * @author: liushaowen + * @date: 2020/11/17 10:07 + */ +@Data +public class AccessTokenDTO implements Serializable { + private String resiToken; + + private String workToken; + + private String errMsg; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/utils/ThirdUtils.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/utils/ThirdUtils.java new file mode 100644 index 0000000000..426bab2b82 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/utils/ThirdUtils.java @@ -0,0 +1,53 @@ +package com.epmet.utils; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.epmet.commons.tools.enums.EnvEnum; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.HttpClientManager; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.AccessTokenDTO; +import com.epmet.dto.result.CustomerTokensResultDTO; +import org.apache.commons.lang3.StringUtils; + +import java.util.HashMap; +import java.util.Map; + +/** + * @description: + * @author: liushaowen + * @date: 2020/11/17 10:04 + */ + +public class ThirdUtils { + /** + * @Description 获取AccessToken公共方法 + * @param customerId + * @return com.epmet.dto.AccessTokenDTO + * @Author liushaowen + * @Date 2020/11/17 10:09 + */ + public static AccessTokenDTO getAccessToken(String customerId) { + EnvEnum envEnum = EnvEnum.getCurrentEnv(); + AccessTokenDTO accessToken = new AccessTokenDTO(); + + String url = "https://epmet-cloud.elinkservice.cn/api/third/pacustomer/tokenlist"; + JSONObject postData = new JSONObject(); + postData.put("customerId", customerId); + String data = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(postData)).getData(); + JSONObject toResult = JSON.parseObject(data); + Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class); + if (null != toResult.get("code")) { + mapToResult.setCode(((Integer) toResult.get("code")).intValue()); + } + if (!mapToResult.success()) { + accessToken.setErrMsg( StringUtils.isBlank(mapToResult.getMsg()) ? mapToResult.getInternalMsg() : mapToResult.getMsg()); + } + Object CustomerTokensResultDTO = mapToResult.getData(); + JSONObject json = JSON.parseObject(CustomerTokensResultDTO.toString()); + CustomerTokensResultDTO customerTokensResultDTO = ConvertUtils.mapToEntity(json, com.epmet.dto.result.CustomerTokensResultDTO.class); + accessToken.setResiToken(customerTokensResultDTO.getResiAuthorizerToken()); + accessToken.setWorkToken(customerTokensResultDTO.getWorkAuthorizerToken()); + return accessToken; + } +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupCodeConstant.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupCodeConstant.java new file mode 100644 index 0000000000..2dd3ab893c --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupCodeConstant.java @@ -0,0 +1,23 @@ +package com.epmet.resi.group.constant; + +/** + * @description: + * @author: liushaowen + * @date: 2020/11/13 16:23 + */ + +public interface GroupCodeConstant { + /** + * 群二维码类型-邀请 + */ + String CODE_TYPE_INVITE = "invite"; + + /** + * aliyun图片地址域名对应正则表达式 + */ + String PATTERN = "^((http://)|(https://))?([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}(/)"; + /** + * 供前端下载图片jenkins转发前缀 + */ + String STORAGE = "/storage/"; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupStateConstant.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupStateConstant.java index fcb2afc28f..ee3bcda420 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupStateConstant.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupStateConstant.java @@ -41,4 +41,20 @@ public interface GroupStateConstant { * 群已关闭 - closed */ String GROUP_CLOSED = "closed"; + /** + * 邀请链接:invited + */ + String GROUP_INVITED = "invited"; + /** + * 扫码:scancode + */ + String GROUP_SCANCODE = "scancode"; + /** + * 进组审核open开启;close关闭 + */ + String AUDIT_SWITCH_OPEN = "open"; + /** + * 进组审核open开启;close关闭 + */ + String AUDIT_SWITCH_CLOSED = "close"; } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/QRCodeMultipartFileDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/QRCodeMultipartFileDTO.java new file mode 100644 index 0000000000..5b8f6a8cd9 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/QRCodeMultipartFileDTO.java @@ -0,0 +1,66 @@ +package com.epmet.resi.group.dto; + +import lombok.Data; +import org.apache.commons.lang3.ArrayUtils; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; + +/** + * @description: + * @author: liushaowen + * @date: 2020/11/16 13:52 + */ +@Data +public class QRCodeMultipartFileDTO implements MultipartFile { + + private String name = "file"; + + private String originalFilename; + + private String contentType = "image/jpeg"; + + private byte[] bytes; + + @Override + public String getName() { + return this.name; + } + + @Override + public String getOriginalFilename() { + return this.originalFilename; + } + + @Override + public String getContentType() { + return this.contentType; + } + + @Override + public boolean isEmpty() { + return ArrayUtils.isEmpty(bytes)?true:false; + } + + @Override + public long getSize() { + return ArrayUtils.isEmpty(bytes)?bytes.length:0; + } + + @Override + public byte[] getBytes() { + return this.bytes; + } + + @Override + public InputStream getInputStream() { + return null; + } + + @Override + public void transferTo(File file) { + + } +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/ResiGroupCodeDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/ResiGroupCodeDTO.java new file mode 100644 index 0000000000..ac301a624c --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/ResiGroupCodeDTO.java @@ -0,0 +1,101 @@ +/** + * 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.epmet.resi.group.dto.group; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 小组二维码 小组唯一二维码,海报码和小组码是同一个二维码,长期有效的 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-11-13 + */ +@Data +public class ResiGroupCodeDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 网格ID + */ + private String gridId; + + /** + * 小组Id + */ + private String groupId; + + /** + * 二维码类型 + */ + private String type; + + /** + * 邀请ID + */ + private String invitationId; + + /** + * 二维码路径 + */ + private String url; + + /** + * 删除标志 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/ResiGroupDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/ResiGroupDTO.java index 9045ac28ea..be61d33c2a 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/ResiGroupDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/ResiGroupDTO.java @@ -74,6 +74,11 @@ Ps: 如果一个小组被拒绝,当前小组的状态将永久停留在“审 */ private Date latestTopicPublishDate; + /** + * 进组审核open开启;close关闭 + */ + private String auditSwitch; + /** * 删除标记 0:未删除,1:已删除 */ diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/CreateGroupCodeFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/CreateGroupCodeFormDTO.java new file mode 100644 index 0000000000..2de7fe7531 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/CreateGroupCodeFormDTO.java @@ -0,0 +1,40 @@ +package com.epmet.resi.group.dto.group.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @description: + * @author: liushaowen + * @date: 2020/11/13 16:22 + */ +@Data +public class CreateGroupCodeFormDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + @NotBlank(message = "客户id不能为空") + private String customerId; + + /** + * 网格id + */ + @NotBlank(message = "网格id不能为空") + private String gridId; + + /** + * 组id + */ + @NotBlank(message = "群组id不能为空") + private String groupId; + + /** + * 类型 GroupCodeConstant中的类型 + */ + @NotBlank(message = "二维码类型不能为空") + private String type; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GetGroupCodeFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GetGroupCodeFormDTO.java new file mode 100644 index 0000000000..351c8dbc7b --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GetGroupCodeFormDTO.java @@ -0,0 +1,40 @@ +package com.epmet.resi.group.dto.group.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @description: + * @author: liushaowen + * @date: 2020/11/16 9:31 + */ +@Data +public class GetGroupCodeFormDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + @NotBlank(message = "客户id不能为空") + private String customerId; + + /** + * 网格id + */ + @NotBlank(message = "网格id不能为空") + private String gridId; + + /** + * 组id + */ + @NotBlank(message = "群组id不能为空") + private String groupId; + + /** + * 类型 GroupCodeConstant中的类型 + */ + @NotBlank(message = "二维码类型不能为空") + private String type; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupCodeBasicInfoFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupCodeBasicInfoFormDTO.java new file mode 100644 index 0000000000..b9a6102ecd --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupCodeBasicInfoFormDTO.java @@ -0,0 +1,33 @@ +package com.epmet.resi.group.dto.group.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @description: 获取生成海报(小组码)信息-接口入参 + * @author: sun + */ +@Data +public class GroupCodeBasicInfoFormDTO implements Serializable { + private static final long serialVersionUID = 1L; + /** + * 客户id + */ + @NotBlank(message = "客户id不能为空", groups = {GroupCodeBasicInfoFormDTO.GroupCodeInfo.class}) + private String customerId; + /** + * 网格id + */ + @NotBlank(message = "网格id不能为空", groups = {GroupCodeBasicInfoFormDTO.GroupCodeInfo.class}) + private String gridId; + /** + * 组id + */ + @NotBlank(message = "群组id不能为空", groups = {GroupCodeBasicInfoFormDTO.GroupCodeInfo.class}) + private String groupId; + + public interface GroupCodeInfo {} + +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupCodeBasicInfoResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupCodeBasicInfoResultDTO.java new file mode 100644 index 0000000000..b3275408bf --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupCodeBasicInfoResultDTO.java @@ -0,0 +1,35 @@ +package com.epmet.resi.group.dto.group.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @description: 获取生成海报(小组码)信息-接口入参 + * @author: sun + */ +@Data +public class GroupCodeBasicInfoResultDTO implements Serializable { + private static final long serialVersionUID = -1590972041272087570L; + + /** + * 小组Id + */ + private String groupId; + /** + * 小组名称 + */ + private String groupName; + /** + * 小组头像 + */ + private String groupHeadPhoto; + /** + * 小组介绍 + */ + private String groupIntroduction; + /** + * 小组二维码路径 + */ + private String groupCodeUrl; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupSummarizeResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupSummarizeResultDTO.java index 9e54c59eb5..0b19208c9f 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupSummarizeResultDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupSummarizeResultDTO.java @@ -65,6 +65,10 @@ public class GroupSummarizeResultDTO implements Serializable { */ private String leaderFlag; + /** + * 进组审核open开启;close关闭 + */ + private String auditSwitch; public GroupSummarizeResultDTO(){ this.setGroupId(""); this.setGroupHeadPhoto(""); @@ -76,5 +80,6 @@ public class GroupSummarizeResultDTO implements Serializable { this.setTotalApplyingMember(NumConstant.ZERO); this.setTotalTopics(NumConstant.ZERO); this.setLeaderFlag(""); + this.setAuditSwitch("open"); } } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/GroupInvitationDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/GroupInvitationDTO.java index b4bc7fe18a..f157c439d1 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/GroupInvitationDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/GroupInvitationDTO.java @@ -68,6 +68,11 @@ public class GroupInvitationDTO implements Serializable { */ private Date validEndTime; + /** + * 邀请链接:invited;扫码:scancode + */ + private String invitationType; + /** * 删除标记 0:未删除,1:已删除 */ diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/result/AcceptInvitationResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/result/AcceptInvitationResultDTO.java new file mode 100644 index 0000000000..c7dc6cf6f7 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/result/AcceptInvitationResultDTO.java @@ -0,0 +1,19 @@ +package com.epmet.resi.group.dto.invitation.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 同意邀请进组 + * @Author sun + */ +@Data +public class AcceptInvitationResultDTO implements Serializable { + private static final long serialVersionUID = 8860336693592035343L; + + /** + * true 已经入组过需要审核 false没有入组过 + */ + private Boolean awaitAudit = false; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/result/LinkGroupInfoResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/result/LinkGroupInfoResultDTO.java index 4e3fd08cd5..441571f202 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/result/LinkGroupInfoResultDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/result/LinkGroupInfoResultDTO.java @@ -14,6 +14,10 @@ import java.io.Serializable; public class LinkGroupInfoResultDTO implements Serializable { private static final long serialVersionUID = 8860336693592035343L; + /** + * true 已经入组过需要审核 false没有入组过 + */ + private Boolean awaitAudit; /** * 是否在群内标志,已经在群内yes 不在群内no */ diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/GroupMemeberOperationDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/GroupMemeberOperationDTO.java index 23a8331ac0..751153861a 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/GroupMemeberOperationDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/GroupMemeberOperationDTO.java @@ -62,7 +62,7 @@ public class GroupMemeberOperationDTO implements Serializable { private String operateStatus; /** - * 入群方式:(受邀请入群 - invited 、 主动加入 - join、created群主创建群自动进入群) + * 入群方式:(受邀请入群 - invited 、 主动加入 - join、created群主创建群自动进入群、扫码入群 - scancode) */ private String enterGroupType; diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/ResiGroupMemberDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/ResiGroupMemberDTO.java index 49de542902..c6cd651968 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/ResiGroupMemberDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/ResiGroupMemberDTO.java @@ -54,7 +54,7 @@ public class ResiGroupMemberDTO implements Serializable { private String groupLeaderFlag; /** - * 入群方式:(受邀请入群 - invited 、 主动加入 - join、created群主创建群自动进入群) + * 入群方式:(受邀请入群 - invited 、 主动加入 - join、created群主创建群自动进入群、扫码入群 - scancode) */ private String enterGroupType; diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/form/EditAuditSwitchFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/form/EditAuditSwitchFormDTO.java new file mode 100644 index 0000000000..da1391fa51 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/form/EditAuditSwitchFormDTO.java @@ -0,0 +1,27 @@ +package com.epmet.resi.group.dto.member.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 组长开启/关闭入群审核 + * + * @author yinzuomei@elink-cn.com + * @date 2020/11/17 14:02 + */ +@Data +public class EditAuditSwitchFormDTO implements Serializable { + private static final long serialVersionUID = -8185514609968752625L; + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + @NotBlank(message = "小组id不能为空") + private String groupId; + /** + * 进组审核open开启;close关闭 + */ + @NotBlank(message = "请选择是否开启", groups = {EditAuditSwitchFormDTO.AddUserShowGroup.class}) + private String auditSwitch; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/result/ApplyingMemberResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/result/ApplyingMemberResultDTO.java index 6374a9314b..915523354b 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/result/ApplyingMemberResultDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/result/ApplyingMemberResultDTO.java @@ -47,6 +47,12 @@ public class ApplyingMemberResultDTO implements Serializable { */ private String status; + /** + * invited:通过链接加入 ; join:申请加入;scancode通过扫码加入 + */ + private String enterGroupType; + + /** * 用户徽章Url列表 */ diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java index 494cdc0dc4..574af0884f 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java @@ -17,12 +17,18 @@ import com.epmet.resi.group.dto.topic.result.MyPartIssueResultDTO; import com.epmet.resi.group.dto.topic.result.ParticipatedTopicUnitResultDTO; import com.epmet.resi.group.feign.fallback.ResiGroupOpenFeignClientFallback; import com.epmet.resi.mine.dto.from.MyPartProjectsFormDTO; +import com.epmet.commons.tools.utils.Result; +import com.epmet.resi.group.dto.group.form.CreateGroupCodeFormDTO; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import java.util.HashMap; import java.util.List; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; /** * 本服务对外开放的API,其他服务通过引用此client调用该服务 @@ -58,6 +64,16 @@ public interface ResiGroupOpenFeignClient { Result govAuditEdit(@RequestBody GroupEditionAuditFormDTO param); + /** + * @Description 创建群组二维码 + * @param dto + * @return com.epmet.commons.tools.utils.Result + * @Author liushaowen + * @Date 2020/11/13 16:33 + */ + @PostMapping(value = "/resi/group/resigroupcode/creategroupcode", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) + Result createGroupCode(@RequestBody CreateGroupCodeFormDTO dto); + /** * @Description 查询用户参与的且不是自己发表的话题对应的议题Id集合 * @author sun diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java index 164d1ddfc7..7df5d859cf 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java @@ -17,6 +17,10 @@ import com.epmet.resi.group.dto.topic.form.*; import com.epmet.resi.group.dto.topic.result.IssueGridResultDTO; import com.epmet.resi.group.dto.topic.result.MyPartIssueResultDTO; import com.epmet.resi.group.dto.topic.result.ParticipatedTopicUnitResultDTO; +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.resi.group.dto.group.form.CreateGroupCodeFormDTO; import com.epmet.resi.group.feign.ResiGroupOpenFeignClient; import com.epmet.resi.mine.dto.from.MyPartProjectsFormDTO; import org.springframework.stereotype.Component; @@ -46,6 +50,17 @@ public class ResiGroupOpenFeignClientFallback implements ResiGroupOpenFeignClien public Result govAuditEdit(GroupEditionAuditFormDTO param) { return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "govAuditEdit", param); } + /** + * @param dto + * @return com.epmet.commons.tools.utils.Result + * @Description 创建群组二维码 + * @Author liushaowen + * @Date 2020/11/13 16:33 + */ + @Override + public Result createGroupCode(CreateGroupCodeFormDTO dto) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "createGroupCode", dto); + } @Override public Result> topicToIssueList(MyPartProjectsFormDTO formDTO) { diff --git a/epmet-module/resi-group/resi-group-server/pom.xml b/epmet-module/resi-group/resi-group-server/pom.xml index 86ccf538e0..6585d78081 100644 --- a/epmet-module/resi-group/resi-group-server/pom.xml +++ b/epmet-module/resi-group/resi-group-server/pom.xml @@ -94,6 +94,18 @@ 2.0.0 compile + + com.epmet + epmet-third-client + 2.0.0 + compile + + + com.epmet + epmet-oss-client + 2.0.0 + compile + @@ -148,6 +160,11 @@ false https://epmet-dev.elinkservice.cn/api/epmetscan/api + + 5 + 8 + 10 + 30 @@ -188,6 +205,11 @@ false https://epmet-dev.elinkservice.cn/api/epmetscan/api + + 5 + 8 + 10 + 30 @@ -227,6 +249,11 @@ true https://epmet-dev.elinkservice.cn/api/epmetscan/api + + 5 + 8 + 10 + 30 @@ -263,6 +290,11 @@ true https://epmet-open.elinkservice.cn/api/epmetscan/api + + 5 + 8 + 10 + 30 diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/config/AsyncConfig.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/config/AsyncConfig.java new file mode 100644 index 0000000000..8a1a958939 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/config/AsyncConfig.java @@ -0,0 +1,49 @@ +package com.epmet.config; + +import com.epmet.properties.ThreadProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.ThreadPoolExecutor; + +/** + * 线程池配置类 + */ +@Configuration +@EnableConfigurationProperties(ThreadProperties.class) +@EnableAsync +public class AsyncConfig { + + @Autowired + private ThreadProperties threadProperties; + + @Bean + public Executor executor() { + ThreadProperties.ThreadPoolProperties threadPoolProps = threadProperties.getThreadPool(); + + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(threadPoolProps.getCorePoolSize()); + executor.setMaxPoolSize(threadPoolProps.getMaxPoolSize()); + executor.setQueueCapacity(threadPoolProps.getQueueCapacity()); + executor.setThreadNamePrefix("epmet-resi-group-"); + // rejection-policy:当pool已经达到max size的时候,如何处理新任务 + // CALLER_RUNS:不在新线程中执行任务,而是由调用者所在的线程来执行 + executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); //对拒绝task的处理策略 + executor.setKeepAliveSeconds(threadPoolProps.getKeepAlive()); + executor.initialize(); + return executor; + } + + @Bean + public ExecutorService executorService() { + ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) executor(); + return executor.getThreadPoolExecutor(); + } + +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/UserMessageConstant.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/UserMessageConstant.java index dcc8e30fce..29f89329e4 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/UserMessageConstant.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/UserMessageConstant.java @@ -28,6 +28,7 @@ public interface UserMessageConstant { * 成员通过链接同意进群后,组长会收到:您的好友-【认证的居民名字 xxx路-王先生】通过邀请链接,加入了【组名】 */ String INVITED_JOIN_GROUP = "您的好友-【%s】通过邀请连接,加入了【%s】"; + String SCANCODE_JOIN_GROUP = "您的好友-【%s】通过扫描二维码,加入了【%s】"; /** * 组成员被禁言时会收到消息:您已被禁言,禁言时间2020.03.20 12:20-2020.03.27 12:20 @@ -79,4 +80,14 @@ public interface UserMessageConstant { */ String WX_CREATE_GROUP_BEHAVIOR = "建组申请消息"; + /** + * 邀请入组的入组理由 + */ + String INVITED_OPERATE = "通过邀请链接加入小组。"; + + /** + * 扫码入组的入组理由 + */ + String SCANCODE_OPERATE = "通过扫码加入小组。"; + } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupCodeController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupCodeController.java new file mode 100644 index 0000000000..34b4458ea8 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupCodeController.java @@ -0,0 +1,112 @@ +/** + * 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.epmet.modules.group.controller; + + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.modules.group.service.ResiGroupCodeService; +import com.epmet.resi.group.dto.group.ResiGroupCodeDTO; +import com.epmet.resi.group.dto.group.form.CreateGroupCodeFormDTO; +import com.epmet.resi.group.dto.group.form.GetGroupCodeFormDTO; +import com.epmet.resi.group.dto.group.form.GroupCodeBasicInfoFormDTO; +import com.epmet.resi.group.dto.group.result.GroupCodeBasicInfoResultDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 小组二维码 小组唯一二维码,海报码和小组码是同一个二维码,长期有效的 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-11-13 + */ +@RestController +@RequestMapping("resigroupcode") +public class ResiGroupCodeController { + + @Autowired + private ResiGroupCodeService resiGroupCodeService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = resiGroupCodeService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + ResiGroupCodeDTO data = resiGroupCodeService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody ResiGroupCodeDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + resiGroupCodeService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody ResiGroupCodeDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + resiGroupCodeService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + resiGroupCodeService.delete(ids); + return new Result(); + } + + @RequestMapping("creategroupcode") + public Result createGroupCode(@RequestBody CreateGroupCodeFormDTO dto){ + ValidatorUtils.validateEntity(dto); + return new Result().ok(resiGroupCodeService.createGroupCode(dto, true)); + } + + @RequestMapping("getgroupcode") + public Result getGroupCode(@RequestBody GetGroupCodeFormDTO dto){ + ValidatorUtils.validateEntity(dto); + return resiGroupCodeService.getGroupCode(dto); + } + + /** + * @param formDTO + * @Description 获取生成海报(小组码)信息 + * @author sun + */ + @PostMapping("groupcodebasicinfo") + public Result groupCodeBasicInfo(@RequestBody GroupCodeBasicInfoFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GroupCodeBasicInfoFormDTO.GroupCodeInfo.class); + return new Result().ok(resiGroupCodeService.groupCodeBasicInfo(formDTO)); + } + +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java index 793cdbb83b..d8e11dc942 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java @@ -28,6 +28,7 @@ import com.epmet.resi.group.dto.group.GroupProcessingCountResultDTO; import com.epmet.resi.group.dto.group.ResiGroupDTO; import com.epmet.resi.group.dto.group.form.*; import com.epmet.resi.group.dto.group.result.*; +import com.epmet.resi.group.dto.member.form.EditAuditSwitchFormDTO; import com.epmet.resi.group.dto.member.form.ResiIdentityFormDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; @@ -35,6 +36,10 @@ 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; +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; import java.util.HashMap; import java.util.List; @@ -109,7 +114,7 @@ public class ResiGroupController { * @param modifyGroupFormDTO * @return com.epmet.commons.tools.utils.Result * @Author yinzuomei - * @Description 修改组信息 + * @Description 修改组信息 此接口废弃 * @Date 2020/3/28 22:20 **/ @PostMapping("modifygroup") @@ -429,6 +434,19 @@ public class ResiGroupController { } + /** + * @param formDTO + * @author yinzuomei + * @description 组长开启/关闭入群审核 + * @Date 2020/11/17 14:18 + **/ + @PostMapping("editauditswitch") + public Result editAuditSwitch(@RequestBody EditAuditSwitchFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO,EditAuditSwitchFormDTO.AddUserShowGroup.class); + resiGroupService.editAuditSwitch(formDTO); + return new Result(); + } + /** * @Description 查询话题所属小组名 * @Param groupInfoFormDTO diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupCodeDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupCodeDao.java new file mode 100644 index 0000000000..14415b5447 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupCodeDao.java @@ -0,0 +1,41 @@ +/** + * 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.epmet.modules.group.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.modules.group.entity.ResiGroupCodeEntity; +import com.epmet.resi.group.dto.group.form.GroupCodeBasicInfoFormDTO; +import com.epmet.resi.group.dto.group.result.GroupCodeBasicInfoResultDTO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 小组二维码 小组唯一二维码,海报码和小组码是同一个二维码,长期有效的 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-11-13 + */ +@Mapper +public interface ResiGroupCodeDao extends BaseDao { + + /** + * @param formDTO + * @Description 获取生成海报(小组码)信息 + * @author sun + */ + GroupCodeBasicInfoResultDTO selectGroupCodeBasicInfo(GroupCodeBasicInfoFormDTO formDTO); +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/entity/ResiGroupCodeEntity.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/entity/ResiGroupCodeEntity.java new file mode 100644 index 0000000000..3859492d3a --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/entity/ResiGroupCodeEntity.java @@ -0,0 +1,72 @@ +/** + * 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.epmet.modules.group.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 小组二维码 小组唯一二维码,海报码和小组码是同一个二维码,长期有效的 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-11-13 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("resi_group_code") +public class ResiGroupCodeEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 网格ID + */ + private String gridId; + + /** + * 小组Id + */ + private String groupId; + + /** + * 二维码类型 + */ + private String type; + + /** + * 邀请ID + */ + private String invitationId; + + /** + * 二维码路径 + */ + private String url; + +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/entity/ResiGroupEntity.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/entity/ResiGroupEntity.java index 0305fb7834..8dfa5e2db8 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/entity/ResiGroupEntity.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/entity/ResiGroupEntity.java @@ -74,4 +74,9 @@ Ps: 如果一个小组被拒绝,当前小组的状态将永久停留在“审 */ private Date latestTopicPublishDate; + /** + * 进组审核open开启;close关闭 + */ + private String auditSwitch; + } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/redis/ResiGroupCodeRedis.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/redis/ResiGroupCodeRedis.java new file mode 100644 index 0000000000..a34bae4c5e --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/redis/ResiGroupCodeRedis.java @@ -0,0 +1,58 @@ +/** + * 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.epmet.modules.group.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** + * 小组二维码 小组唯一二维码,海报码和小组码是同一个二维码,长期有效的 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-11-13 + */ +@Component +public class ResiGroupCodeRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + + /** + * @Description 获取刷新 + * @param key = epmet:wechartthird:authorizerrefreshtoken:customerId:clientType 前缀+客户ID+客户端类型 + * @author zxc + */ + public Map getAuthorizerRefreshToken(String key){ + Map result = redisUtils.hGetAll("epmet:wechartthird:authorizerrefreshtoken:" + key); + return result; + } +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupCodeService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupCodeService.java new file mode 100644 index 0000000000..e0b5e7ec4d --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupCodeService.java @@ -0,0 +1,126 @@ +/** + * 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.epmet.modules.group.service; + + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.modules.group.entity.ResiGroupCodeEntity; +import com.epmet.resi.group.dto.group.ResiGroupCodeDTO; +import com.epmet.resi.group.dto.group.form.CreateGroupCodeFormDTO; +import com.epmet.resi.group.dto.group.form.GetGroupCodeFormDTO; +import com.epmet.resi.group.dto.group.form.GroupCodeBasicInfoFormDTO; +import com.epmet.resi.group.dto.group.result.GroupCodeBasicInfoResultDTO; + +import java.util.List; +import java.util.Map; + +/** + * 小组二维码 小组唯一二维码,海报码和小组码是同一个二维码,长期有效的 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-11-13 + */ +public interface ResiGroupCodeService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-11-13 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-11-13 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return ResiGroupCodeDTO + * @author generator + * @date 2020-11-13 + */ + ResiGroupCodeDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-11-13 + */ + void save(ResiGroupCodeDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-11-13 + */ + void update(ResiGroupCodeDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-11-13 + */ + void delete(String[] ids); + + /** + * @Description 创建群组二维码 + * @param dto,syncFlag(是否同步执行,true同步,false异步) + * @return String + * @Author liushaowen + * @Date 2020/11/13 16:32 + */ + String createGroupCode(CreateGroupCodeFormDTO dto, boolean syncFlag); + + /** + * @Description 获取群组二维码 + * @param dto + * @return com.epmet.commons.tools.utils.Result + * @Author liushaowen + * @Date 2020/11/16 9:37 + */ + Result getGroupCode(GetGroupCodeFormDTO dto); + + /** + * @param formDTO + * @Description 获取生成海报(小组码)信息 + * @author sun + */ + GroupCodeBasicInfoResultDTO groupCodeBasicInfo(GroupCodeBasicInfoFormDTO formDTO); +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java index fa1768d946..0fd92bf582 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java @@ -27,6 +27,7 @@ import com.epmet.resi.group.dto.group.GroupProcessingCountResultDTO; import com.epmet.resi.group.dto.group.ResiGroupDTO; import com.epmet.resi.group.dto.group.form.*; import com.epmet.resi.group.dto.group.result.*; +import com.epmet.resi.group.dto.member.form.EditAuditSwitchFormDTO; import java.util.HashMap; import java.util.List; @@ -135,6 +136,7 @@ public interface ResiGroupService extends BaseService { * @Description 修改组信息 * @Date 2020/3/28 22:27 **/ + @Deprecated void modifyGroup(ModifyGroupFormDTO modifyGroupFormDTO); /** @@ -326,6 +328,15 @@ public interface ResiGroupService extends BaseService { */ void auditEdit(GroupEditionAuditFormDTO param); + /** + * @return void + * @param formDTO + * @author yinzuomei + * @description 组长开启/关闭入群审核 + * @Date 2020/11/17 14:18 + **/ + void editAuditSwitch(EditAuditSwitchFormDTO formDTO); + /** * @Description 查询话题所属小组名 * @Param groupInfoFormDTO diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupCodeServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupCodeServiceImpl.java new file mode 100644 index 0000000000..b77e271163 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupCodeServiceImpl.java @@ -0,0 +1,304 @@ +/** + * 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.epmet.modules.group.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.HttpClientManager; +import com.epmet.commons.tools.utils.HttpContextUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.result.UploadImgResultDTO; +import com.epmet.feign.OssFeignClient; +import com.epmet.modules.group.dao.ResiGroupCodeDao; +import com.epmet.modules.group.entity.ResiGroupCodeEntity; +import com.epmet.modules.group.redis.ResiGroupCodeRedis; +import com.epmet.modules.group.service.ResiGroupCodeService; +import com.epmet.modules.group.service.ResiGroupService; +import com.epmet.modules.invitation.service.GroupInvitationService; +import com.epmet.modules.utils.ModuleConstant; +import com.epmet.resi.group.constant.GroupCodeConstant; +import com.epmet.resi.group.dto.QRCodeMultipartFileDTO; +import com.epmet.resi.group.dto.group.ResiGroupCodeDTO; +import com.epmet.resi.group.dto.group.form.CreateGroupCodeFormDTO; +import com.epmet.resi.group.dto.group.form.GetGroupCodeFormDTO; +import com.epmet.resi.group.dto.group.form.GroupCodeBasicInfoFormDTO; +import com.epmet.resi.group.dto.group.result.GroupCodeBasicInfoResultDTO; +import com.epmet.resi.group.dto.invitation.form.CreateGroupInvitationFormDTO; +import com.epmet.resi.group.dto.invitation.result.CreateGroupInvitationResultDTO; +import com.epmet.utils.ThirdUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.UnsupportedEncodingException; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutorService; + +/** + * 小组二维码 小组唯一二维码,海报码和小组码是同一个二维码,长期有效的 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-11-13 + */ +@Service +public class ResiGroupCodeServiceImpl extends BaseServiceImpl implements ResiGroupCodeService { + + private static final Logger logger = LoggerFactory.getLogger(ResiGroupCodeServiceImpl.class); + + @Autowired + private ResiGroupCodeRedis resiGroupCodeRedis; + + @Autowired + private OssFeignClient ossFeignClient; + + @Autowired + private ExecutorService executorService; + + @Autowired + private GroupInvitationService groupInvitationService; + + @Autowired + private ResiGroupService resiGroupService; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, ResiGroupCodeDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, ResiGroupCodeDTO.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 ResiGroupCodeDTO get(String id) { + ResiGroupCodeEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, ResiGroupCodeDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(ResiGroupCodeDTO dto) { + ResiGroupCodeEntity entity = ConvertUtils.sourceToTarget(dto, ResiGroupCodeEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(ResiGroupCodeDTO dto) { + ResiGroupCodeEntity entity = ConvertUtils.sourceToTarget(dto, ResiGroupCodeEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * @param dto, syncFlag(是否同步执行,true同步,false异步) + * @return String + * @Description 创建群组二维码 + * @Author liushaowen + * @Date 2020/11/13 16:32 + */ + @Override + public String createGroupCode(CreateGroupCodeFormDTO dto, boolean syncFlag) { + if (syncFlag){ + return createCodeFunction(dto); + }else { + executorService.execute(()->{ + try { + long startTs = System.currentTimeMillis(); + createCodeFunction(dto); + long endTs = System.currentTimeMillis(); + logger.info("异步创建群二维码成功,执行时长:{}", endTs - startTs); + } catch (Exception e) { + logger.error("异步创建群二维码失败,错误信息:{}", ExceptionUtils.getErrorStackTrace(e)); + } + }); + return ""; + } + } + + /** + * @param dto + * @return com.epmet.commons.tools.utils.Result + * @Description 获取群组二维码 + * @Author liushaowen + * @Date 2020/11/16 9:37 + */ + @Override + public Result getGroupCode(GetGroupCodeFormDTO dto) { + ResiGroupCodeEntity codeByGroupId = getCode(dto.getGroupId(), dto.getType()); + if (codeByGroupId != null) { + //数据库有数据 + return new Result().ok(codeByGroupId.getUrl()); + } else { + //从微信获取二维码并存储 + CreateGroupCodeFormDTO createDto = new CreateGroupCodeFormDTO(); + BeanUtils.copyProperties(dto, createDto); + String url = createGroupCode(createDto, true); + if (StringUtils.isBlank(url)){ + throw new RenException("获取二维码失败"); + } + return new Result().ok(url); + } + } + + private ResiGroupCodeEntity getCode(String groupId, String type) { + if (StringUtils.isBlank(groupId) || StringUtils.isBlank(type)) { + throw new RenException("获取二维码失败,groupId或type为空"); + } + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("DEL_FLAG", "0"); + queryWrapper.eq("GROUP_ID", groupId); + queryWrapper.eq("TYPE", type); + return baseDao.selectOne(queryWrapper); + } + + private String createCodeFunction(CreateGroupCodeFormDTO dto){ + String result = ""; + ResiGroupCodeEntity codeByGroupId = getCode(dto.getGroupId(), dto.getType()); + if (codeByGroupId != null) { + logger.error("本群组该类型二维码已存在,请勿重复添加。groupId:{},type:{}", dto.getGroupId(), dto.getType()); + throw new RenException("本群组该类型二维码已存在,请勿重复添加。"); + } else { + //向微信获取二维码 + + // 获取AccessToken + String accessToken = ThirdUtils.getAccessToken(dto.getCustomerId()).getResiToken(); + if (StringUtils.isBlank(accessToken)) { + logger.error("获取accessToken失败,customerId:{}", dto.getCustomerId()); + throw new RenException("获取accessToken失败"); + } + //跳转的页面 + StringBuilder path = new StringBuilder(ModuleConstant.CODE_INVITE_PAGE); + //获取invitationId + CreateGroupInvitationFormDTO invitationFormDTO = new CreateGroupInvitationFormDTO(); + //获取群主userId + invitationFormDTO.setUserId(resiGroupService.get(dto.getGroupId()).getCreatedBy()); + invitationFormDTO.setGroupId(dto.getGroupId()); + CreateGroupInvitationResultDTO groupScanCodeInvitation = groupInvitationService.createGroupScanCodeInvitation(invitationFormDTO); + path.append("?invitationId=").append(groupScanCodeInvitation.getInvitationId()); + + //需要发送的Json + JSONObject data = new JSONObject(); + data.put("path", path.toString()); + data.put("width", 400); + //发送 + byte[] buffer = HttpClientManager.getInstance().getMediaByteArray(ModuleConstant.GET_CODE_URL + accessToken, JSON.toJSONString(data)).getData(); + if (buffer != null && buffer.length < 500) { + String wxResult = ""; + try { + wxResult = new String(buffer, "UTF-8"); + if (-1 != wxResult.indexOf("errcode")) { + logger.error("获取二维码接口返回错误:{}", wxResult); + throw new RenException("获取二维码失败"); + } + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + //上传 + QRCodeMultipartFileDTO qrCodeMultipartFile = new QRCodeMultipartFileDTO(); + qrCodeMultipartFile.setBytes(buffer); + qrCodeMultipartFile.setOriginalFilename("qrcode.jpg"); + Result uploadResult = ossFeignClient.uploadQrCode(qrCodeMultipartFile); + if (uploadResult.success()) { + result = uploadResult.getData().getUrl(); + //存表 + ResiGroupCodeEntity entity = new ResiGroupCodeEntity(); + BeanUtils.copyProperties(dto, entity); + entity.setInvitationId(groupScanCodeInvitation.getInvitationId()); + entity.setUrl(uploadResult.getData().getUrl()); + baseDao.insert(entity); + } else { + logger.error("上传图片失败:{}", uploadResult.getMsg()); + throw new RenException("上传图片失败"); + } + } + return result; + } + + /** + * @param formDTO + * @Description 获取生成海报(小组码)信息 + * @author sun + */ + @Override + public GroupCodeBasicInfoResultDTO groupCodeBasicInfo(GroupCodeBasicInfoFormDTO formDTO) { + String headUrl = ""; + String url = ""; + //1.获取小组基本信息 + GroupCodeBasicInfoResultDTO resultDTO = baseDao.selectGroupCodeBasicInfo(formDTO); + if (null == resultDTO) { + logger.error(String.format("获取小组码基本信息失败,小组Id:%s", formDTO.getGroupId())); + throw new RenException("获取小组码基本信息失败"); + } + if (null == resultDTO.getGroupCodeUrl() || "".equals(resultDTO.getGroupCodeUrl())) { + CreateGroupCodeFormDTO dto = ConvertUtils.sourceToTarget(formDTO, CreateGroupCodeFormDTO.class); + dto.setType(GroupCodeConstant.CODE_TYPE_INVITE); + url = createGroupCode(dto, true); + if (StringUtils.isBlank(url)) { + logger.error(String.format("生成小组二维码失败,小组Id:%s", formDTO.getGroupId())); + throw new RenException("获取小组码基本信息失败"); + } + } + headUrl = resultDTO.getGroupHeadPhoto(); + url = resultDTO.getGroupCodeUrl(); + + //2.图片的url,服务器域名端口+storage+阿里云相对路径,storage段是为了nginx做oss代理,前缀 + String requestDomain = HttpContextUtils.getRequestServerNameAndPort(); + resultDTO.setGroupHeadPhoto(requestDomain.concat(headUrl.replaceAll(GroupCodeConstant.PATTERN, GroupCodeConstant.STORAGE))); + resultDTO.setGroupCodeUrl(requestDomain.concat(url.replaceAll(GroupCodeConstant.PATTERN, GroupCodeConstant.STORAGE))); + return resultDTO; + } + +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java index cd3266e76e..5a2a9915cb 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java @@ -28,6 +28,10 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.user.LoginUserUtil; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.scan.param.ImgScanParamDTO; import com.epmet.commons.tools.scan.param.ImgTaskDTO; import com.epmet.commons.tools.scan.param.TextScanParamDTO; @@ -51,6 +55,7 @@ import com.epmet.modules.group.entity.GroupEditSubmitRecordEntity; import com.epmet.modules.group.entity.ResiGroupEntity; import com.epmet.modules.group.entity.ResiGroupOperationEntity; import com.epmet.modules.group.redis.ResiGroupRedis; +import com.epmet.modules.group.service.ResiGroupCodeService; import com.epmet.modules.group.service.ResiGroupOperationService; import com.epmet.modules.group.service.ResiGroupService; import com.epmet.modules.group.service.ResiGroupStatisticalService; @@ -71,6 +76,7 @@ import com.epmet.resi.group.dto.member.GroupMemeberOperationDTO; import com.epmet.resi.group.dto.member.ResiGroupMemberDTO; import com.epmet.resi.group.dto.member.ResiGroupMemberInfoRedisDTO; import com.github.pagehelper.PageHelper; +import com.epmet.resi.group.dto.member.form.EditAuditSwitchFormDTO; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -155,6 +161,9 @@ public class ResiGroupServiceImpl extends BaseServiceImpl page(Map params) { IPage page = baseDao.selectPage( @@ -555,6 +564,18 @@ public class ResiGroupServiceImpl extends BaseServiceImpl param = new HashMap<>(); @@ -793,7 +814,7 @@ public class ResiGroupServiceImpl extends BaseServiceImpl().ok(resultDTO); @@ -984,12 +1005,30 @@ public class ResiGroupServiceImpl extends BaseServiceImpl accetInvitationV2(@LoginUser TokenDto tokenDto, @RequestBody AccetInvitationFormDTO formDTO) { + formDTO.setUserId(tokenDto.getUserId()); + formDTO.setApp(tokenDto.getApp()); + ValidatorUtils.validateEntity(formDTO); + return new Result().ok(groupInvitationService.accetInvitationV2(formDTO)); + } } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/entity/GroupInvitationEntity.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/entity/GroupInvitationEntity.java index 5595d7fd5c..bba85a4635 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/entity/GroupInvitationEntity.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/entity/GroupInvitationEntity.java @@ -68,4 +68,9 @@ public class GroupInvitationEntity extends BaseEpmetEntity { */ private Date validEndTime; + /** + * 邀请链接:invited;扫码:scancode + */ + private String invitationType; + } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/service/GroupInvitationService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/service/GroupInvitationService.java index 053c4e036e..44f61b26ec 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/service/GroupInvitationService.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/service/GroupInvitationService.java @@ -25,6 +25,7 @@ import com.epmet.resi.group.dto.invitation.GroupInvitationDTO; import com.epmet.resi.group.dto.invitation.form.AccetInvitationFormDTO; import com.epmet.resi.group.dto.invitation.form.CreateGroupInvitationFormDTO; import com.epmet.resi.group.dto.invitation.form.LinkGroupInfoFormDTO; +import com.epmet.resi.group.dto.invitation.result.AcceptInvitationResultDTO; import com.epmet.resi.group.dto.invitation.result.CreateGroupInvitationResultDTO; import com.epmet.resi.group.dto.invitation.result.LinkGroupInfoResultDTO; @@ -103,11 +104,20 @@ public interface GroupInvitationService extends BaseService * @param formDTO * @Author yinzuomei - * @Description 生成邀请连接 + * @Description 生成邀请连接-链接 * @Date 2020/3/31 22:50 **/ CreateGroupInvitationResultDTO createGroupInvitation(CreateGroupInvitationFormDTO formDTO); + /** + * @return com.epmet.commons.tools.utils.Result + * @param formDTO + * @Author liushaowen + * @Description 生成邀请连接-扫码 + * @Date 2020-11-17 13:58 + **/ + CreateGroupInvitationResultDTO createGroupScanCodeInvitation(CreateGroupInvitationFormDTO formDTO); + /** * @return com.epmet.commons.tools.utils.Result * @param formDTO @@ -124,5 +134,12 @@ public interface GroupInvitationService extends BaseService page(Map params) { @@ -181,6 +185,41 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl + * @Author liushaowen + * @Description 生成邀请连接-扫码 + * @Date 2020-11-17 13:58 + **/ + @Override + public CreateGroupInvitationResultDTO createGroupScanCodeInvitation(CreateGroupInvitationFormDTO formDTO) { + //1、只有群主可以邀请新成员(这块界面限制死了,只有群主才能看到邀请新成员按钮) + //2、审核通过(讨论中)的群才可以分享邀请连接 + ResiGroupDTO resiGroupDTO = resiGroupService.get(formDTO.getGroupId()); + if (!GroupStateConstant.GROUP_APPROVED.equals(resiGroupDTO.getState())) { + logger.error(String.format("生成群成员链接失败,原因:%s",EpmetErrorCode.INVITE_NEW_MEMBER.getMsg())); + throw new RenException(EpmetErrorCode.INVITE_NEW_MEMBER.getCode()); + } + //3、插入一条邀请记录 + GroupInvitationEntity groupInvitationEntity = new GroupInvitationEntity(); + groupInvitationEntity.setInviterUserId(formDTO.getUserId()); + groupInvitationEntity.setInviterCustomerId(resiGroupDTO.getCustomerId()); + groupInvitationEntity.setInviterGridId(resiGroupDTO.getGridId()); + //添加类型字段 scancode + groupInvitationEntity.setInvitationType(GroupStateConstant.GROUP_SCANCODE); + //暂定50年有效期 + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) + NumConstant.FIFTY); + groupInvitationEntity.setValidEndTime(calendar.getTime()); + groupInvitationEntity.setResiGroupId(formDTO.getGroupId()); insert(groupInvitationEntity); CreateGroupInvitationResultDTO resultDTO = new CreateGroupInvitationResultDTO(); resultDTO.setInvitationId(groupInvitationEntity.getId()); @@ -206,6 +245,13 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl result=resiGuideFeignClient.enterGrid(userEnterGridFormDTO); + if (!result.success() || null == result.getData()) { + logger.error(String.format("用户同意邀请进组,进入网格失败。入参:userId【%s】、invitationId【%s】、groupId【%s】、customerId【%s】、gridId【%s】", + formDTO.getUserId(), formDTO.getInvitationId(), + groupInvitationDTO.getResiGroupId()), + resiGroupDTO.getCustomerId(), resiGroupDTO.getGridId()); + logger.error(String.format("用户同意邀请进组,进入网格失败。当前接口返回8000,调用enterGrid接口返回", result.toString())); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } + //4、校验是否已经注册居民 + if(null==result.getData().getUserRoleList()||result.getData().getUserRoleList().size()==0){ + logger.error(String.format("用户同意邀请进组失败,返回角色列表为空错误编码%s,错误提示%s",EpmetErrorCode.CANNOT_JOIN_GROUP.getCode(),EpmetErrorCode.CANNOT_JOIN_GROUP.getMsg())); + throw new RenException(EpmetErrorCode.CANNOT_JOIN_GROUP.getCode()); + } + //2020.11.17 sun 新增扫描或邀请进组是否需要审核的逻辑 start + GroupMemeberOperationDTO groupMemeberOperation = new GroupMemeberOperationDTO(); + groupMemeberOperation.setGroupId(resiGroupDTO.getId()); + groupMemeberOperation.setCustomerUserId(formDTO.getUserId()); + groupMemeberOperation.setEnterGroupType(groupInvitationDTO.getInvitationType()); + groupMemeberOperation.setGroupInvitationId(formDTO.getInvitationId()); + groupMemeberOperation.setOperateUserId(formDTO.getUserId()); + //邀请入组 + if (StringUtils.isNotBlank(groupInvitationDTO.getInvitationType())) { + if (groupInvitationDTO.getInvitationType().equals(GroupStateConstant.GROUP_INVITED)) { + groupMemeberOperation.setOperateDes(UserMessageConstant.INVITED_OPERATE); + //扫码入组 + } else if (groupInvitationDTO.getInvitationType().equals(GroupStateConstant.GROUP_SCANCODE)) { + groupMemeberOperation.setOperateDes(UserMessageConstant.SCANCODE_OPERATE); + } + } else {//兼容旧程序 + groupMemeberOperation.setOperateDes(UserMessageConstant.INVITED_OPERATE); + } + //入组审核开关是开启状态则需要组长审核 + if (StringUtils.isNotBlank(resiGroupDTO.getAuditSwitch()) && GroupStateConstant.AUDIT_SWITCH_OPEN.equals(resiGroupDTO.getAuditSwitch())) { + groupMemeberOperation.setOperateStatus(MemberStateConstant.UNDER_AUDITTING); + //新增一条入组申请 + groupMemeberOperationService.accetInvitation(groupMemeberOperation); + //给小组长推送站内信 + resiGroupMemberServiceImpl.sendMessageToGroupLeader(resiGroupDTO, formDTO.getUserId()); + resultDTO.setAwaitAudit(true); + return resultDTO; + } + UserRoleDTO userRoleDTO = this.getUserRoleDTO(result.getData().getUserRoleList()); + //5、新增一条邀请入群、直接审核通过的入群记录 + groupMemeberOperation.setOperateStatus(MemberStateConstant.APPROVED); + //2020.11.17 end + groupMemeberOperationService.accetInvitation(groupMemeberOperation); + //6、直接加入群成员关系表 + //如果是之前被移除的,则修改resi_group_member记录 + ResiGroupMemberDTO resiGroupMemberDTO = new ResiGroupMemberDTO(); + ResiGroupMemberDTO resiGroupMember = resiGroupMemberDao.selectGroupMemberInfo(groupInvitationDTO.getResiGroupId(), formDTO.getUserId()); + if (null != resiGroupMember) { + resiGroupMemberDTO.setId(resiGroupMember.getId()); + } + resiGroupMemberDTO.setCustomerUserId(groupMemeberOperation.getCustomerUserId()); + resiGroupMemberDTO.setResiGroupId(groupMemeberOperation.getGroupId()); + resiGroupMemberDTO.setGroupLeaderFlag(LeaderFlagConstant.GROUP_MEMBER); + resiGroupMemberDTO.setEnterGroupType(groupMemeberOperation.getEnterGroupType()); + resiGroupMemberDTO.setStatus(MemberStateConstant.APPROVED); + resiGroupMemberDTO.setCreatedBy(groupMemeberOperation.getCustomerUserId()); + resiGroupMemberService.saveOrUpdate(resiGroupMemberDTO); + //7、修改群统计值 + resiGroupMemberDao.updateResiGroupStatistical(groupMemeberOperation.getGroupId(), userRoleDTO); ResiGroupInfoRedisDTO groupCache = resiGroupRedis.get(groupInvitationDTO.getResiGroupId()); if(null != groupCache && null != groupCache.getGroupStatisticalInfo()){ @@ -387,6 +551,7 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl userRoleList) { @@ -428,7 +593,17 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl resultUserInfo = epmetUserFeignClient.getUserResiInfoDTO(userResiInfoFormDTO); if (!resultUserInfo.success() || null == resultUserInfo.getData()) { - logger.error(String.format("居民申请入群,给组长发送消息通知错误,调用%s服务查询申请用户名称失败,入参%s", ServiceConstant.EPMET_USER_SERVER, JSON.toJSONString(userResiInfoFormDTO))); + logger.warn(String.format("居民申请入群,给组长发送消息通知错误,调用%s服务查询申请用户名称失败,入参%s", ServiceConstant.EPMET_USER_SERVER, JSON.toJSONString(userResiInfoFormDTO))); } else { currentUserName = resultUserInfo.getData().getShowName(); } @@ -288,7 +288,7 @@ public class ResiGroupMemberServiceImpl extends BaseServiceImpl list = baseDao.selectListGroupMember(groupMemberListFormDTO); if (null == list || list.size() == 0) { - logger.error(String.format("群成员列表查询列表为空,selectListGroupMember入参%s",JSON.toJSONString(groupMemberListFormDTO))); + logger.warn(String.format("群成员列表查询列表为空,selectListGroupMember入参%s",JSON.toJSONString(groupMemberListFormDTO))); return new ArrayList<>(); } List userIdList=new ArrayList<>(); @@ -424,13 +424,13 @@ public class ResiGroupMemberServiceImpl extends BaseServiceImpl + + + + + + + diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupDao.xml index 356844a5c2..ccc4d1b945 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupDao.xml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupDao.xml @@ -150,7 +150,8 @@ AND gmo.GROUP_ID = rg.id AND gmo.OPERATE_STATUS = 'under_auditting' ) AS totalApplyingMember, - rgs.TOTAL_TOPICS + rgs.TOTAL_TOPICS, + rg.AUDIT_SWITCH FROM resi_group rg LEFT JOIN resi_group_statistical rgs ON ( rg.id = rgs.RESI_GROUP_ID ) diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/member/ResiGroupMemberDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/member/ResiGroupMemberDao.xml index 7910965741..f125ebb551 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/member/ResiGroupMemberDao.xml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/member/ResiGroupMemberDao.xml @@ -30,8 +30,9 @@ gmo.CUSTOMER_USER_ID AS applyUserId, NULL AS applyUserHeadPhoto, NULL AS applyUserName, - gmo.OPERATE_DES AS applyReason, - gmo.OPERATE_STATUS as status + IFNULL(gmo.OPERATE_DES, '') AS applyReason, + gmo.OPERATE_STATUS as status, + gmo.ENTER_GROUP_TYPE as enterGroupType FROM group_memeber_operation gmo WHERE diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index 8c6458ce44..b31f94ddff 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -411,6 +411,14 @@ public interface EpmetUserOpenFeignClient { @PostMapping("/epmetuser/govstaffrole/list-roles-by-rolekey/{role-key}") Result> listRolesByRoleKey(@PathVariable("role-key") String roleKey); + /** + * 根据userId集合查询用户注册信息 + * @author sun + */ + @PostMapping("/epmetuser/userresiinfo/getuserresiinfolist") + Result> getUserResiInfoList(@RequestBody UserResiInfoListFormDTO userResiInfoListFormDTO); + + /** * @Description 个人中心-我的建议列表 * @param dto diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index 938973838a..69371a19cd 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -283,6 +283,11 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "listRolesByRoleKey", roleKey); } + @Override + public Result> getUserResiInfoList(UserResiInfoListFormDTO fromDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getUserResiInfoList", fromDTO); + } + @Override public Result> myAdviceList(MyAdviceListFormDTO dto) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "myAdviceList", dto);