修改升级wxjava sdk启动报错
This commit is contained in:
@ -10,6 +10,7 @@ package co.yixiang;
|
|||||||
|
|
||||||
import co.yixiang.annotation.AnonymousAccess;
|
import co.yixiang.annotation.AnonymousAccess;
|
||||||
import co.yixiang.utils.SpringContextHolder;
|
import co.yixiang.utils.SpringContextHolder;
|
||||||
|
import com.binarywang.spring.starter.wxjava.miniapp.config.WxMaAutoConfiguration;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
@ -27,7 +28,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
*/
|
*/
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
@RestController
|
@RestController
|
||||||
@SpringBootApplication
|
@SpringBootApplication(exclude = {WxMaAutoConfiguration.class})
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@MapperScan(basePackages ={"co.yixiang.modules.*.service.mapper", "co.yixiang.config"})
|
@MapperScan(basePackages ={"co.yixiang.modules.*.service.mapper", "co.yixiang.config"})
|
||||||
public class AppRun {
|
public class AppRun {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package co.yixiang;
|
package co.yixiang;
|
||||||
|
|
||||||
import co.yixiang.utils.SpringContextHolder;
|
import co.yixiang.utils.SpringContextHolder;
|
||||||
|
import com.binarywang.spring.starter.wxjava.miniapp.config.WxMaAutoConfiguration;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
@ -18,7 +19,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@EnableCaching
|
@EnableCaching
|
||||||
@MapperScan({"co.yixiang.modules.*.service.mapper"})
|
@MapperScan({"co.yixiang.modules.*.service.mapper"})
|
||||||
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class , WxMaAutoConfiguration.class})
|
||||||
public class ApiRun {
|
public class ApiRun {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -26,6 +26,7 @@ import co.yixiang.modules.user.service.YxUserService;
|
|||||||
import co.yixiang.modules.user.service.dto.WechatUserDto;
|
import co.yixiang.modules.user.service.dto.WechatUserDto;
|
||||||
import co.yixiang.modules.user.vo.OnlineUser;
|
import co.yixiang.modules.user.vo.OnlineUser;
|
||||||
import co.yixiang.mp.config.WxMpConfiguration;
|
import co.yixiang.mp.config.WxMpConfiguration;
|
||||||
|
import co.yixiang.tools.config.WxMaConfiguration;
|
||||||
import co.yixiang.utils.EncryptUtils;
|
import co.yixiang.utils.EncryptUtils;
|
||||||
import co.yixiang.utils.RedisUtils;
|
import co.yixiang.utils.RedisUtils;
|
||||||
import co.yixiang.utils.ShopKeyUtils;
|
import co.yixiang.utils.ShopKeyUtils;
|
||||||
@ -61,9 +62,7 @@ public class AuthService {
|
|||||||
|
|
||||||
private final YxUserService userService;
|
private final YxUserService userService;
|
||||||
private final RedisUtils redisUtil;
|
private final RedisUtils redisUtil;
|
||||||
private final WxMaService wxMaService;
|
|
||||||
private final RedisUtils redisUtils;
|
private final RedisUtils redisUtils;
|
||||||
|
|
||||||
private static Integer expiredTimeIn;
|
private static Integer expiredTimeIn;
|
||||||
|
|
||||||
|
|
||||||
@ -93,11 +92,7 @@ public class AuthService {
|
|||||||
if (StrUtil.isBlank(appId) || StrUtil.isBlank(secret)) {
|
if (StrUtil.isBlank(appId) || StrUtil.isBlank(secret)) {
|
||||||
throw new YshopException("请先配置小程序");
|
throw new YshopException("请先配置小程序");
|
||||||
}
|
}
|
||||||
WxMaDefaultConfigImpl wxMaConfig = new WxMaDefaultConfigImpl();
|
WxMaService wxMaService = WxMaConfiguration.getWxMaService();
|
||||||
wxMaConfig.setAppid(appId);
|
|
||||||
wxMaConfig.setSecret(secret);
|
|
||||||
|
|
||||||
wxMaService.setWxMaConfig(wxMaConfig);
|
|
||||||
WxMaJscode2SessionResult session = wxMaService.getUserService().getSessionInfo(code);
|
WxMaJscode2SessionResult session = wxMaService.getUserService().getSessionInfo(code);
|
||||||
WxMaUserInfo wxMpUser = wxMaService.getUserService()
|
WxMaUserInfo wxMpUser = wxMaService.getUserService()
|
||||||
.getUserInfo(session.getSessionKey(), encryptedData, iv);
|
.getUserInfo(session.getSessionKey(), encryptedData, iv);
|
||||||
|
@ -21,12 +21,15 @@ import co.yixiang.modules.user.domain.YxUser;
|
|||||||
import co.yixiang.modules.user.service.YxUserService;
|
import co.yixiang.modules.user.service.YxUserService;
|
||||||
import co.yixiang.modules.wechat.rest.param.BindPhoneParam;
|
import co.yixiang.modules.wechat.rest.param.BindPhoneParam;
|
||||||
import co.yixiang.modules.wechat.rest.param.WxPhoneParam;
|
import co.yixiang.modules.wechat.rest.param.WxPhoneParam;
|
||||||
|
import co.yixiang.mp.config.WxMpConfiguration;
|
||||||
|
import co.yixiang.tools.config.WxMaConfiguration;
|
||||||
import co.yixiang.utils.RedisUtils;
|
import co.yixiang.utils.RedisUtils;
|
||||||
import co.yixiang.utils.ShopKeyUtils;
|
import co.yixiang.utils.ShopKeyUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import me.chanjar.weixin.common.error.WxErrorException;
|
import me.chanjar.weixin.common.error.WxErrorException;
|
||||||
|
import me.chanjar.weixin.mp.api.WxMpService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -45,7 +48,6 @@ import java.util.Map;
|
|||||||
@Api(value = "微信其他", tags = "微信:微信其他", description = "微信其他")
|
@Api(value = "微信其他", tags = "微信:微信其他", description = "微信其他")
|
||||||
public class WxMaUserController {
|
public class WxMaUserController {
|
||||||
|
|
||||||
private final WxMaService wxMaService;
|
|
||||||
private final YxUserService userService;
|
private final YxUserService userService;
|
||||||
private final RedisUtils redisUtils;
|
private final RedisUtils redisUtils;
|
||||||
|
|
||||||
@ -91,10 +93,7 @@ public class WxMaUserController {
|
|||||||
if (StrUtil.isBlank(appId) || StrUtil.isBlank(secret)) {
|
if (StrUtil.isBlank(appId) || StrUtil.isBlank(secret)) {
|
||||||
throw new YshopException("请先配置小程序");
|
throw new YshopException("请先配置小程序");
|
||||||
}
|
}
|
||||||
WxMaDefaultConfigImpl wxMaConfig = new WxMaDefaultConfigImpl();
|
WxMaService wxMaService = WxMaConfiguration.getWxMaService();
|
||||||
wxMaConfig.setAppid(appId);
|
|
||||||
wxMaConfig.setSecret(secret);
|
|
||||||
wxMaService.setWxMaConfig(wxMaConfig);
|
|
||||||
String phone = "";
|
String phone = "";
|
||||||
try {
|
try {
|
||||||
WxMaJscode2SessionResult session = wxMaService.getUserService()
|
WxMaJscode2SessionResult session = wxMaService.getUserService()
|
||||||
|
Reference in New Issue
Block a user