From 1038dbefc8ad51809a1b586f92fe5dce9fd3156d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= <2270033969@qq.com> Date: Mon, 10 Mar 2025 08:56:08 +0800 Subject: [PATCH] =?UTF-8?q?refactor(login):=20=E5=88=A0=E9=99=A4=20`WeChat?= =?UTF-8?q?CPLoginHandler`=20=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除 `WeChatCPLoginHandler` 类,该类用于处理企业微信登录逻辑。此次删除可能是由于功能重构或不再需要该登录方式。 --- .../admin/handler/WeChatCPLoginHandler.java | 107 ------------------ 1 file changed, 107 deletions(-) delete mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/handler/WeChatCPLoginHandler.java diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/handler/WeChatCPLoginHandler.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/handler/WeChatCPLoginHandler.java deleted file mode 100644 index 5c55a435b..000000000 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/handler/WeChatCPLoginHandler.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - */ - -package com.pig4cloud.pigx.admin.handler; - -import cn.hutool.http.HttpUtil; -import cn.hutool.json.JSONUtil; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.pig4cloud.pigx.admin.api.dto.UserInfo; -import com.pig4cloud.pigx.admin.api.entity.SysSocialDetails; -import com.pig4cloud.pigx.admin.api.entity.SysUser; -import com.pig4cloud.pigx.admin.mapper.SysSocialDetailsMapper; -import com.pig4cloud.pigx.admin.service.SysUserService; -import com.pig4cloud.pigx.common.core.constant.enums.LoginTypeEnum; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - * @author lengleng - * @date 2023-10-14 - *

- * 企业微信登录 - */ -@Slf4j -@Component("WEIXIN_CP") -@RequiredArgsConstructor -public class WeChatCPLoginHandler extends AbstractLoginHandler { - - private final SysUserService sysUserService; - - private final SysSocialDetailsMapper sysSocialDetailsMapper; - - /** - * 企微登录传入code - *

- * 通过code 调用获取唯一标识 - * - * @param code - * @return - */ - @Override - public String identify(String code) { - SysSocialDetails condition = new SysSocialDetails(); - condition.setType(LoginTypeEnum.WEIXIN_CP.getType()); - SysSocialDetails socialDetails = sysSocialDetailsMapper.selectOne(new QueryWrapper<>(condition)); - - String getAccessTokenUrl = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=%s&corpsecret=%s"; - - String accessTokenResult = HttpUtil - .get(String.format(getAccessTokenUrl, socialDetails.getAppId(), socialDetails.getAppSecret())); - log.debug("获取企业微信Token响应报文:{}", accessTokenResult); - String accessToken = JSONUtil.parseObj(accessTokenResult).getStr("access_token"); - String getUserIdUrl = "https://qyapi.weixin.qq.com/cgi-bin/auth/getuserinfo?access_token=%s&code=%s"; - String userResult = HttpUtil.get(String.format(getUserIdUrl, accessToken, code)); - log.debug("获取企业微信UserId响应报文:{}", userResult); - // 企微唯一标识 - return JSONUtil.parseObj(userResult).getStr("userid"); - } - - /** - * openId 获取用户信息 - * - * @param openId - * @return - */ - @Override - public UserInfo info(String openId) { - SysUser user = sysUserService.getOne(Wrappers.query().lambda().eq(SysUser::getWxCpUserid, openId)); - - if (user == null) { - log.info("企业微信未绑定:{}", openId); - return null; - } - return sysUserService.findUserInfo(user); - } - - /** - * 绑定逻辑 - * - * @param user 用户实体 - * @param identify 渠道返回唯一标识 - * @return - */ - @Override - public Boolean bind(SysUser user, String identify) { - user.setWxCpUserid(identify); - sysUserService.updateById(user); - return true; - } - -}