Commit 0641f793a374b8056c97cc226156776858cc3608

Authored by YunaiV
1 parent 8e64de0a

【代码评审】全局:微信小程序码

yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/AppSocialUserController.java
@@ -63,9 +63,10 @@ public class AppSocialUserController { @@ -63,9 +63,10 @@ public class AppSocialUserController {
63 return success(BeanUtils.toBean(socialUser, AppSocialUserRespVO.class)); 63 return success(BeanUtils.toBean(socialUser, AppSocialUserRespVO.class));
64 } 64 }
65 65
  66 + // TODO @puhui999:是不是 url 叫 wxa-qrcode?然后相关的方法,都做下调整哈;因为是微信小程序的二维码
66 @PostMapping("/wxacode") 67 @PostMapping("/wxacode")
67 @Operation(summary = "获得微信小程序码") 68 @Operation(summary = "获得微信小程序码")
68 - @PreAuthenticated 69 + @PreAuthenticated // TODO @puhui999:可能不需要登录
69 public CommonResult<String> getWxQrcode(@RequestBody @Valid AppSocialWxQrcodeReqVO reqVO) { 70 public CommonResult<String> getWxQrcode(@RequestBody @Valid AppSocialWxQrcodeReqVO reqVO) {
70 byte[] wxQrcode = socialUserApi.getWxQrcode(BeanUtils.toBean(reqVO, SocialWxQrcodeReqDTO.class).setUserId(getLoginUserId()) 71 byte[] wxQrcode = socialUserApi.getWxQrcode(BeanUtils.toBean(reqVO, SocialWxQrcodeReqDTO.class).setUserId(getLoginUserId())
71 .setUserType(UserTypeEnum.MEMBER.getValue()).setSocialType(reqVO.getType())); 72 .setUserType(UserTypeEnum.MEMBER.getValue()).setSocialType(reqVO.getType()));
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/social/vo/AppSocialWxQrcodeReqVO.java
@@ -7,53 +7,44 @@ import jakarta.validation.constraints.NotEmpty; @@ -7,53 +7,44 @@ import jakarta.validation.constraints.NotEmpty;
7 import jakarta.validation.constraints.NotNull; 7 import jakarta.validation.constraints.NotNull;
8 import lombok.Data; 8 import lombok.Data;
9 9
  10 +// TODO @芋艿:需要精简下参数;
10 @Schema(description = "用户 APP - 获得获取小程序码 Request VO") 11 @Schema(description = "用户 APP - 获得获取小程序码 Request VO")
11 @Data 12 @Data
12 public class AppSocialWxQrcodeReqVO { 13 public class AppSocialWxQrcodeReqVO {
13 14
  15 + // TODO @puhui999:这个后续不用前端传递,应该是后端搞的
14 private static String SCENE = "1011"; // 默认场景值 1011 扫描二维码 16 private static String SCENE = "1011"; // 默认场景值 1011 扫描二维码
  17 + // TODO @puhui999:这个默认是不是 release 哈?
15 private static String ENV_VERSION = "develop"; // 小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop" 18 private static String ENV_VERSION = "develop"; // 小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop"
  19 + // TODO @puhui999:这个去掉;因为本身就是 430 啦;
16 private static Integer WIDTH = 430; // 二维码宽度 20 private static Integer WIDTH = 430; // 二维码宽度
  21 + // TODO @puhui999:这个去掉;因为本身就是 true 啦;
17 private static Boolean AUTO_COLOR = true; // 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 22 private static Boolean AUTO_COLOR = true; // 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
  23 + // TODO @puhui999:这个去掉;因为本身就是 true 啦;
18 private static Boolean CHECK_PATH = true; // 默认true 检查 page 是否存在 24 private static Boolean CHECK_PATH = true; // 默认true 检查 page 是否存在
  25 + // TODO @puhui999:这个去掉;因为本身就是 true 啦;
19 private static Boolean IS_HYALINE = true; // 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码 26 private static Boolean IS_HYALINE = true; // 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码
20 27
21 - /**  
22 - * 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~, 其它字符请自行编码为合法字符  
23 - * (因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)  
24 - */  
25 - @Schema(description = "场景值/页面参数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1001") 28 + @Schema(description = "场景值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1001")
26 private String scene = SCENE; 29 private String scene = SCENE;
27 - /**  
28 - * 页面路径  
29 - */ 30 +
30 @Schema(description = "页面路径", requiredMode = Schema.RequiredMode.REQUIRED, example = "pages/goods/index") 31 @Schema(description = "页面路径", requiredMode = Schema.RequiredMode.REQUIRED, example = "pages/goods/index")
31 @NotEmpty(message = "页面路径不能为空") 32 @NotEmpty(message = "页面路径不能为空")
32 private String path; 33 private String path;
33 - /**  
34 - * 要打开的小程序版本。默认是开发版。  
35 - */ 34 +
  35 + // TODO @puhui999:这个应该不传递哈
36 @Schema(description = "小程序版本", requiredMode = Schema.RequiredMode.REQUIRED, example = "develop") 36 @Schema(description = "小程序版本", requiredMode = Schema.RequiredMode.REQUIRED, example = "develop")
37 private String envVersion = ENV_VERSION; 37 private String envVersion = ENV_VERSION;
38 - /**  
39 - * 二维码宽度  
40 - */ 38 +
41 @Schema(description = "二维码宽度", requiredMode = Schema.RequiredMode.REQUIRED, example = "430") 39 @Schema(description = "二维码宽度", requiredMode = Schema.RequiredMode.REQUIRED, example = "430")
42 private Integer width = WIDTH; 40 private Integer width = WIDTH;
43 - /**  
44 - * 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调  
45 - */ 41 +
46 @Schema(description = "是/否自动配置线条颜色", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") 42 @Schema(description = "是/否自动配置线条颜色", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
47 private Boolean isAutoColor = AUTO_COLOR; 43 private Boolean isAutoColor = AUTO_COLOR;
48 - /**  
49 - * 默认true 检查 page 是否存在,为 true 时 page 必须是已经发布的小程序存在的页面(否则报错);  
50 - * 为 false 时允许小程序未发布或者 page 不存在,但 page 有数量上限(60000个)请勿滥用  
51 - */ 44 +
52 @Schema(description = "是/否检查 page 是否存在", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") 45 @Schema(description = "是/否检查 page 是否存在", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
53 private Boolean isCheckPath = CHECK_PATH; 46 private Boolean isCheckPath = CHECK_PATH;
54 - /**  
55 - * 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码  
56 - */ 47 +
57 @Schema(description = "是/否需要透明底色", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") 48 @Schema(description = "是/否需要透明底色", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
58 private Boolean isHyaline = IS_HYALINE; 49 private Boolean isHyaline = IS_HYALINE;
59 50
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/dto/SocialWxQrcodeReqDTO.java
@@ -7,9 +7,17 @@ import jakarta.validation.constraints.NotEmpty; @@ -7,9 +7,17 @@ import jakarta.validation.constraints.NotEmpty;
7 import jakarta.validation.constraints.NotNull; 7 import jakarta.validation.constraints.NotNull;
8 import lombok.Data; 8 import lombok.Data;
9 9
  10 +/**
  11 + * 获取小程序码 Request DTO
  12 + *
  13 + * @see <a href="https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/qr-code/getUnlimitedQRCode.html">获取不限制的小程序码</a>
  14 + *
  15 + * @author HUIHUI
  16 + */
10 @Data 17 @Data
11 public class SocialWxQrcodeReqDTO { 18 public class SocialWxQrcodeReqDTO {
12 19
  20 + // TODO @puhui999:userId、userType 应该后续要搞成抽象参数;说白了,就是 path 的参数; socialType 应该去掉,因为就是微信的;
13 /** 21 /**
14 * 用户编号 22 * 用户编号
15 */ 23 */
@@ -30,9 +38,9 @@ public class SocialWxQrcodeReqDTO { @@ -30,9 +38,9 @@ public class SocialWxQrcodeReqDTO {
30 private Integer socialType; 38 private Integer socialType;
31 39
32 /** 40 /**
33 - * 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~, 其它字符请自行编码为合法字符  
34 - * (因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式) 41 + * 场景
35 */ 42 */
  43 + @NotEmpty(message = "场景不能为空")
36 private String scene; 44 private String scene;
37 /** 45 /**
38 * 页面路径 46 * 页面路径
@@ -40,24 +48,30 @@ public class SocialWxQrcodeReqDTO { @@ -40,24 +48,30 @@ public class SocialWxQrcodeReqDTO {
40 @NotEmpty(message = "页面路径不能为空") 48 @NotEmpty(message = "页面路径不能为空")
41 private String path; 49 private String path;
42 /** 50 /**
43 - * 要打开的小程序版本。默认是开发版。 51 + * 要打开的小程序版本
44 */ 52 */
45 private String envVersion; 53 private String envVersion;
46 /** 54 /**
47 * 二维码宽度 55 * 二维码宽度
48 */ 56 */
49 private Integer width; 57 private Integer width;
  58 +
  59 + // TODO @puhui999:autoColor
  60 +
50 /** 61 /**
51 - * 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 62 + * 是否需要透明底色
52 */ 63 */
53 private Boolean isAutoColor; 64 private Boolean isAutoColor;
  65 +
  66 + // TODO @puhui999: checkPath
54 /** 67 /**
55 - * 默认true 检查 page 是否存在,为 true 时 page 必须是已经发布的小程序存在的页面(否则报错);  
56 - * 为 false 时允许小程序未发布或者 page 不存在,但 page 有数量上限(60000个)请勿滥用 68 + * 是否检查 page 是否存在
57 */ 69 */
58 private Boolean isCheckPath; 70 private Boolean isCheckPath;
  71 +
  72 + // TODO @puhui999: hyaline
59 /** 73 /**
60 - * 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码 74 + * 是否需要透明底色
61 */ 75 */
62 private Boolean isHyaline; 76 private Boolean isHyaline;
63 77
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialUserApiImpl.java
@@ -43,6 +43,7 @@ public class SocialUserApiImpl implements SocialUserApi { @@ -43,6 +43,7 @@ public class SocialUserApiImpl implements SocialUserApi {
43 return socialUserService.getSocialUserByCode(userType, socialType, code, state); 43 return socialUserService.getSocialUserByCode(userType, socialType, code, state);
44 } 44 }
45 45
  46 + // TODO @puhui999:貌似搞到 SocialClientApiImpl 更合适,二维码和用户关系不大;这样 socialUserService 也不用绕一次了
46 @Override 47 @Override
47 public byte[] getWxQrcode(SocialWxQrcodeReqDTO reqVO) { 48 public byte[] getWxQrcode(SocialWxQrcodeReqDTO reqVO) {
48 return socialUserService.getWxQrcode(reqVO); 49 return socialUserService.getWxQrcode(reqVO);