类 UserThirdpartWeiXinController
java.lang.Object
net.sohelp.boot.admin.core.base.BaseController
net.sohelp.boot.demo.web.user.UserThirdpartWeiXinController
@RestController("admin-user-thirdpart-weixin")
@RequestMapping("/admin/user/weixin")
public class UserThirdpartWeiXinController
extends BaseController
微信第三方
- 从以下版本开始:
- 2024/10/22 16:33
- 作者:
- ShenganWu
-
字段概要
从类继承的字段 net.sohelp.boot.admin.core.base.BaseController
request, response -
构造器概要
构造器 -
方法概要
从类继承的方法 net.sohelp.boot.admin.core.base.BaseController
error, error, fail, fail, fail, getLoginID, getLoginName, getLoginOrgID, getLoginOrgName, getLoginUser, getNickname, getTenantId, getUserName, getUserNo, i18n, i18n, isAdministrator, isDeveloper, limit, offset, ok, ok, response, response, responseStream, success, success, success, success, validateToken
-
构造器详细资料
-
UserThirdpartWeiXinController
public UserThirdpartWeiXinController()
-
-
方法详细资料
-
wxBinding
@GetMapping("/binding") @Permission("") public ApiResult wxBinding() throws IOException, TokenAuthenticationException发起微信绑定请求,跳转至微信扫码授权页面。此方法会从系统缓存中读取微信登录相关配置,并验证是否启用、是否已正确配置 AppId、密钥及回调地址等必要参数, 若校验通过则构造微信扫码登录链接并进行重定向。
- 返回:
- 成功时返回 null(表示重定向),失败时返回错误提示信息
- 抛出:
IOException- IO 异常TokenAuthenticationException- 认证异常
-
invokeWxBinding
@RequestMapping(value="/binding/callback", method={GET,POST}) @Transactional(rollbackFor=java.lang.Exception.class) public ApiResult invokeWxBinding(@RequestParam Map paramMap) throws Exception 微信授权后的回调接口,用于处理用户与微信账号的绑定逻辑。接收来自微信服务器的 code 和 userId 参数,使用 code 获取 access_token 及用户 openid, 然后删除旧的绑定记录并插入新的绑定关系。最后重定向到用户信息页或错误页。
- 参数:
paramMap- 请求参数集合,包括 code 和 userId 等字段- 返回:
- 返回 null 表示已完成重定向操作
- 抛出:
Exception- 操作过程中可能抛出的各种异常
-
wxUnbind
@PostMapping("/wx/unbind") @Permission("") @Transactional(rollbackFor=java.lang.Exception.class) public ApiResult wxUnbind() throws Exception解除当前登录用户与其绑定的微信账号之间的关联。执行数据库删除操作,移除该用户在 pb_user_thirdpart 表中类型为 0 的记录(即微信绑定)。
- 返回:
- 解绑结果提示信息
- 抛出:
Exception- 数据库操作或其他业务层异常
-