feat:小程序平台-登录
This commit is contained in:
1 parent
43e6df6f72
commit
ee870fb9d1
18 files changed
+433
No files matched your search
+8
@@ -39,6 +39,14 @@ public class AppVersionController {
|
|||||||
}
|
}
|
||||||
/* ************************************* end 设备端 end ************************************* */
|
/* ************************************* end 设备端 end ************************************* */
|
||||||
|
|
||||||
|
/* ************************************* start app start ************************************* */
|
||||||
|
@Operation(summary = "获取最新版本", description = "获取最新版本")
|
||||||
|
@GetMapping("/app/last-version")
|
||||||
|
public R<AppVersionEntity> lastVersion(@ParameterObject AppVersionDto dto) {
|
||||||
|
return R.ok(appVersionService.lastVersion(dto));
|
||||||
|
}
|
||||||
|
/* ************************************* end app end ************************************* */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询
|
* 分页查询
|
||||||
*/
|
*/
|
||||||
|
|||||||
+5
@@ -12,4 +12,9 @@ public interface AppVersionService extends IService<AppVersionEntity> {
|
|||||||
* 分页查询
|
* 分页查询
|
||||||
*/
|
*/
|
||||||
Page<AppVersionVo> pageList(Page page, AppVersionDto dto);
|
Page<AppVersionVo> pageList(Page page, AppVersionDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最新版本
|
||||||
|
*/
|
||||||
|
AppVersionEntity lastVersion(AppVersionDto dto);
|
||||||
}
|
}
|
||||||
+16
@@ -1,7 +1,10 @@
|
|||||||
package com.bsd.pjcloud.integrated.service.impl.appmodule;
|
package com.bsd.pjcloud.integrated.service.impl.appmodule;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.bsd.pjcloud.integrated.constant.appmodule.AppVersionStatusEnum;
|
||||||
import com.bsd.pjcloud.integrated.dto.appmodule.AppVersionDto;
|
import com.bsd.pjcloud.integrated.dto.appmodule.AppVersionDto;
|
||||||
import com.bsd.pjcloud.integrated.entity.app.AppVersionEntity;
|
import com.bsd.pjcloud.integrated.entity.app.AppVersionEntity;
|
||||||
import com.bsd.pjcloud.integrated.mapper.appmodule.AppVersionMapper;
|
import com.bsd.pjcloud.integrated.mapper.appmodule.AppVersionMapper;
|
||||||
@@ -23,4 +26,17 @@ public class AppVersionServiceImpl extends ServiceImpl<AppVersionMapper, AppVers
|
|||||||
return baseMapper.pagList(page, dto);
|
return baseMapper.pagList(page, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最新版本
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AppVersionEntity lastVersion(AppVersionDto dto) {
|
||||||
|
LambdaQueryWrapper<AppVersionEntity> queryWrapper = new LambdaQueryWrapper<AppVersionEntity>()
|
||||||
|
.gt(ObjectUtil.isNotEmpty(dto.getVersionCode()), AppVersionEntity::getVersionCode, dto.getVersionCode())
|
||||||
|
.eq(AppVersionEntity::getStatus, AppVersionStatusEnum.PUBLISHED.getCode())
|
||||||
|
.like(ObjectUtil.isNotEmpty(dto.getPlatform()), AppVersionEntity::getPlatform, dto.getPlatform())
|
||||||
|
.orderByDesc(AppVersionEntity::getVersionCode)
|
||||||
|
.last("limit 1");
|
||||||
|
return baseMapper.selectOne(queryWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
package com.bsd.pjcloud.thirdparty.constant.miniplatform;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序平台登录错误
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public enum MiniPlatformLoginErrorEnum {
|
||||||
|
|
||||||
|
GET_PHONE_ERROR("10", "获取手机号错误"),
|
||||||
|
USER_NOT_EXIST("20", "用户不存在"),
|
||||||
|
LOGIN_ERROR("30", "登录错误"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String type;
|
||||||
|
private final String description;
|
||||||
|
|
||||||
|
public static MiniPlatformLoginErrorEnum valueOfByType(String type) {
|
||||||
|
if (ObjectUtil.isEmpty(type)) return null;
|
||||||
|
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
package com.bsd.pjcloud.thirdparty.constant.miniplatform;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.bsd.pjcloud.thirdparty.constant.ThirdKeyTypeEnum;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序平台
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public enum MiniPlatformTypeEnum {
|
||||||
|
|
||||||
|
WECAHT("10", "微信小程序"),
|
||||||
|
ALI_PAY("20", "支付宝"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String type;
|
||||||
|
private final String description;
|
||||||
|
|
||||||
|
public static MiniPlatformTypeEnum valueOfByType(String type) {
|
||||||
|
if (ObjectUtil.isEmpty(type)) return null;
|
||||||
|
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
package com.bsd.pjcloud.thirdparty.dto.oathmini;
|
||||||
|
|
||||||
|
import com.bsd.pjcloud.thirdparty.constant.miniplatform.MiniPlatformTypeEnum;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ThirdMinAppOAth2LoginDto {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序平台
|
||||||
|
*/
|
||||||
|
@NotNull(message = "小程序平台标识不能为空")
|
||||||
|
private MiniPlatformTypeEnum miniPlatformType;
|
||||||
|
|
||||||
|
@NotEmpty(message = "code不能为空")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
package com.bsd.pjcloud.thirdparty.vo.oathmini;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ThirdMinAppOAth2LoginVo {
|
||||||
|
|
||||||
|
private String accessToken;
|
||||||
|
|
||||||
|
private String refreshToken;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -143,6 +143,12 @@
|
|||||||
<artifactId>wechatpay-java</artifactId>
|
<artifactId>wechatpay-java</artifactId>
|
||||||
<version>0.2.17</version>
|
<version>0.2.17</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- 微信登录(小程序) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.binarywang</groupId>
|
||||||
|
<artifactId>wx-java-miniapp-spring-boot-starter</artifactId>
|
||||||
|
<version>4.7.0</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.bsd</groupId>
|
<groupId>com.bsd</groupId>
|
||||||
<artifactId>pjcloud-hardware-api</artifactId>
|
<artifactId>pjcloud-hardware-api</artifactId>
|
||||||
|
|||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
package com.bsd.pjcloud.thirdparty.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序平台配置
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix = "mini-platform.mini-app")
|
||||||
|
@Data
|
||||||
|
public class MiniAppConfig {
|
||||||
|
|
||||||
|
|
||||||
|
private WechatConfig wechatConfig;
|
||||||
|
|
||||||
|
private AliPayConfig aliPayConfig;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class WechatConfig {
|
||||||
|
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
private String appSecret;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class AliPayConfig {
|
||||||
|
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+40
@@ -0,0 +1,40 @@
|
|||||||
|
package com.bsd.pjcloud.thirdparty.config.initconfig;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||||
|
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||||
|
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
|
||||||
|
import com.bsd.pjcloud.thirdparty.config.MiniAppConfig;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Configuration
|
||||||
|
public class MinWechatConfiguration {
|
||||||
|
|
||||||
|
private final MiniAppConfig properties;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public MinWechatConfiguration(MiniAppConfig properties) {
|
||||||
|
this.properties = properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WxMaService wxMaService() {
|
||||||
|
MiniAppConfig.WechatConfig wechatConfig = properties.getWechatConfig();
|
||||||
|
|
||||||
|
WxMaDefaultConfigImpl wxMaDefaultConfig = new WxMaDefaultConfigImpl();
|
||||||
|
wxMaDefaultConfig.setAppid(wechatConfig.getAppId());
|
||||||
|
wxMaDefaultConfig.setSecret(wechatConfig.getAppSecret());
|
||||||
|
wxMaDefaultConfig.setMsgDataFormat("JSON");
|
||||||
|
|
||||||
|
WxMaService maService = new WxMaServiceImpl();
|
||||||
|
maService.setWxMaConfig(wxMaDefaultConfig);
|
||||||
|
return maService;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
package com.bsd.pjcloud.thirdparty.controller.oathmini;
|
||||||
|
|
||||||
|
import com.bsd.pjcloud.common.core.util.R;
|
||||||
|
import com.bsd.pjcloud.thirdparty.dto.oathmini.ThirdMinAppOAth2LoginDto;
|
||||||
|
import com.bsd.pjcloud.thirdparty.service.ThirdMiniAppService;
|
||||||
|
import com.bsd.pjcloud.thirdparty.vo.oathmini.ThirdMinAppOAth2LoginVo;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/third-mini-app-oath")
|
||||||
|
@Tag(description = "third-mini-app-oath", name = "第三方登录")
|
||||||
|
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||||
|
public class ThirdMinAppOAth2Cotroller {
|
||||||
|
|
||||||
|
private final ThirdMiniAppService thirdMiniAppService;
|
||||||
|
|
||||||
|
@Operation(summary = "微信小程序登录")
|
||||||
|
@PostMapping("/auto-admin-login")
|
||||||
|
public R<ThirdMinAppOAth2LoginVo> wechatLogin(@RequestBody ThirdMinAppOAth2LoginDto dto) {
|
||||||
|
return R.ok(thirdMiniAppService.adminLogin(dto));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
package com.bsd.pjcloud.thirdparty.service;
|
||||||
|
|
||||||
|
|
||||||
|
public interface ThirdMiniAppAliPayService {
|
||||||
|
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
package com.bsd.pjcloud.thirdparty.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.bsd.pjcloud.thirdparty.dto.oathmini.ThirdMinAppOAth2LoginDto;
|
||||||
|
import com.bsd.pjcloud.thirdparty.vo.oathmini.ThirdMinAppOAth2LoginVo;
|
||||||
|
|
||||||
|
public interface ThirdMiniAppService {
|
||||||
|
|
||||||
|
ThirdMinAppOAth2LoginVo adminLogin(ThirdMinAppOAth2LoginDto dto);
|
||||||
|
|
||||||
|
}
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package com.bsd.pjcloud.thirdparty.service;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
||||||
|
|
||||||
|
public interface ThirdMiniAppWechatService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取openId
|
||||||
|
*/
|
||||||
|
String getOpenId(String code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取手机号
|
||||||
|
*/
|
||||||
|
WxMaPhoneNumberInfo getPhone(String code);
|
||||||
|
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package com.bsd.pjcloud.thirdparty.service.impl.miniapp;
|
||||||
|
|
||||||
|
import com.bsd.pjcloud.thirdparty.config.MiniAppConfig;
|
||||||
|
import com.bsd.pjcloud.thirdparty.service.ThirdMiniAppAliPayService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付宝小程序(小程序版本)
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ThirdMiniAppAliPayServiceImpl implements ThirdMiniAppAliPayService {
|
||||||
|
|
||||||
|
private final MiniAppConfig miniAppConfig;
|
||||||
|
|
||||||
|
}
|
||||||
+71
@@ -0,0 +1,71 @@
|
|||||||
|
package com.bsd.pjcloud.thirdparty.service.impl.miniapp;
|
||||||
|
|
||||||
|
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.bsd.pjcloud.admin.api.dto.UserInfo;
|
||||||
|
import com.bsd.pjcloud.admin.api.dto.UserTokenDTO;
|
||||||
|
import com.bsd.pjcloud.admin.api.feign.RemoteTokenService;
|
||||||
|
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||||
|
import com.bsd.pjcloud.common.core.util.R;
|
||||||
|
import com.bsd.pjcloud.thirdparty.constant.miniplatform.MiniPlatformLoginErrorEnum;
|
||||||
|
import com.bsd.pjcloud.thirdparty.constant.miniplatform.MiniPlatformTypeEnum;
|
||||||
|
import com.bsd.pjcloud.thirdparty.dto.oathmini.ThirdMinAppOAth2LoginDto;
|
||||||
|
import com.bsd.pjcloud.thirdparty.service.ThirdMiniAppAliPayService;
|
||||||
|
import com.bsd.pjcloud.thirdparty.service.ThirdMiniAppService;
|
||||||
|
import com.bsd.pjcloud.thirdparty.service.ThirdMiniAppWechatService;
|
||||||
|
import com.bsd.pjcloud.thirdparty.vo.oathmini.ThirdMinAppOAth2LoginVo;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序(小程序版本)
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ThirdMiniAppServiceImpl implements ThirdMiniAppService {
|
||||||
|
|
||||||
|
private final ThirdMiniAppWechatService thirdMiniAppWechatService;
|
||||||
|
private final ThirdMiniAppAliPayService thirdMiniAppAliPayService;
|
||||||
|
|
||||||
|
private final RemoteUserService remoteUserService;
|
||||||
|
private final RemoteTokenService remoteTokenService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ThirdMinAppOAth2LoginVo adminLogin(ThirdMinAppOAth2LoginDto dto) {
|
||||||
|
ThirdMinAppOAth2LoginVo vo = new ThirdMinAppOAth2LoginVo();
|
||||||
|
// 微信小程序
|
||||||
|
if (ObjectUtil.equals(dto.getMiniPlatformType().getType(), MiniPlatformTypeEnum.WECAHT.getType())) {
|
||||||
|
// 获取手机号
|
||||||
|
WxMaPhoneNumberInfo phoneInfo = thirdMiniAppWechatService.getPhone(dto.getCode());
|
||||||
|
if (ObjectUtil.isEmpty(phoneInfo)) {
|
||||||
|
throw new RuntimeException(MiniPlatformLoginErrorEnum.GET_PHONE_ERROR.getType());
|
||||||
|
}
|
||||||
|
// 根据手机号查询用户
|
||||||
|
UserInfo userInfo = remoteUserService.getInnerByPhone(phoneInfo.getPurePhoneNumber()).getData();
|
||||||
|
if (ObjectUtil.isEmpty(userInfo)) {
|
||||||
|
throw new RuntimeException(MiniPlatformLoginErrorEnum.USER_NOT_EXIST.getType());
|
||||||
|
}
|
||||||
|
// 执行登录
|
||||||
|
UserTokenDTO userTokenDTO = new UserTokenDTO();
|
||||||
|
userTokenDTO.setSysUser(userInfo.getSysUser());
|
||||||
|
Map<String, Object> dataMap = (Map<String, Object>) remoteTokenService.generateToken(userTokenDTO).getData();
|
||||||
|
if (ObjectUtil.isEmpty(dataMap)) {
|
||||||
|
throw new RuntimeException(MiniPlatformLoginErrorEnum.LOGIN_ERROR.getType());
|
||||||
|
}
|
||||||
|
vo.setAccessToken(String.valueOf(dataMap.getOrDefault("accessToken", "")));
|
||||||
|
vo.setRefreshToken(String.valueOf(dataMap.getOrDefault("refreshToken", "")));
|
||||||
|
}
|
||||||
|
// 支付宝
|
||||||
|
else if (ObjectUtil.equals(dto.getMiniPlatformType().getType(), MiniPlatformTypeEnum.ALI_PAY.getType())) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
package com.bsd.pjcloud.thirdparty.service.impl.miniapp;
|
||||||
|
|
||||||
|
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||||
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
||||||
|
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.bsd.pjcloud.thirdparty.config.MiniAppConfig;
|
||||||
|
import com.bsd.pjcloud.thirdparty.service.ThirdMiniAppWechatService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信小程序(小程序版本)
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ThirdMiniAppWechatServiceImpl implements ThirdMiniAppWechatService {
|
||||||
|
|
||||||
|
private final String TAG = "微信小程序(小程序版本)";
|
||||||
|
|
||||||
|
private final MiniAppConfig miniAppConfig;
|
||||||
|
|
||||||
|
private final WxMaService wxMaService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取openId
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getOpenId(String code) {
|
||||||
|
try {
|
||||||
|
WxMaJscode2SessionResult session = wxMaService.getUserService().getSessionInfo(code);
|
||||||
|
if (ObjectUtil.isNotEmpty(session) && ObjectUtil.isNotEmpty(session.getOpenid())) {
|
||||||
|
return session.getOpenid();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("|{}|获取openId:{}", TAG, e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取手机号
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public WxMaPhoneNumberInfo getPhone(String code) {
|
||||||
|
try {
|
||||||
|
WxMaPhoneNumberInfo phoneInfo = wxMaService.getUserService().getPhoneNumber(code);
|
||||||
|
if (ObjectUtil.isNotEmpty(phoneInfo)) {
|
||||||
|
return phoneInfo;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("|{}|获取手机号:{}", TAG, e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -173,3 +173,11 @@ hikvision:
|
|||||||
cancel-appointment: /api/visitor/v1/appointment/cancel # 新增取消预约接口
|
cancel-appointment: /api/visitor/v1/appointment/cancel # 新增取消预约接口
|
||||||
register-appointment: /api/visitor/v1/order/register # 新增登记接口
|
register-appointment: /api/visitor/v1/order/register # 新增登记接口
|
||||||
visitor-checkout: /api/visitor/v1/visitor/out # 新增签离接口
|
visitor-checkout: /api/visitor/v1/visitor/out # 新增签离接口
|
||||||
|
|
||||||
|
mini-platform:
|
||||||
|
mini-app:
|
||||||
|
wechat-config:
|
||||||
|
app-id: wx11771c7bf2913cb2
|
||||||
|
app-secret: a6b0d036b229117595687a7c1705d332
|
||||||
|
ali-pay-config:
|
||||||
|
app-id:
|
||||||
Reference in new issue
Block a user