提交 7a191ff3 authored 作者: 李秋林's avatar 李秋林

暂存代码

上级 71bacad6
......@@ -155,6 +155,13 @@
<artifactId>jedis</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.auth0/java-jwt -->
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>4.4.0</version>
</dependency>
</dependencies>
<build>
......
......@@ -11,7 +11,11 @@ public interface RedisKeys {
/**
* 用户接收手机验证码
*/
PHONE_VER_CODE("user:phone_"),
PHONE_VER_CODE("user:phone_code:phone_"),
/**
* 用户登录信息:token
*/
TEMPORARY_TOKEN("user:login_token:temporary:"),
;
String key;
......
......@@ -46,6 +46,14 @@ public class RedisCache {
vo.set(key, valToJson(val), time, TimeUnit.MINUTES);
}
/**
* 保存一个值,并将val json化,设置过期时间(天)
*/
public void addToJsonToDays(String key, Object val, long days) {
ValueOperations<String, String> vo = redisTemplate.opsForValue();
vo.set(key, valToJson(val), days, TimeUnit.DAYS);
}
/**
* 获取一个值
*/
......
......@@ -38,6 +38,13 @@ public class ControllerLogAspect {
ServletRequestAttributes sra = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = sra.getRequest();
/**
* 暂时使用这个判断是否登录
*/
String accessToken = request.getHeader("access_token");
// Signature signature = joinPoint.getSignature();
// String name = signature.getName();
......
package com.wangxiaolu.promotion.controller.tengxunyun;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author : liqiulin
* @date : 2024-04-15 14
* @describe : 验证、控制相关数据接口
*/
@Slf4j
@RestController
@RequestMapping("/console/query")
public class ConsoleDataQueryController {
/**
* 查询验证码
*/
}
......@@ -22,7 +22,7 @@ import java.util.Map;
*/
@Slf4j
@RestController
@RequestMapping("/tencent/core")
@RequestMapping("/tencent")
public class TencentCoreController {
@Autowired
......@@ -31,13 +31,13 @@ public class TencentCoreController {
/**
* 腾讯云短信
*/
@PostMapping("/send/sms")
@PostMapping("/send/sms/ver_code")
public void sendSms(@RequestBody Map<String, String> phoneInfo) {
String phone = phoneInfo.get("phone");
if (StringUtils.isEmpty(phone) || !DataUtils.phonePattern(phone)) {
throw new ParamException(RCode.PHONE_PARAM_ERROR, null);
}
tencentCoreService.sendSmsPhoneVerCOde(phone);
tencentCoreService.sendSmsPhoneVerCode(phone);
}
......
......@@ -5,7 +5,7 @@ import com.wangxiaolu.promotion.common.redis.RedisKeys;
import com.wangxiaolu.promotion.common.redis.service.RedisCache;
import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.pojo.user.dto.WxTemporaryInfoDto;
import com.wangxiaolu.promotion.pojo.user.vo.WxJsUserInfoVo;
import com.wangxiaolu.promotion.pojo.user.vo.WxTemporaryEnrollVo;
import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.service.wechat.WeChatUserCoreService;
import com.wangxiaolu.promotion.utils.DataUtils;
......@@ -38,24 +38,25 @@ public class WeChatUserCoreController {
* 促销员注册信息
*/
@PostMapping("/temporary/enroll")
public boolean enrollUserInfo(@RequestBody @Validated WxJsUserInfoVo wxJsUserInfoVo) {
log.info("微信-促销员注册:{}", JSONObject.toJSONString(wxJsUserInfoVo));
public boolean enrollUserInfo(@RequestBody @Validated WxTemporaryEnrollVo wxTemporaryEnrollVo) {
log.info("微信-促销员注册:{}", JSONObject.toJSONString(wxTemporaryEnrollVo));
// 人员信息校验
boolean isIden = DataUtils.idenCardPattern(wxJsUserInfoVo.getIdenNumber());
boolean isPhone = DataUtils.phonePattern(wxJsUserInfoVo.getPhone());
boolean isIden = DataUtils.idenCardPattern(wxTemporaryEnrollVo.getIdenNumber());
boolean isPhone = DataUtils.phonePattern(wxTemporaryEnrollVo.getPhone());
if (!isIden || !isPhone) {
throw new ParamException(RCode.ENROLL_PARAM_ERROR, null);
}
// 手机号-验证码 校验
String redisKey = RedisKeys.UserKeys.PHONE_VER_CODE.getKey() + wxJsUserInfoVo.getPhone();
String redisKey = RedisKeys.UserKeys.PHONE_VER_CODE.getKey() + wxTemporaryEnrollVo.getPhone();
String phoneCodeOld = redisCache.get(redisKey);
if (StringUtils.isBlank(phoneCodeOld) || !phoneCodeOld.equals(wxJsUserInfoVo.getPhoneCode())){
if (StringUtils.isBlank(phoneCodeOld) || !phoneCodeOld.equals(wxTemporaryEnrollVo.getPhoneCode())){
throw new ParamException(RCode.TENCENT_SMS_PHONE_CODE_ERROR, null);
}
redisCache.removeKey(redisKey);
WxTemporaryInfoDto temporaryDto = new WxTemporaryInfoDto();
BeanUtils.copyProperties(wxJsUserInfoVo, temporaryDto);
BeanUtils.copyProperties(wxTemporaryEnrollVo, temporaryDto);
return weChatUserCoreService.saveWxUserInfoTemporary(temporaryDto);
}
......
package com.wangxiaolu.promotion.controller.wechat;
import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.pojo.user.dto.WxTemporaryInfoDto;
import com.wangxiaolu.promotion.pojo.user.vo.WxTemporaryLoginVo;
import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.service.wechat.WeChatUserQueryService;
import com.wangxiaolu.promotion.utils.WxMaUtils;
import com.wangxiaolu.promotion.utils.DataUtils;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Objects;
/**
* @author : liqiulin
......@@ -19,36 +22,34 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/user/wechat/query")
public class WeChatUserQueryController {
@Autowired
private WxMaUtils wxMaUtils;
@Autowired
private WeChatUserQueryService weChatUserQueryService;
/**
* 接收wx临时登录凭证code,查询openid是否已注册
* 促销员查询
* 根据OpenId、Phone登录(促销员查询是否存在)
* @return 非null则登录成功
*/
@GetMapping("/temporary/login")
public boolean temporaryLoginByOpenId(String jsCode) {
String userOpenId = null;
try {
userOpenId = wxMaUtils.getWxOpenId(jsCode);
return weChatUserQueryService.loginTemporaryByOpenId(userOpenId);
} catch (WxErrorException e) {
log.info("微信-促销员登录无效,jsCode:{},获取openId:{}", jsCode, userOpenId);
@PostMapping("/temporary/login/phone_openid")
public WxTemporaryInfoDto temporaryLoginByPhoneAndOpenId(@RequestBody WxTemporaryLoginVo wxTemporaryLoginVo) {
if (!DataUtils.phonePattern(wxTemporaryLoginVo.getPhone())) {
throw new ParamException(RCode.PHONE_PARAM_ERROR, null);
}
return false;
WxTemporaryInfoDto wxTemDto = weChatUserQueryService.loginTemporaryByOpenIdAndPhone(wxTemporaryLoginVo.getOpenId(), wxTemporaryLoginVo.getPhone());
if (Objects.isNull(wxTemDto)){
throw new ParamException(RCode.LOGIN_USER_IS_NULL_ERROR, null);
}
return wxTemDto;
}
/**
* 根据openId查询人员详情
* 需要改成:根据token查询人员详情
* 促销员查询
*/
@GetMapping("/temporary/openId")
public WxTemporaryInfoDto getTemporaryInfoByOpenId(String openId) {
return weChatUserQueryService.getTemporaryByOpenId(openId);
return weChatUserQueryService.getTemporaryByToken(openId);
}
}
package com.wangxiaolu.promotion.domain.user.dao;
import com.wangxiaolu.promotion.domain.user.mapper.entity.TemporaryInfoDO;
import com.wangxiaolu.promotion.pojo.user.dto.WxTemporaryInfoDto;
/**
......@@ -19,4 +18,9 @@ public interface TemporaryInfoDao {
* 根据OpenId查询人员是否存在(非保密信息)
*/
WxTemporaryInfoDto getUnimportantData(String openId);
/**
* 根据OpenId、phone查询人员是否存在(非保密信息)
*/
WxTemporaryInfoDto getUnimportantData(String openId,String phone);
}
......@@ -28,7 +28,7 @@ public class TemporaryInfoDaoImpl implements TemporaryInfoDao {
* 微信-小程序注册的促销员信息
*/
@Override
public int saveWxTemporaryInfo(WxTemporaryInfoDto temporaryDto) {
public int saveWxTemporaryInfo(WxTemporaryInfoDto temporaryDto){
TemporaryInfoDO entity = new TemporaryInfoDO();
BeanUtils.copyProperties(temporaryDto, entity);
return temporaryInfoMapper.insert(entity);
......@@ -37,14 +37,15 @@ public class TemporaryInfoDaoImpl implements TemporaryInfoDao {
@Override
public WxTemporaryInfoDto getUnimportantData(String openId) {
TemporaryInfoDO temDo = temporaryInfoMapper.getUnimportantData(openId);
WxTemporaryInfoDto temporaryDto = null;
if (!Objects.isNull(temDo)){
temporaryDto = new WxTemporaryInfoDto();
BeanUtils.copyProperties(temDo, temporaryDto);
return transitionDto(temDo);
}
return temporaryDto;
@Override
public WxTemporaryInfoDto getUnimportantData(String openId, String phone) {
TemporaryWrapper tw = new TemporaryWrapper().setOpenId(openId).setPhone(phone);
LambdaQueryWrapper<TemporaryInfoDO> doqwer = buildQueryList(tw);
TemporaryInfoDO temDo = temporaryInfoMapper.selectOne(doqwer);
return transitionDto(temDo);
}
private LambdaQueryWrapper<TemporaryInfoDO> buildQueryList(TemporaryWrapper tw){
......@@ -52,6 +53,23 @@ public class TemporaryInfoDaoImpl implements TemporaryInfoDao {
if (!StringUtils.isEmpty(tw.getOpenId())){
queryWrapper.eq(TemporaryInfoDO::getOpenId,tw.getOpenId());
}
if (!StringUtils.isEmpty(tw.getPhone())){
queryWrapper.eq(TemporaryInfoDO::getPhone,tw.getPhone());
}
return queryWrapper;
}
/**
* DO to DTO (单个对象)
* @param temDo DO对象
* @return DTO对象
*/
private WxTemporaryInfoDto transitionDto(TemporaryInfoDO temDo){
WxTemporaryInfoDto temporaryDto = null;
if (!Objects.isNull(temDo)){
temporaryDto = new WxTemporaryInfoDto();
BeanUtils.copyProperties(temDo, temporaryDto);
}
return temporaryDto;
}
}
......@@ -19,5 +19,9 @@ public class TemporaryWrapper {
* openId
*/
String openId;
/**
* 手机号
*/
String phone;
}
......@@ -76,4 +76,9 @@ public class WxTemporaryInfoDto {
* 详细地址
*/
String address;
/**
* 登录token
*/
String token;
}
......@@ -10,29 +10,13 @@ import javax.validation.constraints.NotBlank;
/**
* @author : liqiulin
* @date : 2024-04-08 12
* @describe :
* @describe : 微信-促销员注册参数
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class WxJsUserInfoVo {
/**
* js传过来的临时登录code
*/
// @NotBlank(message = "微信登录凭证错误")
// String jsCode;
/**
* 用户信息的加密文字
*/
// String encryptedData;
/**
* 标识
*/
// String iv;
public class WxTemporaryEnrollVo {
/**
* openId
*/
......@@ -104,4 +88,23 @@ public class WxJsUserInfoVo {
*/
@NotBlank(message = "验证码无效")
String phoneCode;
// 暂时用不到的参数
/**
* js传过来的临时登录code
*/
// @NotBlank(message = "微信登录凭证错误")
// String jsCode;
/**
* 用户信息的加密文字
*/
// String encryptedData;
/**
* 标识
*/
// String iv;
}
package com.wangxiaolu.promotion.pojo.user.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
/**
* @author : liqiulin
* @date : 2024-04-16 10
* @describe : 促销员登录
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class WxTemporaryLoginVo {
@NotBlank(message = "微信登录错误")
String openId;
@NotBlank(message = "手机号不可为空")
String phone;
}
......@@ -8,6 +8,8 @@ import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.sql.SQLIntegrityConstraintViolationException;
/**
* @author : liqiulin
* @date : 2024-03-28 19
......@@ -18,19 +20,33 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
public class ControllerExceptionAdvice {
@ExceptionHandler({ParamException.class})
public R ParamExceptionHandler(ParamException e) {
public R paramExceptionHandler(ParamException e) {
return new R(e.getCode(), e.getMsg(), e.getMessage());
}
@ExceptionHandler({APIException.class})
public R APIExceptionHandler(APIException e) {
public R apiExceptionHandler(APIException e) {
return new R(e.getCode(), e.getMsg(), e.getMessage());
}
@ExceptionHandler({SQLIntegrityConstraintViolationException.class})
public R dbConstraintViolationExceptionHandler(SQLIntegrityConstraintViolationException e) {
RCode errorCode = RCode.USER_PHONE_IDENNUMBER_WXOPENID_UNIQUE_ERROR;
String msg = errorCode.getMsg();
String message = e.getMessage();
if (message.contains("phone_unique")) {
msg = "手机号已注册";
} else if (message.contains("iden_num_unique")) {
msg = "身份证已注册";
} else if (message.contains("open_id_unique")) {
msg = "微信号已注册";
}
return new R(errorCode.getCode(), msg, message);
}
@ExceptionHandler({MethodArgumentNotValidException.class})
public R MethodArgumentNotValidExceptionHandler(MethodArgumentNotValidException e) {
public R methodArgumentNotValidExceptionHandler(MethodArgumentNotValidException e) {
String msg = e.getBindingResult().getFieldError().getDefaultMessage();
return new R(RCode.PARAM_ERROR.getCode(), msg);
}
}
......@@ -31,6 +31,8 @@ public enum RCode implements StatusCode {
LOGIN_PARAM_ERROR(3000, "登录信息错误"),
ENROLL_PARAM_ERROR(3001, "注册信息错误"),
PHONE_PARAM_ERROR(3002, "手机号异常"),
USER_PHONE_IDENNUMBER_WXOPENID_UNIQUE_ERROR(3003, "个人信息已注册"),
LOGIN_USER_IS_NULL_ERROR(3004, "账号未注册"),
/**
* 腾讯云
* 3500+
......
......@@ -10,5 +10,5 @@ public interface TencentCoreService {
* 发送手机号验证码
* @param phone 手机号
*/
void sendSmsPhoneVerCOde(String phone);
void sendSmsPhoneVerCode(String phone);
}
......@@ -31,7 +31,7 @@ public class TencentCoreServiceImpl implements TencentCoreService {
RedisCache redisCache;
@Override
public void sendSmsPhoneVerCOde(String phone) {
public void sendSmsPhoneVerCode(String phone) {
String redisKey = RedisKeys.UserKeys.PHONE_VER_CODE.getKey() + phone;
// 判断是否已获取
String verCodeOld = redisCache.get(redisKey);
......@@ -44,7 +44,7 @@ public class TencentCoreServiceImpl implements TencentCoreService {
log.info("腾讯云短信,发送验证码:{}-{}", phone, phoneVerCode);
redisCache.addToMinute(redisKey, phoneVerCode, overdueLong);
// boolean succss = tencentUtils.sendSmsPhoneVerCOde(phone, phoneVerCode);
// todo boolean succss = tencentUtils.sendSmsPhoneVerCOde(phone, phoneVerCode);
boolean succss = true;
if (!succss) {
redisCache.removeKey(redisKey);
......
package com.wangxiaolu.promotion.service.wechat;
import com.wangxiaolu.promotion.pojo.user.dto.WxTemporaryInfoDto;
import com.wangxiaolu.promotion.pojo.user.vo.WxJsUserInfoVo;
/**
* @author : liqiulin
......
......@@ -8,7 +8,8 @@ import com.wangxiaolu.promotion.pojo.user.dto.WxTemporaryInfoDto;
* @describe :微信人员信息查询
*/
public interface WeChatUserQueryService {
boolean loginTemporaryByOpenId(String userOpenId);
WxTemporaryInfoDto getTemporaryByOpenId(String openId);
WxTemporaryInfoDto loginTemporaryByOpenIdAndPhone(String openId,String phone);
WxTemporaryInfoDto getTemporaryByToken(String openId);
}
......@@ -3,12 +3,8 @@ package com.wangxiaolu.promotion.service.wechat.impl;
import com.alibaba.fastjson.JSONObject;
import com.wangxiaolu.promotion.domain.user.dao.TemporaryInfoDao;
import com.wangxiaolu.promotion.pojo.user.dto.WxTemporaryInfoDto;
import com.wangxiaolu.promotion.pojo.user.vo.WxJsUserInfoVo;
import com.wangxiaolu.promotion.service.wechat.WeChatUserCoreService;
import lombok.extern.slf4j.Slf4j;
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;
......
package com.wangxiaolu.promotion.service.wechat.impl;
import com.alibaba.fastjson.JSONObject;
import com.wangxiaolu.promotion.common.redis.RedisKeys;
import com.wangxiaolu.promotion.common.redis.service.RedisCache;
import com.wangxiaolu.promotion.domain.user.dao.TemporaryInfoDao;
import com.wangxiaolu.promotion.domain.user.mapper.entity.TemporaryInfoDO;
import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.pojo.user.dto.WxTemporaryInfoDto;
import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.service.wechat.WeChatUserQueryService;
import com.wangxiaolu.promotion.utils.JwtUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -25,38 +26,48 @@ public class WeChatUserQueryServiceImpl implements WeChatUserQueryService {
private static final Logger log = LoggerFactory.getLogger(WeChatUserQueryServiceImpl.class);
@Autowired
TemporaryInfoDao temporaryInfoDao;
@Autowired
RedisCache redisCache;
@Autowired
JwtUtils jwtUtils;
/**
* 根据openId、手机号登录
*/
@Override
public boolean loginTemporaryByOpenId(String userOpenId) {
WxTemporaryInfoDto temDto = temporaryInfoDao.getUnimportantData(userOpenId);
boolean exist = !Objects.isNull(temDto);
// todo 查询到时,将个人信息放到reids中进行保存
if (exist) {
log.info("微信-促销员{}登录成功,openId:{}", temDto.getName(), userOpenId);
log.info(JSONObject.toJSONString(temDto));
} else {
log.info("微信-促销员登录失败,登录openId:{}", userOpenId);
public WxTemporaryInfoDto loginTemporaryByOpenIdAndPhone(String openId, String phone) {
WxTemporaryInfoDto temDto = temporaryInfoDao.getUnimportantData(openId, phone);
if (Objects.isNull(temDto)) {
log.info("微信-促销员登录失败,当前信息未注册(openId、手机号),openId:{},phone:{}", openId, phone);
return null;
}
return exist;
// 生成登录token
String temToken = jwtUtils.getTemporaryToken(openId, phone);
temDto.setToken(temToken);
String key = RedisKeys.UserKeys.TEMPORARY_TOKEN.getKey();
redisCache.addToJsonToDays(key + temToken, temDto, 3);
log.info("微信-促销员{}登录成功(openId、手机号),openId:{},phone:{}\n生成登录token:{}", temDto.getName(), openId, phone, temToken);
return temDto;
}
/**
* 根据openId查询人员详情
* @param openId 微信openId
* @return 不返回身份证照片等重要信息,详情请查看sql语句
* 不返回身份证照片等重要信息,详情请查看sql语句
*/
@Override
public WxTemporaryInfoDto getTemporaryByOpenId(String openId) {
public WxTemporaryInfoDto getTemporaryByToken(String openId) {
// todo 先查询redis中是否有缓存数据
String key = RedisKeys.UserKeys.TEMPORARY_TOKEN.getKey();
// todo redis中没有缓存数据,则进行查询
WxTemporaryInfoDto temporaryInfoDto = temporaryInfoDao.getUnimportantData(openId);
if (Objects.isNull(temporaryInfoDto)){
throw new ParamException(RCode.LOGIN_PARAM_ERROR,null);
if (Objects.isNull(temporaryInfoDto)) {
throw new ParamException(RCode.LOGIN_PARAM_ERROR, null);
}
return temporaryInfoDto;
}
}
package com.wangxiaolu.promotion.utils;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.result.basedata.RCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* @author : liqiulin
* @date : 2024-04-16 17
* @describe : java web token
*/
@Slf4j
@Component
public class JwtUtils {
/**
* 促销员-解密秘钥
*/
@Value("${wx.miniapp.temporary.token_secret}")
private String TEMPORARY_SECRET;
public String getTemporaryToken(String openId, String phone) {
try {
//用秘钥生成签名
Algorithm algorithm = Algorithm.HMAC256(TEMPORARY_SECRET);
//默认头部+载荷(手机号/id)+签名=jwt
String jwtToken = JWT.create()
.withClaim("openId", openId)
.withClaim("phone", phone)
.sign(algorithm);
return jwtToken;
} catch (Exception e) {
log.error("用户{}的token生成异常:{}", openId, e);
throw new ParamException(RCode.LOGIN_PARAM_ERROR, e.getMessage());
}
}
/**
* 校验token是否正确
**/
public boolean verifyTemporaryToken(String token,String openId, String phone) {
try {
// 生成JWT效验器
Algorithm algorithm = Algorithm.HMAC256(TEMPORARY_SECRET);
JWTVerifier verifier = JWT.require(algorithm).build();
verifier.verify(token);
return true;
// DecodedJWT jwt = JWT.decode(token);
// if (
// openId.equals(jwt.getClaim("openId").asString())
// && phone.equals(jwt.getClaim("phone").asString())
// ){
// return true;
// }
// return false;
} catch (Exception e) {
log.error("用户{}的token解析异常:{}", openId, e);
throw new ParamException(RCode.LOGIN_PARAM_ERROR, e.getMessage());
}
}
}
......@@ -12,6 +12,9 @@ spring:
url: jdbc:mysql://bj-cdb-j8ppdy86.sql.tencentcdb.com:63569/promotion_dev?autoReconnect=true
username: LnNDBM
password: fd0%bhD4@oO(%
redis:
port: 6379
host: 127.0.0.1
logging:
config: classpath:logback-spring.xml
......@@ -31,20 +34,22 @@ wx:
token: #微信小程序消息服务器配置的token
aesKey: #微信小程序消息服务器配置的EncodingAESKey
msgDataFormat: JSON
temporary:
token_secret: sXwHPj#U#xmim^ts
tengxunyun:
secret_d: AKIDVt353sWyY0GXn0ANa0YyGdwDIBtjQwGS
secret_key: SBqJcrxypSxeGOPF81mLgsANXo3ALhz7
sms:
# 指定接入地域域名,默认就近地域接入域名为 sms.tencentcloudapi.com
#指定接入地域域名,默认就近地域接入域名为 sms.tencentcloudapi.com
endpoint_beijing: sms.ap-beijing.tencentcloudapi.com
# 地域信息
#地域信息
ap_beijing: ap-beijing
# 应用ID
#应用ID(默认应用)
sdk_app_id_defult: 1400903035
# 模板名称
#模板名称-手机验证码
sign_name_a: 北京王小卤
# 模板ID
#模板ID-手机验证码
template_id_a: 2127434
# 验证码过期时间(分钟)
#验证码过期时间(分钟)
overdue_long: 5
\ No newline at end of file
package com.wangxiaolu.promotion.controller.wechat;
import com.alibaba.fastjson.JSONObject;
import com.wangxiaolu.promotion.pojo.user.vo.WxJsUserInfoVo;
import com.wangxiaolu.promotion.pojo.user.vo.WxTemporaryEnrollVo;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.jupiter.api.Assertions.*;
/**
* @author : liqiulin
* @date : 2024-04-08 16
......@@ -26,7 +24,7 @@ class WeChatUserCoreControllerTest {
@Test
void enrollUserInfo() {
WxJsUserInfoVo vo = new WxJsUserInfoVo()
WxTemporaryEnrollVo vo = new WxTemporaryEnrollVo()
.setOpenId("openid111")
.setAvatarUrl("头像Url")
.setName("姓名")
......@@ -46,7 +44,5 @@ class WeChatUserCoreControllerTest {
@Test
void getOpenIdByWxcode() {
Boolean openIdByWxcode = weChatUserQueryController.temporaryLoginByOpenId("111");
System.out.println(openIdByWxcode);
}
}
\ No newline at end of file
package com.wangxiaolu.promotion.controller.wechat;
import com.wangxiaolu.promotion.pojo.user.dto.WxTemporaryInfoDto;
import com.wangxiaolu.promotion.pojo.user.vo.WxTemporaryLoginVo;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.jupiter.api.Assertions.*;
/**
* @author : liqiulin
* @date : 2024-04-16 11
* @describe :
*/
@SpringBootTest
@RunWith(SpringRunner.class)
class WeChatUserQueryControllerTest {
@Autowired
WeChatUserQueryController weChatUserQueryController;
@Test
void temporaryLoginByPhoneAndOpenId() {
WxTemporaryLoginVo loginVO = new WxTemporaryLoginVo().setOpenId("oCMt-66hnlY9-bQcZAAZKX0p3s6I").setPhone("15701654502");
WxTemporaryInfoDto b = weChatUserQueryController.temporaryLoginByPhoneAndOpenId(loginVO);
System.out.println("temporaryLoginByPhoneAndOpenId 登录结果:" + b);
}
@Test
void getTemporaryInfoByOpenId() {
}
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论