From 380ec112217a442b31172a527fb7f0c2ead7d428 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Thu, 16 May 2024 16:57:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=BE=AE=E4=BF=A1=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/social/AppSocialUserController.java | 2 +- .../app/social/vo/AppSocialWxQrcodeReqVO.java | 37 ++++++------------ .../api/social/dto/SocialWxQrcodeReqDTO.java | 39 ++----------------- .../social/SocialClientServiceImpl.java | 7 ++-- 4 files changed, 20 insertions(+), 65 deletions(-) diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java index a07e6324f..6e3973525 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java @@ -70,7 +70,7 @@ public class AppSocialUserController { @Operation(summary = "获得微信小程序码(base64 image)") public CommonResult getWxQrcode(@RequestBody @Valid AppSocialWxQrcodeReqVO reqVO) { byte[] wxQrcode = socialClientApi.getWxaQrcode(BeanUtils.toBean(reqVO, SocialWxQrcodeReqDTO.class) - .setUserId(getLoginUserId()).setUserType(UserTypeEnum.MEMBER.getValue()).setSocialType(reqVO.getType())); + .setEnvVersion(AppSocialWxQrcodeReqVO.ENV_VERSION)); return success("data:image/png;base64," + Base64.getEncoder().encodeToString(wxQrcode)); } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxQrcodeReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxQrcodeReqVO.java index 6465b2384..10321519c 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxQrcodeReqVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxQrcodeReqVO.java @@ -1,31 +1,25 @@ package cn.iocoder.yudao.module.member.controller.app.social.vo; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; import lombok.Data; -// TODO @芋艿:需要精简下参数; + @Schema(description = "用户 APP - 获得获取小程序码 Request VO") @Data public class AppSocialWxQrcodeReqVO { - // TODO @puhui999:这个后续不用前端传递,应该是后端搞的。 - // 页面路径不能携带参数(参数请放在scene字段里) - private static String SCENE = ""; // 默认场景值 1011 扫描二维码 - // TODO @puhui999:这个默认是不是 release 哈? - private static String ENV_VERSION = "develop"; // 小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop" - // TODO @puhui999:这个去掉;因为本身就是 430 啦; + // TODO @puhui999: 没有默认值 getQrcodeService().createWxaCodeUnlimitBytes() 转类型会报错 🤣 + public static String ENV_VERSION = "release"; // 小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop" + private static String SCENE = ""; // 页面路径不能携带参数(参数请放在scene字段里) private static Integer WIDTH = 430; // 二维码宽度 - // TODO @puhui999:这个去掉;因为本身就是 true 啦; private static Boolean AUTO_COLOR = true; // 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 - // TODO @puhui999:这个去掉;因为本身就是 true 啦; private static Boolean CHECK_PATH = true; // 默认true 检查 page 是否存在 - // TODO @puhui999:这个去掉;因为本身就是 true 啦; - private static Boolean IS_HYALINE = true; // 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码 + private static Boolean HYALINE = true; // 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码 + /** + * 页面路径不能携带参数(参数请放在scene字段里) + */ @Schema(description = "场景值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1001") private String scene = SCENE; @@ -37,25 +31,16 @@ public class AppSocialWxQrcodeReqVO { @NotEmpty(message = "页面路径不能为空") private String path; - // TODO @puhui999:这个应该不传递哈 - @Schema(description = "小程序版本", requiredMode = Schema.RequiredMode.REQUIRED, example = "develop") - private String envVersion = ENV_VERSION; - @Schema(description = "二维码宽度", requiredMode = Schema.RequiredMode.REQUIRED, example = "430") private Integer width = WIDTH; @Schema(description = "是/否自动配置线条颜色", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean isAutoColor = AUTO_COLOR; + private Boolean autoColor = AUTO_COLOR; @Schema(description = "是/否检查 page 是否存在", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean isCheckPath = CHECK_PATH; + private Boolean checkPath = CHECK_PATH; @Schema(description = "是/否需要透明底色", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - private Boolean isHyaline = IS_HYALINE; - - @Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") - @InEnum(SocialTypeEnum.class) - @NotNull(message = "社交平台的类型不能为空") - private Integer type; + private Boolean hyaline = HYALINE; } diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxQrcodeReqDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxQrcodeReqDTO.java index d5e7f194f..efda43e81 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxQrcodeReqDTO.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxQrcodeReqDTO.java @@ -1,42 +1,17 @@ package cn.iocoder.yudao.module.system.api.social.dto; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; import lombok.Data; /** * 获取小程序码 Request DTO * - * @see 获取不限制的小程序码 - * * @author HUIHUI + * @see 获取不限制的小程序码 */ @Data public class SocialWxQrcodeReqDTO { - // TODO @puhui999:userId、userType 应该后续要搞成抽象参数;说白了,就是 path 的参数; socialType 应该去掉,因为就是微信的; - /** - * 用户编号 - */ - @NotNull(message = "用户编号不能为空") - private Long userId; - /** - * 用户类型 - */ - @InEnum(UserTypeEnum.class) - @NotNull(message = "用户类型不能为空") - private Integer userType; - - /** - * 社交平台的类型 - */ - @InEnum(SocialTypeEnum.class) - @NotNull(message = "社交平台的类型不能为空") - private Integer socialType; - /** * 场景 */ @@ -56,23 +31,17 @@ public class SocialWxQrcodeReqDTO { */ private Integer width; - // TODO @puhui999:autoColor - /** * 是否需要透明底色 */ - private Boolean isAutoColor; - - // TODO @puhui999: checkPath + private Boolean autoColor; /** * 是否检查 page 是否存在 */ - private Boolean isCheckPath; - - // TODO @puhui999: hyaline + private Boolean checkPath; /** * 是否需要透明底色 */ - private Boolean isHyaline; + private Boolean hyaline; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java index aeff40cce..41b27b171 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java @@ -9,6 +9,7 @@ import cn.hutool.core.lang.Assert; import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ReflectUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.cache.CacheUtils; import cn.iocoder.yudao.framework.common.util.http.HttpUtils; @@ -230,11 +231,11 @@ public class SocialClientServiceImpl implements SocialClientService { @Override public byte[] getWxaQrcode(SocialWxQrcodeReqDTO reqVO) { - WxMaService service = getWxMaService(reqVO.getUserType()); + WxMaService service = getWxMaService(UserTypeEnum.MEMBER.getValue()); try { return service.getQrcodeService().createWxaCodeUnlimitBytes(reqVO.getScene(), reqVO.getPath(), - reqVO.getIsCheckPath(), reqVO.getEnvVersion(), reqVO.getWidth(), reqVO.getIsAutoColor(), - null, reqVO.getIsHyaline()); + reqVO.getCheckPath(), reqVO.getEnvVersion(), reqVO.getWidth(), reqVO.getAutoColor(), + null, reqVO.getHyaline()); } catch (WxErrorException e) { log.error("[getWxQrcode][reqVO({})) 获得小程序码失败]", reqVO, e); throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_QRCODE_ERROR);