mirror of
https://gitee.com/mmsAdmin/mms
synced 2025-12-06 17:08:54 +08:00
优化 SysSign
This commit is contained in:
parent
57fdb22006
commit
04cfe055ec
@ -2,6 +2,7 @@ package com.sxpcwlkj.framework.mapper;
|
|||||||
|
|
||||||
import com.sxpcwlkj.datasource.mapper.BaseMapperPlus;
|
import com.sxpcwlkj.datasource.mapper.BaseMapperPlus;
|
||||||
import com.sxpcwlkj.framework.entity.SysSign;
|
import com.sxpcwlkj.framework.entity.SysSign;
|
||||||
|
import org.apache.ibatis.annotations.Insert;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@ -13,4 +14,6 @@ import org.springframework.stereotype.Repository;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface SysSignMapper extends BaseMapperPlus<SysSign,SysSign> {
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.sxpcwlkj.framework.sercice.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DateField;
|
import cn.hutool.core.date.DateField;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.sxpcwlkj.authority.LoginObject;
|
import com.sxpcwlkj.authority.LoginObject;
|
||||||
import com.sxpcwlkj.common.constant.Constants;
|
import com.sxpcwlkj.common.constant.Constants;
|
||||||
@ -53,11 +54,14 @@ public class SysSignServiceImpl implements SysSignService {
|
|||||||
SysSign sysSign = getSign();
|
SysSign sysSign = getSign();
|
||||||
if(sysSign==null){
|
if(sysSign==null){
|
||||||
sysSign=new SysSign();
|
sysSign=new SysSign();
|
||||||
|
sysSign.setId(IdUtil.getSnowflakeNextId());
|
||||||
sysSign.setAppId(appid);
|
sysSign.setAppId(appid);
|
||||||
sysSign.setSecretKey(Objects.requireNonNull(SignUtil.getAesKey()).getSecretKey());
|
sysSign.setSecretKey(Objects.requireNonNull(SignUtil.getAesKey()).getSecretKey());
|
||||||
sysSign.setTimeOut(DateUtil.offset(new Date(), DateField.SECOND, timeOut));
|
sysSign.setTimeOut(DateUtil.offset(new Date(), DateField.SECOND, timeOut));
|
||||||
sysSign.setUserId(LoginObject.getLoginId());
|
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){
|
if(flag){
|
||||||
RedisUtil.setCacheObject(RedisConstant.ENCRYPTION_APP_ID+LoginObject.getLoginId(), sysSign);
|
RedisUtil.setCacheObject(RedisConstant.ENCRYPTION_APP_ID+LoginObject.getLoginId(), sysSign);
|
||||||
RedisUtil.expire(RedisConstant.ENCRYPTION_APP_ID+LoginObject.getLoginId(), Duration.ofSeconds(10));
|
RedisUtil.expire(RedisConstant.ENCRYPTION_APP_ID+LoginObject.getLoginId(), Duration.ofSeconds(10));
|
||||||
|
|||||||
@ -142,12 +142,12 @@ public class WeChatController {
|
|||||||
if (encType == null) {
|
if (encType == null) {
|
||||||
// 明文传输的消息
|
// 明文传输的消息
|
||||||
WxMpXmlMessage inMessage = WxMpXmlMessage.fromXml(requestBody);
|
WxMpXmlMessage inMessage = WxMpXmlMessage.fromXml(requestBody);
|
||||||
log.error("\n消息内容为:\n{} ", inMessage.toString());
|
log.error("\n微信公众号扫码后的回调消息内容为:\n{} ", inMessage.toString());
|
||||||
return wxCodeService.scanCallBack(inMessage);
|
return wxCodeService.scanCallBack(inMessage);
|
||||||
} else if ("aes".equalsIgnoreCase(encType)) {
|
} else if ("aes".equalsIgnoreCase(encType)) {
|
||||||
// aes加密的消息
|
// aes加密的消息
|
||||||
WxMpXmlMessage inMessage = WxMpXmlMessage.fromEncryptedXml(requestBody, wxService.getWxMpService().getWxMpConfigStorage(), timestamp, nonce, msgSignature);
|
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 wxCodeService.scanCallBack(inMessage);
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user