Compare commits
No commits in common. "9e0538db20dd0ad86c6d2b8a4365810163c91706" and "05f96f68cc40103d664e3a56507ca3b634fb05f3" have entirely different histories.
9e0538db20
...
05f96f68cc
|
|
@ -23,7 +23,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.DigestUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
@ -53,8 +52,6 @@ public class OAuth2Controller extends BaseController {
|
|||
@Autowired
|
||||
private IImsUserService iImsUserService;
|
||||
@Autowired
|
||||
private IUserSupInfoService userSupInfoService;
|
||||
@Autowired
|
||||
private OrgUM orgUM;
|
||||
@Autowired
|
||||
private IUnifiedAuthService unifiedAuthService;
|
||||
|
|
@ -645,20 +642,12 @@ public class OAuth2Controller extends BaseController {
|
|||
}
|
||||
// 查询绑定的账号
|
||||
String usercode = one.getUsercode();
|
||||
ImsUser imsUser = iImsUserService.getById(usercode);
|
||||
if (imsUser == null) {
|
||||
TUsers tuser = usersService.lambdaQuery().eq(TUsers::getImsusercode, usercode).last("limit 1").one();
|
||||
if (tuser == null) {
|
||||
return ResponseEntity.status(HttpStatus.FOUND)
|
||||
.location(java.net.URI.create("/integration/#/login?requestId=" + requestId + "&error=" + URLEncoder.encode("无匹配的综合监管用户,请联系系统管理员", "UTF-8")))
|
||||
.build();
|
||||
}
|
||||
String idCard = SM4Utils.decrypt(imsUser.getIdCard(), sm4Key);
|
||||
UserSupInfo userSup = userSupInfoService.lambdaQuery().eq(UserSupInfo::getIdcardAbstr, DigestUtils.md5DigestAsHex(idCard.getBytes())).one();
|
||||
if (userSup == null) {
|
||||
return ResponseEntity.status(HttpStatus.FOUND)
|
||||
.location(java.net.URI.create("/integration/#/login?requestId=" + requestId + "&error=" + URLEncoder.encode("无匹配的综合监管用户,请联系系统管理员", "UTF-8")))
|
||||
.build();
|
||||
}
|
||||
TUsers tuser = usersService.getById(userSup.getUserid());
|
||||
|
||||
RestResult<AICUser> loginResult = userBaseService.login(tuser.getUsername(), "ChinaWeal_2026");
|
||||
AICUser user = loginResult.getData();
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@ package com.chinaweal.aiccs.org.controller;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.chinaweal.aiccs.common.util.RSAUTil;
|
||||
import com.chinaweal.aiccs.common.util.SM4Utils;
|
||||
import com.chinaweal.aiccs.common.util.StringUtils;
|
||||
import com.chinaweal.aiccs.org.entity.UserSupInfo;
|
||||
import com.chinaweal.aiccs.org.service.IUserSupInfoService;
|
||||
import com.chinaweal.aiccs.org.entity.TUsersapp;
|
||||
import com.chinaweal.aiccs.org.service.TUsersappService;
|
||||
import com.chinaweal.aiccs.redis.RedisService;
|
||||
import com.chinaweal.youfool.framework.springboot.exception.custom.BusinessException;
|
||||
import com.chinaweal.youfool.framework.springboot.rest.RestResult;
|
||||
|
|
@ -17,14 +16,12 @@ import io.swagger.annotations.ApiParam;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.util.DigestUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.KeyPair;
|
||||
import java.security.KeyPairGenerator;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
|
@ -43,22 +40,20 @@ import java.util.Base64;
|
|||
public class TUsersappController {
|
||||
|
||||
@Autowired
|
||||
private IUserSupInfoService userSupInfoService;
|
||||
private TUsersappService tUsersappService;
|
||||
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
@Value("${redis-usersapp-privatekey.expire:300}")
|
||||
private int privateKeyExpire;
|
||||
@Value("${oauth2.sm4.key}")
|
||||
private String sm4Key;
|
||||
|
||||
private static final String REDIS_PRIVATE_KEY_PREFIX = "usersapp:rsa:privatekey:";
|
||||
|
||||
private static final String RSA_COOKIE_KEY = "usersapprsa";
|
||||
|
||||
/**
|
||||
* 接口1:检查用户对应的UserSupInfo中有没有身份证号和手机号码的记录
|
||||
* 接口1:检查用户对应的TUsersapp中有没有身份证号和手机号码的记录
|
||||
*
|
||||
* @param request 请求
|
||||
* @return true-有完整记录,false-没有完整记录
|
||||
|
|
@ -70,9 +65,9 @@ public class TUsersappController {
|
|||
if (StringUtils.isBlank(userId)) {
|
||||
return RestResult.error(com.chinaweal.youfool.framework.springboot.rest.ResultCode.USER_NOT_LOGGED_IN);
|
||||
}
|
||||
UserSupInfo byId = userSupInfoService.getById(userId);
|
||||
TUsersapp byId = tUsersappService.getById(userId);
|
||||
|
||||
return RestResult.ok(byId != null && StringUtils.isNotBlank(byId.getMobileEnc()) && StringUtils.isNotBlank(byId.getIdcardEnc()));
|
||||
return RestResult.ok(byId != null && StringUtils.isNotBlank(byId.getMobile()) && StringUtils.isNotBlank(byId.getIdentityno()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -81,7 +76,6 @@ public class TUsersappController {
|
|||
* Redis的key后缀使用cookie中的值
|
||||
*
|
||||
* @param request 请求
|
||||
* @param response response
|
||||
* @return 公钥
|
||||
*/
|
||||
@GetMapping("/getPublicKey")
|
||||
|
|
@ -117,10 +111,9 @@ public class TUsersappController {
|
|||
/**
|
||||
* 接口3:用户账号信息设置接口
|
||||
* 用户传入身份证号(RSA密文)、手机号(RSA密文)
|
||||
* 使用RSA解密后得到明文,然后使用SM4加密存储到数据库,同时计算MD5摘要用于去重
|
||||
* 查询UserSupInfo表,确保数据是唯一的
|
||||
* 将证件号和手机号解密后,查询TUsersapp表,确保数据是唯一的
|
||||
* 如果不唯一,则抛出BusinessException说明信息已被占用
|
||||
* 否则创建或更新UserSupInfo的记录
|
||||
* 否则创建或更新TUsersapp的记录
|
||||
*
|
||||
* @param identityNoEncrypted 身份证号密文
|
||||
* @param mobileEncrypted 手机号密文
|
||||
|
|
@ -151,50 +144,38 @@ public class TUsersappController {
|
|||
}
|
||||
|
||||
try {
|
||||
// 使用RSA解密前端传来的数据
|
||||
// 解密身份证号和手机号
|
||||
String identityNo = RSAUTil.decrypt(identityNoEncrypted, privateKeyString);
|
||||
String mobile = RSAUTil.decrypt(mobileEncrypted, privateKeyString);
|
||||
|
||||
// 计算MD5摘要(用于去重)
|
||||
String identityNoAbstr = DigestUtils.md5DigestAsHex(identityNo.getBytes(StandardCharsets.UTF_8));
|
||||
String mobileAbstr = DigestUtils.md5DigestAsHex(mobile.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// 查询是否存在相同的身份证号或手机号(排除当前用户)
|
||||
LambdaQueryWrapper<UserSupInfo> wrapper = new LambdaQueryWrapper<>();
|
||||
LambdaQueryWrapper<TUsersapp> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.and(w -> w
|
||||
.eq(UserSupInfo::getIdcardAbstr, identityNoAbstr)
|
||||
.eq(TUsersapp::getIdentityno, identityNo)
|
||||
.or()
|
||||
.eq(UserSupInfo::getMobileAbstr, mobileAbstr)
|
||||
).ne(UserSupInfo::getUserid, userId);
|
||||
.eq(TUsersapp::getMobile, mobile)
|
||||
).ne(TUsersapp::getUserid, userId);
|
||||
|
||||
long count = userSupInfoService.count(wrapper);
|
||||
long count = tUsersappService.count(wrapper);
|
||||
if (count > 0) {
|
||||
throw new BusinessException("身份证号或手机号已被其他用户占用");
|
||||
}
|
||||
|
||||
// 使用SM4加密后存储到数据库
|
||||
String identityNoEnc = SM4Utils.encrypt(identityNo, sm4Key);
|
||||
String mobileEnc = SM4Utils.encrypt(mobile, sm4Key);
|
||||
|
||||
// 查询当前用户的UserSupInfo记录
|
||||
UserSupInfo existUser = userSupInfoService.getById(userId);
|
||||
// 查询当前用户的TUsersapp记录
|
||||
TUsersapp existUser = tUsersappService.getById(userId);
|
||||
|
||||
if (existUser != null) {
|
||||
// 更新记录
|
||||
existUser.setIdcardEnc(identityNoEnc);
|
||||
existUser.setIdcardAbstr(identityNoAbstr);
|
||||
existUser.setMobileEnc(mobileEnc);
|
||||
existUser.setMobileAbstr(mobileAbstr);
|
||||
userSupInfoService.updateById(existUser);
|
||||
existUser.setIdentityno(identityNo);
|
||||
existUser.setMobile(mobile);
|
||||
tUsersappService.updateById(existUser);
|
||||
} else {
|
||||
// 创建新记录
|
||||
UserSupInfo newUser = new UserSupInfo();
|
||||
TUsersapp newUser = new TUsersapp();
|
||||
newUser.setUserid(userId);
|
||||
newUser.setIdcardEnc(identityNoEnc);
|
||||
newUser.setIdcardAbstr(identityNoAbstr);
|
||||
newUser.setMobileEnc(mobileEnc);
|
||||
newUser.setMobileAbstr(mobileAbstr);
|
||||
userSupInfoService.save(newUser);
|
||||
newUser.setIdentityno(identityNo);
|
||||
newUser.setMobile(mobile);
|
||||
tUsersappService.save(newUser);
|
||||
}
|
||||
|
||||
// 删除Redis中的私钥
|
||||
|
|
@ -216,6 +197,7 @@ public class TUsersappController {
|
|||
Cookie[] cookies = request.getCookies();
|
||||
if (cookies != null) {
|
||||
for (Cookie cookie : cookies) {
|
||||
// 根据实际情况修改cookie名称
|
||||
if (cookieKey.equals(cookie.getName())) {
|
||||
return cookie.getValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,71 +0,0 @@
|
|||
package com.chinaweal.aiccs.org.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户补充信息
|
||||
* </p>
|
||||
*
|
||||
* @author system
|
||||
* @since 2026-03-26
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName(value = "USER_SUP_INFO", schema = "CXAICORG")
|
||||
@ApiModel("用户补充信息")
|
||||
public class UserSupInfo extends Model<UserSupInfo> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableId("USERID")
|
||||
@ApiModelProperty("用户id")
|
||||
private String userid;
|
||||
|
||||
/**
|
||||
* 手机号(密文)
|
||||
*/
|
||||
@TableField("MOBILE_ENC")
|
||||
@ApiModelProperty("手机号(密文)")
|
||||
private String mobileEnc;
|
||||
|
||||
/**
|
||||
* 手机号(MD5的摘要)
|
||||
*/
|
||||
@TableField("MOBILE_ABSTR")
|
||||
@ApiModelProperty("手机号(MD5的摘要)")
|
||||
private String mobileAbstr;
|
||||
|
||||
/**
|
||||
* 身份证号(密文)
|
||||
*/
|
||||
@TableField("IDCARD_ENC")
|
||||
@ApiModelProperty("身份证号(密文)")
|
||||
private String idcardEnc;
|
||||
|
||||
/**
|
||||
* 身份证号(MD5摘要)
|
||||
*/
|
||||
@TableField("IDCARD_ABSTR")
|
||||
@ApiModelProperty("身份证号(MD5摘要)")
|
||||
private String idcardAbstr;
|
||||
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
return this.userid;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
package com.chinaweal.aiccs.org.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.chinaweal.aiccs.org.entity.UserSupInfo;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author system
|
||||
* @since 2026-03-26
|
||||
*/
|
||||
public interface UserSupInfoMapper extends BaseMapper<UserSupInfo> {
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
package com.chinaweal.aiccs.org.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.chinaweal.aiccs.org.entity.UserSupInfo;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户补充信息 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author system
|
||||
* @since 2026-03-26
|
||||
*/
|
||||
public interface IUserSupInfoService extends IService<UserSupInfo> {
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ package com.chinaweal.aiccs.org.service.impl;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.chinaweal.aiccs.common.constant.CommonConstants;
|
||||
import com.chinaweal.aiccs.common.util.SM4Utils;
|
||||
import com.chinaweal.aiccs.org.entity.ImsUser;
|
||||
import com.chinaweal.aiccs.org.entity.dto.ImsUserDTO;
|
||||
import com.chinaweal.aiccs.org.mapper.ImsUserMapper;
|
||||
|
|
@ -10,7 +9,6 @@ import com.chinaweal.aiccs.org.service.IImsUserService;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
|
@ -25,9 +23,6 @@ public class ImsUserServiceImpl extends ServiceImpl<ImsUserMapper, ImsUser> impl
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ImsUserServiceImpl.class);
|
||||
|
||||
@Value("${oauth2.sm4.key}")
|
||||
private String sm4Key;
|
||||
|
||||
@Override
|
||||
public boolean syncUser(ImsUserDTO dto) {
|
||||
if (dto == null || dto.getType() == null) {
|
||||
|
|
@ -82,7 +77,7 @@ public class ImsUserServiceImpl extends ServiceImpl<ImsUserMapper, ImsUser> impl
|
|||
newUser.setMobile(dto.getMobile());
|
||||
newUser.setGender(dto.getGender());
|
||||
newUser.setEmail(dto.getEmail());
|
||||
newUser.setIdCard(SM4Utils.encrypt(dto.getIdCard(), sm4Key));
|
||||
newUser.setIdCard(dto.getIdCard());
|
||||
newUser.setLandline(dto.getLandline());
|
||||
newUser.setJobna(dto.getJobna());
|
||||
newUser.setLecn(dto.getLecn());
|
||||
|
|
@ -127,7 +122,7 @@ public class ImsUserServiceImpl extends ServiceImpl<ImsUserMapper, ImsUser> impl
|
|||
user.setMobile(dto.getMobile());
|
||||
user.setGender(dto.getGender());
|
||||
user.setEmail(dto.getEmail());
|
||||
user.setIdCard(SM4Utils.encrypt(dto.getIdCard(), sm4Key));
|
||||
user.setIdCard(dto.getIdCard());
|
||||
user.setLandline(dto.getLandline());
|
||||
user.setJobna(dto.getJobna());
|
||||
user.setLecn(dto.getLecn());
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
package com.chinaweal.aiccs.org.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.chinaweal.aiccs.org.entity.UserSupInfo;
|
||||
import com.chinaweal.aiccs.org.mapper.UserSupInfoMapper;
|
||||
import com.chinaweal.aiccs.org.service.IUserSupInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户补充信息 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author system
|
||||
* @since 2026-03-26
|
||||
*/
|
||||
@Service
|
||||
public class UserSupInfoServiceImpl extends ServiceImpl<UserSupInfoMapper, UserSupInfo> implements IUserSupInfoService {
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.chinaweal.aiccs.org.mapper.UserSupInfoMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.chinaweal.aiccs.org.entity.UserSupInfo">
|
||||
<id column="USERID" property="userid"/>
|
||||
<result column="MOBILE_ENC" property="mobileEnc"/>
|
||||
<result column="MOBILE_ABSTR" property="mobileAbstr"/>
|
||||
<result column="IDCARD_ENC" property="idcardEnc"/>
|
||||
<result column="IDCARD_ABSTR" property="idcardAbstr"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
USERID, MOBILE_ENC, MOBILE_ABSTR, IDCARD_ENC, IDCARD_ABSTR
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue