Browse Source

测试微信登录

zyh
Loki 3 years ago
parent
commit
73877d675a
  1. 8
      yudao-framework/yudao-spring-boot-starter-biz-weixin/src/main/java/cn/iocoder/yudao/config/WxCpConfigure.java
  2. 6
      yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java
  3. 2
      yudao-ui-admin

8
yudao-framework/yudao-spring-boot-starter-biz-weixin/src/main/java/cn/iocoder/yudao/config/WxCpConfigure.java

@ -4,17 +4,25 @@ import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
@Configuration
@Slf4j
public class WxCpConfigure {
@Value("${corpId}")
private String corpId;
private String farmAppid;
private String farmSecret;
@Bean
@Scope("singleton")
public WxCpService wxCpService(){
log.info("333:{}",corpId);
WxCpDefaultConfigImpl config = new WxCpDefaultConfigImpl();
config.setCorpId("wwb9f9734e8e124761");

6
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java

@ -29,6 +29,7 @@ import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.WxCpMaJsCode2SessionResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -65,6 +66,10 @@ public class AuthController {
@Resource
private WxCpService wxCpService;
@Value("${farm_secret}")
private String farmSecret;
@PostMapping("/login")
@ApiOperation("使用账号密码登录")
@OperateLog(enable = false) // 避免 Post 请求被记录操作日志
@ -77,6 +82,7 @@ public class AuthController {
@PostMapping("/loginByCp")
@ApiOperation("微信小程序登录")
public CommonResult<AuthLoginRespVO> loginByMxApp(String code) throws WxErrorException {
log.info("farmSecret:{}",farmSecret);
// 企业微信登录
CpUserDO cpuser;
if ("zhanyonghui".equals(code)){

2
yudao-ui-admin

@ -1 +1 @@
Subproject commit 8db432a76334b37b1a9c20fb16287fd0c9e57fe0
Subproject commit 940f54e876f1c6ccc6e239c5990d34e83fb02b78
Loading…
Cancel
Save