修改微信授权逻辑
This commit is contained in:
@@ -20,4 +20,6 @@ public interface AppUserMapper extends BaseMapper<AppUser>
|
||||
public List<AppUser> selectAppUserList(AppUser appUser);
|
||||
|
||||
List<AppUser> selectByJobId(Long jobId);
|
||||
|
||||
AppUser selectByOpenid(String openid);
|
||||
}
|
||||
|
@@ -52,4 +52,6 @@ public interface IAppUserService
|
||||
public int deleteAppUserByUserIds(Long[] userIds);
|
||||
|
||||
public AppUser getPhone(String phone);
|
||||
|
||||
AppUser selectByOpenid(String openid);
|
||||
}
|
||||
|
@@ -108,4 +108,9 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
|
||||
return appUserMapper.selectOne(new LambdaQueryWrapper<AppUser>()
|
||||
.eq(AppUser::getPhone, phone));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppUser selectByOpenid(String openid) {
|
||||
return appUserMapper.selectByOpenid(openid);
|
||||
}
|
||||
}
|
||||
|
@@ -266,6 +266,15 @@ public class WechatUtil {
|
||||
byte[] sessionKeyBytes = Base64.getDecoder().decode(sessionKey);
|
||||
byte[] ivBytes = Base64.getDecoder().decode(iv);
|
||||
|
||||
// 2. 验证session_key长度(AES-128要求密钥长度为16字节)
|
||||
if (sessionKeyBytes.length != 16) {
|
||||
throw new RuntimeException("session_key长度错误,应为16字节");
|
||||
}
|
||||
// 验证iv长度(CBC模式下iv长度必须与块大小一致,AES为16字节)
|
||||
if (ivBytes.length != 16) {
|
||||
throw new RuntimeException("iv长度错误,应为16字节");
|
||||
}
|
||||
|
||||
// 2. 初始化 AES-128-CBC 解密器(使用PKCS5Padding替换PKCS7Padding,两者在AES中效果一致)
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
SecretKeySpec keySpec = new SecretKeySpec(sessionKeyBytes, "AES");
|
||||
|
@@ -62,4 +62,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
INNER JOIN JOB_APPLY ja ON ja.USER_ID = au.USER_ID
|
||||
WHERE au.DEL_FLAG = '0' AND ja.DEL_FLAG = '0' AND ja.JOB_Id = #{jobId})
|
||||
</select>
|
||||
|
||||
<select id="selectByOpenid" resultType="com.ruoyi.common.core.domain.entity.AppUser">
|
||||
SELECT * FROM app_user WHERE DEL_FLAG = '0' and openid=#{openid} LIMIT 1
|
||||
</select>
|
||||
</mapper>
|
Reference in New Issue
Block a user