Merge remote-tracking branch 'origin/master' into doc

This commit is contained in:
MMS 2025-08-25 01:04:30 +08:00
commit 3c55bd1b2c
3 changed files with 10 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package com.sxpcwlkj.framework.mapper;
import com.sxpcwlkj.datasource.mapper.BaseMapperPlus;
import com.sxpcwlkj.framework.entity.SysSign;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
@ -13,4 +14,6 @@ import org.springframework.stereotype.Repository;
@Repository
public interface SysSignMapper extends BaseMapperPlus<SysSign,SysSign> {
@Insert("insert into sys_sign(id,user_id,app_id,secret_key,public_key,private_key,time_out,created_time,created_by) values(#{id},#{userId},#{appId},#{secretKey},#{publicKey},#{privateKey},#{timeOut},#{createdTime},#{createdBy})")
int initSign(SysSign sysSign);
}

View File

@ -2,6 +2,7 @@ package com.sxpcwlkj.framework.sercice.impl;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sxpcwlkj.authority.LoginObject;
import com.sxpcwlkj.common.constant.Constants;
@ -53,11 +54,14 @@ public class SysSignServiceImpl implements SysSignService {
SysSign sysSign = getSign();
if(sysSign==null){
sysSign=new SysSign();
sysSign.setId(IdUtil.getSnowflakeNextId());
sysSign.setAppId(appid);
sysSign.setSecretKey(Objects.requireNonNull(SignUtil.getAesKey()).getSecretKey());
sysSign.setTimeOut(DateUtil.offset(new Date(), DateField.SECOND, timeOut));
sysSign.setUserId(LoginObject.getLoginId());
boolean flag = sysSignMapper.insert(sysSign)>0;
sysSign.setCreatedBy(LoginObject.isLogin()?Long.parseLong(Objects.requireNonNull(LoginObject.getLoginId())):0);
sysSign.setCreatedTime(new Date());
boolean flag = sysSignMapper.initSign(sysSign)>0;
if(flag){
RedisUtil.setCacheObject(RedisConstant.ENCRYPTION_APP_ID+LoginObject.getLoginId(), sysSign);
RedisUtil.expire(RedisConstant.ENCRYPTION_APP_ID+LoginObject.getLoginId(), Duration.ofSeconds(10));

View File

@ -142,12 +142,12 @@ public class WeChatController {
if (encType == null) {
// 明文传输的消息
WxMpXmlMessage inMessage = WxMpXmlMessage.fromXml(requestBody);
log.error("\n消息内容为:\n{} ", inMessage.toString());
log.error("\n微信公众号扫码后的回调消息内容为:\n{} ", inMessage.toString());
return wxCodeService.scanCallBack(inMessage);
} else if ("aes".equalsIgnoreCase(encType)) {
// aes加密的消息
WxMpXmlMessage inMessage = WxMpXmlMessage.fromEncryptedXml(requestBody, wxService.getWxMpService().getWxMpConfigStorage(), timestamp, nonce, msgSignature);
log.error("\n消息解密后内容为:\n{} ", inMessage.toString());
log.error("\n微信公众号扫码后的回调消息解密后内容为:\n{} ", inMessage.toString());
return wxCodeService.scanCallBack(inMessage);
}
return "";