Browse Source
# Conflicts: # epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/result/ApplyingMemberResultDTO.java # epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java # epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java # epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java # epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java # epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java # epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.javamaster
58 changed files with 1801 additions and 29 deletions
@ -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; |
|||
} |
@ -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; |
|||
} |
|||
} |
@ -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/"; |
|||
} |
@ -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) { |
|||
|
|||
} |
|||
} |
@ -0,0 +1,101 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.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; |
|||
|
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
} |
@ -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 {} |
|||
|
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
} |
@ -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(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,112 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.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<PageData<ResiGroupCodeDTO>> page(@RequestParam Map<String, Object> params){ |
|||
PageData<ResiGroupCodeDTO> page = resiGroupCodeService.page(params); |
|||
return new Result<PageData<ResiGroupCodeDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
public Result<ResiGroupCodeDTO> get(@PathVariable("id") String id){ |
|||
ResiGroupCodeDTO data = resiGroupCodeService.get(id); |
|||
return new Result<ResiGroupCodeDTO>().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<String> createGroupCode(@RequestBody CreateGroupCodeFormDTO dto){ |
|||
ValidatorUtils.validateEntity(dto); |
|||
return new Result<String>().ok(resiGroupCodeService.createGroupCode(dto, true)); |
|||
} |
|||
|
|||
@RequestMapping("getgroupcode") |
|||
public Result<String> getGroupCode(@RequestBody GetGroupCodeFormDTO dto){ |
|||
ValidatorUtils.validateEntity(dto); |
|||
return resiGroupCodeService.getGroupCode(dto); |
|||
} |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @Description 获取生成海报(小组码)信息 |
|||
* @author sun |
|||
*/ |
|||
@PostMapping("groupcodebasicinfo") |
|||
public Result<GroupCodeBasicInfoResultDTO> groupCodeBasicInfo(@RequestBody GroupCodeBasicInfoFormDTO formDTO) { |
|||
ValidatorUtils.validateEntity(formDTO, GroupCodeBasicInfoFormDTO.GroupCodeInfo.class); |
|||
return new Result<GroupCodeBasicInfoResultDTO>().ok(resiGroupCodeService.groupCodeBasicInfo(formDTO)); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,41 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.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<ResiGroupCodeEntity> { |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @Description 获取生成海报(小组码)信息 |
|||
* @author sun |
|||
*/ |
|||
GroupCodeBasicInfoResultDTO selectGroupCodeBasicInfo(GroupCodeBasicInfoFormDTO formDTO); |
|||
} |
@ -0,0 +1,72 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.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; |
|||
|
|||
} |
@ -0,0 +1,58 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.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<String,Object> getAuthorizerRefreshToken(String key){ |
|||
Map<String, Object> result = redisUtils.hGetAll("epmet:wechartthird:authorizerrefreshtoken:" + key); |
|||
return result; |
|||
} |
|||
} |
@ -0,0 +1,126 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.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<ResiGroupCodeEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<ResiGroupCodeDTO> |
|||
* @author generator |
|||
* @date 2020-11-13 |
|||
*/ |
|||
PageData<ResiGroupCodeDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<ResiGroupCodeDTO> |
|||
* @author generator |
|||
* @date 2020-11-13 |
|||
*/ |
|||
List<ResiGroupCodeDTO> list(Map<String, Object> 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<java.lang.String> |
|||
* @Author liushaowen |
|||
* @Date 2020/11/16 9:37 |
|||
*/ |
|||
Result<String> getGroupCode(GetGroupCodeFormDTO dto); |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @Description 获取生成海报(小组码)信息 |
|||
* @author sun |
|||
*/ |
|||
GroupCodeBasicInfoResultDTO groupCodeBasicInfo(GroupCodeBasicInfoFormDTO formDTO); |
|||
} |
@ -0,0 +1,304 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.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<ResiGroupCodeDao, ResiGroupCodeEntity> 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<ResiGroupCodeDTO> page(Map<String, Object> params) { |
|||
IPage<ResiGroupCodeEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
getWrapper(params) |
|||
); |
|||
return getPageData(page, ResiGroupCodeDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<ResiGroupCodeDTO> list(Map<String, Object> params) { |
|||
List<ResiGroupCodeEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, ResiGroupCodeDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<ResiGroupCodeEntity> getWrapper(Map<String, Object> params) { |
|||
String id = (String) params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<ResiGroupCodeEntity> 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<java.lang.String> |
|||
* @Description 获取群组二维码 |
|||
* @Author liushaowen |
|||
* @Date 2020/11/16 9:37 |
|||
*/ |
|||
@Override |
|||
public Result<String> getGroupCode(GetGroupCodeFormDTO dto) { |
|||
ResiGroupCodeEntity codeByGroupId = getCode(dto.getGroupId(), dto.getType()); |
|||
if (codeByGroupId != null) { |
|||
//数据库有数据
|
|||
return new Result<String>().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<String>().ok(url); |
|||
} |
|||
} |
|||
|
|||
private ResiGroupCodeEntity getCode(String groupId, String type) { |
|||
if (StringUtils.isBlank(groupId) || StringUtils.isBlank(type)) { |
|||
throw new RenException("获取二维码失败,groupId或type为空"); |
|||
} |
|||
QueryWrapper<ResiGroupCodeEntity> 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<UploadImgResultDTO> 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; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,21 @@ |
|||
package com.epmet.modules.test; |
|||
|
|||
import com.epmet.commons.tools.utils.HttpContextUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
|
|||
@RestController |
|||
@RequestMapping("test") |
|||
public class TestController { |
|||
|
|||
@PostMapping("get-req-info") |
|||
public Result testDomain(HttpServletRequest request) { |
|||
String requestServerNameAndPort = HttpContextUtils.getRequestServerNameAndPort(); |
|||
return new Result().ok(requestServerNameAndPort); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,25 @@ |
|||
package com.epmet.properties; |
|||
|
|||
import lombok.Data; |
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
|
|||
/** |
|||
* 线程池属性类 |
|||
*/ |
|||
@ConfigurationProperties(prefix = "thread") |
|||
@Data |
|||
public class ThreadProperties { |
|||
|
|||
private ThreadPoolProperties threadPool; |
|||
|
|||
@Data |
|||
public static class ThreadPoolProperties { |
|||
private int corePoolSize; |
|||
private int maxPoolSize; |
|||
private int queueCapacity; |
|||
private int keepAlive; |
|||
|
|||
public ThreadPoolProperties() { |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,16 @@ |
|||
CREATE TABLE `resi_group_code` ( |
|||
`ID` varchar(64) NOT NULL COMMENT '主键', |
|||
`CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户ID', |
|||
`GRID_ID` varchar(64) NOT NULL COMMENT '网格ID', |
|||
`GROUP_ID` varchar(64) NOT NULL COMMENT '小组Id', |
|||
`INVITATION_ID` varchar(64) NOT NULL COMMENT '邀请id', |
|||
`TYPE` varchar(32) NOT NULL COMMENT '微信二维码使用类型 邀请:invite', |
|||
`URL` varchar(128) NOT NULL COMMENT '二维码路径', |
|||
`DEL_FLAG` varchar(1) NOT NULL COMMENT '删除标志', |
|||
`REVISION` int(11) NOT NULL COMMENT '乐观锁', |
|||
`CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', |
|||
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间', |
|||
`UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', |
|||
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', |
|||
PRIMARY KEY (`ID`) |
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='小组二维码 小组唯一二维码,海报码和小组码是同一个二维码,长期有效的'; |
@ -0,0 +1,9 @@ |
|||
ALTER TABLE `resi_group` |
|||
ADD COLUMN `AUDIT_SWITCH` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'open' COMMENT '进组审核open开启;close关闭' AFTER `LATEST_TOPIC_PUBLISH_DATE`; |
|||
|
|||
ALTER TABLE `group_invitation` |
|||
ADD COLUMN `INVITATION_TYPE` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'link' COMMENT '邀请链接:invited;扫码:scancode' AFTER `RESI_GROUP_ID`; |
|||
|
|||
alter table group_memeber_operation MODIFY ENTER_GROUP_TYPE varchar(32) not null comment '入群方式:(受邀请入群 - invited;主动加入 - join;created创建群自动进入;scancode扫码入群)'; |
|||
|
|||
alter table resi_group_member modify ENTER_GROUP_TYPE varchar(32) not null comment '入群方式:(受邀请入群 - invited 、 主动加入 - join、created创建群自动进入、扫码入群-scancode)'; |
@ -0,0 +1,6 @@ |
|||
ALTER TABLE `group_invitation` |
|||
DROP COLUMN `INVITATION_TYPE`; |
|||
|
|||
ALTER TABLE `group_invitation` |
|||
ADD COLUMN `INVITATION_TYPE` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'invited' COMMENT '邀请链接:invited;扫码:scancode' AFTER `RESI_GROUP_ID`; |
|||
|
@ -0,0 +1,27 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.modules.group.dao.ResiGroupCodeDao"> |
|||
|
|||
<select id="selectGroupCodeBasicInfo" resultType="com.epmet.resi.group.dto.group.result.GroupCodeBasicInfoResultDTO"> |
|||
SELECT |
|||
rg.id AS "groupId", |
|||
rg.group_name AS "groupName", |
|||
rg.group_head_photo AS "groupHeadPhoto", |
|||
rg.group_introduction AS "groupIntroduction", |
|||
rgc.URL AS "groupCodeUrl" |
|||
FROM |
|||
resi_group rg |
|||
LEFT JOIN resi_group_code rgc ON rgc.group_id = rg.id AND rgc.del_flag = '0' |
|||
WHERE |
|||
rg.del_flag = '0' |
|||
AND rg.id = #{groupId} |
|||
<if test='null != customerId and "" != customerId'> |
|||
and rg.customer_id = #{customerId} |
|||
</if> |
|||
<if test='null != gridId and "" != gridId'> |
|||
and rg.grid_id = #{gridId} |
|||
</if> |
|||
</select> |
|||
|
|||
</mapper> |
Loading…
Reference in new issue