测试微信登录

This commit is contained in:
2022-05-23 14:14:36 +08:00
parent e9d29ef2df
commit 73877d675a
3 changed files with 15 additions and 1 deletions
@@ -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");
@@ -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)){