mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 12:18:42 +08:00 
			
		
		
		
	@@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialUserBind
 | 
			
		||||
import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialUserRespVO;
 | 
			
		||||
import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialUserUnbindReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.member.controller.app.social.vo.AppSocialWxQrcodeReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.api.social.SocialClientApi;
 | 
			
		||||
import cn.iocoder.yudao.module.system.api.social.SocialUserApi;
 | 
			
		||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialUserRespDTO;
 | 
			
		||||
@@ -34,6 +35,8 @@ public class AppSocialUserController {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private SocialUserApi socialUserApi;
 | 
			
		||||
    @Resource
 | 
			
		||||
    private SocialClientApi socialClientApi;
 | 
			
		||||
 | 
			
		||||
    @PostMapping("/bind")
 | 
			
		||||
    @Operation(summary = "社交绑定,使用 code 授权码")
 | 
			
		||||
@@ -63,14 +66,12 @@ public class AppSocialUserController {
 | 
			
		||||
        return success(BeanUtils.toBean(socialUser, AppSocialUserRespVO.class));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // TODO @puhui999:是不是 url 叫 wxa-qrcode?然后相关的方法,都做下调整哈;因为是微信小程序的二维码
 | 
			
		||||
    @PostMapping("/wxacode")
 | 
			
		||||
    @Operation(summary = "获得微信小程序码")
 | 
			
		||||
    @PreAuthenticated // TODO @puhui999:可能不需要登录
 | 
			
		||||
    @PostMapping("/wxa-qrcode")
 | 
			
		||||
    @Operation(summary = "获得微信小程序码(base64 image)")
 | 
			
		||||
    public CommonResult<String> getWxQrcode(@RequestBody @Valid AppSocialWxQrcodeReqVO reqVO) {
 | 
			
		||||
        byte[] wxQrcode = socialUserApi.getWxQrcode(BeanUtils.toBean(reqVO, SocialWxQrcodeReqDTO.class).setUserId(getLoginUserId())
 | 
			
		||||
                .setUserType(UserTypeEnum.MEMBER.getValue()).setSocialType(reqVO.getType()));
 | 
			
		||||
        return success(Base64.getEncoder().encodeToString(wxQrcode));
 | 
			
		||||
        byte[] wxQrcode = socialClientApi.getWxaQrcode(BeanUtils.toBean(reqVO, SocialWxQrcodeReqDTO.class)
 | 
			
		||||
                .setEnvVersion(AppSocialWxQrcodeReqVO.ENV_VERSION));
 | 
			
		||||
        return success("data:image/png;base64," + Base64.getEncoder().encodeToString(wxQrcode));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,56 +1,46 @@
 | 
			
		||||
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:这个后续不用前端传递,应该是后端搞的
 | 
			
		||||
    private static String SCENE = "1011"; // 默认场景值 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;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 默认是主页,页面 page,例如 pages/index/index,根路径前不要填加 /,不能携带参数(参数请放在scene字段里),
 | 
			
		||||
     * 如果不填写这个字段,默认跳主页面。scancode_time为系统保留参数,不允许配置
 | 
			
		||||
     */
 | 
			
		||||
    @Schema(description = "页面路径", requiredMode = Schema.RequiredMode.REQUIRED, example = "pages/goods/index")
 | 
			
		||||
    @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;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -11,6 +11,9 @@ import lombok.NoArgsConstructor;
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
public class AppMemberUserInfoRespVO {
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
 | 
			
		||||
    private Long id;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
 | 
			
		||||
    private String nickname;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.member.dal.dataobject.tag.MemberTagDO;
 | 
			
		||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
 | 
			
		||||
import org.mapstruct.Mapper;
 | 
			
		||||
import org.mapstruct.Mapping;
 | 
			
		||||
import org.mapstruct.Mappings;
 | 
			
		||||
import org.mapstruct.factory.Mappers;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
@@ -27,8 +28,12 @@ public interface MemberUserConvert {
 | 
			
		||||
 | 
			
		||||
    AppMemberUserInfoRespVO convert(MemberUserDO bean);
 | 
			
		||||
 | 
			
		||||
    @Mapping(source = "level", target = "level")
 | 
			
		||||
 | 
			
		||||
    @Mappings({
 | 
			
		||||
            @Mapping(source = "level", target = "level"),
 | 
			
		||||
            @Mapping(source = "bean.id", target = "id"),
 | 
			
		||||
            @Mapping(source = "bean.experience", target = "experience")
 | 
			
		||||
    })
 | 
			
		||||
    AppMemberUserInfoRespVO convert(MemberUserDO bean, MemberLevelDO level);
 | 
			
		||||
 | 
			
		||||
    MemberUserRespDTO convert2(MemberUserDO bean);
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,9 @@ package cn.iocoder.yudao.module.system.api.social;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum;
 | 
			
		||||
import jakarta.validation.Valid;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 社交应用的 API 接口
 | 
			
		||||
@@ -39,4 +41,12 @@ public interface SocialClientApi {
 | 
			
		||||
     */
 | 
			
		||||
    SocialWxPhoneNumberInfoRespDTO getWxMaPhoneNumberInfo(Integer userType, String phoneCode);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获得小程序二维码
 | 
			
		||||
     *
 | 
			
		||||
     * @param reqVO 请求信息
 | 
			
		||||
     * @return 小程序二维码
 | 
			
		||||
     */
 | 
			
		||||
    byte[] getWxaQrcode(@Valid SocialWxQrcodeReqDTO reqVO);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -52,12 +52,4 @@ public interface SocialUserApi {
 | 
			
		||||
     */
 | 
			
		||||
    SocialUserRespDTO getSocialUserByCode(Integer userType, Integer socialType, String code, String state);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获得小程序二维码
 | 
			
		||||
     *
 | 
			
		||||
     * @param reqVO 请求信息
 | 
			
		||||
     * @return 小程序二维码
 | 
			
		||||
     */
 | 
			
		||||
    byte[] getWxQrcode(@Valid SocialWxQrcodeReqDTO reqVO);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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 <a href="https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/qr-code/getUnlimitedQRCode.html">获取不限制的小程序码</a>
 | 
			
		||||
 *
 | 
			
		||||
 * @author HUIHUI
 | 
			
		||||
 * @see <a href="https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/qr-code/getUnlimitedQRCode.html">获取不限制的小程序码</a>
 | 
			
		||||
 */
 | 
			
		||||
@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;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 | 
			
		||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxQrcodeReqDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.service.social.SocialClientService;
 | 
			
		||||
import me.chanjar.weixin.common.bean.WxJsapiSignature;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
@@ -40,4 +41,9 @@ public class SocialClientApiImpl implements SocialClientApi {
 | 
			
		||||
        return BeanUtils.toBean(info, SocialWxPhoneNumberInfoRespDTO.class);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public byte[] getWxaQrcode(SocialWxQrcodeReqDTO reqVO) {
 | 
			
		||||
        return socialClientService.getWxaQrcode(reqVO);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -43,10 +43,4 @@ public class SocialUserApiImpl implements SocialUserApi {
 | 
			
		||||
       return socialUserService.getSocialUserByCode(userType, socialType, code, state);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // TODO @puhui999:貌似搞到 SocialClientApiImpl 更合适,二维码和用户关系不大;这样 socialUserService 也不用绕一次了
 | 
			
		||||
    @Override
 | 
			
		||||
    public byte[] getWxQrcode(SocialWxQrcodeReqDTO reqVO) {
 | 
			
		||||
        return socialUserService.getWxQrcode(reqVO);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -67,7 +67,7 @@ public interface SocialClientService {
 | 
			
		||||
     * @param reqVO 请求信息
 | 
			
		||||
     * @return 小程序二维码
 | 
			
		||||
     */
 | 
			
		||||
    byte[] getWxQrcode(SocialWxQrcodeReqDTO reqVO);
 | 
			
		||||
    byte[] getWxaQrcode(SocialWxQrcodeReqDTO reqVO);
 | 
			
		||||
 | 
			
		||||
    // =================== 客户端管理 ===================
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
@@ -229,12 +230,12 @@ public class SocialClientServiceImpl implements SocialClientService {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public byte[] getWxQrcode(SocialWxQrcodeReqDTO reqVO) {
 | 
			
		||||
        WxMaService service = getWxMaService(reqVO.getUserType());
 | 
			
		||||
    public byte[] getWxaQrcode(SocialWxQrcodeReqDTO reqVO) {
 | 
			
		||||
        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);
 | 
			
		||||
 
 | 
			
		||||
@@ -87,12 +87,4 @@ public interface SocialUserService {
 | 
			
		||||
     */
 | 
			
		||||
    PageResult<SocialUserDO> getSocialUserPage(SocialUserPageReqVO pageReqVO);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获得小程序二维码
 | 
			
		||||
     *
 | 
			
		||||
     * @param reqVO 请求信息
 | 
			
		||||
     * @return 小程序二维码
 | 
			
		||||
     */
 | 
			
		||||
    byte[] getWxQrcode(SocialWxQrcodeReqDTO reqVO);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -171,9 +171,4 @@ public class SocialUserServiceImpl implements SocialUserService {
 | 
			
		||||
        return socialUserMapper.selectPage(pageReqVO);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public byte[] getWxQrcode(SocialWxQrcodeReqDTO reqVO) {
 | 
			
		||||
        return socialClientService.getWxQrcode(reqVO);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user